|
@@ -7,15 +7,15 @@ discard block |
|
|
block discarded – undo |
7
|
7
|
*/ |
8
|
8
|
|
9
|
9
|
// MUST have WordPress. |
10
|
|
-if ( !defined( 'WPINC' ) ) { |
11
|
|
- exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10
|
+if (!defined('WPINC')) { |
|
11
|
+ exit('Do NOT access this file directly: ' . basename(__FILE__)); |
12
|
12
|
} |
13
|
13
|
|
14
|
14
|
class WPInv_Plugin { |
15
|
15
|
private static $instance; |
16
|
16
|
|
17
|
17
|
public static function run() { |
18
|
|
- if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18
|
+ if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
19
|
19
|
self::$instance = new WPInv_Plugin; |
20
|
20
|
self::$instance->includes(); |
21
|
21
|
self::$instance->actions(); |
|
@@ -23,7 +23,7 @@ discard block |
|
|
block discarded – undo |
23
|
23
|
self::$instance->reports = new WPInv_Reports(); |
24
|
24
|
} |
25
|
25
|
|
26
|
|
- do_action( 'wpinv_loaded' ); |
|
26
|
+ do_action('wpinv_loaded'); |
27
|
27
|
|
28
|
28
|
return self::$instance; |
29
|
29
|
} |
|
@@ -33,33 +33,33 @@ discard block |
|
|
block discarded – undo |
33
|
33
|
} |
34
|
34
|
|
35
|
35
|
public function define_constants() { |
36
|
|
- define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
37
|
|
- define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
36
|
+ define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
37
|
+ define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
38
|
38
|
} |
39
|
39
|
|
40
|
40
|
private function actions() { |
41
|
41
|
/* Internationalize the text strings used. */ |
42
|
|
- add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
42
|
+ add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
43
|
43
|
|
44
|
44
|
/* Perform actions on admin initialization. */ |
45
|
|
- add_action( 'admin_init', array( &$this, 'admin_init') ); |
46
|
|
- add_action( 'init', array( &$this, 'init' ), 3 ); |
47
|
|
- add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
48
|
|
- add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
45
|
+ add_action('admin_init', array(&$this, 'admin_init')); |
|
46
|
+ add_action('init', array(&$this, 'init'), 3); |
|
47
|
+ add_action('init', array('WPInv_Shortcodes', 'init')); |
|
48
|
+ add_action('init', array(&$this, 'wpinv_actions')); |
49
|
49
|
|
50
|
|
- if ( class_exists( 'BuddyPress' ) ) { |
51
|
|
- add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
50
|
+ if (class_exists('BuddyPress')) { |
|
51
|
+ add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
52
|
52
|
} |
53
|
53
|
|
54
|
|
- add_filter( 'geodir_googlemap_script_extra', array( &$this,'add_google_maps_places_lib'), 101, 1 ); |
|
54
|
+ add_filter('geodir_googlemap_script_extra', array(&$this, 'add_google_maps_places_lib'), 101, 1); |
55
|
55
|
|
56
|
|
- add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
56
|
+ add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
57
|
57
|
|
58
|
|
- if ( is_admin() ) { |
59
|
|
- add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
60
|
|
- add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
58
|
+ if (is_admin()) { |
|
59
|
+ add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
60
|
+ add_action('admin_body_class', array(&$this, 'admin_body_class')); |
61
|
61
|
} else { |
62
|
|
- add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
62
|
+ add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
63
|
63
|
} |
64
|
64
|
|
65
|
65
|
/** |
|
@@ -69,9 +69,9 @@ discard block |
|
|
block discarded – undo |
69
|
69
|
* |
70
|
70
|
* @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
71
|
71
|
*/ |
72
|
|
- do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
72
|
+ do_action_ref_array('wpinv_actions', array(&$this)); |
73
|
73
|
|
74
|
|
- add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
74
|
+ add_action('admin_init', array(&$this, 'activation_redirect')); |
75
|
75
|
} |
76
|
76
|
|
77
|
77
|
public function plugins_loaded() { |
|
@@ -85,157 +85,157 @@ discard block |
|
|
block discarded – undo |
85
|
85
|
* @since 1.0 |
86
|
86
|
*/ |
87
|
87
|
public function load_textdomain() { |
88
|
|
- $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' ); |
|
88
|
+ $locale = apply_filters('plugin_locale', get_locale(), 'invoicing'); |
89
|
89
|
|
90
|
|
- load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
91
|
|
- load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
90
|
+ load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
91
|
+ load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
92
|
92
|
|
93
|
93
|
/** |
94
|
94
|
* Define language constants. |
95
|
95
|
*/ |
96
|
|
- require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
96
|
+ require_once(WPINV_PLUGIN_DIR . 'language.php'); |
97
|
97
|
} |
98
|
98
|
|
99
|
99
|
public function includes() { |
100
|
100
|
global $wpinv_options; |
101
|
101
|
|
102
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
102
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
103
|
103
|
$wpinv_options = wpinv_get_settings(); |
104
|
104
|
|
105
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
106
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
107
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
108
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
109
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
110
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
111
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
112
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
113
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
114
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
115
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
116
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
117
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
118
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' ); |
119
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
105
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
106
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
107
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
108
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
109
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
110
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
111
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
112
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
113
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
114
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
115
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
116
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
117
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
118
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php'); |
|
119
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
120
|
120
|
//require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
121
|
121
|
//require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
122
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
122
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
123
|
123
|
//require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); |
124
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
125
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
126
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
127
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
128
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
129
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
130
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
131
|
|
- if ( !class_exists( 'Geodir_EUVat' ) ) { |
132
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
124
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
125
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
126
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
127
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
128
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
129
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
130
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
131
|
+ if (!class_exists('Geodir_EUVat')) { |
|
132
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
133
|
133
|
} |
134
|
134
|
|
135
|
|
- $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
136
|
|
- if ( !empty( $gateways ) ) { |
137
|
|
- foreach ( $gateways as $gateway ) { |
138
|
|
- if ( $gateway == 'manual' ) { |
|
135
|
+ $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
136
|
+ if (!empty($gateways)) { |
|
137
|
+ foreach ($gateways as $gateway) { |
|
138
|
+ if ($gateway == 'manual') { |
139
|
139
|
continue; |
140
|
140
|
} |
141
|
141
|
|
142
|
142
|
$gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
143
|
143
|
|
144
|
|
- if ( file_exists( $gateway_file ) ) { |
145
|
|
- require_once( $gateway_file ); |
|
144
|
+ if (file_exists($gateway_file)) { |
|
145
|
+ require_once($gateway_file); |
146
|
146
|
} |
147
|
147
|
} |
148
|
148
|
} |
149
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
149
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
150
|
150
|
|
151
|
|
- if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
152
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
153
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
154
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
151
|
+ if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
152
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
153
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
154
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
155
|
155
|
//require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
156
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
157
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
158
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
159
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
160
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
156
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
157
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
158
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
159
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
160
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
161
|
161
|
//require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
162
|
162
|
} |
163
|
163
|
|
164
|
164
|
// include css inliner |
165
|
|
- if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
166
|
|
- include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
165
|
+ if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
166
|
+ include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
167
|
167
|
} |
168
|
168
|
|
169
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
169
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
170
|
170
|
} |
171
|
171
|
|
172
|
172
|
public function init() { |
173
|
173
|
} |
174
|
174
|
|
175
|
175
|
public function admin_init() { |
176
|
|
- if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
176
|
+ if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
177
|
177
|
} |
178
|
178
|
|
179
|
|
- add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
179
|
+ add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
180
|
180
|
} |
181
|
181
|
|
182
|
182
|
public function activation_redirect() { |
183
|
183
|
// Bail if no activation redirect |
184
|
|
- if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
184
|
+ if (!get_transient('_wpinv_activation_redirect')) { |
185
|
185
|
return; |
186
|
186
|
} |
187
|
187
|
|
188
|
188
|
// Delete the redirect transient |
189
|
|
- delete_transient( '_wpinv_activation_redirect' ); |
|
189
|
+ delete_transient('_wpinv_activation_redirect'); |
190
|
190
|
|
191
|
191
|
// Bail if activating from network, or bulk |
192
|
|
- if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
192
|
+ if (is_network_admin() || isset($_GET['activate-multi'])) { |
193
|
193
|
return; |
194
|
194
|
} |
195
|
195
|
|
196
|
|
- wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
196
|
+ wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
197
|
197
|
exit; |
198
|
198
|
} |
199
|
199
|
|
200
|
200
|
public function enqueue_scripts() { |
201
|
|
- $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
201
|
+ $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
202
|
202
|
|
203
|
|
- wp_deregister_style( 'font-awesome' ); |
204
|
|
- wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
205
|
|
- wp_enqueue_style( 'font-awesome' ); |
|
203
|
+ wp_deregister_style('font-awesome'); |
|
204
|
+ wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
205
|
+ wp_enqueue_style('font-awesome'); |
206
|
206
|
|
207
|
|
- wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
208
|
|
- wp_enqueue_style( 'wpinv_front_style' ); |
|
207
|
+ wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
208
|
+ wp_enqueue_style('wpinv_front_style'); |
209
|
209
|
|
210
|
210
|
// Register scripts |
211
|
|
- wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
212
|
|
- wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
211
|
+ wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
212
|
+ wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
213
|
213
|
|
214
|
214
|
$localize = array(); |
215
|
|
- $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
216
|
|
- $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
215
|
+ $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
216
|
+ $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
217
|
217
|
$localize['currency_symbol'] = wpinv_currency_symbol(); |
218
|
218
|
$localize['currency_pos'] = wpinv_currency_position(); |
219
|
219
|
$localize['thousand_sep'] = wpinv_thousands_separator(); |
220
|
220
|
$localize['decimal_sep'] = wpinv_decimal_separator(); |
221
|
221
|
$localize['decimals'] = wpinv_decimals(); |
222
|
222
|
|
223
|
|
- $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
223
|
+ $localize = apply_filters('wpinv_front_js_localize', $localize); |
224
|
224
|
|
225
|
|
- wp_enqueue_script( 'jquery-blockui' ); |
|
225
|
+ wp_enqueue_script('jquery-blockui'); |
226
|
226
|
$autofill_api = wpinv_get_option('address_autofill_api'); |
227
|
227
|
$autofill_active = wpinv_get_option('address_autofill_active'); |
228
|
228
|
if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
229
|
229
|
|
230
|
230
|
// we don't need this if GD is installed. |
231
|
|
- if(!function_exists('geodir_templates_scripts')){ |
|
231
|
+ if (!function_exists('geodir_templates_scripts')) { |
232
|
232
|
wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
233
|
233
|
} |
234
|
|
- wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery','google-maps-api'), '', true); |
|
234
|
+ wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
235
|
235
|
|
236
|
236
|
} |
237
|
|
- wp_enqueue_script( 'wpinv-front-script' ); |
238
|
|
- wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
237
|
+ wp_enqueue_script('wpinv-front-script'); |
|
238
|
+ wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
239
|
239
|
} |
240
|
240
|
|
241
|
241
|
/** |
|
@@ -245,9 +245,9 @@ discard block |
|
|
block discarded – undo |
245
|
245
|
* @since 1.0.0 |
246
|
246
|
* @return string |
247
|
247
|
*/ |
248
|
|
- public function add_google_maps_places_lib( $extra ) { |
|
248
|
+ public function add_google_maps_places_lib($extra) { |
249
|
249
|
|
250
|
|
- if ( wpinv_is_checkout() && ! str_replace( 'libraries=places', '', $extra ) ) { |
|
250
|
+ if (wpinv_is_checkout() && !str_replace('libraries=places', '', $extra)) { |
251
|
251
|
$extra .= "&libraries=places"; |
252
|
252
|
} |
253
|
253
|
|
|
@@ -258,35 +258,35 @@ discard block |
|
|
block discarded – undo |
258
|
258
|
global $post, $pagenow; |
259
|
259
|
|
260
|
260
|
$post_type = wpinv_admin_post_type(); |
261
|
|
- $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
261
|
+ $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
262
|
262
|
|
263
|
|
- wp_deregister_style( 'font-awesome' ); |
264
|
|
- wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
265
|
|
- wp_enqueue_style( 'font-awesome' ); |
|
263
|
+ wp_deregister_style('font-awesome'); |
|
264
|
+ wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
265
|
+ wp_enqueue_style('font-awesome'); |
266
|
266
|
|
267
|
|
- wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
268
|
|
- wp_enqueue_style( 'jquery-ui-css' ); |
|
267
|
+ wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
268
|
+ wp_enqueue_style('jquery-ui-css'); |
269
|
269
|
|
270
|
|
- wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' ); |
271
|
|
- wp_enqueue_style( 'jquery-chosen' ); |
|
270
|
+ wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2'); |
|
271
|
+ wp_enqueue_style('jquery-chosen'); |
272
|
272
|
|
273
|
|
- wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' ); |
274
|
|
- wp_enqueue_script( 'jquery-chosen' ); |
|
273
|
+ wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2'); |
|
274
|
+ wp_enqueue_script('jquery-chosen'); |
275
|
275
|
|
276
|
|
- wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
277
|
|
- wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
276
|
+ wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
277
|
+ wp_enqueue_style('wpinv_meta_box_style'); |
278
|
278
|
|
279
|
|
- wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
280
|
|
- wp_enqueue_style( 'wpinv_admin_style' ); |
|
279
|
+ wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
280
|
+ wp_enqueue_style('wpinv_admin_style'); |
281
|
281
|
|
282
|
|
- if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
283
|
|
- wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
282
|
+ if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
283
|
+ wp_enqueue_script('jquery-ui-datepicker'); |
284
|
284
|
} |
285
|
285
|
|
286
|
|
- wp_enqueue_style( 'wp-color-picker' ); |
287
|
|
- wp_enqueue_script( 'wp-color-picker' ); |
|
286
|
+ wp_enqueue_style('wp-color-picker'); |
|
287
|
+ wp_enqueue_script('wp-color-picker'); |
288
|
288
|
|
289
|
|
- wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
289
|
+ wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
290
|
290
|
|
291
|
291
|
if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
292
|
292
|
$autofill_api = wpinv_get_option('address_autofill_api'); |
|
@@ -297,17 +297,17 @@ discard block |
|
|
block discarded – undo |
297
|
297
|
} |
298
|
298
|
} |
299
|
299
|
|
300
|
|
- wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
301
|
|
- wp_enqueue_script( 'wpinv-admin-script' ); |
|
300
|
+ wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
301
|
+ wp_enqueue_script('wpinv-admin-script'); |
302
|
302
|
|
303
|
303
|
$localize = array(); |
304
|
|
- $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
305
|
|
- $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
306
|
|
- $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
307
|
|
- $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
308
|
|
- $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
309
|
|
- $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
310
|
|
- $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
304
|
+ $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
305
|
+ $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
306
|
+ $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
307
|
+ $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
308
|
+ $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
309
|
+ $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
310
|
+ $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
311
|
311
|
$localize['tax'] = wpinv_tax_amount(); |
312
|
312
|
$localize['discount'] = wpinv_discount_amount(); |
313
|
313
|
$localize['currency_symbol'] = wpinv_currency_symbol(); |
|
@@ -315,65 +315,65 @@ discard block |
|
|
block discarded – undo |
315
|
315
|
$localize['thousand_sep'] = wpinv_thousands_separator(); |
316
|
316
|
$localize['decimal_sep'] = wpinv_decimal_separator(); |
317
|
317
|
$localize['decimals'] = wpinv_decimals(); |
318
|
|
- $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
319
|
|
- $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
320
|
|
- $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
321
|
|
- $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
322
|
|
- $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
323
|
|
- $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
324
|
|
- $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
325
|
|
- $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
326
|
|
- $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
318
|
+ $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
319
|
+ $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
320
|
+ $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
321
|
+ $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
322
|
+ $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
323
|
+ $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
324
|
+ $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
325
|
+ $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
326
|
+ $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
327
|
327
|
$localize['hasGD'] = wpinv_gd_active(); |
328
|
328
|
$localize['hasPM'] = wpinv_pm_active(); |
329
|
|
- $localize['emptyInvoice'] = __( 'Add atleast one item to save invoice!', 'invoicing' ); |
330
|
|
- $localize['deletePackage'] = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' ); |
331
|
|
- $localize['deletePackages'] = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' ); |
332
|
|
- $localize['deleteInvoiceFirst'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
329
|
+ $localize['emptyInvoice'] = __('Add atleast one item to save invoice!', 'invoicing'); |
|
330
|
+ $localize['deletePackage'] = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing'); |
|
331
|
+ $localize['deletePackages'] = __('GD package items should be deleted from GD payment manager only', 'invoicing'); |
|
332
|
+ $localize['deleteInvoiceFirst'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
333
|
333
|
|
334
|
|
- $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
334
|
+ $localize = apply_filters('wpinv_admin_js_localize', $localize); |
335
|
335
|
|
336
|
|
- wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
336
|
+ wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
337
|
337
|
} |
338
|
338
|
|
339
|
|
- public function admin_body_class( $classes ) { |
|
339
|
+ public function admin_body_class($classes) { |
340
|
340
|
global $pagenow, $post, $current_screen; |
341
|
341
|
|
342
|
|
- if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
342
|
+ if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
343
|
343
|
$classes .= ' wpinv-cpt'; |
344
|
344
|
} |
345
|
345
|
|
346
|
|
- $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
346
|
+ $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
347
|
347
|
|
348
|
348
|
$add_class = false; |
349
|
|
- if ( $pagenow == 'admin.php' && $page ) { |
350
|
|
- $add_class = strpos( $page, 'wpinv-' ); |
|
349
|
+ if ($pagenow == 'admin.php' && $page) { |
|
350
|
+ $add_class = strpos($page, 'wpinv-'); |
351
|
351
|
} |
352
|
352
|
|
353
|
353
|
$settings_class = array(); |
354
|
|
- if ( $page == 'wpinv-settings' ) { |
355
|
|
- if ( !empty( $_REQUEST['tab'] ) ) { |
356
|
|
- $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
354
|
+ if ($page == 'wpinv-settings') { |
|
355
|
+ if (!empty($_REQUEST['tab'])) { |
|
356
|
+ $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
357
|
357
|
} |
358
|
358
|
|
359
|
|
- if ( !empty( $_REQUEST['section'] ) ) { |
360
|
|
- $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
359
|
+ if (!empty($_REQUEST['section'])) { |
|
360
|
+ $settings_class[] = sanitize_text_field($_REQUEST['section']); |
361
|
361
|
} |
362
|
362
|
|
363
|
|
- $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
363
|
+ $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
364
|
364
|
} |
365
|
365
|
|
366
|
|
- if ( !empty( $settings_class ) ) { |
367
|
|
- $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
366
|
+ if (!empty($settings_class)) { |
|
367
|
+ $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
368
|
368
|
} |
369
|
369
|
|
370
|
370
|
$post_type = wpinv_admin_post_type(); |
371
|
371
|
|
372
|
|
- if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
372
|
+ if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
373
|
373
|
return $classes .= ' wpinv'; |
374
|
374
|
} |
375
|
375
|
|
376
|
|
- if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
376
|
+ if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
377
|
377
|
$classes .= ' wpi-editable-n'; |
378
|
378
|
} |
379
|
379
|
|
|
@@ -385,20 +385,20 @@ discard block |
|
|
block discarded – undo |
385
|
385
|
} |
386
|
386
|
|
387
|
387
|
public function wpinv_actions() { |
388
|
|
- if ( isset( $_REQUEST['wpi_action'] ) ) { |
389
|
|
- do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388
|
+ if (isset($_REQUEST['wpi_action'])) { |
|
389
|
+ do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
390
|
390
|
} |
391
|
391
|
} |
392
|
392
|
|
393
|
|
- public function pre_get_posts( $wp_query ) { |
394
|
|
- if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
395
|
|
- $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
393
|
+ public function pre_get_posts($wp_query) { |
|
394
|
+ if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
395
|
+ $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
396
|
396
|
} |
397
|
397
|
|
398
|
398
|
return $wp_query; |
399
|
399
|
} |
400
|
400
|
|
401
|
401
|
public function bp_invoicing_init() { |
402
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
402
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
403
|
403
|
} |
404
|
404
|
} |
405
|
405
|
\ No newline at end of file |