|
@@ -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(); |
|
@@ -31,31 +31,31 @@ discard block |
|
|
block discarded – undo |
31
|
31
|
} |
32
|
32
|
|
33
|
33
|
public function define_constants() { |
34
|
|
- define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
35
|
|
- define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
34
|
+ define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
35
|
+ define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
36
|
36
|
} |
37
|
37
|
|
38
|
38
|
private function actions() { |
39
|
39
|
/* Internationalize the text strings used. */ |
40
|
|
- add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
40
|
+ add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
41
|
41
|
|
42
|
42
|
/* Perform actions on admin initialization. */ |
43
|
|
- add_action( 'admin_init', array( &$this, 'admin_init') ); |
44
|
|
- add_action( 'init', array( &$this, 'init' ), 3 ); |
45
|
|
- add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
46
|
|
- add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
43
|
+ add_action('admin_init', array(&$this, 'admin_init')); |
|
44
|
+ add_action('init', array(&$this, 'init'), 3); |
|
45
|
+ add_action('init', array('WPInv_Shortcodes', 'init')); |
|
46
|
+ add_action('init', array(&$this, 'wpinv_actions')); |
47
|
47
|
|
48
|
|
- if ( class_exists( 'BuddyPress' ) ) { |
49
|
|
- add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
48
|
+ if (class_exists('BuddyPress')) { |
|
49
|
+ add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
50
|
50
|
} |
51
|
51
|
|
52
|
|
- add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
52
|
+ add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
53
|
53
|
|
54
|
|
- if ( is_admin() ) { |
55
|
|
- add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
56
|
|
- add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
54
|
+ if (is_admin()) { |
|
55
|
+ add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
56
|
+ add_action('admin_body_class', array(&$this, 'admin_body_class')); |
57
|
57
|
} else { |
58
|
|
- add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
58
|
+ add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
59
|
59
|
} |
60
|
60
|
|
61
|
61
|
/** |
|
@@ -65,16 +65,16 @@ discard block |
|
|
block discarded – undo |
65
|
65
|
* |
66
|
66
|
* @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
67
|
67
|
*/ |
68
|
|
- do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
68
|
+ do_action_ref_array('wpinv_actions', array(&$this)); |
69
|
69
|
|
70
|
|
- add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
70
|
+ add_action('admin_init', array(&$this, 'activation_redirect')); |
71
|
71
|
} |
72
|
72
|
|
73
|
73
|
public function plugins_loaded() { |
74
|
74
|
/* Internationalize the text strings used. */ |
75
|
75
|
$this->load_textdomain(); |
76
|
76
|
|
77
|
|
- do_action( 'wpinv_loaded' ); |
|
77
|
+ do_action('wpinv_loaded'); |
78
|
78
|
} |
79
|
79
|
|
80
|
80
|
/** |
|
@@ -83,205 +83,205 @@ discard block |
|
|
block discarded – undo |
83
|
83
|
* @since 1.0 |
84
|
84
|
*/ |
85
|
85
|
public function load_textdomain() { |
86
|
|
- $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
87
|
|
- $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
86
|
+ $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
87
|
+ $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
88
|
88
|
|
89
|
|
- unload_textdomain( 'invoicing' ); |
90
|
|
- load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
91
|
|
- load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
89
|
+ unload_textdomain('invoicing'); |
|
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-error-functions.php' ); |
119
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
120
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
121
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
122
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
123
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
124
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
125
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
126
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
127
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
128
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
129
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
130
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
131
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
132
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
133
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
134
|
|
- if ( !class_exists( 'WPInv_EUVat' ) ) { |
135
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.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-error-functions.php'); |
|
119
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
120
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
121
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
122
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
123
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
124
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
125
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
126
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
127
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
128
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
129
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
130
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
131
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
132
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
133
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
134
|
+ if (!class_exists('WPInv_EUVat')) { |
|
135
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
136
|
136
|
} |
137
|
137
|
|
138
|
|
- $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
139
|
|
- if ( !empty( $gateways ) ) { |
140
|
|
- foreach ( $gateways as $gateway ) { |
141
|
|
- if ( $gateway == 'manual' ) { |
|
138
|
+ $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
139
|
+ if (!empty($gateways)) { |
|
140
|
+ foreach ($gateways as $gateway) { |
|
141
|
+ if ($gateway == 'manual') { |
142
|
142
|
continue; |
143
|
143
|
} |
144
|
144
|
|
145
|
145
|
$gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
146
|
146
|
|
147
|
|
- if ( file_exists( $gateway_file ) ) { |
148
|
|
- require_once( $gateway_file ); |
|
147
|
+ if (file_exists($gateway_file)) { |
|
148
|
+ require_once($gateway_file); |
149
|
149
|
} |
150
|
150
|
} |
151
|
151
|
} |
152
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
152
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
153
|
153
|
|
154
|
|
- if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
155
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
156
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
157
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
154
|
+ if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
155
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
156
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
157
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
158
|
158
|
//require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
159
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
160
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
161
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
162
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
163
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
159
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
160
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
161
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
162
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
163
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
164
|
164
|
//require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
165
|
165
|
} |
166
|
166
|
|
167
|
167
|
// include css inliner |
168
|
|
- if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
169
|
|
- include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
168
|
+ if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
169
|
+ include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
170
|
170
|
} |
171
|
171
|
|
172
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
172
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
173
|
173
|
} |
174
|
174
|
|
175
|
175
|
public function init() { |
176
|
176
|
} |
177
|
177
|
|
178
|
178
|
public function admin_init() { |
179
|
|
- if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
179
|
+ if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
180
|
180
|
} |
181
|
181
|
|
182
|
|
- add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
182
|
+ add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
183
|
183
|
} |
184
|
184
|
|
185
|
185
|
public function activation_redirect() { |
186
|
186
|
// Bail if no activation redirect |
187
|
|
- if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
187
|
+ if (!get_transient('_wpinv_activation_redirect')) { |
188
|
188
|
return; |
189
|
189
|
} |
190
|
190
|
|
191
|
191
|
// Delete the redirect transient |
192
|
|
- delete_transient( '_wpinv_activation_redirect' ); |
|
192
|
+ delete_transient('_wpinv_activation_redirect'); |
193
|
193
|
|
194
|
194
|
// Bail if activating from network, or bulk |
195
|
|
- if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
195
|
+ if (is_network_admin() || isset($_GET['activate-multi'])) { |
196
|
196
|
return; |
197
|
197
|
} |
198
|
198
|
|
199
|
|
- wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
199
|
+ wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
200
|
200
|
exit; |
201
|
201
|
} |
202
|
202
|
|
203
|
203
|
public function enqueue_scripts() { |
204
|
|
- $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
204
|
+ $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
205
|
205
|
|
206
|
|
- wp_deregister_style( 'font-awesome' ); |
207
|
|
- wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
208
|
|
- wp_enqueue_style( 'font-awesome' ); |
|
206
|
+ wp_deregister_style('font-awesome'); |
|
207
|
+ wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
208
|
+ wp_enqueue_style('font-awesome'); |
209
|
209
|
|
210
|
|
- wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
211
|
|
- wp_enqueue_style( 'wpinv_front_style' ); |
|
210
|
+ wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
211
|
+ wp_enqueue_style('wpinv_front_style'); |
212
|
212
|
|
213
|
213
|
// Register scripts |
214
|
|
- wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
215
|
|
- wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
214
|
+ wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
215
|
+ wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
216
|
216
|
|
217
|
217
|
$localize = array(); |
218
|
|
- $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
219
|
|
- $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
218
|
+ $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
219
|
+ $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
220
|
220
|
$localize['currency_symbol'] = wpinv_currency_symbol(); |
221
|
221
|
$localize['currency_pos'] = wpinv_currency_position(); |
222
|
222
|
$localize['thousand_sep'] = wpinv_thousands_separator(); |
223
|
223
|
$localize['decimal_sep'] = wpinv_decimal_separator(); |
224
|
224
|
$localize['decimals'] = wpinv_decimals(); |
225
|
|
- $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
225
|
+ $localize['txtComplete'] = __('Complete', 'invoicing'); |
226
|
226
|
|
227
|
|
- $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
227
|
+ $localize = apply_filters('wpinv_front_js_localize', $localize); |
228
|
228
|
|
229
|
|
- wp_enqueue_script( 'jquery-blockui' ); |
|
229
|
+ wp_enqueue_script('jquery-blockui'); |
230
|
230
|
$autofill_api = wpinv_get_option('address_autofill_api'); |
231
|
231
|
$autofill_active = wpinv_get_option('address_autofill_active'); |
232
|
|
- if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
233
|
|
- if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
234
|
|
- wp_dequeue_script( 'google-maps-api' ); |
|
232
|
+ if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
233
|
+ if (wp_script_is('google-maps-api', 'enqueued')) { |
|
234
|
+ wp_dequeue_script('google-maps-api'); |
235
|
235
|
} |
236
|
|
- wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
237
|
|
- wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
236
|
+ wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
237
|
+ wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
238
|
238
|
} |
239
|
|
- wp_enqueue_script( 'wpinv-front-script' ); |
240
|
|
- wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
239
|
+ wp_enqueue_script('wpinv-front-script'); |
|
240
|
+ wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
241
|
241
|
} |
242
|
242
|
|
243
|
243
|
public function admin_enqueue_scripts() { |
244
|
244
|
global $post, $pagenow; |
245
|
245
|
|
246
|
246
|
$post_type = wpinv_admin_post_type(); |
247
|
|
- $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
248
|
|
- $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
247
|
+ $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
248
|
+ $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
249
|
249
|
|
250
|
|
- wp_deregister_style( 'font-awesome' ); |
251
|
|
- wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
252
|
|
- wp_enqueue_style( 'font-awesome' ); |
|
250
|
+ wp_deregister_style('font-awesome'); |
|
251
|
+ wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
252
|
+ wp_enqueue_style('font-awesome'); |
253
|
253
|
|
254
|
254
|
$jquery_ui_css = false; |
255
|
|
- if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
255
|
+ if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
256
|
256
|
$jquery_ui_css = true; |
257
|
|
- } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
257
|
+ } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
258
|
258
|
$jquery_ui_css = true; |
259
|
259
|
} |
260
|
|
- if ( $jquery_ui_css ) { |
261
|
|
- wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
262
|
|
- wp_enqueue_style( 'jquery-ui-css' ); |
|
260
|
+ if ($jquery_ui_css) { |
|
261
|
+ wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
262
|
+ wp_enqueue_style('jquery-ui-css'); |
263
|
263
|
} |
264
|
264
|
|
265
|
|
- wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
266
|
|
- wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
265
|
+ wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
266
|
+ wp_enqueue_style('wpinv_meta_box_style'); |
267
|
267
|
|
268
|
|
- wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
269
|
|
- wp_enqueue_style( 'wpinv_admin_style' ); |
|
268
|
+ wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
269
|
+ wp_enqueue_style('wpinv_admin_style'); |
270
|
270
|
|
271
|
|
- $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
272
|
|
- if ( $page == 'wpinv-subscriptions' ) { |
273
|
|
- wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
271
|
+ $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
272
|
+ if ($page == 'wpinv-subscriptions') { |
|
273
|
+ wp_enqueue_script('jquery-ui-datepicker'); |
274
|
274
|
} |
275
|
|
- $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ); |
|
275
|
+ $enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue); |
276
|
276
|
|
277
|
|
- if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
278
|
|
- wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
277
|
+ if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
278
|
+ wp_enqueue_script('jquery-ui-datepicker'); |
279
|
279
|
} |
280
|
280
|
|
281
|
|
- wp_enqueue_style( 'wp-color-picker' ); |
282
|
|
- wp_enqueue_script( 'wp-color-picker' ); |
|
281
|
+ wp_enqueue_style('wp-color-picker'); |
|
282
|
+ wp_enqueue_script('wp-color-picker'); |
283
|
283
|
|
284
|
|
- wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
284
|
+ wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
285
|
285
|
|
286
|
286
|
if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
287
|
287
|
$autofill_api = wpinv_get_option('address_autofill_api'); |
|
@@ -292,17 +292,17 @@ discard block |
|
|
block discarded – undo |
292
|
292
|
} |
293
|
293
|
} |
294
|
294
|
|
295
|
|
- wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
296
|
|
- wp_enqueue_script( 'wpinv-admin-script' ); |
|
295
|
+ wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
296
|
+ wp_enqueue_script('wpinv-admin-script'); |
297
|
297
|
|
298
|
298
|
$localize = array(); |
299
|
|
- $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
300
|
|
- $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
301
|
|
- $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
302
|
|
- $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
303
|
|
- $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
304
|
|
- $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
305
|
|
- $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
299
|
+ $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
300
|
+ $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
301
|
+ $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
302
|
+ $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
303
|
+ $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
304
|
+ $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
305
|
+ $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
306
|
306
|
$localize['tax'] = wpinv_tax_amount(); |
307
|
307
|
$localize['discount'] = wpinv_discount_amount(); |
308
|
308
|
$localize['currency_symbol'] = wpinv_currency_symbol(); |
|
@@ -310,69 +310,69 @@ discard block |
|
|
block discarded – undo |
310
|
310
|
$localize['thousand_sep'] = wpinv_thousands_separator(); |
311
|
311
|
$localize['decimal_sep'] = wpinv_decimal_separator(); |
312
|
312
|
$localize['decimals'] = wpinv_decimals(); |
313
|
|
- $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
314
|
|
- $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
315
|
|
- $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
316
|
|
- $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
317
|
|
- $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
318
|
|
- $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
319
|
|
- $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
320
|
|
- $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' ); |
321
|
|
- $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
322
|
|
- $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
323
|
|
- $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
324
|
|
- $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
325
|
|
- $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
326
|
|
- $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
313
|
+ $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
314
|
+ $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
315
|
+ $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
316
|
+ $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
317
|
+ $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
318
|
+ $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
319
|
+ $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
320
|
+ $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'); |
|
321
|
+ $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
322
|
+ $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
323
|
+ $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
324
|
+ $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
325
|
+ $localize['action_edit'] = __('Edit', 'invoicing'); |
|
326
|
+ $localize['action_cancel'] = __('Cancel', 'invoicing'); |
327
|
327
|
|
328
|
|
- $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
328
|
+ $localize = apply_filters('wpinv_admin_js_localize', $localize); |
329
|
329
|
|
330
|
|
- wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
330
|
+ wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
331
|
331
|
|
332
|
|
- if ( $page == 'wpinv-subscriptions' ) { |
333
|
|
- wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
334
|
|
- wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
332
|
+ if ($page == 'wpinv-subscriptions') { |
|
333
|
+ wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
334
|
+ wp_enqueue_script('wpinv-sub-admin-script'); |
335
|
335
|
} |
336
|
336
|
} |
337
|
337
|
|
338
|
|
- public function admin_body_class( $classes ) { |
|
338
|
+ public function admin_body_class($classes) { |
339
|
339
|
global $pagenow, $post, $current_screen; |
340
|
340
|
|
341
|
|
- if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
341
|
+ if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
342
|
342
|
$classes .= ' wpinv-cpt'; |
343
|
343
|
} |
344
|
344
|
|
345
|
|
- $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
345
|
+ $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
346
|
346
|
|
347
|
|
- $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
348
|
|
- if ( $add_class ) { |
349
|
|
- $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
347
|
+ $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
348
|
+ if ($add_class) { |
|
349
|
+ $classes .= ' wpi-' . wpinv_sanitize_key($page); |
350
|
350
|
} |
351
|
351
|
|
352
|
352
|
$settings_class = array(); |
353
|
|
- if ( $page == 'wpinv-settings' ) { |
354
|
|
- if ( !empty( $_REQUEST['tab'] ) ) { |
355
|
|
- $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
353
|
+ if ($page == 'wpinv-settings') { |
|
354
|
+ if (!empty($_REQUEST['tab'])) { |
|
355
|
+ $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
356
|
356
|
} |
357
|
357
|
|
358
|
|
- if ( !empty( $_REQUEST['section'] ) ) { |
359
|
|
- $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
358
|
+ if (!empty($_REQUEST['section'])) { |
|
359
|
+ $settings_class[] = sanitize_text_field($_REQUEST['section']); |
360
|
360
|
} |
361
|
361
|
|
362
|
|
- $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
362
|
+ $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
363
|
363
|
} |
364
|
364
|
|
365
|
|
- if ( !empty( $settings_class ) ) { |
366
|
|
- $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
365
|
+ if (!empty($settings_class)) { |
|
366
|
+ $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
367
|
367
|
} |
368
|
368
|
|
369
|
369
|
$post_type = wpinv_admin_post_type(); |
370
|
370
|
|
371
|
|
- if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
371
|
+ if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
372
|
372
|
return $classes .= ' wpinv'; |
373
|
373
|
} |
374
|
374
|
|
375
|
|
- if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
375
|
+ if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
376
|
376
|
$classes .= ' wpi-editable-n'; |
377
|
377
|
} |
378
|
378
|
|
|
@@ -384,20 +384,20 @@ discard block |
|
|
block discarded – undo |
384
|
384
|
} |
385
|
385
|
|
386
|
386
|
public function wpinv_actions() { |
387
|
|
- if ( isset( $_REQUEST['wpi_action'] ) ) { |
388
|
|
- do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
387
|
+ if (isset($_REQUEST['wpi_action'])) { |
|
388
|
+ do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
389
|
389
|
} |
390
|
390
|
} |
391
|
391
|
|
392
|
|
- public function pre_get_posts( $wp_query ) { |
393
|
|
- 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() ) { |
394
|
|
- $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
392
|
+ public function pre_get_posts($wp_query) { |
|
393
|
+ 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()) { |
|
394
|
+ $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
395
|
395
|
} |
396
|
396
|
|
397
|
397
|
return $wp_query; |
398
|
398
|
} |
399
|
399
|
|
400
|
400
|
public function bp_invoicing_init() { |
401
|
|
- require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
401
|
+ require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
402
|
402
|
} |
403
|
403
|
} |
404
|
404
|
\ No newline at end of file |