@@ -14,421 +14,421 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Plugin { |
16 | 16 | |
17 | - /** |
|
18 | - * GetPaid version. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * Data container. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * Form elements instance. |
|
33 | - * |
|
34 | - * @var WPInv_Payment_Form_Elements |
|
35 | - */ |
|
36 | - public $form_elements; |
|
37 | - |
|
38 | - /** |
|
39 | - * Tax instance. |
|
40 | - * |
|
41 | - * @var WPInv_EUVat |
|
42 | - */ |
|
43 | - public $tax; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param array An array of payment gateways. |
|
47 | - */ |
|
48 | - public $gateways; |
|
49 | - |
|
50 | - /** |
|
51 | - * Class constructor. |
|
52 | - */ |
|
53 | - public function __construct() { |
|
54 | - $this->define_constants(); |
|
55 | - $this->includes(); |
|
56 | - $this->init_hooks(); |
|
57 | - $this->set_properties(); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Sets a custom data property. |
|
62 | - * |
|
63 | - * @param string $prop The prop to set. |
|
64 | - * @param mixed $value The value to retrieve. |
|
65 | - */ |
|
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Gets a custom data property. |
|
72 | - * |
|
73 | - * @param string $prop The prop to set. |
|
74 | - * @return mixed The value. |
|
75 | - */ |
|
76 | - public function get( $prop ) { |
|
77 | - |
|
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
80 | - } |
|
81 | - |
|
82 | - return null; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Define class properties. |
|
87 | - */ |
|
88 | - public function set_properties() { |
|
89 | - |
|
90 | - // Sessions. |
|
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
93 | - $this->form_elements = new WPInv_Payment_Form_Elements(); |
|
94 | - $this->tax = new WPInv_EUVat(); |
|
95 | - $this->tax->init(); |
|
96 | - $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
97 | - |
|
98 | - // Init other objects. |
|
99 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
100 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
101 | - $this->set( 'notes', new WPInv_Notes() ); |
|
102 | - $this->set( 'api', new WPInv_API() ); |
|
103 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
104 | - $this->set( 'template', new GetPaid_Template() ); |
|
105 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
106 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
107 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
108 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
109 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
110 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Define plugin constants. |
|
116 | - */ |
|
117 | - public function define_constants() { |
|
118 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
120 | - $this->version = WPINV_VERSION; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Hook into actions and filters. |
|
125 | - * |
|
126 | - * @since 1.0.19 |
|
127 | - */ |
|
128 | - protected function init_hooks() { |
|
129 | - /* Internationalize the text strings used. */ |
|
130 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
131 | - |
|
132 | - // Init the plugin after WordPress inits. |
|
133 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | - add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
|
135 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
136 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
137 | - |
|
138 | - if ( class_exists( 'BuddyPress' ) ) { |
|
139 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
140 | - } |
|
141 | - |
|
142 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
147 | - |
|
148 | - // Fires after registering actions. |
|
149 | - do_action( 'wpinv_actions', $this ); |
|
150 | - do_action( 'getpaid_actions', $this ); |
|
151 | - |
|
152 | - } |
|
153 | - |
|
154 | - public function plugins_loaded() { |
|
155 | - /* Internationalize the text strings used. */ |
|
156 | - $this->load_textdomain(); |
|
157 | - |
|
158 | - do_action( 'wpinv_loaded' ); |
|
159 | - |
|
160 | - // Fix oxygen page builder conflict |
|
161 | - if ( function_exists( 'ct_css_output' ) ) { |
|
162 | - wpinv_oxygen_fix_conflict(); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Load the translation of the plugin. |
|
168 | - * |
|
169 | - * @since 1.0 |
|
170 | - */ |
|
171 | - public function load_textdomain( $locale = NULL ) { |
|
172 | - if ( empty( $locale ) ) { |
|
173 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
174 | - } |
|
175 | - |
|
176 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
177 | - |
|
178 | - unload_textdomain( 'invoicing' ); |
|
179 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
181 | - |
|
182 | - /** |
|
183 | - * Define language constants. |
|
184 | - */ |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Include required core files used in admin and on the frontend. |
|
190 | - */ |
|
191 | - public function includes() { |
|
192 | - |
|
193 | - // Start with the settings. |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
195 | - |
|
196 | - // Packages/libraries. |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
199 | - |
|
200 | - // Load functions. |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
216 | - |
|
217 | - // Register autoloader. |
|
218 | - try { |
|
219 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | - } catch ( Exception $e ) { |
|
221 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
222 | - } |
|
223 | - |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
245 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
246 | - |
|
247 | - /** |
|
248 | - * Load the tax class. |
|
249 | - */ |
|
250 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
251 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
252 | - } |
|
253 | - |
|
254 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
255 | - GetPaid_Post_Types_Admin::init(); |
|
256 | - |
|
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
263 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
264 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
265 | - // load the user class only on the users.php page |
|
266 | - global $pagenow; |
|
267 | - if($pagenow=='users.php'){ |
|
268 | - new WPInv_Admin_Users(); |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - // Register cli commands |
|
273 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
274 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
275 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
276 | - } |
|
277 | - |
|
278 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Class autoloader |
|
283 | - * |
|
284 | - * @param string $class_name The name of the class to load. |
|
285 | - * @access public |
|
286 | - * @since 1.0.19 |
|
287 | - * @return void |
|
288 | - */ |
|
289 | - public function autoload( $class_name ) { |
|
290 | - |
|
291 | - // Normalize the class name... |
|
292 | - $class_name = strtolower( $class_name ); |
|
293 | - |
|
294 | - // ... and make sure it is our class. |
|
295 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
296 | - return; |
|
297 | - } |
|
298 | - |
|
299 | - // Next, prepare the file name from the class. |
|
300 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
301 | - |
|
302 | - // Base path of the classes. |
|
303 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
304 | - |
|
305 | - // And an array of possible locations in order of importance. |
|
306 | - $locations = array( |
|
307 | - "$plugin_path/includes", |
|
308 | - "$plugin_path/includes/data-stores", |
|
309 | - "$plugin_path/includes/gateways", |
|
310 | - "$plugin_path/includes/api", |
|
311 | - "$plugin_path/includes/admin", |
|
312 | - "$plugin_path/includes/admin/meta-boxes", |
|
313 | - ); |
|
314 | - |
|
315 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
316 | - |
|
317 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
318 | - include trailingslashit( $location ) . $file_name; |
|
319 | - break; |
|
320 | - } |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Inits hooks etc. |
|
328 | - */ |
|
329 | - public function init() { |
|
330 | - |
|
331 | - // Fires before getpaid inits. |
|
332 | - do_action( 'before_getpaid_init', $this ); |
|
333 | - |
|
334 | - // Load default gateways. |
|
335 | - $gateways = apply_filters( |
|
336 | - 'getpaid_default_gateways', |
|
337 | - array( |
|
338 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
339 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
340 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
341 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
342 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
343 | - ) |
|
344 | - ); |
|
345 | - |
|
346 | - foreach ( $gateways as $id => $class ) { |
|
347 | - $this->gateways[ $id ] = new $class(); |
|
348 | - } |
|
349 | - |
|
350 | - // Fires after getpaid inits. |
|
351 | - do_action( 'getpaid_init', $this ); |
|
352 | - |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Checks if this is an IPN request and processes it. |
|
357 | - */ |
|
358 | - public function maybe_process_ipn() { |
|
359 | - |
|
360 | - // Ensure that this is an IPN request. |
|
361 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
362 | - return; |
|
363 | - } |
|
364 | - |
|
365 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
366 | - |
|
367 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
368 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
369 | - exit; |
|
370 | - |
|
371 | - } |
|
372 | - |
|
373 | - public function enqueue_scripts() { |
|
374 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
375 | - |
|
376 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
377 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
378 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
379 | - |
|
380 | - // Register scripts |
|
381 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
382 | - 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' ) ); |
|
383 | - |
|
384 | - $localize = array(); |
|
385 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
386 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
387 | - $localize['currency_symbol'] = wpinv_currency_symbol(); |
|
388 | - $localize['currency_pos'] = wpinv_currency_position(); |
|
389 | - $localize['thousand_sep'] = wpinv_thousands_separator(); |
|
390 | - $localize['decimal_sep'] = wpinv_decimal_separator(); |
|
391 | - $localize['decimals'] = wpinv_decimals(); |
|
392 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
393 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
394 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
395 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
396 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
397 | - |
|
398 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
399 | - |
|
400 | - wp_enqueue_script( 'jquery-blockui' ); |
|
401 | - $autofill_api = wpinv_get_option('address_autofill_api'); |
|
402 | - $autofill_active = wpinv_get_option('address_autofill_active'); |
|
403 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
404 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
405 | - wp_dequeue_script( 'google-maps-api' ); |
|
406 | - } |
|
407 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
408 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
409 | - } |
|
410 | - |
|
411 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
412 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
413 | - |
|
414 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
415 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
416 | - |
|
417 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
418 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
419 | - } |
|
420 | - |
|
421 | - public function wpinv_actions() { |
|
422 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
423 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
424 | - } |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
17 | + /** |
|
18 | + * GetPaid version. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * Data container. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * Form elements instance. |
|
33 | + * |
|
34 | + * @var WPInv_Payment_Form_Elements |
|
35 | + */ |
|
36 | + public $form_elements; |
|
37 | + |
|
38 | + /** |
|
39 | + * Tax instance. |
|
40 | + * |
|
41 | + * @var WPInv_EUVat |
|
42 | + */ |
|
43 | + public $tax; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param array An array of payment gateways. |
|
47 | + */ |
|
48 | + public $gateways; |
|
49 | + |
|
50 | + /** |
|
51 | + * Class constructor. |
|
52 | + */ |
|
53 | + public function __construct() { |
|
54 | + $this->define_constants(); |
|
55 | + $this->includes(); |
|
56 | + $this->init_hooks(); |
|
57 | + $this->set_properties(); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Sets a custom data property. |
|
62 | + * |
|
63 | + * @param string $prop The prop to set. |
|
64 | + * @param mixed $value The value to retrieve. |
|
65 | + */ |
|
66 | + public function set( $prop, $value ) { |
|
67 | + $this->data[ $prop ] = $value; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Gets a custom data property. |
|
72 | + * |
|
73 | + * @param string $prop The prop to set. |
|
74 | + * @return mixed The value. |
|
75 | + */ |
|
76 | + public function get( $prop ) { |
|
77 | + |
|
78 | + if ( isset( $this->data[ $prop ] ) ) { |
|
79 | + return $this->data[ $prop ]; |
|
80 | + } |
|
81 | + |
|
82 | + return null; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Define class properties. |
|
87 | + */ |
|
88 | + public function set_properties() { |
|
89 | + |
|
90 | + // Sessions. |
|
91 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
93 | + $this->form_elements = new WPInv_Payment_Form_Elements(); |
|
94 | + $this->tax = new WPInv_EUVat(); |
|
95 | + $this->tax->init(); |
|
96 | + $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
97 | + |
|
98 | + // Init other objects. |
|
99 | + $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
100 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
101 | + $this->set( 'notes', new WPInv_Notes() ); |
|
102 | + $this->set( 'api', new WPInv_API() ); |
|
103 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
104 | + $this->set( 'template', new GetPaid_Template() ); |
|
105 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
106 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
107 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
108 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
109 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
110 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
111 | + |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Define plugin constants. |
|
116 | + */ |
|
117 | + public function define_constants() { |
|
118 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
120 | + $this->version = WPINV_VERSION; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Hook into actions and filters. |
|
125 | + * |
|
126 | + * @since 1.0.19 |
|
127 | + */ |
|
128 | + protected function init_hooks() { |
|
129 | + /* Internationalize the text strings used. */ |
|
130 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
131 | + |
|
132 | + // Init the plugin after WordPress inits. |
|
133 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | + add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
|
135 | + add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
136 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
137 | + |
|
138 | + if ( class_exists( 'BuddyPress' ) ) { |
|
139 | + add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
140 | + } |
|
141 | + |
|
142 | + add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | + add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
147 | + |
|
148 | + // Fires after registering actions. |
|
149 | + do_action( 'wpinv_actions', $this ); |
|
150 | + do_action( 'getpaid_actions', $this ); |
|
151 | + |
|
152 | + } |
|
153 | + |
|
154 | + public function plugins_loaded() { |
|
155 | + /* Internationalize the text strings used. */ |
|
156 | + $this->load_textdomain(); |
|
157 | + |
|
158 | + do_action( 'wpinv_loaded' ); |
|
159 | + |
|
160 | + // Fix oxygen page builder conflict |
|
161 | + if ( function_exists( 'ct_css_output' ) ) { |
|
162 | + wpinv_oxygen_fix_conflict(); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Load the translation of the plugin. |
|
168 | + * |
|
169 | + * @since 1.0 |
|
170 | + */ |
|
171 | + public function load_textdomain( $locale = NULL ) { |
|
172 | + if ( empty( $locale ) ) { |
|
173 | + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
174 | + } |
|
175 | + |
|
176 | + $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
177 | + |
|
178 | + unload_textdomain( 'invoicing' ); |
|
179 | + load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | + load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
181 | + |
|
182 | + /** |
|
183 | + * Define language constants. |
|
184 | + */ |
|
185 | + require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Include required core files used in admin and on the frontend. |
|
190 | + */ |
|
191 | + public function includes() { |
|
192 | + |
|
193 | + // Start with the settings. |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
195 | + |
|
196 | + // Packages/libraries. |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
199 | + |
|
200 | + // Load functions. |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
216 | + |
|
217 | + // Register autoloader. |
|
218 | + try { |
|
219 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | + } catch ( Exception $e ) { |
|
221 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
222 | + } |
|
223 | + |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
245 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
246 | + |
|
247 | + /** |
|
248 | + * Load the tax class. |
|
249 | + */ |
|
250 | + if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
251 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
252 | + } |
|
253 | + |
|
254 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
255 | + GetPaid_Post_Types_Admin::init(); |
|
256 | + |
|
257 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
258 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
259 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
260 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
261 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
262 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
263 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
264 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
265 | + // load the user class only on the users.php page |
|
266 | + global $pagenow; |
|
267 | + if($pagenow=='users.php'){ |
|
268 | + new WPInv_Admin_Users(); |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + // Register cli commands |
|
273 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
274 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
275 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
276 | + } |
|
277 | + |
|
278 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Class autoloader |
|
283 | + * |
|
284 | + * @param string $class_name The name of the class to load. |
|
285 | + * @access public |
|
286 | + * @since 1.0.19 |
|
287 | + * @return void |
|
288 | + */ |
|
289 | + public function autoload( $class_name ) { |
|
290 | + |
|
291 | + // Normalize the class name... |
|
292 | + $class_name = strtolower( $class_name ); |
|
293 | + |
|
294 | + // ... and make sure it is our class. |
|
295 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
296 | + return; |
|
297 | + } |
|
298 | + |
|
299 | + // Next, prepare the file name from the class. |
|
300 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
301 | + |
|
302 | + // Base path of the classes. |
|
303 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
304 | + |
|
305 | + // And an array of possible locations in order of importance. |
|
306 | + $locations = array( |
|
307 | + "$plugin_path/includes", |
|
308 | + "$plugin_path/includes/data-stores", |
|
309 | + "$plugin_path/includes/gateways", |
|
310 | + "$plugin_path/includes/api", |
|
311 | + "$plugin_path/includes/admin", |
|
312 | + "$plugin_path/includes/admin/meta-boxes", |
|
313 | + ); |
|
314 | + |
|
315 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
316 | + |
|
317 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
318 | + include trailingslashit( $location ) . $file_name; |
|
319 | + break; |
|
320 | + } |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Inits hooks etc. |
|
328 | + */ |
|
329 | + public function init() { |
|
330 | + |
|
331 | + // Fires before getpaid inits. |
|
332 | + do_action( 'before_getpaid_init', $this ); |
|
333 | + |
|
334 | + // Load default gateways. |
|
335 | + $gateways = apply_filters( |
|
336 | + 'getpaid_default_gateways', |
|
337 | + array( |
|
338 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
339 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
340 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
341 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
342 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
343 | + ) |
|
344 | + ); |
|
345 | + |
|
346 | + foreach ( $gateways as $id => $class ) { |
|
347 | + $this->gateways[ $id ] = new $class(); |
|
348 | + } |
|
349 | + |
|
350 | + // Fires after getpaid inits. |
|
351 | + do_action( 'getpaid_init', $this ); |
|
352 | + |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * Checks if this is an IPN request and processes it. |
|
357 | + */ |
|
358 | + public function maybe_process_ipn() { |
|
359 | + |
|
360 | + // Ensure that this is an IPN request. |
|
361 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
362 | + return; |
|
363 | + } |
|
364 | + |
|
365 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
366 | + |
|
367 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
368 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
369 | + exit; |
|
370 | + |
|
371 | + } |
|
372 | + |
|
373 | + public function enqueue_scripts() { |
|
374 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
375 | + |
|
376 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
377 | + wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
378 | + wp_enqueue_style( 'wpinv_front_style' ); |
|
379 | + |
|
380 | + // Register scripts |
|
381 | + wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
382 | + 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' ) ); |
|
383 | + |
|
384 | + $localize = array(); |
|
385 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
386 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
387 | + $localize['currency_symbol'] = wpinv_currency_symbol(); |
|
388 | + $localize['currency_pos'] = wpinv_currency_position(); |
|
389 | + $localize['thousand_sep'] = wpinv_thousands_separator(); |
|
390 | + $localize['decimal_sep'] = wpinv_decimal_separator(); |
|
391 | + $localize['decimals'] = wpinv_decimals(); |
|
392 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
393 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
394 | + $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
395 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
396 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
397 | + |
|
398 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
399 | + |
|
400 | + wp_enqueue_script( 'jquery-blockui' ); |
|
401 | + $autofill_api = wpinv_get_option('address_autofill_api'); |
|
402 | + $autofill_active = wpinv_get_option('address_autofill_active'); |
|
403 | + if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
404 | + if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
405 | + wp_dequeue_script( 'google-maps-api' ); |
|
406 | + } |
|
407 | + wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
408 | + wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
409 | + } |
|
410 | + |
|
411 | + wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
412 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
413 | + |
|
414 | + wp_enqueue_script( 'wpinv-front-script' ); |
|
415 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
416 | + |
|
417 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
418 | + wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
419 | + } |
|
420 | + |
|
421 | + public function wpinv_actions() { |
|
422 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
423 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
424 | + } |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | 428 | * Fires an action after verifying that a user can fire them. |
429 | - * |
|
430 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
431 | - * current user owns the invoice/subscription. |
|
429 | + * |
|
430 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
431 | + * current user owns the invoice/subscription. |
|
432 | 432 | */ |
433 | 433 | public function maybe_do_authenticated_action() { |
434 | 434 | |
@@ -439,82 +439,82 @@ discard block |
||
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | - public function pre_get_posts( $wp_query ) { |
|
443 | - if ( ! is_admin() && !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() ) { |
|
444 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
445 | - } |
|
446 | - |
|
447 | - return $wp_query; |
|
448 | - } |
|
449 | - |
|
450 | - public function bp_invoicing_init() { |
|
451 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Register widgets |
|
456 | - * |
|
457 | - */ |
|
458 | - public function register_widgets() { |
|
459 | - $widgets = apply_filters( |
|
460 | - 'getpaid_widget_classes', |
|
461 | - array( |
|
462 | - 'WPInv_Checkout_Widget', |
|
463 | - 'WPInv_History_Widget', |
|
464 | - 'WPInv_Receipt_Widget', |
|
465 | - 'WPInv_Subscriptions_Widget', |
|
466 | - 'WPInv_Buy_Item_Widget', |
|
467 | - 'WPInv_Messages_Widget', |
|
468 | - 'WPInv_GetPaid_Widget' |
|
469 | - ) |
|
470 | - ); |
|
471 | - |
|
472 | - foreach ( $widgets as $widget ) { |
|
473 | - register_widget( $widget ); |
|
474 | - } |
|
442 | + public function pre_get_posts( $wp_query ) { |
|
443 | + if ( ! is_admin() && !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() ) { |
|
444 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
445 | + } |
|
446 | + |
|
447 | + return $wp_query; |
|
448 | + } |
|
449 | + |
|
450 | + public function bp_invoicing_init() { |
|
451 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Register widgets |
|
456 | + * |
|
457 | + */ |
|
458 | + public function register_widgets() { |
|
459 | + $widgets = apply_filters( |
|
460 | + 'getpaid_widget_classes', |
|
461 | + array( |
|
462 | + 'WPInv_Checkout_Widget', |
|
463 | + 'WPInv_History_Widget', |
|
464 | + 'WPInv_Receipt_Widget', |
|
465 | + 'WPInv_Subscriptions_Widget', |
|
466 | + 'WPInv_Buy_Item_Widget', |
|
467 | + 'WPInv_Messages_Widget', |
|
468 | + 'WPInv_GetPaid_Widget' |
|
469 | + ) |
|
470 | + ); |
|
471 | + |
|
472 | + foreach ( $widgets as $widget ) { |
|
473 | + register_widget( $widget ); |
|
474 | + } |
|
475 | 475 | |
476 | - } |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * Remove our pages from yoast sitemaps. |
|
480 | - * |
|
481 | - * @since 1.0.19 |
|
482 | - * @param int[] $excluded_posts_ids |
|
483 | - */ |
|
484 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
478 | + /** |
|
479 | + * Remove our pages from yoast sitemaps. |
|
480 | + * |
|
481 | + * @since 1.0.19 |
|
482 | + * @param int[] $excluded_posts_ids |
|
483 | + */ |
|
484 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
485 | 485 | |
486 | - // Ensure that we have an array. |
|
487 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
488 | - $excluded_posts_ids = array(); |
|
489 | - } |
|
486 | + // Ensure that we have an array. |
|
487 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
488 | + $excluded_posts_ids = array(); |
|
489 | + } |
|
490 | 490 | |
491 | - // Prepare our pages. |
|
492 | - $our_pages = array(); |
|
491 | + // Prepare our pages. |
|
492 | + $our_pages = array(); |
|
493 | 493 | |
494 | - // Checkout page. |
|
495 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
494 | + // Checkout page. |
|
495 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
496 | 496 | |
497 | - // Success page. |
|
498 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
497 | + // Success page. |
|
498 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
499 | 499 | |
500 | - // Failure page. |
|
501 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
500 | + // Failure page. |
|
501 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
502 | 502 | |
503 | - // History page. |
|
504 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
503 | + // History page. |
|
504 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
505 | 505 | |
506 | - // Subscriptions page. |
|
507 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
506 | + // Subscriptions page. |
|
507 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
508 | 508 | |
509 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
509 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
510 | 510 | |
511 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
512 | - return array_unique( $excluded_posts_ids ); |
|
511 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
512 | + return array_unique( $excluded_posts_ids ); |
|
513 | 513 | |
514 | - } |
|
514 | + } |
|
515 | 515 | |
516 | - public function wp_footer() { |
|
517 | - echo ' |
|
516 | + public function wp_footer() { |
|
517 | + echo ' |
|
518 | 518 | <div class="bsui"> |
519 | 519 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
520 | 520 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
@@ -525,6 +525,6 @@ discard block |
||
525 | 525 | </div> |
526 | 526 | </div> |
527 | 527 | '; |
528 | - } |
|
528 | + } |
|
529 | 529 | |
530 | 530 | } |
@@ -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. |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param string $prop The prop to set. |
64 | 64 | * @param mixed $value The value to retrieve. |
65 | 65 | */ |
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
66 | + public function set($prop, $value) { |
|
67 | + $this->data[$prop] = $value; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @param string $prop The prop to set. |
74 | 74 | * @return mixed The value. |
75 | 75 | */ |
76 | - public function get( $prop ) { |
|
76 | + public function get($prop) { |
|
77 | 77 | |
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
78 | + if (isset($this->data[$prop])) { |
|
79 | + return $this->data[$prop]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return null; |
@@ -88,26 +88,26 @@ discard block |
||
88 | 88 | public function set_properties() { |
89 | 89 | |
90 | 90 | // Sessions. |
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
91 | + $this->set('session', new WPInv_Session_Handler()); |
|
92 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
93 | 93 | $this->form_elements = new WPInv_Payment_Form_Elements(); |
94 | 94 | $this->tax = new WPInv_EUVat(); |
95 | 95 | $this->tax->init(); |
96 | 96 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
97 | 97 | |
98 | 98 | // Init other objects. |
99 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
100 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
101 | - $this->set( 'notes', new WPInv_Notes() ); |
|
102 | - $this->set( 'api', new WPInv_API() ); |
|
103 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
104 | - $this->set( 'template', new GetPaid_Template() ); |
|
105 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
106 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
107 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
108 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
109 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
110 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
99 | + $this->set('reports', new WPInv_Reports()); // TODO: Refactor. |
|
100 | + $this->set('session', new WPInv_Session_Handler()); |
|
101 | + $this->set('notes', new WPInv_Notes()); |
|
102 | + $this->set('api', new WPInv_API()); |
|
103 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
104 | + $this->set('template', new GetPaid_Template()); |
|
105 | + $this->set('admin', new GetPaid_Admin()); |
|
106 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
107 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
108 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
109 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
110 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * Define plugin constants. |
116 | 116 | */ |
117 | 117 | public function define_constants() { |
118 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
118 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
119 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
120 | 120 | $this->version = WPINV_VERSION; |
121 | 121 | } |
122 | 122 | |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function init_hooks() { |
129 | 129 | /* Internationalize the text strings used. */ |
130 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
130 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
131 | 131 | |
132 | 132 | // Init the plugin after WordPress inits. |
133 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | - add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
|
135 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
136 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
133 | + add_action('init', array($this, 'init'), 1); |
|
134 | + add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5); |
|
135 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
136 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
137 | 137 | |
138 | - if ( class_exists( 'BuddyPress' ) ) { |
|
139 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
138 | + if (class_exists('BuddyPress')) { |
|
139 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
140 | 140 | } |
141 | 141 | |
142 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
142 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
143 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
144 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
145 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
146 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
147 | 147 | |
148 | 148 | // Fires after registering actions. |
149 | - do_action( 'wpinv_actions', $this ); |
|
150 | - do_action( 'getpaid_actions', $this ); |
|
149 | + do_action('wpinv_actions', $this); |
|
150 | + do_action('getpaid_actions', $this); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | /* Internationalize the text strings used. */ |
156 | 156 | $this->load_textdomain(); |
157 | 157 | |
158 | - do_action( 'wpinv_loaded' ); |
|
158 | + do_action('wpinv_loaded'); |
|
159 | 159 | |
160 | 160 | // Fix oxygen page builder conflict |
161 | - if ( function_exists( 'ct_css_output' ) ) { |
|
161 | + if (function_exists('ct_css_output')) { |
|
162 | 162 | wpinv_oxygen_fix_conflict(); |
163 | 163 | } |
164 | 164 | } |
@@ -168,21 +168,21 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @since 1.0 |
170 | 170 | */ |
171 | - public function load_textdomain( $locale = NULL ) { |
|
172 | - if ( empty( $locale ) ) { |
|
173 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
171 | + public function load_textdomain($locale = NULL) { |
|
172 | + if (empty($locale)) { |
|
173 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
174 | 174 | } |
175 | 175 | |
176 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
176 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
177 | 177 | |
178 | - unload_textdomain( 'invoicing' ); |
|
179 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
178 | + unload_textdomain('invoicing'); |
|
179 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
180 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Define language constants. |
184 | 184 | */ |
185 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,91 +191,91 @@ discard block |
||
191 | 191 | public function includes() { |
192 | 192 | |
193 | 193 | // Start with the settings. |
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
195 | 195 | |
196 | 196 | // Packages/libraries. |
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
199 | 199 | |
200 | 200 | // Load functions. |
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
216 | 216 | |
217 | 217 | // Register autoloader. |
218 | 218 | try { |
219 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | - } catch ( Exception $e ) { |
|
221 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
219 | + spl_autoload_register(array($this, 'autoload'), true); |
|
220 | + } catch (Exception $e) { |
|
221 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
222 | 222 | } |
223 | 223 | |
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
245 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
244 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
245 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Load the tax class. |
249 | 249 | */ |
250 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
251 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
250 | + if (!class_exists('WPInv_EUVat')) { |
|
251 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
252 | 252 | } |
253 | 253 | |
254 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
254 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
255 | 255 | GetPaid_Post_Types_Admin::init(); |
256 | 256 | |
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
263 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
264 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
257 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
258 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
259 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
260 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
261 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
262 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
263 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
264 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
265 | 265 | // load the user class only on the users.php page |
266 | 266 | global $pagenow; |
267 | - if($pagenow=='users.php'){ |
|
267 | + if ($pagenow == 'users.php') { |
|
268 | 268 | new WPInv_Admin_Users(); |
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Register cli commands |
273 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
274 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
275 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
273 | + if (defined('WP_CLI') && WP_CLI) { |
|
274 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
275 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
276 | 276 | } |
277 | 277 | |
278 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
278 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -286,21 +286,21 @@ discard block |
||
286 | 286 | * @since 1.0.19 |
287 | 287 | * @return void |
288 | 288 | */ |
289 | - public function autoload( $class_name ) { |
|
289 | + public function autoload($class_name) { |
|
290 | 290 | |
291 | 291 | // Normalize the class name... |
292 | - $class_name = strtolower( $class_name ); |
|
292 | + $class_name = strtolower($class_name); |
|
293 | 293 | |
294 | 294 | // ... and make sure it is our class. |
295 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
295 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Next, prepare the file name from the class. |
300 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
300 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
301 | 301 | |
302 | 302 | // Base path of the classes. |
303 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
303 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
304 | 304 | |
305 | 305 | // And an array of possible locations in order of importance. |
306 | 306 | $locations = array( |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | "$plugin_path/includes/admin/meta-boxes", |
313 | 313 | ); |
314 | 314 | |
315 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
315 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
316 | 316 | |
317 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
318 | - include trailingslashit( $location ) . $file_name; |
|
317 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
318 | + include trailingslashit($location) . $file_name; |
|
319 | 319 | break; |
320 | 320 | } |
321 | 321 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | public function init() { |
330 | 330 | |
331 | 331 | // Fires before getpaid inits. |
332 | - do_action( 'before_getpaid_init', $this ); |
|
332 | + do_action('before_getpaid_init', $this); |
|
333 | 333 | |
334 | 334 | // Load default gateways. |
335 | 335 | $gateways = apply_filters( |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | ) |
344 | 344 | ); |
345 | 345 | |
346 | - foreach ( $gateways as $id => $class ) { |
|
347 | - $this->gateways[ $id ] = new $class(); |
|
346 | + foreach ($gateways as $id => $class) { |
|
347 | + $this->gateways[$id] = new $class(); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Fires after getpaid inits. |
351 | - do_action( 'getpaid_init', $this ); |
|
351 | + do_action('getpaid_init', $this); |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | |
@@ -358,69 +358,69 @@ discard block |
||
358 | 358 | public function maybe_process_ipn() { |
359 | 359 | |
360 | 360 | // Ensure that this is an IPN request. |
361 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
361 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
362 | 362 | return; |
363 | 363 | } |
364 | 364 | |
365 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
365 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
366 | 366 | |
367 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
368 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
367 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
368 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
369 | 369 | exit; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | 373 | public function enqueue_scripts() { |
374 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
374 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
375 | 375 | |
376 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
377 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
378 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
376 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
377 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
378 | + wp_enqueue_style('wpinv_front_style'); |
|
379 | 379 | |
380 | 380 | // Register scripts |
381 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
382 | - 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' ) ); |
|
381 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
382 | + 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')); |
|
383 | 383 | |
384 | 384 | $localize = array(); |
385 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
386 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
385 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
386 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
387 | 387 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
388 | 388 | $localize['currency_pos'] = wpinv_currency_position(); |
389 | 389 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
390 | 390 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
391 | 391 | $localize['decimals'] = wpinv_decimals(); |
392 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
392 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
393 | 393 | $localize['UseTaxes'] = wpinv_use_taxes(); |
394 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
395 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
396 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
394 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
395 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
396 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
397 | 397 | |
398 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
398 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
399 | 399 | |
400 | - wp_enqueue_script( 'jquery-blockui' ); |
|
400 | + wp_enqueue_script('jquery-blockui'); |
|
401 | 401 | $autofill_api = wpinv_get_option('address_autofill_api'); |
402 | 402 | $autofill_active = wpinv_get_option('address_autofill_active'); |
403 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
404 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
405 | - wp_dequeue_script( 'google-maps-api' ); |
|
403 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
404 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
405 | + wp_dequeue_script('google-maps-api'); |
|
406 | 406 | } |
407 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
408 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
407 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
408 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
409 | 409 | } |
410 | 410 | |
411 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
412 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
411 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all'); |
|
412 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
413 | 413 | |
414 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
415 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
414 | + wp_enqueue_script('wpinv-front-script'); |
|
415 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
416 | 416 | |
417 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
418 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
417 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
418 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | public function wpinv_actions() { |
422 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
423 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
422 | + if (isset($_REQUEST['wpi_action'])) { |
|
423 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
@@ -432,23 +432,23 @@ discard block |
||
432 | 432 | */ |
433 | 433 | public function maybe_do_authenticated_action() { |
434 | 434 | |
435 | - if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
436 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
437 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
435 | + if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
436 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
437 | + do_action("getpaid_authenticated_action_$key", $_REQUEST); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | - public function pre_get_posts( $wp_query ) { |
|
443 | - if ( ! is_admin() && !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() ) { |
|
444 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
442 | + public function pre_get_posts($wp_query) { |
|
443 | + if (!is_admin() && !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()) { |
|
444 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | return $wp_query; |
448 | 448 | } |
449 | 449 | |
450 | 450 | public function bp_invoicing_init() { |
451 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
451 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | ) |
470 | 470 | ); |
471 | 471 | |
472 | - foreach ( $widgets as $widget ) { |
|
473 | - register_widget( $widget ); |
|
472 | + foreach ($widgets as $widget) { |
|
473 | + register_widget($widget); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | } |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | * @since 1.0.19 |
482 | 482 | * @param int[] $excluded_posts_ids |
483 | 483 | */ |
484 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
484 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
485 | 485 | |
486 | 486 | // Ensure that we have an array. |
487 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
487 | + if (!is_array($excluded_posts_ids)) { |
|
488 | 488 | $excluded_posts_ids = array(); |
489 | 489 | } |
490 | 490 | |
@@ -492,24 +492,24 @@ discard block |
||
492 | 492 | $our_pages = array(); |
493 | 493 | |
494 | 494 | // Checkout page. |
495 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
495 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
496 | 496 | |
497 | 497 | // Success page. |
498 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
498 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
499 | 499 | |
500 | 500 | // Failure page. |
501 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
501 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
502 | 502 | |
503 | 503 | // History page. |
504 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
504 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
505 | 505 | |
506 | 506 | // Subscriptions page. |
507 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
507 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
508 | 508 | |
509 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
509 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
510 | 510 | |
511 | 511 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
512 | - return array_unique( $excluded_posts_ids ); |
|
512 | + return array_unique($excluded_posts_ids); |
|
513 | 513 | |
514 | 514 | } |
515 | 515 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __('1','invoicing'), |
|
48 | - 'advanced' => false |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __('1','invoicing'), |
|
58 | - 'advanced' => false |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __('1','invoicing'), |
|
48 | + 'advanced' => false |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __('1','invoicing'), |
|
58 | + 'advanced' => false |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false |
|
68 | - ) |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false |
|
68 | + ) |
|
69 | 69 | |
70 | 70 | ) |
71 | 71 | |
@@ -75,95 +75,95 @@ discard block |
||
75 | 75 | parent::__construct( $options ); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * The Super block output function. |
|
80 | - * |
|
81 | - * @param array $args |
|
82 | - * @param array $widget_args |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
78 | + /** |
|
79 | + * The Super block output function. |
|
80 | + * |
|
81 | + * @param array $args |
|
82 | + * @param array $widget_args |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
88 | 88 | |
89 | - // Is the shortcode set up correctly? |
|
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | - return aui()->alert( |
|
92 | - array( |
|
93 | - 'type' => 'warning', |
|
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - // Payment form or button? |
|
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
102 | - } else { |
|
103 | - return $this->handle_buy_item( $args ); |
|
104 | - } |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Displaying a payment form |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
89 | + // Is the shortcode set up correctly? |
|
90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | + return aui()->alert( |
|
92 | + array( |
|
93 | + 'type' => 'warning', |
|
94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + // Payment form or button? |
|
100 | + if ( ! empty( $args['form'] ) ) { |
|
101 | + return $this->handle_payment_form( $args ); |
|
102 | + } else { |
|
103 | + return $this->handle_buy_item( $args ); |
|
104 | + } |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Displaying a payment form |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | 113 | protected function handle_payment_form( $args = array() ) { |
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
116 | - ob_start(); |
|
117 | - getpaid_display_payment_form( $args['form'] ); |
|
118 | - return ob_get_clean(); |
|
119 | - } |
|
115 | + if ( empty( $args['button'] ) ) { |
|
116 | + ob_start(); |
|
117 | + getpaid_display_payment_form( $args['form'] ); |
|
118 | + return ob_get_clean(); |
|
119 | + } |
|
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | - } |
|
121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Displays a payment form button. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Displays a payment form button. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | protected function payment_form_button( $form, $button ) { |
130 | - return getpaid_get_payment_button( $button, $form ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Selling an item |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
130 | + return getpaid_get_payment_button( $button, $form ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Selling an item |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | 138 | protected function handle_buy_item( $args = array() ) { |
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
142 | - } |
|
140 | + if ( empty( $args['button'] ) ) { |
|
141 | + return $this->buy_item_form( $args['item'] ); |
|
142 | + } |
|
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Displays a buy item form. |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Displays a buy item form. |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | 153 | protected function buy_item_form( $item ) { |
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
155 | - ob_start(); |
|
156 | - getpaid_display_item_payment_form( $items ); |
|
157 | - return ob_get_clean(); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Displays a buy item button. |
|
162 | - * |
|
163 | - * @return string |
|
164 | - */ |
|
154 | + $items = getpaid_convert_items_to_array( $item ); |
|
155 | + ob_start(); |
|
156 | + getpaid_display_item_payment_form( $items ); |
|
157 | + return ob_get_clean(); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Displays a buy item button. |
|
162 | + * |
|
163 | + * @return string |
|
164 | + */ |
|
165 | 165 | protected function buy_item_button( $item, $button ) { |
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return getpaid_get_payment_button( $button, null, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'form']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'getpaid', |
25 | - 'name' => __('GetPaid','invoicing'), |
|
25 | + 'name' => __('GetPaid', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid bsui', |
28 | - 'description' => esc_html__('Show payment forms or buttons.','invoicing'), |
|
28 | + 'description' => esc_html__('Show payment forms or buttons.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | ), |
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
42 | + 'title' => __('Form', 'invoicing'), |
|
43 | + 'desc' => __('Enter a form id in case you want to display a specific payment form', 'invoicing'), |
|
44 | 44 | 'type' => 'text', |
45 | 45 | 'desc_tip' => true, |
46 | 46 | 'default' => '', |
47 | - 'placeholder' => __('1','invoicing'), |
|
47 | + 'placeholder' => __('1', 'invoicing'), |
|
48 | 48 | 'advanced' => false |
49 | 49 | ), |
50 | 50 | |
51 | 51 | 'item' => array( |
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
52 | + 'title' => __('Items', 'invoicing'), |
|
53 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing'), |
|
54 | 54 | 'type' => 'text', |
55 | 55 | 'desc_tip' => true, |
56 | 56 | 'default' => '', |
57 | - 'placeholder' => __('1','invoicing'), |
|
57 | + 'placeholder' => __('1', 'invoicing'), |
|
58 | 58 | 'advanced' => false |
59 | 59 | ), |
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
62 | + 'title' => __('Button', 'invoicing'), |
|
63 | + 'desc' => __('Enter button label in case you would like to display the forms in a popup.', 'invoicing'), |
|
64 | 64 | 'type' => 'text', |
65 | 65 | 'desc_tip' => true, |
66 | 66 | 'default' => '', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ); |
73 | 73 | |
74 | 74 | |
75 | - parent::__construct( $options ); |
|
75 | + parent::__construct($options); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
87 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
88 | 88 | |
89 | 89 | // Is the shortcode set up correctly? |
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
90 | + if (empty($args['form']) && empty($args['item'])) { |
|
91 | 91 | return aui()->alert( |
92 | 92 | array( |
93 | 93 | 'type' => 'warning', |
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
94 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Payment form or button? |
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
100 | + if (!empty($args['form'])) { |
|
101 | + return $this->handle_payment_form($args); |
|
102 | 102 | } else { |
103 | - return $this->handle_buy_item( $args ); |
|
103 | + return $this->handle_buy_item($args); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - protected function handle_payment_form( $args = array() ) { |
|
113 | + protected function handle_payment_form($args = array()) { |
|
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
115 | + if (empty($args['button'])) { |
|
116 | 116 | ob_start(); |
117 | - getpaid_display_payment_form( $args['form'] ); |
|
117 | + getpaid_display_payment_form($args['form']); |
|
118 | 118 | return ob_get_clean(); |
119 | 119 | } |
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
121 | + return $this->payment_form_button($args['form'], $args['button']); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected function payment_form_button( $form, $button ) { |
|
130 | - return getpaid_get_payment_button( $button, $form ); |
|
129 | + protected function payment_form_button($form, $button) { |
|
130 | + return getpaid_get_payment_button($button, $form); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - protected function handle_buy_item( $args = array() ) { |
|
138 | + protected function handle_buy_item($args = array()) { |
|
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
140 | + if (empty($args['button'])) { |
|
141 | + return $this->buy_item_form($args['item']); |
|
142 | 142 | } |
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button($args['item'], $args['button']); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - protected function buy_item_form( $item ) { |
|
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
153 | + protected function buy_item_form($item) { |
|
154 | + $items = getpaid_convert_items_to_array($item); |
|
155 | 155 | ob_start(); |
156 | - getpaid_display_item_payment_form( $items ); |
|
156 | + getpaid_display_item_payment_form($items); |
|
157 | 157 | return ob_get_clean(); |
158 | 158 | } |
159 | 159 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - protected function buy_item_button( $item, $button ) { |
|
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
165 | + protected function buy_item_button($item, $button) { |
|
166 | + return getpaid_get_payment_button($button, null, $item); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |