|
@@ -18,55 +18,55 @@ discard block |
|
|
block discarded – undo |
|
18
|
18
|
* @package wpshop |
|
19
|
19
|
*/ |
|
20
|
20
|
|
|
21
|
|
-ini_set( 'memory_limit', '512M' ); |
|
|
21
|
+ini_set('memory_limit', '512M'); |
|
22
|
22
|
|
|
23
|
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' ); |
|
|
24
|
+if (!defined('ABSPATH')) { |
|
|
25
|
+ die('Access is not allowed by this way'); |
|
26
|
26
|
} |
|
27
|
27
|
|
|
28
|
28
|
/** Allows to refresh css and js file in final user browser */ |
|
29
|
|
-DEFINE( 'WPSHOP_VERSION', '1.4.3.8' ); |
|
|
29
|
+DEFINE('WPSHOP_VERSION', '1.4.3.8'); |
|
30
|
30
|
|
|
31
|
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 ); |
|
|
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
|
36
|
|
|
37
|
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__ ) ); |
|
|
38
|
+DEFINE('WPSHOP_PLUGIN_DIR', basename(dirname(__FILE__))); |
|
|
39
|
+DEFINE('WPSHOP_PLUGIN_NAME', plugin_basename(__FILE__)); |
|
40
|
40
|
|
|
41
|
41
|
/** Get the current language to translate the different text in plugin */ |
|
42
|
42
|
$locale = get_locale(); |
|
43
|
43
|
global $wpdb; |
|
44
|
|
-if ( defined( 'ICL_LANGUAGE_CODE' ) ) { |
|
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; |
|
|
44
|
+if (defined('ICL_LANGUAGE_CODE')) { |
|
|
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
|
48
|
} |
|
49
|
|
-DEFINE( 'WPSHOP_CURRENT_LOCALE', $locale ); |
|
|
49
|
+DEFINE('WPSHOP_CURRENT_LOCALE', $locale); |
|
50
|
50
|
/** Load plugin translation */ |
|
51
|
|
-load_plugin_textdomain( 'wpshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
|
51
|
+load_plugin_textdomain('wpshop', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
52
|
52
|
|
|
53
|
53
|
/** Include the config file */ |
|
54
|
54
|
require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php'; |
|
55
|
55
|
|
|
56
|
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 ); |
|
|
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
|
60
|
} |
|
61
|
61
|
|
|
62
|
62
|
include_once WPSHOP_LIBRAIRIES_DIR . 'init.class.php'; |
|
63
|
|
-$current_installation_step = get_option( 'wps-installation-current-step', 1 ); |
|
|
63
|
+$current_installation_step = get_option('wps-installation-current-step', 1); |
|
64
|
64
|
|
|
65
|
65
|
/** Get current plugin version */ |
|
66
|
|
-$current_db_version = get_option( 'wpshop_db_options', 0 ); |
|
|
66
|
+$current_db_version = get_option('wpshop_db_options', 0); |
|
67
|
67
|
|
|
68
|
68
|
/** Call main initialisation function */ |
|
69
|
|
-add_action( 'init', array( 'wpshop_init', 'load' ) ); |
|
|
69
|
+add_action('init', array('wpshop_init', 'load')); |
|
70
|
70
|
|
|
71
|
71
|
/** Include the main including file */ |
|
72
|
72
|
require WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/include.php'; |
|
@@ -78,35 +78,35 @@ discard block |
|
|
block discarded – undo |
|
78
|
78
|
|
|
79
|
79
|
/** Call function to create the main left menu */ |
|
80
|
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' ] ) ) ) { |
|
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' ) ); |
|
|
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
|
84
|
|
|
85
|
85
|
/* Call function for new wordpress element creating [term (product_category) / post (product)] */ |
|
86
|
|
-add_action( 'init', array( 'wpshop_init', 'add_new_wp_type' ) ); |
|
|
86
|
+add_action('init', array('wpshop_init', 'add_new_wp_type')); |
|
87
|
87
|
|
|
88
|
88
|
/* Call function allowing to change element front output */ |
|
89
|
|
-add_action( 'the_content', array( 'wpshop_display', 'products_page' ), 1 ); |
|
|
89
|
+add_action('the_content', array('wpshop_display', 'products_page'), 1); |
|
90
|
90
|
// add_action('archive_template', array('wpshop_categories', 'category_template_switcher')); |
|
91
|
91
|
// } |
|
92
|
92
|
/** On plugin activation create the default parameters to use the ecommerce */ |
|
93
|
|
-register_activation_hook( __FILE__, array( 'wpshop_install', 'install_on_activation' ) ); |
|
|
93
|
+register_activation_hook(__FILE__, array('wpshop_install', 'install_on_activation')); |
|
94
|
94
|
|
|
95
|
95
|
/** On plugin deactivation call the function to clean the wordpress installation */ |
|
96
|
|
-register_deactivation_hook( __FILE__, array( 'wpshop_install', 'uninstall_wpshop' ) ); |
|
|
96
|
+register_deactivation_hook(__FILE__, array('wpshop_install', 'uninstall_wpshop')); |
|
97
|
97
|
|
|
98
|
98
|
/** Get current plugin version */ |
|
99
|
|
-$current_db_version = get_option( 'wpshop_db_options', 0 ); |
|
|
99
|
+$current_db_version = get_option('wpshop_db_options', 0); |
|
100
|
100
|
|
|
101
|
101
|
/** Add the database content */ |
|
102
|
|
-add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop' ) ); |
|
103
|
|
-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'])) ) { |
|
104
|
|
- if ( in_array( long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) ) ) { |
|
105
|
|
- add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop_dev' ) ); |
|
|
102
|
+add_action('admin_init', array('wpshop_install', 'update_wpshop')); |
|
|
103
|
+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']))) { |
|
|
104
|
+ if (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) { |
|
|
105
|
+ add_action('admin_init', array('wpshop_install', 'update_wpshop_dev')); |
|
106
|
106
|
} |
|
107
|
107
|
} |
|
108
|
108
|
// Start session |
|
109
|
|
-if(session_id() == '') |
|
|
109
|
+if (session_id() == '') |
|
110
|
110
|
session_start(); |
|
111
|
111
|
|
|
112
|
112
|
// WP-Shop class instanciation |
|
@@ -115,47 +115,47 @@ discard block |
|
|
block discarded – undo |
|
115
|
115
|
$wpshop = new wpshop_form_management(); |
|
116
|
116
|
$wpshop_payment = new wpshop_payment(); |
|
117
|
117
|
} |
|
118
|
|
-add_action( 'init', 'classes_init' ); |
|
|
118
|
+add_action('init', 'classes_init'); |
|
119
|
119
|
|
|
120
|
120
|
/** Shortcode management */ |
|
121
|
|
-add_shortcode( 'wpshop_att_val', array( 'wpshop_attributes', 'wpshop_att_val_func' ) ); // Attributes |
|
122
|
|
-add_shortcode( 'wpshop_products', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list |
|
123
|
|
-add_shortcode( 'wpshop_product', array( 'wpshop_products', 'wpshop_products_func' ) ); // Products list |
|
124
|
|
-add_shortcode( 'wpshop_product_variation_summary', array( 'wpshop_products', 'wpshop_product_variations_summary' ) ); // Variation summary |
|
125
|
|
-add_shortcode( 'wpshop_product_variation_value_detail', array( 'wpshop_products', 'wpshop_product_variation_value_detail' ) ); // Variation value detail |
|
126
|
|
-add_shortcode( 'wpshop_related_products', array( 'wpshop_products', 'wpshop_related_products_func' ) ); // Products list |
|
127
|
|
-add_shortcode( 'wpshop_category', array( 'wpshop_categories', 'wpshop_category_func' ) ); // Category |
|
128
|
|
-add_shortcode( 'wpshop_att_group', array( 'wpshop_attributes_set', 'wpshop_att_group_func' ) ); // Attributes groups |
|
129
|
|
-add_shortcode( 'wpshop_cart', 'wpshop_display_cart' ); // Cart |
|
|
121
|
+add_shortcode('wpshop_att_val', array('wpshop_attributes', 'wpshop_att_val_func')); // Attributes |
|
|
122
|
+add_shortcode('wpshop_products', array('wpshop_products', 'wpshop_products_func')); // Products list |
|
|
123
|
+add_shortcode('wpshop_product', array('wpshop_products', 'wpshop_products_func')); // Products list |
|
|
124
|
+add_shortcode('wpshop_product_variation_summary', array('wpshop_products', 'wpshop_product_variations_summary')); // Variation summary |
|
|
125
|
+add_shortcode('wpshop_product_variation_value_detail', array('wpshop_products', 'wpshop_product_variation_value_detail')); // Variation value detail |
|
|
126
|
+add_shortcode('wpshop_related_products', array('wpshop_products', 'wpshop_related_products_func')); // Products list |
|
|
127
|
+add_shortcode('wpshop_category', array('wpshop_categories', 'wpshop_category_func')); // Category |
|
|
128
|
+add_shortcode('wpshop_att_group', array('wpshop_attributes_set', 'wpshop_att_group_func')); // Attributes groups |
|
|
129
|
+add_shortcode('wpshop_cart', 'wpshop_display_cart'); // Cart |
|
130
|
130
|
// add_shortcode('wpshop_mini_cart', 'wpshop_display_mini_cart'); // Mini cart |
|
131
|
131
|
// add_shortcode('wpshop_signup', 'wpshop_signup_init'); // Signup |
|
132
|
132
|
// add_shortcode('wpshop_myaccount', 'wpshop_account_display_form' ); |
|
133
|
|
-add_shortcode( 'wpshop_payment_result', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result |
|
134
|
|
-add_shortcode( 'wpshop_payment_result_unsuccessfull', array( 'wpshop_payment', 'wpshop_payment_result' ) ); // Payment result |
|
|
133
|
+add_shortcode('wpshop_payment_result', array('wpshop_payment', 'wpshop_payment_result')); // Payment result |
|
|
134
|
+add_shortcode('wpshop_payment_result_unsuccessfull', array('wpshop_payment', 'wpshop_payment_result')); // Payment result |
|
135
|
135
|
|
|
136
|
|
-add_shortcode( 'wpshop_variations', array( 'wpshop_products', 'wpshop_variation' ) ); |
|
137
|
|
-add_shortcode( 'wpshop_entities', array( 'wpshop_entities', 'wpshop_entities_shortcode' ) ); |
|
138
|
|
-add_shortcode( 'wpshop_attributes', array( 'wpshop_attributes', 'wpshop_attributes_shortcode' ) ); |
|
|
136
|
+add_shortcode('wpshop_variations', array('wpshop_products', 'wpshop_variation')); |
|
|
137
|
+add_shortcode('wpshop_entities', array('wpshop_entities', 'wpshop_entities_shortcode')); |
|
|
138
|
+add_shortcode('wpshop_attributes', array('wpshop_attributes', 'wpshop_attributes_shortcode')); |
|
139
|
139
|
|
|
140
|
140
|
/** Add specific messages for wpshop elements management */ |
|
141
|
141
|
// add_filter('post_updated_messages', array('wpshop_messages', 'update_wp_message_list')); |
|
142
|
|
-$file = basename( __FILE__ ); |
|
143
|
|
-$folder = basename( dirname( __FILE__ ) ); |
|
|
142
|
+$file = basename(__FILE__); |
|
|
143
|
+$folder = basename(dirname(__FILE__)); |
|
144
|
144
|
$hook = "in_plugin_update_message-{$folder}/{$file}"; |
|
145
|
|
-add_action( $hook, 'wps_update_message', 10, 2 ); // 10:priority, 2:arguments # |
|
146
|
|
-function wps_update_message( $currentPluginMetadata, $newPluginMetadata ) { |
|
|
145
|
+add_action($hook, 'wps_update_message', 10, 2); // 10:priority, 2:arguments # |
|
|
146
|
+function wps_update_message($currentPluginMetadata, $newPluginMetadata) { |
|
147
|
147
|
$message = ''; |
|
148
|
148
|
|
|
149
|
|
- if ( '1.4.1.6' == $currentPluginMetadata['Version'] ) { |
|
150
|
|
- $message = sprintf( __( 'For security reason %1$splease read this post%2$s', 'wpshop' ), '<a href="" >', '</a>' ); |
|
|
149
|
+ if ('1.4.1.6' == $currentPluginMetadata['Version']) { |
|
|
150
|
+ $message = sprintf(__('For security reason %1$splease read this post%2$s', 'wpshop'), '<a href="" >', '</a>'); |
|
151
|
151
|
} |
|
152
|
152
|
|
|
153
|
153
|
// check "upgrade_notice" |
|
154
|
|
- if ( isset( $newPluginMetadata->upgrade_notice ) && strlen( trim( $newPluginMetadata->upgrade_notice ) ) > 0 ) { |
|
155
|
|
- $message = esc_html( $newPluginMetadata->upgrade_notice ); |
|
|
154
|
+ if (isset($newPluginMetadata->upgrade_notice) && strlen(trim($newPluginMetadata->upgrade_notice)) > 0) { |
|
|
155
|
+ $message = esc_html($newPluginMetadata->upgrade_notice); |
|
156
|
156
|
} |
|
157
|
157
|
|
|
158
|
|
- if ( ! empty( $message ) ) { |
|
159
|
|
- echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __( 'Important upgrade notice', 'wpshop' ) . ': </strong>' . $message . '</p>'; |
|
|
158
|
+ if (!empty($message)) { |
|
|
159
|
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>' . __('Important upgrade notice', 'wpshop') . ': </strong>' . $message . '</p>'; |
|
160
|
160
|
} |
|
161
|
161
|
} |