@@ -55,27 +55,27 @@ |
||
55 | 55 | public static function vat_rates_settings() {} |
56 | 56 | |
57 | 57 | /** |
58 | - * |
|
59 | - * @deprecated |
|
60 | - */ |
|
58 | + * |
|
59 | + * @deprecated |
|
60 | + */ |
|
61 | 61 | public static function vat_settings() {} |
62 | 62 | |
63 | 63 | /** |
64 | - * |
|
65 | - * @deprecated |
|
66 | - */ |
|
64 | + * |
|
65 | + * @deprecated |
|
66 | + */ |
|
67 | 67 | public static function maxmind_folder() {} |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @deprecated |
|
72 | - */ |
|
70 | + * |
|
71 | + * @deprecated |
|
72 | + */ |
|
73 | 73 | public static function geoip2_download_database() {} |
74 | 74 | |
75 | 75 | /** |
76 | - * |
|
77 | - * @deprecated |
|
78 | - */ |
|
76 | + * |
|
77 | + * @deprecated |
|
78 | + */ |
|
79 | 79 | public static function geoip2_download_file() {} |
80 | 80 | |
81 | 81 | /** |
@@ -14,485 +14,485 @@ 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 | - * @param array An array of payment gateways. |
|
40 | - */ |
|
41 | - public $gateways; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->define_constants(); |
|
48 | - $this->includes(); |
|
49 | - $this->init_hooks(); |
|
50 | - $this->set_properties(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Sets a custom data property. |
|
55 | - * |
|
56 | - * @param string $prop The prop to set. |
|
57 | - * @param mixed $value The value to retrieve. |
|
58 | - */ |
|
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets a custom data property. |
|
65 | - * |
|
66 | - * @param string $prop The prop to set. |
|
67 | - * @return mixed The value. |
|
68 | - */ |
|
69 | - public function get( $prop ) { |
|
70 | - |
|
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
73 | - } |
|
74 | - |
|
75 | - return null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Define class properties. |
|
80 | - */ |
|
81 | - public function set_properties() { |
|
82 | - |
|
83 | - // Sessions. |
|
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | - $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | - |
|
88 | - // Init other objects. |
|
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Define plugin constants. |
|
106 | - */ |
|
107 | - public function define_constants() { |
|
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | - $this->version = WPINV_VERSION; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Hook into actions and filters. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - */ |
|
118 | - protected function init_hooks() { |
|
119 | - /* Internationalize the text strings used. */ |
|
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | - |
|
122 | - // Init the plugin after WordPress inits. |
|
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - |
|
128 | - if ( class_exists( 'BuddyPress' ) ) { |
|
129 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
130 | - } |
|
131 | - |
|
132 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
133 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
134 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
135 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
136 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
137 | - |
|
138 | - // Fires after registering actions. |
|
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
141 | - |
|
142 | - } |
|
143 | - |
|
144 | - public function plugins_loaded() { |
|
145 | - /* Internationalize the text strings used. */ |
|
146 | - $this->load_textdomain(); |
|
147 | - |
|
148 | - do_action( 'wpinv_loaded' ); |
|
149 | - |
|
150 | - // Fix oxygen page builder conflict |
|
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
152 | - wpinv_oxygen_fix_conflict(); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Load the translation of the plugin. |
|
158 | - * |
|
159 | - * @since 1.0 |
|
160 | - */ |
|
161 | - public function load_textdomain( $locale = NULL ) { |
|
162 | - if ( empty( $locale ) ) { |
|
163 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
164 | - } |
|
165 | - |
|
166 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
167 | - |
|
168 | - unload_textdomain( 'invoicing' ); |
|
169 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
170 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
171 | - |
|
172 | - /** |
|
173 | - * Define language constants. |
|
174 | - */ |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Include required core files used in admin and on the frontend. |
|
180 | - */ |
|
181 | - public function includes() { |
|
182 | - |
|
183 | - // Start with the settings. |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
185 | - |
|
186 | - // Packages/libraries. |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
189 | - |
|
190 | - // Load functions. |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
206 | - |
|
207 | - // Register autoloader. |
|
208 | - try { |
|
209 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
210 | - } catch ( Exception $e ) { |
|
211 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
212 | - } |
|
213 | - |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | - GetPaid_Post_Types_Admin::init(); |
|
237 | - |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
245 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
246 | - // load the user class only on the users.php page |
|
247 | - global $pagenow; |
|
248 | - if($pagenow=='users.php'){ |
|
249 | - new WPInv_Admin_Users(); |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - // Register cli commands |
|
254 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
255 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
256 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
257 | - } |
|
258 | - |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Class autoloader |
|
264 | - * |
|
265 | - * @param string $class_name The name of the class to load. |
|
266 | - * @access public |
|
267 | - * @since 1.0.19 |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - public function autoload( $class_name ) { |
|
271 | - |
|
272 | - // Normalize the class name... |
|
273 | - $class_name = strtolower( $class_name ); |
|
274 | - |
|
275 | - // ... and make sure it is our class. |
|
276 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
277 | - return; |
|
278 | - } |
|
279 | - |
|
280 | - // Next, prepare the file name from the class. |
|
281 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
282 | - |
|
283 | - // Base path of the classes. |
|
284 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
285 | - |
|
286 | - // And an array of possible locations in order of importance. |
|
287 | - $locations = array( |
|
288 | - "$plugin_path/includes", |
|
289 | - "$plugin_path/includes/data-stores", |
|
290 | - "$plugin_path/includes/gateways", |
|
291 | - "$plugin_path/includes/payments", |
|
292 | - "$plugin_path/includes/geolocation", |
|
293 | - "$plugin_path/includes/reports", |
|
294 | - "$plugin_path/includes/api", |
|
295 | - "$plugin_path/includes/admin", |
|
296 | - "$plugin_path/includes/admin/meta-boxes", |
|
297 | - ); |
|
298 | - |
|
299 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
300 | - |
|
301 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
302 | - include trailingslashit( $location ) . $file_name; |
|
303 | - break; |
|
304 | - } |
|
305 | - |
|
306 | - } |
|
307 | - |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * Inits hooks etc. |
|
312 | - */ |
|
313 | - public function init() { |
|
314 | - |
|
315 | - // Fires before getpaid inits. |
|
316 | - do_action( 'before_getpaid_init', $this ); |
|
317 | - |
|
318 | - // Load default gateways. |
|
319 | - $gateways = apply_filters( |
|
320 | - 'getpaid_default_gateways', |
|
321 | - array( |
|
322 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | - ) |
|
328 | - ); |
|
329 | - |
|
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
332 | - } |
|
333 | - |
|
334 | - // Fires after getpaid inits. |
|
335 | - do_action( 'getpaid_init', $this ); |
|
336 | - |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Checks if this is an IPN request and processes it. |
|
341 | - */ |
|
342 | - public function maybe_process_ipn() { |
|
343 | - |
|
344 | - // Ensure that this is an IPN request. |
|
345 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
346 | - return; |
|
347 | - } |
|
348 | - |
|
349 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
350 | - |
|
351 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
352 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
353 | - exit; |
|
354 | - |
|
355 | - } |
|
356 | - |
|
357 | - public function enqueue_scripts() { |
|
358 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
359 | - |
|
360 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
361 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
362 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
363 | - |
|
364 | - // Register scripts |
|
365 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
366 | - 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' ) ); |
|
367 | - |
|
368 | - $localize = array(); |
|
369 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
370 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
371 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
372 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
373 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
376 | - |
|
377 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | - |
|
379 | - wp_enqueue_script( 'jquery-blockui' ); |
|
380 | - |
|
381 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
382 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
383 | - |
|
384 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
385 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
386 | - |
|
387 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
388 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
389 | - } |
|
390 | - |
|
391 | - public function wpinv_actions() { |
|
392 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
393 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
394 | - } |
|
395 | - } |
|
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 | + * @param array An array of payment gateways. |
|
40 | + */ |
|
41 | + public $gateways; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->define_constants(); |
|
48 | + $this->includes(); |
|
49 | + $this->init_hooks(); |
|
50 | + $this->set_properties(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Sets a custom data property. |
|
55 | + * |
|
56 | + * @param string $prop The prop to set. |
|
57 | + * @param mixed $value The value to retrieve. |
|
58 | + */ |
|
59 | + public function set( $prop, $value ) { |
|
60 | + $this->data[ $prop ] = $value; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets a custom data property. |
|
65 | + * |
|
66 | + * @param string $prop The prop to set. |
|
67 | + * @return mixed The value. |
|
68 | + */ |
|
69 | + public function get( $prop ) { |
|
70 | + |
|
71 | + if ( isset( $this->data[ $prop ] ) ) { |
|
72 | + return $this->data[ $prop ]; |
|
73 | + } |
|
74 | + |
|
75 | + return null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Define class properties. |
|
80 | + */ |
|
81 | + public function set_properties() { |
|
82 | + |
|
83 | + // Sessions. |
|
84 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | + $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | + |
|
88 | + // Init other objects. |
|
89 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | + $this->set( 'notes', new WPInv_Notes() ); |
|
91 | + $this->set( 'api', new WPInv_API() ); |
|
92 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | + $this->set( 'template', new GetPaid_Template() ); |
|
94 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Define plugin constants. |
|
106 | + */ |
|
107 | + public function define_constants() { |
|
108 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | + $this->version = WPINV_VERSION; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Hook into actions and filters. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + */ |
|
118 | + protected function init_hooks() { |
|
119 | + /* Internationalize the text strings used. */ |
|
120 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | + |
|
122 | + // Init the plugin after WordPress inits. |
|
123 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | + |
|
128 | + if ( class_exists( 'BuddyPress' ) ) { |
|
129 | + add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
130 | + } |
|
131 | + |
|
132 | + add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
133 | + add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
134 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
135 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
136 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
137 | + |
|
138 | + // Fires after registering actions. |
|
139 | + do_action( 'wpinv_actions', $this ); |
|
140 | + do_action( 'getpaid_actions', $this ); |
|
141 | + |
|
142 | + } |
|
143 | + |
|
144 | + public function plugins_loaded() { |
|
145 | + /* Internationalize the text strings used. */ |
|
146 | + $this->load_textdomain(); |
|
147 | + |
|
148 | + do_action( 'wpinv_loaded' ); |
|
149 | + |
|
150 | + // Fix oxygen page builder conflict |
|
151 | + if ( function_exists( 'ct_css_output' ) ) { |
|
152 | + wpinv_oxygen_fix_conflict(); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Load the translation of the plugin. |
|
158 | + * |
|
159 | + * @since 1.0 |
|
160 | + */ |
|
161 | + public function load_textdomain( $locale = NULL ) { |
|
162 | + if ( empty( $locale ) ) { |
|
163 | + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
164 | + } |
|
165 | + |
|
166 | + $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
167 | + |
|
168 | + unload_textdomain( 'invoicing' ); |
|
169 | + load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
170 | + load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
171 | + |
|
172 | + /** |
|
173 | + * Define language constants. |
|
174 | + */ |
|
175 | + require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Include required core files used in admin and on the frontend. |
|
180 | + */ |
|
181 | + public function includes() { |
|
182 | + |
|
183 | + // Start with the settings. |
|
184 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
185 | + |
|
186 | + // Packages/libraries. |
|
187 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
188 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
189 | + |
|
190 | + // Load functions. |
|
191 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
199 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
200 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
205 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
206 | + |
|
207 | + // Register autoloader. |
|
208 | + try { |
|
209 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
210 | + } catch ( Exception $e ) { |
|
211 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
212 | + } |
|
213 | + |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
216 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
217 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
218 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
219 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
220 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
221 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
222 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
223 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
234 | + |
|
235 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | + GetPaid_Post_Types_Admin::init(); |
|
237 | + |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
244 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
245 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
246 | + // load the user class only on the users.php page |
|
247 | + global $pagenow; |
|
248 | + if($pagenow=='users.php'){ |
|
249 | + new WPInv_Admin_Users(); |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + // Register cli commands |
|
254 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
255 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
256 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
257 | + } |
|
258 | + |
|
259 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Class autoloader |
|
264 | + * |
|
265 | + * @param string $class_name The name of the class to load. |
|
266 | + * @access public |
|
267 | + * @since 1.0.19 |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + public function autoload( $class_name ) { |
|
271 | + |
|
272 | + // Normalize the class name... |
|
273 | + $class_name = strtolower( $class_name ); |
|
396 | 274 | |
397 | - /** |
|
275 | + // ... and make sure it is our class. |
|
276 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
277 | + return; |
|
278 | + } |
|
279 | + |
|
280 | + // Next, prepare the file name from the class. |
|
281 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
282 | + |
|
283 | + // Base path of the classes. |
|
284 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
285 | + |
|
286 | + // And an array of possible locations in order of importance. |
|
287 | + $locations = array( |
|
288 | + "$plugin_path/includes", |
|
289 | + "$plugin_path/includes/data-stores", |
|
290 | + "$plugin_path/includes/gateways", |
|
291 | + "$plugin_path/includes/payments", |
|
292 | + "$plugin_path/includes/geolocation", |
|
293 | + "$plugin_path/includes/reports", |
|
294 | + "$plugin_path/includes/api", |
|
295 | + "$plugin_path/includes/admin", |
|
296 | + "$plugin_path/includes/admin/meta-boxes", |
|
297 | + ); |
|
298 | + |
|
299 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
300 | + |
|
301 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
302 | + include trailingslashit( $location ) . $file_name; |
|
303 | + break; |
|
304 | + } |
|
305 | + |
|
306 | + } |
|
307 | + |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Inits hooks etc. |
|
312 | + */ |
|
313 | + public function init() { |
|
314 | + |
|
315 | + // Fires before getpaid inits. |
|
316 | + do_action( 'before_getpaid_init', $this ); |
|
317 | + |
|
318 | + // Load default gateways. |
|
319 | + $gateways = apply_filters( |
|
320 | + 'getpaid_default_gateways', |
|
321 | + array( |
|
322 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | + ) |
|
328 | + ); |
|
329 | + |
|
330 | + foreach ( $gateways as $id => $class ) { |
|
331 | + $this->gateways[ $id ] = new $class(); |
|
332 | + } |
|
333 | + |
|
334 | + // Fires after getpaid inits. |
|
335 | + do_action( 'getpaid_init', $this ); |
|
336 | + |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Checks if this is an IPN request and processes it. |
|
341 | + */ |
|
342 | + public function maybe_process_ipn() { |
|
343 | + |
|
344 | + // Ensure that this is an IPN request. |
|
345 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
346 | + return; |
|
347 | + } |
|
348 | + |
|
349 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
350 | + |
|
351 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
352 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
353 | + exit; |
|
354 | + |
|
355 | + } |
|
356 | + |
|
357 | + public function enqueue_scripts() { |
|
358 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
359 | + |
|
360 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
361 | + wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
362 | + wp_enqueue_style( 'wpinv_front_style' ); |
|
363 | + |
|
364 | + // Register scripts |
|
365 | + wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
366 | + 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' ) ); |
|
367 | + |
|
368 | + $localize = array(); |
|
369 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
370 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
371 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
372 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
373 | + $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
374 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
376 | + |
|
377 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | + |
|
379 | + wp_enqueue_script( 'jquery-blockui' ); |
|
380 | + |
|
381 | + wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
382 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
383 | + |
|
384 | + wp_enqueue_script( 'wpinv-front-script' ); |
|
385 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
386 | + |
|
387 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
388 | + wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
389 | + } |
|
390 | + |
|
391 | + public function wpinv_actions() { |
|
392 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
393 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
394 | + } |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | 398 | * Fires an action after verifying that a user can fire them. |
399 | - * |
|
400 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
401 | - * current user owns the invoice/subscription. |
|
399 | + * |
|
400 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
401 | + * current user owns the invoice/subscription. |
|
402 | 402 | */ |
403 | 403 | public function maybe_do_authenticated_action() { |
404 | 404 | |
405 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
405 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
406 | 406 | |
407 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
408 | - if ( is_user_logged_in() ) { |
|
409 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
410 | - } |
|
407 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
408 | + if ( is_user_logged_in() ) { |
|
409 | + do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
410 | + } |
|
411 | 411 | |
412 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
412 | + do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
413 | 413 | |
414 | - } |
|
414 | + } |
|
415 | 415 | |
416 | 416 | |
417 | 417 | } |
418 | 418 | |
419 | - public function pre_get_posts( $wp_query ) { |
|
420 | - |
|
421 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
422 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
423 | - } |
|
424 | - |
|
425 | - return $wp_query; |
|
426 | - } |
|
427 | - |
|
428 | - public function bp_invoicing_init() { |
|
429 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Register widgets |
|
434 | - * |
|
435 | - */ |
|
436 | - public function register_widgets() { |
|
437 | - $widgets = apply_filters( |
|
438 | - 'getpaid_widget_classes', |
|
439 | - array( |
|
440 | - 'WPInv_Checkout_Widget', |
|
441 | - 'WPInv_History_Widget', |
|
442 | - 'WPInv_Receipt_Widget', |
|
443 | - 'WPInv_Subscriptions_Widget', |
|
444 | - 'WPInv_Buy_Item_Widget', |
|
445 | - 'WPInv_Messages_Widget', |
|
446 | - 'WPInv_GetPaid_Widget' |
|
447 | - ) |
|
448 | - ); |
|
449 | - |
|
450 | - foreach ( $widgets as $widget ) { |
|
451 | - register_widget( $widget ); |
|
452 | - } |
|
419 | + public function pre_get_posts( $wp_query ) { |
|
420 | + |
|
421 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
422 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
423 | + } |
|
424 | + |
|
425 | + return $wp_query; |
|
426 | + } |
|
427 | + |
|
428 | + public function bp_invoicing_init() { |
|
429 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Register widgets |
|
434 | + * |
|
435 | + */ |
|
436 | + public function register_widgets() { |
|
437 | + $widgets = apply_filters( |
|
438 | + 'getpaid_widget_classes', |
|
439 | + array( |
|
440 | + 'WPInv_Checkout_Widget', |
|
441 | + 'WPInv_History_Widget', |
|
442 | + 'WPInv_Receipt_Widget', |
|
443 | + 'WPInv_Subscriptions_Widget', |
|
444 | + 'WPInv_Buy_Item_Widget', |
|
445 | + 'WPInv_Messages_Widget', |
|
446 | + 'WPInv_GetPaid_Widget' |
|
447 | + ) |
|
448 | + ); |
|
449 | + |
|
450 | + foreach ( $widgets as $widget ) { |
|
451 | + register_widget( $widget ); |
|
452 | + } |
|
453 | 453 | |
454 | - } |
|
454 | + } |
|
455 | 455 | |
456 | - /** |
|
457 | - * Remove our pages from yoast sitemaps. |
|
458 | - * |
|
459 | - * @since 1.0.19 |
|
460 | - * @param int[] $excluded_posts_ids |
|
461 | - */ |
|
462 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
456 | + /** |
|
457 | + * Remove our pages from yoast sitemaps. |
|
458 | + * |
|
459 | + * @since 1.0.19 |
|
460 | + * @param int[] $excluded_posts_ids |
|
461 | + */ |
|
462 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
463 | 463 | |
464 | - // Ensure that we have an array. |
|
465 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
466 | - $excluded_posts_ids = array(); |
|
467 | - } |
|
464 | + // Ensure that we have an array. |
|
465 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
466 | + $excluded_posts_ids = array(); |
|
467 | + } |
|
468 | 468 | |
469 | - // Prepare our pages. |
|
470 | - $our_pages = array(); |
|
469 | + // Prepare our pages. |
|
470 | + $our_pages = array(); |
|
471 | 471 | |
472 | - // Checkout page. |
|
473 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
472 | + // Checkout page. |
|
473 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
474 | 474 | |
475 | - // Success page. |
|
476 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
475 | + // Success page. |
|
476 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
477 | 477 | |
478 | - // Failure page. |
|
479 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
478 | + // Failure page. |
|
479 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
480 | 480 | |
481 | - // History page. |
|
482 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
481 | + // History page. |
|
482 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
483 | 483 | |
484 | - // Subscriptions page. |
|
485 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
484 | + // Subscriptions page. |
|
485 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
486 | 486 | |
487 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
487 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
488 | 488 | |
489 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
490 | - return array_unique( $excluded_posts_ids ); |
|
489 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
490 | + return array_unique( $excluded_posts_ids ); |
|
491 | 491 | |
492 | - } |
|
492 | + } |
|
493 | 493 | |
494 | - public function wp_footer() { |
|
495 | - echo ' |
|
494 | + public function wp_footer() { |
|
495 | + echo ' |
|
496 | 496 | <div class="bsui"> |
497 | 497 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
498 | 498 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
@@ -508,6 +508,6 @@ discard block |
||
508 | 508 | </div> |
509 | 509 | </div> |
510 | 510 | '; |
511 | - } |
|
511 | + } |
|
512 | 512 | |
513 | 513 | } |
@@ -12,210 +12,210 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Taxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Submission taxes. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $taxes = array(); |
|
15 | + /** |
|
16 | + * Submission taxes. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $taxes = array(); |
|
20 | + |
|
21 | + /** |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + // Validate VAT number. |
|
29 | + $this->validate_vat( $submission ); |
|
30 | + |
|
31 | + foreach ( $submission->get_items() as $item ) { |
|
32 | + $this->process_item_tax( $item, $submission ); |
|
33 | + } |
|
34 | + |
|
35 | + // Process any existing invoice taxes. |
|
36 | + if ( $submission->has_invoice() ) { |
|
37 | + $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
38 | + } |
|
39 | + |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Maybe process tax. |
|
44 | + * |
|
45 | + * @since 1.0.19 |
|
46 | + * @param GetPaid_Form_Item $item |
|
47 | + * @param GetPaid_Payment_Form_Submission $submission |
|
48 | + */ |
|
49 | + public function process_item_tax( $item, $submission ) { |
|
50 | + |
|
51 | + $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
52 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
53 | + $taxes = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates ); |
|
54 | + $r_taxes = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates ); |
|
55 | + |
|
56 | + foreach ( $taxes as $name => $amount ) { |
|
57 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
58 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
59 | + |
|
60 | + if ( ! isset( $this->taxes[ $name ] ) ) { |
|
61 | + $this->taxes[ $name ] = $tax; |
|
62 | + continue; |
|
63 | + } |
|
64 | + |
|
65 | + $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
66 | + $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
67 | + |
|
68 | + } |
|
69 | + |
|
70 | + } |
|
20 | 71 | |
21 | 72 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - // Validate VAT number. |
|
29 | - $this->validate_vat( $submission ); |
|
30 | - |
|
31 | - foreach ( $submission->get_items() as $item ) { |
|
32 | - $this->process_item_tax( $item, $submission ); |
|
33 | - } |
|
34 | - |
|
35 | - // Process any existing invoice taxes. |
|
36 | - if ( $submission->has_invoice() ) { |
|
37 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
38 | - } |
|
39 | - |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Maybe process tax. |
|
44 | - * |
|
45 | - * @since 1.0.19 |
|
46 | - * @param GetPaid_Form_Item $item |
|
47 | - * @param GetPaid_Payment_Form_Submission $submission |
|
48 | - */ |
|
49 | - public function process_item_tax( $item, $submission ) { |
|
50 | - |
|
51 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
52 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
53 | - $taxes = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates ); |
|
54 | - $r_taxes = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates ); |
|
55 | - |
|
56 | - foreach ( $taxes as $name => $amount ) { |
|
57 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
58 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
59 | - |
|
60 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
61 | - $this->taxes[ $name ] = $tax; |
|
62 | - continue; |
|
63 | - } |
|
64 | - |
|
65 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
66 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
67 | - |
|
68 | - } |
|
69 | - |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Checks if the submission has a digital item. |
|
74 | - * |
|
75 | - * @param GetPaid_Payment_Form_Submission $submission |
|
76 | - * @since 1.0.19 |
|
77 | - * @return bool |
|
78 | - */ |
|
79 | - public function has_digital_item( $submission ) { |
|
80 | - |
|
81 | - foreach ( $submission->get_items() as $item ) { |
|
82 | - |
|
83 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
84 | - return true; |
|
85 | - } |
|
86 | - |
|
87 | - } |
|
88 | - |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Checks if this is an eu store. |
|
94 | - * |
|
95 | - * @since 1.0.19 |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - public function is_eu_store() { |
|
99 | - return $this->is_eu_country( wpinv_get_default_country() ); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Checks if this is an eu country. |
|
104 | - * |
|
105 | - * @param string $country |
|
106 | - * @since 1.0.19 |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - public function is_eu_country( $country ) { |
|
110 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Checks if this is an eu purchase. |
|
115 | - * |
|
116 | - * @param string $customer_country |
|
117 | - * @since 1.0.19 |
|
118 | - * @return bool |
|
119 | - */ |
|
120 | - public function is_eu_transaction( $customer_country ) { |
|
121 | - return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Retrieves the vat number. |
|
126 | - * |
|
127 | - * @param GetPaid_Payment_Form_Submission $submission |
|
128 | - * @since 1.0.19 |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function get_vat_number( $submission ) { |
|
132 | - |
|
133 | - // Retrieve from the posted number. |
|
134 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
135 | - if ( ! empty( $vat_number ) ) { |
|
136 | - return wpinv_clean( $vat_number ); |
|
137 | - } |
|
138 | - |
|
139 | - // Retrieve from the invoice. |
|
140 | - return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Retrieves the company. |
|
145 | - * |
|
146 | - * @param GetPaid_Payment_Form_Submission $submission |
|
147 | - * @since 1.0.19 |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function get_company( $submission ) { |
|
151 | - |
|
152 | - // Retrieve from the posted data. |
|
153 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
154 | - if ( ! empty( $company ) ) { |
|
155 | - return wpinv_clean( $company ); |
|
156 | - } |
|
157 | - |
|
158 | - // Retrieve from the invoice. |
|
159 | - return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Checks if we require a VAT number. |
|
164 | - * |
|
165 | - * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
166 | - * @param bool $country_in_eu Whether the customer country is from the EU |
|
167 | - * @since 1.0.19 |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
171 | - |
|
172 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
173 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
174 | - $is_eu = $ip_in_eu || $country_in_eu; |
|
175 | - |
|
176 | - return $prevent_b2c && $is_eu; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Validate VAT data. |
|
181 | - * |
|
182 | - * @param GetPaid_Payment_Form_Submission $submission |
|
183 | - * @since 1.0.19 |
|
184 | - */ |
|
185 | - public function validate_vat( $submission ) { |
|
186 | - |
|
187 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
188 | - |
|
189 | - // Abort if we are not validating vat numbers. |
|
190 | - if ( ! $in_eu ) { |
|
73 | + * Checks if the submission has a digital item. |
|
74 | + * |
|
75 | + * @param GetPaid_Payment_Form_Submission $submission |
|
76 | + * @since 1.0.19 |
|
77 | + * @return bool |
|
78 | + */ |
|
79 | + public function has_digital_item( $submission ) { |
|
80 | + |
|
81 | + foreach ( $submission->get_items() as $item ) { |
|
82 | + |
|
83 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
84 | + return true; |
|
85 | + } |
|
86 | + |
|
87 | + } |
|
88 | + |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Checks if this is an eu store. |
|
94 | + * |
|
95 | + * @since 1.0.19 |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + public function is_eu_store() { |
|
99 | + return $this->is_eu_country( wpinv_get_default_country() ); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Checks if this is an eu country. |
|
104 | + * |
|
105 | + * @param string $country |
|
106 | + * @since 1.0.19 |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + public function is_eu_country( $country ) { |
|
110 | + return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Checks if this is an eu purchase. |
|
115 | + * |
|
116 | + * @param string $customer_country |
|
117 | + * @since 1.0.19 |
|
118 | + * @return bool |
|
119 | + */ |
|
120 | + public function is_eu_transaction( $customer_country ) { |
|
121 | + return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Retrieves the vat number. |
|
126 | + * |
|
127 | + * @param GetPaid_Payment_Form_Submission $submission |
|
128 | + * @since 1.0.19 |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function get_vat_number( $submission ) { |
|
132 | + |
|
133 | + // Retrieve from the posted number. |
|
134 | + $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
135 | + if ( ! empty( $vat_number ) ) { |
|
136 | + return wpinv_clean( $vat_number ); |
|
137 | + } |
|
138 | + |
|
139 | + // Retrieve from the invoice. |
|
140 | + return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Retrieves the company. |
|
145 | + * |
|
146 | + * @param GetPaid_Payment_Form_Submission $submission |
|
147 | + * @since 1.0.19 |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function get_company( $submission ) { |
|
151 | + |
|
152 | + // Retrieve from the posted data. |
|
153 | + $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
154 | + if ( ! empty( $company ) ) { |
|
155 | + return wpinv_clean( $company ); |
|
156 | + } |
|
157 | + |
|
158 | + // Retrieve from the invoice. |
|
159 | + return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Checks if we require a VAT number. |
|
164 | + * |
|
165 | + * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
166 | + * @param bool $country_in_eu Whether the customer country is from the EU |
|
167 | + * @since 1.0.19 |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
171 | + |
|
172 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
173 | + $prevent_b2c = ! empty( $prevent_b2c ); |
|
174 | + $is_eu = $ip_in_eu || $country_in_eu; |
|
175 | + |
|
176 | + return $prevent_b2c && $is_eu; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Validate VAT data. |
|
181 | + * |
|
182 | + * @param GetPaid_Payment_Form_Submission $submission |
|
183 | + * @since 1.0.19 |
|
184 | + */ |
|
185 | + public function validate_vat( $submission ) { |
|
186 | + |
|
187 | + $in_eu = $this->is_eu_transaction( $submission->country ); |
|
188 | + |
|
189 | + // Abort if we are not validating vat numbers. |
|
190 | + if ( ! $in_eu ) { |
|
191 | 191 | return; |
192 | - } |
|
192 | + } |
|
193 | 193 | |
194 | - // Prepare variables. |
|
195 | - $vat_number = $this->get_vat_number( $submission ); |
|
196 | - $ip_country = getpaid_get_ip_country(); |
|
194 | + // Prepare variables. |
|
195 | + $vat_number = $this->get_vat_number( $submission ); |
|
196 | + $ip_country = getpaid_get_ip_country(); |
|
197 | 197 | $is_eu = $this->is_eu_country( $submission->country ); |
198 | 198 | $is_ip_eu = $this->is_eu_country( $ip_country ); |
199 | 199 | |
200 | - // If we're preventing business to consumer purchases, |
|
201 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
200 | + // If we're preventing business to consumer purchases, |
|
201 | + if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
202 | 202 | |
203 | - // Ensure that a vat number has been specified. |
|
204 | - throw new Exception( |
|
205 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
206 | - ); |
|
203 | + // Ensure that a vat number has been specified. |
|
204 | + throw new Exception( |
|
205 | + __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
206 | + ); |
|
207 | 207 | |
208 | - } |
|
208 | + } |
|
209 | 209 | |
210 | - // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
|
211 | - if ( ! $in_eu ) { |
|
210 | + // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
|
211 | + if ( ! $in_eu ) { |
|
212 | 212 | return; |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
216 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
217 | - } |
|
215 | + if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
216 | + throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
217 | + } |
|
218 | 218 | |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | 221 | } |
@@ -9,32 +9,32 @@ |
||
9 | 9 | defined( 'ABSPATH' ) || exit; |
10 | 10 | |
11 | 11 | return array( |
12 | - 'AT', |
|
13 | - 'BE', |
|
14 | - 'BG', |
|
15 | - 'HR', |
|
16 | - 'CY', |
|
17 | - 'CZ', |
|
18 | - 'DK', |
|
19 | - 'EE', |
|
20 | - 'FI', |
|
21 | - 'FR', |
|
22 | - 'DE', |
|
23 | - 'GB', |
|
24 | - 'GR', |
|
25 | - 'HU', |
|
26 | - 'IE', |
|
27 | - 'IT', |
|
28 | - 'LV', |
|
29 | - 'LT', |
|
30 | - 'LU', |
|
31 | - 'MT', |
|
32 | - 'NL', |
|
33 | - 'PL', |
|
34 | - 'PT', |
|
35 | - 'RO', |
|
36 | - 'SK', |
|
37 | - 'SI', |
|
38 | - 'ES', |
|
39 | - 'SE' |
|
12 | + 'AT', |
|
13 | + 'BE', |
|
14 | + 'BG', |
|
15 | + 'HR', |
|
16 | + 'CY', |
|
17 | + 'CZ', |
|
18 | + 'DK', |
|
19 | + 'EE', |
|
20 | + 'FI', |
|
21 | + 'FR', |
|
22 | + 'DE', |
|
23 | + 'GB', |
|
24 | + 'GR', |
|
25 | + 'HU', |
|
26 | + 'IE', |
|
27 | + 'IT', |
|
28 | + 'LV', |
|
29 | + 'LT', |
|
30 | + 'LU', |
|
31 | + 'MT', |
|
32 | + 'NL', |
|
33 | + 'PL', |
|
34 | + 'PT', |
|
35 | + 'RO', |
|
36 | + 'SK', |
|
37 | + 'SI', |
|
38 | + 'ES', |
|
39 | + 'SE' |
|
40 | 40 | ); |
@@ -13,233 +13,233 @@ |
||
13 | 13 | |
14 | 14 | return array( |
15 | 15 | |
16 | - 'id' => array( |
|
17 | - 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
18 | - 'type' => 'integer', |
|
19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
20 | - 'readonly' => true, |
|
21 | - ), |
|
22 | - |
|
23 | - 'parent_id' => array( |
|
24 | - 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
25 | - 'type' => 'integer', |
|
26 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
27 | - 'default' => 0, |
|
28 | - ), |
|
29 | - |
|
30 | - 'status' => array( |
|
31 | - 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
32 | - 'type' => 'string', |
|
33 | - 'enum' => array( 'draft', 'pending', 'publish' ), |
|
34 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
35 | - 'default' => 'draft', |
|
36 | - ), |
|
37 | - |
|
38 | - 'version' => array( |
|
39 | - 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
40 | - 'type' => 'string', |
|
41 | - 'context' => array( 'view', 'edit' ), |
|
42 | - 'readonly' => true, |
|
43 | - ), |
|
44 | - |
|
45 | - 'date_created' => array( |
|
46 | - 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
47 | - 'type' => 'string', |
|
48 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
49 | - ), |
|
50 | - |
|
51 | - 'date_created_gmt' => array( |
|
52 | - 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
53 | - 'type' => 'string', |
|
54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
55 | - 'readonly' => true, |
|
56 | - ), |
|
57 | - |
|
58 | - 'date_modified' => array( |
|
59 | - 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
60 | - 'type' => 'string', |
|
61 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
62 | - 'readonly' => true, |
|
63 | - ), |
|
64 | - |
|
65 | - 'date_modified_gmt' => array( |
|
66 | - 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
67 | - 'type' => 'string', |
|
68 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
69 | - 'readonly' => true, |
|
70 | - ), |
|
71 | - |
|
72 | - 'name' => array( |
|
73 | - 'description' => __( "The item's name.", 'invoicing' ), |
|
74 | - 'type' => 'string', |
|
75 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
76 | - 'required' => true, |
|
77 | - ), |
|
78 | - |
|
79 | - 'description' => array( |
|
80 | - 'description' => __( "The item's description.", 'invoicing' ), |
|
81 | - 'type' => 'string', |
|
82 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
83 | - ), |
|
84 | - |
|
85 | - 'owner' => array( |
|
86 | - 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
87 | - 'type' => 'integer', |
|
88 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
89 | - ), |
|
90 | - |
|
91 | - 'price' => array( |
|
92 | - 'description' => __( 'The price of the item.', 'invoicing' ), |
|
93 | - 'type' => 'number', |
|
94 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
95 | - 'required' => true, |
|
96 | - ), |
|
97 | - |
|
98 | - 'the_price' => array( |
|
99 | - 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
100 | - 'type' => 'string', |
|
101 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
102 | - 'readonly' => true, |
|
103 | - ), |
|
104 | - |
|
105 | - 'type' => array( |
|
106 | - 'description' => __( 'The item type.', 'invoicing' ), |
|
107 | - 'type' => 'string', |
|
108 | - 'enum' => wpinv_item_types(), |
|
109 | - 'default' => 'custom', |
|
110 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
111 | - ), |
|
112 | - |
|
113 | - 'vat_rule' => array( |
|
114 | - 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
115 | - 'type' => 'string', |
|
116 | - 'enum' => array_keys( getpaid_get_tax_rules() ), |
|
117 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
118 | - ), |
|
119 | - |
|
120 | - 'vat_class' => array( |
|
121 | - 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
122 | - 'type' => 'string', |
|
123 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
124 | - 'enum' => array_keys( getpaid_get_tax_classes() ), |
|
125 | - ), |
|
126 | - |
|
127 | - 'custom_id' => array( |
|
128 | - 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
129 | - 'type' => 'string', |
|
130 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
131 | - ), |
|
16 | + 'id' => array( |
|
17 | + 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
18 | + 'type' => 'integer', |
|
19 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
20 | + 'readonly' => true, |
|
21 | + ), |
|
22 | + |
|
23 | + 'parent_id' => array( |
|
24 | + 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
25 | + 'type' => 'integer', |
|
26 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
27 | + 'default' => 0, |
|
28 | + ), |
|
29 | + |
|
30 | + 'status' => array( |
|
31 | + 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
32 | + 'type' => 'string', |
|
33 | + 'enum' => array( 'draft', 'pending', 'publish' ), |
|
34 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
35 | + 'default' => 'draft', |
|
36 | + ), |
|
37 | + |
|
38 | + 'version' => array( |
|
39 | + 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
40 | + 'type' => 'string', |
|
41 | + 'context' => array( 'view', 'edit' ), |
|
42 | + 'readonly' => true, |
|
43 | + ), |
|
44 | + |
|
45 | + 'date_created' => array( |
|
46 | + 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
47 | + 'type' => 'string', |
|
48 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
49 | + ), |
|
50 | + |
|
51 | + 'date_created_gmt' => array( |
|
52 | + 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
53 | + 'type' => 'string', |
|
54 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
55 | + 'readonly' => true, |
|
56 | + ), |
|
57 | + |
|
58 | + 'date_modified' => array( |
|
59 | + 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
60 | + 'type' => 'string', |
|
61 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
62 | + 'readonly' => true, |
|
63 | + ), |
|
64 | + |
|
65 | + 'date_modified_gmt' => array( |
|
66 | + 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
67 | + 'type' => 'string', |
|
68 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
69 | + 'readonly' => true, |
|
70 | + ), |
|
71 | + |
|
72 | + 'name' => array( |
|
73 | + 'description' => __( "The item's name.", 'invoicing' ), |
|
74 | + 'type' => 'string', |
|
75 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
76 | + 'required' => true, |
|
77 | + ), |
|
78 | + |
|
79 | + 'description' => array( |
|
80 | + 'description' => __( "The item's description.", 'invoicing' ), |
|
81 | + 'type' => 'string', |
|
82 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
83 | + ), |
|
84 | + |
|
85 | + 'owner' => array( |
|
86 | + 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
87 | + 'type' => 'integer', |
|
88 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
89 | + ), |
|
90 | + |
|
91 | + 'price' => array( |
|
92 | + 'description' => __( 'The price of the item.', 'invoicing' ), |
|
93 | + 'type' => 'number', |
|
94 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
95 | + 'required' => true, |
|
96 | + ), |
|
97 | + |
|
98 | + 'the_price' => array( |
|
99 | + 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
100 | + 'type' => 'string', |
|
101 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
102 | + 'readonly' => true, |
|
103 | + ), |
|
104 | + |
|
105 | + 'type' => array( |
|
106 | + 'description' => __( 'The item type.', 'invoicing' ), |
|
107 | + 'type' => 'string', |
|
108 | + 'enum' => wpinv_item_types(), |
|
109 | + 'default' => 'custom', |
|
110 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
111 | + ), |
|
112 | + |
|
113 | + 'vat_rule' => array( |
|
114 | + 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
115 | + 'type' => 'string', |
|
116 | + 'enum' => array_keys( getpaid_get_tax_rules() ), |
|
117 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
118 | + ), |
|
119 | + |
|
120 | + 'vat_class' => array( |
|
121 | + 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
122 | + 'type' => 'string', |
|
123 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
124 | + 'enum' => array_keys( getpaid_get_tax_classes() ), |
|
125 | + ), |
|
126 | + |
|
127 | + 'custom_id' => array( |
|
128 | + 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
129 | + 'type' => 'string', |
|
130 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
131 | + ), |
|
132 | 132 | |
133 | - 'custom_name' => array( |
|
134 | - 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
135 | - 'type' => 'string', |
|
136 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
137 | - ), |
|
138 | - |
|
139 | - 'custom_singular_name' => array( |
|
140 | - 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
141 | - 'type' => 'string', |
|
142 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
143 | - ), |
|
144 | - |
|
145 | - 'is_dynamic_pricing' => array( |
|
146 | - 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
147 | - 'type' => 'integer', |
|
148 | - 'enum' => array( 0, 1 ), |
|
149 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
150 | - ), |
|
151 | - |
|
152 | - 'minimum_price' => array( |
|
153 | - 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
154 | - 'type' => 'number', |
|
155 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
156 | - ), |
|
157 | - |
|
158 | - 'is_recurring' => array( |
|
159 | - 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
160 | - 'type' => 'integer', |
|
161 | - 'enum' => array( 0, 1 ), |
|
162 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
163 | - ), |
|
164 | - |
|
165 | - 'initial_price' => array( |
|
166 | - 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
167 | - 'type' => 'number', |
|
168 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
169 | - 'readonly' => true, |
|
170 | - ), |
|
171 | - |
|
172 | - 'the_initial_price' => array( |
|
173 | - 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
174 | - 'type' => 'string', |
|
175 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
176 | - 'readonly' => true, |
|
177 | - ), |
|
178 | - |
|
179 | - 'recurring_price' => array( |
|
180 | - 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
181 | - 'type' => 'number', |
|
182 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
183 | - 'readonly' => true, |
|
184 | - ), |
|
185 | - |
|
186 | - 'the_recurring_price' => array( |
|
187 | - 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
188 | - 'type' => 'string', |
|
189 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
190 | - 'readonly' => true, |
|
191 | - ), |
|
192 | - |
|
193 | - 'recurring_period' => array( |
|
194 | - 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
195 | - 'type' => 'string', |
|
196 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
197 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
198 | - ), |
|
199 | - |
|
200 | - 'recurring_interval' => array( |
|
201 | - 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
202 | - 'type' => 'integer', |
|
203 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
204 | - ), |
|
205 | - |
|
206 | - 'recurring_limit' => array( |
|
207 | - 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
208 | - 'type' => 'integer', |
|
209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
210 | - ), |
|
211 | - |
|
212 | - 'is_free_trial' => array( |
|
213 | - 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
214 | - 'type' => 'integer', |
|
215 | - 'enum' => array( 0, 1 ), |
|
216 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
217 | - ), |
|
218 | - |
|
219 | - 'trial_period' => array( |
|
220 | - 'description' => __( 'The trial period.', 'invoicing' ), |
|
221 | - 'type' => 'string', |
|
222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
223 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
224 | - ), |
|
225 | - |
|
226 | - 'trial_interval' => array( |
|
227 | - 'description' => __( 'The trial interval.', 'invoicing' ), |
|
228 | - 'type' => 'integer', |
|
229 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
230 | - ), |
|
231 | - |
|
232 | - 'first_renewal_date' => array( |
|
233 | - 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
234 | - 'type' => 'string', |
|
235 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
236 | - 'readonly' => true, |
|
237 | - ), |
|
238 | - |
|
239 | - 'edit_url' => array( |
|
240 | - 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
241 | - 'type' => 'string', |
|
242 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
243 | - 'readonly' => true, |
|
244 | - ), |
|
133 | + 'custom_name' => array( |
|
134 | + 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
135 | + 'type' => 'string', |
|
136 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
137 | + ), |
|
138 | + |
|
139 | + 'custom_singular_name' => array( |
|
140 | + 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
141 | + 'type' => 'string', |
|
142 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
143 | + ), |
|
144 | + |
|
145 | + 'is_dynamic_pricing' => array( |
|
146 | + 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
147 | + 'type' => 'integer', |
|
148 | + 'enum' => array( 0, 1 ), |
|
149 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
150 | + ), |
|
151 | + |
|
152 | + 'minimum_price' => array( |
|
153 | + 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
154 | + 'type' => 'number', |
|
155 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
156 | + ), |
|
157 | + |
|
158 | + 'is_recurring' => array( |
|
159 | + 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
160 | + 'type' => 'integer', |
|
161 | + 'enum' => array( 0, 1 ), |
|
162 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
163 | + ), |
|
164 | + |
|
165 | + 'initial_price' => array( |
|
166 | + 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
167 | + 'type' => 'number', |
|
168 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
169 | + 'readonly' => true, |
|
170 | + ), |
|
171 | + |
|
172 | + 'the_initial_price' => array( |
|
173 | + 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
174 | + 'type' => 'string', |
|
175 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
176 | + 'readonly' => true, |
|
177 | + ), |
|
178 | + |
|
179 | + 'recurring_price' => array( |
|
180 | + 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
181 | + 'type' => 'number', |
|
182 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
183 | + 'readonly' => true, |
|
184 | + ), |
|
185 | + |
|
186 | + 'the_recurring_price' => array( |
|
187 | + 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
188 | + 'type' => 'string', |
|
189 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
190 | + 'readonly' => true, |
|
191 | + ), |
|
192 | + |
|
193 | + 'recurring_period' => array( |
|
194 | + 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
195 | + 'type' => 'string', |
|
196 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
197 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
198 | + ), |
|
199 | + |
|
200 | + 'recurring_interval' => array( |
|
201 | + 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
202 | + 'type' => 'integer', |
|
203 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
204 | + ), |
|
205 | + |
|
206 | + 'recurring_limit' => array( |
|
207 | + 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
208 | + 'type' => 'integer', |
|
209 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
210 | + ), |
|
211 | + |
|
212 | + 'is_free_trial' => array( |
|
213 | + 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
214 | + 'type' => 'integer', |
|
215 | + 'enum' => array( 0, 1 ), |
|
216 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
217 | + ), |
|
218 | + |
|
219 | + 'trial_period' => array( |
|
220 | + 'description' => __( 'The trial period.', 'invoicing' ), |
|
221 | + 'type' => 'string', |
|
222 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
223 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
224 | + ), |
|
225 | + |
|
226 | + 'trial_interval' => array( |
|
227 | + 'description' => __( 'The trial interval.', 'invoicing' ), |
|
228 | + 'type' => 'integer', |
|
229 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
230 | + ), |
|
231 | + |
|
232 | + 'first_renewal_date' => array( |
|
233 | + 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
234 | + 'type' => 'string', |
|
235 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
236 | + 'readonly' => true, |
|
237 | + ), |
|
238 | + |
|
239 | + 'edit_url' => array( |
|
240 | + 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
241 | + 'type' => 'string', |
|
242 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
243 | + 'readonly' => true, |
|
244 | + ), |
|
245 | 245 | ); |