Passed
Push — master ( 258987...abdd42 )
by Brian
11:44 queued 05:35
created

WPInv_Plugin::maybe_do_authenticated_action()   A

Complexity

Conditions 5
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 9.6111
cc 5
nc 2
nop 0
1
<?php
2
/**
3
 * Main Invoicing class.
4
 *
5
 * @package Invoicing
6
 * @since   1.0.0
7
 */
8
9
defined( 'ABSPATH' ) || exit;
10
11
/**
12
 * Main Invoicing class.
13
 *
14
 */
15
class WPInv_Plugin {
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
108
	}
109
110
	 /**
111
	 * Define plugin constants.
112
	 */
113
	public function define_constants() {
114
		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
115
		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
116
		$this->version = WPINV_VERSION;
117
	}
118
119
	/**
120
	 * Hook into actions and filters.
121
	 *
122
	 * @since 1.0.19
123
	 */
124
	protected function init_hooks() {
125
		/* Internationalize the text strings used. */
126
		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
127
128
		// Init the plugin after WordPress inits.
129
		add_action( 'init', array( $this, 'init' ), 1 );
130
		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
131
		add_action( 'init', array( &$this, 'wpinv_actions' ) );
132
		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ) );
133
134
		if ( class_exists( 'BuddyPress' ) ) {
135
			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
136
		}
137
138
		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
139
		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
140
		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
141
		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
142
		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
143
144
		// Fires after registering actions.
145
		do_action( 'wpinv_actions', $this );
146
		do_action( 'getpaid_actions', $this );
147
148
	}
149
150
	public function plugins_loaded() {
151
		/* Internationalize the text strings used. */
152
		$this->load_textdomain();
153
154
		do_action( 'wpinv_loaded' );
155
156
		// Fix oxygen page builder conflict
157
		if ( function_exists( 'ct_css_output' ) ) {
158
			wpinv_oxygen_fix_conflict();
159
		}
160
	}
161
162
	/**
163
	 * Load the translation of the plugin.
164
	 *
165
	 * @since 1.0
166
	 */
167
	public function load_textdomain( $locale = NULL ) {
168
		if ( empty( $locale ) ) {
169
			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
170
		}
171
172
		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
0 ignored issues
show
Unused Code introduced by
The call to get_locale() has too many arguments starting with $locale. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

172
		$locale = /** @scrutinizer ignore-call */ apply_filters( 'plugin_locale', $locale, 'invoicing' );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
173
174
		unload_textdomain( 'invoicing' );
175
		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
176
		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
177
178
		/**
179
		 * Define language constants.
180
		 */
181
		require_once( WPINV_PLUGIN_DIR . 'language.php' );
182
	}
183
184
	/**
185
	 * Include required core files used in admin and on the frontend.
186
	 */
187
	public function includes() {
188
189
		// Start with the settings.
190
		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
191
192
		// Packages/libraries.
193
		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
194
		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
195
		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
196
197
		// Load functions.
198
		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
199
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
200
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
201
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
202
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
203
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
204
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
205
		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
206
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
207
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
208
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
209
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
210
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
211
		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
212
213
		// Register autoloader.
214
		try {
215
			spl_autoload_register( array( $this, 'autoload' ), true );
216
		} catch ( Exception $e ) {
217
			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
218
		}
219
220
		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
221
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
222
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
223
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
224
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
225
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
226
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
227
		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
228
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
229
		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
230
		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
231
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
232
		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
233
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
234
		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
235
		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
236
		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
237
		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
238
		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
239
		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
240
		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
241
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
242
243
		/**
244
		 * Load the tax class.
245
		 */
246
		if ( ! class_exists( 'WPInv_EUVat' ) ) {
247
			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
248
		}
249
250
		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
251
		if ( !empty( $gateways ) ) {
252
			foreach ( $gateways as $gateway ) {
253
				if ( $gateway == 'manual' ) {
254
					continue;
255
				}
256
257
				$gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
258
259
				if ( file_exists( $gateway_file ) ) {
260
					require_once( $gateway_file );
261
				}
262
			}
263
		}
264
265
		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
0 ignored issues
show
Bug introduced by
The constant WP_CLI was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
266
			GetPaid_Post_Types_Admin::init();
267
268
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
269
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
270
			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
271
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
272
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
273
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
274
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
275
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
276
			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
277
			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
278
			// load the user class only on the users.php page
279
			global $pagenow;
280
			if($pagenow=='users.php'){
281
				new WPInv_Admin_Users();
282
			}
283
		}
284
285
		// Register cli commands
286
		if ( defined( 'WP_CLI' ) && WP_CLI ) {
287
			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
288
			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
0 ignored issues
show
Bug introduced by
The type WP_CLI was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
289
		}
290
291
		// include css inliner
292
		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
293
			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
294
		}
295
296
		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
297
	}
298
299
	/**
300
	 * Class autoloader
301
	 *
302
	 * @param       string $class_name The name of the class to load.
303
	 * @access      public
304
	 * @since       1.0.19
305
	 * @return      void
306
	 */
307
	public function autoload( $class_name ) {
308
309
		// Normalize the class name...
310
		$class_name  = strtolower( $class_name );
311
312
		// ... and make sure it is our class.
313
		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
314
			return;
315
		}
316
317
		// Next, prepare the file name from the class.
318
		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
319
320
		// Base path of the classes.
321
		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
322
323
		// And an array of possible locations in order of importance.
324
		$locations = array(
325
			"$plugin_path/includes",
326
			"$plugin_path/includes/data-stores",
327
			"$plugin_path/includes/gateways",
328
			"$plugin_path/includes/api",
329
			"$plugin_path/includes/admin",
330
			"$plugin_path/includes/admin/meta-boxes",
331
		);
332
333
		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
334
335
			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
336
				include trailingslashit( $location ) . $file_name;
337
				break;
338
			}
339
340
		}
341
342
	}
343
344
	/**
345
	 * Inits hooks etc.
346
	 */
347
	public function init() {
348
349
		// Fires before getpaid inits.
350
		do_action( 'before_getpaid_init', $this );
351
352
		// Load default gateways.
353
		$gateways = apply_filters(
354
			'getpaid_default_gateways',
355
			array(
356
				'manual'        => 'GetPaid_Manual_Gateway',
357
				'paypal'        => 'GetPaid_Paypal_Gateway',
358
				'worldpay'      => 'GetPaid_Worldpay_Gateway',
359
				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
360
				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
361
			)
362
		);
363
364
		foreach ( $gateways as $id => $class ) {
365
			$this->gateways[ $id ] = new $class();
366
		}
367
368
		// Fires after getpaid inits.
369
		do_action( 'getpaid_init', $this );
370
371
	}
372
373
	/**
374
	 * Checks if this is an IPN request and processes it.
375
	 */
376
	public function maybe_process_ipn() {
377
378
		// Ensure that this is an IPN request.
379
		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
380
			return;
381
		}
382
383
		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
384
385
		do_action( 'wpinv_verify_payment_ipn', $gateway );
386
		do_action( "wpinv_verify_{$gateway}_ipn" );
387
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
388
389
	}
390
391
	public function enqueue_scripts() {
392
		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
393
394
		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
395
		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
396
		wp_enqueue_style( 'wpinv_front_style' );
397
398
		// Register scripts
399
		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
400
		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' ) );
401
402
		$localize                         = array();
403
		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
404
		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
405
		$localize['currency_symbol']      = wpinv_currency_symbol();
406
		$localize['currency_pos']         = wpinv_currency_position();
407
		$localize['thousand_sep']         = wpinv_thousands_separator();
408
		$localize['decimal_sep']          = wpinv_decimal_separator();
409
		$localize['decimals']             = wpinv_decimals();
410
		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
411
		$localize['UseTaxes']             = wpinv_use_taxes();
412
		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
413
		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
414
		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
415
416
		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
417
418
		wp_enqueue_script( 'jquery-blockui' );
419
		$autofill_api = wpinv_get_option('address_autofill_api');
420
		$autofill_active = wpinv_get_option('address_autofill_active');
421
		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
0 ignored issues
show
introduced by
The condition 1 == $autofill_active is always false.
Loading history...
422
			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
423
				wp_dequeue_script( 'google-maps-api' );
424
			}
425
			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
426
			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
427
		}
428
429
		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
430
		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
431
432
		wp_enqueue_script( 'wpinv-front-script' );
433
		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
434
435
		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
436
		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
437
	}
438
439
	public function wpinv_actions() {
440
		if ( isset( $_REQUEST['wpi_action'] ) ) {
441
			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
442
		}
443
	}
444
445
	/**
446
     * Fires an action after verifying that a user can fire them.
447
	 *
448
	 * Note: If the action is on an invoice, subscription etc, esure that the
449
	 * current user owns the invoice/subscription.
450
     */
451
    public function maybe_do_authenticated_action() {
452
453
        if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
454
            $key = sanitize_key( $_REQUEST['getpaid-action'] );
455
            do_action( "getpaid_authenticated_action_$key", $_REQUEST );
456
        }
457
458
    }
459
460
	public function pre_get_posts( $wp_query ) {
461
		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() ) {
462
			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
463
		}
464
465
		return $wp_query;
466
	}
467
468
	public function bp_invoicing_init() {
469
		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
470
	}
471
472
	/**
473
	 * Register widgets
474
	 *
475
	 */
476
	public function register_widgets() {
477
		$widgets = apply_filters(
478
			'getpaid_widget_classes',
479
			array(
480
				'WPInv_Checkout_Widget',
481
				'WPInv_History_Widget',
482
				'WPInv_Receipt_Widget',
483
				'WPInv_Subscriptions_Widget',
484
				'WPInv_Buy_Item_Widget',
485
				'WPInv_Messages_Widget',
486
				'WPInv_GetPaid_Widget'
487
			)
488
		);
489
490
		foreach ( $widgets as $widget ) {
491
			register_widget( $widget );
492
		}
493
		
494
	}
495
496
	/**
497
	 * Remove our pages from yoast sitemaps.
498
	 *
499
	 * @since 1.0.19
500
	 * @param int[] $excluded_posts_ids
501
	 */
502
	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
503
504
		// Ensure that we have an array.
505
		if ( ! is_array( $excluded_posts_ids ) ) {
0 ignored issues
show
introduced by
The condition is_array($excluded_posts_ids) is always true.
Loading history...
506
			$excluded_posts_ids = array();
507
		}
508
509
		// Prepare our pages.
510
		$our_pages = array();
511
512
		// Checkout page.
513
		$our_pages[] = wpinv_get_option( 'checkout_page', false );
514
515
		// Success page.
516
		$our_pages[] = wpinv_get_option( 'success_page', false );
517
518
		// Failure page.
519
		$our_pages[] = wpinv_get_option( 'failure_page', false );
520
521
		// History page.
522
		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
523
524
		// Subscriptions page.
525
		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
526
527
		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
528
529
		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
530
		return array_unique( $excluded_posts_ids );
531
532
	}
533
534
	public function wp_footer() {
535
		echo '
536
			<div class="bsui">
537
				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
538
					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
539
						<div class="modal-content">
540
							<div class="modal-body"></div>
541
						</div>
542
					</div>
543
				</div>
544
			</div>
545
		';
546
	}
547
548
}
549