@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | + |
|
134 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
135 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
136 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
137 | 137 | |
138 | 138 | // Fires after registering actions. |
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
139 | + do_action('wpinv_actions', $this); |
|
140 | + do_action('getpaid_actions', $this); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | /* Internationalize the text strings used. */ |
146 | 146 | $this->load_textdomain(); |
147 | 147 | |
148 | - do_action( 'wpinv_loaded' ); |
|
148 | + do_action('wpinv_loaded'); |
|
149 | 149 | |
150 | 150 | // Fix oxygen page builder conflict |
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
151 | + if (function_exists('ct_css_output')) { |
|
152 | 152 | wpinv_oxygen_fix_conflict(); |
153 | 153 | } |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | load_plugin_textdomain( |
170 | 170 | 'invoicing', |
171 | 171 | false, |
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
172 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -180,78 +180,78 @@ discard block |
||
180 | 180 | public function includes() { |
181 | 181 | |
182 | 182 | // Start with the settings. |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
184 | 184 | |
185 | 185 | // Packages/libraries. |
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
188 | 188 | |
189 | 189 | // Load functions. |
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
205 | 205 | |
206 | 206 | // Register autoloader. |
207 | 207 | try { |
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + spl_autoload_register(array($this, 'autoload'), true); |
|
209 | + } catch (Exception $e) { |
|
210 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
211 | 211 | } |
212 | 212 | |
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
234 | + |
|
235 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
236 | 236 | GetPaid_Post_Types_Admin::init(); |
237 | 237 | |
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
244 | 244 | // load the user class only on the users.php page |
245 | 245 | global $pagenow; |
246 | - if($pagenow=='users.php'){ |
|
246 | + if ($pagenow == 'users.php') { |
|
247 | 247 | new WPInv_Admin_Users(); |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Register cli commands |
252 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
252 | + if (defined('WP_CLI') && WP_CLI) { |
|
253 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
254 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
@@ -264,21 +264,21 @@ discard block |
||
264 | 264 | * @since 1.0.19 |
265 | 265 | * @return void |
266 | 266 | */ |
267 | - public function autoload( $class_name ) { |
|
267 | + public function autoload($class_name) { |
|
268 | 268 | |
269 | 269 | // Normalize the class name... |
270 | - $class_name = strtolower( $class_name ); |
|
270 | + $class_name = strtolower($class_name); |
|
271 | 271 | |
272 | 272 | // ... and make sure it is our class. |
273 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
273 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Next, prepare the file name from the class. |
278 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
278 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
279 | 279 | |
280 | 280 | // Base path of the classes. |
281 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
281 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
282 | 282 | |
283 | 283 | // And an array of possible locations in order of importance. |
284 | 284 | $locations = array( |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | "$plugin_path/includes/admin/meta-boxes", |
294 | 294 | ); |
295 | 295 | |
296 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
296 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
297 | 297 | |
298 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | - include trailingslashit( $location ) . $file_name; |
|
298 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
299 | + include trailingslashit($location) . $file_name; |
|
300 | 300 | break; |
301 | 301 | } |
302 | 302 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | public function init() { |
311 | 311 | |
312 | 312 | // Fires before getpaid inits. |
313 | - do_action( 'before_getpaid_init', $this ); |
|
313 | + do_action('before_getpaid_init', $this); |
|
314 | 314 | |
315 | 315 | // Maybe upgrade. |
316 | 316 | $this->maybe_upgrade_database(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | ) |
328 | 328 | ); |
329 | 329 | |
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
330 | + foreach ($gateways as $id => $class) { |
|
331 | + $this->gateways[$id] = new $class(); |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
334 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
335 | 335 | GetPaid_Installer::rename_gateways_label(); |
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
336 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Fires after getpaid inits. |
340 | - do_action( 'getpaid_init', $this ); |
|
340 | + do_action('getpaid_init', $this); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function maybe_process_ipn() { |
348 | 348 | |
349 | 349 | // Ensure that this is an IPN request. |
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
350 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
354 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
355 | 355 | |
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
356 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
357 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
358 | 358 | exit; |
359 | 359 | |
360 | 360 | } |
@@ -362,29 +362,29 @@ discard block |
||
362 | 362 | public function enqueue_scripts() { |
363 | 363 | |
364 | 364 | // Fires before adding scripts. |
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
365 | + do_action('getpaid_enqueue_scripts'); |
|
366 | 366 | |
367 | 367 | $localize = array(); |
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
368 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
369 | 369 | $localize['thousands'] = wpinv_thousands_separator(); |
370 | 370 | $localize['decimals'] = wpinv_decimal_separator(); |
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
371 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
372 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
373 | 373 | $localize['UseTaxes'] = wpinv_use_taxes(); |
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
374 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
375 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
376 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
377 | 377 | |
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
379 | 379 | |
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
380 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
381 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
382 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function wpinv_actions() { |
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
386 | + if (isset($_REQUEST['wpi_action'])) { |
|
387 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function maybe_do_authenticated_action() { |
398 | 398 | |
399 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
399 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
400 | 400 | |
401 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | - $data = wp_unslash( $_REQUEST ); |
|
403 | - if ( is_user_logged_in() ) { |
|
404 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
401 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
402 | + $data = wp_unslash($_REQUEST); |
|
403 | + if (is_user_logged_in()) { |
|
404 | + do_action("getpaid_authenticated_action_$key", $data); |
|
405 | 405 | } |
406 | 406 | |
407 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
407 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
412 | 412 | |
413 | - public function pre_get_posts( $wp_query ) { |
|
413 | + public function pre_get_posts($wp_query) { |
|
414 | 414 | |
415 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
416 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
415 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
416 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | return $wp_query; |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | |
429 | 429 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
430 | 430 | // So we disable our widgets when editing a page with UX Builder. |
431 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
431 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
436 | 436 | |
437 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
437 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
438 | 438 | // don't initiate in these conditions. |
439 | - }else{ |
|
439 | + } else { |
|
440 | 440 | |
441 | 441 | $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
442 | 442 | $widgets = apply_filters( |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | ) |
453 | 453 | ); |
454 | 454 | |
455 | - if( !empty($widgets) ){ |
|
456 | - foreach ( $widgets as $widget ) { |
|
457 | - if(!in_array($widget,$exclude)){ |
|
458 | - register_widget( $widget ); |
|
455 | + if (!empty($widgets)) { |
|
456 | + foreach ($widgets as $widget) { |
|
457 | + if (!in_array($widget, $exclude)) { |
|
458 | + register_widget($widget); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
@@ -471,29 +471,29 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public function maybe_upgrade_database() { |
473 | 473 | |
474 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
474 | + $wpi_version = get_option('wpinv_version', 0); |
|
475 | 475 | |
476 | - if ( $wpi_version == WPINV_VERSION ) { |
|
476 | + if ($wpi_version == WPINV_VERSION) { |
|
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | 480 | $installer = new GetPaid_Installer(); |
481 | 481 | |
482 | - if ( empty( $wpi_version ) ) { |
|
483 | - return $installer->upgrade_db( 0 ); |
|
482 | + if (empty($wpi_version)) { |
|
483 | + return $installer->upgrade_db(0); |
|
484 | 484 | } |
485 | 485 | |
486 | - $upgrades = array( |
|
486 | + $upgrades = array( |
|
487 | 487 | '0.0.5' => '004', |
488 | 488 | '1.0.3' => '102', |
489 | 489 | '2.0.0' => '118', |
490 | 490 | '2.0.8' => '207', |
491 | 491 | ); |
492 | 492 | |
493 | - foreach ( $upgrades as $key => $method ) { |
|
493 | + foreach ($upgrades as $key => $method) { |
|
494 | 494 | |
495 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
496 | - return $installer->upgrade_db( $method ); |
|
495 | + if (version_compare($wpi_version, $key, '<')) { |
|
496 | + return $installer->upgrade_db($method); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | } |
@@ -507,11 +507,11 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function maybe_flush_permalinks() { |
509 | 509 | |
510 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
510 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
511 | 511 | |
512 | - if ( ! empty( $flush ) ) { |
|
512 | + if (!empty($flush)) { |
|
513 | 513 | flush_rewrite_rules(); |
514 | - delete_option( 'wpinv_flush_permalinks' ); |
|
514 | + delete_option('wpinv_flush_permalinks'); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | } |
@@ -522,10 +522,10 @@ discard block |
||
522 | 522 | * @since 1.0.19 |
523 | 523 | * @param int[] $excluded_posts_ids |
524 | 524 | */ |
525 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
525 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
526 | 526 | |
527 | 527 | // Ensure that we have an array. |
528 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
528 | + if (!is_array($excluded_posts_ids)) { |
|
529 | 529 | $excluded_posts_ids = array(); |
530 | 530 | } |
531 | 531 | |
@@ -533,24 +533,24 @@ discard block |
||
533 | 533 | $our_pages = array(); |
534 | 534 | |
535 | 535 | // Checkout page. |
536 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
536 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
537 | 537 | |
538 | 538 | // Success page. |
539 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
539 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
540 | 540 | |
541 | 541 | // Failure page. |
542 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
542 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
543 | 543 | |
544 | 544 | // History page. |
545 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
545 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
546 | 546 | |
547 | 547 | // Subscriptions page. |
548 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
548 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
549 | 549 | |
550 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
550 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
551 | 551 | |
552 | 552 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
553 | - return array_unique( $excluded_posts_ids ); |
|
553 | + return array_unique($excluded_posts_ids); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @since 2.0.0 |
561 | 561 | */ |
562 | 562 | public function wp_footer() { |
563 | - wpinv_get_template( 'frontend-footer.php' ); |
|
563 | + wpinv_get_template('frontend-footer.php'); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,14 +569,14 @@ discard block |
||
569 | 569 | * @since 2.0.0 |
570 | 570 | */ |
571 | 571 | public function wp_head() { |
572 | - wpinv_get_template( 'frontend-head.php' ); |
|
572 | + wpinv_get_template('frontend-head.php'); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
576 | 576 | * Custom query vars. |
577 | 577 | * |
578 | 578 | */ |
579 | - public function custom_query_vars( $vars ) { |
|
579 | + public function custom_query_vars($vars) { |
|
580 | 580 | $vars[] = 'getpaid-ipn'; |
581 | 581 | return $vars; |
582 | 582 | } |
@@ -587,28 +587,28 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function add_rewrite_rule() { |
589 | 589 | $tag = 'getpaid-ipn'; |
590 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
591 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
|
590 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
591 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
595 | 595 | * Processes non-query string ipns. |
596 | 596 | * |
597 | 597 | */ |
598 | - public function maybe_process_new_ipn( $query ) { |
|
598 | + public function maybe_process_new_ipn($query) { |
|
599 | 599 | |
600 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
600 | + if (is_admin() || !$query->is_main_query()) { |
|
601 | 601 | return; |
602 | 602 | } |
603 | 603 | |
604 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
604 | + $gateway = get_query_var('getpaid-ipn'); |
|
605 | 605 | |
606 | - if ( ! empty( $gateway ) ){ |
|
606 | + if (!empty($gateway)) { |
|
607 | 607 | |
608 | - $gateway = sanitize_text_field( $gateway ); |
|
608 | + $gateway = sanitize_text_field($gateway); |
|
609 | 609 | nocache_headers(); |
610 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
611 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
610 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
611 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
612 | 612 | exit; |
613 | 613 | |
614 | 614 | } |