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