@@ -44,25 +44,25 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | |
| 58 | - ob_start(); |
|
| 58 | + ob_start(); |
|
| 59 | 59 | |
| 60 | - do_action( 'wpinv_success_content_before' ); |
|
| 61 | - echo wpinv_payment_receipt( $args ); |
|
| 62 | - do_action( 'wpinv_success_content_after' ); |
|
| 60 | + do_action( 'wpinv_success_content_before' ); |
|
| 61 | + echo wpinv_payment_receipt( $args ); |
|
| 62 | + do_action( 'wpinv_success_content_after' ); |
|
| 63 | 63 | |
| 64 | - $output = ob_get_clean(); |
|
| 65 | - return trim($output); |
|
| 64 | + $output = ob_get_clean(); |
|
| 65 | + return trim($output); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','receipt']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_receipt', |
| 25 | - 'name' => __('Invoicing > Invoice Receipt','invoicing'), |
|
| 25 | + 'name' => __('Invoicing > Invoice Receipt', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-receipt-class wpi-g', |
| 28 | - 'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | |
| 58 | 58 | ob_start(); |
| 59 | 59 | |
| 60 | - do_action( 'wpinv_success_content_before' ); |
|
| 61 | - echo wpinv_payment_receipt( $args ); |
|
| 62 | - do_action( 'wpinv_success_content_after' ); |
|
| 60 | + do_action('wpinv_success_content_before'); |
|
| 61 | + echo wpinv_payment_receipt($args); |
|
| 62 | + do_action('wpinv_success_content_after'); |
|
| 63 | 63 | |
| 64 | 64 | $output = ob_get_clean(); |
| 65 | 65 | return trim($output); |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
| 140 | 140 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
| 141 | 141 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
| 142 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 143 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 144 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 145 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 146 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 147 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 142 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 143 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 144 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 145 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 146 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 147 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 148 | 148 | |
| 149 | 149 | if ( !class_exists( 'WPInv_EUVat' ) ) { |
| 150 | 150 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
@@ -420,16 +420,16 @@ discard block |
||
| 420 | 420 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - /** |
|
| 424 | - * Register widgets |
|
| 425 | - * |
|
| 426 | - */ |
|
| 427 | - public function register_widgets() { |
|
| 428 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 429 | - register_widget( "WPInv_History_Widget" ); |
|
| 430 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 431 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 432 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 433 | - register_widget( "WPInv_Messages_Widget" ); |
|
| 434 | - } |
|
| 423 | + /** |
|
| 424 | + * Register widgets |
|
| 425 | + * |
|
| 426 | + */ |
|
| 427 | + public function register_widgets() { |
|
| 428 | + register_widget( "WPInv_Checkout_Widget" ); |
|
| 429 | + register_widget( "WPInv_History_Widget" ); |
|
| 430 | + register_widget( "WPInv_Receipt_Widget" ); |
|
| 431 | + register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 432 | + register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 433 | + register_widget( "WPInv_Messages_Widget" ); |
|
| 434 | + } |
|
| 435 | 435 | } |
| 436 | 436 | \ No newline at end of file |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -32,33 +32,33 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function define_constants() { |
| 35 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 36 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 35 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 36 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | private function actions() { |
| 40 | 40 | /* Internationalize the text strings used. */ |
| 41 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 41 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 42 | 42 | |
| 43 | 43 | /* Perform actions on admin initialization. */ |
| 44 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
| 45 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
| 46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
| 44 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
| 45 | + add_action('init', array(&$this, 'init'), 3); |
|
| 46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
| 47 | 47 | |
| 48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 48 | + if (class_exists('BuddyPress')) { |
|
| 49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 53 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 53 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
| 54 | 54 | |
| 55 | - if ( is_admin() ) { |
|
| 56 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 57 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 58 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
| 55 | + if (is_admin()) { |
|
| 56 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 57 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 58 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 61 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,28 +68,28 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 70 | 70 | */ |
| 71 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 71 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 72 | 72 | |
| 73 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 73 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Maybe show the AyeCode Connect Notice. |
| 78 | 78 | */ |
| 79 | - public function init_ayecode_connect_helper(){ |
|
| 79 | + public function init_ayecode_connect_helper() { |
|
| 80 | 80 | // AyeCode Connect notice |
| 81 | - if ( is_admin() ){ |
|
| 81 | + if (is_admin()) { |
|
| 82 | 82 | // set the strings so they can be translated |
| 83 | 83 | $strings = array( |
| 84 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 85 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 86 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 87 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 88 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 89 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 90 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 84 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 85 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 86 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 87 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 88 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 89 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 90 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 91 | 91 | ); |
| 92 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
| 92 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | /* Internationalize the text strings used. */ |
| 98 | 98 | $this->load_textdomain(); |
| 99 | 99 | |
| 100 | - do_action( 'wpinv_loaded' ); |
|
| 100 | + do_action('wpinv_loaded'); |
|
| 101 | 101 | |
| 102 | 102 | // Fix oxygen page builder conflict |
| 103 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 103 | + if (function_exists('ct_css_output')) { |
|
| 104 | 104 | wpinv_oxygen_fix_conflict(); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -110,230 +110,230 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @since 1.0 |
| 112 | 112 | */ |
| 113 | - public function load_textdomain( $locale = NULL ) { |
|
| 114 | - if ( empty( $locale ) ) { |
|
| 115 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 113 | + public function load_textdomain($locale = NULL) { |
|
| 114 | + if (empty($locale)) { |
|
| 115 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 118 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 119 | 119 | |
| 120 | - unload_textdomain( 'invoicing' ); |
|
| 121 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 122 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 120 | + unload_textdomain('invoicing'); |
|
| 121 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 122 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Define language constants. |
| 126 | 126 | */ |
| 127 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public function includes() { |
| 131 | 131 | global $wpinv_options; |
| 132 | 132 | |
| 133 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 133 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 134 | 134 | $wpinv_options = wpinv_get_settings(); |
| 135 | 135 | |
| 136 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 137 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
| 138 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 139 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 140 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 153 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 155 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 162 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 163 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 165 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
| 166 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
| 168 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 170 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 171 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 172 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 173 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 178 | - |
|
| 179 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
| 180 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 136 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
| 137 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
| 138 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 139 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 140 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 153 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 155 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 162 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
| 163 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
| 164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
| 165 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
| 166 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
| 167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
| 168 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
| 170 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
| 171 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
| 172 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
| 173 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
| 174 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
| 175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
| 176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
| 177 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
| 178 | + |
|
| 179 | + if (!class_exists('WPInv_EUVat')) { |
|
| 180 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 184 | - if ( !empty( $gateways ) ) { |
|
| 185 | - foreach ( $gateways as $gateway ) { |
|
| 186 | - if ( $gateway == 'manual' ) { |
|
| 183 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 184 | + if (!empty($gateways)) { |
|
| 185 | + foreach ($gateways as $gateway) { |
|
| 186 | + if ($gateway == 'manual') { |
|
| 187 | 187 | continue; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 191 | 191 | |
| 192 | - if ( file_exists( $gateway_file ) ) { |
|
| 193 | - require_once( $gateway_file ); |
|
| 192 | + if (file_exists($gateway_file)) { |
|
| 193 | + require_once($gateway_file); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 197 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 198 | 198 | |
| 199 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 200 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 201 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 202 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 199 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 200 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 201 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 202 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 203 | 203 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 204 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 207 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 208 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 210 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 204 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 207 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 208 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
| 210 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 211 | 211 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 212 | 212 | // load the user class only on the users.php page |
| 213 | 213 | global $pagenow; |
| 214 | - if($pagenow=='users.php'){ |
|
| 214 | + if ($pagenow == 'users.php') { |
|
| 215 | 215 | new WPInv_Admin_Users(); |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Register cli commands |
| 220 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 221 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 222 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 220 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 221 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
| 222 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // include css inliner |
| 226 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 227 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 226 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 227 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function init() { |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public function admin_init() { |
| 237 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 237 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | public function activation_redirect() { |
| 241 | 241 | // Bail if no activation redirect |
| 242 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 242 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Delete the redirect transient |
| 247 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 247 | + delete_transient('_wpinv_activation_redirect'); |
|
| 248 | 248 | |
| 249 | 249 | // Bail if activating from network, or bulk |
| 250 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 250 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 251 | 251 | return; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 254 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 255 | 255 | exit; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | public function enqueue_scripts() { |
| 259 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 259 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 260 | 260 | |
| 261 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 262 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 261 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 262 | + wp_enqueue_style('wpinv_front_style'); |
|
| 263 | 263 | |
| 264 | 264 | // Register scripts |
| 265 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 266 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 265 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 266 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
| 267 | 267 | |
| 268 | 268 | $localize = array(); |
| 269 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 270 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 269 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 270 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 271 | 271 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 272 | 272 | $localize['currency_pos'] = wpinv_currency_position(); |
| 273 | 273 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 274 | 274 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 275 | 275 | $localize['decimals'] = wpinv_decimals(); |
| 276 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
| 276 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
| 277 | 277 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 278 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 278 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 279 | 279 | |
| 280 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 280 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 281 | 281 | |
| 282 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 282 | + wp_enqueue_script('jquery-blockui'); |
|
| 283 | 283 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 284 | 284 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 285 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
| 286 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
| 287 | - wp_dequeue_script( 'google-maps-api' ); |
|
| 285 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
| 286 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
| 287 | + wp_dequeue_script('google-maps-api'); |
|
| 288 | 288 | } |
| 289 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
| 290 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
| 289 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
| 290 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 294 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 293 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 294 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 295 | 295 | |
| 296 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 297 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 296 | + wp_enqueue_script('wpinv-front-script'); |
|
| 297 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | public function admin_enqueue_scripts() { |
| 301 | 301 | global $post, $pagenow; |
| 302 | 302 | |
| 303 | 303 | $post_type = wpinv_admin_post_type(); |
| 304 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 305 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
| 304 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 305 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
| 306 | 306 | |
| 307 | 307 | $jquery_ui_css = false; |
| 308 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 308 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 309 | 309 | $jquery_ui_css = true; |
| 310 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
| 310 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
| 311 | 311 | $jquery_ui_css = true; |
| 312 | 312 | } |
| 313 | - if ( $jquery_ui_css ) { |
|
| 314 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 315 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 313 | + if ($jquery_ui_css) { |
|
| 314 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 315 | + wp_enqueue_style('jquery-ui-css'); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 319 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 318 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 319 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 320 | 320 | |
| 321 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 322 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 321 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 322 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 323 | 323 | |
| 324 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
| 325 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 326 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 324 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
| 325 | + if ($page == 'wpinv-subscriptions') { |
|
| 326 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
| 330 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 329 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
| 330 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 334 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 333 | + wp_enqueue_style('wp-color-picker'); |
|
| 334 | + wp_enqueue_script('wp-color-picker'); |
|
| 335 | 335 | |
| 336 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 336 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 337 | 337 | |
| 338 | 338 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 339 | 339 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -344,20 +344,20 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 348 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 347 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 348 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 349 | 349 | |
| 350 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 351 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 350 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 351 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 352 | 352 | |
| 353 | 353 | $localize = array(); |
| 354 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 355 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 356 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 357 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 358 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 359 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 360 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 354 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 355 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 356 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 357 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 358 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 359 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 360 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 361 | 361 | $localize['tax'] = wpinv_tax_amount(); |
| 362 | 362 | $localize['discount'] = wpinv_discount_amount(); |
| 363 | 363 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -365,69 +365,69 @@ discard block |
||
| 365 | 365 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 366 | 366 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 367 | 367 | $localize['decimals'] = wpinv_decimals(); |
| 368 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 369 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 370 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 371 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 372 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 373 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 374 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 375 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
| 376 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 377 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
| 378 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 379 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
| 380 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
| 381 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
| 382 | - |
|
| 383 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 384 | - |
|
| 385 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 386 | - |
|
| 387 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 388 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 389 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 368 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 369 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 370 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 371 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 372 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 373 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 374 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 375 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
| 376 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 377 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
| 378 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 379 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
| 380 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
| 381 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
| 382 | + |
|
| 383 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 384 | + |
|
| 385 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 386 | + |
|
| 387 | + if ($page == 'wpinv-subscriptions') { |
|
| 388 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 389 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - public function admin_body_class( $classes ) { |
|
| 393 | + public function admin_body_class($classes) { |
|
| 394 | 394 | global $pagenow, $post, $current_screen; |
| 395 | 395 | |
| 396 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 396 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 397 | 397 | $classes .= ' wpinv-cpt'; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 400 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 401 | 401 | |
| 402 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
| 403 | - if ( $add_class ) { |
|
| 404 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
| 402 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
| 403 | + if ($add_class) { |
|
| 404 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $settings_class = array(); |
| 408 | - if ( $page == 'wpinv-settings' ) { |
|
| 409 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 410 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 408 | + if ($page == 'wpinv-settings') { |
|
| 409 | + if (!empty($_REQUEST['tab'])) { |
|
| 410 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 414 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 413 | + if (!empty($_REQUEST['section'])) { |
|
| 414 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 417 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if ( !empty( $settings_class ) ) { |
|
| 421 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 420 | + if (!empty($settings_class)) { |
|
| 421 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $post_type = wpinv_admin_post_type(); |
| 425 | 425 | |
| 426 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 426 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 427 | 427 | return $classes .= ' wpinv'; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 430 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 431 | 431 | $classes .= ' wpi-editable-n'; |
| 432 | 432 | } |
| 433 | 433 | |
@@ -439,21 +439,21 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | public function wpinv_actions() { |
| 442 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 443 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 442 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 443 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - public function pre_get_posts( $wp_query ) { |
|
| 448 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 449 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 447 | + public function pre_get_posts($wp_query) { |
|
| 448 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 449 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | return $wp_query; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | public function bp_invoicing_init() { |
| 456 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 456 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -461,11 +461,11 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | */ |
| 463 | 463 | public function register_widgets() { |
| 464 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 465 | - register_widget( "WPInv_History_Widget" ); |
|
| 466 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 467 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 468 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 469 | - register_widget( "WPInv_Messages_Widget" ); |
|
| 464 | + register_widget("WPInv_Checkout_Widget"); |
|
| 465 | + register_widget("WPInv_History_Widget"); |
|
| 466 | + register_widget("WPInv_Receipt_Widget"); |
|
| 467 | + register_widget("WPInv_Subscriptions_Widget"); |
|
| 468 | + register_widget("WPInv_Buy_Item_Widget"); |
|
| 469 | + register_widget("WPInv_Messages_Widget"); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | \ No newline at end of file |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | case 'status' : |
| 102 | 102 | $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
| 103 | 103 | $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
| 104 | - $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
| 105 | - $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
|
| 106 | - $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
|
| 104 | + $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
| 105 | + $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
|
| 106 | + $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
|
| 107 | 107 | |
| 108 | 108 | if ( 1 == $is_viewed ) { |
| 109 | 109 | $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
@@ -174,69 +174,69 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | function wpinv_admin_messages() { |
| 177 | - global $wpinv_options, $pagenow, $post; |
|
| 177 | + global $wpinv_options, $pagenow, $post; |
|
| 178 | 178 | |
| 179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 181 | - } |
|
| 179 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 180 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 185 | - } |
|
| 183 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 184 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 189 | - } |
|
| 187 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 188 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 193 | - } |
|
| 191 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 192 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 197 | - } |
|
| 195 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 196 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 201 | - } |
|
| 199 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 200 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
| 205 | - } |
|
| 203 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 204 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 207 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 208 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
| 212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 212 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
| 216 | 216 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 221 | - } |
|
| 219 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 220 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 225 | - } |
|
| 223 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 224 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 229 | - } |
|
| 227 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 228 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 231 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 232 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 233 | 233 | |
| 234 | - if ( !empty( $message ) ) { |
|
| 235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 236 | - } |
|
| 237 | - } |
|
| 234 | + if ( !empty( $message ) ) { |
|
| 235 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - settings_errors( 'wpinv-notices' ); |
|
| 239 | + settings_errors( 'wpinv-notices' ); |
|
| 240 | 240 | } |
| 241 | 241 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
| 242 | 242 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | break; |
| 327 | 327 | case 'id' : |
| 328 | 328 | echo $post->ID; |
| 329 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 329 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 330 | 330 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
| 331 | 331 | if ( $wpinv_euvat->allow_vat_rules() ) { |
| 332 | 332 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,245 +7,245 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_columns( $columns ) { |
|
| 14 | +function wpinv_columns($columns) { |
|
| 15 | 15 | $columns = array( |
| 16 | 16 | 'cb' => $columns['cb'], |
| 17 | - 'number' => __( 'Number', 'invoicing' ), |
|
| 18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
| 21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
| 22 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
| 24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
| 17 | + 'number' => __('Number', 'invoicing'), |
|
| 18 | + 'customer' => __('Customer', 'invoicing'), |
|
| 19 | + 'amount' => __('Amount', 'invoicing'), |
|
| 20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
| 21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
| 22 | + 'status' => __('Status', 'invoicing'), |
|
| 23 | + 'ID' => __('ID', 'invoicing'), |
|
| 24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 28 | 28 | } |
| 29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
| 29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
| 30 | 30 | |
| 31 | -function wpinv_bulk_actions( $actions ) { |
|
| 32 | - if ( isset( $actions['edit'] ) ) { |
|
| 33 | - unset( $actions['edit'] ); |
|
| 31 | +function wpinv_bulk_actions($actions) { |
|
| 32 | + if (isset($actions['edit'])) { |
|
| 33 | + unset($actions['edit']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $actions; |
| 37 | 37 | } |
| 38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 40 | 40 | |
| 41 | -function wpinv_sortable_columns( $columns ) { |
|
| 41 | +function wpinv_sortable_columns($columns) { |
|
| 42 | 42 | $columns = array( |
| 43 | - 'ID' => array( 'ID', true ), |
|
| 44 | - 'number' => array( 'number', false ), |
|
| 45 | - 'amount' => array( 'amount', false ), |
|
| 46 | - 'invoice_date' => array( 'date', false ), |
|
| 47 | - 'payment_date' => array( 'payment_date', true ), |
|
| 48 | - 'customer' => array( 'customer', false ), |
|
| 49 | - 'status' => array( 'status', false ), |
|
| 43 | + 'ID' => array('ID', true), |
|
| 44 | + 'number' => array('number', false), |
|
| 45 | + 'amount' => array('amount', false), |
|
| 46 | + 'invoice_date' => array('date', false), |
|
| 47 | + 'payment_date' => array('payment_date', true), |
|
| 48 | + 'customer' => array('customer', false), |
|
| 49 | + 'status' => array('status', false), |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
| 52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
| 53 | 53 | } |
| 54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
| 54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
| 55 | 55 | |
| 56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
| 56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
| 58 | 58 | global $post, $wpi_invoice; |
| 59 | 59 | |
| 60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
| 61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
| 60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
| 61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $value = NULL; |
| 65 | 65 | |
| 66 | - switch ( $column_name ) { |
|
| 66 | + switch ($column_name) { |
|
| 67 | 67 | case 'email' : |
| 68 | - $value = $wpi_invoice->get_email(); |
|
| 68 | + $value = $wpi_invoice->get_email(); |
|
| 69 | 69 | break; |
| 70 | 70 | case 'customer' : |
| 71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
| 72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
| 73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
| 74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
| 73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
| 74 | + if ($email = $wpi_invoice->get_email()) { |
|
| 75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | case 'amount' : |
| 79 | - echo $wpi_invoice->get_total( true ); |
|
| 79 | + echo $wpi_invoice->get_total(true); |
|
| 80 | 80 | break; |
| 81 | 81 | case 'invoice_date' : |
| 82 | - $date_format = get_option( 'date_format' ); |
|
| 82 | + $date_format = get_option('date_format'); |
|
| 83 | 83 | |
| 84 | 84 | $m_time = $post->post_date; |
| 85 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 85 | + $h_time = mysql2date($date_format, $m_time); |
|
| 86 | 86 | |
| 87 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 87 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 88 | 88 | break; |
| 89 | 89 | case 'payment_date' : |
| 90 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
| 91 | - $date_format = get_option( 'date_format' ); |
|
| 90 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
| 91 | + $date_format = get_option('date_format'); |
|
| 92 | 92 | |
| 93 | 93 | $m_time = $date_completed; |
| 94 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 94 | + $h_time = mysql2date($date_format, $m_time); |
|
| 95 | 95 | |
| 96 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 96 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 97 | 97 | } else { |
| 98 | 98 | $value = '-'; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | case 'status' : |
| 102 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
| 103 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
| 104 | - $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
| 102 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
| 103 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
| 104 | + $gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()); |
|
| 105 | 105 | $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
| 106 | 106 | $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
| 107 | 107 | |
| 108 | - if ( 1 == $is_viewed ) { |
|
| 109 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 108 | + if (1 == $is_viewed) { |
|
| 109 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 110 | 110 | } |
| 111 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment ) && ( isset( $gateway_title ) ) ) { |
|
| 112 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
| 111 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment) && (isset($gateway_title))) { |
|
| 112 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
| 113 | 113 | } |
| 114 | 114 | break; |
| 115 | 115 | case 'number' : |
| 116 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 117 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 116 | + $edit_link = get_edit_post_link($post->ID); |
|
| 117 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 118 | 118 | break; |
| 119 | 119 | case 'wpi_actions' : |
| 120 | 120 | $value = ''; |
| 121 | - if ( !empty( $post->post_name ) ) { |
|
| 122 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 121 | + if (!empty($post->post_name)) { |
|
| 122 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 126 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 125 | + if ($email = $wpi_invoice->get_email()) { |
|
| 126 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | break; |
| 130 | 130 | default: |
| 131 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
| 131 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
| 132 | 132 | break; |
| 133 | 133 | |
| 134 | 134 | } |
| 135 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
| 135 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
| 136 | 136 | |
| 137 | - if ( $value !== NULL ) { |
|
| 137 | + if ($value !== NULL) { |
|
| 138 | 138 | echo $value; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 142 | +function wpinv_admin_post_id($id = 0) { |
|
| 143 | 143 | global $post; |
| 144 | 144 | |
| 145 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 146 | - return (int)$id; |
|
| 147 | - } else if ( get_the_ID() ) { |
|
| 145 | + if (isset($id) && !empty($id)) { |
|
| 146 | + return (int) $id; |
|
| 147 | + } else if (get_the_ID()) { |
|
| 148 | 148 | return (int) get_the_ID(); |
| 149 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 149 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 150 | 150 | return (int) $post->ID; |
| 151 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 151 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 152 | 152 | return (int) $_GET['post']; |
| 153 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 153 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 154 | 154 | return (int) $_GET['id']; |
| 155 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 155 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 156 | 156 | return (int) $_POST['id']; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return null; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 163 | - if ( !$id ) { |
|
| 162 | +function wpinv_admin_post_type($id = 0) { |
|
| 163 | + if (!$id) { |
|
| 164 | 164 | $id = wpinv_admin_post_id(); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $type = get_post_type( $id ); |
|
| 167 | + $type = get_post_type($id); |
|
| 168 | 168 | |
| 169 | - if ( !$type ) { |
|
| 170 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 169 | + if (!$type) { |
|
| 170 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 173 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | function wpinv_admin_messages() { |
| 177 | 177 | global $wpinv_options, $pagenow, $post; |
| 178 | 178 | |
| 179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 179 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 180 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 183 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 184 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 187 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 188 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 191 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 192 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 195 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 196 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 199 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 200 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
| 203 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 204 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 207 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 208 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 211 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 212 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 216 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
| 215 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 216 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 219 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 220 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 223 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 224 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
| 228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 227 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
| 228 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 231 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
| 232 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
| 233 | 233 | |
| 234 | - if ( !empty( $message ) ) { |
|
| 235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 234 | + if (!empty($message)) { |
|
| 235 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - settings_errors( 'wpinv-notices' ); |
|
| 239 | + settings_errors('wpinv-notices'); |
|
| 240 | 240 | } |
| 241 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 241 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 242 | 242 | |
| 243 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
| 244 | -function wpinv_show_test_payment_gateway_notice(){ |
|
| 245 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
| 243 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
| 244 | +function wpinv_show_test_payment_gateway_notice() { |
|
| 245 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | -function wpinv_test_payment_gateway_messages(){ |
|
| 248 | +function wpinv_test_payment_gateway_messages() { |
|
| 249 | 249 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 250 | 250 | $name = array(); $test_gateways = ''; |
| 251 | 251 | if ($gateways) { |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | $test_gateways = implode(', ', $name); |
| 258 | 258 | } |
| 259 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
| 259 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
| 260 | 260 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
| 261 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
| 261 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
| 262 | 262 | ?> |
| 263 | 263 | <div class="notice notice-warning is-dismissible"> |
| 264 | 264 | <p><?php echo $notice; ?></p> |
@@ -267,29 +267,29 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | -function wpinv_items_columns( $existing_columns ) { |
|
| 270 | +function wpinv_items_columns($existing_columns) { |
|
| 271 | 271 | global $wpinv_euvat; |
| 272 | 272 | |
| 273 | 273 | $columns = array(); |
| 274 | 274 | $columns['cb'] = $existing_columns['cb']; |
| 275 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
| 276 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
| 277 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 278 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
| 275 | + $columns['title'] = __('Title', 'invoicing'); |
|
| 276 | + $columns['price'] = __('Price', 'invoicing'); |
|
| 277 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 278 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
| 279 | 279 | } |
| 280 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 281 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
| 280 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 281 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
| 282 | 282 | } |
| 283 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
| 284 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
| 285 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
| 286 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
| 283 | + $columns['type'] = __('Type', 'invoicing'); |
|
| 284 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
| 285 | + $columns['date'] = __('Date', 'invoicing'); |
|
| 286 | + $columns['id'] = __('ID', 'invoicing'); |
|
| 287 | 287 | |
| 288 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
| 288 | + return apply_filters('wpinv_items_columns', $columns); |
|
| 289 | 289 | } |
| 290 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
| 290 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
| 291 | 291 | |
| 292 | -function wpinv_items_sortable_columns( $columns ) { |
|
| 292 | +function wpinv_items_sortable_columns($columns) { |
|
| 293 | 293 | $columns['price'] = 'price'; |
| 294 | 294 | $columns['vat_rule'] = 'vat_rule'; |
| 295 | 295 | $columns['vat_class'] = 'vat_class'; |
@@ -299,175 +299,175 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | return $columns; |
| 301 | 301 | } |
| 302 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
| 302 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
| 303 | 303 | |
| 304 | -function wpinv_items_table_custom_column( $column ) { |
|
| 304 | +function wpinv_items_table_custom_column($column) { |
|
| 305 | 305 | global $wpinv_euvat, $post, $wpi_item; |
| 306 | 306 | |
| 307 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
| 308 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
| 307 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
| 308 | + $wpi_item = new WPInv_Item($post->ID); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - switch ( $column ) { |
|
| 311 | + switch ($column) { |
|
| 312 | 312 | case 'price' : |
| 313 | - echo wpinv_item_price( $post->ID ); |
|
| 313 | + echo wpinv_item_price($post->ID); |
|
| 314 | 314 | break; |
| 315 | 315 | case 'vat_rule' : |
| 316 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
| 316 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
| 317 | 317 | break; |
| 318 | 318 | case 'vat_class' : |
| 319 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
| 319 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
| 320 | 320 | break; |
| 321 | 321 | case 'type' : |
| 322 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 322 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 323 | 323 | break; |
| 324 | 324 | case 'recurring' : |
| 325 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
| 325 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
| 326 | 326 | break; |
| 327 | 327 | case 'id' : |
| 328 | 328 | echo $post->ID; |
| 329 | 329 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
| 330 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
| 331 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 332 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
| 330 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
| 331 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 332 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
| 333 | 333 | } |
| 334 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 335 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
| 334 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 335 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
| 336 | 336 | } |
| 337 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
| 337 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
| 338 | 338 | </div>'; |
| 339 | 339 | break; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
| 342 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
| 343 | 343 | } |
| 344 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
| 344 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
| 345 | 345 | |
| 346 | 346 | function wpinv_add_items_filters() { |
| 347 | 347 | global $wpinv_euvat, $typenow; |
| 348 | 348 | |
| 349 | 349 | // Checks if the current post type is 'item' |
| 350 | - if ( $typenow == 'wpi_item') { |
|
| 351 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 350 | + if ($typenow == 'wpi_item') { |
|
| 351 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 352 | 352 | |
| 353 | 353 | // Sanitize selected vat rule. |
| 354 | - $vat_rule = ''; |
|
| 355 | - if( isset( $_GET['vat_rule'] ) && array_key_exists( $_GET['type'], $wpinv_euvat->get_rules() ) ) { |
|
| 356 | - $class = $_GET['type']; |
|
| 354 | + $vat_rule = ''; |
|
| 355 | + if (isset($_GET['vat_rule']) && array_key_exists($_GET['type'], $wpinv_euvat->get_rules())) { |
|
| 356 | + $class = $_GET['type']; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - echo wpinv_html_select( array( |
|
| 360 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
| 359 | + echo wpinv_html_select(array( |
|
| 360 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
| 361 | 361 | 'name' => 'vat_rule', |
| 362 | 362 | 'id' => 'vat_rule', |
| 363 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
| 363 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
| 364 | 364 | 'show_option_all' => false, |
| 365 | 365 | 'show_option_none' => false, |
| 366 | 366 | 'class' => 'gdmbx2-text-medium wpi_select2', |
| 367 | - 'placeholder' => __( 'Select VAT rule', 'invoicing' ), |
|
| 368 | - ) ); |
|
| 367 | + 'placeholder' => __('Select VAT rule', 'invoicing'), |
|
| 368 | + )); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 371 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 372 | 372 | |
| 373 | 373 | $classes = $wpinv_euvat->get_all_classes(); |
| 374 | 374 | |
| 375 | 375 | // Sanitize selected vat class. |
| 376 | 376 | $class = ''; |
| 377 | - if( isset( $_GET['vat_class'] ) && array_key_exists( $_GET['vat_class'], $classes ) ) { |
|
| 378 | - $class = $_GET['vat_class']; |
|
| 377 | + if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $classes)) { |
|
| 378 | + $class = $_GET['vat_class']; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - echo wpinv_html_select( array( |
|
| 382 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $classes ), |
|
| 381 | + echo wpinv_html_select(array( |
|
| 382 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $classes), |
|
| 383 | 383 | 'name' => 'vat_class', |
| 384 | 384 | 'id' => 'vat_class', |
| 385 | 385 | 'selected' => $class, |
| 386 | 386 | 'show_option_all' => false, |
| 387 | 387 | 'show_option_none' => false, |
| 388 | 388 | 'class' => 'gdmbx2-text-medium wpi_select2', |
| 389 | - 'placeholder' => __( 'Select VAT class', 'invoicing' ), |
|
| 390 | - ) ); |
|
| 389 | + 'placeholder' => __('Select VAT class', 'invoicing'), |
|
| 390 | + )); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // Sanitize selected item type. |
| 394 | - $type = ''; |
|
| 395 | - if( isset( $_GET['type'] ) && array_key_exists( $_GET['type'], wpinv_get_item_types() ) ) { |
|
| 396 | - $class = $_GET['type']; |
|
| 394 | + $type = ''; |
|
| 395 | + if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) { |
|
| 396 | + $class = $_GET['type']; |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - echo wpinv_html_select( array( |
|
| 400 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
| 399 | + echo wpinv_html_select(array( |
|
| 400 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
| 401 | 401 | 'name' => 'type', |
| 402 | 402 | 'id' => 'type', |
| 403 | 403 | 'selected' => $type, |
| 404 | 404 | 'show_option_all' => false, |
| 405 | 405 | 'show_option_none' => false, |
| 406 | 406 | 'class' => 'gdmbx2-text-medium', |
| 407 | - ) ); |
|
| 407 | + )); |
|
| 408 | 408 | |
| 409 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
| 409 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
| 410 | 410 | echo '<input type="hidden" name="all_posts" value="1" />'; |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
| 414 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
| 415 | 415 | |
| 416 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
| 417 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
| 416 | +function wpinv_send_invoice_after_save($invoice) { |
|
| 417 | + if (empty($_POST['wpi_save_send'])) { |
|
| 418 | 418 | return; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
| 422 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
| 421 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
| 422 | + wpinv_user_invoice_notification($invoice->ID); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 425 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 426 | 426 | |
| 427 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
| 428 | - if ( wpinv_current_user_can_manage_invoicing() && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
| 429 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
| 430 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
| 427 | +function wpinv_send_register_new_user($data, $postarr) { |
|
| 428 | + if (wpinv_current_user_can_manage_invoicing() && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
| 429 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
| 430 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
| 431 | 431 | |
| 432 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
| 433 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
| 434 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
| 435 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
| 436 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
| 437 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
| 432 | + if ($is_new_user && $email && !email_exists($email)) { |
|
| 433 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
| 434 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
| 435 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
| 436 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
| 437 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
| 438 | 438 | |
| 439 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
| 440 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 439 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
| 440 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 441 | 441 | $new_user_login = strstr($email, '@', true); |
| 442 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 443 | - $user_login = sanitize_user($new_user_login, true ); |
|
| 442 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 443 | + $user_login = sanitize_user($new_user_login, true); |
|
| 444 | 444 | } |
| 445 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 446 | - $user_append_text = rand(10,1000); |
|
| 447 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
| 445 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 446 | + $user_append_text = rand(10, 1000); |
|
| 447 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 450 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 451 | 451 | $user_login = $email; |
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $userdata = array( |
| 456 | 456 | 'user_login' => $user_login, |
| 457 | - 'user_pass' => wp_generate_password( 12, false ), |
|
| 458 | - 'user_email' => sanitize_text_field( $email ), |
|
| 457 | + 'user_pass' => wp_generate_password(12, false), |
|
| 458 | + 'user_email' => sanitize_text_field($email), |
|
| 459 | 459 | 'first_name' => $first_name, |
| 460 | 460 | 'last_name' => $last_name, |
| 461 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
| 461 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
| 462 | 462 | 'nickname' => $display_name, |
| 463 | 463 | 'display_name' => $display_name, |
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
| 466 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
| 467 | 467 | |
| 468 | - $new_user_id = wp_insert_user( $userdata ); |
|
| 468 | + $new_user_id = wp_insert_user($userdata); |
|
| 469 | 469 | |
| 470 | - if ( !is_wp_error( $new_user_id ) ) { |
|
| 470 | + if (!is_wp_error($new_user_id)) { |
|
| 471 | 471 | $data['post_author'] = $new_user_id; |
| 472 | 472 | $_POST['post_author'] = $new_user_id; |
| 473 | 473 | $_POST['post_author_override'] = $new_user_id; |
@@ -488,72 +488,72 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | $meta = array(); |
| 490 | 490 | ///$meta['_wpinv_user_id'] = $new_user_id; |
| 491 | - foreach ( $meta_fields as $field ) { |
|
| 492 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
| 491 | + foreach ($meta_fields as $field) { |
|
| 492 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
| 495 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
| 496 | 496 | |
| 497 | 497 | // Update user meta. |
| 498 | - foreach ( $meta as $key => $value ) { |
|
| 499 | - update_user_meta( $new_user_id, $key, $value ); |
|
| 498 | + foreach ($meta as $key => $value) { |
|
| 499 | + update_user_meta($new_user_id, $key, $value); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
| 502 | + if (function_exists('wp_send_new_user_notifications')) { |
|
| 503 | 503 | // Send email notifications related to the creation of new user. |
| 504 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
| 504 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
| 505 | 505 | } |
| 506 | 506 | } else { |
| 507 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
| 507 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | return $data; |
| 513 | 513 | } |
| 514 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
| 514 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
| 515 | 515 | |
| 516 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
| 516 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
| 517 | 517 | $all_gateways = wpinv_get_payment_gateways(); |
| 518 | 518 | |
| 519 | - if ( !empty( $all_gateways ) ) { |
|
| 519 | + if (!empty($all_gateways)) { |
|
| 520 | 520 | $gateways = array(); |
| 521 | 521 | |
| 522 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 523 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 522 | + foreach ($all_gateways as $key => $gateway) { |
|
| 523 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 524 | 524 | $gateways[] = $gateway['admin_label']; |
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( !empty( $gateways ) ) { |
|
| 528 | + if (!empty($gateways)) { |
|
| 529 | 529 | ?> |
| 530 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
| 530 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
| 531 | 531 | <?php |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
| 535 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
| 536 | 536 | |
| 537 | -function wpinv_post_updated_messages( $messages ) { |
|
| 537 | +function wpinv_post_updated_messages($messages) { |
|
| 538 | 538 | global $post, $post_ID; |
| 539 | 539 | |
| 540 | 540 | $messages['wpi_discount'] = array( |
| 541 | 541 | 0 => '', |
| 542 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 543 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 544 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 545 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 546 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 547 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 548 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 549 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 550 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 551 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 542 | + 1 => __('Discount updated.', 'invoicing'), |
|
| 543 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 544 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 545 | + 4 => __('Discount updated.', 'invoicing'), |
|
| 546 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 547 | + 6 => __('Discount updated.', 'invoicing'), |
|
| 548 | + 7 => __('Discount saved.', 'invoicing'), |
|
| 549 | + 8 => __('Discount submitted.', 'invoicing'), |
|
| 550 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 551 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | 554 | return $messages; |
| 555 | 555 | } |
| 556 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
| 556 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
| 557 | 557 | |
| 558 | 558 | add_action('admin_init', 'admin_init_example_type'); |
| 559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | function admin_init_example_type() { |
| 564 | 564 | global $typenow; |
| 565 | 565 | |
| 566 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
| 566 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
| 567 | 567 | add_filter('posts_search', 'posts_search_example_type', 10, 2); |
| 568 | 568 | } |
| 569 | 569 | } |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | global $wpdb; |
| 579 | 579 | |
| 580 | 580 | if ($query->is_main_query() && !empty($query->query['s'])) { |
| 581 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
| 582 | - if ( ! empty( $search ) ) { |
|
| 583 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
| 581 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
| 582 | + if (!empty($search)) { |
|
| 583 | + $search = preg_replace('/^ AND /', '', $search); |
|
| 584 | 584 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
| 585 | 585 | } else { |
| 586 | 586 | $search = " AND ( {$conditions_str} )"; |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | return $search; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
| 594 | -function wpinv_reset_invoice_count(){ |
|
| 595 | - if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 593 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
| 594 | +function wpinv_reset_invoice_count() { |
|
| 595 | + if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 596 | 596 | wpinv_update_option('invoice_sequence_start', 1); |
| 597 | 597 | delete_option('wpinv_last_invoice_number'); |
| 598 | 598 | $url = add_query_arg(array('reset_invoice_done' => 1)); |
@@ -603,8 +603,8 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | add_action('admin_notices', 'wpinv_invoice_count_reset_message'); |
| 606 | -function wpinv_invoice_count_reset_message(){ |
|
| 607 | - if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 606 | +function wpinv_invoice_count_reset_message() { |
|
| 607 | + if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 608 | 608 | $notice = __('Invoice number sequence reset successfully.', 'invoicing'); |
| 609 | 609 | ?> |
| 610 | 610 | <div class="notice notice-success is-dismissible"> |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | return false; |
| 343 | 343 | } |
| 344 | 344 | if (null !== $this->apcuPrefix) { |
| 345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
| 345 | + $file = apcu_fetch($this->apcuPrefix . $class, $hit); |
|
| 346 | 346 | if ($hit) { |
| 347 | 347 | return $file; |
| 348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | if (null !== $this->apcuPrefix) { |
| 359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
| 359 | + apcu_add($this->apcuPrefix . $class, $file); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | if (false === $file) { |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $month = ($month ? $month : date('m')); |
| 66 | 66 | $year = ($year ? $year : date('Y')); |
| 67 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6); |
|
| 68 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6); |
|
| 67 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, $month, 1, $year)), 0, -6); |
|
| 68 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, $month + 1, 0, $year)), 0, -6); |
|
| 69 | 69 | return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | $month = ($month ? $month : date('m')); |
| 99 | 99 | $day = ($day ? $day : date('d')); |
| 100 | 100 | $year = ($year ? $year : date('Y')); |
| 101 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
| 102 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
| 101 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6); |
|
| 102 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6); |
|
| 103 | 103 | $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
| 104 | 104 | $batches = $response->xpath("batchList/batch"); |
| 105 | 105 | foreach ($batches as $batch) { |
| 106 | - $batch_id = (string)$batch->batchId; |
|
| 106 | + $batch_id = (string) $batch->batchId; |
|
| 107 | 107 | $request = new AuthorizeNetTD; |
| 108 | 108 | $tran_list = $request->getTransactionList($batch_id); |
| 109 | 109 | $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction")); |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | private function _constructXml($request_type) |
| 189 | 189 | { |
| 190 | - $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>'; |
|
| 190 | + $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>'; |
|
| 191 | 191 | $this->_xml = @new SimpleXMLElement($string); |
| 192 | 192 | $merchant = $this->_xml->addChild('merchantAuthentication'); |
| 193 | - $merchant->addChild('name',$this->_api_login); |
|
| 194 | - $merchant->addChild('transactionKey',$this->_transaction_key); |
|
| 193 | + $merchant->addChild('name', $this->_api_login); |
|
| 194 | + $merchant->addChild('transactionKey', $this->_transaction_key); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
@@ -178,11 +178,11 @@ |
||
| 178 | 178 | */ |
| 179 | 179 | public function getHiddenFieldString() |
| 180 | 180 | { |
| 181 | - $array = (array)$this; |
|
| 181 | + $array = (array) $this; |
|
| 182 | 182 | $string = ""; |
| 183 | 183 | foreach ($array as $key => $value) { |
| 184 | 184 | if ($value) { |
| 185 | - $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
| 185 | + $string .= '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | return $string; |
@@ -114,24 +114,24 @@ |
||
| 114 | 114 | |
| 115 | 115 | public function __construct() |
| 116 | 116 | { |
| 117 | - $this->tax = (object)array(); |
|
| 117 | + $this->tax = (object) array(); |
|
| 118 | 118 | $this->tax->amount = ""; |
| 119 | 119 | $this->tax->name = ""; |
| 120 | 120 | $this->tax->description = ""; |
| 121 | 121 | |
| 122 | - $this->shipping = (object)array(); |
|
| 122 | + $this->shipping = (object) array(); |
|
| 123 | 123 | $this->shipping->amount = ""; |
| 124 | 124 | $this->shipping->name = ""; |
| 125 | 125 | $this->shipping->description = ""; |
| 126 | 126 | |
| 127 | - $this->duty = (object)array(); |
|
| 127 | + $this->duty = (object) array(); |
|
| 128 | 128 | $this->duty->amount = ""; |
| 129 | 129 | $this->duty->name = ""; |
| 130 | 130 | $this->duty->description = ""; |
| 131 | 131 | |
| 132 | 132 | // line items |
| 133 | 133 | |
| 134 | - $this->order = (object)array(); |
|
| 134 | + $this->order = (object) array(); |
|
| 135 | 135 | $this->order->invoiceNumber = ""; |
| 136 | 136 | $this->order->description = ""; |
| 137 | 137 | $this->order->purchaseOrderNumber = ""; |
@@ -77,19 +77,19 @@ discard block |
||
| 77 | 77 | * A list of all fields in the AIM API. |
| 78 | 78 | * Used to warn user if they try to set a field not offered in the API. |
| 79 | 79 | */ |
| 80 | - private $_all_aim_fields = array("address","allow_partial_auth","amount", |
|
| 81 | - "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name", |
|
| 82 | - "bank_acct_num","bank_acct_type","bank_check_number","bank_name", |
|
| 83 | - "card_code","card_num","cardholder_authentication_value","city","company", |
|
| 84 | - "country","cust_id","customer_ip","delim_char","delim_data","description", |
|
| 85 | - "duplicate_window","duty","echeck_type","email","email_customer", |
|
| 86 | - "encap_char","exp_date","fax","first_name","footer_email_receipt", |
|
| 87 | - "freight","header_email_receipt","invoice_num","last_name","line_item", |
|
| 88 | - "login","method","phone","po_num","recurring_billing","relay_response", |
|
| 89 | - "ship_to_address","ship_to_city","ship_to_company","ship_to_country", |
|
| 90 | - "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip", |
|
| 91 | - "split_tender_id","state","tax","tax_exempt","test_request","tran_key", |
|
| 92 | - "trans_id","type","version","zip" |
|
| 80 | + private $_all_aim_fields = array("address", "allow_partial_auth", "amount", |
|
| 81 | + "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name", |
|
| 82 | + "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name", |
|
| 83 | + "card_code", "card_num", "cardholder_authentication_value", "city", "company", |
|
| 84 | + "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description", |
|
| 85 | + "duplicate_window", "duty", "echeck_type", "email", "email_customer", |
|
| 86 | + "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt", |
|
| 87 | + "freight", "header_email_receipt", "invoice_num", "last_name", "line_item", |
|
| 88 | + "login", "method", "phone", "po_num", "recurring_billing", "relay_response", |
|
| 89 | + "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country", |
|
| 90 | + "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip", |
|
| 91 | + "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key", |
|
| 92 | + "trans_id", "type", "version", "zip" |
|
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function setFields($fields) |
| 236 | 236 | { |
| 237 | - $array = (array)$fields; |
|
| 237 | + $array = (array) $fields; |
|
| 238 | 238 | foreach ($array as $key => $value) { |
| 239 | 239 | $this->setField($key, $value); |
| 240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | public function setCustomFields($fields) |
| 249 | 249 | { |
| 250 | - $array = (array)$fields; |
|
| 250 | + $array = (array) $fields; |
|
| 251 | 251 | foreach ($array as $key => $value) { |
| 252 | 252 | $this->setCustomField($key, $value); |
| 253 | 253 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | // Split Array |
| 404 | 404 | $this->response = $response; |
| 405 | 405 | if ($encap_char) { |
| 406 | - $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
| 406 | + $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
| 407 | 407 | } else { |
| 408 | 408 | $this->_response_array = explode($delimiter, $response); |
| 409 | 409 | } |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | $this->duty = $this->_response_array[33]; |
| 458 | 458 | $this->freight = $this->_response_array[34]; |
| 459 | 459 | $this->tax_exempt = $this->_response_array[35]; |
| 460 | - $this->purchase_order_number= $this->_response_array[36]; |
|
| 460 | + $this->purchase_order_number = $this->_response_array[36]; |
|
| 461 | 461 | $this->md5_hash = $this->_response_array[37]; |
| 462 | 462 | $this->card_code_response = $this->_response_array[38]; |
| 463 | 463 | $this->cavv_response = $this->_response_array[39]; |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | if ($this->error) { |
| 486 | 486 | $this->error_message = "AuthorizeNet Error: |
| 487 | - Response Code: ".$this->response_code." |
|
| 488 | - Response Subcode: ".$this->response_subcode." |
|
| 489 | - Response Reason Code: ".$this->response_reason_code." |
|
| 490 | - Response Reason Text: ".$this->response_reason_text." |
|
| 487 | + Response Code: ".$this->response_code . " |
|
| 488 | + Response Subcode: ".$this->response_subcode . " |
|
| 489 | + Response Reason Code: ".$this->response_reason_code . " |
|
| 490 | + Response Reason Text: ".$this->response_reason_text . " |
|
| 491 | 491 | "; |
| 492 | 492 | } |
| 493 | 493 | } else { |
@@ -116,27 +116,27 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $this->xml = @simplexml_load_string($response); |
| 118 | 118 | // Set all fields |
| 119 | - $this->version = array_pop(array_slice(explode('"', $response), 1,1)); |
|
| 120 | - $this->response_code = (string)$this->xml->ResponseCode; |
|
| 119 | + $this->version = array_pop(array_slice(explode('"', $response), 1, 1)); |
|
| 120 | + $this->response_code = (string) $this->xml->ResponseCode; |
|
| 121 | 121 | |
| 122 | 122 | if ($this->response_code == 1) { |
| 123 | - $this->response_reason_code = (string)$this->xml->Messages->Message->Code; |
|
| 124 | - $this->response_reason_text = (string)$this->xml->Messages->Message->Description; |
|
| 123 | + $this->response_reason_code = (string) $this->xml->Messages->Message->Code; |
|
| 124 | + $this->response_reason_text = (string) $this->xml->Messages->Message->Description; |
|
| 125 | 125 | } else { |
| 126 | - $this->response_reason_code = (string)$this->xml->Errors->Error->ErrorCode; |
|
| 127 | - $this->response_reason_text = (string)$this->xml->Errors->Error->ErrorText; |
|
| 126 | + $this->response_reason_code = (string) $this->xml->Errors->Error->ErrorCode; |
|
| 127 | + $this->response_reason_text = (string) $this->xml->Errors->Error->ErrorText; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $this->authorization_code = (string)$this->xml->AuthCode; |
|
| 131 | - $this->avs_code = (string)$this->xml->AVSResultCode; |
|
| 132 | - $this->card_code_response = (string)$this->xml->CVVResultCode; |
|
| 133 | - $this->transaction_id = (string)$this->xml->TransID; |
|
| 134 | - $this->md5_hash = (string)$this->xml->TransHash; |
|
| 135 | - $this->user_ref = (string)$this->xml->UserRef; |
|
| 136 | - $this->card_num = (string)$this->xml->AccountNumber; |
|
| 137 | - $this->card_type = (string)$this->xml->AccountType; |
|
| 138 | - $this->test_mode = (string)$this->xml->TestMode; |
|
| 139 | - $this->ref_trans_id = (string)$this->xml->RefTransID; |
|
| 130 | + $this->authorization_code = (string) $this->xml->AuthCode; |
|
| 131 | + $this->avs_code = (string) $this->xml->AVSResultCode; |
|
| 132 | + $this->card_code_response = (string) $this->xml->CVVResultCode; |
|
| 133 | + $this->transaction_id = (string) $this->xml->TransID; |
|
| 134 | + $this->md5_hash = (string) $this->xml->TransHash; |
|
| 135 | + $this->user_ref = (string) $this->xml->UserRef; |
|
| 136 | + $this->card_num = (string) $this->xml->AccountNumber; |
|
| 137 | + $this->card_type = (string) $this->xml->AccountType; |
|
| 138 | + $this->test_mode = (string) $this->xml->TestMode; |
|
| 139 | + $this->ref_trans_id = (string) $this->xml->RefTransID; |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | } else { // If it's an NVP response |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | // Split Array |
| 145 | 145 | $this->response = $response; |
| 146 | 146 | if ($encap_char) { |
| 147 | - $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
| 147 | + $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
| 148 | 148 | } else { |
| 149 | 149 | $this->_response_array = explode($delimiter, $response); |
| 150 | 150 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | if ($this->error) { |
| 192 | 192 | $this->error_message = "AuthorizeNet Error: |
| 193 | - Response Code: ".$this->response_code." |
|
| 194 | - Response Reason Code: ".$this->response_reason_code." |
|
| 195 | - Response Reason Text: ".$this->response_reason_text." |
|
| 193 | + Response Code: ".$this->response_code . " |
|
| 194 | + Response Reason Code: ".$this->response_reason_code . " |
|
| 195 | + Response Reason Text: ".$this->response_reason_text . " |
|
| 196 | 196 | "; |
| 197 | 197 | } |
| 198 | 198 | |