|  | @@ -7,15 +7,15 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 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(); | 
                                                                                                                                                        
                                                        |  | @@ -23,7 +23,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 23 | 23 |              self::$instance->reports    = new WPInv_Reports(); | 
                                                                                                            
                                                            | 24 | 24 |          } | 
                                                                                                            
                                                            | 25 | 25 |           | 
                                                                                                            
                                                            | 26 |  | -        do_action( 'wpinv_loaded' ); | 
                                                                                                            
                                                            |  | 26 | +        do_action('wpinv_loaded'); | 
                                                                                                            
                                                            | 27 | 27 |           | 
                                                                                                            
                                                            | 28 | 28 |          return self::$instance; | 
                                                                                                            
                                                            | 29 | 29 |      } | 
                                                                                                                                                        
                                                        |  | @@ -33,31 +33,31 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 33 | 33 |      } | 
                                                                                                            
                                                            | 34 | 34 |       | 
                                                                                                            
                                                            | 35 | 35 |      public function define_constants() { | 
                                                                                                            
                                                            | 36 |  | -        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); | 
                                                                                                            
                                                            | 37 |  | -        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); | 
                                                                                                            
                                                            |  | 36 | +        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); | 
                                                                                                            
                                                            |  | 37 | +        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); | 
                                                                                                            
                                                            | 38 | 38 |      } | 
                                                                                                            
                                                            | 39 | 39 |       | 
                                                                                                            
                                                            | 40 | 40 |      private function actions() { | 
                                                                                                            
                                                            | 41 | 41 |          /* Internationalize the text strings used. */ | 
                                                                                                            
                                                            | 42 |  | -        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); | 
                                                                                                            
                                                            |  | 42 | +        add_action('plugins_loaded', array(&$this, 'plugins_loaded')); | 
                                                                                                            
                                                            | 43 | 43 |           | 
                                                                                                            
                                                            | 44 | 44 |          /* Perform actions on admin initialization. */ | 
                                                                                                            
                                                            | 45 |  | -        add_action( 'admin_init', array( &$this, 'admin_init') ); | 
                                                                                                            
                                                            | 46 |  | -        add_action( 'init', array( &$this, 'init' ), 3 ); | 
                                                                                                            
                                                            | 47 |  | -        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); | 
                                                                                                            
                                                            | 48 |  | -        add_action( 'init', array( &$this, 'wpinv_actions' ) ); | 
                                                                                                            
                                                            |  | 45 | +        add_action('admin_init', array(&$this, 'admin_init')); | 
                                                                                                            
                                                            |  | 46 | +        add_action('init', array(&$this, 'init'), 3); | 
                                                                                                            
                                                            |  | 47 | +        add_action('init', array('WPInv_Shortcodes', 'init')); | 
                                                                                                            
                                                            |  | 48 | +        add_action('init', array(&$this, 'wpinv_actions')); | 
                                                                                                            
                                                            | 49 | 49 |           | 
                                                                                                            
                                                            | 50 |  | -        if ( class_exists( 'BuddyPress' ) ) { | 
                                                                                                            
                                                            | 51 |  | -            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); | 
                                                                                                            
                                                            |  | 50 | +        if (class_exists('BuddyPress')) { | 
                                                                                                            
                                                            |  | 51 | +            add_action('bp_include', array(&$this, 'bp_invoicing_init')); | 
                                                                                                            
                                                            | 52 | 52 |          } | 
                                                                                                            
                                                            | 53 | 53 |   | 
                                                                                                            
                                                            | 54 |  | -        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); | 
                                                                                                            
                                                            |  | 54 | +        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); | 
                                                                                                            
                                                            | 55 | 55 |           | 
                                                                                                            
                                                            | 56 |  | -        if ( is_admin() ) { | 
                                                                                                            
                                                            | 57 |  | -            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); | 
                                                                                                            
                                                            | 58 |  | -            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); | 
                                                                                                            
                                                            |  | 56 | +        if (is_admin()) { | 
                                                                                                            
                                                            |  | 57 | +            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); | 
                                                                                                            
                                                            |  | 58 | +            add_action('admin_body_class', array(&$this, 'admin_body_class')); | 
                                                                                                            
                                                            | 59 | 59 |          } else { | 
                                                                                                            
                                                            | 60 |  | -            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); | 
                                                                                                            
                                                            |  | 60 | +            add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); | 
                                                                                                            
                                                            | 61 | 61 |          } | 
                                                                                                            
                                                            | 62 | 62 |           | 
                                                                                                            
                                                            | 63 | 63 |          /** | 
                                                                                                                                                        
                                                        |  | @@ -67,9 +67,9 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 67 | 67 |           * | 
                                                                                                            
                                                            | 68 | 68 |           * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. | 
                                                                                                            
                                                            | 69 | 69 |           */ | 
                                                                                                            
                                                            | 70 |  | -        do_action_ref_array( 'wpinv_actions', array( &$this ) ); | 
                                                                                                            
                                                            |  | 70 | +        do_action_ref_array('wpinv_actions', array(&$this)); | 
                                                                                                            
                                                            | 71 | 71 |   | 
                                                                                                            
                                                            | 72 |  | -        add_action( 'admin_init', array( &$this, 'activation_redirect') ); | 
                                                                                                            
                                                            |  | 72 | +        add_action('admin_init', array(&$this, 'activation_redirect')); | 
                                                                                                            
                                                            | 73 | 73 |      } | 
                                                                                                            
                                                            | 74 | 74 |       | 
                                                                                                            
                                                            | 75 | 75 |      public function plugins_loaded() { | 
                                                                                                                                                        
                                                        |  | @@ -83,191 +83,191 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 83 | 83 |       * @since 1.0 | 
                                                                                                            
                                                            | 84 | 84 |       */ | 
                                                                                                            
                                                            | 85 | 85 |      public function load_textdomain() { | 
                                                                                                            
                                                            | 86 |  | -        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' ); | 
                                                                                                            
                                                            |  | 86 | +        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing'); | 
                                                                                                            
                                                            | 87 | 87 |           | 
                                                                                                            
                                                            | 88 |  | -        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); | 
                                                                                                            
                                                            | 89 |  | -        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); | 
                                                                                                            
                                                            |  | 88 | +        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); | 
                                                                                                            
                                                            |  | 89 | +        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); | 
                                                                                                            
                                                            | 90 | 90 |           | 
                                                                                                            
                                                            | 91 | 91 |          /** | 
                                                                                                            
                                                            | 92 | 92 |           * Define language constants. | 
                                                                                                            
                                                            | 93 | 93 |           */ | 
                                                                                                            
                                                            | 94 |  | -        require_once( WPINV_PLUGIN_DIR . 'language.php' ); | 
                                                                                                            
                                                            |  | 94 | +        require_once(WPINV_PLUGIN_DIR . 'language.php'); | 
                                                                                                            
                                                            | 95 | 95 |      } | 
                                                                                                            
                                                            | 96 | 96 |           | 
                                                                                                            
                                                            | 97 | 97 |      public function includes() { | 
                                                                                                            
                                                            | 98 | 98 |          global $wpinv_options; | 
                                                                                                            
                                                            | 99 | 99 |           | 
                                                                                                            
                                                            | 100 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); | 
                                                                                                            
                                                            |  | 100 | +        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); | 
                                                                                                            
                                                            | 101 | 101 |          $wpinv_options = wpinv_get_settings(); | 
                                                                                                            
                                                            | 102 | 102 |           | 
                                                                                                            
                                                            | 103 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); | 
                                                                                                            
                                                            | 104 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); | 
                                                                                                            
                                                            | 105 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); | 
                                                                                                            
                                                            | 106 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); | 
                                                                                                            
                                                            | 107 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); | 
                                                                                                            
                                                            | 108 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); | 
                                                                                                            
                                                            | 109 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); | 
                                                                                                            
                                                            | 110 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); | 
                                                                                                            
                                                            | 111 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); | 
                                                                                                            
                                                            | 112 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); | 
                                                                                                            
                                                            | 113 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); | 
                                                                                                            
                                                            | 114 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); | 
                                                                                                            
                                                            | 115 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); | 
                                                                                                            
                                                            | 116 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); | 
                                                                                                            
                                                            |  | 103 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); | 
                                                                                                            
                                                            |  | 104 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); | 
                                                                                                            
                                                            |  | 105 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); | 
                                                                                                            
                                                            |  | 106 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); | 
                                                                                                            
                                                            |  | 107 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); | 
                                                                                                            
                                                            |  | 108 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); | 
                                                                                                            
                                                            |  | 109 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); | 
                                                                                                            
                                                            |  | 110 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); | 
                                                                                                            
                                                            |  | 111 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); | 
                                                                                                            
                                                            |  | 112 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); | 
                                                                                                            
                                                            |  | 113 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); | 
                                                                                                            
                                                            |  | 114 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); | 
                                                                                                            
                                                            |  | 115 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); | 
                                                                                                            
                                                            |  | 116 | +        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); | 
                                                                                                            
                                                            | 117 | 117 |          //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); | 
                                                                                                            
                                                            | 118 | 118 |          //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); | 
                                                                                                            
                                                            | 119 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); | 
                                                                                                            
                                                            |  | 119 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); | 
                                                                                                            
                                                            | 120 | 120 |          //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); | 
                                                                                                            
                                                            | 121 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); | 
                                                                                                            
                                                            | 122 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); | 
                                                                                                            
                                                            | 123 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); | 
                                                                                                            
                                                            | 124 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); | 
                                                                                                            
                                                            | 125 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); | 
                                                                                                            
                                                            | 126 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); | 
                                                                                                            
                                                            | 127 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); | 
                                                                                                            
                                                            | 128 |  | -        if ( !class_exists( 'WPInv_EUVat' ) ) { | 
                                                                                                            
                                                            | 129 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); | 
                                                                                                            
                                                            |  | 121 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); | 
                                                                                                            
                                                            |  | 122 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); | 
                                                                                                            
                                                            |  | 123 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); | 
                                                                                                            
                                                            |  | 124 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); | 
                                                                                                            
                                                            |  | 125 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); | 
                                                                                                            
                                                            |  | 126 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); | 
                                                                                                            
                                                            |  | 127 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); | 
                                                                                                            
                                                            |  | 128 | +        if (!class_exists('WPInv_EUVat')) { | 
                                                                                                            
                                                            |  | 129 | +            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); | 
                                                                                                            
                                                            | 130 | 130 |          } | 
                                                                                                            
                                                            | 131 | 131 |           | 
                                                                                                            
                                                            | 132 |  | -        $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); | 
                                                                                                            
                                                            | 133 |  | -        if ( !empty( $gateways ) ) { | 
                                                                                                            
                                                            | 134 |  | -            foreach ( $gateways as $gateway ) { | 
                                                                                                            
                                                            | 135 |  | -                if ( $gateway == 'manual' ) { | 
                                                                                                            
                                                            |  | 132 | +        $gateways = array_keys(wpinv_get_enabled_payment_gateways()); | 
                                                                                                            
                                                            |  | 133 | +        if (!empty($gateways)) { | 
                                                                                                            
                                                            |  | 134 | +            foreach ($gateways as $gateway) { | 
                                                                                                            
                                                            |  | 135 | +                if ($gateway == 'manual') { | 
                                                                                                            
                                                            | 136 | 136 |                      continue; | 
                                                                                                            
                                                            | 137 | 137 |                  } | 
                                                                                                            
                                                            | 138 | 138 |                   | 
                                                                                                            
                                                            | 139 | 139 |                  $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; | 
                                                                                                            
                                                            | 140 | 140 |                   | 
                                                                                                            
                                                            | 141 |  | -                if ( file_exists( $gateway_file ) ) { | 
                                                                                                            
                                                            | 142 |  | -                    require_once( $gateway_file ); | 
                                                                                                            
                                                            |  | 141 | +                if (file_exists($gateway_file)) { | 
                                                                                                            
                                                            |  | 142 | +                    require_once($gateway_file); | 
                                                                                                            
                                                            | 143 | 143 |                  } | 
                                                                                                            
                                                            | 144 | 144 |              } | 
                                                                                                            
                                                            | 145 | 145 |          } | 
                                                                                                            
                                                            | 146 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); | 
                                                                                                            
                                                            |  | 146 | +        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); | 
                                                                                                            
                                                            | 147 | 147 |           | 
                                                                                                            
                                                            | 148 |  | -        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { | 
                                                                                                            
                                                            | 149 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); | 
                                                                                                            
                                                            | 150 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); | 
                                                                                                            
                                                            | 151 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); | 
                                                                                                            
                                                            |  | 148 | +        if (is_admin() || (defined('WP_CLI') && WP_CLI)) { | 
                                                                                                            
                                                            |  | 149 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); | 
                                                                                                            
                                                            |  | 150 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); | 
                                                                                                            
                                                            |  | 151 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); | 
                                                                                                            
                                                            | 152 | 152 |              //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); | 
                                                                                                            
                                                            | 153 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); | 
                                                                                                            
                                                            | 154 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); | 
                                                                                                            
                                                            | 155 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); | 
                                                                                                            
                                                            | 156 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); | 
                                                                                                            
                                                            | 157 |  | -            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); | 
                                                                                                            
                                                            |  | 153 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); | 
                                                                                                            
                                                            |  | 154 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); | 
                                                                                                            
                                                            |  | 155 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); | 
                                                                                                            
                                                            |  | 156 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); | 
                                                                                                            
                                                            |  | 157 | +            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); | 
                                                                                                            
                                                            | 158 | 158 |              //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); | 
                                                                                                            
                                                            | 159 | 159 |          } | 
                                                                                                            
                                                            | 160 | 160 |           | 
                                                                                                            
                                                            | 161 | 161 |          // include css inliner | 
                                                                                                            
                                                            | 162 |  | -        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { | 
                                                                                                            
                                                            | 163 |  | -            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); | 
                                                                                                            
                                                            |  | 162 | +        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { | 
                                                                                                            
                                                            |  | 163 | +            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); | 
                                                                                                            
                                                            | 164 | 164 |          } | 
                                                                                                            
                                                            | 165 | 165 |           | 
                                                                                                            
                                                            | 166 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); | 
                                                                                                            
                                                            |  | 166 | +        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); | 
                                                                                                            
                                                            | 167 | 167 |      } | 
                                                                                                            
                                                            | 168 | 168 |       | 
                                                                                                            
                                                            | 169 | 169 |      public function init() { | 
                                                                                                            
                                                            | 170 | 170 |      } | 
                                                                                                            
                                                            | 171 | 171 |       | 
                                                                                                            
                                                            | 172 | 172 |      public function admin_init() { | 
                                                                                                            
                                                            | 173 |  | -        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { | 
                                                                                                            
                                                            |  | 173 | +        if (!(defined('DOING_AJAX') && DOING_AJAX)) { | 
                                                                                                            
                                                            | 174 | 174 |          } | 
                                                                                                            
                                                            | 175 | 175 |           | 
                                                                                                            
                                                            | 176 |  | -        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); | 
                                                                                                            
                                                            |  | 176 | +        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); | 
                                                                                                            
                                                            | 177 | 177 |      } | 
                                                                                                            
                                                            | 178 | 178 |   | 
                                                                                                            
                                                            | 179 | 179 |      public function activation_redirect() { | 
                                                                                                            
                                                            | 180 | 180 |          // Bail if no activation redirect | 
                                                                                                            
                                                            | 181 |  | -        if ( !get_transient( '_wpinv_activation_redirect' ) ) { | 
                                                                                                            
                                                            |  | 181 | +        if (!get_transient('_wpinv_activation_redirect')) { | 
                                                                                                            
                                                            | 182 | 182 |              return; | 
                                                                                                            
                                                            | 183 | 183 |          } | 
                                                                                                            
                                                            | 184 | 184 |   | 
                                                                                                            
                                                            | 185 | 185 |          // Delete the redirect transient | 
                                                                                                            
                                                            | 186 |  | -        delete_transient( '_wpinv_activation_redirect' ); | 
                                                                                                            
                                                            |  | 186 | +        delete_transient('_wpinv_activation_redirect'); | 
                                                                                                            
                                                            | 187 | 187 |   | 
                                                                                                            
                                                            | 188 | 188 |          // Bail if activating from network, or bulk | 
                                                                                                            
                                                            | 189 |  | -        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | 
                                                                                                            
                                                            |  | 189 | +        if (is_network_admin() || isset($_GET['activate-multi'])) { | 
                                                                                                            
                                                            | 190 | 190 |              return; | 
                                                                                                            
                                                            | 191 | 191 |          } | 
                                                                                                            
                                                            | 192 | 192 |   | 
                                                                                                            
                                                            | 193 |  | -        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); | 
                                                                                                            
                                                            |  | 193 | +        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); | 
                                                                                                            
                                                            | 194 | 194 |          exit; | 
                                                                                                            
                                                            | 195 | 195 |      } | 
                                                                                                            
                                                            | 196 | 196 |       | 
                                                                                                            
                                                            | 197 | 197 |      public function enqueue_scripts() { | 
                                                                                                            
                                                            | 198 |  | -        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | 
                                                                                                            
                                                            |  | 198 | +        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | 
                                                                                                            
                                                            | 199 | 199 |           | 
                                                                                                            
                                                            | 200 |  | -        wp_deregister_style( 'font-awesome' ); | 
                                                                                                            
                                                            | 201 |  | -        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); | 
                                                                                                            
                                                            | 202 |  | -        wp_enqueue_style( 'font-awesome' ); | 
                                                                                                            
                                                            |  | 200 | +        wp_deregister_style('font-awesome'); | 
                                                                                                            
                                                            |  | 201 | +        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); | 
                                                                                                            
                                                            |  | 202 | +        wp_enqueue_style('font-awesome'); | 
                                                                                                            
                                                            | 203 | 203 |           | 
                                                                                                            
                                                            | 204 |  | -        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); | 
                                                                                                            
                                                            | 205 |  | -        wp_enqueue_style( 'wpinv_front_style' ); | 
                                                                                                            
                                                            |  | 204 | +        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); | 
                                                                                                            
                                                            |  | 205 | +        wp_enqueue_style('wpinv_front_style'); | 
                                                                                                            
                                                            | 206 | 206 |                  | 
                                                                                                            
                                                            | 207 | 207 |          // Register scripts | 
                                                                                                            
                                                            | 208 |  | -        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); | 
                                                                                                            
                                                            | 209 |  | -        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION ); | 
                                                                                                            
                                                            |  | 208 | +        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); | 
                                                                                                            
                                                            |  | 209 | +        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); | 
                                                                                                            
                                                            | 210 | 210 |           | 
                                                                                                            
                                                            | 211 | 211 |          $localize                         = array(); | 
                                                                                                            
                                                            | 212 |  | -        $localize['ajax_url']             = admin_url( 'admin-ajax.php' ); | 
                                                                                                            
                                                            | 213 |  | -        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' ); | 
                                                                                                            
                                                            |  | 212 | +        $localize['ajax_url']             = admin_url('admin-ajax.php'); | 
                                                                                                            
                                                            |  | 213 | +        $localize['nonce']                = wp_create_nonce('wpinv-nonce'); | 
                                                                                                            
                                                            | 214 | 214 |          $localize['currency_symbol']      = wpinv_currency_symbol(); | 
                                                                                                            
                                                            | 215 | 215 |          $localize['currency_pos']         = wpinv_currency_position(); | 
                                                                                                            
                                                            | 216 | 216 |          $localize['thousand_sep']         = wpinv_thousands_separator(); | 
                                                                                                            
                                                            | 217 | 217 |          $localize['decimal_sep']          = wpinv_decimal_separator(); | 
                                                                                                            
                                                            | 218 | 218 |          $localize['decimals']             = wpinv_decimals(); | 
                                                                                                            
                                                            | 219 | 219 |           | 
                                                                                                            
                                                            | 220 |  | -        $localize = apply_filters( 'wpinv_front_js_localize', $localize ); | 
                                                                                                            
                                                            |  | 220 | +        $localize = apply_filters('wpinv_front_js_localize', $localize); | 
                                                                                                            
                                                            | 221 | 221 |           | 
                                                                                                            
                                                            | 222 |  | -        wp_enqueue_script( 'jquery-blockui' ); | 
                                                                                                            
                                                            |  | 222 | +        wp_enqueue_script('jquery-blockui'); | 
                                                                                                            
                                                            | 223 | 223 |          $autofill_api = wpinv_get_option('address_autofill_api'); | 
                                                                                                            
                                                            | 224 | 224 |          $autofill_active = wpinv_get_option('address_autofill_active'); | 
                                                                                                            
                                                            | 225 |  | -        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { | 
                                                                                                            
                                                            | 226 |  | -            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { | 
                                                                                                            
                                                            | 227 |  | -                wp_dequeue_script( 'google-maps-api' ); | 
                                                                                                            
                                                            |  | 225 | +        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { | 
                                                                                                            
                                                            |  | 226 | +            if (wp_script_is('google-maps-api', 'enqueued')) { | 
                                                                                                            
                                                            |  | 227 | +                wp_dequeue_script('google-maps-api'); | 
                                                                                                            
                                                            | 228 | 228 |              } | 
                                                                                                            
                                                            | 229 |  | -            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); | 
                                                                                                            
                                                            | 230 |  | -            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); | 
                                                                                                            
                                                            |  | 229 | +            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); | 
                                                                                                            
                                                            |  | 230 | +            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); | 
                                                                                                            
                                                            | 231 | 231 |          } | 
                                                                                                            
                                                            | 232 |  | -        wp_enqueue_script( 'wpinv-front-script' ); | 
                                                                                                            
                                                            | 233 |  | -        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); | 
                                                                                                            
                                                            |  | 232 | +        wp_enqueue_script('wpinv-front-script'); | 
                                                                                                            
                                                            |  | 233 | +        wp_localize_script('wpinv-front-script', 'WPInv', $localize); | 
                                                                                                            
                                                            | 234 | 234 |      } | 
                                                                                                            
                                                            | 235 | 235 |   | 
                                                                                                            
                                                            | 236 | 236 |      public function admin_enqueue_scripts() { | 
                                                                                                            
                                                            | 237 | 237 |          global $post, $pagenow; | 
                                                                                                            
                                                            | 238 | 238 |           | 
                                                                                                            
                                                            | 239 | 239 |          $post_type  = wpinv_admin_post_type(); | 
                                                                                                            
                                                            | 240 |  | -        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | 
                                                                                                            
                                                            |  | 240 | +        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | 
                                                                                                            
                                                            | 241 | 241 |           | 
                                                                                                            
                                                            | 242 |  | -        wp_deregister_style( 'font-awesome' ); | 
                                                                                                            
                                                            | 243 |  | -        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); | 
                                                                                                            
                                                            | 244 |  | -        wp_enqueue_style( 'font-awesome' ); | 
                                                                                                            
                                                            |  | 242 | +        wp_deregister_style('font-awesome'); | 
                                                                                                            
                                                            |  | 243 | +        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); | 
                                                                                                            
                                                            |  | 244 | +        wp_enqueue_style('font-awesome'); | 
                                                                                                            
                                                            | 245 | 245 |           | 
                                                                                                            
                                                            | 246 | 246 |          if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { | 
                                                                                                            
                                                            | 247 |  | -            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); | 
                                                                                                            
                                                            | 248 |  | -            wp_enqueue_style( 'jquery-ui-css' ); | 
                                                                                                            
                                                            |  | 247 | +            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); | 
                                                                                                            
                                                            |  | 248 | +            wp_enqueue_style('jquery-ui-css'); | 
                                                                                                            
                                                            | 249 | 249 |          } | 
                                                                                                            
                                                            | 250 | 250 |           | 
                                                                                                            
                                                            | 251 |  | -        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' ); | 
                                                                                                            
                                                            | 252 |  | -        wp_enqueue_style( 'jquery-chosen' ); | 
                                                                                                            
                                                            |  | 251 | +        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2'); | 
                                                                                                            
                                                            |  | 252 | +        wp_enqueue_style('jquery-chosen'); | 
                                                                                                            
                                                            | 253 | 253 |   | 
                                                                                                            
                                                            | 254 |  | -        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' ); | 
                                                                                                            
                                                            | 255 |  | -        wp_enqueue_script( 'jquery-chosen' ); | 
                                                                                                            
                                                            |  | 254 | +        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2'); | 
                                                                                                            
                                                            |  | 255 | +        wp_enqueue_script('jquery-chosen'); | 
                                                                                                            
                                                            | 256 | 256 |           | 
                                                                                                            
                                                            | 257 |  | -        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); | 
                                                                                                            
                                                            | 258 |  | -        wp_enqueue_style( 'wpinv_meta_box_style' ); | 
                                                                                                            
                                                            |  | 257 | +        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); | 
                                                                                                            
                                                            |  | 258 | +        wp_enqueue_style('wpinv_meta_box_style'); | 
                                                                                                            
                                                            | 259 | 259 |           | 
                                                                                                            
                                                            | 260 |  | -        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); | 
                                                                                                            
                                                            | 261 |  | -        wp_enqueue_style( 'wpinv_admin_style' ); | 
                                                                                                            
                                                            |  | 260 | +        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); | 
                                                                                                            
                                                            |  | 261 | +        wp_enqueue_style('wpinv_admin_style'); | 
                                                                                                            
                                                            | 262 | 262 |           | 
                                                                                                            
                                                            | 263 |  | -        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { | 
                                                                                                            
                                                            | 264 |  | -            wp_enqueue_script( 'jquery-ui-datepicker' ); | 
                                                                                                            
                                                            |  | 263 | +        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { | 
                                                                                                            
                                                            |  | 264 | +            wp_enqueue_script('jquery-ui-datepicker'); | 
                                                                                                            
                                                            | 265 | 265 |          } | 
                                                                                                            
                                                            | 266 | 266 |   | 
                                                                                                            
                                                            | 267 |  | -        wp_enqueue_style( 'wp-color-picker' ); | 
                                                                                                            
                                                            | 268 |  | -        wp_enqueue_script( 'wp-color-picker' ); | 
                                                                                                            
                                                            |  | 267 | +        wp_enqueue_style('wp-color-picker'); | 
                                                                                                            
                                                            |  | 268 | +        wp_enqueue_script('wp-color-picker'); | 
                                                                                                            
                                                            | 269 | 269 |           | 
                                                                                                            
                                                            | 270 |  | -        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); | 
                                                                                                            
                                                            |  | 270 | +        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); | 
                                                                                                            
                                                            | 271 | 271 |   | 
                                                                                                            
                                                            | 272 | 272 |          if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { | 
                                                                                                            
                                                            | 273 | 273 |              $autofill_api = wpinv_get_option('address_autofill_api'); | 
                                                                                                                                                        
                                                        |  | @@ -278,17 +278,17 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 278 | 278 |              } | 
                                                                                                            
                                                            | 279 | 279 |          } | 
                                                                                                            
                                                            | 280 | 280 |   | 
                                                                                                            
                                                            | 281 |  | -        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION ); | 
                                                                                                            
                                                            | 282 |  | -        wp_enqueue_script( 'wpinv-admin-script' ); | 
                                                                                                            
                                                            |  | 281 | +        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); | 
                                                                                                            
                                                            |  | 282 | +        wp_enqueue_script('wpinv-admin-script'); | 
                                                                                                            
                                                            | 283 | 283 |           | 
                                                                                                            
                                                            | 284 | 284 |          $localize                               = array(); | 
                                                                                                            
                                                            | 285 |  | -        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' ); | 
                                                                                                            
                                                            | 286 |  | -        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : ''; | 
                                                                                                            
                                                            | 287 |  | -        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' ); | 
                                                                                                            
                                                            | 288 |  | -        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' ); | 
                                                                                                            
                                                            | 289 |  | -        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' ); | 
                                                                                                            
                                                            | 290 |  | -        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' ); | 
                                                                                                            
                                                            | 291 |  | -        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' ); | 
                                                                                                            
                                                            |  | 285 | +        $localize['ajax_url']                   = admin_url('admin-ajax.php'); | 
                                                                                                            
                                                            |  | 286 | +        $localize['post_ID']                    = isset($post->ID) ? $post->ID : ''; | 
                                                                                                            
                                                            |  | 287 | +        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce'); | 
                                                                                                            
                                                            |  | 288 | +        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note'); | 
                                                                                                            
                                                            |  | 289 | +        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note'); | 
                                                                                                            
                                                            |  | 290 | +        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item'); | 
                                                                                                            
                                                            |  | 291 | +        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details'); | 
                                                                                                            
                                                            | 292 | 292 |          $localize['tax']                        = wpinv_tax_amount(); | 
                                                                                                            
                                                            | 293 | 293 |          $localize['discount']                   = wpinv_discount_amount(); | 
                                                                                                            
                                                            | 294 | 294 |          $localize['currency_symbol']            = wpinv_currency_symbol(); | 
                                                                                                                                                        
                                                        |  | @@ -296,60 +296,60 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 296 | 296 |          $localize['thousand_sep']               = wpinv_thousands_separator(); | 
                                                                                                            
                                                            | 297 | 297 |          $localize['decimal_sep']                = wpinv_decimal_separator(); | 
                                                                                                            
                                                            | 298 | 298 |          $localize['decimals']                   = wpinv_decimals(); | 
                                                                                                            
                                                            | 299 |  | -        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' ); | 
                                                                                                            
                                                            | 300 |  | -        $localize['status_publish']             = wpinv_status_nicename( 'publish' ); | 
                                                                                                            
                                                            | 301 |  | -        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' ); | 
                                                                                                            
                                                            | 302 |  | -        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); | 
                                                                                                            
                                                            | 303 |  | -        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' ); | 
                                                                                                            
                                                            | 304 |  | -        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' ); | 
                                                                                                            
                                                            | 305 |  | -        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); | 
                                                                                                            
                                                            | 306 |  | -        $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' ); | 
                                                                                                            
                                                            | 307 |  | -        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' ); | 
                                                                                                            
                                                            | 308 |  | -        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); | 
                                                                                                            
                                                            |  | 299 | +        $localize['save_invoice']               = __('Save Invoice', 'invoicing'); | 
                                                                                                            
                                                            |  | 300 | +        $localize['status_publish']             = wpinv_status_nicename('publish'); | 
                                                                                                            
                                                            |  | 301 | +        $localize['status_pending']             = wpinv_status_nicename('wpi-pending'); | 
                                                                                                            
                                                            |  | 302 | +        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing'); | 
                                                                                                            
                                                            |  | 303 | +        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing'); | 
                                                                                                            
                                                            |  | 304 | +        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing'); | 
                                                                                                            
                                                            |  | 305 | +        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); | 
                                                                                                            
                                                            |  | 306 | +        $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'); | 
                                                                                                            
                                                            |  | 307 | +        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing'); | 
                                                                                                            
                                                            |  | 308 | +        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); | 
                                                                                                            
                                                            | 309 | 309 |   | 
                                                                                                            
                                                            | 310 |  | -        $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); | 
                                                                                                            
                                                            |  | 310 | +        $localize = apply_filters('wpinv_admin_js_localize', $localize); | 
                                                                                                            
                                                            | 311 | 311 |   | 
                                                                                                            
                                                            | 312 |  | -        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); | 
                                                                                                            
                                                            |  | 312 | +        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); | 
                                                                                                            
                                                            | 313 | 313 |      } | 
                                                                                                            
                                                            | 314 | 314 |       | 
                                                                                                            
                                                            | 315 |  | -    public function admin_body_class( $classes ) { | 
                                                                                                            
                                                            |  | 315 | +    public function admin_body_class($classes) { | 
                                                                                                            
                                                            | 316 | 316 |          global $pagenow, $post, $current_screen; | 
                                                                                                            
                                                            | 317 | 317 |           | 
                                                                                                            
                                                            | 318 |  | -        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { | 
                                                                                                            
                                                            |  | 318 | +        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { | 
                                                                                                            
                                                            | 319 | 319 |              $classes .= ' wpinv-cpt'; | 
                                                                                                            
                                                            | 320 | 320 |          } | 
                                                                                                            
                                                            | 321 | 321 |           | 
                                                                                                            
                                                            | 322 |  | -        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; | 
                                                                                                            
                                                            |  | 322 | +        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; | 
                                                                                                            
                                                            | 323 | 323 |   | 
                                                                                                            
                                                            | 324 | 324 |          $add_class = false; | 
                                                                                                            
                                                            | 325 |  | -        if ( $pagenow == 'admin.php' && $page ) { | 
                                                                                                            
                                                            | 326 |  | -            $add_class = strpos( $page, 'wpinv-' ); | 
                                                                                                            
                                                            |  | 325 | +        if ($pagenow == 'admin.php' && $page) { | 
                                                                                                            
                                                            |  | 326 | +            $add_class = strpos($page, 'wpinv-'); | 
                                                                                                            
                                                            | 327 | 327 |          } | 
                                                                                                            
                                                            | 328 | 328 |           | 
                                                                                                            
                                                            | 329 | 329 |          $settings_class = array(); | 
                                                                                                            
                                                            | 330 |  | -        if ( $page == 'wpinv-settings' ) { | 
                                                                                                            
                                                            | 331 |  | -            if ( !empty( $_REQUEST['tab'] ) ) { | 
                                                                                                            
                                                            | 332 |  | -                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); | 
                                                                                                            
                                                            |  | 330 | +        if ($page == 'wpinv-settings') { | 
                                                                                                            
                                                            |  | 331 | +            if (!empty($_REQUEST['tab'])) { | 
                                                                                                            
                                                            |  | 332 | +                $settings_class[] = sanitize_text_field($_REQUEST['tab']); | 
                                                                                                            
                                                            | 333 | 333 |              } | 
                                                                                                            
                                                            | 334 | 334 |               | 
                                                                                                            
                                                            | 335 |  | -            if ( !empty( $_REQUEST['section'] ) ) { | 
                                                                                                            
                                                            | 336 |  | -                $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); | 
                                                                                                            
                                                            |  | 335 | +            if (!empty($_REQUEST['section'])) { | 
                                                                                                            
                                                            |  | 336 | +                $settings_class[] = sanitize_text_field($_REQUEST['section']); | 
                                                                                                            
                                                            | 337 | 337 |              } | 
                                                                                                            
                                                            | 338 | 338 |               | 
                                                                                                            
                                                            | 339 |  | -            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; | 
                                                                                                            
                                                            |  | 339 | +            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; | 
                                                                                                            
                                                            | 340 | 340 |          } | 
                                                                                                            
                                                            | 341 | 341 |           | 
                                                                                                            
                                                            | 342 |  | -        if ( !empty( $settings_class ) ) { | 
                                                                                                            
                                                            | 343 |  | -            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); | 
                                                                                                            
                                                            |  | 342 | +        if (!empty($settings_class)) { | 
                                                                                                            
                                                            |  | 343 | +            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); | 
                                                                                                            
                                                            | 344 | 344 |          } | 
                                                                                                            
                                                            | 345 | 345 |           | 
                                                                                                            
                                                            | 346 | 346 |          $post_type = wpinv_admin_post_type(); | 
                                                                                                            
                                                            | 347 | 347 |   | 
                                                                                                            
                                                            | 348 |  | -        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { | 
                                                                                                            
                                                            |  | 348 | +        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { | 
                                                                                                            
                                                            | 349 | 349 |              return $classes .= ' wpinv'; | 
                                                                                                            
                                                            | 350 | 350 |          } | 
                                                                                                            
                                                            | 351 | 351 |           | 
                                                                                                            
                                                            | 352 |  | -        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { | 
                                                                                                            
                                                            |  | 352 | +        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { | 
                                                                                                            
                                                            | 353 | 353 |              $classes .= ' wpi-editable-n'; | 
                                                                                                            
                                                            | 354 | 354 |          } | 
                                                                                                            
                                                            | 355 | 355 |   | 
                                                                                                                                                        
                                                        |  | @@ -361,20 +361,20 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 361 | 361 |      } | 
                                                                                                            
                                                            | 362 | 362 |       | 
                                                                                                            
                                                            | 363 | 363 |      public function wpinv_actions() { | 
                                                                                                            
                                                            | 364 |  | -        if ( isset( $_REQUEST['wpi_action'] ) ) { | 
                                                                                                            
                                                            | 365 |  | -            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); | 
                                                                                                            
                                                            |  | 364 | +        if (isset($_REQUEST['wpi_action'])) { | 
                                                                                                            
                                                            |  | 365 | +            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); | 
                                                                                                            
                                                            | 366 | 366 |          } | 
                                                                                                            
                                                            | 367 | 367 |      } | 
                                                                                                            
                                                            | 368 | 368 |       | 
                                                                                                            
                                                            | 369 |  | -    public function pre_get_posts( $wp_query ) { | 
                                                                                                            
                                                            | 370 |  | -        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() ) { | 
                                                                                                            
                                                            | 371 |  | -            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); | 
                                                                                                            
                                                            |  | 369 | +    public function pre_get_posts($wp_query) { | 
                                                                                                            
                                                            |  | 370 | +        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()) { | 
                                                                                                            
                                                            |  | 371 | +            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); | 
                                                                                                            
                                                            | 372 | 372 |          } | 
                                                                                                            
                                                            | 373 | 373 |           | 
                                                                                                            
                                                            | 374 | 374 |          return $wp_query; | 
                                                                                                            
                                                            | 375 | 375 |      } | 
                                                                                                            
                                                            | 376 | 376 |       | 
                                                                                                            
                                                            | 377 | 377 |      public function bp_invoicing_init() { | 
                                                                                                            
                                                            | 378 |  | -        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); | 
                                                                                                            
                                                            |  | 378 | +        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); | 
                                                                                                            
                                                            | 379 | 379 |      } | 
                                                                                                            
                                                            | 380 | 380 |  } | 
                                                                                                            
                                                            | 381 | 381 | \ No newline at end of file |