@@ -14,537 +14,537 @@ 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' ), 11 ); |
|
| 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/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 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 235 | - |
|
| 236 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 237 | - GetPaid_Post_Types_Admin::init(); |
|
| 238 | - |
|
| 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/class-wpinv-admin-menus.php' ); |
|
| 243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 244 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
| 245 | - // load the user class only on the users.php page |
|
| 246 | - global $pagenow; |
|
| 247 | - if($pagenow=='users.php'){ |
|
| 248 | - new WPInv_Admin_Users(); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - // Register cli commands |
|
| 253 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 254 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 255 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Class autoloader |
|
| 262 | - * |
|
| 263 | - * @param string $class_name The name of the class to load. |
|
| 264 | - * @access public |
|
| 265 | - * @since 1.0.19 |
|
| 266 | - * @return void |
|
| 267 | - */ |
|
| 268 | - public function autoload( $class_name ) { |
|
| 269 | - |
|
| 270 | - // Normalize the class name... |
|
| 271 | - $class_name = strtolower( $class_name ); |
|
| 272 | - |
|
| 273 | - // ... and make sure it is our class. |
|
| 274 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 275 | - return; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - // Next, prepare the file name from the class. |
|
| 279 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 280 | - |
|
| 281 | - // Base path of the classes. |
|
| 282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 283 | - |
|
| 284 | - // And an array of possible locations in order of importance. |
|
| 285 | - $locations = array( |
|
| 286 | - "$plugin_path/includes", |
|
| 287 | - "$plugin_path/includes/data-stores", |
|
| 288 | - "$plugin_path/includes/gateways", |
|
| 289 | - "$plugin_path/includes/payments", |
|
| 290 | - "$plugin_path/includes/geolocation", |
|
| 291 | - "$plugin_path/includes/reports", |
|
| 292 | - "$plugin_path/includes/api", |
|
| 293 | - "$plugin_path/includes/admin", |
|
| 294 | - "$plugin_path/includes/admin/meta-boxes", |
|
| 295 | - ); |
|
| 296 | - |
|
| 297 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 298 | - |
|
| 299 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 300 | - include trailingslashit( $location ) . $file_name; |
|
| 301 | - break; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Inits hooks etc. |
|
| 310 | - */ |
|
| 311 | - public function init() { |
|
| 312 | - |
|
| 313 | - // Fires before getpaid inits. |
|
| 314 | - do_action( 'before_getpaid_init', $this ); |
|
| 315 | - |
|
| 316 | - // Maybe upgrade. |
|
| 317 | - $this->maybe_upgrade_database(); |
|
| 318 | - |
|
| 319 | - // Load default gateways. |
|
| 320 | - $gateways = apply_filters( |
|
| 321 | - 'getpaid_default_gateways', |
|
| 322 | - array( |
|
| 323 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
| 324 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
| 325 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
| 326 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
| 327 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
| 328 | - ) |
|
| 329 | - ); |
|
| 330 | - |
|
| 331 | - foreach ( $gateways as $id => $class ) { |
|
| 332 | - $this->gateways[ $id ] = new $class(); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - // Fires after getpaid inits. |
|
| 336 | - do_action( 'getpaid_init', $this ); |
|
| 337 | - |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Checks if this is an IPN request and processes it. |
|
| 342 | - */ |
|
| 343 | - public function maybe_process_ipn() { |
|
| 344 | - |
|
| 345 | - // Ensure that this is an IPN request. |
|
| 346 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 347 | - return; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 351 | - |
|
| 352 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 353 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 354 | - exit; |
|
| 355 | - |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - public function enqueue_scripts() { |
|
| 359 | - |
|
| 360 | - // Fires before adding scripts. |
|
| 361 | - do_action( 'getpaid_enqueue_scripts' ); |
|
| 362 | - |
|
| 363 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 364 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 365 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 366 | - |
|
| 367 | - $localize = array(); |
|
| 368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 369 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 370 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 371 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
| 372 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 373 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 374 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
| 375 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 376 | - |
|
| 377 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 378 | - |
|
| 379 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 380 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
| 381 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - public function wpinv_actions() { |
|
| 385 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 386 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 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' ), 11 ); |
|
| 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/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 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 235 | + |
|
| 236 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 237 | + GetPaid_Post_Types_Admin::init(); |
|
| 238 | + |
|
| 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/class-wpinv-admin-menus.php' ); |
|
| 243 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 244 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
| 245 | + // load the user class only on the users.php page |
|
| 246 | + global $pagenow; |
|
| 247 | + if($pagenow=='users.php'){ |
|
| 248 | + new WPInv_Admin_Users(); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + // Register cli commands |
|
| 253 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 254 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 255 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Class autoloader |
|
| 262 | + * |
|
| 263 | + * @param string $class_name The name of the class to load. |
|
| 264 | + * @access public |
|
| 265 | + * @since 1.0.19 |
|
| 266 | + * @return void |
|
| 267 | + */ |
|
| 268 | + public function autoload( $class_name ) { |
|
| 269 | + |
|
| 270 | + // Normalize the class name... |
|
| 271 | + $class_name = strtolower( $class_name ); |
|
| 272 | + |
|
| 273 | + // ... and make sure it is our class. |
|
| 274 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + // Next, prepare the file name from the class. |
|
| 279 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 280 | + |
|
| 281 | + // Base path of the classes. |
|
| 282 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 283 | + |
|
| 284 | + // And an array of possible locations in order of importance. |
|
| 285 | + $locations = array( |
|
| 286 | + "$plugin_path/includes", |
|
| 287 | + "$plugin_path/includes/data-stores", |
|
| 288 | + "$plugin_path/includes/gateways", |
|
| 289 | + "$plugin_path/includes/payments", |
|
| 290 | + "$plugin_path/includes/geolocation", |
|
| 291 | + "$plugin_path/includes/reports", |
|
| 292 | + "$plugin_path/includes/api", |
|
| 293 | + "$plugin_path/includes/admin", |
|
| 294 | + "$plugin_path/includes/admin/meta-boxes", |
|
| 295 | + ); |
|
| 296 | + |
|
| 297 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 298 | + |
|
| 299 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 300 | + include trailingslashit( $location ) . $file_name; |
|
| 301 | + break; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Inits hooks etc. |
|
| 310 | + */ |
|
| 311 | + public function init() { |
|
| 312 | + |
|
| 313 | + // Fires before getpaid inits. |
|
| 314 | + do_action( 'before_getpaid_init', $this ); |
|
| 315 | + |
|
| 316 | + // Maybe upgrade. |
|
| 317 | + $this->maybe_upgrade_database(); |
|
| 318 | + |
|
| 319 | + // Load default gateways. |
|
| 320 | + $gateways = apply_filters( |
|
| 321 | + 'getpaid_default_gateways', |
|
| 322 | + array( |
|
| 323 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
| 324 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
| 325 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
| 326 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
| 327 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
| 328 | + ) |
|
| 329 | + ); |
|
| 330 | + |
|
| 331 | + foreach ( $gateways as $id => $class ) { |
|
| 332 | + $this->gateways[ $id ] = new $class(); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + // Fires after getpaid inits. |
|
| 336 | + do_action( 'getpaid_init', $this ); |
|
| 337 | + |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Checks if this is an IPN request and processes it. |
|
| 342 | + */ |
|
| 343 | + public function maybe_process_ipn() { |
|
| 344 | + |
|
| 345 | + // Ensure that this is an IPN request. |
|
| 346 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 347 | + return; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 351 | + |
|
| 352 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 353 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 354 | + exit; |
|
| 355 | + |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + public function enqueue_scripts() { |
|
| 359 | + |
|
| 360 | + // Fires before adding scripts. |
|
| 361 | + do_action( 'getpaid_enqueue_scripts' ); |
|
| 362 | + |
|
| 363 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 364 | + wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 365 | + wp_enqueue_style( 'wpinv_front_style' ); |
|
| 366 | + |
|
| 367 | + $localize = array(); |
|
| 368 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 369 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 370 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 371 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
| 372 | + $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 373 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 374 | + $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
| 375 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 376 | + |
|
| 377 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 378 | + |
|
| 379 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 380 | + wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
| 381 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + public function wpinv_actions() { |
|
| 385 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 386 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | 391 | * Fires an action after verifying that a user can fire them. |
| 392 | - * |
|
| 393 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
| 394 | - * current user owns the invoice/subscription. |
|
| 392 | + * |
|
| 393 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
| 394 | + * current user owns the invoice/subscription. |
|
| 395 | 395 | */ |
| 396 | 396 | public function maybe_do_authenticated_action() { |
| 397 | 397 | |
| 398 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 398 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 399 | + |
|
| 400 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 401 | + $data = wp_unslash( $_REQUEST ); |
|
| 402 | + if ( is_user_logged_in() ) { |
|
| 403 | + do_action( "getpaid_authenticated_action_$key", $data ); |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 401 | - $data = wp_unslash( $_REQUEST ); |
|
| 402 | - if ( is_user_logged_in() ) { |
|
| 403 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
| 404 | - } |
|
| 406 | + do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
| 407 | + |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + } |
|
| 405 | 411 | |
| 406 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
| 412 | + public function pre_get_posts( $wp_query ) { |
|
| 407 | 413 | |
| 408 | - } |
|
| 414 | + 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() ) { |
|
| 415 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 416 | + } |
|
| 409 | 417 | |
| 418 | + return $wp_query; |
|
| 410 | 419 | } |
| 411 | 420 | |
| 412 | - public function pre_get_posts( $wp_query ) { |
|
| 413 | - |
|
| 414 | - 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() ) { |
|
| 415 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - return $wp_query; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - public function bp_invoicing_init() { |
|
| 422 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Register widgets |
|
| 427 | - * |
|
| 428 | - */ |
|
| 429 | - public function register_widgets() { |
|
| 430 | - |
|
| 431 | - // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
| 432 | - // So we disable our widgets when editing a page with UX Builder. |
|
| 433 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
| 434 | - return; |
|
| 435 | - } |
|
| 436 | - |
|
| 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 | - } |
|
| 421 | + public function bp_invoicing_init() { |
|
| 422 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Register widgets |
|
| 427 | + * |
|
| 428 | + */ |
|
| 429 | + public function register_widgets() { |
|
| 430 | + |
|
| 431 | + // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
| 432 | + // So we disable our widgets when editing a page with UX Builder. |
|
| 433 | + if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
| 434 | + return; |
|
| 435 | + } |
|
| 436 | + |
|
| 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 | - * Upgrades the database. |
|
| 458 | - * |
|
| 459 | - * @since 2.0.2 |
|
| 460 | - */ |
|
| 461 | - public function maybe_upgrade_database() { |
|
| 456 | + /** |
|
| 457 | + * Upgrades the database. |
|
| 458 | + * |
|
| 459 | + * @since 2.0.2 |
|
| 460 | + */ |
|
| 461 | + public function maybe_upgrade_database() { |
|
| 462 | 462 | |
| 463 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
| 463 | + $wpi_version = get_option( 'wpinv_version', 0 ); |
|
| 464 | 464 | |
| 465 | - if ( $wpi_version == WPINV_VERSION ) { |
|
| 466 | - return; |
|
| 467 | - } |
|
| 465 | + if ( $wpi_version == WPINV_VERSION ) { |
|
| 466 | + return; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $installer = new GetPaid_Installer(); |
|
| 469 | + $installer = new GetPaid_Installer(); |
|
| 470 | 470 | |
| 471 | - if ( empty( $wpi_version ) ) { |
|
| 472 | - return $installer->upgrade_db( 0 ); |
|
| 473 | - } |
|
| 471 | + if ( empty( $wpi_version ) ) { |
|
| 472 | + return $installer->upgrade_db( 0 ); |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - $upgrades = array( |
|
| 476 | - '0.0.5' => '004', |
|
| 477 | - '1.0.3' => '102', |
|
| 478 | - '2.0.0' => '118', |
|
| 479 | - '2.0.8' => '207', |
|
| 480 | - ); |
|
| 475 | + $upgrades = array( |
|
| 476 | + '0.0.5' => '004', |
|
| 477 | + '1.0.3' => '102', |
|
| 478 | + '2.0.0' => '118', |
|
| 479 | + '2.0.8' => '207', |
|
| 480 | + ); |
|
| 481 | 481 | |
| 482 | - foreach ( $upgrades as $key => $method ) { |
|
| 482 | + foreach ( $upgrades as $key => $method ) { |
|
| 483 | 483 | |
| 484 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
| 485 | - return $installer->upgrade_db( $method ); |
|
| 486 | - } |
|
| 484 | + if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
| 485 | + return $installer->upgrade_db( $method ); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - } |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | - /** |
|
| 493 | - * Flushes the permalinks if needed. |
|
| 494 | - * |
|
| 495 | - * @since 2.0.8 |
|
| 496 | - */ |
|
| 497 | - public function maybe_flush_permalinks() { |
|
| 492 | + /** |
|
| 493 | + * Flushes the permalinks if needed. |
|
| 494 | + * |
|
| 495 | + * @since 2.0.8 |
|
| 496 | + */ |
|
| 497 | + public function maybe_flush_permalinks() { |
|
| 498 | 498 | |
| 499 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
| 499 | + $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
| 500 | 500 | |
| 501 | - if ( ! empty( $flush ) ) { |
|
| 502 | - flush_rewrite_rules(); |
|
| 503 | - delete_option( 'wpinv_flush_permalinks' ); |
|
| 504 | - } |
|
| 501 | + if ( ! empty( $flush ) ) { |
|
| 502 | + flush_rewrite_rules(); |
|
| 503 | + delete_option( 'wpinv_flush_permalinks' ); |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - /** |
|
| 509 | - * Remove our pages from yoast sitemaps. |
|
| 510 | - * |
|
| 511 | - * @since 1.0.19 |
|
| 512 | - * @param int[] $excluded_posts_ids |
|
| 513 | - */ |
|
| 514 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 508 | + /** |
|
| 509 | + * Remove our pages from yoast sitemaps. |
|
| 510 | + * |
|
| 511 | + * @since 1.0.19 |
|
| 512 | + * @param int[] $excluded_posts_ids |
|
| 513 | + */ |
|
| 514 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 515 | 515 | |
| 516 | - // Ensure that we have an array. |
|
| 517 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 518 | - $excluded_posts_ids = array(); |
|
| 519 | - } |
|
| 516 | + // Ensure that we have an array. |
|
| 517 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 518 | + $excluded_posts_ids = array(); |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | - // Prepare our pages. |
|
| 522 | - $our_pages = array(); |
|
| 521 | + // Prepare our pages. |
|
| 522 | + $our_pages = array(); |
|
| 523 | 523 | |
| 524 | - // Checkout page. |
|
| 525 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 524 | + // Checkout page. |
|
| 525 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 526 | 526 | |
| 527 | - // Success page. |
|
| 528 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 527 | + // Success page. |
|
| 528 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 529 | 529 | |
| 530 | - // Failure page. |
|
| 531 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 530 | + // Failure page. |
|
| 531 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 532 | 532 | |
| 533 | - // History page. |
|
| 534 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 533 | + // History page. |
|
| 534 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 535 | 535 | |
| 536 | - // Subscriptions page. |
|
| 537 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 536 | + // Subscriptions page. |
|
| 537 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 538 | 538 | |
| 539 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 539 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 540 | 540 | |
| 541 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
| 542 | - return array_unique( $excluded_posts_ids ); |
|
| 541 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
| 542 | + return array_unique( $excluded_posts_ids ); |
|
| 543 | 543 | |
| 544 | - } |
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - public function wp_footer() { |
|
| 547 | - echo ' |
|
| 546 | + public function wp_footer() { |
|
| 547 | + echo ' |
|
| 548 | 548 | <div class="bsui"> |
| 549 | 549 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
| 550 | 550 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
@@ -560,6 +560,6 @@ discard block |
||
| 560 | 560 | </div> |
| 561 | 561 | </div> |
| 562 | 562 | '; |
| 563 | - } |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | 565 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @since 1.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @param string $prop The prop to set. |
| 57 | 57 | * @param mixed $value The value to retrieve. |
| 58 | 58 | */ |
| 59 | - public function set( $prop, $value ) { |
|
| 60 | - $this->data[ $prop ] = $value; |
|
| 59 | + public function set($prop, $value) { |
|
| 60 | + $this->data[$prop] = $value; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | * @param string $prop The prop to set. |
| 67 | 67 | * @return mixed The value. |
| 68 | 68 | */ |
| 69 | - public function get( $prop ) { |
|
| 69 | + public function get($prop) { |
|
| 70 | 70 | |
| 71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
| 72 | - return $this->data[ $prop ]; |
|
| 71 | + if (isset($this->data[$prop])) { |
|
| 72 | + return $this->data[$prop]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
| 81 | 81 | public function set_properties() { |
| 82 | 82 | |
| 83 | 83 | // Sessions. |
| 84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
| 84 | + $this->set('session', new WPInv_Session_Handler()); |
|
| 85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
| 86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
| 87 | 87 | |
| 88 | 88 | // Init other objects. |
| 89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
| 91 | - $this->set( 'api', new WPInv_API() ); |
|
| 92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
| 93 | - $this->set( 'template', new GetPaid_Template() ); |
|
| 94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
| 95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
| 96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
| 97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
| 98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
| 99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
| 100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
| 89 | + $this->set('session', new WPInv_Session_Handler()); |
|
| 90 | + $this->set('notes', new WPInv_Notes()); |
|
| 91 | + $this->set('api', new WPInv_API()); |
|
| 92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
| 93 | + $this->set('template', new GetPaid_Template()); |
|
| 94 | + $this->set('admin', new GetPaid_Admin()); |
|
| 95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
| 96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
| 97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
| 98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
| 99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
| 100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * Define plugin constants. |
| 106 | 106 | */ |
| 107 | 107 | public function define_constants() { |
| 108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 110 | 110 | $this->version = WPINV_VERSION; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function init_hooks() { |
| 119 | 119 | /* Internationalize the text strings used. */ |
| 120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 121 | 121 | |
| 122 | 122 | // Init the plugin after WordPress inits. |
| 123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
| 124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
| 125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
| 126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
| 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 | 127 | |
| 128 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 129 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 128 | + if (class_exists('BuddyPress')) { |
|
| 129 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
| 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' ) ); |
|
| 132 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
| 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 | 137 | |
| 138 | 138 | // Fires after registering actions. |
| 139 | - do_action( 'wpinv_actions', $this ); |
|
| 140 | - do_action( 'getpaid_actions', $this ); |
|
| 139 | + do_action('wpinv_actions', $this); |
|
| 140 | + do_action('getpaid_actions', $this); |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | /* Internationalize the text strings used. */ |
| 146 | 146 | $this->load_textdomain(); |
| 147 | 147 | |
| 148 | - do_action( 'wpinv_loaded' ); |
|
| 148 | + do_action('wpinv_loaded'); |
|
| 149 | 149 | |
| 150 | 150 | // Fix oxygen page builder conflict |
| 151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 151 | + if (function_exists('ct_css_output')) { |
|
| 152 | 152 | wpinv_oxygen_fix_conflict(); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -158,21 +158,21 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @since 1.0 |
| 160 | 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(); |
|
| 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 | 164 | } |
| 165 | 165 | |
| 166 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 166 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 167 | 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' ); |
|
| 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 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Define language constants. |
| 174 | 174 | */ |
| 175 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 175 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -181,78 +181,78 @@ discard block |
||
| 181 | 181 | public function includes() { |
| 182 | 182 | |
| 183 | 183 | // Start with the settings. |
| 184 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 184 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 185 | 185 | |
| 186 | 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' ); |
|
| 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 | 189 | |
| 190 | 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/user-functions.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
| 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/user-functions.php'); |
|
| 205 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
| 206 | 206 | |
| 207 | 207 | // Register autoloader. |
| 208 | 208 | try { |
| 209 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 210 | - } catch ( Exception $e ) { |
|
| 211 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 209 | + spl_autoload_register(array($this, 'autoload'), true); |
|
| 210 | + } catch (Exception $e) { |
|
| 211 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
| 212 | 212 | } |
| 213 | 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 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 235 | - |
|
| 236 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 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 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 235 | + |
|
| 236 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 237 | 237 | GetPaid_Post_Types_Admin::init(); |
| 238 | 238 | |
| 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/class-wpinv-admin-menus.php' ); |
|
| 243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 244 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.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/class-wpinv-admin-menus.php'); |
|
| 243 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 244 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
| 245 | 245 | // load the user class only on the users.php page |
| 246 | 246 | global $pagenow; |
| 247 | - if($pagenow=='users.php'){ |
|
| 247 | + if ($pagenow == 'users.php') { |
|
| 248 | 248 | new WPInv_Admin_Users(); |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // Register cli commands |
| 253 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 254 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 255 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 253 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 254 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
| 255 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | } |
@@ -265,21 +265,21 @@ discard block |
||
| 265 | 265 | * @since 1.0.19 |
| 266 | 266 | * @return void |
| 267 | 267 | */ |
| 268 | - public function autoload( $class_name ) { |
|
| 268 | + public function autoload($class_name) { |
|
| 269 | 269 | |
| 270 | 270 | // Normalize the class name... |
| 271 | - $class_name = strtolower( $class_name ); |
|
| 271 | + $class_name = strtolower($class_name); |
|
| 272 | 272 | |
| 273 | 273 | // ... and make sure it is our class. |
| 274 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 274 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Next, prepare the file name from the class. |
| 279 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 279 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
| 280 | 280 | |
| 281 | 281 | // Base path of the classes. |
| 282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 282 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
| 283 | 283 | |
| 284 | 284 | // And an array of possible locations in order of importance. |
| 285 | 285 | $locations = array( |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | "$plugin_path/includes/admin/meta-boxes", |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 297 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
| 298 | 298 | |
| 299 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 300 | - include trailingslashit( $location ) . $file_name; |
|
| 299 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
| 300 | + include trailingslashit($location) . $file_name; |
|
| 301 | 301 | break; |
| 302 | 302 | } |
| 303 | 303 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | public function init() { |
| 312 | 312 | |
| 313 | 313 | // Fires before getpaid inits. |
| 314 | - do_action( 'before_getpaid_init', $this ); |
|
| 314 | + do_action('before_getpaid_init', $this); |
|
| 315 | 315 | |
| 316 | 316 | // Maybe upgrade. |
| 317 | 317 | $this->maybe_upgrade_database(); |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | ) |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - foreach ( $gateways as $id => $class ) { |
|
| 332 | - $this->gateways[ $id ] = new $class(); |
|
| 331 | + foreach ($gateways as $id => $class) { |
|
| 332 | + $this->gateways[$id] = new $class(); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | // Fires after getpaid inits. |
| 336 | - do_action( 'getpaid_init', $this ); |
|
| 336 | + do_action('getpaid_init', $this); |
|
| 337 | 337 | |
| 338 | 338 | } |
| 339 | 339 | |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | public function maybe_process_ipn() { |
| 344 | 344 | |
| 345 | 345 | // Ensure that this is an IPN request. |
| 346 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 346 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
| 347 | 347 | return; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 350 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
| 351 | 351 | |
| 352 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 353 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 352 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
| 353 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
| 354 | 354 | exit; |
| 355 | 355 | |
| 356 | 356 | } |
@@ -358,32 +358,32 @@ discard block |
||
| 358 | 358 | public function enqueue_scripts() { |
| 359 | 359 | |
| 360 | 360 | // Fires before adding scripts. |
| 361 | - do_action( 'getpaid_enqueue_scripts' ); |
|
| 361 | + do_action('getpaid_enqueue_scripts'); |
|
| 362 | 362 | |
| 363 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 364 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 365 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 363 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
| 364 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
| 365 | + wp_enqueue_style('wpinv_front_style'); |
|
| 366 | 366 | |
| 367 | 367 | $localize = array(); |
| 368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 369 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 370 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 368 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 369 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 370 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
| 371 | 371 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 372 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 373 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 374 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
| 375 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 372 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 373 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
| 374 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
| 375 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
| 376 | 376 | |
| 377 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 377 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 378 | 378 | |
| 379 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 380 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
| 381 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 379 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
| 380 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
| 381 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | public function wpinv_actions() { |
| 385 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 386 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 385 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 386 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
@@ -395,31 +395,31 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | public function maybe_do_authenticated_action() { |
| 397 | 397 | |
| 398 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 398 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
| 399 | 399 | |
| 400 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 401 | - $data = wp_unslash( $_REQUEST ); |
|
| 402 | - if ( is_user_logged_in() ) { |
|
| 403 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
| 400 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
| 401 | + $data = wp_unslash($_REQUEST); |
|
| 402 | + if (is_user_logged_in()) { |
|
| 403 | + do_action("getpaid_authenticated_action_$key", $data); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
| 406 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
| 407 | 407 | |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - public function pre_get_posts( $wp_query ) { |
|
| 412 | + public function pre_get_posts($wp_query) { |
|
| 413 | 413 | |
| 414 | - 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() ) { |
|
| 415 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 414 | + 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()) { |
|
| 415 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | return $wp_query; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | public function bp_invoicing_init() { |
| 422 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 422 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
| 432 | 432 | // So we disable our widgets when editing a page with UX Builder. |
| 433 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
| 433 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
| 434 | 434 | return; |
| 435 | 435 | } |
| 436 | 436 | |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | ) |
| 448 | 448 | ); |
| 449 | 449 | |
| 450 | - foreach ( $widgets as $widget ) { |
|
| 451 | - register_widget( $widget ); |
|
| 450 | + foreach ($widgets as $widget) { |
|
| 451 | + register_widget($widget); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | } |
@@ -460,29 +460,29 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public function maybe_upgrade_database() { |
| 462 | 462 | |
| 463 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
| 463 | + $wpi_version = get_option('wpinv_version', 0); |
|
| 464 | 464 | |
| 465 | - if ( $wpi_version == WPINV_VERSION ) { |
|
| 465 | + if ($wpi_version == WPINV_VERSION) { |
|
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | $installer = new GetPaid_Installer(); |
| 470 | 470 | |
| 471 | - if ( empty( $wpi_version ) ) { |
|
| 472 | - return $installer->upgrade_db( 0 ); |
|
| 471 | + if (empty($wpi_version)) { |
|
| 472 | + return $installer->upgrade_db(0); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - $upgrades = array( |
|
| 475 | + $upgrades = array( |
|
| 476 | 476 | '0.0.5' => '004', |
| 477 | 477 | '1.0.3' => '102', |
| 478 | 478 | '2.0.0' => '118', |
| 479 | 479 | '2.0.8' => '207', |
| 480 | 480 | ); |
| 481 | 481 | |
| 482 | - foreach ( $upgrades as $key => $method ) { |
|
| 482 | + foreach ($upgrades as $key => $method) { |
|
| 483 | 483 | |
| 484 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
| 485 | - return $installer->upgrade_db( $method ); |
|
| 484 | + if (version_compare($wpi_version, $key, '<')) { |
|
| 485 | + return $installer->upgrade_db($method); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | } |
@@ -496,11 +496,11 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | public function maybe_flush_permalinks() { |
| 498 | 498 | |
| 499 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
| 499 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
| 500 | 500 | |
| 501 | - if ( ! empty( $flush ) ) { |
|
| 501 | + if (!empty($flush)) { |
|
| 502 | 502 | flush_rewrite_rules(); |
| 503 | - delete_option( 'wpinv_flush_permalinks' ); |
|
| 503 | + delete_option('wpinv_flush_permalinks'); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | } |
@@ -511,10 +511,10 @@ discard block |
||
| 511 | 511 | * @since 1.0.19 |
| 512 | 512 | * @param int[] $excluded_posts_ids |
| 513 | 513 | */ |
| 514 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 514 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
| 515 | 515 | |
| 516 | 516 | // Ensure that we have an array. |
| 517 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 517 | + if (!is_array($excluded_posts_ids)) { |
|
| 518 | 518 | $excluded_posts_ids = array(); |
| 519 | 519 | } |
| 520 | 520 | |
@@ -522,24 +522,24 @@ discard block |
||
| 522 | 522 | $our_pages = array(); |
| 523 | 523 | |
| 524 | 524 | // Checkout page. |
| 525 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 525 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
| 526 | 526 | |
| 527 | 527 | // Success page. |
| 528 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 528 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
| 529 | 529 | |
| 530 | 530 | // Failure page. |
| 531 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 531 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
| 532 | 532 | |
| 533 | 533 | // History page. |
| 534 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 534 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
| 535 | 535 | |
| 536 | 536 | // Subscriptions page. |
| 537 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 537 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
| 538 | 538 | |
| 539 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 539 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
| 540 | 540 | |
| 541 | 541 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
| 542 | - return array_unique( $excluded_posts_ids ); |
|
| 542 | + return array_unique($excluded_posts_ids); |
|
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
| 551 | 551 | <div class="modal-content"> |
| 552 | 552 | <div class="modal-body"> |
| 553 | - <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__( 'Close', 'invoicing' ) . '"> |
|
| 553 | + <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__('Close', 'invoicing') . '"> |
|
| 554 | 554 | <i class="fa fa-times" aria-hidden="true"></i> |
| 555 | 555 | </button> |
| 556 | 556 | <div class="modal-body-wrapper"></div> |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | function getpaid_get_current_invoice_id() { |
| 15 | 15 | |
| 16 | 16 | // Ensure that we have an invoice key. |
| 17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
| 17 | + if (empty($_GET['invoice_key'])) { |
|
| 18 | 18 | return 0; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // Retrieve an invoice using the key. |
| 22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
| 22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
| 23 | 23 | |
| 24 | 24 | // Compare the invoice key and the parsed key. |
| 25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
| 25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
| 26 | 26 | return $invoice->get_id(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Checks if the current user cna view an invoice. |
| 34 | 34 | */ |
| 35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
| 36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 35 | +function wpinv_user_can_view_invoice($invoice) { |
|
| 36 | + $invoice = new WPInv_Invoice($invoice); |
|
| 37 | 37 | |
| 38 | 38 | // Abort if the invoice does not exist. |
| 39 | - if ( 0 == $invoice->get_id() ) { |
|
| 39 | + if (0 == $invoice->get_id()) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Don't allow trash, draft status |
| 44 | - if ( $invoice->is_draft() ) { |
|
| 44 | + if ($invoice->is_draft()) { |
|
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
| 49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
| 49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Always enable for admins.. |
| 54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
| 54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Else, ensure that this is their invoice. |
| 59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
| 59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
| 60 | 60 | return true; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
| 63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Checks if the current user cna view an invoice receipt. |
| 68 | 68 | */ |
| 69 | -function wpinv_can_view_receipt( $invoice ) { |
|
| 70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 69 | +function wpinv_can_view_receipt($invoice) { |
|
| 70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function getpaid_get_invoice_post_types() { |
| 79 | 79 | $post_types = array( |
| 80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
| 81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
| 80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
| 81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
| 84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param string $post_type The post type to check for. |
| 92 | 92 | */ |
| 93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
| 94 | - return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
| 93 | +function getpaid_is_invoice_post_type($post_type) { |
|
| 94 | + return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 103 | 103 | */ |
| 104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
| 105 | - $data[ 'invoice_id' ] = 0; |
|
| 106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
| 105 | + $data['invoice_id'] = 0; |
|
| 106 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 115 | 115 | */ |
| 116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
| 116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
| 117 | 117 | |
| 118 | 118 | // Backwards compatibility. |
| 119 | - if ( ! empty( $data['ID'] ) ) { |
|
| 119 | + if (!empty($data['ID'])) { |
|
| 120 | 120 | $data['invoice_id'] = $data['ID']; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Do we have an invoice id? |
| 124 | - if ( empty( $data['invoice_id'] ) ) { |
|
| 125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
| 124 | + if (empty($data['invoice_id'])) { |
|
| 125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Retrieve the invoice. |
| 129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
| 129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
| 130 | 130 | |
| 131 | 131 | // And abort if it does not exist. |
| 132 | - if ( empty( $invoice ) ) { |
|
| 133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
| 132 | + if (empty($invoice)) { |
|
| 133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Do not update totals for paid / refunded invoices. |
| 137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
| 140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
| 139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
| 140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 145 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
| 153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 155 | 155 | */ |
| 156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
| 156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
| 157 | 157 | |
| 158 | 158 | // Ensure that we have invoice data. |
| 159 | - if ( empty( $data ) ) { |
|
| 159 | + if (empty($data)) { |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // The invoice id will be provided when updating an invoice. |
| 164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
| 164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
| 165 | 165 | |
| 166 | 166 | // Retrieve the invoice. |
| 167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
| 167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
| 168 | 168 | |
| 169 | 169 | // Do we have an error? |
| 170 | - if ( ! empty( $invoice->last_error ) ) { |
|
| 171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
| 170 | + if (!empty($invoice->last_error)) { |
|
| 171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Backwards compatibility (billing address). |
| 175 | - if ( ! empty( $data['user_info'] ) ) { |
|
| 175 | + if (!empty($data['user_info'])) { |
|
| 176 | 176 | |
| 177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
| 177 | + foreach ($data['user_info'] as $key => $value) { |
|
| 178 | 178 | |
| 179 | - if ( $key == 'discounts' ) { |
|
| 179 | + if ($key == 'discounts') { |
|
| 180 | 180 | $value = (array) $value; |
| 181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
| 181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
| 182 | 182 | } else { |
| 183 | - $data[ $key ] = $value; |
|
| 183 | + $data[$key] = $value; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Backwards compatibility. |
| 191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
| 191 | + if (!empty($data['payment_details'])) { |
|
| 192 | 192 | |
| 193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
| 194 | - $data[ $key ] = $value; |
|
| 193 | + foreach ($data['payment_details'] as $key => $value) { |
|
| 194 | + $data[$key] = $value; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Set up the owner of the invoice. |
| 200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
| 200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
| 201 | 201 | |
| 202 | 202 | // Make sure the user exists. |
| 203 | - if ( ! get_userdata( $user_id ) ) { |
|
| 204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
| 203 | + if (!get_userdata($user_id)) { |
|
| 204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $address = wpinv_get_user_address( $user_id ); |
|
| 207 | + $address = wpinv_get_user_address($user_id); |
|
| 208 | 208 | |
| 209 | - foreach ( $address as $key => $value ) { |
|
| 209 | + foreach ($address as $key => $value) { |
|
| 210 | 210 | |
| 211 | - if ( $value == '' ) { |
|
| 212 | - $address[ $key ] = null; |
|
| 211 | + if ($value == '') { |
|
| 212 | + $address[$key] = null; |
|
| 213 | 213 | } else { |
| 214 | - $address[ $key ] = wpinv_clean( $value ); |
|
| 214 | + $address[$key] = wpinv_clean($value); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
| 222 | 222 | array( |
| 223 | 223 | |
| 224 | 224 | // Basic info. |
| 225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
| 226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
| 227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
| 228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
| 229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
| 230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
| 231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
| 232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
| 233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
| 234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
| 235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
| 236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
| 237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
| 225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
| 226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
| 227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
| 228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
| 229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
| 230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
| 231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
| 232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
| 233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
| 234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
| 235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
| 236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
| 237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
| 238 | 238 | |
| 239 | 239 | // Payment info. |
| 240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
| 241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
| 242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
| 243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
| 244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
| 245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
| 246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
| 247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
| 248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
| 249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
| 250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
| 251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
| 240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
| 241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
| 242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
| 243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
| 244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
| 245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
| 246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
| 247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
| 248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
| 249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
| 250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
| 251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | // Billing details. |
| 255 | 255 | 'user_id' => $data['user_id'], |
| 256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
| 257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
| 258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
| 259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
| 260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
| 261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
| 262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
| 263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
| 264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
| 265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
| 266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
| 256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
| 257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
| 258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
| 259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
| 260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
| 261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
| 262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
| 263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
| 264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
| 265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
| 266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
| 267 | 267 | |
| 268 | 268 | ) |
| 269 | 269 | |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | // Backwards compatibililty. |
| 273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
| 273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
| 274 | 274 | $data['items'] = array(); |
| 275 | 275 | |
| 276 | - foreach( $data['cart_details'] as $_item ) { |
|
| 276 | + foreach ($data['cart_details'] as $_item) { |
|
| 277 | 277 | |
| 278 | 278 | // Ensure that we have an item id. |
| 279 | - if ( empty( $_item['id'] ) ) { |
|
| 279 | + if (empty($_item['id'])) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // Retrieve the item. |
| 284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
| 284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
| 285 | 285 | |
| 286 | 286 | // Ensure that it is purchasable. |
| 287 | - if ( ! $item->can_purchase() ) { |
|
| 287 | + if (!$item->can_purchase()) { |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Set quantity. |
| 292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
| 293 | - $item->set_quantity( $_item['quantity'] ); |
|
| 292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
| 293 | + $item->set_quantity($_item['quantity']); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Set price. |
| 297 | - if ( isset( $_item['item_price'] ) ) { |
|
| 298 | - $item->set_price( $_item['item_price'] ); |
|
| 297 | + if (isset($_item['item_price'])) { |
|
| 298 | + $item->set_price($_item['item_price']); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( isset( $_item['custom_price'] ) ) { |
|
| 302 | - $item->set_price( $_item['custom_price'] ); |
|
| 301 | + if (isset($_item['custom_price'])) { |
|
| 302 | + $item->set_price($_item['custom_price']); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Set name. |
| 306 | - if ( ! empty( $_item['name'] ) ) { |
|
| 307 | - $item->set_name( $_item['name'] ); |
|
| 306 | + if (!empty($_item['name'])) { |
|
| 307 | + $item->set_name($_item['name']); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Set description. |
| 311 | - if ( isset( $_item['description'] ) ) { |
|
| 312 | - $item->set_custom_description( $_item['description'] ); |
|
| 311 | + if (isset($_item['description'])) { |
|
| 312 | + $item->set_custom_description($_item['description']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Set meta. |
| 316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
| 316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
| 317 | 317 | |
| 318 | - $item->set_item_meta( $_item['meta'] ); |
|
| 318 | + $item->set_item_meta($_item['meta']); |
|
| 319 | 319 | |
| 320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
| 321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
| 320 | + if (isset($_item['meta']['description'])) { |
|
| 321 | + $item->set_custom_description($_item['meta']['description']); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Add invoice items. |
| 332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
| 332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
| 333 | 333 | |
| 334 | - $invoice->set_items( array() ); |
|
| 334 | + $invoice->set_items(array()); |
|
| 335 | 335 | |
| 336 | - foreach ( $data['items'] as $item ) { |
|
| 336 | + foreach ($data['items'] as $item) { |
|
| 337 | 337 | |
| 338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
| 339 | - $invoice->add_item( $item ); |
|
| 338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
| 339 | + $invoice->add_item($item); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | } |
@@ -347,30 +347,30 @@ discard block |
||
| 347 | 347 | $invoice->recalculate_total(); |
| 348 | 348 | $invoice->save(); |
| 349 | 349 | |
| 350 | - if ( ! $invoice->get_id() ) { |
|
| 351 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
| 350 | + if (!$invoice->get_id()) { |
|
| 351 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | // Add private note. |
| 355 | - if ( ! empty( $data['private_note'] ) ) { |
|
| 356 | - $invoice->add_note( $data['private_note'] ); |
|
| 355 | + if (!empty($data['private_note'])) { |
|
| 356 | + $invoice->add_note($data['private_note']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | // User notes. |
| 360 | - if ( !empty( $data['user_note'] ) ) { |
|
| 361 | - $invoice->add_note( $data['user_note'], true ); |
|
| 360 | + if (!empty($data['user_note'])) { |
|
| 361 | + $invoice->add_note($data['user_note'], true); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // Created via. |
| 365 | - if ( isset( $data['created_via'] ) ) { |
|
| 366 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
| 365 | + if (isset($data['created_via'])) { |
|
| 366 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // Backwards compatiblity. |
| 370 | - if ( $invoice->is_quote() ) { |
|
| 370 | + if ($invoice->is_quote()) { |
|
| 371 | 371 | |
| 372 | - if ( isset( $data['valid_until'] ) ) { |
|
| 373 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
| 372 | + if (isset($data['valid_until'])) { |
|
| 373 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
| 374 | 374 | } |
| 375 | 375 | return $invoice; |
| 376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
| 385 | 385 | * @param $bool $deprecated |
| 386 | 386 | * @return WPInv_Invoice|null |
| 387 | 387 | */ |
| 388 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
| 388 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
| 389 | 389 | |
| 390 | 390 | // If we are retrieving the invoice from the cart... |
| 391 | - if ( $deprecated && empty( $invoice ) ) { |
|
| 391 | + if ($deprecated && empty($invoice)) { |
|
| 392 | 392 | $invoice = (int) getpaid_get_current_invoice_id(); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | // Retrieve the invoice. |
| 396 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 396 | + $invoice = new WPInv_Invoice($invoice); |
|
| 397 | 397 | |
| 398 | 398 | // Check if it exists. |
| 399 | - if ( $invoice->get_id() != 0 ) { |
|
| 399 | + if ($invoice->get_id() != 0) { |
|
| 400 | 400 | return $invoice; |
| 401 | 401 | } |
| 402 | 402 | |
@@ -409,15 +409,15 @@ discard block |
||
| 409 | 409 | * @param array $args Args to search for. |
| 410 | 410 | * @return WPInv_Invoice[]|int[]|object |
| 411 | 411 | */ |
| 412 | -function wpinv_get_invoices( $args ) { |
|
| 412 | +function wpinv_get_invoices($args) { |
|
| 413 | 413 | |
| 414 | 414 | // Prepare args. |
| 415 | 415 | $args = wp_parse_args( |
| 416 | 416 | $args, |
| 417 | 417 | array( |
| 418 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 418 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 419 | 419 | 'type' => 'wpi_invoice', |
| 420 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 420 | + 'limit' => get_option('posts_per_page'), |
|
| 421 | 421 | 'return' => 'objects', |
| 422 | 422 | ) |
| 423 | 423 | ); |
@@ -435,24 +435,24 @@ discard block |
||
| 435 | 435 | 'post__in' => 'include', |
| 436 | 436 | ); |
| 437 | 437 | |
| 438 | - foreach ( $map_legacy as $to => $from ) { |
|
| 439 | - if ( isset( $args[ $from ] ) ) { |
|
| 440 | - $args[ $to ] = $args[ $from ]; |
|
| 441 | - unset( $args[ $from ] ); |
|
| 438 | + foreach ($map_legacy as $to => $from) { |
|
| 439 | + if (isset($args[$from])) { |
|
| 440 | + $args[$to] = $args[$from]; |
|
| 441 | + unset($args[$from]); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | // Backwards compatibility. |
| 446 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
| 446 | + if (!empty($args['email']) && empty($args['user'])) { |
|
| 447 | 447 | $args['user'] = $args['email']; |
| 448 | - unset( $args['email'] ); |
|
| 448 | + unset($args['email']); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | // Handle cases where the user is set as an email. |
| 452 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
| 453 | - $user = get_user_by( 'email', $args['user'] ); |
|
| 452 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
| 453 | + $user = get_user_by('email', $args['user']); |
|
| 454 | 454 | |
| 455 | - if ( $user ) { |
|
| 455 | + if ($user) { |
|
| 456 | 456 | $args['author'] = $user->user_email; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -463,31 +463,31 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // Show all posts. |
| 465 | 465 | $paginate = true; |
| 466 | - if ( isset( $args['paginate'] ) ) { |
|
| 466 | + if (isset($args['paginate'])) { |
|
| 467 | 467 | |
| 468 | 468 | $paginate = $args['paginate']; |
| 469 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
| 470 | - unset( $args['paginate'] ); |
|
| 469 | + $args['no_found_rows'] = empty($args['paginate']); |
|
| 470 | + unset($args['paginate']); |
|
| 471 | 471 | |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | // Whether to return objects or fields. |
| 475 | 475 | $return = $args['return']; |
| 476 | - unset( $args['return'] ); |
|
| 476 | + unset($args['return']); |
|
| 477 | 477 | |
| 478 | 478 | // Get invoices. |
| 479 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
| 479 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
| 480 | 480 | |
| 481 | 481 | // Prepare the results. |
| 482 | - if ( 'objects' === $return ) { |
|
| 483 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 484 | - } elseif ( 'self' === $return ) { |
|
| 482 | + if ('objects' === $return) { |
|
| 483 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 484 | + } elseif ('self' === $return) { |
|
| 485 | 485 | return $invoices; |
| 486 | 486 | } else { |
| 487 | 487 | $results = $invoices->posts; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if ( $paginate ) { |
|
| 490 | + if ($paginate) { |
|
| 491 | 491 | return (object) array( |
| 492 | 492 | 'invoices' => $results, |
| 493 | 493 | 'total' => $invoices->found_posts, |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | * @param string $transaction_id The transaction id to check. |
| 506 | 506 | * @return int Invoice id on success or 0 on failure |
| 507 | 507 | */ |
| 508 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
| 509 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
| 508 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
| 509 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | * @param string $invoice_number The invoice number to check. |
| 516 | 516 | * @return int Invoice id on success or 0 on failure |
| 517 | 517 | */ |
| 518 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
| 519 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
| 518 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
| 519 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
| 525 | 525 | * @param string $invoice_key The invoice key to check. |
| 526 | 526 | * @return int Invoice id on success or 0 on failure |
| 527 | 527 | */ |
| 528 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
| 529 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
| 528 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
| 529 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -536,19 +536,19 @@ discard block |
||
| 536 | 536 | * @param string $type Optionally filter by type i.e customer|system |
| 537 | 537 | * @return array|null |
| 538 | 538 | */ |
| 539 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
| 539 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
| 540 | 540 | |
| 541 | 541 | // Prepare the invoice. |
| 542 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 543 | - if ( empty( $invoice ) ) { |
|
| 542 | + $invoice = wpinv_get_invoice($invoice); |
|
| 543 | + if (empty($invoice)) { |
|
| 544 | 544 | return NULL; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | // Fetch notes. |
| 548 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
| 548 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
| 549 | 549 | |
| 550 | 550 | // Filter the notes. |
| 551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
| 551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -556,10 +556,10 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @param string $post_type |
| 558 | 558 | */ |
| 559 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
| 559 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
| 560 | 560 | |
| 561 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
| 562 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
| 561 | + $label = getpaid_get_post_type_label($post_type, false); |
|
| 562 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
| 563 | 563 | $columns = array( |
| 564 | 564 | |
| 565 | 565 | 'invoice-number' => array( |
@@ -568,22 +568,22 @@ discard block |
||
| 568 | 568 | ), |
| 569 | 569 | |
| 570 | 570 | 'created-date' => array( |
| 571 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
| 571 | + 'title' => __('Created Date', 'invoicing'), |
|
| 572 | 572 | 'class' => 'text-left' |
| 573 | 573 | ), |
| 574 | 574 | |
| 575 | 575 | 'payment-date' => array( |
| 576 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
| 576 | + 'title' => __('Payment Date', 'invoicing'), |
|
| 577 | 577 | 'class' => 'text-left' |
| 578 | 578 | ), |
| 579 | 579 | |
| 580 | 580 | 'invoice-status' => array( |
| 581 | - 'title' => __( 'Status', 'invoicing' ), |
|
| 581 | + 'title' => __('Status', 'invoicing'), |
|
| 582 | 582 | 'class' => 'text-center' |
| 583 | 583 | ), |
| 584 | 584 | |
| 585 | 585 | 'invoice-total' => array( |
| 586 | - 'title' => __( 'Total', 'invoicing' ), |
|
| 586 | + 'title' => __('Total', 'invoicing'), |
|
| 587 | 587 | 'class' => 'text-right' |
| 588 | 588 | ), |
| 589 | 589 | |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | ); |
| 596 | 596 | |
| 597 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
| 597 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -604,59 +604,59 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | // Find the invoice. |
| 606 | 606 | $invoice_id = getpaid_get_current_invoice_id(); |
| 607 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 607 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 608 | 608 | |
| 609 | 609 | // Abort if non was found. |
| 610 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
| 610 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
| 611 | 611 | |
| 612 | 612 | return aui()->alert( |
| 613 | 613 | array( |
| 614 | 614 | 'type' => 'warning', |
| 615 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
| 615 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
| 616 | 616 | ) |
| 617 | 617 | ); |
| 618 | 618 | |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Can the user view this invoice? |
| 622 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
| 622 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
| 623 | 623 | |
| 624 | 624 | return aui()->alert( |
| 625 | 625 | array( |
| 626 | 626 | 'type' => 'warning', |
| 627 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
| 627 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
| 628 | 628 | ) |
| 629 | 629 | ); |
| 630 | 630 | |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // Load the template. |
| 634 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
| 634 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
| 635 | 635 | |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Displays the invoice history. |
| 640 | 640 | */ |
| 641 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
| 641 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
| 642 | 642 | |
| 643 | 643 | // Ensure that we have a user id. |
| 644 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 644 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 645 | 645 | $user_id = get_current_user_id(); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - $label = getpaid_get_post_type_label( $post_type ); |
|
| 649 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
| 648 | + $label = getpaid_get_post_type_label($post_type); |
|
| 649 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
| 650 | 650 | |
| 651 | 651 | // View user id. |
| 652 | - if ( empty( $user_id ) ) { |
|
| 652 | + if (empty($user_id)) { |
|
| 653 | 653 | |
| 654 | 654 | return aui()->alert( |
| 655 | 655 | array( |
| 656 | 656 | 'type' => 'warning', |
| 657 | 657 | 'content' => sprintf( |
| 658 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
| 659 | - strtolower( $label ) |
|
| 658 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
| 659 | + strtolower($label) |
|
| 660 | 660 | ) |
| 661 | 661 | ) |
| 662 | 662 | ); |
@@ -667,23 +667,23 @@ discard block |
||
| 667 | 667 | $invoices = wpinv_get_invoices( |
| 668 | 668 | |
| 669 | 669 | array( |
| 670 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 670 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 671 | 671 | 'user' => $user_id, |
| 672 | 672 | 'paginate' => true, |
| 673 | 673 | 'type' => $post_type, |
| 674 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
| 674 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
| 675 | 675 | ) |
| 676 | 676 | |
| 677 | 677 | ); |
| 678 | 678 | |
| 679 | - if ( empty( $invoices->total ) ) { |
|
| 679 | + if (empty($invoices->total)) { |
|
| 680 | 680 | |
| 681 | 681 | return aui()->alert( |
| 682 | 682 | array( |
| 683 | 683 | 'type' => 'info', |
| 684 | 684 | 'content' => sprintf( |
| 685 | - __( 'No %s found.', 'invoicing' ), |
|
| 686 | - strtolower( $label ) |
|
| 685 | + __('No %s found.', 'invoicing'), |
|
| 686 | + strtolower($label) |
|
| 687 | 687 | ) |
| 688 | 688 | ) |
| 689 | 689 | ); |
@@ -691,38 +691,38 @@ discard block |
||
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | // Load the template. |
| 694 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
| 694 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
| 695 | 695 | |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | 699 | * Formats an invoice number given an invoice type. |
| 700 | 700 | */ |
| 701 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
| 701 | +function wpinv_format_invoice_number($number, $type = '') { |
|
| 702 | 702 | |
| 703 | 703 | // Allow other plugins to overide this. |
| 704 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
| 705 | - if ( null !== $check ) { |
|
| 704 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
| 705 | + if (null !== $check) { |
|
| 706 | 706 | return $check; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Ensure that we have a numeric number. |
| 710 | - if ( ! is_numeric( $number ) ) { |
|
| 710 | + if (!is_numeric($number)) { |
|
| 711 | 711 | return $number; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | // Format the number. |
| 715 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) ); |
|
| 716 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
| 717 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
| 718 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
| 719 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
| 720 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
| 715 | + $padd = absint((int) wpinv_get_option('invoice_number_padd', 5)); |
|
| 716 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
| 717 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
| 718 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
| 719 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
| 720 | + $formatted_number = zeroise(absint($number), $padd); |
|
| 721 | 721 | |
| 722 | 722 | // Add the prefix and post fix. |
| 723 | 723 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 724 | 724 | |
| 725 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 725 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
@@ -731,58 +731,58 @@ discard block |
||
| 731 | 731 | * @param string $type. |
| 732 | 732 | * @return int|null|bool |
| 733 | 733 | */ |
| 734 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
| 734 | +function wpinv_get_next_invoice_number($type = '') { |
|
| 735 | 735 | |
| 736 | 736 | // Allow plugins to overide this. |
| 737 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
| 738 | - if ( null !== $check ) { |
|
| 737 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
| 738 | + if (null !== $check) { |
|
| 739 | 739 | return $check; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | // Ensure sequential invoice numbers is active. |
| 743 | - if ( ! wpinv_sequential_number_active() ) { |
|
| 743 | + if (!wpinv_sequential_number_active()) { |
|
| 744 | 744 | return false; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | // Retrieve the current number and the start number. |
| 748 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
| 749 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
| 748 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
| 749 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
| 750 | 750 | |
| 751 | 751 | // Ensure that we are starting at a positive integer. |
| 752 | - $start = max( $start, 1 ); |
|
| 752 | + $start = max($start, 1); |
|
| 753 | 753 | |
| 754 | 754 | // If this is the first invoice, use the start number. |
| 755 | - $number = max( $start, $number ); |
|
| 755 | + $number = max($start, $number); |
|
| 756 | 756 | |
| 757 | 757 | // Format the invoice number. |
| 758 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
| 758 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
| 759 | 759 | |
| 760 | 760 | // Ensure that this number is unique. |
| 761 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
| 761 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
| 762 | 762 | |
| 763 | 763 | // We found a match. Nice. |
| 764 | - if ( empty( $invoice_id ) ) { |
|
| 765 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 766 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
| 764 | + if (empty($invoice_id)) { |
|
| 765 | + update_option('wpinv_last_invoice_number', $number); |
|
| 766 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
| 770 | - return wpinv_get_next_invoice_number( $type ); |
|
| 769 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
| 770 | + return wpinv_get_next_invoice_number($type); |
|
| 771 | 771 | |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | /** |
| 775 | 775 | * The prefix used for invoice paths. |
| 776 | 776 | */ |
| 777 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
| 778 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
| 777 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
| 778 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | -function wpinv_generate_post_name( $post_ID ) { |
|
| 782 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
| 783 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
| 781 | +function wpinv_generate_post_name($post_ID) { |
|
| 782 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
| 783 | + $post_name = sanitize_title($prefix . $post_ID); |
|
| 784 | 784 | |
| 785 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
| 785 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | /** |
@@ -790,8 +790,8 @@ discard block |
||
| 790 | 790 | * |
| 791 | 791 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 792 | 792 | */ |
| 793 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
| 794 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 793 | +function wpinv_is_invoice_viewed($invoice) { |
|
| 794 | + $invoice = new WPInv_Invoice($invoice); |
|
| 795 | 795 | return (bool) $invoice->get_is_viewed(); |
| 796 | 796 | } |
| 797 | 797 | |
@@ -800,17 +800,17 @@ discard block |
||
| 800 | 800 | * |
| 801 | 801 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 802 | 802 | */ |
| 803 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
| 804 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 803 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
| 804 | + $invoice = new WPInv_Invoice($invoice); |
|
| 805 | 805 | |
| 806 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
| 807 | - $invoice->set_is_viewed( true ); |
|
| 806 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
| 807 | + $invoice->set_is_viewed(true); |
|
| 808 | 808 | $invoice->save(); |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | } |
| 812 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 813 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 812 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 813 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | 816 | * Processes an invoice refund. |
@@ -819,27 +819,27 @@ discard block |
||
| 819 | 819 | * @param array $status_transition |
| 820 | 820 | * @todo: descrease customer/store earnings |
| 821 | 821 | */ |
| 822 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
| 822 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
| 823 | 823 | |
| 824 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 824 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 825 | 825 | return; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | $discount_code = $invoice->get_discount_code(); |
| 829 | - if ( ! empty( $discount_code ) ) { |
|
| 830 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 829 | + if (!empty($discount_code)) { |
|
| 830 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 831 | 831 | |
| 832 | - if ( $discount->exists() ) { |
|
| 832 | + if ($discount->exists()) { |
|
| 833 | 833 | $discount->increase_usage( -1 ); |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 839 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 840 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 838 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
| 839 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
| 840 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
| 841 | 841 | } |
| 842 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
| 842 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
| 843 | 843 | |
| 844 | 844 | |
| 845 | 845 | /** |
@@ -847,49 +847,49 @@ discard block |
||
| 847 | 847 | * |
| 848 | 848 | * @param int $invoice_id |
| 849 | 849 | */ |
| 850 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
| 850 | +function getpaid_process_invoice_payment($invoice_id) { |
|
| 851 | 851 | |
| 852 | 852 | // Fetch the invoice. |
| 853 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 853 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 854 | 854 | |
| 855 | 855 | // We only want to do this once. |
| 856 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
| 856 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
| 857 | 857 | return; |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
| 860 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
| 861 | 861 | |
| 862 | 862 | // Fires when processing a payment. |
| 863 | - do_action( 'getpaid_process_payment', $invoice ); |
|
| 863 | + do_action('getpaid_process_payment', $invoice); |
|
| 864 | 864 | |
| 865 | 865 | // Fire an action for each invoice item. |
| 866 | - foreach( $invoice->get_items() as $item ) { |
|
| 867 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
| 866 | + foreach ($invoice->get_items() as $item) { |
|
| 867 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | // Increase discount usage. |
| 871 | 871 | $discount_code = $invoice->get_discount_code(); |
| 872 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
| 873 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 872 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
| 873 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 874 | 874 | |
| 875 | - if ( $discount->exists() ) { |
|
| 875 | + if ($discount->exists()) { |
|
| 876 | 876 | $discount->increase_usage(); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | // Record reverse vat. |
| 882 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
| 882 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
| 883 | 883 | |
| 884 | 884 | $taxes = $invoice->get_total_tax(); |
| 885 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
| 886 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
| 885 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
| 886 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | } |
| 892 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
| 892 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
| 893 | 893 | |
| 894 | 894 | /** |
| 895 | 895 | * Returns an array of invoice item columns |
@@ -897,13 +897,13 @@ discard block |
||
| 897 | 897 | * @param int|WPInv_Invoice $invoice |
| 898 | 898 | * @return array |
| 899 | 899 | */ |
| 900 | -function getpaid_invoice_item_columns( $invoice ) { |
|
| 900 | +function getpaid_invoice_item_columns($invoice) { |
|
| 901 | 901 | |
| 902 | 902 | // Prepare the invoice. |
| 903 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 903 | + $invoice = new WPInv_Invoice($invoice); |
|
| 904 | 904 | |
| 905 | 905 | // Abort if there is no invoice. |
| 906 | - if ( 0 == $invoice->get_id() ) { |
|
| 906 | + if (0 == $invoice->get_id()) { |
|
| 907 | 907 | return array(); |
| 908 | 908 | } |
| 909 | 909 | |
@@ -911,47 +911,47 @@ discard block |
||
| 911 | 911 | $columns = apply_filters( |
| 912 | 912 | 'getpaid_invoice_item_columns', |
| 913 | 913 | array( |
| 914 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 915 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 916 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 917 | - 'subtotal' => __( 'Item Subtotal', 'invoicing' ), |
|
| 914 | + 'name' => __('Item', 'invoicing'), |
|
| 915 | + 'price' => __('Price', 'invoicing'), |
|
| 916 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 917 | + 'subtotal' => __('Item Subtotal', 'invoicing'), |
|
| 918 | 918 | ), |
| 919 | 919 | $invoice |
| 920 | 920 | ); |
| 921 | 921 | |
| 922 | 922 | // Quantities. |
| 923 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
| 923 | + if (isset($columns['quantity'])) { |
|
| 924 | 924 | |
| 925 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 926 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
| 925 | + if ('hours' == $invoice->get_template()) { |
|
| 926 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
| 930 | - unset( $columns[ 'quantity' ] ); |
|
| 929 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
| 930 | + unset($columns['quantity']); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | // Price. |
| 937 | - if ( isset( $columns[ 'price' ] ) ) { |
|
| 937 | + if (isset($columns['price'])) { |
|
| 938 | 938 | |
| 939 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 940 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
| 939 | + if ('amount' == $invoice->get_template()) { |
|
| 940 | + $columns['price'] = __('Amount', 'invoicing'); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 944 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
| 943 | + if ('hours' == $invoice->get_template()) { |
|
| 944 | + $columns['price'] = __('Rate', 'invoicing'); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | |
| 950 | 950 | // Sub total. |
| 951 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
| 951 | + if (isset($columns['subtotal'])) { |
|
| 952 | 952 | |
| 953 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 954 | - unset( $columns[ 'subtotal' ] ); |
|
| 953 | + if ('amount' == $invoice->get_template()) { |
|
| 954 | + unset($columns['subtotal']); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | } |
@@ -965,38 +965,38 @@ discard block |
||
| 965 | 965 | * @param int|WPInv_Invoice $invoice |
| 966 | 966 | * @return array |
| 967 | 967 | */ |
| 968 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
| 968 | +function getpaid_invoice_totals_rows($invoice) { |
|
| 969 | 969 | |
| 970 | 970 | // Prepare the invoice. |
| 971 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 971 | + $invoice = new WPInv_Invoice($invoice); |
|
| 972 | 972 | |
| 973 | 973 | // Abort if there is no invoice. |
| 974 | - if ( 0 == $invoice->get_id() ) { |
|
| 974 | + if (0 == $invoice->get_id()) { |
|
| 975 | 975 | return array(); |
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | $totals = apply_filters( |
| 979 | 979 | 'getpaid_invoice_totals_rows', |
| 980 | 980 | array( |
| 981 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 982 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 983 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
| 984 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 985 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 981 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 982 | + 'tax' => __('Tax', 'invoicing'), |
|
| 983 | + 'fee' => __('Fee', 'invoicing'), |
|
| 984 | + 'discount' => __('Discount', 'invoicing'), |
|
| 985 | + 'total' => __('Total', 'invoicing'), |
|
| 986 | 986 | ), |
| 987 | 987 | $invoice |
| 988 | 988 | ); |
| 989 | 989 | |
| 990 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
| 991 | - unset( $totals['tax'] ); |
|
| 990 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
| 991 | + unset($totals['tax']); |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) { |
|
| 995 | - unset( $totals['fee'] ); |
|
| 994 | + if (0 == $invoice->get_total_fees() && isset($totals['fee'])) { |
|
| 995 | + unset($totals['fee']); |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | - if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) { |
|
| 999 | - unset( $totals['discount'] ); |
|
| 998 | + if (0 == $invoice->get_total_discount() && isset($totals['discount'])) { |
|
| 999 | + unset($totals['discount']); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | return $totals; |
@@ -1007,47 +1007,47 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @param WPInv_Invoice $invoice |
| 1009 | 1009 | */ |
| 1010 | -function getpaid_new_invoice( $invoice ) { |
|
| 1010 | +function getpaid_new_invoice($invoice) { |
|
| 1011 | 1011 | |
| 1012 | - if ( ! $invoice->get_status() ) { |
|
| 1012 | + if (!$invoice->get_status()) { |
|
| 1013 | 1013 | return; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | // Add an invoice created note. |
| 1017 | 1017 | $invoice->add_note( |
| 1018 | 1018 | sprintf( |
| 1019 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
| 1020 | - ucfirst( $invoice->get_invoice_quote_type() ), |
|
| 1021 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
| 1019 | + __('%s created with the status "%s".', 'invoicing'), |
|
| 1020 | + ucfirst($invoice->get_invoice_quote_type()), |
|
| 1021 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
| 1022 | 1022 | ) |
| 1023 | 1023 | ); |
| 1024 | 1024 | |
| 1025 | 1025 | } |
| 1026 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
| 1026 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
| 1027 | 1027 | |
| 1028 | 1028 | /** |
| 1029 | 1029 | * This function updates invoice caches. |
| 1030 | 1030 | * |
| 1031 | 1031 | * @param WPInv_Invoice $invoice |
| 1032 | 1032 | */ |
| 1033 | -function getpaid_update_invoice_caches( $invoice ) { |
|
| 1033 | +function getpaid_update_invoice_caches($invoice) { |
|
| 1034 | 1034 | |
| 1035 | 1035 | // Cache invoice number. |
| 1036 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
| 1036 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
| 1037 | 1037 | |
| 1038 | 1038 | // Cache invoice key. |
| 1039 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
| 1039 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
| 1040 | 1040 | |
| 1041 | 1041 | // (Maybe) cache transaction id. |
| 1042 | 1042 | $transaction_id = $invoice->get_transaction_id(); |
| 1043 | 1043 | |
| 1044 | - if ( ! empty( $transaction_id ) ) { |
|
| 1045 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
| 1044 | + if (!empty($transaction_id)) { |
|
| 1045 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | } |
| 1049 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1050 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1049 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1050 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1051 | 1051 | |
| 1052 | 1052 | /** |
| 1053 | 1053 | * Duplicates an invoice. |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
| 1058 | 1058 | * @return WPInv_Invoice The new invoice. |
| 1059 | 1059 | */ |
| 1060 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
| 1060 | +function getpaid_duplicate_invoice($old_invoice) { |
|
| 1061 | 1061 | |
| 1062 | 1062 | // Create the new invoice. |
| 1063 | 1063 | $invoice = new WPInv_Invoice(); |
@@ -1118,123 +1118,123 @@ discard block |
||
| 1118 | 1118 | * @param WPInv_Invoice $invoice |
| 1119 | 1119 | * @return array |
| 1120 | 1120 | */ |
| 1121 | -function getpaid_get_invoice_meta( $invoice ) { |
|
| 1121 | +function getpaid_get_invoice_meta($invoice) { |
|
| 1122 | 1122 | |
| 1123 | 1123 | // Load the invoice meta. |
| 1124 | 1124 | $meta = array( |
| 1125 | 1125 | |
| 1126 | 1126 | 'number' => array( |
| 1127 | 1127 | 'label' => sprintf( |
| 1128 | - __( '%s Number', 'invoicing' ), |
|
| 1129 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1128 | + __('%s Number', 'invoicing'), |
|
| 1129 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1130 | 1130 | ), |
| 1131 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
| 1131 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
| 1132 | 1132 | ), |
| 1133 | 1133 | |
| 1134 | 1134 | 'status' => array( |
| 1135 | 1135 | 'label' => sprintf( |
| 1136 | - __( '%s Status', 'invoicing' ), |
|
| 1137 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1136 | + __('%s Status', 'invoicing'), |
|
| 1137 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1138 | 1138 | ), |
| 1139 | 1139 | 'value' => $invoice->get_status_label_html(), |
| 1140 | 1140 | ), |
| 1141 | 1141 | |
| 1142 | 1142 | 'date' => array( |
| 1143 | 1143 | 'label' => sprintf( |
| 1144 | - __( '%s Date', 'invoicing' ), |
|
| 1145 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1144 | + __('%s Date', 'invoicing'), |
|
| 1145 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1146 | 1146 | ), |
| 1147 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
| 1147 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
| 1148 | 1148 | ), |
| 1149 | 1149 | |
| 1150 | 1150 | 'date_paid' => array( |
| 1151 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
| 1152 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
| 1151 | + 'label' => __('Paid On', 'invoicing'), |
|
| 1152 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
| 1153 | 1153 | ), |
| 1154 | 1154 | |
| 1155 | 1155 | 'gateway' => array( |
| 1156 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
| 1157 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
| 1156 | + 'label' => __('Payment Method', 'invoicing'), |
|
| 1157 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
| 1158 | 1158 | ), |
| 1159 | 1159 | |
| 1160 | 1160 | 'transaction_id' => array( |
| 1161 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
| 1162 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
| 1161 | + 'label' => __('Transaction ID', 'invoicing'), |
|
| 1162 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
| 1163 | 1163 | ), |
| 1164 | 1164 | |
| 1165 | 1165 | 'due_date' => array( |
| 1166 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
| 1167 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
| 1166 | + 'label' => __('Due Date', 'invoicing'), |
|
| 1167 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
| 1168 | 1168 | ), |
| 1169 | 1169 | |
| 1170 | 1170 | 'vat_number' => array( |
| 1171 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 1172 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
| 1171 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 1172 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
| 1173 | 1173 | ), |
| 1174 | 1174 | |
| 1175 | 1175 | ); |
| 1176 | 1176 | |
| 1177 | 1177 | // If it is not paid, remove the date of payment. |
| 1178 | - if ( ! $invoice->is_paid() ) { |
|
| 1179 | - unset( $meta[ 'date_paid' ] ); |
|
| 1180 | - unset( $meta[ 'transaction_id' ] ); |
|
| 1178 | + if (!$invoice->is_paid()) { |
|
| 1179 | + unset($meta['date_paid']); |
|
| 1180 | + unset($meta['transaction_id']); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
| 1184 | - unset( $meta[ 'gateway' ] ); |
|
| 1183 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
| 1184 | + unset($meta['gateway']); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | 1187 | // Only display the due date if due dates are enabled. |
| 1188 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
| 1189 | - unset( $meta[ 'due_date' ] ); |
|
| 1188 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
| 1189 | + unset($meta['due_date']); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | 1192 | // Only display the vat number if taxes are enabled. |
| 1193 | - if ( ! wpinv_use_taxes() ) { |
|
| 1194 | - unset( $meta[ 'vat_number' ] ); |
|
| 1193 | + if (!wpinv_use_taxes()) { |
|
| 1194 | + unset($meta['vat_number']); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | - if ( $invoice->is_recurring() ) { |
|
| 1197 | + if ($invoice->is_recurring()) { |
|
| 1198 | 1198 | |
| 1199 | 1199 | // Link to the parent invoice. |
| 1200 | - if ( $invoice->is_renewal() ) { |
|
| 1200 | + if ($invoice->is_renewal()) { |
|
| 1201 | 1201 | |
| 1202 | - $meta[ 'parent' ] = array( |
|
| 1202 | + $meta['parent'] = array( |
|
| 1203 | 1203 | |
| 1204 | 1204 | 'label' => sprintf( |
| 1205 | - __( 'Parent %s', 'invoicing' ), |
|
| 1206 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1205 | + __('Parent %s', 'invoicing'), |
|
| 1206 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1207 | 1207 | ), |
| 1208 | 1208 | |
| 1209 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
| 1209 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
| 1210 | 1210 | |
| 1211 | 1211 | ); |
| 1212 | 1212 | |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 1215 | + $subscription = wpinv_get_subscription($invoice); |
|
| 1216 | 1216 | |
| 1217 | - if ( ! empty ( $subscription ) ) { |
|
| 1217 | + if (!empty ($subscription)) { |
|
| 1218 | 1218 | |
| 1219 | 1219 | // Display the renewal date. |
| 1220 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
| 1220 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
| 1221 | 1221 | |
| 1222 | - $meta[ 'renewal_date' ] = array( |
|
| 1222 | + $meta['renewal_date'] = array( |
|
| 1223 | 1223 | |
| 1224 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 1225 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
| 1224 | + 'label' => __('Renews On', 'invoicing'), |
|
| 1225 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
| 1226 | 1226 | |
| 1227 | 1227 | ); |
| 1228 | 1228 | |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | - if ( $invoice->is_parent() ) { |
|
| 1231 | + if ($invoice->is_parent()) { |
|
| 1232 | 1232 | |
| 1233 | 1233 | // Display the recurring amount. |
| 1234 | - $meta[ 'recurring_total' ] = array( |
|
| 1234 | + $meta['recurring_total'] = array( |
|
| 1235 | 1235 | |
| 1236 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
| 1237 | - 'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ), |
|
| 1236 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
| 1237 | + 'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()), |
|
| 1238 | 1238 | |
| 1239 | 1239 | ); |
| 1240 | 1240 | |
@@ -1244,15 +1244,15 @@ discard block |
||
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | // Add the invoice total to the meta. |
| 1247 | - $meta[ 'invoice_total' ] = array( |
|
| 1247 | + $meta['invoice_total'] = array( |
|
| 1248 | 1248 | |
| 1249 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
| 1250 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
| 1249 | + 'label' => __('Total Amount', 'invoicing'), |
|
| 1250 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
| 1251 | 1251 | |
| 1252 | 1252 | ); |
| 1253 | 1253 | |
| 1254 | 1254 | // Provide a way for third party plugins to filter the meta. |
| 1255 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
| 1255 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
| 1256 | 1256 | |
| 1257 | 1257 | return $meta; |
| 1258 | 1258 | |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.1.2' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.1.2' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | * @package GetPaid |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -defined( 'ABSPATH' ) || exit; |
|
| 18 | +defined('ABSPATH') || exit; |
|
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
| 22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
| 26 | - define( 'WPINV_VERSION', '2.1.2' ); |
|
| 25 | +if (!defined('WPINV_VERSION')) { |
|
| 26 | + define('WPINV_VERSION', '2.1.2'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
| 31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function getpaid() { |
| 41 | 41 | |
| 42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
| 42 | + if (empty($GLOBALS['invoicing'])) { |
|
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @since 2.0.8 |
| 53 | 53 | */ |
| 54 | 54 | function getpaid_deactivation_hook() { |
| 55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
| 55 | + update_option('wpinv_flush_permalinks', 1); |
|
| 56 | 56 | } |
| 57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
| 57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Kickstart the plugin. |
| 67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
| 67 | +add_action('plugins_loaded', 'getpaid', -100); |
|