Completed
Push — master ( eaa76e...0a533c )
by
unknown
13:59
created

wpshop.php ➔ wps_update_message()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 16
Code Lines 8

Duplication

Lines 3
Ratio 18.75 %

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 8
nop 2
dl 3
loc 16
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Plugin Name: WP-Shop
4
 * Plugin URI: http://www.wpshop.fr/documentations/presentation-wpshop/
5
 * Description: With this plugin you will be able to manage the products you want to sell and user would be able to buy this products
6
 * Version: 1.4.4.4
7
 * Author: Eoxia
8
 * Author URI: http://eoxia.com/
9
 */
10
11
/**
12
 * Plugin main file.
13
 *
14
 * This file is the main file called by WordPress for our plugin use. It define the basic vars and include the different file needed to use the plugin
15
 *
16
 * @author Eoxia <[email protected]>
17
 * @version 1.3
18
 * @package wpshop
19
 */
20
21
ini_set( 'memory_limit', '512M' );
22
23
/**    Check if file is include. No direct access possible with file url    */
24
if ( ! defined( 'ABSPATH' ) ) {
25
	die( 'Access is not allowed by this way' );
26
}
27
28
/**    Allows to refresh css and js file in final user browser    */
29
DEFINE( 'WPSHOP_VERSION', '1.4.4.4' );
30
31
/**    Allows to avoid problem with theme not supporting thumbnail for post    */
32
add_theme_support( 'post-thumbnails' );
33
add_image_size( 'wpshop-product-galery', 270, 270, true );
34
add_image_size( 'wps-categorie-mini-display', 80, 80, true );
35
add_image_size( 'wps-categorie-display', 480, 340, true );
36
37
/**    First thing we define the main directory for our plugin in a super global var    */
38
DEFINE( 'WPSHOP_PLUGIN_DIR', basename( dirname( __FILE__ ) ) );
39
DEFINE( 'WPSHOP_PLUGIN_NAME', plugin_basename( __FILE__ ) );
40
41
/**    Get the current language to translate the different text in plugin    */
42
$locale = get_locale();
43
global $wpdb;
44 View Code Duplication
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
	$query = $wpdb->prepare( 'SELECT locale FROM ' . $wpdb->prefix . 'icl_locale_map WHERE code = %s', ICL_LANGUAGE_CODE );
46
	$local = $wpdb->get_var( $query );
47
	$locale = ! empty( $local ) ? $local : $locale;
48
}
49
DEFINE( 'WPSHOP_CURRENT_LOCALE', $locale );
50
/**    Load plugin translation    */
51
load_plugin_textdomain( 'wpshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
52
53
/**    Include the config file    */
54
require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php';
55
56
/** Allow to get errors back when debug mode is set to true    */
57
if ( WPSHOP_DEBUG_MODE && (in_array( long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) )) ) {
58
	ini_set( 'display_errors', true );
59
	error_reporting( E_ALL );
60
}
61
62
include_once WPSHOP_LIBRAIRIES_DIR . 'init.class.php';
63
$current_installation_step = get_option( 'wps-installation-current-step', 1 );
64
65
/**    Get current plugin version    */
66
$current_db_version = get_option( 'wpshop_db_options', 0 );
67
68
/**    Call main initialisation function    */
69
add_action( 'init', array( 'wpshop_init', 'load' ) );
70
71
/**    Include the main including file    */
72
require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/include.php';
73
74
/**    Check and set (if needed) administrator(s) permissions' each time the plugin is launched. Admin role has all right    */
75
$wpshop_permissions = new wpshop_permissions();
76
$wpshop_permissions->set_administrator_role_permission();
77
$wpshop_permissions->wpshop_init_roles();
78
79
/**    Call function to create the main left menu    */
80
// if ( ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $_GET ) && !empty( $_GET[ 'installation_state' ] ) && ( "ignored" == $_GET[ 'installation_state' ] ) ) ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
81
add_action( 'admin_menu', array( 'wpshop_init', 'admin_menu' ) );
82
add_action( 'menu_order', array( 'wpshop_init', 'admin_menu_order' ) );
83
add_action( 'custom_menu_order', array( 'wpshop_init', 'admin_custom_menu_order' ) );
84
85
/*    Call function for new WordPress element creating [term (product_category) / post (product)]    */
86
add_action( 'init', array( 'wpshop_init', 'add_new_wp_type' ) );
87
88
/*    Call function allowing to change element front output    */
89
add_action( 'the_content', array( 'wpshop_display', 'products_page' ), 1 );
90
// add_action('archive_template', array('wpshop_categories', 'category_template_switcher'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
// }
92
/**    On plugin activation create the default parameters to use the ecommerce    */
93
register_activation_hook( __FILE__, array( 'wpshop_install', 'install_on_activation' ) );
94
95
/**    Get current plugin version    */
96
$current_db_version = get_option( 'wpshop_db_options', 0 );
97
98
/**    Add the database content    */
99
add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop' ) );
100
if ( (defined( 'WPSINSTALLER_STEPS_COUNT' ) && (WPSINSTALLER_STEPS_COUNT <= $current_installation_step)) || ( ! empty( $current_db_version ) && ! empty( $current_db_version['db_version'] ) && (51 < $current_db_version['db_version'])) || ( ! empty( $current_db_version ) && ! empty( $current_db_version['installation_state'] ) && ('ignore' == $current_db_version['installation_state'])) ) {
101
	if ( in_array( long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) ) ) {
102
		add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop_dev' ) );
103
	}
104
}
105
// Start session
106
if ( session_id() == '' ) {
107
	 session_start();
108
}
109
110
// WP-Shop class instanciation
111
function classes_init() {
112
	global $wpshop_cart, $wpshop, $wpshop_account, $wpshop_payment;
113
	$wpshop = new wpshop_form_management();
114
	$wpshop_payment = new wpshop_payment();
115
}
116
add_action( 'init', 'classes_init' );
117
118
/** Shortcode management */
119
add_shortcode( 'wpshop_att_val', array( 'wpshop_attributes', 'wpshop_att_val_func' ) ); // Attributes
120
add_shortcode( 'wpshop_products', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list
121
add_shortcode( 'wpshop_product', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list
122
add_shortcode( 'wpshop_product_variation_summary', array( 'wpshop_products', 'wpshop_product_variations_summary' ) ); // Variation summary
123
add_shortcode( 'wpshop_product_variation_value_detail', array( 'wpshop_products', 'wpshop_product_variation_value_detail' ) ); // Variation value detail
124
add_shortcode( 'wpshop_related_products', array( 'wpshop_products', 'wpshop_related_products_func' ) ); // Products list
125
add_shortcode( 'wpshop_category', array( 'wpshop_categories', 'wpshop_category_func' ) ); // Category
126
add_shortcode( 'wpshop_att_group', array( 'wpshop_attributes_set', 'wpshop_att_group_func' ) ); // Attributes groups
127
add_shortcode( 'wpshop_cart', 'wpshop_display_cart' ); // Cart
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
128
// add_shortcode('wpshop_mini_cart', 'wpshop_display_mini_cart'); // Mini cart
129
// add_shortcode('wpshop_signup', 'wpshop_signup_init'); // Signup
130
// add_shortcode('wpshop_myaccount', 'wpshop_account_display_form' );
131
add_shortcode( 'wpshop_payment_result', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result
132
add_shortcode( 'wpshop_payment_result_unsuccessfull', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result
133
134
add_shortcode( 'wpshop_variations', array( 'wpshop_products', 'wpshop_variation' ) );
135
add_shortcode( 'wpshop_entities', array( 'wpshop_entities', 'wpshop_entities_shortcode' ) );
136
add_shortcode( 'wpshop_attributes', array( 'wpshop_attributes', 'wpshop_attributes_shortcode' ) );
137
138
require_once 'core/external/wpeo_util/singleton.util.php';
139
require_once 'core/external/wpeo_util/init.util.php';
140
require_once 'core/external/wpeo_log/class/log.class.php';
141
\eoxia\Init_util::g()->exec( realpath( plugin_dir_path( __FILE__ ) ) . '/', basename( __FILE__, '.php' ) );
142