@@ -7,15 +7,15 @@ discard block |
||
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 |
||
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 |
||
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 | /** |
@@ -82,208 +82,208 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @since 1.0 |
84 | 84 | */ |
85 | - public function load_textdomain( $locale = NULL ) { |
|
86 | - if ( empty( $locale ) ) { |
|
87 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
85 | + public function load_textdomain($locale = NULL) { |
|
86 | + if (empty($locale)) { |
|
87 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
88 | 88 | } |
89 | 89 | |
90 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
90 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
91 | 91 | |
92 | - unload_textdomain( 'invoicing' ); |
|
93 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
94 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
92 | + unload_textdomain('invoicing'); |
|
93 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
94 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Define language constants. |
98 | 98 | */ |
99 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
99 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | public function includes() { |
103 | 103 | global $wpinv_options; |
104 | 104 | |
105 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
106 | 106 | $wpinv_options = wpinv_get_settings(); |
107 | 107 | |
108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
132 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
137 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php' ); |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
139 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
132 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
137 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php'); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
139 | + if (!class_exists('WPInv_EUVat')) { |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
141 | 141 | } |
142 | 142 | |
143 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
144 | - if ( !empty( $gateways ) ) { |
|
145 | - foreach ( $gateways as $gateway ) { |
|
146 | - if ( $gateway == 'manual' ) { |
|
143 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
144 | + if (!empty($gateways)) { |
|
145 | + foreach ($gateways as $gateway) { |
|
146 | + if ($gateway == 'manual') { |
|
147 | 147 | continue; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
151 | 151 | |
152 | - if ( file_exists( $gateway_file ) ) { |
|
153 | - require_once( $gateway_file ); |
|
152 | + if (file_exists($gateway_file)) { |
|
153 | + require_once($gateway_file); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
158 | 158 | |
159 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
159 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
163 | 163 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
170 | 170 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
171 | 171 | // load the user class only on the users.php page |
172 | 172 | global $pagenow; |
173 | - if($pagenow=='users.php'){ |
|
173 | + if ($pagenow == 'users.php') { |
|
174 | 174 | new WPInv_Admin_Users(); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | // include css inliner |
179 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
180 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
179 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
180 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
181 | 181 | } |
182 | 182 | |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | public function init() { |
187 | 187 | } |
188 | 188 | |
189 | 189 | public function admin_init() { |
190 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
190 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
191 | 191 | } |
192 | 192 | |
193 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
193 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function activation_redirect() { |
197 | 197 | // Bail if no activation redirect |
198 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
198 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Delete the redirect transient |
203 | - delete_transient( '_wpinv_activation_redirect' ); |
|
203 | + delete_transient('_wpinv_activation_redirect'); |
|
204 | 204 | |
205 | 205 | // Bail if activating from network, or bulk |
206 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
206 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
210 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
211 | 211 | exit; |
212 | 212 | } |
213 | 213 | |
214 | 214 | public function enqueue_scripts() { |
215 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
215 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
216 | 216 | |
217 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
218 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
217 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
218 | + wp_enqueue_style('wpinv_front_style'); |
|
219 | 219 | |
220 | 220 | // Register scripts |
221 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
222 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
221 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
222 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
223 | 223 | |
224 | 224 | $localize = array(); |
225 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
226 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
225 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
226 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
227 | 227 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
228 | 228 | $localize['currency_pos'] = wpinv_currency_position(); |
229 | 229 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
230 | 230 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
231 | 231 | $localize['decimals'] = wpinv_decimals(); |
232 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
232 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
233 | 233 | |
234 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
234 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
235 | 235 | |
236 | - wp_enqueue_script( 'jquery-blockui' ); |
|
236 | + wp_enqueue_script('jquery-blockui'); |
|
237 | 237 | $autofill_api = wpinv_get_option('address_autofill_api'); |
238 | 238 | $autofill_active = wpinv_get_option('address_autofill_active'); |
239 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
240 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
241 | - wp_dequeue_script( 'google-maps-api' ); |
|
239 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
240 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
241 | + wp_dequeue_script('google-maps-api'); |
|
242 | 242 | } |
243 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
244 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
243 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
244 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
245 | 245 | } |
246 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
247 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
246 | + wp_enqueue_script('wpinv-front-script'); |
|
247 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | public function admin_enqueue_scripts() { |
251 | 251 | global $post, $pagenow; |
252 | 252 | |
253 | 253 | $post_type = wpinv_admin_post_type(); |
254 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
255 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
254 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
255 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
256 | 256 | |
257 | 257 | $jquery_ui_css = false; |
258 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
258 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
259 | 259 | $jquery_ui_css = true; |
260 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
260 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
261 | 261 | $jquery_ui_css = true; |
262 | 262 | } |
263 | - if ( $jquery_ui_css ) { |
|
264 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
265 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
263 | + if ($jquery_ui_css) { |
|
264 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
265 | + wp_enqueue_style('jquery-ui-css'); |
|
266 | 266 | } |
267 | 267 | |
268 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
269 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
268 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
269 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
270 | 270 | |
271 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
272 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
271 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
272 | + wp_enqueue_style('wpinv_admin_style'); |
|
273 | 273 | |
274 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
275 | - if ( $page == 'wpinv-subscriptions' ) { |
|
276 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
274 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
275 | + if ($page == 'wpinv-subscriptions') { |
|
276 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
277 | 277 | } |
278 | 278 | |
279 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
280 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
279 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
280 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
281 | 281 | } |
282 | 282 | |
283 | - wp_enqueue_style( 'wp-color-picker' ); |
|
284 | - wp_enqueue_script( 'wp-color-picker' ); |
|
283 | + wp_enqueue_style('wp-color-picker'); |
|
284 | + wp_enqueue_script('wp-color-picker'); |
|
285 | 285 | |
286 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
286 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
287 | 287 | wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), WPINV_VERSION); |
288 | 288 | wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), WPINV_VERSION); |
289 | 289 | |
@@ -296,22 +296,22 @@ discard block |
||
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | - if ( !wp_script_is( 'font-awesome', 'enqueued' ) ) { |
|
300 | - wp_enqueue_script( 'font-awesome' ); |
|
301 | - wp_enqueue_script( 'font-awesome-shim' ); |
|
299 | + if (!wp_script_is('font-awesome', 'enqueued')) { |
|
300 | + wp_enqueue_script('font-awesome'); |
|
301 | + wp_enqueue_script('font-awesome-shim'); |
|
302 | 302 | } |
303 | 303 | |
304 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
305 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
304 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
305 | + wp_enqueue_script('wpinv-admin-script'); |
|
306 | 306 | |
307 | 307 | $localize = array(); |
308 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
309 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
310 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
311 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
312 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
313 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
314 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
308 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
309 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
310 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
311 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
312 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
313 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
314 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
315 | 315 | $localize['tax'] = wpinv_tax_amount(); |
316 | 316 | $localize['discount'] = wpinv_discount_amount(); |
317 | 317 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -319,69 +319,69 @@ discard block |
||
319 | 319 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
320 | 320 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
321 | 321 | $localize['decimals'] = wpinv_decimals(); |
322 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
323 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
324 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
325 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
326 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
327 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
328 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
329 | - $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' ); |
|
330 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
331 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
332 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
333 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
334 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
335 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
322 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
323 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
324 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
325 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
326 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
327 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
328 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
329 | + $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'); |
|
330 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
331 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
332 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
333 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
334 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
335 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
336 | 336 | |
337 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
337 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
338 | 338 | |
339 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
339 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
340 | 340 | |
341 | - if ( $page == 'wpinv-subscriptions' ) { |
|
342 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
343 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
341 | + if ($page == 'wpinv-subscriptions') { |
|
342 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
343 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | - public function admin_body_class( $classes ) { |
|
347 | + public function admin_body_class($classes) { |
|
348 | 348 | global $pagenow, $post, $current_screen; |
349 | 349 | |
350 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
350 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
351 | 351 | $classes .= ' wpinv-cpt'; |
352 | 352 | } |
353 | 353 | |
354 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
354 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
355 | 355 | |
356 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
357 | - if ( $add_class ) { |
|
358 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
356 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
357 | + if ($add_class) { |
|
358 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $settings_class = array(); |
362 | - if ( $page == 'wpinv-settings' ) { |
|
363 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
364 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
362 | + if ($page == 'wpinv-settings') { |
|
363 | + if (!empty($_REQUEST['tab'])) { |
|
364 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
368 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
367 | + if (!empty($_REQUEST['section'])) { |
|
368 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
369 | 369 | } |
370 | 370 | |
371 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
371 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( !empty( $settings_class ) ) { |
|
375 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
374 | + if (!empty($settings_class)) { |
|
375 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | $post_type = wpinv_admin_post_type(); |
379 | 379 | |
380 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
380 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
381 | 381 | return $classes .= ' wpinv'; |
382 | 382 | } |
383 | 383 | |
384 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
384 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
385 | 385 | $classes .= ' wpi-editable-n'; |
386 | 386 | } |
387 | 387 | |
@@ -393,20 +393,20 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | public function wpinv_actions() { |
396 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
397 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
396 | + if (isset($_REQUEST['wpi_action'])) { |
|
397 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | - public function pre_get_posts( $wp_query ) { |
|
402 | - 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() ) { |
|
403 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
401 | + public function pre_get_posts($wp_query) { |
|
402 | + 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()) { |
|
403 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | return $wp_query; |
407 | 407 | } |
408 | 408 | |
409 | 409 | public function bp_invoicing_init() { |
410 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
410 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | \ No newline at end of file |