@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // MUST have WordPress. |
| 14 | -if ( !defined( 'WPINC' ) ) { |
|
| 15 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 14 | +if (!defined('WPINC')) { |
|
| 15 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
| 19 | - define( 'WPINV_VERSION', '0.0.41' ); |
|
| 18 | +if (!defined('WPINV_VERSION')) { |
|
| 19 | + define('WPINV_VERSION', '0.0.41'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
| 23 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
| 23 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
| 26 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
| 27 | 27 | |
| 28 | 28 | function wpinv_run() { |
| 29 | 29 | global $invoicing; |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * Show update plugin admin notification. |
| 42 | 42 | */ |
| 43 | -if(is_admin()){ |
|
| 43 | +if (is_admin()) { |
|
| 44 | 44 | if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed |
| 45 | 45 | function ayecode_show_update_plugin_requirement() { |
| 46 | - if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
| 46 | + if (!defined('WP_EASY_UPDATES_ACTIVE')) { |
|
| 47 | 47 | ?> |
| 48 | 48 | <div class="notice notice-warning is-dismissible"> |
| 49 | 49 | <p> |
| 50 | 50 | <strong> |
| 51 | 51 | <?php |
| 52 | - echo sprintf( __( 'The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory' ), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>' ); |
|
| 52 | + echo sprintf(__('The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory'), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>'); |
|
| 53 | 53 | ?> |
| 54 | 54 | </strong> |
| 55 | 55 | </p> |
@@ -58,6 +58,6 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - add_action( 'admin_notices', 'ayecode_show_update_plugin_requirement' ); |
|
| 61 | + add_action('admin_notices', 'ayecode_show_update_plugin_requirement'); |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -23,7 +23,7 @@ discard block |
||
| 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,33 +33,33 @@ discard block |
||
| 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_filter( 'geodir_googlemap_script_extra', array( &$this,'add_google_maps_places_lib'), 101, 1 ); |
|
| 54 | + add_filter('geodir_googlemap_script_extra', array(&$this, 'add_google_maps_places_lib'), 101, 1); |
|
| 55 | 55 | |
| 56 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 56 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 57 | 57 | |
| 58 | - if ( is_admin() ) { |
|
| 59 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 60 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 58 | + if (is_admin()) { |
|
| 59 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 60 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 61 | 61 | } else { |
| 62 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 62 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 71 | 71 | */ |
| 72 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 72 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 73 | 73 | |
| 74 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 74 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function plugins_loaded() { |
@@ -85,157 +85,157 @@ discard block |
||
| 85 | 85 | * @since 1.0 |
| 86 | 86 | */ |
| 87 | 87 | public function load_textdomain() { |
| 88 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' ); |
|
| 88 | + $locale = apply_filters('plugin_locale', get_locale(), 'invoicing'); |
|
| 89 | 89 | |
| 90 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 91 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 90 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 91 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * Define language constants. |
| 95 | 95 | */ |
| 96 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 96 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function includes() { |
| 100 | 100 | global $wpinv_options; |
| 101 | 101 | |
| 102 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 102 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 103 | 103 | $wpinv_options = wpinv_get_settings(); |
| 104 | 104 | |
| 105 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 106 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 107 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' ); |
|
| 119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 105 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 106 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 107 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php'); |
|
| 119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 120 | 120 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
| 121 | 121 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
| 122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 123 | 123 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); |
| 124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
| 127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
| 131 | - if ( !class_exists( 'Geodir_EUVat' ) ) { |
|
| 132 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
| 131 | + if (!class_exists('Geodir_EUVat')) { |
|
| 132 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 136 | - if ( !empty( $gateways ) ) { |
|
| 137 | - foreach ( $gateways as $gateway ) { |
|
| 138 | - if ( $gateway == 'manual' ) { |
|
| 135 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 136 | + if (!empty($gateways)) { |
|
| 137 | + foreach ($gateways as $gateway) { |
|
| 138 | + if ($gateway == 'manual') { |
|
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 143 | 143 | |
| 144 | - if ( file_exists( $gateway_file ) ) { |
|
| 145 | - require_once( $gateway_file ); |
|
| 144 | + if (file_exists($gateway_file)) { |
|
| 145 | + require_once($gateway_file); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 149 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 150 | 150 | |
| 151 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 153 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 151 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 153 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 155 | 155 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 160 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 160 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 161 | 161 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // include css inliner |
| 165 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 166 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 165 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 166 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | public function init() { |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function admin_init() { |
| 176 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
| 176 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 179 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function activation_redirect() { |
| 183 | 183 | // Bail if no activation redirect |
| 184 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 184 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 185 | 185 | return; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Delete the redirect transient |
| 189 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 189 | + delete_transient('_wpinv_activation_redirect'); |
|
| 190 | 190 | |
| 191 | 191 | // Bail if activating from network, or bulk |
| 192 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 192 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 196 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 197 | 197 | exit; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | public function enqueue_scripts() { |
| 201 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 201 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 202 | 202 | |
| 203 | - wp_deregister_style( 'font-awesome' ); |
|
| 204 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 205 | - wp_enqueue_style( 'font-awesome' ); |
|
| 203 | + wp_deregister_style('font-awesome'); |
|
| 204 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 205 | + wp_enqueue_style('font-awesome'); |
|
| 206 | 206 | |
| 207 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 208 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 207 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 208 | + wp_enqueue_style('wpinv_front_style'); |
|
| 209 | 209 | |
| 210 | 210 | // Register scripts |
| 211 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 212 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
| 211 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 212 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
| 213 | 213 | |
| 214 | 214 | $localize = array(); |
| 215 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 216 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 215 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 216 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 217 | 217 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 218 | 218 | $localize['currency_pos'] = wpinv_currency_position(); |
| 219 | 219 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 220 | 220 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 221 | 221 | $localize['decimals'] = wpinv_decimals(); |
| 222 | 222 | |
| 223 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 223 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 224 | 224 | |
| 225 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 225 | + wp_enqueue_script('jquery-blockui'); |
|
| 226 | 226 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 227 | 227 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 228 | 228 | if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
| 229 | 229 | |
| 230 | 230 | // we don't need this if GD is installed. |
| 231 | - if(!function_exists('geodir_templates_scripts')){ |
|
| 231 | + if (!function_exists('geodir_templates_scripts')) { |
|
| 232 | 232 | wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
| 233 | 233 | } |
| 234 | - wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery','google-maps-api'), '', true); |
|
| 234 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 235 | 235 | |
| 236 | 236 | } |
| 237 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 238 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 237 | + wp_enqueue_script('wpinv-front-script'); |
|
| 238 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | * @since 1.0.0 |
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | - public function add_google_maps_places_lib( $extra ) { |
|
| 248 | + public function add_google_maps_places_lib($extra) { |
|
| 249 | 249 | |
| 250 | - if ( wpinv_is_checkout() && ! str_replace( 'libraries=places', '', $extra ) ) { |
|
| 250 | + if (wpinv_is_checkout() && !str_replace('libraries=places', '', $extra)) { |
|
| 251 | 251 | $extra .= "&libraries=places"; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -258,35 +258,35 @@ discard block |
||
| 258 | 258 | global $post, $pagenow; |
| 259 | 259 | |
| 260 | 260 | $post_type = wpinv_admin_post_type(); |
| 261 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 261 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 262 | 262 | |
| 263 | - wp_deregister_style( 'font-awesome' ); |
|
| 264 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 265 | - wp_enqueue_style( 'font-awesome' ); |
|
| 263 | + wp_deregister_style('font-awesome'); |
|
| 264 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 265 | + wp_enqueue_style('font-awesome'); |
|
| 266 | 266 | |
| 267 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 268 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 267 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 268 | + wp_enqueue_style('jquery-ui-css'); |
|
| 269 | 269 | |
| 270 | - wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' ); |
|
| 271 | - wp_enqueue_style( 'jquery-chosen' ); |
|
| 270 | + wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2'); |
|
| 271 | + wp_enqueue_style('jquery-chosen'); |
|
| 272 | 272 | |
| 273 | - wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' ); |
|
| 274 | - wp_enqueue_script( 'jquery-chosen' ); |
|
| 273 | + wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2'); |
|
| 274 | + wp_enqueue_script('jquery-chosen'); |
|
| 275 | 275 | |
| 276 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 277 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 276 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 277 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 278 | 278 | |
| 279 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 280 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 279 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 280 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 281 | 281 | |
| 282 | - if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 283 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 282 | + if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 283 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 287 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 286 | + wp_enqueue_style('wp-color-picker'); |
|
| 287 | + wp_enqueue_script('wp-color-picker'); |
|
| 288 | 288 | |
| 289 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 289 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 290 | 290 | |
| 291 | 291 | if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 292 | 292 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -297,17 +297,17 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 301 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 300 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 301 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 302 | 302 | |
| 303 | 303 | $localize = array(); |
| 304 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 305 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 306 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 307 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 308 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 309 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 310 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 304 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 305 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 306 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 307 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 308 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 309 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 310 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 311 | 311 | $localize['tax'] = wpinv_tax_amount(); |
| 312 | 312 | $localize['discount'] = wpinv_discount_amount(); |
| 313 | 313 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -315,65 +315,65 @@ discard block |
||
| 315 | 315 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 316 | 316 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 317 | 317 | $localize['decimals'] = wpinv_decimals(); |
| 318 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 319 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 320 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 321 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 322 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 323 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 324 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 325 | - $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' ); |
|
| 326 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 318 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 319 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 320 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 321 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 322 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 323 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 324 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 325 | + $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'); |
|
| 326 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 327 | 327 | $localize['hasGD'] = wpinv_gd_active(); |
| 328 | 328 | $localize['hasPM'] = wpinv_pm_active(); |
| 329 | - $localize['emptyInvoice'] = __( 'Add atleast one item to save invoice!', 'invoicing' ); |
|
| 330 | - $localize['deletePackage'] = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' ); |
|
| 331 | - $localize['deletePackages'] = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' ); |
|
| 332 | - $localize['deleteInvoiceFirst'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 329 | + $localize['emptyInvoice'] = __('Add atleast one item to save invoice!', 'invoicing'); |
|
| 330 | + $localize['deletePackage'] = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing'); |
|
| 331 | + $localize['deletePackages'] = __('GD package items should be deleted from GD payment manager only', 'invoicing'); |
|
| 332 | + $localize['deleteInvoiceFirst'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 333 | 333 | |
| 334 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 334 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 335 | 335 | |
| 336 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 336 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - public function admin_body_class( $classes ) { |
|
| 339 | + public function admin_body_class($classes) { |
|
| 340 | 340 | global $pagenow, $post, $current_screen; |
| 341 | 341 | |
| 342 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 342 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 343 | 343 | $classes .= ' wpinv-cpt'; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 346 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 347 | 347 | |
| 348 | 348 | $add_class = false; |
| 349 | - if ( $pagenow == 'admin.php' && $page ) { |
|
| 350 | - $add_class = strpos( $page, 'wpinv-' ); |
|
| 349 | + if ($pagenow == 'admin.php' && $page) { |
|
| 350 | + $add_class = strpos($page, 'wpinv-'); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $settings_class = array(); |
| 354 | - if ( $page == 'wpinv-settings' ) { |
|
| 355 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 356 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 354 | + if ($page == 'wpinv-settings') { |
|
| 355 | + if (!empty($_REQUEST['tab'])) { |
|
| 356 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 360 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 359 | + if (!empty($_REQUEST['section'])) { |
|
| 360 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 363 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if ( !empty( $settings_class ) ) { |
|
| 367 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 366 | + if (!empty($settings_class)) { |
|
| 367 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $post_type = wpinv_admin_post_type(); |
| 371 | 371 | |
| 372 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 372 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 373 | 373 | return $classes .= ' wpinv'; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 376 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 377 | 377 | $classes .= ' wpi-editable-n'; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -385,20 +385,20 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | public function wpinv_actions() { |
| 388 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 389 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 388 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 389 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - public function pre_get_posts( $wp_query ) { |
|
| 394 | - 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() ) { |
|
| 395 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 393 | + public function pre_get_posts($wp_query) { |
|
| 394 | + 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()) { |
|
| 395 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | return $wp_query; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | public function bp_invoicing_init() { |
| 402 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 402 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | \ No newline at end of file |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | set_transient('_wpinv_activation_redirect', true, 30); |
| 8 | 8 | wpinv_install($network_wide); |
| 9 | 9 | |
| 10 | - if(!wpinv_get_option('address_autofill_api') && $api_key = get_option('geodir_google_api_key')){ |
|
| 11 | - wpinv_update_option( 'address_autofill_api', $api_key); |
|
| 10 | + if (!wpinv_get_option('address_autofill_api') && $api_key = get_option('geodir_google_api_key')) { |
|
| 11 | + wpinv_update_option('address_autofill_api', $api_key); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Billing_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $user_ID; |
| 10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 11 | + $invoice = new WPInv_Invoice($post_id); |
|
| 12 | 12 | ?> |
| 13 | 13 | <div class="gdmbx2-wrap form-table"> |
| 14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
| 15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
| 16 | 16 | <div class="gdmbx-th"> |
| 17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
| 20 | - <?php wpinv_dropdown_users( array( |
|
| 20 | + <?php wpinv_dropdown_users(array( |
|
| 21 | 21 | 'name' => 'post_author_override', |
| 22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 23 | 23 | 'include_selected' => true, |
| 24 | 24 | 'show' => 'user_email', |
| 25 | 25 | 'orderby' => 'user_email', |
| 26 | 26 | 'class' => 'gdmbx2-text-large' |
| 27 | - ) ); ?> |
|
| 27 | + )); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
| 31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
| 31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="gdmbx-td"> |
| 34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,58 +36,58 @@ discard block |
||
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
| 39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
| 39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
| 40 | 40 | </div> |
| 41 | - <?php if($invoice->has_status(array('auto-draft', 'wpi-pending', 'wpi-quote-pending'))){ ?> |
|
| 41 | + <?php if ($invoice->has_status(array('auto-draft', 'wpi-pending', 'wpi-quote-pending'))) { ?> |
|
| 42 | 42 | <div class="gdmbx-td"> |
| 43 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
| 44 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
| 45 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
| 43 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
| 44 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
| 45 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
| 46 | 46 | </div> |
| 47 | 47 | <?php } ?> |
| 48 | 48 | </div> |
| 49 | 49 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
| 50 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
| 50 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
| 51 | 51 | <div class="gdmbx-td"> |
| 52 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
| 52 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
| 53 | 53 | </div> |
| 54 | 54 | </div> |
| 55 | 55 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
| 56 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
| 56 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
| 57 | 57 | <div class="gdmbx-td"> |
| 58 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
| 58 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
| 59 | 59 | </div> |
| 60 | 60 | </div> |
| 61 | 61 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
| 62 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
| 62 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
| 63 | 63 | <div class="gdmbx-td"> |
| 64 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
| 64 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
| 65 | 65 | </div> |
| 66 | 66 | </div> |
| 67 | 67 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
| 68 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
| 68 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
| 69 | 69 | <div class="gdmbx-td"> |
| 70 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
| 70 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
| 71 | 71 | </div> |
| 72 | 72 | </div> |
| 73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
| 74 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
| 74 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
| 75 | 75 | <div class="gdmbx-td"> |
| 76 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
| 76 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
| 77 | 77 | </div> |
| 78 | 78 | </div> |
| 79 | 79 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
| 80 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
| 80 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
| 81 | 81 | <div class="gdmbx-td"> |
| 82 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
| 82 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
| 83 | 83 | </div> |
| 84 | 84 | </div> |
| 85 | 85 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
| 86 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 86 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 87 | 87 | <div class="gdmbx-td"> |
| 88 | 88 | <?php |
| 89 | - echo wpinv_html_select( array( |
|
| 90 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
| 89 | + echo wpinv_html_select(array( |
|
| 90 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
| 91 | 91 | 'name' => 'wpinv_country', |
| 92 | 92 | 'id' => 'wpinv_country', |
| 93 | 93 | 'selected' => $invoice->country, |
@@ -95,20 +95,20 @@ discard block |
||
| 95 | 95 | 'show_option_none' => false, |
| 96 | 96 | 'class' => 'gdmbx2-text-large', |
| 97 | 97 | 'chosen' => false, |
| 98 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 98 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 99 | 99 | 'required' => false, |
| 100 | - ) ); |
|
| 100 | + )); |
|
| 101 | 101 | ?> |
| 102 | 102 | </div> |
| 103 | 103 | </div> |
| 104 | 104 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
| 105 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
| 105 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
| 106 | 106 | <div class="gdmbx-td"> |
| 107 | 107 | <?php |
| 108 | - $states = wpinv_get_country_states( $invoice->country ); |
|
| 109 | - if( !empty( $states ) ) { |
|
| 110 | - echo wpinv_html_select( array( |
|
| 111 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
| 108 | + $states = wpinv_get_country_states($invoice->country); |
|
| 109 | + if (!empty($states)) { |
|
| 110 | + echo wpinv_html_select(array( |
|
| 111 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
| 112 | 112 | 'name' => 'wpinv_state', |
| 113 | 113 | 'id' => 'wpinv_state', |
| 114 | 114 | 'selected' => $invoice->state, |
@@ -116,44 +116,44 @@ discard block |
||
| 116 | 116 | 'show_option_none' => false, |
| 117 | 117 | 'class' => 'gdmbx2-text-large', |
| 118 | 118 | 'chosen' => false, |
| 119 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 119 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 120 | 120 | 'required' => false, |
| 121 | - ) ); |
|
| 121 | + )); |
|
| 122 | 122 | } else { |
| 123 | - echo wpinv_html_text( array( |
|
| 123 | + echo wpinv_html_text(array( |
|
| 124 | 124 | 'name' => 'wpinv_state', |
| 125 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
| 125 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
| 126 | 126 | 'id' => 'wpinv_state', |
| 127 | 127 | 'class' => 'gdmbx2-text-large', |
| 128 | 128 | 'required' => false, |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | } |
| 131 | 131 | ?> |
| 132 | 132 | </div> |
| 133 | 133 | </div> |
| 134 | 134 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
| 135 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
| 135 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
| 136 | 136 | <div class="gdmbx-td"> |
| 137 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
| 137 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
| 138 | 138 | </div> |
| 139 | 139 | </div> |
| 140 | 140 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
| 141 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
| 141 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
| 142 | 142 | <div class="gdmbx-td"> |
| 143 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
| 143 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
| 144 | 144 | </div> |
| 145 | 145 | </div> |
| 146 | 146 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
| 147 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
| 148 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 147 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
| 148 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 149 | 149 | <?php } ?></label></div> |
| 150 | 150 | <div class="gdmbx-td"> |
| 151 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
| 151 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
| 152 | 152 | </div> |
| 153 | 153 | </div> |
| 154 | 154 | </div> |
| 155 | 155 | </div> |
| 156 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
| 156 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
| 157 | 157 | <?php |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -1,56 +1,56 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined('ABSPATH') ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
| 5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
| 6 | 6 | <html <?php language_attributes(); ?>> |
| 7 | 7 | <head> |
| 8 | 8 | <meta charset="UTF-8"> |
| 9 | 9 | <title><?php wp_title() ?></title> |
| 10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
| 10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
| 11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 12 | 12 | <meta name="robots" content="noindex,nofollow"> |
| 13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
| 13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
| 14 | 14 | </head> |
| 15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
| 16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
| 16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
| 17 | 17 | <div class="container wpinv-wrap"> |
| 18 | 18 | <!-- ///// Start Header --> |
| 19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
| 20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
| 20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
| 21 | 21 | <div class="row wpinv-header"> |
| 22 | 22 | <div class="col-xs-12 wpinv-business"> |
| 23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
| 24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
| 25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
| 23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
| 24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
| 25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
| 26 | 26 | <?php } else { ?> |
| 27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
| 27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
| 28 | 28 | <?php } ?> |
| 29 | 29 | </a> |
| 30 | 30 | </div> |
| 31 | 31 | </div> |
| 32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
| 32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
| 33 | 33 | </htmlpageheader> |
| 34 | 34 | <!-- End Header ///// --> |
| 35 | 35 | |
| 36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
| 36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
| 37 | 37 | |
| 38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
| 38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
| 39 | 39 | |
| 40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
| 40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
| 41 | 41 | |
| 42 | 42 | <!-- ///// Start Footer --> |
| 43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
| 44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
| 44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
| 45 | 45 | <div class="row wpinv-footer"> |
| 46 | 46 | <div class="col-sm-12"> |
| 47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
| 50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
| 50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
| 51 | 51 | </htmlpagefooter> |
| 52 | 52 | <!-- End Footer ///// --> |
| 53 | 53 | </div> |
| 54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
| 54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
| 55 | 55 | </body> |
| 56 | 56 | </html> |
| 57 | 57 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -function wpinv_get_subscriptions( $args = array() ) { |
|
| 3 | - if ( empty( $args['parent_invoice_id'] ) ) { |
|
| 2 | +function wpinv_get_subscriptions($args = array()) { |
|
| 3 | + if (empty($args['parent_invoice_id'])) { |
|
| 4 | 4 | return false; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | $args['post_parent'] = $args['parent_invoice_id']; |
| 17 | - $args = wp_parse_args( $args, $defaults ); |
|
| 17 | + $args = wp_parse_args($args, $defaults); |
|
| 18 | 18 | |
| 19 | - if( $args['numberposts'] < 1 ) { |
|
| 19 | + if ($args['numberposts'] < 1) { |
|
| 20 | 20 | $args['numberposts'] = 999999999999; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $posts = get_posts( $args ); |
|
| 23 | + $posts = get_posts($args); |
|
| 24 | 24 | $subscriptions = array(); |
| 25 | - if ( !empty( $posts ) ) { |
|
| 26 | - foreach ( $posts as $post ) { |
|
| 27 | - if ( !empty( $post->ID ) ) { |
|
| 28 | - $subscriptions[] = wpinv_get_invoice( $post->ID ); |
|
| 25 | + if (!empty($posts)) { |
|
| 26 | + foreach ($posts as $post) { |
|
| 27 | + if (!empty($post->ID)) { |
|
| 28 | + $subscriptions[] = wpinv_get_invoice($post->ID); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | return $subscriptions; |
| 35 | 35 | } |
| 36 | -function wpinv_get_subscription( $id = 0, $by_profile_id = false ) { |
|
| 36 | +function wpinv_get_subscription($id = 0, $by_profile_id = false) { |
|
| 37 | 37 | global $wpdb; |
| 38 | 38 | |
| 39 | - if ( empty( $id ) ) { |
|
| 39 | + if (empty($id)) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $id = esc_sql( $id ); |
|
| 43 | + $id = esc_sql($id); |
|
| 44 | 44 | |
| 45 | - $invoice_id = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1" ); |
|
| 45 | + $invoice_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1"); |
|
| 46 | 46 | |
| 47 | - if ( $invoice_id != null ) { |
|
| 48 | - return wpinv_get_invoice( $invoice_id ); |
|
| 47 | + if ($invoice_id != null) { |
|
| 48 | + return wpinv_get_invoice($invoice_id); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return false; |
@@ -55,46 +55,46 @@ discard block |
||
| 55 | 55 | * Records a new payment on the subscription |
| 56 | 56 | * |
| 57 | 57 | */ |
| 58 | -function wpinv_recurring_add_subscription_payment( $parent_invoice_id, $subscription_args = array() ) { |
|
| 59 | - $args = wp_parse_args( $subscription_args, array( |
|
| 58 | +function wpinv_recurring_add_subscription_payment($parent_invoice_id, $subscription_args = array()) { |
|
| 59 | + $args = wp_parse_args($subscription_args, array( |
|
| 60 | 60 | 'amount' => '', |
| 61 | 61 | 'transaction_id' => '', |
| 62 | 62 | 'gateway' => '' |
| 63 | - ) ); |
|
| 63 | + )); |
|
| 64 | 64 | |
| 65 | - if ( wpinv_payment_exists( $args['transaction_id'] ) ) { |
|
| 65 | + if (wpinv_payment_exists($args['transaction_id'])) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $parent_invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
| 70 | - if ( empty( $parent_invoice ) ) { |
|
| 69 | + $parent_invoice = wpinv_get_invoice($parent_invoice_id); |
|
| 70 | + if (empty($parent_invoice)) { |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $invoice = new WPInv_Invoice(); |
| 75 | - $invoice->set( 'parent_invoice', $parent_invoice_id ); |
|
| 76 | - $invoice->set( 'currency', $parent_invoice->get_currency() ); |
|
| 77 | - $invoice->set( 'transaction_id', $args['transaction_id'] ); |
|
| 78 | - $invoice->set( 'key', $parent_invoice->generate_key() ); |
|
| 79 | - $invoice->set( 'ip', $parent_invoice->ip ); |
|
| 80 | - $invoice->set( 'user_id', $parent_invoice->get_user_id() ); |
|
| 81 | - $invoice->set( 'first_name', $parent_invoice->get_first_name() ); |
|
| 82 | - $invoice->set( 'last_name', $parent_invoice->get_last_name() ); |
|
| 83 | - $invoice->set( 'phone', $parent_invoice->phone ); |
|
| 84 | - $invoice->set( 'address', $parent_invoice->address ); |
|
| 85 | - $invoice->set( 'city', $parent_invoice->city ); |
|
| 86 | - $invoice->set( 'country', $parent_invoice->country ); |
|
| 87 | - $invoice->set( 'state', $parent_invoice->state ); |
|
| 88 | - $invoice->set( 'zip', $parent_invoice->zip ); |
|
| 89 | - $invoice->set( 'company', $parent_invoice->company ); |
|
| 90 | - $invoice->set( 'vat_number', $parent_invoice->vat_number ); |
|
| 91 | - $invoice->set( 'vat_rate', $parent_invoice->vat_rate ); |
|
| 92 | - $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed ); |
|
| 93 | - |
|
| 94 | - if ( empty( $args['gateway'] ) ) { |
|
| 95 | - $invoice->set( 'gateway', $parent_invoice->get_gateway() ); |
|
| 75 | + $invoice->set('parent_invoice', $parent_invoice_id); |
|
| 76 | + $invoice->set('currency', $parent_invoice->get_currency()); |
|
| 77 | + $invoice->set('transaction_id', $args['transaction_id']); |
|
| 78 | + $invoice->set('key', $parent_invoice->generate_key()); |
|
| 79 | + $invoice->set('ip', $parent_invoice->ip); |
|
| 80 | + $invoice->set('user_id', $parent_invoice->get_user_id()); |
|
| 81 | + $invoice->set('first_name', $parent_invoice->get_first_name()); |
|
| 82 | + $invoice->set('last_name', $parent_invoice->get_last_name()); |
|
| 83 | + $invoice->set('phone', $parent_invoice->phone); |
|
| 84 | + $invoice->set('address', $parent_invoice->address); |
|
| 85 | + $invoice->set('city', $parent_invoice->city); |
|
| 86 | + $invoice->set('country', $parent_invoice->country); |
|
| 87 | + $invoice->set('state', $parent_invoice->state); |
|
| 88 | + $invoice->set('zip', $parent_invoice->zip); |
|
| 89 | + $invoice->set('company', $parent_invoice->company); |
|
| 90 | + $invoice->set('vat_number', $parent_invoice->vat_number); |
|
| 91 | + $invoice->set('vat_rate', $parent_invoice->vat_rate); |
|
| 92 | + $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed); |
|
| 93 | + |
|
| 94 | + if (empty($args['gateway'])) { |
|
| 95 | + $invoice->set('gateway', $parent_invoice->get_gateway()); |
|
| 96 | 96 | } else { |
| 97 | - $invoice->set( 'gateway', $args['gateway'] ); |
|
| 97 | + $invoice->set('gateway', $args['gateway']); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $recurring_details = $parent_invoice->get_recurring_details(); |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | // increase the earnings for each item in the subscription |
| 103 | 103 | $items = $recurring_details['cart_details']; |
| 104 | 104 | |
| 105 | - if ( $items ) { |
|
| 105 | + if ($items) { |
|
| 106 | 106 | $add_items = array(); |
| 107 | 107 | $cart_details = array(); |
| 108 | 108 | |
| 109 | - foreach ( $items as $item ) { |
|
| 109 | + foreach ($items as $item) { |
|
| 110 | 110 | $add_item = array(); |
| 111 | 111 | $add_item['id'] = $item['id']; |
| 112 | 112 | $add_item['quantity'] = $item['quantity']; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $invoice->set( 'items', $add_items ); |
|
| 119 | + $invoice->set('items', $add_items); |
|
| 120 | 120 | $invoice->cart_details = $cart_details; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -126,277 +126,277 @@ discard block |
||
| 126 | 126 | $tax = $recurring_details['tax']; |
| 127 | 127 | $discount = $recurring_details['discount']; |
| 128 | 128 | |
| 129 | - if ( $discount > 0 ) { |
|
| 130 | - $invoice->set( 'discount_code', $parent_invoice->discount_code ); |
|
| 129 | + if ($discount > 0) { |
|
| 130 | + $invoice->set('discount_code', $parent_invoice->discount_code); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $invoice->subtotal = wpinv_round_amount( $subtotal ); |
|
| 134 | - $invoice->tax = wpinv_round_amount( $tax ); |
|
| 135 | - $invoice->discount = wpinv_round_amount( $discount ); |
|
| 136 | - $invoice->total = wpinv_round_amount( $total ); |
|
| 133 | + $invoice->subtotal = wpinv_round_amount($subtotal); |
|
| 134 | + $invoice->tax = wpinv_round_amount($tax); |
|
| 135 | + $invoice->discount = wpinv_round_amount($discount); |
|
| 136 | + $invoice->total = wpinv_round_amount($total); |
|
| 137 | 137 | $invoice->save(); |
| 138 | 138 | |
| 139 | - wpinv_update_payment_status( $invoice->ID, 'publish' ); |
|
| 139 | + wpinv_update_payment_status($invoice->ID, 'publish'); |
|
| 140 | 140 | sleep(1); |
| 141 | - wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' ); |
|
| 141 | + wpinv_update_payment_status($invoice->ID, 'wpi-renewal'); |
|
| 142 | 142 | |
| 143 | - $invoice = wpinv_get_invoice( $invoice->ID ); |
|
| 143 | + $invoice = wpinv_get_invoice($invoice->ID); |
|
| 144 | 144 | |
| 145 | - $subscription_data = wpinv_payment_subscription_data( $parent_invoice ); |
|
| 145 | + $subscription_data = wpinv_payment_subscription_data($parent_invoice); |
|
| 146 | 146 | $subscription_data['recurring_amount'] = $invoice->get_total(); |
| 147 | - $subscription_data['created'] = current_time( 'mysql', 0 ); |
|
| 148 | - $subscription_data['expiration'] = $invoice->get_new_expiration( $subscription_data['item_id'] ); |
|
| 147 | + $subscription_data['created'] = current_time('mysql', 0); |
|
| 148 | + $subscription_data['expiration'] = $invoice->get_new_expiration($subscription_data['item_id']); |
|
| 149 | 149 | |
| 150 | 150 | // Retrieve pending subscription from database and update it's status to active and set proper profile ID |
| 151 | - $invoice->update_subscription( $subscription_data ); |
|
| 151 | + $invoice->update_subscription($subscription_data); |
|
| 152 | 152 | |
| 153 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args ); |
|
| 154 | - do_action( 'wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args ); |
|
| 153 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args); |
|
| 154 | + do_action('wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args); |
|
| 155 | 155 | |
| 156 | 156 | return $invoice; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -function wpinv_payment_exists( $txn_id = '' ) { |
|
| 159 | +function wpinv_payment_exists($txn_id = '') { |
|
| 160 | 160 | global $wpdb; |
| 161 | 161 | |
| 162 | - if ( empty( $txn_id ) ) { |
|
| 162 | + if (empty($txn_id)) { |
|
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $txn_id = esc_sql( $txn_id ); |
|
| 166 | + $txn_id = esc_sql($txn_id); |
|
| 167 | 167 | |
| 168 | - $invoice = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" ); |
|
| 168 | + $invoice = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1"); |
|
| 169 | 169 | |
| 170 | - if ( $invoice != null ) { |
|
| 170 | + if ($invoice != null) { |
|
| 171 | 171 | return true; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
| 178 | - if ( empty( $invoice ) ) { |
|
| 177 | +function wpinv_is_subscription_payment($invoice = '') { |
|
| 178 | + if (empty($invoice)) { |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 183 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 182 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 183 | + $invoice = wpinv_get_invoice($invoice); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( empty( $invoice ) ) { |
|
| 186 | + if (empty($invoice)) { |
|
| 187 | 187 | return false; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( $invoice->is_renewal() ) { |
|
| 190 | + if ($invoice->is_renewal()) { |
|
| 191 | 191 | return true; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | return false; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -function wpinv_payment_subscription_data( $invoice = '' ) { |
|
| 198 | - if ( empty( $invoice ) ) { |
|
| 197 | +function wpinv_payment_subscription_data($invoice = '') { |
|
| 198 | + if (empty($invoice)) { |
|
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 203 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 202 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 203 | + $invoice = wpinv_get_invoice($invoice); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if ( empty( $invoice ) ) { |
|
| 206 | + if (empty($invoice)) { |
|
| 207 | 207 | return false; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | return $invoice->get_subscription_data(); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
| 214 | - if ( empty( $invoice ) ) { |
|
| 213 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
| 214 | + if (empty($invoice)) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 219 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 218 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 219 | + $invoice = wpinv_get_invoice($invoice); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( empty( $invoice ) ) { |
|
| 222 | + if (empty($invoice)) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
| 226 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | -function wpinv_get_pretty_subscription_period( $period ) { |
|
| 229 | +function wpinv_get_pretty_subscription_period($period) { |
|
| 230 | 230 | $frequency = ''; |
| 231 | 231 | //Format period details |
| 232 | - switch ( $period ) { |
|
| 232 | + switch ($period) { |
|
| 233 | 233 | case 'D' : |
| 234 | 234 | case 'day' : |
| 235 | - $frequency = __( 'Daily', 'invoicing' ); |
|
| 235 | + $frequency = __('Daily', 'invoicing'); |
|
| 236 | 236 | break; |
| 237 | 237 | case 'W' : |
| 238 | 238 | case 'week' : |
| 239 | - $frequency = __( 'Weekly', 'invoicing' ); |
|
| 239 | + $frequency = __('Weekly', 'invoicing'); |
|
| 240 | 240 | break; |
| 241 | 241 | case 'M' : |
| 242 | 242 | case 'month' : |
| 243 | - $frequency = __( 'Monthly', 'invoicing' ); |
|
| 243 | + $frequency = __('Monthly', 'invoicing'); |
|
| 244 | 244 | break; |
| 245 | 245 | case 'Y' : |
| 246 | 246 | case 'year' : |
| 247 | - $frequency = __( 'Yearly', 'invoicing' ); |
|
| 247 | + $frequency = __('Yearly', 'invoicing'); |
|
| 248 | 248 | break; |
| 249 | 249 | default : |
| 250 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period', $frequency, $period ); |
|
| 250 | + $frequency = apply_filters('wpinv_pretty_subscription_period', $frequency, $period); |
|
| 251 | 251 | break; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $frequency; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | -function wpinv_get_pretty_subscription_period_name( $period ) { |
|
| 257 | +function wpinv_get_pretty_subscription_period_name($period) { |
|
| 258 | 258 | $frequency = ''; |
| 259 | 259 | //Format period details |
| 260 | - switch ( $period ) { |
|
| 260 | + switch ($period) { |
|
| 261 | 261 | case 'D' : |
| 262 | 262 | case 'day' : |
| 263 | - $frequency = __( 'Day', 'invoicing' ); |
|
| 263 | + $frequency = __('Day', 'invoicing'); |
|
| 264 | 264 | break; |
| 265 | 265 | case 'W' : |
| 266 | 266 | case 'week' : |
| 267 | - $frequency = __( 'Week', 'invoicing' ); |
|
| 267 | + $frequency = __('Week', 'invoicing'); |
|
| 268 | 268 | break; |
| 269 | 269 | case 'M' : |
| 270 | 270 | case 'month' : |
| 271 | - $frequency = __( 'Month', 'invoicing' ); |
|
| 271 | + $frequency = __('Month', 'invoicing'); |
|
| 272 | 272 | break; |
| 273 | 273 | case 'Y' : |
| 274 | 274 | case 'year' : |
| 275 | - $frequency = __( 'Year', 'invoicing' ); |
|
| 275 | + $frequency = __('Year', 'invoicing'); |
|
| 276 | 276 | break; |
| 277 | 277 | default : |
| 278 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period_name', $frequency, $period ); |
|
| 278 | + $frequency = apply_filters('wpinv_pretty_subscription_period_name', $frequency, $period); |
|
| 279 | 279 | break; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | return $frequency; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
| 285 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
| 286 | 286 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 287 | 287 | |
| 288 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 289 | - $amount = __( 'Free', 'invoicing' ); |
|
| 288 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 289 | + $amount = __('Free', 'invoicing'); |
|
| 290 | 290 | $interval = $trial_interval; |
| 291 | 291 | $period = $trial_period; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $description = ''; |
| 295 | - switch ( $period ) { |
|
| 295 | + switch ($period) { |
|
| 296 | 296 | case 'D' : |
| 297 | 297 | case 'day' : |
| 298 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 298 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 299 | 299 | break; |
| 300 | 300 | case 'W' : |
| 301 | 301 | case 'week' : |
| 302 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 302 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 303 | 303 | break; |
| 304 | 304 | case 'M' : |
| 305 | 305 | case 'month' : |
| 306 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 306 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 307 | 307 | break; |
| 308 | 308 | case 'Y' : |
| 309 | 309 | case 'year' : |
| 310 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 310 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 314 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
| 317 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
| 318 | 318 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 319 | 319 | $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
| 320 | 320 | |
| 321 | 321 | $description = ''; |
| 322 | - switch ( $period ) { |
|
| 322 | + switch ($period) { |
|
| 323 | 323 | case 'D' : |
| 324 | 324 | case 'day' : |
| 325 | - if ( (int)$bill_times > 0 ) { |
|
| 326 | - if ( $interval > 1 ) { |
|
| 327 | - if ( $bill_times > 1 ) { |
|
| 328 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 325 | + if ((int)$bill_times > 0) { |
|
| 326 | + if ($interval > 1) { |
|
| 327 | + if ($bill_times > 1) { |
|
| 328 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 329 | 329 | } else { |
| 330 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
| 330 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
| 331 | 331 | } |
| 332 | 332 | } else { |
| 333 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 333 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 334 | 334 | } |
| 335 | 335 | } else { |
| 336 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
| 336 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 337 | 337 | } |
| 338 | 338 | break; |
| 339 | 339 | case 'W' : |
| 340 | 340 | case 'week' : |
| 341 | - if ( (int)$bill_times > 0 ) { |
|
| 342 | - if ( $interval > 1 ) { |
|
| 343 | - if ( $bill_times > 1 ) { |
|
| 344 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 341 | + if ((int)$bill_times > 0) { |
|
| 342 | + if ($interval > 1) { |
|
| 343 | + if ($bill_times > 1) { |
|
| 344 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 345 | 345 | } else { |
| 346 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
| 346 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
| 347 | 347 | } |
| 348 | 348 | } else { |
| 349 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 349 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 350 | 350 | } |
| 351 | 351 | } else { |
| 352 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 352 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 353 | 353 | } |
| 354 | 354 | break; |
| 355 | 355 | case 'M' : |
| 356 | 356 | case 'month' : |
| 357 | - if ( (int)$bill_times > 0 ) { |
|
| 358 | - if ( $interval > 1 ) { |
|
| 359 | - if ( $bill_times > 1 ) { |
|
| 360 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 357 | + if ((int)$bill_times > 0) { |
|
| 358 | + if ($interval > 1) { |
|
| 359 | + if ($bill_times > 1) { |
|
| 360 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 361 | 361 | } else { |
| 362 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
| 362 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
| 363 | 363 | } |
| 364 | 364 | } else { |
| 365 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 365 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 366 | 366 | } |
| 367 | 367 | } else { |
| 368 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 368 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 369 | 369 | } |
| 370 | 370 | break; |
| 371 | 371 | case 'Y' : |
| 372 | 372 | case 'year' : |
| 373 | - if ( (int)$bill_times > 0 ) { |
|
| 374 | - if ( $interval > 1 ) { |
|
| 375 | - if ( $bill_times > 1 ) { |
|
| 376 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 373 | + if ((int)$bill_times > 0) { |
|
| 374 | + if ($interval > 1) { |
|
| 375 | + if ($bill_times > 1) { |
|
| 376 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 377 | 377 | } else { |
| 378 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
| 378 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
| 379 | 379 | } |
| 380 | 380 | } else { |
| 381 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 381 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 382 | 382 | } |
| 383 | 383 | } else { |
| 384 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 384 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 385 | 385 | } |
| 386 | 386 | break; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 389 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
| 393 | - if ( empty( $invoice ) ) { |
|
| 392 | +function wpinv_subscription_payment_desc($invoice) { |
|
| 393 | + if (empty($invoice)) { |
|
| 394 | 394 | return NULL; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | $description = ''; |
| 398 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
| 399 | - if ( $item->has_free_trial() ) { |
|
| 398 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
| 399 | + if ($item->has_free_trial()) { |
|
| 400 | 400 | $trial_period = $item->get_trial_period(); |
| 401 | 401 | $trial_interval = $item->get_trial_interval(); |
| 402 | 402 | } else { |
@@ -404,45 +404,45 @@ discard block |
||
| 404 | 404 | $trial_interval = 0; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
| 407 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
| 410 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
| 414 | - $initial_total = wpinv_round_amount( $initial ); |
|
| 415 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
| 413 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
| 414 | + $initial_total = wpinv_round_amount($initial); |
|
| 415 | + $recurring_total = wpinv_round_amount($recurring); |
|
| 416 | 416 | |
| 417 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 417 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 418 | 418 | // Free trial |
| 419 | 419 | } else { |
| 420 | - if ( $bill_times == 1 ) { |
|
| 420 | + if ($bill_times == 1) { |
|
| 421 | 421 | $recurring_total = $initial_total; |
| 422 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
| 422 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
| 423 | 423 | $bill_times--; |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
| 428 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
| 427 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
| 428 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
| 429 | 429 | |
| 430 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 430 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 431 | 431 | |
| 432 | - if ( $initial_total != $recurring_total ) { |
|
| 433 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 432 | + if ($initial_total != $recurring_total) { |
|
| 433 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
| 434 | 434 | |
| 435 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
| 435 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
| 436 | 436 | } else { |
| 437 | 437 | $description = $recurring; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
| 440 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | -function wpinv_recurring_send_payment_failed( $invoice ) { |
|
| 444 | - if ( !empty( $invoice->ID ) ) { |
|
| 445 | - wpinv_failed_invoice_notification( $invoice->ID ); |
|
| 443 | +function wpinv_recurring_send_payment_failed($invoice) { |
|
| 444 | + if (!empty($invoice->ID)) { |
|
| 445 | + wpinv_failed_invoice_notification($invoice->ID); |
|
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | -add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 ); |
|
| 449 | 448 | \ No newline at end of file |
| 449 | +add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1); |
|
| 450 | 450 | \ No newline at end of file |