@@ -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(); |
@@ -33,34 +33,34 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function define_constants() { |
36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | private function actions() { |
41 | 41 | /* Internationalize the text strings used. */ |
42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
43 | 43 | |
44 | 44 | /* Perform actions on admin initialization. */ |
45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
47 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
46 | + add_action('init', array(&$this, 'init'), 3); |
|
47 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
48 | 48 | |
49 | - if ( class_exists( 'BuddyPress' ) ) { |
|
50 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
49 | + if (class_exists('BuddyPress')) { |
|
50 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
51 | 51 | } |
52 | 52 | |
53 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
54 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
55 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
53 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
54 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
55 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
56 | 56 | |
57 | - if ( is_admin() ) { |
|
58 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
59 | - add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
60 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
57 | + if (is_admin()) { |
|
58 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
59 | + add_filter('admin_body_class', array(&$this, 'admin_body_class')); |
|
60 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
61 | 61 | |
62 | 62 | } else { |
63 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
63 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,28 +70,28 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
72 | 72 | */ |
73 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
73 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
74 | 74 | |
75 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
75 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Maybe show the AyeCode Connect Notice. |
80 | 80 | */ |
81 | - public function init_ayecode_connect_helper(){ |
|
81 | + public function init_ayecode_connect_helper() { |
|
82 | 82 | // AyeCode Connect notice |
83 | - if ( is_admin() ){ |
|
83 | + if (is_admin()) { |
|
84 | 84 | // set the strings so they can be translated |
85 | 85 | $strings = array( |
86 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
87 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
88 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
89 | - 'connect_button' => __("Connect Site","invoicing"), |
|
90 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
91 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
92 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
86 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
87 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
88 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
89 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
90 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
91 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
92 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
93 | 93 | ); |
94 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
94 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | /* Internationalize the text strings used. */ |
100 | 100 | $this->load_textdomain(); |
101 | 101 | |
102 | - do_action( 'wpinv_loaded' ); |
|
102 | + do_action('wpinv_loaded'); |
|
103 | 103 | |
104 | 104 | // Fix oxygen page builder conflict |
105 | - if ( function_exists( 'ct_css_output' ) ) { |
|
105 | + if (function_exists('ct_css_output')) { |
|
106 | 106 | wpinv_oxygen_fix_conflict(); |
107 | 107 | } |
108 | 108 | } |
@@ -112,237 +112,237 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @since 1.0 |
114 | 114 | */ |
115 | - public function load_textdomain( $locale = NULL ) { |
|
116 | - if ( empty( $locale ) ) { |
|
117 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
115 | + public function load_textdomain($locale = NULL) { |
|
116 | + if (empty($locale)) { |
|
117 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
118 | 118 | } |
119 | 119 | |
120 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
120 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
121 | 121 | |
122 | - unload_textdomain( 'invoicing' ); |
|
123 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
124 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
122 | + unload_textdomain('invoicing'); |
|
123 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
124 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Define language constants. |
128 | 128 | */ |
129 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function includes() { |
133 | 133 | global $wpinv_options; |
134 | 134 | |
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
136 | 136 | $wpinv_options = wpinv_get_settings(); |
137 | 137 | |
138 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
139 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
163 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
179 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'widgets/payment-form.php' ); |
|
181 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
182 | - |
|
183 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
139 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
163 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
179 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'widgets/payment-form.php'); |
|
181 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
182 | + |
|
183 | + if (!class_exists('WPInv_EUVat')) { |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
185 | 185 | } |
186 | 186 | |
187 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
188 | - if ( !empty( $gateways ) ) { |
|
189 | - foreach ( $gateways as $gateway ) { |
|
190 | - if ( $gateway == 'manual' ) { |
|
187 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
188 | + if (!empty($gateways)) { |
|
189 | + foreach ($gateways as $gateway) { |
|
190 | + if ($gateway == 'manual') { |
|
191 | 191 | continue; |
192 | 192 | } |
193 | 193 | |
194 | 194 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
195 | 195 | |
196 | - if ( file_exists( $gateway_file ) ) { |
|
197 | - require_once( $gateway_file ); |
|
196 | + if (file_exists($gateway_file)) { |
|
197 | + require_once($gateway_file); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
202 | 202 | |
203 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
203 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
207 | 207 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
216 | 216 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
217 | 217 | // load the user class only on the users.php page |
218 | 218 | global $pagenow; |
219 | - if($pagenow=='users.php'){ |
|
219 | + if ($pagenow == 'users.php') { |
|
220 | 220 | new WPInv_Admin_Users(); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Register cli commands |
225 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
227 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
225 | + if (defined('WP_CLI') && WP_CLI) { |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
227 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | // include css inliner |
231 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
232 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
231 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
232 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
233 | 233 | } |
234 | 234 | |
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | public function init() { |
239 | 239 | } |
240 | 240 | |
241 | 241 | public function admin_init() { |
242 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
242 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | public function activation_redirect() { |
246 | 246 | // Bail if no activation redirect |
247 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
247 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Delete the redirect transient |
252 | - delete_transient( '_wpinv_activation_redirect' ); |
|
252 | + delete_transient('_wpinv_activation_redirect'); |
|
253 | 253 | |
254 | 254 | // Bail if activating from network, or bulk |
255 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
255 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
259 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
260 | 260 | exit; |
261 | 261 | } |
262 | 262 | |
263 | 263 | public function enqueue_scripts() { |
264 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
264 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
265 | 265 | |
266 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
267 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
266 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
267 | + wp_enqueue_style('wpinv_front_style'); |
|
268 | 268 | |
269 | 269 | // Register scripts |
270 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
271 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
270 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
271 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
272 | 272 | |
273 | 273 | $localize = array(); |
274 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
275 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
274 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
275 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
276 | 276 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
277 | 277 | $localize['currency_pos'] = wpinv_currency_position(); |
278 | 278 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
279 | 279 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
280 | 280 | $localize['decimals'] = wpinv_decimals(); |
281 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
281 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
282 | 282 | $localize['UseTaxes'] = wpinv_use_taxes(); |
283 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
283 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
284 | 284 | |
285 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
285 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
286 | 286 | |
287 | - wp_enqueue_script( 'jquery-blockui' ); |
|
287 | + wp_enqueue_script('jquery-blockui'); |
|
288 | 288 | $autofill_api = wpinv_get_option('address_autofill_api'); |
289 | 289 | $autofill_active = wpinv_get_option('address_autofill_active'); |
290 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
291 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
292 | - wp_dequeue_script( 'google-maps-api' ); |
|
290 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
291 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
292 | + wp_dequeue_script('google-maps-api'); |
|
293 | 293 | } |
294 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
295 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
294 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
295 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
296 | 296 | } |
297 | 297 | |
298 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
299 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
298 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
299 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
300 | 300 | |
301 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
302 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
301 | + wp_enqueue_script('wpinv-front-script'); |
|
302 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
303 | 303 | |
304 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
305 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
304 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
305 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
306 | 306 | } |
307 | 307 | |
308 | - public function admin_enqueue_scripts( $hook ) { |
|
308 | + public function admin_enqueue_scripts($hook) { |
|
309 | 309 | global $post, $pagenow; |
310 | 310 | |
311 | 311 | $post_type = wpinv_admin_post_type(); |
312 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
313 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
312 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
313 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
314 | 314 | |
315 | 315 | $jquery_ui_css = false; |
316 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
316 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
317 | 317 | $jquery_ui_css = true; |
318 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
318 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
319 | 319 | $jquery_ui_css = true; |
320 | 320 | } |
321 | - if ( $jquery_ui_css ) { |
|
322 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
323 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
321 | + if ($jquery_ui_css) { |
|
322 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
323 | + wp_enqueue_style('jquery-ui-css'); |
|
324 | 324 | } |
325 | 325 | |
326 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
327 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
326 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
327 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
328 | 328 | |
329 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
330 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version ); |
|
331 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
329 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
330 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version); |
|
331 | + wp_enqueue_style('wpinv_admin_style'); |
|
332 | 332 | |
333 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
334 | - if ( $page == 'wpinv-subscriptions' ) { |
|
335 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
333 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
334 | + if ($page == 'wpinv-subscriptions') { |
|
335 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
336 | 336 | } |
337 | 337 | |
338 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
339 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
338 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
339 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
340 | 340 | } |
341 | 341 | |
342 | - wp_enqueue_style( 'wp-color-picker' ); |
|
343 | - wp_enqueue_script( 'wp-color-picker' ); |
|
342 | + wp_enqueue_style('wp-color-picker'); |
|
343 | + wp_enqueue_script('wp-color-picker'); |
|
344 | 344 | |
345 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
345 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
346 | 346 | |
347 | 347 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
348 | 348 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -353,21 +353,21 @@ discard block |
||
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
357 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
356 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
357 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
358 | 358 | |
359 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
360 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), $version ); |
|
361 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
359 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
360 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version); |
|
361 | + wp_enqueue_script('wpinv-admin-script'); |
|
362 | 362 | |
363 | 363 | $localize = array(); |
364 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
365 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
366 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
367 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
368 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
369 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
370 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
364 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
365 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
366 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
367 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
368 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
369 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
370 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
371 | 371 | $localize['tax'] = wpinv_tax_amount(); |
372 | 372 | $localize['discount'] = wpinv_discount_amount(); |
373 | 373 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -375,95 +375,95 @@ discard block |
||
375 | 375 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
376 | 376 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
377 | 377 | $localize['decimals'] = wpinv_decimals(); |
378 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
379 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
380 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
381 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
382 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
383 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
384 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
385 | - $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' ); |
|
386 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
387 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
388 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
389 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
390 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
391 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
392 | - |
|
393 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
394 | - |
|
395 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
378 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
379 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
380 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
381 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
382 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
383 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
384 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
385 | + $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'); |
|
386 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
387 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
388 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
389 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
390 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
391 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
392 | + |
|
393 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
394 | + |
|
395 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
396 | 396 | |
397 | 397 | // Load payment form scripts on our admin pages only. |
398 | - if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) { |
|
398 | + if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) { |
|
399 | 399 | |
400 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
401 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
402 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
400 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
401 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
402 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
403 | 403 | |
404 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
405 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
404 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
405 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
406 | 406 | |
407 | - wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
407 | + wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
408 | 408 | 'elements' => $this->form_elements->get_elements(), |
409 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
409 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
410 | 410 | 'all_items' => $this->form_elements->get_published_items(), |
411 | 411 | 'currency' => wpinv_currency_symbol(), |
412 | 412 | 'position' => wpinv_currency_position(), |
413 | 413 | 'decimals' => (int) wpinv_decimals(), |
414 | 414 | 'thousands_sep' => wpinv_thousands_separator(), |
415 | 415 | 'decimals_sep' => wpinv_decimal_separator(), |
416 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
417 | - ) ); |
|
416 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
417 | + )); |
|
418 | 418 | |
419 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
419 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
420 | 420 | } |
421 | 421 | |
422 | - if ( $page == 'wpinv-subscriptions' ) { |
|
423 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
424 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
422 | + if ($page == 'wpinv-subscriptions') { |
|
423 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
424 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | } |
428 | 428 | |
429 | - public function admin_body_class( $classes ) { |
|
429 | + public function admin_body_class($classes) { |
|
430 | 430 | global $pagenow, $post, $current_screen; |
431 | 431 | |
432 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
432 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) { |
|
433 | 433 | $classes .= ' wpinv-cpt'; |
434 | 434 | } |
435 | 435 | |
436 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
436 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
437 | 437 | |
438 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
439 | - if ( $add_class ) { |
|
440 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
438 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
439 | + if ($add_class) { |
|
440 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $settings_class = array(); |
444 | - if ( $page == 'wpinv-settings' ) { |
|
445 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
446 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
444 | + if ($page == 'wpinv-settings') { |
|
445 | + if (!empty($_REQUEST['tab'])) { |
|
446 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
447 | 447 | } |
448 | 448 | |
449 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
450 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
449 | + if (!empty($_REQUEST['section'])) { |
|
450 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
451 | 451 | } |
452 | 452 | |
453 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
453 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
454 | 454 | } |
455 | 455 | |
456 | - if ( !empty( $settings_class ) ) { |
|
457 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
456 | + if (!empty($settings_class)) { |
|
457 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | $post_type = wpinv_admin_post_type(); |
461 | 461 | |
462 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
462 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
463 | 463 | return $classes .= ' wpinv'; |
464 | 464 | } |
465 | 465 | |
466 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
466 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
467 | 467 | $classes .= ' wpi-editable-n'; |
468 | 468 | } |
469 | 469 | |
@@ -475,21 +475,21 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | public function wpinv_actions() { |
478 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
479 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
478 | + if (isset($_REQUEST['wpi_action'])) { |
|
479 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - public function pre_get_posts( $wp_query ) { |
|
484 | - 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() ) { |
|
485 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
483 | + public function pre_get_posts($wp_query) { |
|
484 | + 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()) { |
|
485 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | return $wp_query; |
489 | 489 | } |
490 | 490 | |
491 | 491 | public function bp_invoicing_init() { |
492 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
492 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -497,13 +497,13 @@ discard block |
||
497 | 497 | * |
498 | 498 | */ |
499 | 499 | public function register_widgets() { |
500 | - register_widget( "WPInv_Checkout_Widget" ); |
|
501 | - register_widget( "WPInv_History_Widget" ); |
|
502 | - register_widget( "WPInv_Receipt_Widget" ); |
|
503 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
504 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
505 | - register_widget( "WPInv_Messages_Widget" ); |
|
506 | - register_widget( 'WPInv_Payment_Form_Widget' ); |
|
500 | + register_widget("WPInv_Checkout_Widget"); |
|
501 | + register_widget("WPInv_History_Widget"); |
|
502 | + register_widget("WPInv_Receipt_Widget"); |
|
503 | + register_widget("WPInv_Subscriptions_Widget"); |
|
504 | + register_widget("WPInv_Buy_Item_Widget"); |
|
505 | + register_widget("WPInv_Messages_Widget"); |
|
506 | + register_widget('WPInv_Payment_Form_Widget'); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | * @since 1.0.19 |
513 | 513 | * @param int[] $excluded_posts_ids |
514 | 514 | */ |
515 | - function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
515 | + function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
516 | 516 | |
517 | 517 | // Ensure that we have an array. |
518 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
518 | + if (!is_array($excluded_posts_ids)) { |
|
519 | 519 | $excluded_posts_ids = array(); |
520 | 520 | } |
521 | 521 | |
@@ -523,24 +523,24 @@ discard block |
||
523 | 523 | $our_pages = array(); |
524 | 524 | |
525 | 525 | // Checkout page. |
526 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
526 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
527 | 527 | |
528 | 528 | // Success page. |
529 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
529 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
530 | 530 | |
531 | 531 | // Failure page. |
532 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
532 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
533 | 533 | |
534 | 534 | // History page. |
535 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
535 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
536 | 536 | |
537 | 537 | // Subscriptions page. |
538 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
538 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
539 | 539 | |
540 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
540 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
541 | 541 | |
542 | 542 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
543 | - return array_unique( $excluded_posts_ids ); |
|
543 | + return array_unique($excluded_posts_ids); |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | } |