Passed
Pull Request — master (#38)
by Farhan
04:09
created
templates/wpinv-invoice-print.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@  discard block
 block discarded – undo
1 1
 <?php 
2
-if ( !defined('ABSPATH') ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 global $post;
6 6
 $invoice_id = $post->ID;
7
-$invoice = wpinv_get_invoice( $invoice_id );
8
-if ( empty( $invoice ) ) {
7
+$invoice = wpinv_get_invoice($invoice_id);
8
+if (empty($invoice)) {
9 9
     exit;
10 10
 }
11
-$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' );
12
-do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html>
11
+$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing');
12
+do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html>
13 13
 <html <?php language_attributes(); ?>>
14 14
 <head>
15 15
     <meta charset="UTF-8">
16 16
     <title><?php wp_title() ?></title>
17
-    <meta charset="<?php bloginfo( 'charset' ); ?>" />
17
+    <meta charset="<?php bloginfo('charset'); ?>" />
18 18
     <meta name="viewport" content="width=device-width, initial-scale=1">
19 19
     <meta name="robots" content="noindex,nofollow">
20 20
 
21
-    <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
21
+    <?php do_action('wpinv_invoice_print_head', $invoice); ?>
22 22
 </head>
23 23
 <body class="body wpinv wpinv-print">
24
-    <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?>
24
+    <?php do_action('wpinv_invoice_print_body_start', $invoice); ?>
25 25
     <div class="container wpinv-wrap">
26
-        <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?>
27
-            <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div>
26
+        <?php if ($watermark = wpinv_watermark($invoice_id)) { ?>
27
+            <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div>
28 28
         <?php } ?>
29 29
         <!-- ///// Start PDF header -->
30 30
         <htmlpageheader name="wpinv-pdf-header">
31
-            <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?>
31
+            <?php do_action('wpinv_invoice_print_before_header', $invoice); ?>
32 32
             <div class="row wpinv-header">
33 33
                 <div class="col-xs-6 wpinv-business">
34
-                    <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
35
-                        <?php if ( $logo = wpinv_get_business_logo() ) { ?>
36
-                        <img class="logo" src="<?php echo esc_url( $logo ); ?>">
34
+                    <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
35
+                        <?php if ($logo = wpinv_get_business_logo()) { ?>
36
+                        <img class="logo" src="<?php echo esc_url($logo); ?>">
37 37
                         <?php } else { ?>
38
-                        <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
38
+                        <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1>
39 39
                         <?php } ?>
40 40
                     </a>
41 41
                 </div>
@@ -44,56 +44,56 @@  discard block
 block discarded – undo
44 44
                     <h2><?php echo $type; ?></h2>
45 45
                 </div>
46 46
             </div>
47
-            <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?>
47
+            <?php do_action('wpinv_invoice_print_after_header', $invoice); ?>
48 48
         </htmlpageheader>
49 49
         <!-- End PDF header ///// -->
50 50
         
51
-        <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?>
51
+        <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?>
52 52
         <div class="row wpinv-top-content">
53 53
             <div class="col-xs-12 col-sm-6 wpinv-addresses">
54 54
                 <div class="col-xs-12 wpinv-address wpinv-from-address">
55 55
                     <?php wpinv_display_from_address(); ?>
56 56
                 </div>
57 57
                 <div class="col-xs-12 wpinv-address wpinv-to-address">
58
-                    <?php wpinv_display_to_address( $invoice_id ); ?>
58
+                    <?php wpinv_display_to_address($invoice_id); ?>
59 59
                 </div>
60 60
             </div>
61 61
             <div class="col-xs-12 col-sm-6 wpinv-details">
62 62
                 <div class="col-xs-12 wpinv-line-details">
63
-                    <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?>
64
-                    <?php wpinv_display_invoice_details( $invoice ); ?>
65
-                    <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?>
63
+                    <?php do_action('wpinv_invoice_print_before_details', $invoice); ?>
64
+                    <?php wpinv_display_invoice_details($invoice); ?>
65
+                    <?php do_action('wpinv_invoice_print_after_details', $invoice); ?>
66 66
                 </div>
67 67
             </div>
68 68
         </div>
69
-        <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?>
69
+        <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?>
70 70
 
71
-        <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?>
71
+        <?php do_action('wpinv_invoice_print_middle', $invoice); ?>
72 72
         
73
-        <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?>
73
+        <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?>
74 74
         <div class="row wpinv-items">
75 75
             <div class="col-sm-12 wpinv-line-items">
76
-                <?php wpinv_display_line_items( $invoice_id ); ?>
76
+                <?php wpinv_display_line_items($invoice_id); ?>
77 77
             </div>
78 78
         </div>
79
-        <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?>
79
+        <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?>
80 80
         
81 81
         <!-- ///// Start PDF footer -->
82 82
         <htmlpagefooter name="wpinv-pdf-footer">
83
-            <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?>
83
+            <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?>
84 84
             <div class="row wpinv-footer">
85 85
                 <div class="col-sm-12">
86
-                    <?php if ( $term_text = wpinv_get_terms_text() ) { ?>
87
-                    <div class="terms-text"><?php echo wpautop( $term_text ); ?></div>
86
+                    <?php if ($term_text = wpinv_get_terms_text()) { ?>
87
+                    <div class="terms-text"><?php echo wpautop($term_text); ?></div>
88 88
                     <?php } ?>
89 89
                     <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div>
90
-                    <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div>
90
+                    <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div>
91 91
                 </div>
92 92
             </div>
93
-            <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?>
93
+            <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?>
94 94
         </htmlpagefooter>
95 95
         <!-- End PDF footer ///// -->
96 96
     </div><!-- END wpinv-wrap -->
97
-    <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?>
97
+    <?php do_action('wpinv_invoice_print_body_end', $invoice); ?>
98 98
 </body>
99 99
 </html>
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -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,187 +83,187 @@  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-gd-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
126
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
127
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.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-gd-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
126
+        if (!class_exists('Geodir_EUVat')) {
127
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
128 128
         }
129 129
         
130
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
131
-        if ( !empty( $gateways ) ) {
132
-            foreach ( $gateways as $gateway ) {
133
-                if ( $gateway == 'manual' ) {
130
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
131
+        if (!empty($gateways)) {
132
+            foreach ($gateways as $gateway) {
133
+                if ($gateway == 'manual') {
134 134
                     continue;
135 135
                 }
136 136
                 
137 137
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
138 138
                 
139
-                if ( file_exists( $gateway_file ) ) {
140
-                    require_once( $gateway_file );
139
+                if (file_exists($gateway_file)) {
140
+                    require_once($gateway_file);
141 141
                 }
142 142
             }
143 143
         }
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
145
-        
146
-        if ( is_admin() ) {
147
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
148
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
149
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
145
+        
146
+        if (is_admin()) {
147
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
148
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
149
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
154 154
         }
155 155
         
156 156
         // include css inliner
157
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
158
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
157
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
158
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
159 159
         }
160 160
         
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
162 162
     }
163 163
     
164 164
     public function init() {
165 165
     }
166 166
     
167 167
     public function admin_init() {
168
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
168
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
169 169
         }
170 170
         
171
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
171
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
172 172
     }
173 173
 
174 174
     public function activation_redirect() {
175 175
         // Bail if no activation redirect
176
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
176
+        if (!get_transient('_wpinv_activation_redirect')) {
177 177
             return;
178 178
         }
179 179
 
180 180
         // Delete the redirect transient
181
-        delete_transient( '_wpinv_activation_redirect' );
181
+        delete_transient('_wpinv_activation_redirect');
182 182
 
183 183
         // Bail if activating from network, or bulk
184
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
             return;
186 186
         }
187 187
 
188
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
188
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
189 189
         exit;
190 190
     }
191 191
     
192 192
     public function enqueue_scripts() {
193
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
193
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
194 194
         
195
-        wp_deregister_style( 'font-awesome' );
196
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
197
-        wp_enqueue_style( 'font-awesome' );
195
+        wp_deregister_style('font-awesome');
196
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
197
+        wp_enqueue_style('font-awesome');
198 198
         
199
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
200
-        wp_enqueue_style( 'wpinv_front_style' );
199
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
200
+        wp_enqueue_style('wpinv_front_style');
201 201
                
202 202
         // Register scripts
203
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
204
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
203
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
204
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
205 205
         
206 206
         $localize                         = array();
207
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
208
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
207
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
208
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
209 209
         $localize['currency_symbol']      = wpinv_currency_symbol();
210 210
         $localize['currency_pos']         = wpinv_currency_position();
211 211
         $localize['thousand_sep']         = wpinv_thousands_seperator();
212 212
         $localize['decimal_sep']          = wpinv_decimal_seperator();
213 213
         $localize['decimals']             = wpinv_decimals();
214 214
         
215
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
215
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
216 216
         
217
-        wp_enqueue_script( 'jquery-blockui' );
218
-        wp_enqueue_script( 'wpinv-front-script' );
219
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
217
+        wp_enqueue_script('jquery-blockui');
218
+        wp_enqueue_script('wpinv-front-script');
219
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
220 220
     }
221 221
     
222 222
     public function admin_enqueue_scripts() {
223 223
         global $post, $pagenow;
224 224
         
225 225
         $post_type  = wpinv_admin_post_type();
226
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
226
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
227 227
         
228
-        wp_deregister_style( 'font-awesome' );
229
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
230
-        wp_enqueue_style( 'font-awesome' );
228
+        wp_deregister_style('font-awesome');
229
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
230
+        wp_enqueue_style('font-awesome');
231 231
         
232
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
233
-        wp_enqueue_style( 'jquery-ui-css' );
232
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
233
+        wp_enqueue_style('jquery-ui-css');
234 234
         
235
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
236
-        wp_enqueue_style( 'jquery-chosen' );
235
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
236
+        wp_enqueue_style('jquery-chosen');
237 237
 
238
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
239
-        wp_enqueue_script( 'jquery-chosen' );
238
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
239
+        wp_enqueue_script('jquery-chosen');
240 240
         
241
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
242
-        wp_enqueue_style( 'wpinv_meta_box_style' );
241
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
242
+        wp_enqueue_style('wpinv_meta_box_style');
243 243
         
244
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
245
-        wp_enqueue_style( 'wpinv_admin_style' );
244
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
245
+        wp_enqueue_style('wpinv_admin_style');
246 246
         
247
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
248
-            wp_enqueue_script( 'jquery-ui-datepicker' );
247
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
248
+            wp_enqueue_script('jquery-ui-datepicker');
249 249
         }
250 250
 
251
-        wp_enqueue_style( 'wp-color-picker' );
252
-        wp_enqueue_script( 'wp-color-picker' );
251
+        wp_enqueue_style('wp-color-picker');
252
+        wp_enqueue_script('wp-color-picker');
253 253
         
254
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
254
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
255 255
         
256
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
257
-        wp_enqueue_script( 'wpinv-admin-script' );
256
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
257
+        wp_enqueue_script('wpinv-admin-script');
258 258
         
259 259
         $localize                               = array();
260
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
261
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
262
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
263
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
264
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
265
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
266
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
260
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
261
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
262
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
263
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
264
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
265
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
266
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
267 267
         $localize['tax']                        = wpinv_tax_amount();
268 268
         $localize['discount']                   = wpinv_discount_amount();
269 269
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -271,55 +271,55 @@  discard block
 block discarded – undo
271 271
         $localize['thousand_sep']               = wpinv_thousands_seperator();
272 272
         $localize['decimal_sep']                = wpinv_decimal_seperator();
273 273
         $localize['decimals']                   = wpinv_decimals();
274
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
275
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
276
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
277
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
278
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
279
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
280
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
281
-        $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' );
282
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
283
-        $localize['hasGD']                      = wpinv_gd_active();;
274
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
275
+        $localize['status_publish']             = wpinv_status_nicename('publish');
276
+        $localize['status_pending']             = wpinv_status_nicename('pending');
277
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
278
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
279
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
280
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
281
+        $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');
282
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
283
+        $localize['hasGD']                      = wpinv_gd_active(); ;
284 284
         $localize['hasPM']                      = wpinv_pm_active();
285
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
286
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
287
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
288
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
285
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
286
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
287
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
288
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
289 289
         
290
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
290
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
291 291
     }
292 292
     
293
-    public function admin_body_class( $classes ) {
293
+    public function admin_body_class($classes) {
294 294
         global $pagenow;
295 295
         
296
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
296
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
297 297
 
298 298
         $add_class = false;
299
-        if ( $pagenow == 'admin.php' && $page ) {
300
-            $add_class = strpos( $page, 'wpinv-' );
299
+        if ($pagenow == 'admin.php' && $page) {
300
+            $add_class = strpos($page, 'wpinv-');
301 301
         }
302 302
         
303 303
         $settings_class = array();
304
-        if ( $page == 'wpinv-settings' ) {
305
-            if ( !empty( $_REQUEST['tab'] ) ) {
306
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
304
+        if ($page == 'wpinv-settings') {
305
+            if (!empty($_REQUEST['tab'])) {
306
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
307 307
             }
308 308
             
309
-            if ( !empty( $_REQUEST['section'] ) ) {
310
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
309
+            if (!empty($_REQUEST['section'])) {
310
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
311 311
             }
312 312
             
313
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
313
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
314 314
         }
315 315
         
316
-        if ( !empty( $settings_class ) ) {
317
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
316
+        if (!empty($settings_class)) {
317
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
318 318
         }
319 319
         
320 320
         $post_type = wpinv_admin_post_type();
321 321
         
322
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
322
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
323 323
             return $classes .= ' wpinv';
324 324
         } else {
325 325
             return $classes;
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
     public function admin_print_scripts_edit_php() {
332 332
         $post_type = wpinv_admin_post_type();
333 333
         
334
-        if ( $post_type == 'wpi_item' ) {
335
-            wp_enqueue_script( 'wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
334
+        if ($post_type == 'wpi_item') {
335
+            wp_enqueue_script('wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array('jquery', 'inline-edit-post'), '', true);
336 336
         }
337 337
     }
338 338
     
339 339
     public function wpinv_actions() {
340
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
341
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
340
+        if (isset($_REQUEST['wpi_action'])) {
341
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
342 342
         }
343 343
     }
344 344
     
345
-    public function pre_get_posts( $wp_query ) {
346
-        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() ) {
347
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
345
+    public function pre_get_posts($wp_query) {
346
+        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()) {
347
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
348 348
         }
349 349
         
350 350
         return $wp_query;
351 351
     }
352 352
     
353 353
     public function bp_invoicing_init() {
354
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
354
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
355 355
     }
356 356
 }
357 357
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@  discard block
 block discarded – undo
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
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 }
32
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
32
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
33 33
 
34
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
35
-    remove_action( 'save_post', __FUNCTION__ );
34
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
35
+    remove_action('save_post', __FUNCTION__);
36 36
     
37 37
     // $post_id and $post are required
38
-    if ( empty( $post_id ) || empty( $post ) ) {
38
+    if (empty($post_id) || empty($post)) {
39 39
         return;
40 40
     }
41 41
         
42
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
42
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
43 43
         return;
44 44
     }
45 45
     
46 46
     // Dont' save meta boxes for revisions or autosaves
47
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
47
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
52
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
51
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
52
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
53 53
             return;
54 54
         }
55 55
     
56
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
57
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
56
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
57
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
58 58
         }
59
-    } else if ( $post->post_type == 'wpi_item' ) {
59
+    } else if ($post->post_type == 'wpi_item') {
60 60
         // verify nonce
61
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
62
-            $fields                                 = array();
61
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
62
+            $fields = array();
63 63
             $fields['_wpinv_price']              = 'wpinv_item_price';
64 64
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
65 65
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -72,291 +72,291 @@  discard block
 block discarded – undo
72 72
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
73 73
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
74 74
             
75
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
75
+            if (!isset($_POST['wpinv_is_recurring'])) {
76 76
                 $_POST['wpinv_is_recurring'] = 0;
77 77
             }
78 78
             
79
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_free_trial'] = 0;
81 81
             }
82 82
             
83
-            foreach ( $fields as $field => $name ) {
84
-                if ( isset( $_POST[ $name ] ) ) {
85
-                    if ( $field == '_wpinv_price' ) {
86
-                        if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) {
87
-                            $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price.
83
+            foreach ($fields as $field => $name) {
84
+                if (isset($_POST[$name])) {
85
+                    if ($field == '_wpinv_price') {
86
+                        if (get_post_meta($post_id, '_wpinv_type', true) === 'package') {
87
+                            $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price.
88 88
                         } else {
89
-                            $value = wpinv_sanitize_amount( $_POST[ $name ] );
89
+                            $value = wpinv_sanitize_amount($_POST[$name]);
90 90
                         }
91 91
                     } else {
92
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
92
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
93 93
                     }
94 94
                     
95
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
96
-                    update_post_meta( $post_id, $field, $value );
95
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
96
+                    update_post_meta($post_id, $field, $value);
97 97
                 }
98 98
             }
99 99
         }
100 100
     }
101 101
 }
102
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
102
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
103 103
 
104
-function wpinv_bulk_and_quick_edit_save( $post_id, $post, $update = false ) {
105
-    if ( !( !empty( $_POST['action'] ) && $_POST['action'] == 'inline-save' ) ) {
104
+function wpinv_bulk_and_quick_edit_save($post_id, $post, $update = false) {
105
+    if (!(!empty($_POST['action']) && $_POST['action'] == 'inline-save')) {
106 106
         return;
107 107
     }
108 108
     
109 109
     // $post_id and $post are required
110
-    if ( empty( $post_id ) || empty( $post ) ) {
110
+    if (empty($post_id) || empty($post)) {
111 111
         return;
112 112
     }
113 113
         
114
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
114
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
115 115
         return;
116 116
     }
117 117
     
118 118
     // Dont' save meta boxes for revisions or autosaves
119
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
119
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
120 120
         return;
121 121
     }
122 122
 
123
-    if ( $post->post_type == 'wpi_item' ) {
123
+    if ($post->post_type == 'wpi_item') {
124 124
         // verify nonce
125
-        if ( isset( $_POST['_wpinv_item_price'] ) && get_post_meta( $post->ID, '_wpinv_type', true ) !== 'package' ) {
126
-            update_post_meta( $post_id, '_wpinv_price', wpinv_sanitize_amount( $_POST['_wpinv_item_price'] ) );
125
+        if (isset($_POST['_wpinv_item_price']) && get_post_meta($post->ID, '_wpinv_type', true) !== 'package') {
126
+            update_post_meta($post_id, '_wpinv_price', wpinv_sanitize_amount($_POST['_wpinv_item_price']));
127 127
         }
128 128
         
129
-        if ( isset( $_POST['_wpinv_vat_class'] ) ) {
130
-            update_post_meta( $post_id, '_wpinv_vat_class', sanitize_text_field( $_POST['_wpinv_vat_class'] ) );
129
+        if (isset($_POST['_wpinv_vat_class'])) {
130
+            update_post_meta($post_id, '_wpinv_vat_class', sanitize_text_field($_POST['_wpinv_vat_class']));
131 131
         }
132 132
 
133
-        if ( isset( $_POST['_wpinv_vat_rules'] ) ) {
134
-            update_post_meta( $post_id, '_wpinv_vat_rule', sanitize_text_field( $_POST['_wpinv_vat_rules'] ) );
133
+        if (isset($_POST['_wpinv_vat_rules'])) {
134
+            update_post_meta($post_id, '_wpinv_vat_rule', sanitize_text_field($_POST['_wpinv_vat_rules']));
135 135
         }
136 136
         
137
-        if ( isset( $_POST['_wpinv_item_type'] ) ) {
138
-            update_post_meta( $post_id, '_wpinv_type', sanitize_text_field( $_POST['_wpinv_item_type'] ) );
137
+        if (isset($_POST['_wpinv_item_type'])) {
138
+            update_post_meta($post_id, '_wpinv_type', sanitize_text_field($_POST['_wpinv_item_type']));
139 139
         }
140 140
     }
141 141
 }
142
-add_action( 'save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3 );
142
+add_action('save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3);
143 143
 
144 144
 function wpinv_register_item_meta_boxes() {    
145 145
     global $wpinv_euvat;
146 146
     
147
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
147
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
148 148
 
149
-    if ( $wpinv_euvat->allow_vat_rules() ) {
150
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
149
+    if ($wpinv_euvat->allow_vat_rules()) {
150
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
151 151
     }
152 152
     
153
-    if ( $wpinv_euvat->allow_vat_classes() ) {
154
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
153
+    if ($wpinv_euvat->allow_vat_classes()) {
154
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
155 155
     }
156 156
     
157
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
157
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
158 158
 }
159 159
 
160 160
 function wpinv_register_discount_meta_boxes() {
161
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
161
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
162 162
 }
163 163
 
164
-function wpinv_discount_metabox_details( $post ) {
164
+function wpinv_discount_metabox_details($post) {
165 165
     $discount_id    = $post->ID;
166
-    $discount       = wpinv_get_discount( $discount_id );
166
+    $discount       = wpinv_get_discount($discount_id);
167 167
     
168
-    $type           = wpinv_get_discount_type( $discount_id );
169
-    $item_reqs      = wpinv_get_discount_item_reqs( $discount_id );
170
-    $excluded_items = wpinv_get_discount_excluded_items( $discount_id );
171
-    $min_total      = wpinv_get_discount_min_total( $discount_id );
172
-    $max_total      = wpinv_get_discount_max_total( $discount_id );
173
-    $max_uses       = wpinv_get_discount_max_uses( $discount_id );
174
-    $single_use     = wpinv_discount_is_single_use( $discount_id );
175
-    $recurring      = (bool)wpinv_discount_is_recurring( $discount_id );
168
+    $type           = wpinv_get_discount_type($discount_id);
169
+    $item_reqs      = wpinv_get_discount_item_reqs($discount_id);
170
+    $excluded_items = wpinv_get_discount_excluded_items($discount_id);
171
+    $min_total      = wpinv_get_discount_min_total($discount_id);
172
+    $max_total      = wpinv_get_discount_max_total($discount_id);
173
+    $max_uses       = wpinv_get_discount_max_uses($discount_id);
174
+    $single_use     = wpinv_discount_is_single_use($discount_id);
175
+    $recurring      = (bool)wpinv_discount_is_recurring($discount_id);
176 176
     
177 177
     $min_total      = $min_total > 0 ? $min_total : '';
178 178
     $max_total      = $max_total > 0 ? $max_total : '';
179 179
     $max_uses       = $max_uses > 0 ? $max_uses : '';
180 180
 ?>
181
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
182
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
181
+<?php do_action('wpinv_discount_form_top', $post); ?>
182
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
183 183
 <table class="form-table wpi-form-table">
184 184
     <tbody>
185
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
186
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
185
+        <?php do_action('wpinv_discount_form_first', $post); ?>
186
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
187 187
         <tr>
188 188
             <th valign="top" scope="row">
189
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
189
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
190 190
             </th>
191 191
             <td>
192
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
193
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
192
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
193
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
194 194
             </td>
195 195
         </tr>
196
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
196
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
197 197
         <tr>
198 198
             <th valign="top" scope="row">
199
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
199
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
200 200
             </th>
201 201
             <td>
202 202
                 <select id="wpinv_discount_type" name="type" class="medium-text">
203
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
204
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
203
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
204
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
205 205
                     <?php } ?>
206 206
                 </select>
207
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
207
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
208 208
             </td>
209 209
         </tr>
210
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
210
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
211 211
         <tr>
212 212
             <th valign="top" scope="row">
213
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
213
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
214 214
             </th>
215 215
             <td>
216
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
217
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
218
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
216
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
217
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
218
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
219 219
             </td>
220 220
         </tr>
221
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
221
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
222 222
         <tr>
223 223
             <th valign="top" scope="row">
224
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
224
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
225 225
             </th>
226 226
             <td>
227
-                <p><?php echo wpinv_item_dropdown( array(
227
+                <p><?php echo wpinv_item_dropdown(array(
228 228
                         'name'              => 'items[]',
229 229
                         'id'                => 'items',
230 230
                         'selected'          => $item_reqs,
231 231
                         'multiple'          => true,
232 232
                         'chosen'            => true,
233 233
                         'class'             => 'medium-text',
234
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
234
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
235 235
                         'show_recurring'    => true,
236
-                    ) ); ?>
236
+                    )); ?>
237 237
                 </p>
238
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
238
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
239 239
             </td>
240 240
         </tr>
241
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
241
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
242 242
         <tr>
243 243
             <th valign="top" scope="row">
244
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
244
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
245 245
             </th>
246 246
             <td>
247
-                <p><?php echo wpinv_item_dropdown( array(
247
+                <p><?php echo wpinv_item_dropdown(array(
248 248
                         'name'              => 'excluded_items[]',
249 249
                         'id'                => 'excluded_items',
250 250
                         'selected'          => $excluded_items,
251 251
                         'multiple'          => true,
252 252
                         'chosen'            => true,
253 253
                         'class'             => 'medium-text',
254
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
254
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
255 255
                         'show_recurring'    => true,
256
-                    ) ); ?>
256
+                    )); ?>
257 257
                 </p>
258
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
258
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
259 259
             </td>
260 260
         </tr>
261
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
261
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
262 262
         <tr>
263 263
             <th valign="top" scope="row">
264
-                <label for="wpinv_discount_start"><?php _e( 'Start date', 'invoicing' ); ?></label>
264
+                <label for="wpinv_discount_start"><?php _e('Start date', 'invoicing'); ?></label>
265 265
             </th>
266 266
             <td>
267
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>">
268
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
267
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>">
268
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
269 269
             </td>
270 270
         </tr>
271
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
271
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
272 272
         <tr>
273 273
             <th valign="top" scope="row">
274
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration date', 'invoicing' ); ?></label>
274
+                <label for="wpinv_discount_expiration"><?php _e('Expiration date', 'invoicing'); ?></label>
275 275
             </th>
276 276
             <td>
277
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>">
278
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
277
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>">
278
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
279 279
             </td>
280 280
         </tr>
281
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
281
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
282 282
         <tr>
283 283
             <th valign="top" scope="row">
284
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
284
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
285 285
             </th>
286 286
             <td>
287 287
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
288
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
288
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
289 289
             </td>
290 290
         </tr>
291
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
291
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
292 292
         <tr>
293 293
             <th valign="top" scope="row">
294
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
294
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
295 295
             </th>
296 296
             <td>
297 297
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
298
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
298
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
299 299
             </td>
300 300
         </tr>
301
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
301
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
302 302
         <tr>
303 303
             <th valign="top" scope="row">
304
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
304
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
305 305
             </th>
306 306
             <td>
307 307
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text">
308
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
309
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
308
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
309
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
310 310
                 </select>
311
-                <p class="description"><?php _e( '<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
311
+                <p class="description"><?php _e('<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
312 312
             </td>
313 313
         </tr>
314
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
314
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
315 315
         <tr>
316 316
             <th valign="top" scope="row">
317
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
317
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
318 318
             </th>
319 319
             <td>
320 320
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
321
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
321
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
322 322
             </td>
323 323
         </tr>
324
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
324
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
325 325
         <tr>
326 326
             <th valign="top" scope="row">
327
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
327
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
328 328
             </th>
329 329
             <td>
330
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
331
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
330
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
331
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
332 332
             </td>
333 333
         </tr>
334
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
334
+        <?php do_action('wpinv_discount_form_last', $post); ?>
335 335
     </tbody>
336 336
 </table>
337
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
337
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
338 338
     <?php
339 339
 }
340 340
 
341
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
342
-    $post_type = !empty( $post ) ? $post->post_type : '';
341
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
342
+    $post_type = !empty($post) ? $post->post_type : '';
343 343
     
344
-    if ( $post_type != 'wpi_discount' ) {
344
+    if ($post_type != 'wpi_discount') {
345 345
         return;
346 346
     }
347 347
     
348
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
348
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
349 349
         return;
350 350
     }
351 351
     
352
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
352
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
353 353
         return;
354 354
     }
355 355
     
356
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
356
+    if (!current_user_can('manage_options', $post_id)) {
357 357
         return;
358 358
     }
359 359
     
360
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
360
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
361 361
 }
362
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
363 362
\ No newline at end of file
363
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
364 364
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@  discard block
 block discarded – undo
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_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10 10
         $statuses           = wpinv_get_invoice_statuses();
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27 27
         
28 28
         $title = apply_filters('invoice_detail_metabox_titles', $title, $invoice);
29 29
         $statuses = apply_filters('wpinv_metabox_statuses', $statuses, $invoice);
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 <div class="gdmbx2-wrap form-table">
32 32
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
33 33
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
34
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
35
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
34
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
35
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
36 36
         </div>
37
-        <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?>
37
+        <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?>
38 38
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
39
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
39
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
40 40
             <div class="gdmbx-td">
41
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
41
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
42 42
             </div>
43 43
         </div>
44 44
         <?php } ?>
45
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
45
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
46 46
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
47
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
48
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
47
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
48
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
49 49
         </div>
50 50
         <?php } ?>
51 51
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
52 52
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
53 53
             <div class="gdmbx-td">
54 54
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select">
55
-                    <?php foreach ( $statuses as $value => $label ) { ?>
56
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
55
+                    <?php foreach ($statuses as $value => $label) { ?>
56
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
57 57
                     <?php } ?>
58 58
                 </select>
59 59
             </div>
@@ -61,104 +61,104 @@  discard block
 block discarded – undo
61 61
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
62 62
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
63 63
             <div class="gdmbx-td">
64
-                <input type="text" placeholder="<?php echo esc_attr( wpinv_format_invoice_number( 1 ) ); ?>" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text">
64
+                <input type="text" placeholder="<?php echo esc_attr(wpinv_format_invoice_number(1)); ?>" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text">
65 65
             </div>
66 66
         </div>
67
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?>
68
-        <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?>
67
+        <?php do_action('wpinv_meta_box_details_inner', $post_id); ?>
68
+        <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?>
69 69
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
70
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
70
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
71 71
             <div class="gdmbx-td">
72
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
72
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
73 73
             </div>
74 74
         </div>
75 75
         <?php } ?>
76 76
     </div>
77 77
 </div>
78 78
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
79
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php _e( 'Send Invoice:', 'invoicing' ); ?></label>
79
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php _e('Send Invoice:', 'invoicing'); ?></label>
80 80
         <select id="wpi_save_send" name="wpi_save_send">
81
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
82
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
81
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
82
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
83 83
         </select>
84 84
     </p>
85
-    <p class="wpi-meta-row wpi-send-info"><?php esc_attr_e( 'After save invoice this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' ); ?></p>
85
+    <p class="wpi-meta-row wpi-send-info"><?php esc_attr_e('After save invoice this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing'); ?></p>
86 86
 </div>
87
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
87
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
88 88
         <?php
89 89
     }
90 90
     
91
-    public static function resend_invoice( $post ) {
91
+    public static function resend_invoice($post) {
92 92
         global $wpi_mb_invoice;
93 93
         
94
-        if ( empty( $wpi_mb_invoice ) ) {
94
+        if (empty($wpi_mb_invoice)) {
95 95
             return;
96 96
         }
97 97
         
98 98
         $text = array(
99
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' ),
100
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
99
+            'message'       => esc_attr__('This will send a copy of the invoice to the user&#8217;s email address.', 'invoicing'),
100
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
101 101
         );
102 102
             
103 103
         $text = apply_filters('resend_invoice_metabox_text', $text);
104
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
104
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
105 105
         
106
-        if ( $email = $wpi_mb_invoice->get_email() ) {
107
-            $email_url      = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) );
108
-            $reminder_url   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
106
+        if ($email = $wpi_mb_invoice->get_email()) {
107
+            $email_url      = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID));
108
+            $reminder_url   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
109 109
         ?>
110 110
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
111
-        <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e( 'Send invoice to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_url ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
112
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
113
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $reminder_url ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
111
+        <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e('Send invoice to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_url); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
112
+        <?php if (wpinv_get_option('overdue_active') && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
113
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($reminder_url); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
114 114
         <?php } ?>
115 115
         <?php
116 116
         }
117 117
         
118
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
118
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
119 119
     }
120 120
     
121
-    public static function subscriptions( $post ) {
121
+    public static function subscriptions($post) {
122 122
         global $wpi_mb_invoice;
123 123
         
124 124
         $invoice = $wpi_mb_invoice;
125 125
         
126
-        if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
126
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
127 127
             $payments       = $invoice->get_child_payments();
128 128
             
129 129
             $total_payments = (int)$invoice->get_total_payments();
130 130
             $subscription   = $invoice->get_subscription_data();
131 131
 
132
-            $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
133
-            $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
132
+            $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
133
+            $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
134 134
             $subscription_status = $invoice->get_subscription_status();
135 135
             ?>
136
-            <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p>
137
-            <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?>
138
-            <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p>
136
+            <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p>
137
+            <?php if ($subscription_id = $invoice->get_subscription_id()) { ?>
138
+            <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p>
139 139
             <?php } ?>
140
-            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p>
141
-            <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p>
142
-            <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?>
143
-                <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p>
144
-                <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p>
145
-                <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?>
146
-                <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p>
140
+            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p>
141
+            <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p>
142
+            <?php if (!empty($payments) || $invoice->is_paid()) { ?>
143
+                <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p>
144
+                <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p>
145
+                <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?>
146
+                <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p>
147 147
                 <?php } ?>
148
-                <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?>
149
-                <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p>
148
+                <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?>
149
+                <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p>
150 150
                 <?php } ?>
151
-                <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?>
152
-                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p>
151
+                <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?>
152
+                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p>
153 153
                 <?php } ?>
154
-                <?php if ( !empty( $payments ) ) { ?>
155
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
154
+                <?php if (!empty($payments)) { ?>
155
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
156 156
                 <ul id="wpi-sub-payments">
157
-                <?php foreach ( $payments as $invoice_id ) { ?>
157
+                <?php foreach ($payments as $invoice_id) { ?>
158 158
                     <li>
159
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
160
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
161
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
159
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
160
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
161
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
162 162
                     </li>
163 163
                 <?php } ?>
164 164
                 </ul>
@@ -166,47 +166,47 @@  discard block
 block discarded – undo
166 166
         }
167 167
     }
168 168
     
169
-    public static function renewals( $post ) {
169
+    public static function renewals($post) {
170 170
         global $wpi_mb_invoice;
171 171
         
172
-        if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
173
-            $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice );
174
-            $parent_id  = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice );
172
+        if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
173
+            $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice);
174
+            $parent_id  = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice);
175 175
         ?>
176
-        <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
177
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
176
+        <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
177
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
178 178
         <?php
179 179
         }
180 180
     }
181 181
     
182
-    public static function payment_meta( $post ) {
182
+    public static function payment_meta($post) {
183 183
         global $wpi_mb_invoice;
184 184
 
185
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
186
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) {
185
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
186
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) {
187 187
             $set_dateway = true;
188 188
         }
189 189
         
190 190
         ?>
191 191
         <p class="wpi-meta-row">
192
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
193
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
192
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
193
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
194 194
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
195
-                <?php foreach ( $gateways as $name => $gateway ) {
196
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
195
+                <?php foreach ($gateways as $name => $gateway) {
196
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
197 197
                         continue;
198 198
                     }
199 199
                     ?>
200
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
200
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
201 201
                 <?php } ?>
202 202
             </select>
203 203
         <?php } else { 
204
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) );
204
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway));
205 205
         } ?>
206 206
         </p>
207
-        <?php if ( $wpi_mb_invoice->is_paid() ) { ?>
208
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p>
209
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
207
+        <?php if ($wpi_mb_invoice->is_paid()) { ?>
208
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p>
209
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
210 210
         <?php } ?>
211 211
         <?php
212 212
     }
Please login to merge, or discard this patch.