@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -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,25 +88,25 @@ 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->tax = new WPInv_EUVat(); |
94 | 94 | $this->tax->init(); |
95 | 95 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
96 | 96 | |
97 | 97 | // Init other objects. |
98 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
99 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
100 | - $this->set( 'notes', new WPInv_Notes() ); |
|
101 | - $this->set( 'api', new WPInv_API() ); |
|
102 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
103 | - $this->set( 'template', new GetPaid_Template() ); |
|
104 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
105 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
106 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
107 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
108 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
109 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
98 | + $this->set('reports', new WPInv_Reports()); // TODO: Refactor. |
|
99 | + $this->set('session', new WPInv_Session_Handler()); |
|
100 | + $this->set('notes', new WPInv_Notes()); |
|
101 | + $this->set('api', new WPInv_API()); |
|
102 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
103 | + $this->set('template', new GetPaid_Template()); |
|
104 | + $this->set('admin', new GetPaid_Admin()); |
|
105 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
106 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
107 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
108 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
109 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * Define plugin constants. |
115 | 115 | */ |
116 | 116 | public function define_constants() { |
117 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
118 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
117 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
118 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
119 | 119 | $this->version = WPINV_VERSION; |
120 | 120 | } |
121 | 121 | |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function init_hooks() { |
128 | 128 | /* Internationalize the text strings used. */ |
129 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
129 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
130 | 130 | |
131 | 131 | // Init the plugin after WordPress inits. |
132 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
133 | - add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
|
134 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
135 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
132 | + add_action('init', array($this, 'init'), 1); |
|
133 | + add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5); |
|
134 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
135 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
136 | 136 | |
137 | - if ( class_exists( 'BuddyPress' ) ) { |
|
138 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
137 | + if (class_exists('BuddyPress')) { |
|
138 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
139 | 139 | } |
140 | 140 | |
141 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
142 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
143 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
144 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
145 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
141 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
142 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
143 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
144 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
145 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
146 | 146 | |
147 | 147 | // Fires after registering actions. |
148 | - do_action( 'wpinv_actions', $this ); |
|
149 | - do_action( 'getpaid_actions', $this ); |
|
148 | + do_action('wpinv_actions', $this); |
|
149 | + do_action('getpaid_actions', $this); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | /* Internationalize the text strings used. */ |
155 | 155 | $this->load_textdomain(); |
156 | 156 | |
157 | - do_action( 'wpinv_loaded' ); |
|
157 | + do_action('wpinv_loaded'); |
|
158 | 158 | |
159 | 159 | // Fix oxygen page builder conflict |
160 | - if ( function_exists( 'ct_css_output' ) ) { |
|
160 | + if (function_exists('ct_css_output')) { |
|
161 | 161 | wpinv_oxygen_fix_conflict(); |
162 | 162 | } |
163 | 163 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - public function load_textdomain( $locale = NULL ) { |
|
171 | - if ( empty( $locale ) ) { |
|
172 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
170 | + public function load_textdomain($locale = NULL) { |
|
171 | + if (empty($locale)) { |
|
172 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
173 | 173 | } |
174 | 174 | |
175 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
175 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
176 | 176 | |
177 | - unload_textdomain( 'invoicing' ); |
|
178 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
179 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
177 | + unload_textdomain('invoicing'); |
|
178 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
179 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Define language constants. |
183 | 183 | */ |
184 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -190,90 +190,90 @@ discard block |
||
190 | 190 | public function includes() { |
191 | 191 | |
192 | 192 | // Start with the settings. |
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
194 | 194 | |
195 | 195 | // Packages/libraries. |
196 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
198 | 198 | |
199 | 199 | // Load functions. |
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
215 | 215 | |
216 | 216 | // Register autoloader. |
217 | 217 | try { |
218 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
219 | - } catch ( Exception $e ) { |
|
220 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
218 | + spl_autoload_register(array($this, 'autoload'), true); |
|
219 | + } catch (Exception $e) { |
|
220 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
221 | 221 | } |
222 | 222 | |
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Load the tax class. |
247 | 247 | */ |
248 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
249 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
248 | + if (!class_exists('WPInv_EUVat')) { |
|
249 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
252 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
253 | 253 | GetPaid_Post_Types_Admin::init(); |
254 | 254 | |
255 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
255 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
256 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
257 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
258 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
259 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
260 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
261 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
262 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
263 | 263 | // load the user class only on the users.php page |
264 | 264 | global $pagenow; |
265 | - if($pagenow=='users.php'){ |
|
265 | + if ($pagenow == 'users.php') { |
|
266 | 266 | new WPInv_Admin_Users(); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Register cli commands |
271 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
272 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
273 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
271 | + if (defined('WP_CLI') && WP_CLI) { |
|
272 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
273 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
274 | 274 | } |
275 | 275 | |
276 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
276 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -284,21 +284,21 @@ discard block |
||
284 | 284 | * @since 1.0.19 |
285 | 285 | * @return void |
286 | 286 | */ |
287 | - public function autoload( $class_name ) { |
|
287 | + public function autoload($class_name) { |
|
288 | 288 | |
289 | 289 | // Normalize the class name... |
290 | - $class_name = strtolower( $class_name ); |
|
290 | + $class_name = strtolower($class_name); |
|
291 | 291 | |
292 | 292 | // ... and make sure it is our class. |
293 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
293 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Next, prepare the file name from the class. |
298 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
298 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
299 | 299 | |
300 | 300 | // Base path of the classes. |
301 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
301 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
302 | 302 | |
303 | 303 | // And an array of possible locations in order of importance. |
304 | 304 | $locations = array( |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | "$plugin_path/includes/admin/meta-boxes", |
311 | 311 | ); |
312 | 312 | |
313 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
313 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
314 | 314 | |
315 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
316 | - include trailingslashit( $location ) . $file_name; |
|
315 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
316 | + include trailingslashit($location) . $file_name; |
|
317 | 317 | break; |
318 | 318 | } |
319 | 319 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | public function init() { |
328 | 328 | |
329 | 329 | // Fires before getpaid inits. |
330 | - do_action( 'before_getpaid_init', $this ); |
|
330 | + do_action('before_getpaid_init', $this); |
|
331 | 331 | |
332 | 332 | // Load default gateways. |
333 | 333 | $gateways = apply_filters( |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | ) |
342 | 342 | ); |
343 | 343 | |
344 | - foreach ( $gateways as $id => $class ) { |
|
345 | - $this->gateways[ $id ] = new $class(); |
|
344 | + foreach ($gateways as $id => $class) { |
|
345 | + $this->gateways[$id] = new $class(); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | // Fires after getpaid inits. |
349 | - do_action( 'getpaid_init', $this ); |
|
349 | + do_action('getpaid_init', $this); |
|
350 | 350 | |
351 | 351 | } |
352 | 352 | |
@@ -356,69 +356,69 @@ discard block |
||
356 | 356 | public function maybe_process_ipn() { |
357 | 357 | |
358 | 358 | // Ensure that this is an IPN request. |
359 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
359 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
363 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
364 | 364 | |
365 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
366 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
365 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
366 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
367 | 367 | exit; |
368 | 368 | |
369 | 369 | } |
370 | 370 | |
371 | 371 | public function enqueue_scripts() { |
372 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
372 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
373 | 373 | |
374 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
375 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
376 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
374 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
375 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
376 | + wp_enqueue_style('wpinv_front_style'); |
|
377 | 377 | |
378 | 378 | // Register scripts |
379 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
380 | - 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' ) ); |
|
379 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
380 | + 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 | 381 | |
382 | 382 | $localize = array(); |
383 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
384 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
383 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
384 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
385 | 385 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
386 | 386 | $localize['currency_pos'] = wpinv_currency_position(); |
387 | 387 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
388 | 388 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
389 | 389 | $localize['decimals'] = wpinv_decimals(); |
390 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
390 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
391 | 391 | $localize['UseTaxes'] = wpinv_use_taxes(); |
392 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
393 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
394 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
392 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
393 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
394 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
395 | 395 | |
396 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
396 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
397 | 397 | |
398 | - wp_enqueue_script( 'jquery-blockui' ); |
|
398 | + wp_enqueue_script('jquery-blockui'); |
|
399 | 399 | $autofill_api = wpinv_get_option('address_autofill_api'); |
400 | 400 | $autofill_active = wpinv_get_option('address_autofill_active'); |
401 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
402 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
403 | - wp_dequeue_script( 'google-maps-api' ); |
|
401 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
402 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
403 | + wp_dequeue_script('google-maps-api'); |
|
404 | 404 | } |
405 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
406 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
405 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
406 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
407 | 407 | } |
408 | 408 | |
409 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
410 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
409 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all'); |
|
410 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
411 | 411 | |
412 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
413 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
412 | + wp_enqueue_script('wpinv-front-script'); |
|
413 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
414 | 414 | |
415 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
416 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
415 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
416 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | public function wpinv_actions() { |
420 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
421 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
420 | + if (isset($_REQUEST['wpi_action'])) { |
|
421 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -430,23 +430,23 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function maybe_do_authenticated_action() { |
432 | 432 | |
433 | - if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
434 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
435 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
433 | + if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
434 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
435 | + do_action("getpaid_authenticated_action_$key", $_REQUEST); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | - public function pre_get_posts( $wp_query ) { |
|
441 | - 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() ) { |
|
442 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
440 | + public function pre_get_posts($wp_query) { |
|
441 | + 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()) { |
|
442 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | return $wp_query; |
446 | 446 | } |
447 | 447 | |
448 | 448 | public function bp_invoicing_init() { |
449 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
449 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | ) |
468 | 468 | ); |
469 | 469 | |
470 | - foreach ( $widgets as $widget ) { |
|
471 | - register_widget( $widget ); |
|
470 | + foreach ($widgets as $widget) { |
|
471 | + register_widget($widget); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | } |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * @since 1.0.19 |
480 | 480 | * @param int[] $excluded_posts_ids |
481 | 481 | */ |
482 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
482 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
483 | 483 | |
484 | 484 | // Ensure that we have an array. |
485 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
485 | + if (!is_array($excluded_posts_ids)) { |
|
486 | 486 | $excluded_posts_ids = array(); |
487 | 487 | } |
488 | 488 | |
@@ -490,24 +490,24 @@ discard block |
||
490 | 490 | $our_pages = array(); |
491 | 491 | |
492 | 492 | // Checkout page. |
493 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
493 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
494 | 494 | |
495 | 495 | // Success page. |
496 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
496 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
497 | 497 | |
498 | 498 | // Failure page. |
499 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
499 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
500 | 500 | |
501 | 501 | // History page. |
502 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
502 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
503 | 503 | |
504 | 504 | // Subscriptions page. |
505 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
505 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
506 | 506 | |
507 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
507 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
508 | 508 | |
509 | 509 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
510 | - return array_unique( $excluded_posts_ids ); |
|
510 | + return array_unique($excluded_posts_ids); |
|
511 | 511 | |
512 | 512 | } |
513 | 513 |
@@ -7,172 +7,172 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
48 | + $page_id = absint($page_id); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option('success_page', false); |
|
55 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
62 | + $ret = $ret ? is_page($ret) : false; |
|
63 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Redirects a user the success page. |
74 | 74 | */ |
75 | -function wpinv_send_to_success_page( $args = array() ) { |
|
75 | +function wpinv_send_to_success_page($args = array()) { |
|
76 | 76 | $redirect = add_query_arg( |
77 | - wp_parse_args( $args ), |
|
77 | + wp_parse_args($args), |
|
78 | 78 | wpinv_get_success_page_uri() |
79 | 79 | ); |
80 | 80 | |
81 | - wp_redirect( $redirect ); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
130 | +function wpinv_get_success_page_url($query_string = null) { |
|
131 | + $success_page = wpinv_get_option('success_page', 0); |
|
132 | + $success_page = get_permalink($success_page); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
134 | + if ($query_string) |
|
135 | 135 | $success_page .= $query_string; |
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
140 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
141 | + $uri = wpinv_get_option('failure_page', ''); |
|
142 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
144 | + if ($extras) |
|
145 | 145 | $uri .= $extras; |
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option('failure_page', false); |
|
152 | + $ret = isset($ret) ? is_page($ret) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_transaction_query( $type = 'start' ) { |
|
157 | +function wpinv_transaction_query($type = 'start') { |
|
158 | 158 | global $wpdb; |
159 | 159 | |
160 | 160 | $wpdb->hide_errors(); |
161 | 161 | |
162 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
163 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
162 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
163 | + define('WPINV_USE_TRANSACTIONS', true); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
167 | - switch ( $type ) { |
|
166 | + if (WPINV_USE_TRANSACTIONS) { |
|
167 | + switch ($type) { |
|
168 | 168 | case 'commit' : |
169 | - $wpdb->query( 'COMMIT' ); |
|
169 | + $wpdb->query('COMMIT'); |
|
170 | 170 | break; |
171 | 171 | case 'rollback' : |
172 | - $wpdb->query( 'ROLLBACK' ); |
|
172 | + $wpdb->query('ROLLBACK'); |
|
173 | 173 | break; |
174 | 174 | default : |
175 | - $wpdb->query( 'START TRANSACTION' ); |
|
175 | + $wpdb->query('START TRANSACTION'); |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
@@ -181,141 +181,141 @@ discard block |
||
181 | 181 | function wpinv_get_prefix() { |
182 | 182 | $invoice_prefix = 'INV-'; |
183 | 183 | |
184 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
184 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | function wpinv_get_business_logo() { |
188 | - $business_logo = wpinv_get_option( 'logo' ); |
|
189 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
188 | + $business_logo = wpinv_get_option('logo'); |
|
189 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | function wpinv_get_business_name() { |
193 | 193 | $business_name = wpinv_get_option('store_name'); |
194 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
194 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | function wpinv_get_blogname() { |
198 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
198 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_admin_email() { |
202 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
203 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
202 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
203 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function wpinv_get_business_website() { |
207 | - $business_website = home_url( '/' ); |
|
208 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
207 | + $business_website = home_url('/'); |
|
208 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
209 | 209 | } |
210 | 210 | |
211 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
211 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
212 | 212 | $terms_text = ''; |
213 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
213 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | function wpinv_get_business_footer() { |
217 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
218 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
219 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
217 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
218 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
219 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function wpinv_checkout_required_fields() { |
223 | 223 | $required_fields = array(); |
224 | 224 | |
225 | 225 | // Let payment gateways and other extensions determine if address fields should be required |
226 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
226 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
227 | 227 | |
228 | - if ( $require_billing_details ) { |
|
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
228 | + if ($require_billing_details) { |
|
229 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
230 | 230 | $required_fields['first_name'] = array( |
231 | 231 | 'error_id' => 'invalid_first_name', |
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
232 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
233 | 233 | ); |
234 | 234 | } |
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
235 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
236 | 236 | $required_fields['address'] = array( |
237 | 237 | 'error_id' => 'invalid_address', |
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
238 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
239 | 239 | ); |
240 | 240 | } |
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
241 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
242 | 242 | $required_fields['city'] = array( |
243 | 243 | 'error_id' => 'invalid_city', |
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
244 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
245 | 245 | ); |
246 | 246 | } |
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
247 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
248 | 248 | $required_fields['state'] = array( |
249 | 249 | 'error_id' => 'invalid_state', |
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
250 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
251 | 251 | ); |
252 | 252 | } |
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
253 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
254 | 254 | $required_fields['country'] = array( |
255 | 255 | 'error_id' => 'invalid_country', |
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
256 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
261 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | function wpinv_is_ssl_enforced() { |
265 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
266 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
265 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
266 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | function wpinv_schedule_event_twicedaily() { |
270 | 270 | wpinv_email_payment_reminders(); |
271 | 271 | } |
272 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
272 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
273 | 273 | |
274 | 274 | function wpinv_require_login_to_checkout() { |
275 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
276 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
275 | + $return = wpinv_get_option('login_to_checkout', false); |
|
276 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
277 | 277 | } |
278 | 278 | |
279 | -function wpinv_sequential_number_active( $type = '' ) { |
|
280 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
281 | - if ( null !== $check ) { |
|
279 | +function wpinv_sequential_number_active($type = '') { |
|
280 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
281 | + if (null !== $check) { |
|
282 | 282 | return $check; |
283 | 283 | } |
284 | 284 | |
285 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
285 | + return wpinv_get_option('sequential_invoice_number'); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
288 | +function wpinv_switch_to_locale($locale = NULL) { |
|
289 | 289 | global $invoicing, $wpi_switch_locale; |
290 | 290 | |
291 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
292 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
291 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
292 | + $locale = empty($locale) ? get_locale() : $locale; |
|
293 | 293 | |
294 | - switch_to_locale( $locale ); |
|
294 | + switch_to_locale($locale); |
|
295 | 295 | |
296 | 296 | $wpi_switch_locale = $locale; |
297 | 297 | |
298 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
298 | + add_filter('plugin_locale', 'get_locale'); |
|
299 | 299 | |
300 | 300 | $invoicing->load_textdomain(); |
301 | 301 | |
302 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
302 | + do_action('wpinv_switch_to_locale', $locale); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | function wpinv_restore_locale() { |
307 | 307 | global $invoicing, $wpi_switch_locale; |
308 | 308 | |
309 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
309 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
310 | 310 | restore_previous_locale(); |
311 | 311 | |
312 | 312 | $wpi_switch_locale = NULL; |
313 | 313 | |
314 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
314 | + remove_filter('plugin_locale', 'get_locale'); |
|
315 | 315 | |
316 | 316 | $invoicing->load_textdomain(); |
317 | 317 | |
318 | - do_action( 'wpinv_restore_locale' ); |
|
318 | + do_action('wpinv_restore_locale'); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * Returns the default form's id. |
324 | 324 | */ |
325 | 325 | function wpinv_get_default_payment_form() { |
326 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
326 | + $form = get_option('wpinv_default_payment_form'); |
|
327 | 327 | |
328 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
328 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
329 | 329 | $form = wp_insert_post( |
330 | 330 | array( |
331 | 331 | 'post_type' => 'wpi_payment_form', |
332 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
332 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
333 | 333 | 'post_status' => 'publish', |
334 | 334 | 'meta_input' => array( |
335 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
335 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
336 | 336 | 'wpinv_form_items' => array(), |
337 | 337 | ) |
338 | 338 | ) |
339 | 339 | ); |
340 | 340 | |
341 | - update_option( 'wpinv_default_payment_form', $form ); |
|
341 | + update_option('wpinv_default_payment_form', $form); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $form; |
@@ -349,19 +349,19 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @param int $payment_form |
351 | 351 | */ |
352 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
352 | +function getpaid_get_payment_form_elements($payment_form) { |
|
353 | 353 | |
354 | - if ( empty( $payment_form ) ) { |
|
355 | - return wpinv_get_data( 'sample-payment-form' ); |
|
354 | + if (empty($payment_form)) { |
|
355 | + return wpinv_get_data('sample-payment-form'); |
|
356 | 356 | } |
357 | 357 | |
358 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
358 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
359 | 359 | |
360 | - if ( is_array( $form_elements ) ) { |
|
360 | + if (is_array($form_elements)) { |
|
361 | 361 | return $form_elements; |
362 | 362 | } |
363 | 363 | |
364 | - return wpinv_get_data( 'sample-payment-form' ); |
|
364 | + return wpinv_get_data('sample-payment-form'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param int $payment_form |
372 | 372 | */ |
373 | -function gepaid_get_form_items( $id ) { |
|
374 | - $form = new GetPaid_Payment_Form( $id ); |
|
373 | +function gepaid_get_form_items($id) { |
|
374 | + $form = new GetPaid_Payment_Form($id); |
|
375 | 375 | |
376 | 376 | // Is this a default form? |
377 | - if ( $form->is_default() ) { |
|
377 | + if ($form->is_default()) { |
|
378 | 378 | return array(); |
379 | 379 | } |
380 | 380 | |
381 | - return $form->get_items( 'view', 'arrays' ); |
|
381 | + return $form->get_items('view', 'arrays'); |
|
382 | 382 | } |