@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | <?php if ( $tabs ) { ?> |
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | - } |
|
20 | - do_action( 'wpi_addons_tabs' ); |
|
21 | - ?> |
|
17 | + foreach ( $tabs as $name => $label ) { |
|
18 | + echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | + } |
|
20 | + do_action( 'wpi_addons_tabs' ); |
|
21 | + ?> |
|
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ( $current_tab == 'membership' ) { |
|
27 | 27 | |
28 | - ?> |
|
28 | + ?> |
|
29 | 29 | |
30 | 30 | <div class="wpi-membership-tab-conatiner"> |
31 | 31 | <div class="membership-content"> |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | <h2><?php _e( 'Have a membership key?', 'invoicing' ); ?></h2> |
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | - ?> |
|
39 | + $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | + echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | + ?> |
|
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | - $addon_obj = new WPInv_Admin_Addons(); |
|
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | - } |
|
56 | - } |
|
57 | - ?> |
|
51 | + $addon_obj = new WPInv_Admin_Addons(); |
|
52 | + if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | + foreach ( $addons as $addon ) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | + } |
|
56 | + } |
|
57 | + ?> |
|
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | <h3><?php _e( 'Included Gateways:', 'invoicing' ); ?></h3> |
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | - } |
|
72 | - } |
|
73 | - ?> |
|
68 | + if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | + foreach ( $addons as $addon ) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | + } |
|
72 | + } |
|
73 | + ?> |
|
74 | 74 | </ul> |
75 | 75 | </div> |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
85 | - ?> |
|
84 | + echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
85 | + ?> |
|
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
88 | 88 | <p> |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
105 | - ?> |
|
104 | + echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
105 | + ?> |
|
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
108 | 108 | <p> |
@@ -126,26 +126,26 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - } else { |
|
130 | - $installed_plugins = get_plugins(); |
|
129 | + } else { |
|
130 | + $installed_plugins = get_plugins(); |
|
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | - //print_r($addons); |
|
134 | - ?> |
|
132 | + if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | + //print_r($addons); |
|
134 | + ?> |
|
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | 137 | foreach ( $addons as $addon ) : |
138 | 138 | if ( 965 == $addon->info->id ) { |
139 | 139 | continue;}// don't show quote add on |
140 | - ?> |
|
140 | + ?> |
|
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
147 | - } |
|
148 | - echo esc_html( $addon->info->title ); |
|
145 | + if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | + echo wpi_help_tip( $addon->info->excerpt ); |
|
147 | + } |
|
148 | + echo esc_html( $addon->info->title ); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
@@ -156,32 +156,32 @@ discard block |
||
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | - $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | - } |
|
163 | - |
|
164 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
167 | - echo '</a>'; |
|
168 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
171 | - } else { |
|
172 | - // if installed show activation link |
|
173 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
174 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
175 | - } else { |
|
176 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
177 | - } |
|
178 | - } |
|
179 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
181 | - echo '</a>'; |
|
182 | - } |
|
183 | - |
|
184 | - ?> |
|
159 | + if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | + $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | + } |
|
163 | + |
|
164 | + if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | + echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | + echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
167 | + echo '</a>'; |
|
168 | + } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | + if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | + $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
171 | + } else { |
|
172 | + // if installed show activation link |
|
173 | + if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
174 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
175 | + } else { |
|
176 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
177 | + } |
|
178 | + } |
|
179 | + echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | + echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
181 | + echo '</a>'; |
|
182 | + } |
|
183 | + |
|
184 | + ?> |
|
185 | 185 | |
186 | 186 | </span> |
187 | 187 | |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | <span class="wpi-product-button"> |
190 | 190 | <?php |
191 | 191 | $addon_obj->output_button( $addon ); |
192 | - ?> |
|
192 | + ?> |
|
193 | 193 | </span> |
194 | 194 | |
195 | 195 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
196 | 196 | <?php |
197 | 197 | endif; |
198 | - } |
|
198 | + } |
|
199 | 199 | } |
200 | - ?> |
|
200 | + ?> |
|
201 | 201 | |
202 | 202 | |
203 | 203 | <div class="clearfix" ></div> |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | <input class="wpeu-licence-key" type="text" placeholder="<?php _e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e( 'Install', 'invoicing' ); ?></button> |
217 | 217 | <br> |
218 | 218 | <?php |
219 | - echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
220 | - ?> |
|
219 | + echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
220 | + ?> |
|
221 | 221 | </span> |
222 | 222 | </div> |
223 | 223 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | 12 | <h1><?php echo get_admin_page_title(); ?></h1> |
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php _e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php _e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php _e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php _e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php _e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php _e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php _e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php _e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) . '" > '; |
|
84 | + echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) . '" > '; |
|
104 | + echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,55 +129,55 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + echo wpi_help_tip($addon->info->excerpt); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | 163 | |
164 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
164 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
165 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
167 | 167 | echo '</a>'; |
168 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
168 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
169 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
170 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
171 | 171 | } else { |
172 | 172 | // if installed show activation link |
173 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
173 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
174 | 174 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
175 | 175 | } else { |
176 | 176 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
177 | 177 | } |
178 | 178 | } |
179 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | - echo '<span class="wpi-product-info">' . __( 'More info', 'invoicing' ) . '</span>'; |
|
179 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
180 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
181 | 181 | echo '</a>'; |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | <span class="wpi-product-button"> |
190 | 190 | <?php |
191 | - $addon_obj->output_button( $addon ); |
|
191 | + $addon_obj->output_button($addon); |
|
192 | 192 | ?> |
193 | 193 | </span> |
194 | 194 | |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | |
203 | 203 | <div class="clearfix" ></div> |
204 | 204 | |
205 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
206 | - <p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p> |
|
207 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
208 | - <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p> |
|
205 | + <?php if ($current_tab == 'addons') { ?> |
|
206 | + <p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p> |
|
207 | + <?php } if ($current_tab == 'gateways') { ?> |
|
208 | + <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p> |
|
209 | 209 | <?php } ?> |
210 | 210 | |
211 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ); ?></span></div> |
|
212 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ); ?></span></div> |
|
211 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div> |
|
212 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true')); ?></span></div> |
|
213 | 213 | <div id="wpeu-licence-popup" style="display:none;"> |
214 | 214 | <span class="wpi-notification noti-white"> |
215 | - <h3 class="wpeu-licence-title"><?php _e( 'Licence key', 'invoicing' ); ?></h3> |
|
216 | - <input class="wpeu-licence-key" type="text" placeholder="<?php _e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e( 'Install', 'invoicing' ); ?></button> |
|
215 | + <h3 class="wpeu-licence-title"><?php _e('Licence key', 'invoicing'); ?></h3> |
|
216 | + <input class="wpeu-licence-key" type="text" placeholder="<?php _e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e('Install', 'invoicing'); ?></button> |
|
217 | 217 | <br> |
218 | 218 | <?php |
219 | - echo sprintf( __( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
219 | + echo sprintf(__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
220 | 220 | ?> |
221 | 221 | </span> |
222 | 222 | </div> |
@@ -12,273 +12,273 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Metaboxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Only save metaboxes once. |
|
17 | - * |
|
18 | - * @var boolean |
|
19 | - */ |
|
20 | - private static $saved_meta_boxes = false; |
|
15 | + /** |
|
16 | + * Only save metaboxes once. |
|
17 | + * |
|
18 | + * @var boolean |
|
19 | + */ |
|
20 | + private static $saved_meta_boxes = false; |
|
21 | 21 | |
22 | 22 | /** |
23 | - * Hook in methods. |
|
24 | - */ |
|
25 | - public static function init() { |
|
23 | + * Hook in methods. |
|
24 | + */ |
|
25 | + public static function init() { |
|
26 | 26 | |
27 | - // Register metaboxes. |
|
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
27 | + // Register metaboxes. |
|
28 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
29 | 29 | |
30 | - // Remove metaboxes. |
|
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
30 | + // Remove metaboxes. |
|
31 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
32 | 32 | |
33 | - // Rename metaboxes. |
|
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
33 | + // Rename metaboxes. |
|
34 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
35 | 35 | |
36 | - // Save metaboxes. |
|
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | - } |
|
36 | + // Save metaboxes. |
|
37 | + add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Register core metaboxes. |
|
42 | - */ |
|
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
40 | + /** |
|
41 | + * Register core metaboxes. |
|
42 | + */ |
|
43 | + public static function add_meta_boxes( $post_type, $post ) { |
|
44 | 44 | |
45 | - // For invoices... |
|
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
45 | + // For invoices... |
|
46 | + self::add_invoice_meta_boxes( $post_type, $post ); |
|
47 | 47 | |
48 | - // For payment forms. |
|
49 | - self::add_payment_form_meta_boxes( $post_type, $post ); |
|
48 | + // For payment forms. |
|
49 | + self::add_payment_form_meta_boxes( $post_type, $post ); |
|
50 | 50 | |
51 | - // For invoice items. |
|
52 | - self::add_item_meta_boxes( $post_type ); |
|
51 | + // For invoice items. |
|
52 | + self::add_item_meta_boxes( $post_type ); |
|
53 | 53 | |
54 | - // For invoice discounts. |
|
55 | - if ( $post_type == 'wpi_discount' ) { |
|
56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
57 | - } |
|
54 | + // For invoice discounts. |
|
55 | + if ( $post_type == 'wpi_discount' ) { |
|
56 | + add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
57 | + } |
|
58 | 58 | |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Register core metaboxes. |
|
63 | - */ |
|
64 | - protected static function add_payment_form_meta_boxes( $post_type, $post ) { |
|
61 | + /** |
|
62 | + * Register core metaboxes. |
|
63 | + */ |
|
64 | + protected static function add_payment_form_meta_boxes( $post_type, $post ) { |
|
65 | 65 | |
66 | - // For payment forms. |
|
67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
66 | + // For payment forms. |
|
67 | + if ( $post_type == 'wpi_payment_form' ) { |
|
68 | 68 | |
69 | - // Design payment form. |
|
70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
69 | + // Design payment form. |
|
70 | + add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
71 | 71 | |
72 | - // Payment form information. |
|
73 | - if ( $post->ID != wpinv_get_default_payment_form() ) { |
|
74 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
75 | - } |
|
72 | + // Payment form information. |
|
73 | + if ( $post->ID != wpinv_get_default_payment_form() ) { |
|
74 | + add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | |
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Register core metaboxes. |
|
82 | - */ |
|
83 | - protected static function add_item_meta_boxes( $post_type ) { |
|
78 | + } |
|
84 | 79 | |
85 | - if ( $post_type == 'wpi_item' ) { |
|
86 | - |
|
87 | - // Item details. |
|
88 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
89 | - |
|
90 | - // If taxes are enabled, register the tax metabox. |
|
91 | - if ( wpinv_use_taxes() ) { |
|
92 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
93 | - } |
|
80 | + /** |
|
81 | + * Register core metaboxes. |
|
82 | + */ |
|
83 | + protected static function add_item_meta_boxes( $post_type ) { |
|
94 | 84 | |
95 | - // Item info. |
|
96 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
85 | + if ( $post_type == 'wpi_item' ) { |
|
97 | 86 | |
98 | - } |
|
87 | + // Item details. |
|
88 | + add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
99 | 89 | |
100 | - } |
|
90 | + // If taxes are enabled, register the tax metabox. |
|
91 | + if ( wpinv_use_taxes() ) { |
|
92 | + add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
93 | + } |
|
101 | 94 | |
102 | - /** |
|
103 | - * Register invoice metaboxes. |
|
104 | - */ |
|
105 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
95 | + // Item info. |
|
96 | + add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
106 | 97 | |
107 | - // For invoices... |
|
108 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
109 | - $invoice = new WPInv_Invoice( $post ); |
|
98 | + } |
|
110 | 99 | |
111 | - // Resend invoice. |
|
112 | - if ( ! $invoice->is_draft() ) { |
|
100 | + } |
|
113 | 101 | |
114 | - add_meta_box( |
|
115 | - 'wpinv-mb-resend-invoice', |
|
116 | - sprintf( |
|
117 | - __( 'Resend %s', 'invoicing' ), |
|
118 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
119 | - ), |
|
120 | - 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
121 | - $post_type, |
|
122 | - 'side', |
|
123 | - 'low' |
|
124 | - ); |
|
102 | + /** |
|
103 | + * Register invoice metaboxes. |
|
104 | + */ |
|
105 | + protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
106 | + |
|
107 | + // For invoices... |
|
108 | + if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
109 | + $invoice = new WPInv_Invoice( $post ); |
|
110 | + |
|
111 | + // Resend invoice. |
|
112 | + if ( ! $invoice->is_draft() ) { |
|
113 | + |
|
114 | + add_meta_box( |
|
115 | + 'wpinv-mb-resend-invoice', |
|
116 | + sprintf( |
|
117 | + __( 'Resend %s', 'invoicing' ), |
|
118 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
119 | + ), |
|
120 | + 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
121 | + $post_type, |
|
122 | + 'side', |
|
123 | + 'low' |
|
124 | + ); |
|
125 | + |
|
126 | + } |
|
127 | + |
|
128 | + // Subscriptions. |
|
129 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
130 | + if ( ! empty( $subscriptions ) ) { |
|
131 | + |
|
132 | + if ( is_array( $subscriptions ) ) { |
|
133 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
134 | + } else { |
|
135 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
136 | + } |
|
137 | + |
|
138 | + if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
139 | + add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
140 | + } |
|
141 | +} |
|
125 | 142 | |
126 | - } |
|
143 | + // Invoice details. |
|
144 | + add_meta_box( |
|
145 | + 'wpinv-details', |
|
146 | + sprintf( |
|
147 | + __( '%s Details', 'invoicing' ), |
|
148 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
149 | + ), |
|
150 | + 'GetPaid_Meta_Box_Invoice_Details::output', |
|
151 | + $post_type, |
|
152 | + 'side' |
|
153 | + ); |
|
154 | + |
|
155 | + // Payment details. |
|
156 | + add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
157 | + |
|
158 | + // Billing details. |
|
159 | + add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
160 | + |
|
161 | + // Invoice items. |
|
162 | + add_meta_box( |
|
163 | + 'wpinv-items', |
|
164 | + sprintf( |
|
165 | + __( '%s Items', 'invoicing' ), |
|
166 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
167 | + ), |
|
168 | + 'GetPaid_Meta_Box_Invoice_Items::output', |
|
169 | + $post_type, |
|
170 | + 'normal', |
|
171 | + 'high' |
|
172 | + ); |
|
173 | + |
|
174 | + // Invoice notes. |
|
175 | + add_meta_box( |
|
176 | + 'wpinv-notes', |
|
177 | + sprintf( |
|
178 | + __( '%s Notes', 'invoicing' ), |
|
179 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
180 | + ), |
|
181 | + 'WPInv_Meta_Box_Notes::output', |
|
182 | + $post_type, |
|
183 | + 'side', |
|
184 | + 'low' |
|
185 | + ); |
|
186 | + |
|
187 | + // Shipping Address. |
|
188 | + if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
189 | + add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
190 | + } |
|
191 | + |
|
192 | + // Payment form information. |
|
193 | + if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
194 | + add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
195 | + } |
|
196 | +} |
|
127 | 197 | |
128 | - // Subscriptions. |
|
129 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
130 | - if ( ! empty( $subscriptions ) ) { |
|
198 | + } |
|
131 | 199 | |
132 | - if ( is_array( $subscriptions ) ) { |
|
133 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
134 | - } else { |
|
135 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
136 | - } |
|
200 | + /** |
|
201 | + * Remove some metaboxes. |
|
202 | + */ |
|
203 | + public static function remove_meta_boxes() { |
|
204 | + remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
205 | + } |
|
137 | 206 | |
138 | - if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
139 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
140 | - } |
|
141 | -} |
|
207 | + /** |
|
208 | + * Rename other metaboxes. |
|
209 | + */ |
|
210 | + public static function rename_meta_boxes() { |
|
142 | 211 | |
143 | - // Invoice details. |
|
144 | - add_meta_box( |
|
145 | - 'wpinv-details', |
|
146 | - sprintf( |
|
147 | - __( '%s Details', 'invoicing' ), |
|
148 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
149 | - ), |
|
150 | - 'GetPaid_Meta_Box_Invoice_Details::output', |
|
151 | - $post_type, |
|
152 | - 'side' |
|
153 | - ); |
|
154 | - |
|
155 | - // Payment details. |
|
156 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
157 | - |
|
158 | - // Billing details. |
|
159 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
160 | - |
|
161 | - // Invoice items. |
|
162 | - add_meta_box( |
|
163 | - 'wpinv-items', |
|
164 | - sprintf( |
|
165 | - __( '%s Items', 'invoicing' ), |
|
166 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
167 | - ), |
|
168 | - 'GetPaid_Meta_Box_Invoice_Items::output', |
|
169 | - $post_type, |
|
170 | - 'normal', |
|
171 | - 'high' |
|
172 | - ); |
|
173 | - |
|
174 | - // Invoice notes. |
|
175 | - add_meta_box( |
|
176 | - 'wpinv-notes', |
|
177 | - sprintf( |
|
178 | - __( '%s Notes', 'invoicing' ), |
|
179 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
180 | - ), |
|
181 | - 'WPInv_Meta_Box_Notes::output', |
|
182 | - $post_type, |
|
183 | - 'side', |
|
184 | - 'low' |
|
185 | - ); |
|
186 | - |
|
187 | - // Shipping Address. |
|
188 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
189 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
190 | - } |
|
191 | - |
|
192 | - // Payment form information. |
|
193 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
194 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
195 | - } |
|
196 | -} |
|
212 | + } |
|
197 | 213 | |
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Remove some metaboxes. |
|
202 | - */ |
|
203 | - public static function remove_meta_boxes() { |
|
204 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Rename other metaboxes. |
|
209 | - */ |
|
210 | - public static function rename_meta_boxes() { |
|
211 | - |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Check if we're saving, then trigger an action based on the post type. |
|
216 | - * |
|
217 | - * @param int $post_id Post ID. |
|
218 | - * @param object $post Post object. |
|
219 | - */ |
|
220 | - public static function save_meta_boxes( $post_id, $post ) { |
|
221 | - $post_id = absint( $post_id ); |
|
222 | - $data = wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
223 | - |
|
224 | - // Do not save for ajax requests. |
|
225 | - if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
226 | - return; |
|
227 | - } |
|
228 | - |
|
229 | - // $post_id and $post are required |
|
230 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
231 | - return; |
|
232 | - } |
|
233 | - |
|
234 | - // Dont' save meta boxes for revisions or autosaves. |
|
235 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
236 | - return; |
|
237 | - } |
|
238 | - |
|
239 | - // Check the nonce. |
|
240 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
241 | - return; |
|
242 | - } |
|
243 | - |
|
244 | - // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
245 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
246 | - return; |
|
247 | - } |
|
248 | - |
|
249 | - // Check user has permission to edit. |
|
250 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
251 | - return; |
|
252 | - } |
|
253 | - |
|
254 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
255 | - |
|
256 | - // We need this save event to run once to avoid potential endless loops. |
|
257 | - self::$saved_meta_boxes = true; |
|
258 | - |
|
259 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
260 | - |
|
261 | - } |
|
262 | - |
|
263 | - // Ensure this is our post type. |
|
264 | - $post_types_map = array( |
|
265 | - 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
266 | - 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
267 | - 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
268 | - ); |
|
269 | - |
|
270 | - // Is this our post type? |
|
271 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
272 | - return; |
|
273 | - } |
|
274 | - |
|
275 | - // We need this save event to run once to avoid potential endless loops. |
|
276 | - self::$saved_meta_boxes = true; |
|
277 | - |
|
278 | - // Save the post. |
|
279 | - $class = $post_types_map[ $post->post_type ]; |
|
280 | - $class::save( $post_id, wp_kses_post_deep( $_POST ), $post ); |
|
281 | - |
|
282 | - } |
|
214 | + /** |
|
215 | + * Check if we're saving, then trigger an action based on the post type. |
|
216 | + * |
|
217 | + * @param int $post_id Post ID. |
|
218 | + * @param object $post Post object. |
|
219 | + */ |
|
220 | + public static function save_meta_boxes( $post_id, $post ) { |
|
221 | + $post_id = absint( $post_id ); |
|
222 | + $data = wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
223 | + |
|
224 | + // Do not save for ajax requests. |
|
225 | + if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
226 | + return; |
|
227 | + } |
|
228 | + |
|
229 | + // $post_id and $post are required |
|
230 | + if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
231 | + return; |
|
232 | + } |
|
233 | + |
|
234 | + // Dont' save meta boxes for revisions or autosaves. |
|
235 | + if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
236 | + return; |
|
237 | + } |
|
238 | + |
|
239 | + // Check the nonce. |
|
240 | + if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
241 | + return; |
|
242 | + } |
|
243 | + |
|
244 | + // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
245 | + if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
246 | + return; |
|
247 | + } |
|
248 | + |
|
249 | + // Check user has permission to edit. |
|
250 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
251 | + return; |
|
252 | + } |
|
253 | + |
|
254 | + if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
255 | + |
|
256 | + // We need this save event to run once to avoid potential endless loops. |
|
257 | + self::$saved_meta_boxes = true; |
|
258 | + |
|
259 | + return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
260 | + |
|
261 | + } |
|
262 | + |
|
263 | + // Ensure this is our post type. |
|
264 | + $post_types_map = array( |
|
265 | + 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
266 | + 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
267 | + 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
268 | + ); |
|
269 | + |
|
270 | + // Is this our post type? |
|
271 | + if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
272 | + return; |
|
273 | + } |
|
274 | + |
|
275 | + // We need this save event to run once to avoid potential endless loops. |
|
276 | + self::$saved_meta_boxes = true; |
|
277 | + |
|
278 | + // Save the post. |
|
279 | + $class = $post_types_map[ $post->post_type ]; |
|
280 | + $class::save( $post_id, wp_kses_post_deep( $_POST ), $post ); |
|
281 | + |
|
282 | + } |
|
283 | 283 | |
284 | 284 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Metaboxes Admin Class |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | public static function init() { |
26 | 26 | |
27 | 27 | // Register metaboxes. |
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2); |
|
29 | 29 | |
30 | 30 | // Remove metaboxes. |
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
32 | 32 | |
33 | 33 | // Rename metaboxes. |
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
35 | 35 | |
36 | 36 | // Save metaboxes. |
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register core metaboxes. |
42 | 42 | */ |
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
43 | + public static function add_meta_boxes($post_type, $post) { |
|
44 | 44 | |
45 | 45 | // For invoices... |
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
46 | + self::add_invoice_meta_boxes($post_type, $post); |
|
47 | 47 | |
48 | 48 | // For payment forms. |
49 | - self::add_payment_form_meta_boxes( $post_type, $post ); |
|
49 | + self::add_payment_form_meta_boxes($post_type, $post); |
|
50 | 50 | |
51 | 51 | // For invoice items. |
52 | - self::add_item_meta_boxes( $post_type ); |
|
52 | + self::add_item_meta_boxes($post_type); |
|
53 | 53 | |
54 | 54 | // For invoice discounts. |
55 | - if ( $post_type == 'wpi_discount' ) { |
|
56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
55 | + if ($post_type == 'wpi_discount') { |
|
56 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Register core metaboxes. |
63 | 63 | */ |
64 | - protected static function add_payment_form_meta_boxes( $post_type, $post ) { |
|
64 | + protected static function add_payment_form_meta_boxes($post_type, $post) { |
|
65 | 65 | |
66 | 66 | // For payment forms. |
67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
67 | + if ($post_type == 'wpi_payment_form') { |
|
68 | 68 | |
69 | 69 | // Design payment form. |
70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
70 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
71 | 71 | |
72 | 72 | // Payment form information. |
73 | - if ( $post->ID != wpinv_get_default_payment_form() ) { |
|
74 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
73 | + if ($post->ID != wpinv_get_default_payment_form()) { |
|
74 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * Register core metaboxes. |
82 | 82 | */ |
83 | - protected static function add_item_meta_boxes( $post_type ) { |
|
83 | + protected static function add_item_meta_boxes($post_type) { |
|
84 | 84 | |
85 | - if ( $post_type == 'wpi_item' ) { |
|
85 | + if ($post_type == 'wpi_item') { |
|
86 | 86 | |
87 | 87 | // Item details. |
88 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
88 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
89 | 89 | |
90 | 90 | // If taxes are enabled, register the tax metabox. |
91 | - if ( wpinv_use_taxes() ) { |
|
92 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
91 | + if (wpinv_use_taxes()) { |
|
92 | + add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Item info. |
96 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
96 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * Register invoice metaboxes. |
104 | 104 | */ |
105 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
105 | + protected static function add_invoice_meta_boxes($post_type, $post) { |
|
106 | 106 | |
107 | 107 | // For invoices... |
108 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
109 | - $invoice = new WPInv_Invoice( $post ); |
|
108 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
109 | + $invoice = new WPInv_Invoice($post); |
|
110 | 110 | |
111 | 111 | // Resend invoice. |
112 | - if ( ! $invoice->is_draft() ) { |
|
112 | + if (!$invoice->is_draft()) { |
|
113 | 113 | |
114 | 114 | add_meta_box( |
115 | 115 | 'wpinv-mb-resend-invoice', |
116 | 116 | sprintf( |
117 | - __( 'Resend %s', 'invoicing' ), |
|
118 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
117 | + __('Resend %s', 'invoicing'), |
|
118 | + ucfirst($invoice->get_invoice_quote_type()) |
|
119 | 119 | ), |
120 | 120 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
121 | 121 | $post_type, |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // Subscriptions. |
129 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
130 | - if ( ! empty( $subscriptions ) ) { |
|
129 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
130 | + if (!empty($subscriptions)) { |
|
131 | 131 | |
132 | - if ( is_array( $subscriptions ) ) { |
|
133 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
132 | + if (is_array($subscriptions)) { |
|
133 | + add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced'); |
|
134 | 134 | } else { |
135 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
135 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
139 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
138 | + if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) { |
|
139 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | add_meta_box( |
145 | 145 | 'wpinv-details', |
146 | 146 | sprintf( |
147 | - __( '%s Details', 'invoicing' ), |
|
148 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
147 | + __('%s Details', 'invoicing'), |
|
148 | + ucfirst($invoice->get_invoice_quote_type()) |
|
149 | 149 | ), |
150 | 150 | 'GetPaid_Meta_Box_Invoice_Details::output', |
151 | 151 | $post_type, |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | ); |
154 | 154 | |
155 | 155 | // Payment details. |
156 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
156 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
157 | 157 | |
158 | 158 | // Billing details. |
159 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
159 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
160 | 160 | |
161 | 161 | // Invoice items. |
162 | 162 | add_meta_box( |
163 | 163 | 'wpinv-items', |
164 | 164 | sprintf( |
165 | - __( '%s Items', 'invoicing' ), |
|
166 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
165 | + __('%s Items', 'invoicing'), |
|
166 | + ucfirst($invoice->get_invoice_quote_type()) |
|
167 | 167 | ), |
168 | 168 | 'GetPaid_Meta_Box_Invoice_Items::output', |
169 | 169 | $post_type, |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | add_meta_box( |
176 | 176 | 'wpinv-notes', |
177 | 177 | sprintf( |
178 | - __( '%s Notes', 'invoicing' ), |
|
179 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
178 | + __('%s Notes', 'invoicing'), |
|
179 | + ucfirst($invoice->get_invoice_quote_type()) |
|
180 | 180 | ), |
181 | 181 | 'WPInv_Meta_Box_Notes::output', |
182 | 182 | $post_type, |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | ); |
186 | 186 | |
187 | 187 | // Shipping Address. |
188 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
189 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
188 | + if (get_post_meta($invoice->get_id(), 'shipping_address', true)) { |
|
189 | + add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // Payment form information. |
193 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
194 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
193 | + if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) { |
|
194 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * Remove some metaboxes. |
202 | 202 | */ |
203 | 203 | public static function remove_meta_boxes() { |
204 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
204 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -217,46 +217,46 @@ discard block |
||
217 | 217 | * @param int $post_id Post ID. |
218 | 218 | * @param object $post Post object. |
219 | 219 | */ |
220 | - public static function save_meta_boxes( $post_id, $post ) { |
|
221 | - $post_id = absint( $post_id ); |
|
222 | - $data = wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
220 | + public static function save_meta_boxes($post_id, $post) { |
|
221 | + $post_id = absint($post_id); |
|
222 | + $data = wp_kses_post_deep(wp_unslash($_POST)); |
|
223 | 223 | |
224 | 224 | // Do not save for ajax requests. |
225 | - if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
225 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // $post_id and $post are required |
230 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
230 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | // Dont' save meta boxes for revisions or autosaves. |
235 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
235 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Check the nonce. |
240 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
240 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | 244 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
245 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
245 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | // Check user has permission to edit. |
250 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
250 | + if (!current_user_can('edit_post', $post_id)) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
254 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
254 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
255 | 255 | |
256 | 256 | // We need this save event to run once to avoid potential endless loops. |
257 | 257 | self::$saved_meta_boxes = true; |
258 | 258 | |
259 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
259 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id); |
|
260 | 260 | |
261 | 261 | } |
262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | ); |
269 | 269 | |
270 | 270 | // Is this our post type? |
271 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
271 | + if (!isset($post_types_map[$post->post_type])) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | self::$saved_meta_boxes = true; |
277 | 277 | |
278 | 278 | // Save the post. |
279 | - $class = $post_types_map[ $post->post_type ]; |
|
280 | - $class::save( $post_id, wp_kses_post_deep( $_POST ), $post ); |
|
279 | + $class = $post_types_map[$post->post_type]; |
|
280 | + $class::save($post_id, wp_kses_post_deep($_POST), $post); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 |
@@ -17,396 +17,396 @@ |
||
17 | 17 | */ |
18 | 18 | class GetPaid_Admin_Setup_Wizard { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string Current Step |
|
22 | - */ |
|
23 | - protected $step = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string|false Previous Step |
|
27 | - */ |
|
28 | - protected $previous_step = ''; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string|false Next Step |
|
32 | - */ |
|
33 | - protected $next_step = ''; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var array All available steps for the setup wizard |
|
37 | - */ |
|
38 | - protected $steps = array(); |
|
39 | - |
|
40 | - /** |
|
41 | - * Class constructor. |
|
42 | - * |
|
43 | - * @since 2.4.0 |
|
44 | - */ |
|
45 | - public function __construct() { |
|
46 | - |
|
47 | - if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
48 | - add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
49 | - add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
50 | - } |
|
51 | - |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Add admin menus/screens. |
|
56 | - * |
|
57 | - * @since 2.4.0 |
|
58 | - */ |
|
59 | - public function add_menu() { |
|
60 | - add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Sets up the setup wizard. |
|
65 | - * |
|
66 | - * @since 2.4.0 |
|
67 | - */ |
|
68 | - public function setup_wizard() { |
|
69 | - |
|
70 | - if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
71 | - $this->setup_globals(); |
|
72 | - $this->maybe_save_current_step(); |
|
73 | - $this->display_wizard(); |
|
74 | - exit; |
|
75 | - } |
|
76 | - |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Sets up class variables. |
|
81 | - * |
|
82 | - * @since 2.4.0 |
|
83 | - */ |
|
84 | - protected function setup_globals() { |
|
85 | - $this->steps = $this->get_setup_steps(); |
|
86 | - $this->step = $this->get_current_step(); |
|
87 | - $this->previous_step = $this->get_previous_step(); |
|
88 | - $this->next_step = $this->get_next_step(); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Saves the current step. |
|
93 | - * |
|
94 | - * @since 2.4.0 |
|
95 | - */ |
|
96 | - protected function maybe_save_current_step() { |
|
97 | - if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
98 | - call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Returns the setup steps. |
|
104 | - * |
|
105 | - * @since 2.4.0 |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - protected function get_setup_steps() { |
|
109 | - |
|
110 | - $steps = array( |
|
111 | - |
|
112 | - 'introduction' => array( |
|
113 | - 'name' => __( 'Introduction', 'invoicing' ), |
|
114 | - 'view' => array( $this, 'setup_introduction' ), |
|
115 | - 'handler' => '', |
|
116 | - ), |
|
117 | - |
|
118 | - 'business_details' => array( |
|
119 | - 'name' => __( 'Business Details', 'invoicing' ), |
|
120 | - 'view' => array( $this, 'setup_business' ), |
|
121 | - 'handler' => '', |
|
122 | - ), |
|
123 | - |
|
124 | - 'currency' => array( |
|
125 | - 'name' => __( 'Currency', 'invoicing' ), |
|
126 | - 'view' => array( $this, 'setup_currency' ), |
|
127 | - 'handler' => '', |
|
128 | - ), |
|
129 | - |
|
130 | - 'payments' => array( |
|
131 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
132 | - 'view' => array( $this, 'setup_payments' ), |
|
133 | - 'handler' => array( $this, 'setup_payments_save' ), |
|
134 | - ), |
|
135 | - |
|
136 | - 'recommend' => array( |
|
137 | - 'name' => __( 'Recommend', 'invoicing' ), |
|
138 | - 'view' => array( $this, 'setup_recommend' ), |
|
139 | - 'handler' => '', |
|
140 | - ), |
|
141 | - |
|
142 | - 'next_steps' => array( |
|
143 | - 'name' => __( 'Get Paid', 'invoicing' ), |
|
144 | - 'view' => array( $this, 'setup_ready' ), |
|
145 | - 'handler' => '', |
|
146 | - ), |
|
147 | - |
|
148 | - ); |
|
149 | - |
|
150 | - return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
151 | - |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns the current step. |
|
156 | - * |
|
157 | - * @since 2.4.0 |
|
158 | - * @return string |
|
159 | - */ |
|
160 | - protected function get_current_step() { |
|
161 | - $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
162 | - return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns the previous step. |
|
167 | - * |
|
168 | - * @since 2.4.0 |
|
169 | - * @return string|false |
|
170 | - */ |
|
171 | - protected function get_previous_step() { |
|
172 | - |
|
173 | - $previous = false; |
|
174 | - $current = $this->step; |
|
175 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
176 | - if ( $current === $step ) { |
|
177 | - return $previous; |
|
178 | - } |
|
179 | - |
|
180 | - $previous = $step; |
|
181 | - } |
|
182 | - |
|
183 | - return false; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Returns the next step. |
|
188 | - * |
|
189 | - * @since 2.4.0 |
|
190 | - * @return string|false |
|
191 | - */ |
|
192 | - protected function get_next_step() { |
|
193 | - |
|
194 | - $on_current = false; |
|
195 | - $current = $this->step; |
|
196 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
197 | - |
|
198 | - if ( $on_current ) { |
|
199 | - return $step; |
|
200 | - } |
|
201 | - |
|
202 | - if ( $current === $step ) { |
|
203 | - return $on_current = true; |
|
204 | - } |
|
20 | + /** |
|
21 | + * @var string Current Step |
|
22 | + */ |
|
23 | + protected $step = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string|false Previous Step |
|
27 | + */ |
|
28 | + protected $previous_step = ''; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string|false Next Step |
|
32 | + */ |
|
33 | + protected $next_step = ''; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var array All available steps for the setup wizard |
|
37 | + */ |
|
38 | + protected $steps = array(); |
|
39 | + |
|
40 | + /** |
|
41 | + * Class constructor. |
|
42 | + * |
|
43 | + * @since 2.4.0 |
|
44 | + */ |
|
45 | + public function __construct() { |
|
46 | + |
|
47 | + if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
48 | + add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
49 | + add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
50 | + } |
|
51 | + |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Add admin menus/screens. |
|
56 | + * |
|
57 | + * @since 2.4.0 |
|
58 | + */ |
|
59 | + public function add_menu() { |
|
60 | + add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Sets up the setup wizard. |
|
65 | + * |
|
66 | + * @since 2.4.0 |
|
67 | + */ |
|
68 | + public function setup_wizard() { |
|
69 | + |
|
70 | + if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
71 | + $this->setup_globals(); |
|
72 | + $this->maybe_save_current_step(); |
|
73 | + $this->display_wizard(); |
|
74 | + exit; |
|
75 | + } |
|
76 | + |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Sets up class variables. |
|
81 | + * |
|
82 | + * @since 2.4.0 |
|
83 | + */ |
|
84 | + protected function setup_globals() { |
|
85 | + $this->steps = $this->get_setup_steps(); |
|
86 | + $this->step = $this->get_current_step(); |
|
87 | + $this->previous_step = $this->get_previous_step(); |
|
88 | + $this->next_step = $this->get_next_step(); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Saves the current step. |
|
93 | + * |
|
94 | + * @since 2.4.0 |
|
95 | + */ |
|
96 | + protected function maybe_save_current_step() { |
|
97 | + if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
98 | + call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Returns the setup steps. |
|
104 | + * |
|
105 | + * @since 2.4.0 |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + protected function get_setup_steps() { |
|
109 | + |
|
110 | + $steps = array( |
|
111 | + |
|
112 | + 'introduction' => array( |
|
113 | + 'name' => __( 'Introduction', 'invoicing' ), |
|
114 | + 'view' => array( $this, 'setup_introduction' ), |
|
115 | + 'handler' => '', |
|
116 | + ), |
|
117 | + |
|
118 | + 'business_details' => array( |
|
119 | + 'name' => __( 'Business Details', 'invoicing' ), |
|
120 | + 'view' => array( $this, 'setup_business' ), |
|
121 | + 'handler' => '', |
|
122 | + ), |
|
123 | + |
|
124 | + 'currency' => array( |
|
125 | + 'name' => __( 'Currency', 'invoicing' ), |
|
126 | + 'view' => array( $this, 'setup_currency' ), |
|
127 | + 'handler' => '', |
|
128 | + ), |
|
129 | + |
|
130 | + 'payments' => array( |
|
131 | + 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
132 | + 'view' => array( $this, 'setup_payments' ), |
|
133 | + 'handler' => array( $this, 'setup_payments_save' ), |
|
134 | + ), |
|
135 | + |
|
136 | + 'recommend' => array( |
|
137 | + 'name' => __( 'Recommend', 'invoicing' ), |
|
138 | + 'view' => array( $this, 'setup_recommend' ), |
|
139 | + 'handler' => '', |
|
140 | + ), |
|
141 | + |
|
142 | + 'next_steps' => array( |
|
143 | + 'name' => __( 'Get Paid', 'invoicing' ), |
|
144 | + 'view' => array( $this, 'setup_ready' ), |
|
145 | + 'handler' => '', |
|
146 | + ), |
|
147 | + |
|
148 | + ); |
|
149 | + |
|
150 | + return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
151 | + |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns the current step. |
|
156 | + * |
|
157 | + * @since 2.4.0 |
|
158 | + * @return string |
|
159 | + */ |
|
160 | + protected function get_current_step() { |
|
161 | + $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
162 | + return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns the previous step. |
|
167 | + * |
|
168 | + * @since 2.4.0 |
|
169 | + * @return string|false |
|
170 | + */ |
|
171 | + protected function get_previous_step() { |
|
172 | + |
|
173 | + $previous = false; |
|
174 | + $current = $this->step; |
|
175 | + foreach ( array_keys( $this->steps ) as $step ) { |
|
176 | + if ( $current === $step ) { |
|
177 | + return $previous; |
|
178 | + } |
|
179 | + |
|
180 | + $previous = $step; |
|
181 | + } |
|
182 | + |
|
183 | + return false; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Returns the next step. |
|
188 | + * |
|
189 | + * @since 2.4.0 |
|
190 | + * @return string|false |
|
191 | + */ |
|
192 | + protected function get_next_step() { |
|
193 | + |
|
194 | + $on_current = false; |
|
195 | + $current = $this->step; |
|
196 | + foreach ( array_keys( $this->steps ) as $step ) { |
|
197 | + |
|
198 | + if ( $on_current ) { |
|
199 | + return $step; |
|
200 | + } |
|
201 | + |
|
202 | + if ( $current === $step ) { |
|
203 | + return $on_current = true; |
|
204 | + } |
|
205 | 205 | } |
206 | 206 | |
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Displays the setup wizard. |
|
212 | - * |
|
213 | - * @since 2.4.0 |
|
214 | - */ |
|
215 | - public function display_wizard() { |
|
216 | - $this->display_header(); |
|
217 | - $this->display_current_step(); |
|
218 | - $this->display_footer(); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Displays the Wizard Header. |
|
223 | - * |
|
224 | - * @since 2.0.0 |
|
225 | - */ |
|
226 | - public function display_header() { |
|
227 | - $steps = $this->steps; |
|
228 | - $current = $this->step; |
|
229 | - $next_step = $this->next_step; |
|
230 | - array_shift( $steps ); |
|
231 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Displays the content for the current step. |
|
236 | - * |
|
237 | - * @since 2.4.0 |
|
238 | - */ |
|
239 | - public function display_current_step() { |
|
240 | - ?> |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Displays the setup wizard. |
|
212 | + * |
|
213 | + * @since 2.4.0 |
|
214 | + */ |
|
215 | + public function display_wizard() { |
|
216 | + $this->display_header(); |
|
217 | + $this->display_current_step(); |
|
218 | + $this->display_footer(); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Displays the Wizard Header. |
|
223 | + * |
|
224 | + * @since 2.0.0 |
|
225 | + */ |
|
226 | + public function display_header() { |
|
227 | + $steps = $this->steps; |
|
228 | + $current = $this->step; |
|
229 | + $next_step = $this->next_step; |
|
230 | + array_shift( $steps ); |
|
231 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Displays the content for the current step. |
|
236 | + * |
|
237 | + * @since 2.4.0 |
|
238 | + */ |
|
239 | + public function display_current_step() { |
|
240 | + ?> |
|
241 | 241 | <div class="gp-setup-content rowx mw-100 text-center mb-3"> |
242 | 242 | <div class="col-12 col-md-5 m-auto"> |
243 | 243 | <?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?> |
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Setup Wizard Footer. |
|
251 | - * |
|
252 | - * @since 2.4.0 |
|
253 | - */ |
|
254 | - public function display_footer() { |
|
255 | - |
|
256 | - if ( isset( $_GET['step'] ) ) { |
|
257 | - $next_url = esc_url( $this->get_next_step_link() ); |
|
258 | - $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
259 | - |
|
260 | - echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>'; |
|
261 | - } |
|
262 | - |
|
263 | - echo '</body></html>'; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Introduction step. |
|
268 | - * |
|
269 | - * @since 2.0.0 |
|
270 | - */ |
|
271 | - public function setup_introduction() { |
|
272 | - $next_url = $this->get_next_step_link(); |
|
273 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Get the URL for the next step's screen. |
|
278 | - * |
|
279 | - * @param string step slug (default: current step) |
|
280 | - * |
|
281 | - * @return string URL for next step if a next step exists. |
|
282 | - * Admin URL if it's the last step. |
|
283 | - * Empty string on failure. |
|
284 | - * @since 3.0.0 |
|
285 | - */ |
|
286 | - public function get_next_step_link( $step = '' ) { |
|
287 | - if ( ! $step ) { |
|
288 | - $step = $this->step; |
|
289 | - } |
|
290 | - |
|
291 | - $keys = array_keys( $this->steps ); |
|
292 | - if ( end( $keys ) === $step ) { |
|
293 | - return admin_url(); |
|
294 | - } |
|
295 | - |
|
296 | - $step_index = array_search( $step, $keys ); |
|
297 | - if ( false === $step_index ) { |
|
298 | - return ''; |
|
299 | - } |
|
300 | - |
|
301 | - return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) ); |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Setup maps api. |
|
306 | - * |
|
307 | - * @since 2.0.0 |
|
308 | - */ |
|
309 | - public function setup_business() { |
|
310 | - $next_url = $this->get_next_step_link(); |
|
311 | - $wizard = $this; |
|
312 | - $page = 'wpinv_settings_general_main'; |
|
313 | - $section = 'wpinv_settings_general_main'; |
|
314 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * Default Location settings. |
|
319 | - * |
|
320 | - * @since 2.0.0 |
|
321 | - */ |
|
322 | - public function setup_currency() { |
|
323 | - $next_url = $this->get_next_step_link(); |
|
324 | - $wizard = $this; |
|
325 | - $page = 'wpinv_settings_general_currency_section'; |
|
326 | - $section = 'wpinv_settings_general_currency_section'; |
|
327 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Installation of recommended plugins. |
|
332 | - * |
|
333 | - * @since 1.0.0 |
|
334 | - */ |
|
335 | - public function setup_recommend() { |
|
336 | - $next_url = $this->get_next_step_link(); |
|
337 | - $recommended_plugins = self::get_recommend_wp_plugins(); |
|
338 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * A list of recommended wp.org plugins. |
|
343 | - * @return array |
|
344 | - */ |
|
345 | - public static function get_recommend_wp_plugins() { |
|
346 | - return array( |
|
347 | - 'ayecode-connect' => array( |
|
348 | - 'file' => 'ayecode-connect/ayecode-connect.php', |
|
349 | - 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
|
350 | - 'slug' => 'ayecode-connect', |
|
351 | - 'name' => 'AyeCode Connect', |
|
352 | - 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
|
353 | - ), |
|
354 | - 'invoicing-quotes' => array( |
|
355 | - 'file' => 'invoicing-quotes/wpinv-quote.php', |
|
356 | - 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
|
357 | - 'slug' => 'invoicing-quotes', |
|
358 | - 'name' => 'Customer Quotes', |
|
359 | - 'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'geodirectory' ), |
|
360 | - ), |
|
361 | - 'userswp' => array( |
|
362 | - 'file' => 'userswp/userswp.php', |
|
363 | - 'url' => 'https://wordpress.org/plugins/userswp/', |
|
364 | - 'slug' => 'userswp', |
|
365 | - 'name' => 'UsersWP', |
|
366 | - 'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'geodirectory' ), |
|
367 | - ), |
|
368 | - ); |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Dummy Data setup. |
|
373 | - * |
|
374 | - * @since 2.4.0 |
|
375 | - */ |
|
376 | - public function setup_payments() { |
|
377 | - $next_url = $this->get_next_step_link(); |
|
378 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * Dummy data save. |
|
383 | - * |
|
384 | - * This is done via ajax so we just pass onto the next step. |
|
385 | - * |
|
386 | - * @since 2.0.0 |
|
387 | - */ |
|
388 | - public function setup_payments_save() { |
|
389 | - check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
390 | - wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
391 | - |
|
392 | - if ( ! empty( $_POST['paypal-email'] ) ) { |
|
393 | - wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) ); |
|
394 | - wpinv_update_option( 'paypal_active', 1 ); |
|
395 | - wpinv_update_option( 'paypal_sandbox', 0 ); |
|
396 | - } |
|
397 | - |
|
398 | - wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
399 | - exit; |
|
400 | - } |
|
401 | - |
|
402 | - /** |
|
403 | - * Final step. |
|
404 | - * |
|
405 | - * @since 2.0.0 |
|
406 | - */ |
|
407 | - public function setup_ready() { |
|
408 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
409 | - } |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Setup Wizard Footer. |
|
251 | + * |
|
252 | + * @since 2.4.0 |
|
253 | + */ |
|
254 | + public function display_footer() { |
|
255 | + |
|
256 | + if ( isset( $_GET['step'] ) ) { |
|
257 | + $next_url = esc_url( $this->get_next_step_link() ); |
|
258 | + $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
259 | + |
|
260 | + echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>'; |
|
261 | + } |
|
262 | + |
|
263 | + echo '</body></html>'; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Introduction step. |
|
268 | + * |
|
269 | + * @since 2.0.0 |
|
270 | + */ |
|
271 | + public function setup_introduction() { |
|
272 | + $next_url = $this->get_next_step_link(); |
|
273 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Get the URL for the next step's screen. |
|
278 | + * |
|
279 | + * @param string step slug (default: current step) |
|
280 | + * |
|
281 | + * @return string URL for next step if a next step exists. |
|
282 | + * Admin URL if it's the last step. |
|
283 | + * Empty string on failure. |
|
284 | + * @since 3.0.0 |
|
285 | + */ |
|
286 | + public function get_next_step_link( $step = '' ) { |
|
287 | + if ( ! $step ) { |
|
288 | + $step = $this->step; |
|
289 | + } |
|
290 | + |
|
291 | + $keys = array_keys( $this->steps ); |
|
292 | + if ( end( $keys ) === $step ) { |
|
293 | + return admin_url(); |
|
294 | + } |
|
295 | + |
|
296 | + $step_index = array_search( $step, $keys ); |
|
297 | + if ( false === $step_index ) { |
|
298 | + return ''; |
|
299 | + } |
|
300 | + |
|
301 | + return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) ); |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Setup maps api. |
|
306 | + * |
|
307 | + * @since 2.0.0 |
|
308 | + */ |
|
309 | + public function setup_business() { |
|
310 | + $next_url = $this->get_next_step_link(); |
|
311 | + $wizard = $this; |
|
312 | + $page = 'wpinv_settings_general_main'; |
|
313 | + $section = 'wpinv_settings_general_main'; |
|
314 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * Default Location settings. |
|
319 | + * |
|
320 | + * @since 2.0.0 |
|
321 | + */ |
|
322 | + public function setup_currency() { |
|
323 | + $next_url = $this->get_next_step_link(); |
|
324 | + $wizard = $this; |
|
325 | + $page = 'wpinv_settings_general_currency_section'; |
|
326 | + $section = 'wpinv_settings_general_currency_section'; |
|
327 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Installation of recommended plugins. |
|
332 | + * |
|
333 | + * @since 1.0.0 |
|
334 | + */ |
|
335 | + public function setup_recommend() { |
|
336 | + $next_url = $this->get_next_step_link(); |
|
337 | + $recommended_plugins = self::get_recommend_wp_plugins(); |
|
338 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * A list of recommended wp.org plugins. |
|
343 | + * @return array |
|
344 | + */ |
|
345 | + public static function get_recommend_wp_plugins() { |
|
346 | + return array( |
|
347 | + 'ayecode-connect' => array( |
|
348 | + 'file' => 'ayecode-connect/ayecode-connect.php', |
|
349 | + 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
|
350 | + 'slug' => 'ayecode-connect', |
|
351 | + 'name' => 'AyeCode Connect', |
|
352 | + 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
|
353 | + ), |
|
354 | + 'invoicing-quotes' => array( |
|
355 | + 'file' => 'invoicing-quotes/wpinv-quote.php', |
|
356 | + 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
|
357 | + 'slug' => 'invoicing-quotes', |
|
358 | + 'name' => 'Customer Quotes', |
|
359 | + 'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'geodirectory' ), |
|
360 | + ), |
|
361 | + 'userswp' => array( |
|
362 | + 'file' => 'userswp/userswp.php', |
|
363 | + 'url' => 'https://wordpress.org/plugins/userswp/', |
|
364 | + 'slug' => 'userswp', |
|
365 | + 'name' => 'UsersWP', |
|
366 | + 'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'geodirectory' ), |
|
367 | + ), |
|
368 | + ); |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Dummy Data setup. |
|
373 | + * |
|
374 | + * @since 2.4.0 |
|
375 | + */ |
|
376 | + public function setup_payments() { |
|
377 | + $next_url = $this->get_next_step_link(); |
|
378 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
379 | + } |
|
380 | + |
|
381 | + /** |
|
382 | + * Dummy data save. |
|
383 | + * |
|
384 | + * This is done via ajax so we just pass onto the next step. |
|
385 | + * |
|
386 | + * @since 2.0.0 |
|
387 | + */ |
|
388 | + public function setup_payments_save() { |
|
389 | + check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
390 | + wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
391 | + |
|
392 | + if ( ! empty( $_POST['paypal-email'] ) ) { |
|
393 | + wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) ); |
|
394 | + wpinv_update_option( 'paypal_active', 1 ); |
|
395 | + wpinv_update_option( 'paypal_sandbox', 0 ); |
|
396 | + } |
|
397 | + |
|
398 | + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
399 | + exit; |
|
400 | + } |
|
401 | + |
|
402 | + /** |
|
403 | + * Final step. |
|
404 | + * |
|
405 | + * @since 2.0.0 |
|
406 | + */ |
|
407 | + public function setup_ready() { |
|
408 | + include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
409 | + } |
|
410 | 410 | |
411 | 411 | } |
412 | 412 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @version 2.4.0 |
11 | 11 | * @info GetPaid Setup Wizard. |
12 | 12 | */ |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * GetPaid_Admin_Setup_Wizard class. |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | |
47 | - if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
48 | - add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
49 | - add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
47 | + if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) { |
|
48 | + add_action('admin_menu', array($this, 'add_menu')); |
|
49 | + add_action('current_screen', array($this, 'setup_wizard')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @since 2.4.0 |
58 | 58 | */ |
59 | 59 | public function add_menu() { |
60 | - add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
60 | + add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', ''); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function setup_wizard() { |
69 | 69 | |
70 | - if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
70 | + if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) { |
|
71 | 71 | $this->setup_globals(); |
72 | 72 | $this->maybe_save_current_step(); |
73 | 73 | $this->display_wizard(); |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @since 2.4.0 |
95 | 95 | */ |
96 | 96 | protected function maybe_save_current_step() { |
97 | - if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
98 | - call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
97 | + if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) { |
|
98 | + call_user_func($this->steps[$this->step]['handler'], $this); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | $steps = array( |
111 | 111 | |
112 | 112 | 'introduction' => array( |
113 | - 'name' => __( 'Introduction', 'invoicing' ), |
|
114 | - 'view' => array( $this, 'setup_introduction' ), |
|
113 | + 'name' => __('Introduction', 'invoicing'), |
|
114 | + 'view' => array($this, 'setup_introduction'), |
|
115 | 115 | 'handler' => '', |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'business_details' => array( |
119 | - 'name' => __( 'Business Details', 'invoicing' ), |
|
120 | - 'view' => array( $this, 'setup_business' ), |
|
119 | + 'name' => __('Business Details', 'invoicing'), |
|
120 | + 'view' => array($this, 'setup_business'), |
|
121 | 121 | 'handler' => '', |
122 | 122 | ), |
123 | 123 | |
124 | 124 | 'currency' => array( |
125 | - 'name' => __( 'Currency', 'invoicing' ), |
|
126 | - 'view' => array( $this, 'setup_currency' ), |
|
125 | + 'name' => __('Currency', 'invoicing'), |
|
126 | + 'view' => array($this, 'setup_currency'), |
|
127 | 127 | 'handler' => '', |
128 | 128 | ), |
129 | 129 | |
130 | 130 | 'payments' => array( |
131 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
132 | - 'view' => array( $this, 'setup_payments' ), |
|
133 | - 'handler' => array( $this, 'setup_payments_save' ), |
|
131 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
132 | + 'view' => array($this, 'setup_payments'), |
|
133 | + 'handler' => array($this, 'setup_payments_save'), |
|
134 | 134 | ), |
135 | 135 | |
136 | 136 | 'recommend' => array( |
137 | - 'name' => __( 'Recommend', 'invoicing' ), |
|
138 | - 'view' => array( $this, 'setup_recommend' ), |
|
137 | + 'name' => __('Recommend', 'invoicing'), |
|
138 | + 'view' => array($this, 'setup_recommend'), |
|
139 | 139 | 'handler' => '', |
140 | 140 | ), |
141 | 141 | |
142 | 142 | 'next_steps' => array( |
143 | - 'name' => __( 'Get Paid', 'invoicing' ), |
|
144 | - 'view' => array( $this, 'setup_ready' ), |
|
143 | + 'name' => __('Get Paid', 'invoicing'), |
|
144 | + 'view' => array($this, 'setup_ready'), |
|
145 | 145 | 'handler' => '', |
146 | 146 | ), |
147 | 147 | |
148 | 148 | ); |
149 | 149 | |
150 | - return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
150 | + return apply_filters('getpaid_setup_wizard_steps', $steps); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | protected function get_current_step() { |
161 | - $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
162 | - return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
161 | + $step = isset($_GET['step']) ? sanitize_key($_GET['step']) : ''; |
|
162 | + return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | |
173 | 173 | $previous = false; |
174 | 174 | $current = $this->step; |
175 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
176 | - if ( $current === $step ) { |
|
175 | + foreach (array_keys($this->steps) as $step) { |
|
176 | + if ($current === $step) { |
|
177 | 177 | return $previous; |
178 | 178 | } |
179 | 179 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | |
194 | 194 | $on_current = false; |
195 | 195 | $current = $this->step; |
196 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
196 | + foreach (array_keys($this->steps) as $step) { |
|
197 | 197 | |
198 | - if ( $on_current ) { |
|
198 | + if ($on_current) { |
|
199 | 199 | return $step; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $current === $step ) { |
|
202 | + if ($current === $step) { |
|
203 | 203 | return $on_current = true; |
204 | 204 | } |
205 | 205 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | $steps = $this->steps; |
228 | 228 | $current = $this->step; |
229 | 229 | $next_step = $this->next_step; |
230 | - array_shift( $steps ); |
|
231 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
230 | + array_shift($steps); |
|
231 | + include plugin_dir_path(__FILE__) . 'views/wizard-header.php'; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ?> |
241 | 241 | <div class="gp-setup-content rowx mw-100 text-center mb-3"> |
242 | 242 | <div class="col-12 col-md-5 m-auto"> |
243 | - <?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?> |
|
243 | + <?php call_user_func($this->steps[$this->step]['view'], $this); ?> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function display_footer() { |
255 | 255 | |
256 | - if ( isset( $_GET['step'] ) ) { |
|
257 | - $next_url = esc_url( $this->get_next_step_link() ); |
|
258 | - $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
256 | + if (isset($_GET['step'])) { |
|
257 | + $next_url = esc_url($this->get_next_step_link()); |
|
258 | + $label = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing'); |
|
259 | 259 | |
260 | 260 | echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>'; |
261 | 261 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function setup_introduction() { |
272 | 272 | $next_url = $this->get_next_step_link(); |
273 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
273 | + include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php'; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -283,22 +283,22 @@ discard block |
||
283 | 283 | * Empty string on failure. |
284 | 284 | * @since 3.0.0 |
285 | 285 | */ |
286 | - public function get_next_step_link( $step = '' ) { |
|
287 | - if ( ! $step ) { |
|
286 | + public function get_next_step_link($step = '') { |
|
287 | + if (!$step) { |
|
288 | 288 | $step = $this->step; |
289 | 289 | } |
290 | 290 | |
291 | - $keys = array_keys( $this->steps ); |
|
292 | - if ( end( $keys ) === $step ) { |
|
291 | + $keys = array_keys($this->steps); |
|
292 | + if (end($keys) === $step) { |
|
293 | 293 | return admin_url(); |
294 | 294 | } |
295 | 295 | |
296 | - $step_index = array_search( $step, $keys ); |
|
297 | - if ( false === $step_index ) { |
|
296 | + $step_index = array_search($step, $keys); |
|
297 | + if (false === $step_index) { |
|
298 | 298 | return ''; |
299 | 299 | } |
300 | 300 | |
301 | - return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) ); |
|
301 | + return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1])); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $wizard = $this; |
312 | 312 | $page = 'wpinv_settings_general_main'; |
313 | 313 | $section = 'wpinv_settings_general_main'; |
314 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
314 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $wizard = $this; |
325 | 325 | $page = 'wpinv_settings_general_currency_section'; |
326 | 326 | $section = 'wpinv_settings_general_currency_section'; |
327 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
327 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | public function setup_recommend() { |
336 | 336 | $next_url = $this->get_next_step_link(); |
337 | 337 | $recommended_plugins = self::get_recommend_wp_plugins(); |
338 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
338 | + include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
350 | 350 | 'slug' => 'ayecode-connect', |
351 | 351 | 'name' => 'AyeCode Connect', |
352 | - 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
|
352 | + 'desc' => __('Documentation and Support from within your WordPress admin.', 'geodirectory'), |
|
353 | 353 | ), |
354 | 354 | 'invoicing-quotes' => array( |
355 | 355 | 'file' => 'invoicing-quotes/wpinv-quote.php', |
356 | 356 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
357 | 357 | 'slug' => 'invoicing-quotes', |
358 | 358 | 'name' => 'Customer Quotes', |
359 | - 'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'geodirectory' ), |
|
359 | + 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.', 'geodirectory'), |
|
360 | 360 | ), |
361 | 361 | 'userswp' => array( |
362 | 362 | 'file' => 'userswp/userswp.php', |
363 | 363 | 'url' => 'https://wordpress.org/plugins/userswp/', |
364 | 364 | 'slug' => 'userswp', |
365 | 365 | 'name' => 'UsersWP', |
366 | - 'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'geodirectory' ), |
|
366 | + 'desc' => __('Frontend user login and registration as well as slick profile pages.', 'geodirectory'), |
|
367 | 367 | ), |
368 | 368 | ); |
369 | 369 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function setup_payments() { |
377 | 377 | $next_url = $this->get_next_step_link(); |
378 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
378 | + include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php'; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -386,16 +386,16 @@ discard block |
||
386 | 386 | * @since 2.0.0 |
387 | 387 | */ |
388 | 388 | public function setup_payments_save() { |
389 | - check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
390 | - wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
389 | + check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard'); |
|
390 | + wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway'])); |
|
391 | 391 | |
392 | - if ( ! empty( $_POST['paypal-email'] ) ) { |
|
393 | - wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) ); |
|
394 | - wpinv_update_option( 'paypal_active', 1 ); |
|
395 | - wpinv_update_option( 'paypal_sandbox', 0 ); |
|
392 | + if (!empty($_POST['paypal-email'])) { |
|
393 | + wpinv_update_option('paypal_email', sanitize_email($_POST['paypal-email'])); |
|
394 | + wpinv_update_option('paypal_active', 1); |
|
395 | + wpinv_update_option('paypal_sandbox', 0); |
|
396 | 396 | } |
397 | 397 | |
398 | - wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
398 | + wp_redirect(esc_url_raw($this->get_next_step_link())); |
|
399 | 399 | exit; |
400 | 400 | } |
401 | 401 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @since 2.0.0 |
406 | 406 | */ |
407 | 407 | public function setup_ready() { |
408 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
408 | + include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php'; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
@@ -13,719 +13,719 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | - |
|
30 | - // Invoice table columns. |
|
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
35 | - |
|
36 | - // Items table columns. |
|
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
43 | - |
|
44 | - // Payment forms columns. |
|
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
48 | - |
|
49 | - // Discount table columns. |
|
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
52 | - |
|
53 | - // Deleting posts. |
|
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
56 | - |
|
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Post updated messages. |
|
62 | - */ |
|
63 | - public static function post_updated_messages( $messages ) { |
|
64 | - global $post; |
|
65 | - |
|
66 | - $messages['wpi_discount'] = array( |
|
67 | - 0 => '', |
|
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
78 | - ); |
|
79 | - |
|
80 | - $messages['wpi_payment_form'] = array( |
|
81 | - 0 => '', |
|
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
92 | - ); |
|
93 | - |
|
94 | - return $messages; |
|
95 | - |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Post row actions. |
|
100 | - */ |
|
101 | - public static function post_row_actions( $actions, $post ) { |
|
102 | - |
|
103 | - $post = get_post( $post ); |
|
104 | - |
|
105 | - // We do not want to edit the default payment form. |
|
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
107 | - |
|
108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
111 | - } |
|
112 | - |
|
113 | - $actions['duplicate'] = sprintf( |
|
114 | - '<a href="%1$s">%2$s</a>', |
|
115 | - esc_url( |
|
116 | - wp_nonce_url( |
|
117 | - add_query_arg( |
|
118 | - array( |
|
119 | - 'getpaid-admin-action' => 'duplicate_form', |
|
120 | - 'form_id' => $post->ID, |
|
121 | - ) |
|
122 | - ), |
|
123 | - 'getpaid-nonce', |
|
124 | - 'getpaid-nonce' |
|
125 | - ) |
|
126 | - ), |
|
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
128 | - ); |
|
129 | - |
|
130 | - } |
|
131 | - |
|
132 | - // Link to item payment form. |
|
133 | - if ( 'wpi_item' == $post->post_type ) { |
|
134 | - |
|
135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
136 | - |
|
137 | - $actions['buy'] = sprintf( |
|
138 | - '<a href="%1$s">%2$s</a>', |
|
139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
141 | - ); |
|
142 | - |
|
143 | - } |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | + |
|
30 | + // Invoice table columns. |
|
31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | + add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | + add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
35 | + |
|
36 | + // Items table columns. |
|
37 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
43 | + |
|
44 | + // Payment forms columns. |
|
45 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
48 | + |
|
49 | + // Discount table columns. |
|
50 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
52 | + |
|
53 | + // Deleting posts. |
|
54 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
56 | + |
|
57 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Post updated messages. |
|
62 | + */ |
|
63 | + public static function post_updated_messages( $messages ) { |
|
64 | + global $post; |
|
65 | + |
|
66 | + $messages['wpi_discount'] = array( |
|
67 | + 0 => '', |
|
68 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
78 | + ); |
|
79 | + |
|
80 | + $messages['wpi_payment_form'] = array( |
|
81 | + 0 => '', |
|
82 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
92 | + ); |
|
93 | + |
|
94 | + return $messages; |
|
95 | + |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Post row actions. |
|
100 | + */ |
|
101 | + public static function post_row_actions( $actions, $post ) { |
|
102 | + |
|
103 | + $post = get_post( $post ); |
|
104 | + |
|
105 | + // We do not want to edit the default payment form. |
|
106 | + if ( 'wpi_payment_form' == $post->post_type ) { |
|
107 | + |
|
108 | + if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
109 | + unset( $actions['trash'] ); |
|
110 | + unset( $actions['inline hide-if-no-js'] ); |
|
111 | + } |
|
112 | + |
|
113 | + $actions['duplicate'] = sprintf( |
|
114 | + '<a href="%1$s">%2$s</a>', |
|
115 | + esc_url( |
|
116 | + wp_nonce_url( |
|
117 | + add_query_arg( |
|
118 | + array( |
|
119 | + 'getpaid-admin-action' => 'duplicate_form', |
|
120 | + 'form_id' => $post->ID, |
|
121 | + ) |
|
122 | + ), |
|
123 | + 'getpaid-nonce', |
|
124 | + 'getpaid-nonce' |
|
125 | + ) |
|
126 | + ), |
|
127 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
128 | + ); |
|
129 | + |
|
130 | + } |
|
131 | + |
|
132 | + // Link to item payment form. |
|
133 | + if ( 'wpi_item' == $post->post_type ) { |
|
134 | + |
|
135 | + if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
136 | + |
|
137 | + $actions['buy'] = sprintf( |
|
138 | + '<a href="%1$s">%2$s</a>', |
|
139 | + esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
140 | + esc_html( __( 'Buy', 'invoicing' ) ) |
|
141 | + ); |
|
142 | + |
|
143 | + } |
|
144 | 144 | } |
145 | 145 | |
146 | - return $actions; |
|
147 | - } |
|
146 | + return $actions; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
149 | + /** |
|
150 | 150 | * Remove bulk edit option from admin side quote listing |
151 | 151 | * |
152 | 152 | * @since 1.0.0 |
153 | 153 | * @param array $actions post actions |
154 | - * @param WP_Post $post |
|
154 | + * @param WP_Post $post |
|
155 | 155 | * @return array $actions actions without edit option |
156 | 156 | */ |
157 | 157 | public static function filter_invoice_row_actions( $actions, $post ) { |
158 | 158 | |
159 | 159 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
160 | 160 | |
161 | - $actions = array(); |
|
162 | - $invoice = new WPInv_Invoice( $post ); |
|
163 | - |
|
164 | - $actions['edit'] = sprintf( |
|
165 | - '<a href="%1$s">%2$s</a>', |
|
166 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
167 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
168 | - ); |
|
169 | - |
|
170 | - if ( ! $invoice->is_draft() ) { |
|
171 | - |
|
172 | - $actions['view'] = sprintf( |
|
173 | - '<a href="%1$s">%2$s</a>', |
|
174 | - esc_url( $invoice->get_view_url() ), |
|
175 | - sprintf( |
|
176 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
177 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
178 | - ) |
|
179 | - ); |
|
180 | - |
|
181 | - $actions['send'] = sprintf( |
|
182 | - '<a href="%1$s">%2$s</a>', |
|
183 | - esc_url( |
|
184 | - wp_nonce_url( |
|
185 | - add_query_arg( |
|
186 | - array( |
|
187 | - 'getpaid-admin-action' => 'send_invoice', |
|
188 | - 'invoice_id' => $invoice->get_id(), |
|
189 | - ) |
|
190 | - ), |
|
191 | - 'getpaid-nonce', |
|
192 | - 'getpaid-nonce' |
|
193 | - ) |
|
194 | - ), |
|
195 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
196 | - ); |
|
197 | - |
|
198 | - } |
|
199 | - |
|
200 | - $actions['duplicate'] = sprintf( |
|
201 | - '<a href="%1$s">%2$s</a>', |
|
202 | - esc_url( |
|
203 | - wp_nonce_url( |
|
204 | - add_query_arg( |
|
205 | - array( |
|
206 | - 'getpaid-admin-action' => 'duplicate_invoice', |
|
207 | - 'invoice_id' => $post->ID, |
|
208 | - ) |
|
209 | - ), |
|
210 | - 'getpaid-nonce', |
|
211 | - 'getpaid-nonce' |
|
212 | - ) |
|
213 | - ), |
|
214 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
215 | - ); |
|
161 | + $actions = array(); |
|
162 | + $invoice = new WPInv_Invoice( $post ); |
|
163 | + |
|
164 | + $actions['edit'] = sprintf( |
|
165 | + '<a href="%1$s">%2$s</a>', |
|
166 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
167 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
168 | + ); |
|
169 | + |
|
170 | + if ( ! $invoice->is_draft() ) { |
|
171 | + |
|
172 | + $actions['view'] = sprintf( |
|
173 | + '<a href="%1$s">%2$s</a>', |
|
174 | + esc_url( $invoice->get_view_url() ), |
|
175 | + sprintf( |
|
176 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
177 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
178 | + ) |
|
179 | + ); |
|
180 | + |
|
181 | + $actions['send'] = sprintf( |
|
182 | + '<a href="%1$s">%2$s</a>', |
|
183 | + esc_url( |
|
184 | + wp_nonce_url( |
|
185 | + add_query_arg( |
|
186 | + array( |
|
187 | + 'getpaid-admin-action' => 'send_invoice', |
|
188 | + 'invoice_id' => $invoice->get_id(), |
|
189 | + ) |
|
190 | + ), |
|
191 | + 'getpaid-nonce', |
|
192 | + 'getpaid-nonce' |
|
193 | + ) |
|
194 | + ), |
|
195 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
196 | + ); |
|
197 | + |
|
198 | + } |
|
199 | + |
|
200 | + $actions['duplicate'] = sprintf( |
|
201 | + '<a href="%1$s">%2$s</a>', |
|
202 | + esc_url( |
|
203 | + wp_nonce_url( |
|
204 | + add_query_arg( |
|
205 | + array( |
|
206 | + 'getpaid-admin-action' => 'duplicate_invoice', |
|
207 | + 'invoice_id' => $post->ID, |
|
208 | + ) |
|
209 | + ), |
|
210 | + 'getpaid-nonce', |
|
211 | + 'getpaid-nonce' |
|
212 | + ) |
|
213 | + ), |
|
214 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
215 | + ); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
219 | 219 | return $actions; |
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Returns an array of invoice table columns. |
|
224 | - */ |
|
225 | - public static function invoice_columns( $columns ) { |
|
226 | - |
|
227 | - $columns = array( |
|
228 | - 'cb' => $columns['cb'], |
|
229 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
230 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
231 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
232 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
233 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
234 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
235 | - 'status' => __( 'Status', 'invoicing' ), |
|
236 | - ); |
|
237 | - |
|
238 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Displays invoice table columns. |
|
243 | - */ |
|
244 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
245 | - |
|
246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
247 | - |
|
248 | - switch ( $column_name ) { |
|
249 | - |
|
250 | - case 'invoice_date': |
|
251 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
252 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
253 | - echo "<span title='$date_time'>$date</span>"; |
|
254 | - break; |
|
255 | - |
|
256 | - case 'payment_date': |
|
257 | - if ( $invoice->is_paid() ) { |
|
258 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
259 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
260 | - echo "<span title='$date_time'>$date</span>"; |
|
261 | - } else { |
|
262 | - echo '—'; |
|
263 | - } |
|
264 | - |
|
265 | - break; |
|
266 | - |
|
267 | - case 'amount': |
|
268 | - $amount = $invoice->get_total(); |
|
269 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
270 | - |
|
271 | - if ( $invoice->is_refunded() ) { |
|
272 | - $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
273 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
274 | - } else { |
|
275 | - |
|
276 | - $discount = $invoice->get_total_discount(); |
|
277 | - |
|
278 | - if ( ! empty( $discount ) ) { |
|
279 | - $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
280 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
281 | - } else { |
|
282 | - echo wp_kses_post( $formated_amount ); |
|
283 | - } |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Returns an array of invoice table columns. |
|
224 | + */ |
|
225 | + public static function invoice_columns( $columns ) { |
|
226 | + |
|
227 | + $columns = array( |
|
228 | + 'cb' => $columns['cb'], |
|
229 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
230 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
231 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
232 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
233 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
234 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
235 | + 'status' => __( 'Status', 'invoicing' ), |
|
236 | + ); |
|
237 | + |
|
238 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Displays invoice table columns. |
|
243 | + */ |
|
244 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
245 | + |
|
246 | + $invoice = new WPInv_Invoice( $post_id ); |
|
247 | + |
|
248 | + switch ( $column_name ) { |
|
249 | + |
|
250 | + case 'invoice_date': |
|
251 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
252 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
253 | + echo "<span title='$date_time'>$date</span>"; |
|
254 | + break; |
|
255 | + |
|
256 | + case 'payment_date': |
|
257 | + if ( $invoice->is_paid() ) { |
|
258 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
259 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
260 | + echo "<span title='$date_time'>$date</span>"; |
|
261 | + } else { |
|
262 | + echo '—'; |
|
263 | + } |
|
264 | + |
|
265 | + break; |
|
266 | + |
|
267 | + case 'amount': |
|
268 | + $amount = $invoice->get_total(); |
|
269 | + $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
270 | + |
|
271 | + if ( $invoice->is_refunded() ) { |
|
272 | + $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
273 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
274 | + } else { |
|
275 | + |
|
276 | + $discount = $invoice->get_total_discount(); |
|
277 | + |
|
278 | + if ( ! empty( $discount ) ) { |
|
279 | + $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
280 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
281 | + } else { |
|
282 | + echo wp_kses_post( $formated_amount ); |
|
283 | + } |
|
284 | 284 | } |
285 | 285 | |
286 | - break; |
|
287 | - |
|
288 | - case 'status': |
|
289 | - $status = esc_html( $invoice->get_status() ); |
|
290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
291 | - |
|
292 | - // If it is paid, show the gateway title. |
|
293 | - if ( $invoice->is_paid() ) { |
|
294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
296 | - |
|
297 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
298 | - } else { |
|
299 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
300 | - } |
|
301 | - |
|
302 | - // If it is not paid, display the overdue and view status. |
|
303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
304 | - |
|
305 | - // Invoice view status. |
|
306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
308 | - } else { |
|
309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
310 | - } |
|
311 | - |
|
312 | - // Display the overview status. |
|
313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
314 | - $due_date = $invoice->get_due_date(); |
|
315 | - $fomatted = getpaid_format_date( $due_date ); |
|
316 | - |
|
317 | - if ( ! empty( $fomatted ) ) { |
|
318 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
319 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
320 | - } |
|
321 | - } |
|
286 | + break; |
|
287 | + |
|
288 | + case 'status': |
|
289 | + $status = esc_html( $invoice->get_status() ); |
|
290 | + $status_label = esc_html( $invoice->get_status_nicename() ); |
|
291 | + |
|
292 | + // If it is paid, show the gateway title. |
|
293 | + if ( $invoice->is_paid() ) { |
|
294 | + $gateway = esc_html( $invoice->get_gateway_title() ); |
|
295 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
296 | + |
|
297 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
298 | + } else { |
|
299 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
300 | + } |
|
301 | + |
|
302 | + // If it is not paid, display the overdue and view status. |
|
303 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
304 | + |
|
305 | + // Invoice view status. |
|
306 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
308 | + } else { |
|
309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
310 | + } |
|
311 | + |
|
312 | + // Display the overview status. |
|
313 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
314 | + $due_date = $invoice->get_due_date(); |
|
315 | + $fomatted = getpaid_format_date( $due_date ); |
|
316 | + |
|
317 | + if ( ! empty( $fomatted ) ) { |
|
318 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
319 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | } |
323 | 323 | |
324 | - break; |
|
324 | + break; |
|
325 | 325 | |
326 | - case 'recurring': |
|
327 | - if ( $invoice->is_recurring() ) { |
|
328 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
329 | - } else { |
|
330 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
331 | - } |
|
332 | - break; |
|
326 | + case 'recurring': |
|
327 | + if ( $invoice->is_recurring() ) { |
|
328 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
329 | + } else { |
|
330 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
331 | + } |
|
332 | + break; |
|
333 | 333 | |
334 | - case 'number': |
|
335 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
336 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
337 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
334 | + case 'number': |
|
335 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
336 | + $invoice_number = esc_html( $invoice->get_number() ); |
|
337 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
338 | 338 | |
339 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
339 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
340 | 340 | |
341 | - break; |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'customer': |
|
344 | - $customer_name = $invoice->get_user_full_name(); |
|
343 | + case 'customer': |
|
344 | + $customer_name = $invoice->get_user_full_name(); |
|
345 | 345 | |
346 | - if ( empty( $customer_name ) ) { |
|
347 | - $customer_name = $invoice->get_email(); |
|
348 | - } |
|
346 | + if ( empty( $customer_name ) ) { |
|
347 | + $customer_name = $invoice->get_email(); |
|
348 | + } |
|
349 | 349 | |
350 | - if ( ! empty( $customer_name ) ) { |
|
351 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
352 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
353 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
354 | - } else { |
|
355 | - echo '<div>—</div>'; |
|
356 | - } |
|
350 | + if ( ! empty( $customer_name ) ) { |
|
351 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
352 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
353 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
354 | + } else { |
|
355 | + echo '<div>—</div>'; |
|
356 | + } |
|
357 | 357 | |
358 | - break; |
|
359 | - |
|
360 | - } |
|
361 | - |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * Displays invoice bulk actions. |
|
366 | - */ |
|
367 | - public static function invoice_bulk_actions( $actions ) { |
|
368 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
369 | - return $actions; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Processes invoice bulk actions. |
|
374 | - */ |
|
375 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
376 | - |
|
377 | - if ( $action == 'resend-invoice' ) { |
|
378 | - foreach ( $post_ids as $post_id ) { |
|
379 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
380 | - } |
|
381 | - } |
|
382 | - |
|
383 | - return $redirect_url; |
|
384 | - |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Returns an array of payment forms table columns. |
|
389 | - */ |
|
390 | - public static function payment_form_columns( $columns ) { |
|
391 | - |
|
392 | - $columns = array( |
|
393 | - 'cb' => $columns['cb'], |
|
394 | - 'title' => __( 'Name', 'invoicing' ), |
|
395 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
396 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
397 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
398 | - 'items' => __( 'Items', 'invoicing' ), |
|
399 | - 'date' => __( 'Date', 'invoicing' ), |
|
400 | - ); |
|
401 | - |
|
402 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
403 | - |
|
404 | - } |
|
405 | - |
|
406 | - /** |
|
407 | - * Displays payment form table columns. |
|
408 | - */ |
|
409 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
410 | - |
|
411 | - // Retrieve the payment form. |
|
412 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
413 | - |
|
414 | - switch ( $column_name ) { |
|
415 | - |
|
416 | - case 'earnings': |
|
417 | - echo wpinv_price( $form->get_earned() ); |
|
418 | - break; |
|
419 | - |
|
420 | - case 'refunds': |
|
421 | - echo wpinv_price( $form->get_refunded() ); |
|
422 | - break; |
|
423 | - |
|
424 | - case 'refunds': |
|
425 | - echo wpinv_price( $form->get_refunded() ); |
|
426 | - break; |
|
427 | - |
|
428 | - case 'shortcode': |
|
429 | - if ( $form->is_default() ) { |
|
430 | - echo '—'; |
|
431 | - } else { |
|
432 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
433 | - } |
|
434 | - |
|
435 | - break; |
|
358 | + break; |
|
436 | 359 | |
437 | - case 'items': |
|
438 | - $items = $form->get_items(); |
|
439 | - |
|
440 | - if ( $form->is_default() || empty( $items ) ) { |
|
441 | - echo '—'; |
|
442 | - return; |
|
443 | - } |
|
444 | - |
|
445 | - $_items = array(); |
|
446 | - |
|
447 | - foreach ( $items as $item ) { |
|
448 | - $url = $item->get_edit_url(); |
|
449 | - |
|
450 | - if ( empty( $url ) ) { |
|
451 | - $_items[] = esc_html( $item->get_name() ); |
|
452 | - } else { |
|
453 | - $_items[] = sprintf( |
|
454 | - '<a href="%s">%s</a>', |
|
455 | - esc_url( $url ), |
|
456 | - esc_html( $item->get_name() ) |
|
457 | - ); |
|
458 | - } |
|
360 | + } |
|
361 | + |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * Displays invoice bulk actions. |
|
366 | + */ |
|
367 | + public static function invoice_bulk_actions( $actions ) { |
|
368 | + $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
369 | + return $actions; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Processes invoice bulk actions. |
|
374 | + */ |
|
375 | + public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
376 | + |
|
377 | + if ( $action == 'resend-invoice' ) { |
|
378 | + foreach ( $post_ids as $post_id ) { |
|
379 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
380 | + } |
|
381 | + } |
|
382 | + |
|
383 | + return $redirect_url; |
|
384 | + |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Returns an array of payment forms table columns. |
|
389 | + */ |
|
390 | + public static function payment_form_columns( $columns ) { |
|
391 | + |
|
392 | + $columns = array( |
|
393 | + 'cb' => $columns['cb'], |
|
394 | + 'title' => __( 'Name', 'invoicing' ), |
|
395 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
396 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
397 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
398 | + 'items' => __( 'Items', 'invoicing' ), |
|
399 | + 'date' => __( 'Date', 'invoicing' ), |
|
400 | + ); |
|
401 | + |
|
402 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
403 | + |
|
404 | + } |
|
405 | + |
|
406 | + /** |
|
407 | + * Displays payment form table columns. |
|
408 | + */ |
|
409 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
410 | + |
|
411 | + // Retrieve the payment form. |
|
412 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
413 | + |
|
414 | + switch ( $column_name ) { |
|
415 | + |
|
416 | + case 'earnings': |
|
417 | + echo wpinv_price( $form->get_earned() ); |
|
418 | + break; |
|
419 | + |
|
420 | + case 'refunds': |
|
421 | + echo wpinv_price( $form->get_refunded() ); |
|
422 | + break; |
|
423 | + |
|
424 | + case 'refunds': |
|
425 | + echo wpinv_price( $form->get_refunded() ); |
|
426 | + break; |
|
427 | + |
|
428 | + case 'shortcode': |
|
429 | + if ( $form->is_default() ) { |
|
430 | + echo '—'; |
|
431 | + } else { |
|
432 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
433 | + } |
|
434 | + |
|
435 | + break; |
|
436 | + |
|
437 | + case 'items': |
|
438 | + $items = $form->get_items(); |
|
439 | + |
|
440 | + if ( $form->is_default() || empty( $items ) ) { |
|
441 | + echo '—'; |
|
442 | + return; |
|
443 | + } |
|
444 | + |
|
445 | + $_items = array(); |
|
446 | + |
|
447 | + foreach ( $items as $item ) { |
|
448 | + $url = $item->get_edit_url(); |
|
449 | + |
|
450 | + if ( empty( $url ) ) { |
|
451 | + $_items[] = esc_html( $item->get_name() ); |
|
452 | + } else { |
|
453 | + $_items[] = sprintf( |
|
454 | + '<a href="%s">%s</a>', |
|
455 | + esc_url( $url ), |
|
456 | + esc_html( $item->get_name() ) |
|
457 | + ); |
|
458 | + } |
|
459 | 459 | } |
460 | 460 | |
461 | - echo implode( '<br>', $_items ); |
|
461 | + echo implode( '<br>', $_items ); |
|
462 | 462 | |
463 | - break; |
|
463 | + break; |
|
464 | 464 | |
465 | - } |
|
465 | + } |
|
466 | 466 | |
467 | - } |
|
467 | + } |
|
468 | 468 | |
469 | - /** |
|
470 | - * Filters post states. |
|
471 | - */ |
|
472 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
469 | + /** |
|
470 | + * Filters post states. |
|
471 | + */ |
|
472 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
473 | 473 | |
474 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
475 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
476 | - } |
|
474 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
475 | + $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
476 | + } |
|
477 | 477 | |
478 | - return $post_states; |
|
478 | + return $post_states; |
|
479 | 479 | |
480 | - } |
|
480 | + } |
|
481 | 481 | |
482 | - /** |
|
483 | - * Returns an array of coupon table columns. |
|
484 | - */ |
|
485 | - public static function discount_columns( $columns ) { |
|
482 | + /** |
|
483 | + * Returns an array of coupon table columns. |
|
484 | + */ |
|
485 | + public static function discount_columns( $columns ) { |
|
486 | + |
|
487 | + $columns = array( |
|
488 | + 'cb' => $columns['cb'], |
|
489 | + 'title' => __( 'Name', 'invoicing' ), |
|
490 | + 'code' => __( 'Code', 'invoicing' ), |
|
491 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
492 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
493 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
494 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
495 | + ); |
|
496 | + |
|
497 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
498 | + } |
|
486 | 499 | |
487 | - $columns = array( |
|
488 | - 'cb' => $columns['cb'], |
|
489 | - 'title' => __( 'Name', 'invoicing' ), |
|
490 | - 'code' => __( 'Code', 'invoicing' ), |
|
491 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
492 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
493 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
494 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
495 | - ); |
|
500 | + /** |
|
501 | + * Filters post states. |
|
502 | + */ |
|
503 | + public static function filter_discount_state( $post_states, $post ) { |
|
496 | 504 | |
497 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
498 | - } |
|
505 | + if ( 'wpi_discount' == $post->post_type ) { |
|
499 | 506 | |
500 | - /** |
|
501 | - * Filters post states. |
|
502 | - */ |
|
503 | - public static function filter_discount_state( $post_states, $post ) { |
|
507 | + $discount = new WPInv_Discount( $post ); |
|
504 | 508 | |
505 | - if ( 'wpi_discount' == $post->post_type ) { |
|
509 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
506 | 510 | |
507 | - $discount = new WPInv_Discount( $post ); |
|
511 | + if ( $status != 'publish' ) { |
|
512 | + return array( |
|
513 | + 'discount_status' => wpinv_discount_status( $status ), |
|
514 | + ); |
|
515 | + } |
|
508 | 516 | |
509 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
517 | + return array(); |
|
510 | 518 | |
511 | - if ( $status != 'publish' ) { |
|
512 | - return array( |
|
513 | - 'discount_status' => wpinv_discount_status( $status ), |
|
514 | - ); |
|
515 | - } |
|
519 | + } |
|
516 | 520 | |
517 | - return array(); |
|
521 | + return $post_states; |
|
518 | 522 | |
519 | - } |
|
523 | + } |
|
520 | 524 | |
521 | - return $post_states; |
|
525 | + /** |
|
526 | + * Returns an array of items table columns. |
|
527 | + */ |
|
528 | + public static function item_columns( $columns ) { |
|
529 | + |
|
530 | + $columns = array( |
|
531 | + 'cb' => $columns['cb'], |
|
532 | + 'title' => __( 'Name', 'invoicing' ), |
|
533 | + 'price' => __( 'Price', 'invoicing' ), |
|
534 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
535 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
536 | + 'type' => __( 'Type', 'invoicing' ), |
|
537 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
538 | + ); |
|
539 | + |
|
540 | + if ( ! wpinv_use_taxes() ) { |
|
541 | + unset( $columns['vat_rule'] ); |
|
542 | + unset( $columns['vat_class'] ); |
|
543 | + } |
|
544 | + |
|
545 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
546 | + } |
|
547 | + |
|
548 | + /** |
|
549 | + * Returns an array of sortable items table columns. |
|
550 | + */ |
|
551 | + public static function sortable_item_columns( $columns ) { |
|
552 | + |
|
553 | + return array_merge( |
|
554 | + $columns, |
|
555 | + array( |
|
556 | + 'price' => 'price', |
|
557 | + 'vat_rule' => 'vat_rule', |
|
558 | + 'vat_class' => 'vat_class', |
|
559 | + 'type' => 'type', |
|
560 | + ) |
|
561 | + ); |
|
562 | + |
|
563 | + } |
|
564 | + |
|
565 | + /** |
|
566 | + * Displays items table columns. |
|
567 | + */ |
|
568 | + public static function display_item_columns( $column_name, $post_id ) { |
|
569 | + |
|
570 | + $item = new WPInv_Item( $post_id ); |
|
571 | + |
|
572 | + switch ( $column_name ) { |
|
573 | + |
|
574 | + case 'price': |
|
575 | + if ( ! $item->is_recurring() ) { |
|
576 | + echo wp_kses_post( $item->get_the_price() ); |
|
577 | + break; |
|
578 | + } |
|
579 | + |
|
580 | + $price = wp_sprintf( |
|
581 | + __( '%1$s / %2$s', 'invoicing' ), |
|
582 | + $item->get_the_price(), |
|
583 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
584 | + ); |
|
585 | + |
|
586 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
587 | + echo wp_kses_post( $price ); |
|
588 | + break; |
|
589 | + } |
|
590 | + |
|
591 | + echo wp_kses_post( $item->get_the_initial_price() ); |
|
592 | + |
|
593 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
594 | + break; |
|
595 | + |
|
596 | + case 'vat_rule': |
|
597 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
598 | + break; |
|
599 | + |
|
600 | + case 'vat_class': |
|
601 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
602 | + break; |
|
603 | + |
|
604 | + case 'shortcode': |
|
605 | + if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
606 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
607 | + } else { |
|
608 | + echo '—'; |
|
609 | + } |
|
610 | + |
|
611 | + break; |
|
612 | + |
|
613 | + case 'type': |
|
614 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
615 | + break; |
|
616 | + |
|
617 | + } |
|
618 | + |
|
619 | + } |
|
620 | + |
|
621 | + /** |
|
622 | + * Lets users filter items using taxes. |
|
623 | + */ |
|
624 | + public static function add_item_filters( $post_type ) { |
|
625 | + |
|
626 | + // Abort if we're not dealing with items. |
|
627 | + if ( $post_type != 'wpi_item' ) { |
|
628 | + return; |
|
629 | + } |
|
630 | + |
|
631 | + // Filter by vat rules. |
|
632 | + if ( wpinv_use_taxes() ) { |
|
633 | + |
|
634 | + // Sanitize selected vat rule. |
|
635 | + $vat_rule = ''; |
|
636 | + $vat_rules = getpaid_get_tax_rules(); |
|
637 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
638 | + $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
639 | + } |
|
640 | + |
|
641 | + // Filter by VAT rule. |
|
642 | + echo wpinv_html_select( |
|
643 | + array( |
|
644 | + 'options' => array_merge( |
|
645 | + array( |
|
646 | + '' => __( 'All VAT rules', 'invoicing' ), |
|
647 | + ), |
|
648 | + $vat_rules |
|
649 | + ), |
|
650 | + 'name' => 'vat_rule', |
|
651 | + 'id' => 'vat_rule', |
|
652 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
653 | + 'show_option_all' => false, |
|
654 | + 'show_option_none' => false, |
|
655 | + ) |
|
656 | + ); |
|
657 | + |
|
658 | + // Filter by VAT class. |
|
659 | + |
|
660 | + // Sanitize selected vat rule. |
|
661 | + $vat_class = ''; |
|
662 | + $vat_classes = getpaid_get_tax_classes(); |
|
663 | + if ( isset( $_GET['vat_class'] ) ) { |
|
664 | + $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
665 | + } |
|
666 | + |
|
667 | + echo wpinv_html_select( |
|
668 | + array( |
|
669 | + 'options' => array_merge( |
|
670 | + array( |
|
671 | + '' => __( 'All VAT classes', 'invoicing' ), |
|
672 | + ), |
|
673 | + $vat_classes |
|
674 | + ), |
|
675 | + 'name' => 'vat_class', |
|
676 | + 'id' => 'vat_class', |
|
677 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
678 | + 'show_option_all' => false, |
|
679 | + 'show_option_none' => false, |
|
680 | + ) |
|
681 | + ); |
|
682 | + |
|
683 | + } |
|
684 | + |
|
685 | + // Filter by item type. |
|
686 | + $type = ''; |
|
687 | + if ( isset( $_GET['type'] ) ) { |
|
688 | + $type = sanitize_text_field( $_GET['type'] ); |
|
689 | + } |
|
522 | 690 | |
523 | - } |
|
691 | + echo wpinv_html_select( |
|
692 | + array( |
|
693 | + 'options' => array_merge( |
|
694 | + array( |
|
695 | + '' => __( 'All item types', 'invoicing' ), |
|
696 | + ), |
|
697 | + wpinv_get_item_types() |
|
698 | + ), |
|
699 | + 'name' => 'type', |
|
700 | + 'id' => 'type', |
|
701 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
702 | + 'show_option_all' => false, |
|
703 | + 'show_option_none' => false, |
|
704 | + ) |
|
705 | + ); |
|
524 | 706 | |
525 | - /** |
|
526 | - * Returns an array of items table columns. |
|
527 | - */ |
|
528 | - public static function item_columns( $columns ) { |
|
707 | + } |
|
529 | 708 | |
530 | - $columns = array( |
|
531 | - 'cb' => $columns['cb'], |
|
532 | - 'title' => __( 'Name', 'invoicing' ), |
|
533 | - 'price' => __( 'Price', 'invoicing' ), |
|
534 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
535 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
536 | - 'type' => __( 'Type', 'invoicing' ), |
|
537 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
538 | - ); |
|
709 | + /** |
|
710 | + * Filters the item query. |
|
711 | + */ |
|
712 | + public static function filter_item_query( $query ) { |
|
539 | 713 | |
540 | - if ( ! wpinv_use_taxes() ) { |
|
541 | - unset( $columns['vat_rule'] ); |
|
542 | - unset( $columns['vat_class'] ); |
|
543 | - } |
|
714 | + // modify the query only if it admin and main query. |
|
715 | + if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
716 | + return $query; |
|
717 | + } |
|
544 | 718 | |
545 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
546 | - } |
|
719 | + // we want to modify the query for our items. |
|
720 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) { |
|
721 | + return $query; |
|
722 | + } |
|
547 | 723 | |
548 | - /** |
|
549 | - * Returns an array of sortable items table columns. |
|
550 | - */ |
|
551 | - public static function sortable_item_columns( $columns ) { |
|
552 | - |
|
553 | - return array_merge( |
|
554 | - $columns, |
|
555 | - array( |
|
556 | - 'price' => 'price', |
|
557 | - 'vat_rule' => 'vat_rule', |
|
558 | - 'vat_class' => 'vat_class', |
|
559 | - 'type' => 'type', |
|
560 | - ) |
|
561 | - ); |
|
562 | - |
|
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Displays items table columns. |
|
567 | - */ |
|
568 | - public static function display_item_columns( $column_name, $post_id ) { |
|
569 | - |
|
570 | - $item = new WPInv_Item( $post_id ); |
|
571 | - |
|
572 | - switch ( $column_name ) { |
|
573 | - |
|
574 | - case 'price': |
|
575 | - if ( ! $item->is_recurring() ) { |
|
576 | - echo wp_kses_post( $item->get_the_price() ); |
|
577 | - break; |
|
578 | - } |
|
579 | - |
|
580 | - $price = wp_sprintf( |
|
581 | - __( '%1$s / %2$s', 'invoicing' ), |
|
582 | - $item->get_the_price(), |
|
583 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
584 | - ); |
|
585 | - |
|
586 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
587 | - echo wp_kses_post( $price ); |
|
588 | - break; |
|
589 | - } |
|
590 | - |
|
591 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
592 | - |
|
593 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
594 | - break; |
|
595 | - |
|
596 | - case 'vat_rule': |
|
597 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
598 | - break; |
|
599 | - |
|
600 | - case 'vat_class': |
|
601 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
602 | - break; |
|
603 | - |
|
604 | - case 'shortcode': |
|
605 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
606 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
607 | - } else { |
|
608 | - echo '—'; |
|
609 | - } |
|
610 | - |
|
611 | - break; |
|
612 | - |
|
613 | - case 'type': |
|
614 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
615 | - break; |
|
616 | - |
|
617 | - } |
|
618 | - |
|
619 | - } |
|
620 | - |
|
621 | - /** |
|
622 | - * Lets users filter items using taxes. |
|
623 | - */ |
|
624 | - public static function add_item_filters( $post_type ) { |
|
625 | - |
|
626 | - // Abort if we're not dealing with items. |
|
627 | - if ( $post_type != 'wpi_item' ) { |
|
628 | - return; |
|
629 | - } |
|
630 | - |
|
631 | - // Filter by vat rules. |
|
632 | - if ( wpinv_use_taxes() ) { |
|
633 | - |
|
634 | - // Sanitize selected vat rule. |
|
635 | - $vat_rule = ''; |
|
636 | - $vat_rules = getpaid_get_tax_rules(); |
|
637 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
638 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
639 | - } |
|
640 | - |
|
641 | - // Filter by VAT rule. |
|
642 | - echo wpinv_html_select( |
|
643 | - array( |
|
644 | - 'options' => array_merge( |
|
645 | - array( |
|
646 | - '' => __( 'All VAT rules', 'invoicing' ), |
|
647 | - ), |
|
648 | - $vat_rules |
|
649 | - ), |
|
650 | - 'name' => 'vat_rule', |
|
651 | - 'id' => 'vat_rule', |
|
652 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
653 | - 'show_option_all' => false, |
|
654 | - 'show_option_none' => false, |
|
655 | - ) |
|
656 | - ); |
|
657 | - |
|
658 | - // Filter by VAT class. |
|
659 | - |
|
660 | - // Sanitize selected vat rule. |
|
661 | - $vat_class = ''; |
|
662 | - $vat_classes = getpaid_get_tax_classes(); |
|
663 | - if ( isset( $_GET['vat_class'] ) ) { |
|
664 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
665 | - } |
|
666 | - |
|
667 | - echo wpinv_html_select( |
|
668 | - array( |
|
669 | - 'options' => array_merge( |
|
670 | - array( |
|
671 | - '' => __( 'All VAT classes', 'invoicing' ), |
|
672 | - ), |
|
673 | - $vat_classes |
|
674 | - ), |
|
675 | - 'name' => 'vat_class', |
|
676 | - 'id' => 'vat_class', |
|
677 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
678 | - 'show_option_all' => false, |
|
679 | - 'show_option_none' => false, |
|
680 | - ) |
|
681 | - ); |
|
682 | - |
|
683 | - } |
|
684 | - |
|
685 | - // Filter by item type. |
|
686 | - $type = ''; |
|
687 | - if ( isset( $_GET['type'] ) ) { |
|
688 | - $type = sanitize_text_field( $_GET['type'] ); |
|
689 | - } |
|
690 | - |
|
691 | - echo wpinv_html_select( |
|
692 | - array( |
|
693 | - 'options' => array_merge( |
|
694 | - array( |
|
695 | - '' => __( 'All item types', 'invoicing' ), |
|
696 | - ), |
|
697 | - wpinv_get_item_types() |
|
698 | - ), |
|
699 | - 'name' => 'type', |
|
700 | - 'id' => 'type', |
|
701 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
702 | - 'show_option_all' => false, |
|
703 | - 'show_option_none' => false, |
|
704 | - ) |
|
705 | - ); |
|
706 | - |
|
707 | - } |
|
708 | - |
|
709 | - /** |
|
710 | - * Filters the item query. |
|
711 | - */ |
|
712 | - public static function filter_item_query( $query ) { |
|
713 | - |
|
714 | - // modify the query only if it admin and main query. |
|
715 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
716 | - return $query; |
|
717 | - } |
|
718 | - |
|
719 | - // we want to modify the query for our items. |
|
720 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) { |
|
721 | - return $query; |
|
722 | - } |
|
723 | - |
|
724 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
725 | - $query->query_vars['meta_query'] = array(); |
|
726 | - } |
|
727 | - |
|
728 | - // Filter vat rule type |
|
724 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
725 | + $query->query_vars['meta_query'] = array(); |
|
726 | + } |
|
727 | + |
|
728 | + // Filter vat rule type |
|
729 | 729 | if ( ! empty( $_GET['vat_rule'] ) ) { |
730 | 730 | $query->query_vars['meta_query'][] = array( |
731 | 731 | 'key' => '_wpinv_vat_rule', |
@@ -750,97 +750,97 @@ discard block |
||
750 | 750 | 'value' => sanitize_text_field( $_GET['type'] ), |
751 | 751 | 'compare' => '=', |
752 | 752 | ); |
753 | - } |
|
754 | - |
|
755 | - } |
|
756 | - |
|
757 | - /** |
|
758 | - * Reorders items. |
|
759 | - */ |
|
760 | - public static function reorder_items( $vars ) { |
|
761 | - global $typenow; |
|
762 | - |
|
763 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
764 | - return $vars; |
|
765 | - } |
|
766 | - |
|
767 | - // By item type. |
|
768 | - if ( 'type' == $vars['orderby'] ) { |
|
769 | - return array_merge( |
|
770 | - $vars, |
|
771 | - array( |
|
772 | - 'meta_key' => '_wpinv_type', |
|
773 | - 'orderby' => 'meta_value', |
|
774 | - ) |
|
775 | - ); |
|
776 | - } |
|
777 | - |
|
778 | - // By vat class. |
|
779 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
780 | - return array_merge( |
|
781 | - $vars, |
|
782 | - array( |
|
783 | - 'meta_key' => '_wpinv_vat_class', |
|
784 | - 'orderby' => 'meta_value', |
|
785 | - ) |
|
786 | - ); |
|
787 | - } |
|
788 | - |
|
789 | - // By vat rule. |
|
790 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
791 | - return array_merge( |
|
792 | - $vars, |
|
793 | - array( |
|
794 | - 'meta_key' => '_wpinv_vat_rule', |
|
795 | - 'orderby' => 'meta_value', |
|
796 | - ) |
|
797 | - ); |
|
798 | - } |
|
799 | - |
|
800 | - // By price. |
|
801 | - if ( 'price' == $vars['orderby'] ) { |
|
802 | - return array_merge( |
|
803 | - $vars, |
|
804 | - array( |
|
805 | - 'meta_key' => '_wpinv_price', |
|
806 | - 'orderby' => 'meta_value_num', |
|
807 | - ) |
|
808 | - ); |
|
809 | - } |
|
810 | - |
|
811 | - return $vars; |
|
812 | - |
|
813 | - } |
|
814 | - |
|
815 | - /** |
|
816 | - * Fired when deleting a post. |
|
817 | - */ |
|
818 | - public static function delete_post( $post_id ) { |
|
819 | - |
|
820 | - switch ( get_post_type( $post_id ) ) { |
|
821 | - |
|
822 | - case 'wpi_item': |
|
823 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
824 | - break; |
|
825 | - |
|
826 | - case 'wpi_payment_form': |
|
827 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
828 | - break; |
|
829 | - |
|
830 | - case 'wpi_discount': |
|
831 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
832 | - break; |
|
833 | - |
|
834 | - case 'wpi_invoice': |
|
835 | - $invoice = new WPInv_Invoice( $post_id ); |
|
836 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
837 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
838 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
839 | - break; |
|
840 | - } |
|
841 | - } |
|
842 | - |
|
843 | - /** |
|
753 | + } |
|
754 | + |
|
755 | + } |
|
756 | + |
|
757 | + /** |
|
758 | + * Reorders items. |
|
759 | + */ |
|
760 | + public static function reorder_items( $vars ) { |
|
761 | + global $typenow; |
|
762 | + |
|
763 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
764 | + return $vars; |
|
765 | + } |
|
766 | + |
|
767 | + // By item type. |
|
768 | + if ( 'type' == $vars['orderby'] ) { |
|
769 | + return array_merge( |
|
770 | + $vars, |
|
771 | + array( |
|
772 | + 'meta_key' => '_wpinv_type', |
|
773 | + 'orderby' => 'meta_value', |
|
774 | + ) |
|
775 | + ); |
|
776 | + } |
|
777 | + |
|
778 | + // By vat class. |
|
779 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
780 | + return array_merge( |
|
781 | + $vars, |
|
782 | + array( |
|
783 | + 'meta_key' => '_wpinv_vat_class', |
|
784 | + 'orderby' => 'meta_value', |
|
785 | + ) |
|
786 | + ); |
|
787 | + } |
|
788 | + |
|
789 | + // By vat rule. |
|
790 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
791 | + return array_merge( |
|
792 | + $vars, |
|
793 | + array( |
|
794 | + 'meta_key' => '_wpinv_vat_rule', |
|
795 | + 'orderby' => 'meta_value', |
|
796 | + ) |
|
797 | + ); |
|
798 | + } |
|
799 | + |
|
800 | + // By price. |
|
801 | + if ( 'price' == $vars['orderby'] ) { |
|
802 | + return array_merge( |
|
803 | + $vars, |
|
804 | + array( |
|
805 | + 'meta_key' => '_wpinv_price', |
|
806 | + 'orderby' => 'meta_value_num', |
|
807 | + ) |
|
808 | + ); |
|
809 | + } |
|
810 | + |
|
811 | + return $vars; |
|
812 | + |
|
813 | + } |
|
814 | + |
|
815 | + /** |
|
816 | + * Fired when deleting a post. |
|
817 | + */ |
|
818 | + public static function delete_post( $post_id ) { |
|
819 | + |
|
820 | + switch ( get_post_type( $post_id ) ) { |
|
821 | + |
|
822 | + case 'wpi_item': |
|
823 | + do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
824 | + break; |
|
825 | + |
|
826 | + case 'wpi_payment_form': |
|
827 | + do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
828 | + break; |
|
829 | + |
|
830 | + case 'wpi_discount': |
|
831 | + do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
832 | + break; |
|
833 | + |
|
834 | + case 'wpi_invoice': |
|
835 | + $invoice = new WPInv_Invoice( $post_id ); |
|
836 | + do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
837 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
838 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
839 | + break; |
|
840 | + } |
|
841 | + } |
|
842 | + |
|
843 | + /** |
|
844 | 844 | * Add a post display state for special GetPaid pages in the page list table. |
845 | 845 | * |
846 | 846 | * @param array $post_states An array of post display states. |
@@ -854,21 +854,21 @@ discard block |
||
854 | 854 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
855 | 855 | } |
856 | 856 | |
857 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
857 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
858 | 858 | |
859 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
860 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
861 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
862 | - $label |
|
863 | - ); |
|
864 | - } |
|
859 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
860 | + $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
861 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
862 | + $label |
|
863 | + ); |
|
864 | + } |
|
865 | 865 | } |
866 | 866 | |
867 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
867 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
868 | 868 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
869 | 869 | } |
870 | 870 | |
871 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
871 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
872 | 872 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
873 | 873 | } |
874 | 874 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
35 | 35 | |
36 | 36 | // Items table columns. |
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
43 | 43 | |
44 | 44 | // Payment forms columns. |
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Discount table columns. |
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
52 | 52 | |
53 | 53 | // Deleting posts. |
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
56 | 56 | |
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Post updated messages. |
62 | 62 | */ |
63 | - public static function post_updated_messages( $messages ) { |
|
63 | + public static function post_updated_messages($messages) { |
|
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | $messages['wpi_discount'] = array( |
67 | 67 | 0 => '', |
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
68 | + 1 => __('Discount updated.', 'invoicing'), |
|
69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
71 | + 4 => __('Discount updated.', 'invoicing'), |
|
72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
73 | + 6 => __('Discount updated.', 'invoicing'), |
|
74 | + 7 => __('Discount saved.', 'invoicing'), |
|
75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $messages['wpi_payment_form'] = array( |
81 | 81 | 0 => '', |
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | return $messages; |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Post row actions. |
100 | 100 | */ |
101 | - public static function post_row_actions( $actions, $post ) { |
|
101 | + public static function post_row_actions($actions, $post) { |
|
102 | 102 | |
103 | - $post = get_post( $post ); |
|
103 | + $post = get_post($post); |
|
104 | 104 | |
105 | 105 | // We do not want to edit the default payment form. |
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
106 | + if ('wpi_payment_form' == $post->post_type) { |
|
107 | 107 | |
108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
108 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
109 | + unset($actions['trash']); |
|
110 | + unset($actions['inline hide-if-no-js']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $actions['duplicate'] = sprintf( |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | 'getpaid-nonce' |
125 | 125 | ) |
126 | 126 | ), |
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
127 | + esc_html(__('Duplicate', 'invoicing')) |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Link to item payment form. |
133 | - if ( 'wpi_item' == $post->post_type ) { |
|
133 | + if ('wpi_item' == $post->post_type) { |
|
134 | 134 | |
135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
135 | + if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) { |
|
136 | 136 | |
137 | 137 | $actions['buy'] = sprintf( |
138 | 138 | '<a href="%1$s">%2$s</a>', |
139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
139 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
140 | + esc_html(__('Buy', 'invoicing')) |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | } |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | * @param WP_Post $post |
155 | 155 | * @return array $actions actions without edit option |
156 | 156 | */ |
157 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
157 | + public static function filter_invoice_row_actions($actions, $post) { |
|
158 | 158 | |
159 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
159 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
160 | 160 | |
161 | 161 | $actions = array(); |
162 | - $invoice = new WPInv_Invoice( $post ); |
|
162 | + $invoice = new WPInv_Invoice($post); |
|
163 | 163 | |
164 | 164 | $actions['edit'] = sprintf( |
165 | 165 | '<a href="%1$s">%2$s</a>', |
166 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
167 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
166 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
167 | + esc_html(__('Edit', 'invoicing')) |
|
168 | 168 | ); |
169 | 169 | |
170 | - if ( ! $invoice->is_draft() ) { |
|
170 | + if (!$invoice->is_draft()) { |
|
171 | 171 | |
172 | 172 | $actions['view'] = sprintf( |
173 | 173 | '<a href="%1$s">%2$s</a>', |
174 | - esc_url( $invoice->get_view_url() ), |
|
174 | + esc_url($invoice->get_view_url()), |
|
175 | 175 | sprintf( |
176 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
177 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
176 | + esc_html(__('View %s', 'invoicing')), |
|
177 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | 'getpaid-nonce' |
193 | 193 | ) |
194 | 194 | ), |
195 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
195 | + esc_html(__('Send to Customer', 'invoicing')) |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | 'getpaid-nonce' |
212 | 212 | ) |
213 | 213 | ), |
214 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
214 | + esc_html(__('Duplicate', 'invoicing')) |
|
215 | 215 | ); |
216 | 216 | |
217 | 217 | } |
@@ -222,41 +222,41 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Returns an array of invoice table columns. |
224 | 224 | */ |
225 | - public static function invoice_columns( $columns ) { |
|
225 | + public static function invoice_columns($columns) { |
|
226 | 226 | |
227 | 227 | $columns = array( |
228 | 228 | 'cb' => $columns['cb'], |
229 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
230 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
231 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
232 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
233 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
234 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
235 | - 'status' => __( 'Status', 'invoicing' ), |
|
229 | + 'number' => __('Invoice', 'invoicing'), |
|
230 | + 'customer' => __('Customer', 'invoicing'), |
|
231 | + 'invoice_date' => __('Created', 'invoicing'), |
|
232 | + 'payment_date' => __('Completed', 'invoicing'), |
|
233 | + 'amount' => __('Amount', 'invoicing'), |
|
234 | + 'recurring' => __('Recurring', 'invoicing'), |
|
235 | + 'status' => __('Status', 'invoicing'), |
|
236 | 236 | ); |
237 | 237 | |
238 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
238 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Displays invoice table columns. |
243 | 243 | */ |
244 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
244 | + public static function display_invoice_columns($column_name, $post_id) { |
|
245 | 245 | |
246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
246 | + $invoice = new WPInv_Invoice($post_id); |
|
247 | 247 | |
248 | - switch ( $column_name ) { |
|
248 | + switch ($column_name) { |
|
249 | 249 | |
250 | 250 | case 'invoice_date': |
251 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
252 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
251 | + $date_time = esc_attr($invoice->get_created_date()); |
|
252 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
253 | 253 | echo "<span title='$date_time'>$date</span>"; |
254 | 254 | break; |
255 | 255 | |
256 | 256 | case 'payment_date': |
257 | - if ( $invoice->is_paid() ) { |
|
258 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
259 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
257 | + if ($invoice->is_paid()) { |
|
258 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
259 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
260 | 260 | echo "<span title='$date_time'>$date</span>"; |
261 | 261 | } else { |
262 | 262 | echo '—'; |
@@ -266,33 +266,33 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'amount': |
268 | 268 | $amount = $invoice->get_total(); |
269 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
269 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
270 | 270 | |
271 | - if ( $invoice->is_refunded() ) { |
|
272 | - $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
271 | + if ($invoice->is_refunded()) { |
|
272 | + $refunded_amount = wp_kses_post(wpinv_price(0, $invoice->get_currency())); |
|
273 | 273 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
274 | 274 | } else { |
275 | 275 | |
276 | 276 | $discount = $invoice->get_total_discount(); |
277 | 277 | |
278 | - if ( ! empty( $discount ) ) { |
|
279 | - $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
278 | + if (!empty($discount)) { |
|
279 | + $new_amount = wp_kses_post(wpinv_price($amount + $discount, $invoice->get_currency())); |
|
280 | 280 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
281 | 281 | } else { |
282 | - echo wp_kses_post( $formated_amount ); |
|
282 | + echo wp_kses_post($formated_amount); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | 286 | break; |
287 | 287 | |
288 | 288 | case 'status': |
289 | - $status = esc_html( $invoice->get_status() ); |
|
290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
289 | + $status = esc_html($invoice->get_status()); |
|
290 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
291 | 291 | |
292 | 292 | // If it is paid, show the gateway title. |
293 | - if ( $invoice->is_paid() ) { |
|
294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
293 | + if ($invoice->is_paid()) { |
|
294 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
295 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
296 | 296 | |
297 | 297 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
298 | 298 | } else { |
@@ -300,22 +300,22 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // If it is not paid, display the overdue and view status. |
303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
303 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
304 | 304 | |
305 | 305 | // Invoice view status. |
306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
306 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
308 | 308 | } else { |
309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Display the overview status. |
313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
313 | + if (wpinv_get_option('overdue_active')) { |
|
314 | 314 | $due_date = $invoice->get_due_date(); |
315 | - $fomatted = getpaid_format_date( $due_date ); |
|
315 | + $fomatted = getpaid_format_date($due_date); |
|
316 | 316 | |
317 | - if ( ! empty( $fomatted ) ) { |
|
318 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
317 | + if (!empty($fomatted)) { |
|
318 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
319 | 319 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
320 | 320 | } |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | break; |
325 | 325 | |
326 | 326 | case 'recurring': |
327 | - if ( $invoice->is_recurring() ) { |
|
327 | + if ($invoice->is_recurring()) { |
|
328 | 328 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
329 | 329 | } else { |
330 | 330 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | break; |
333 | 333 | |
334 | 334 | case 'number': |
335 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
336 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
337 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
335 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
336 | + $invoice_number = esc_html($invoice->get_number()); |
|
337 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
338 | 338 | |
339 | 339 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
340 | 340 | |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | case 'customer': |
344 | 344 | $customer_name = $invoice->get_user_full_name(); |
345 | 345 | |
346 | - if ( empty( $customer_name ) ) { |
|
346 | + if (empty($customer_name)) { |
|
347 | 347 | $customer_name = $invoice->get_email(); |
348 | 348 | } |
349 | 349 | |
350 | - if ( ! empty( $customer_name ) ) { |
|
351 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
352 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
350 | + if (!empty($customer_name)) { |
|
351 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
352 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
353 | 353 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
354 | 354 | } else { |
355 | 355 | echo '<div>—</div>'; |
@@ -364,19 +364,19 @@ discard block |
||
364 | 364 | /** |
365 | 365 | * Displays invoice bulk actions. |
366 | 366 | */ |
367 | - public static function invoice_bulk_actions( $actions ) { |
|
368 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
367 | + public static function invoice_bulk_actions($actions) { |
|
368 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
369 | 369 | return $actions; |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | 373 | * Processes invoice bulk actions. |
374 | 374 | */ |
375 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
375 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
376 | 376 | |
377 | - if ( $action == 'resend-invoice' ) { |
|
378 | - foreach ( $post_ids as $post_id ) { |
|
379 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
377 | + if ($action == 'resend-invoice') { |
|
378 | + foreach ($post_ids as $post_id) { |
|
379 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -387,49 +387,49 @@ discard block |
||
387 | 387 | /** |
388 | 388 | * Returns an array of payment forms table columns. |
389 | 389 | */ |
390 | - public static function payment_form_columns( $columns ) { |
|
390 | + public static function payment_form_columns($columns) { |
|
391 | 391 | |
392 | 392 | $columns = array( |
393 | 393 | 'cb' => $columns['cb'], |
394 | - 'title' => __( 'Name', 'invoicing' ), |
|
395 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
396 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
397 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
398 | - 'items' => __( 'Items', 'invoicing' ), |
|
399 | - 'date' => __( 'Date', 'invoicing' ), |
|
394 | + 'title' => __('Name', 'invoicing'), |
|
395 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
396 | + 'earnings' => __('Revenue', 'invoicing'), |
|
397 | + 'refunds' => __('Refunded', 'invoicing'), |
|
398 | + 'items' => __('Items', 'invoicing'), |
|
399 | + 'date' => __('Date', 'invoicing'), |
|
400 | 400 | ); |
401 | 401 | |
402 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
402 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
407 | 407 | * Displays payment form table columns. |
408 | 408 | */ |
409 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
409 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
410 | 410 | |
411 | 411 | // Retrieve the payment form. |
412 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
412 | + $form = new GetPaid_Payment_Form($post_id); |
|
413 | 413 | |
414 | - switch ( $column_name ) { |
|
414 | + switch ($column_name) { |
|
415 | 415 | |
416 | 416 | case 'earnings': |
417 | - echo wpinv_price( $form->get_earned() ); |
|
417 | + echo wpinv_price($form->get_earned()); |
|
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'refunds': |
421 | - echo wpinv_price( $form->get_refunded() ); |
|
421 | + echo wpinv_price($form->get_refunded()); |
|
422 | 422 | break; |
423 | 423 | |
424 | 424 | case 'refunds': |
425 | - echo wpinv_price( $form->get_refunded() ); |
|
425 | + echo wpinv_price($form->get_refunded()); |
|
426 | 426 | break; |
427 | 427 | |
428 | 428 | case 'shortcode': |
429 | - if ( $form->is_default() ) { |
|
429 | + if ($form->is_default()) { |
|
430 | 430 | echo '—'; |
431 | 431 | } else { |
432 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
432 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | break; |
@@ -437,28 +437,28 @@ discard block |
||
437 | 437 | case 'items': |
438 | 438 | $items = $form->get_items(); |
439 | 439 | |
440 | - if ( $form->is_default() || empty( $items ) ) { |
|
440 | + if ($form->is_default() || empty($items)) { |
|
441 | 441 | echo '—'; |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | 445 | $_items = array(); |
446 | 446 | |
447 | - foreach ( $items as $item ) { |
|
447 | + foreach ($items as $item) { |
|
448 | 448 | $url = $item->get_edit_url(); |
449 | 449 | |
450 | - if ( empty( $url ) ) { |
|
451 | - $_items[] = esc_html( $item->get_name() ); |
|
450 | + if (empty($url)) { |
|
451 | + $_items[] = esc_html($item->get_name()); |
|
452 | 452 | } else { |
453 | 453 | $_items[] = sprintf( |
454 | 454 | '<a href="%s">%s</a>', |
455 | - esc_url( $url ), |
|
456 | - esc_html( $item->get_name() ) |
|
455 | + esc_url($url), |
|
456 | + esc_html($item->get_name()) |
|
457 | 457 | ); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - echo implode( '<br>', $_items ); |
|
461 | + echo implode('<br>', $_items); |
|
462 | 462 | |
463 | 463 | break; |
464 | 464 | |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | /** |
470 | 470 | * Filters post states. |
471 | 471 | */ |
472 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
472 | + public static function filter_payment_form_state($post_states, $post) { |
|
473 | 473 | |
474 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
475 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
474 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
475 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | return $post_states; |
@@ -482,35 +482,35 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * Returns an array of coupon table columns. |
484 | 484 | */ |
485 | - public static function discount_columns( $columns ) { |
|
485 | + public static function discount_columns($columns) { |
|
486 | 486 | |
487 | 487 | $columns = array( |
488 | 488 | 'cb' => $columns['cb'], |
489 | - 'title' => __( 'Name', 'invoicing' ), |
|
490 | - 'code' => __( 'Code', 'invoicing' ), |
|
491 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
492 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
493 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
494 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
489 | + 'title' => __('Name', 'invoicing'), |
|
490 | + 'code' => __('Code', 'invoicing'), |
|
491 | + 'amount' => __('Amount', 'invoicing'), |
|
492 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
493 | + 'start_date' => __('Start Date', 'invoicing'), |
|
494 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
495 | 495 | ); |
496 | 496 | |
497 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
497 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
501 | 501 | * Filters post states. |
502 | 502 | */ |
503 | - public static function filter_discount_state( $post_states, $post ) { |
|
503 | + public static function filter_discount_state($post_states, $post) { |
|
504 | 504 | |
505 | - if ( 'wpi_discount' == $post->post_type ) { |
|
505 | + if ('wpi_discount' == $post->post_type) { |
|
506 | 506 | |
507 | - $discount = new WPInv_Discount( $post ); |
|
507 | + $discount = new WPInv_Discount($post); |
|
508 | 508 | |
509 | 509 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
510 | 510 | |
511 | - if ( $status != 'publish' ) { |
|
511 | + if ($status != 'publish') { |
|
512 | 512 | return array( |
513 | - 'discount_status' => wpinv_discount_status( $status ), |
|
513 | + 'discount_status' => wpinv_discount_status($status), |
|
514 | 514 | ); |
515 | 515 | } |
516 | 516 | |
@@ -525,30 +525,30 @@ discard block |
||
525 | 525 | /** |
526 | 526 | * Returns an array of items table columns. |
527 | 527 | */ |
528 | - public static function item_columns( $columns ) { |
|
528 | + public static function item_columns($columns) { |
|
529 | 529 | |
530 | 530 | $columns = array( |
531 | 531 | 'cb' => $columns['cb'], |
532 | - 'title' => __( 'Name', 'invoicing' ), |
|
533 | - 'price' => __( 'Price', 'invoicing' ), |
|
534 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
535 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
536 | - 'type' => __( 'Type', 'invoicing' ), |
|
537 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
532 | + 'title' => __('Name', 'invoicing'), |
|
533 | + 'price' => __('Price', 'invoicing'), |
|
534 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
535 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
536 | + 'type' => __('Type', 'invoicing'), |
|
537 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
538 | 538 | ); |
539 | 539 | |
540 | - if ( ! wpinv_use_taxes() ) { |
|
541 | - unset( $columns['vat_rule'] ); |
|
542 | - unset( $columns['vat_class'] ); |
|
540 | + if (!wpinv_use_taxes()) { |
|
541 | + unset($columns['vat_rule']); |
|
542 | + unset($columns['vat_class']); |
|
543 | 543 | } |
544 | 544 | |
545 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
545 | + return apply_filters('wpi_item_table_columns', $columns); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Returns an array of sortable items table columns. |
550 | 550 | */ |
551 | - public static function sortable_item_columns( $columns ) { |
|
551 | + public static function sortable_item_columns($columns) { |
|
552 | 552 | |
553 | 553 | return array_merge( |
554 | 554 | $columns, |
@@ -565,45 +565,45 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * Displays items table columns. |
567 | 567 | */ |
568 | - public static function display_item_columns( $column_name, $post_id ) { |
|
568 | + public static function display_item_columns($column_name, $post_id) { |
|
569 | 569 | |
570 | - $item = new WPInv_Item( $post_id ); |
|
570 | + $item = new WPInv_Item($post_id); |
|
571 | 571 | |
572 | - switch ( $column_name ) { |
|
572 | + switch ($column_name) { |
|
573 | 573 | |
574 | 574 | case 'price': |
575 | - if ( ! $item->is_recurring() ) { |
|
576 | - echo wp_kses_post( $item->get_the_price() ); |
|
575 | + if (!$item->is_recurring()) { |
|
576 | + echo wp_kses_post($item->get_the_price()); |
|
577 | 577 | break; |
578 | 578 | } |
579 | 579 | |
580 | 580 | $price = wp_sprintf( |
581 | - __( '%1$s / %2$s', 'invoicing' ), |
|
581 | + __('%1$s / %2$s', 'invoicing'), |
|
582 | 582 | $item->get_the_price(), |
583 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
583 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
584 | 584 | ); |
585 | 585 | |
586 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
587 | - echo wp_kses_post( $price ); |
|
586 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
587 | + echo wp_kses_post($price); |
|
588 | 588 | break; |
589 | 589 | } |
590 | 590 | |
591 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
591 | + echo wp_kses_post($item->get_the_initial_price()); |
|
592 | 592 | |
593 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
593 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
594 | 594 | break; |
595 | 595 | |
596 | 596 | case 'vat_rule': |
597 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
597 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
598 | 598 | break; |
599 | 599 | |
600 | 600 | case 'vat_class': |
601 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
601 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
602 | 602 | break; |
603 | 603 | |
604 | 604 | case 'shortcode': |
605 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
606 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
605 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
606 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
607 | 607 | } else { |
608 | 608 | echo '—'; |
609 | 609 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'type': |
614 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
614 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | } |
@@ -621,21 +621,21 @@ discard block |
||
621 | 621 | /** |
622 | 622 | * Lets users filter items using taxes. |
623 | 623 | */ |
624 | - public static function add_item_filters( $post_type ) { |
|
624 | + public static function add_item_filters($post_type) { |
|
625 | 625 | |
626 | 626 | // Abort if we're not dealing with items. |
627 | - if ( $post_type != 'wpi_item' ) { |
|
627 | + if ($post_type != 'wpi_item') { |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Filter by vat rules. |
632 | - if ( wpinv_use_taxes() ) { |
|
632 | + if (wpinv_use_taxes()) { |
|
633 | 633 | |
634 | 634 | // Sanitize selected vat rule. |
635 | 635 | $vat_rule = ''; |
636 | 636 | $vat_rules = getpaid_get_tax_rules(); |
637 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
638 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
637 | + if (isset($_GET['vat_rule'])) { |
|
638 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // Filter by VAT rule. |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | array( |
644 | 644 | 'options' => array_merge( |
645 | 645 | array( |
646 | - '' => __( 'All VAT rules', 'invoicing' ), |
|
646 | + '' => __('All VAT rules', 'invoicing'), |
|
647 | 647 | ), |
648 | 648 | $vat_rules |
649 | 649 | ), |
650 | 650 | 'name' => 'vat_rule', |
651 | 651 | 'id' => 'vat_rule', |
652 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
652 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
653 | 653 | 'show_option_all' => false, |
654 | 654 | 'show_option_none' => false, |
655 | 655 | ) |
@@ -660,21 +660,21 @@ discard block |
||
660 | 660 | // Sanitize selected vat rule. |
661 | 661 | $vat_class = ''; |
662 | 662 | $vat_classes = getpaid_get_tax_classes(); |
663 | - if ( isset( $_GET['vat_class'] ) ) { |
|
664 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
663 | + if (isset($_GET['vat_class'])) { |
|
664 | + $vat_class = sanitize_text_field($_GET['vat_class']); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | echo wpinv_html_select( |
668 | 668 | array( |
669 | 669 | 'options' => array_merge( |
670 | 670 | array( |
671 | - '' => __( 'All VAT classes', 'invoicing' ), |
|
671 | + '' => __('All VAT classes', 'invoicing'), |
|
672 | 672 | ), |
673 | 673 | $vat_classes |
674 | 674 | ), |
675 | 675 | 'name' => 'vat_class', |
676 | 676 | 'id' => 'vat_class', |
677 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
677 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
678 | 678 | 'show_option_all' => false, |
679 | 679 | 'show_option_none' => false, |
680 | 680 | ) |
@@ -683,22 +683,22 @@ discard block |
||
683 | 683 | } |
684 | 684 | |
685 | 685 | // Filter by item type. |
686 | - $type = ''; |
|
687 | - if ( isset( $_GET['type'] ) ) { |
|
688 | - $type = sanitize_text_field( $_GET['type'] ); |
|
686 | + $type = ''; |
|
687 | + if (isset($_GET['type'])) { |
|
688 | + $type = sanitize_text_field($_GET['type']); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | echo wpinv_html_select( |
692 | 692 | array( |
693 | 693 | 'options' => array_merge( |
694 | 694 | array( |
695 | - '' => __( 'All item types', 'invoicing' ), |
|
695 | + '' => __('All item types', 'invoicing'), |
|
696 | 696 | ), |
697 | 697 | wpinv_get_item_types() |
698 | 698 | ), |
699 | 699 | 'name' => 'type', |
700 | 700 | 'id' => 'type', |
701 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
701 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
702 | 702 | 'show_option_all' => false, |
703 | 703 | 'show_option_none' => false, |
704 | 704 | ) |
@@ -709,45 +709,45 @@ discard block |
||
709 | 709 | /** |
710 | 710 | * Filters the item query. |
711 | 711 | */ |
712 | - public static function filter_item_query( $query ) { |
|
712 | + public static function filter_item_query($query) { |
|
713 | 713 | |
714 | 714 | // modify the query only if it admin and main query. |
715 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
715 | + if (!(is_admin() && $query->is_main_query())) { |
|
716 | 716 | return $query; |
717 | 717 | } |
718 | 718 | |
719 | 719 | // we want to modify the query for our items. |
720 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) { |
|
720 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
721 | 721 | return $query; |
722 | 722 | } |
723 | 723 | |
724 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
724 | + if (empty($query->query_vars['meta_query'])) { |
|
725 | 725 | $query->query_vars['meta_query'] = array(); |
726 | 726 | } |
727 | 727 | |
728 | 728 | // Filter vat rule type |
729 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
729 | + if (!empty($_GET['vat_rule'])) { |
|
730 | 730 | $query->query_vars['meta_query'][] = array( |
731 | 731 | 'key' => '_wpinv_vat_rule', |
732 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
732 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
733 | 733 | 'compare' => '=', |
734 | 734 | ); |
735 | 735 | } |
736 | 736 | |
737 | 737 | // Filter vat class |
738 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
738 | + if (!empty($_GET['vat_class'])) { |
|
739 | 739 | $query->query_vars['meta_query'][] = array( |
740 | 740 | 'key' => '_wpinv_vat_class', |
741 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
741 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
742 | 742 | 'compare' => '=', |
743 | 743 | ); |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Filter item type |
747 | - if ( ! empty( $_GET['type'] ) ) { |
|
747 | + if (!empty($_GET['type'])) { |
|
748 | 748 | $query->query_vars['meta_query'][] = array( |
749 | 749 | 'key' => '_wpinv_type', |
750 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
750 | + 'value' => sanitize_text_field($_GET['type']), |
|
751 | 751 | 'compare' => '=', |
752 | 752 | ); |
753 | 753 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | /** |
758 | 758 | * Reorders items. |
759 | 759 | */ |
760 | - public static function reorder_items( $vars ) { |
|
760 | + public static function reorder_items($vars) { |
|
761 | 761 | global $typenow; |
762 | 762 | |
763 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
763 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
764 | 764 | return $vars; |
765 | 765 | } |
766 | 766 | |
767 | 767 | // By item type. |
768 | - if ( 'type' == $vars['orderby'] ) { |
|
768 | + if ('type' == $vars['orderby']) { |
|
769 | 769 | return array_merge( |
770 | 770 | $vars, |
771 | 771 | array( |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | // By vat class. |
779 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
779 | + if ('vat_class' == $vars['orderby']) { |
|
780 | 780 | return array_merge( |
781 | 781 | $vars, |
782 | 782 | array( |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | } |
788 | 788 | |
789 | 789 | // By vat rule. |
790 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
790 | + if ('vat_rule' == $vars['orderby']) { |
|
791 | 791 | return array_merge( |
792 | 792 | $vars, |
793 | 793 | array( |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | } |
799 | 799 | |
800 | 800 | // By price. |
801 | - if ( 'price' == $vars['orderby'] ) { |
|
801 | + if ('price' == $vars['orderby']) { |
|
802 | 802 | return array_merge( |
803 | 803 | $vars, |
804 | 804 | array( |
@@ -815,27 +815,27 @@ discard block |
||
815 | 815 | /** |
816 | 816 | * Fired when deleting a post. |
817 | 817 | */ |
818 | - public static function delete_post( $post_id ) { |
|
818 | + public static function delete_post($post_id) { |
|
819 | 819 | |
820 | - switch ( get_post_type( $post_id ) ) { |
|
820 | + switch (get_post_type($post_id)) { |
|
821 | 821 | |
822 | 822 | case 'wpi_item': |
823 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
823 | + do_action('getpaid_before_delete_item', new WPInv_Item($post_id)); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | case 'wpi_payment_form': |
827 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
827 | + do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id)); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'wpi_discount': |
831 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
831 | + do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id)); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'wpi_invoice': |
835 | - $invoice = new WPInv_Invoice( $post_id ); |
|
836 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
837 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
838 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
835 | + $invoice = new WPInv_Invoice($post_id); |
|
836 | + do_action('getpaid_before_delete_invoice', $invoice); |
|
837 | + $invoice->get_data_store()->delete_items($invoice); |
|
838 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
839 | 839 | break; |
840 | 840 | } |
841 | 841 | } |
@@ -848,28 +848,28 @@ discard block |
||
848 | 848 | * |
849 | 849 | * @return mixed |
850 | 850 | */ |
851 | - public static function add_display_post_states( $post_states, $post ) { |
|
851 | + public static function add_display_post_states($post_states, $post) { |
|
852 | 852 | |
853 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
854 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
853 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
854 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
855 | 855 | } |
856 | 856 | |
857 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
857 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
858 | 858 | |
859 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
860 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
861 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
859 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
860 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
861 | + __('GetPaid %s History Page', 'invoicing'), |
|
862 | 862 | $label |
863 | 863 | ); |
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
868 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
867 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
868 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
869 | 869 | } |
870 | 870 | |
871 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
872 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
871 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
872 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $post_states; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <style> |
26 | 26 | .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <div class="col-sm-4"> |
34 | 34 | |
35 | 35 | <!-- Builder tabs --> |
36 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
|
36 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button> |
|
37 | 37 | |
38 | 38 | <!-- Builder tab content --> |
39 | 39 | <div class="mt-4"> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <!-- Available builder elements --> |
42 | 42 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
43 | 43 | <div class="wpinv-form-builder-add-field-types"> |
44 | - <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
44 | + <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
45 | 45 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
46 | 46 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
47 | 47 | <button class="button btn text-dark"> |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | <!-- Edit an element --> |
57 | 57 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
58 | 58 | <div class="wpinv-form-builder-edit-field-wrapper"> |
59 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
60 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
59 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
60 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
61 | 61 | <div class='form-group'> |
62 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ); ?></label> |
|
62 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing'); ?></label> |
|
63 | 63 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
64 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
65 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
66 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
64 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
65 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
66 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
67 | 67 | </select> |
68 | 68 | </div> |
69 | 69 | <div> |
70 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
|
70 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | </div> |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | |
77 | 77 | </div> |
78 | 78 | <div class="col-sm-8 border-left"> |
79 | - <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
80 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
79 | + <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
80 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
81 | 81 | |
82 | 82 | <div class="container-fluid"> |
83 | 83 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
84 | 84 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
85 | 85 | <div class="wpinv-form-builder-element-preview-inner"> |
86 | 86 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
87 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
87 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | </draggable> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </script> |
104 | 104 | <?php |
105 | 105 | |
106 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
106 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,33 +111,33 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param int $post_id |
113 | 113 | */ |
114 | - public static function save( $post_id ) { |
|
114 | + public static function save($post_id) { |
|
115 | 115 | |
116 | 116 | // Prepare the form. |
117 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
117 | + $form = new GetPaid_Payment_Form($post_id); |
|
118 | 118 | |
119 | 119 | // Fetch form items. |
120 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
120 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
121 | 121 | |
122 | 122 | // Ensure that we have an array... |
123 | - if ( empty( $form_items ) ) { |
|
123 | + if (empty($form_items)) { |
|
124 | 124 | $form_items = array(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Add it to the form. |
128 | - $form->set_items( self::item_to_objects( wp_kses_post_deep( $form_items ) ) ); |
|
128 | + $form->set_items(self::item_to_objects(wp_kses_post_deep($form_items))); |
|
129 | 129 | |
130 | 130 | // Save form elements. |
131 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
132 | - if ( empty( $form_elements ) ) { |
|
131 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
132 | + if (empty($form_elements)) { |
|
133 | 133 | $form_elements = array(); |
134 | 134 | } |
135 | 135 | |
136 | - $form->set_elements( wp_kses_post_deep( $form_elements ) ); |
|
136 | + $form->set_elements(wp_kses_post_deep($form_elements)); |
|
137 | 137 | |
138 | 138 | // Persist data to the datastore. |
139 | 139 | $form->save(); |
140 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
140 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param array $items |
148 | 148 | */ |
149 | - public static function item_to_objects( $items ) { |
|
149 | + public static function item_to_objects($items) { |
|
150 | 150 | |
151 | 151 | $objects = array(); |
152 | 152 | |
153 | - foreach ( $items as $item ) { |
|
154 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
155 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
156 | - $_item->set_is_required( (bool) $item['required'] ); |
|
153 | + foreach ($items as $item) { |
|
154 | + $_item = new GetPaid_Form_Item($item['id']); |
|
155 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
156 | + $_item->set_is_required((bool) $item['required']); |
|
157 | 157 | $objects[] = $_item; |
158 | 158 | } |
159 | 159 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( ! defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Payment_Form { |
@@ -11,23 +11,23 @@ discard block |
||
11 | 11 | * |
12 | 12 | * @param WP_Post $post |
13 | 13 | */ |
14 | - public static function output_details( $post ) { |
|
15 | - $details = get_post_meta( $post->ID, 'payment_form_data', true ); |
|
14 | + public static function output_details($post) { |
|
15 | + $details = get_post_meta($post->ID, 'payment_form_data', true); |
|
16 | 16 | |
17 | - if ( ! is_array( $details ) ) { |
|
17 | + if (!is_array($details)) { |
|
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | 21 | echo '<div class="bsui"> <div class="form-row">'; |
22 | 22 | |
23 | - foreach ( $details as $key => $value ) { |
|
24 | - $key = esc_html( $key ); |
|
23 | + foreach ($details as $key => $value) { |
|
24 | + $key = esc_html($key); |
|
25 | 25 | |
26 | - if ( is_array( $value ) ) { |
|
27 | - $value = implode( ',', $value ); |
|
26 | + if (is_array($value)) { |
|
27 | + $value = implode(',', $value); |
|
28 | 28 | } |
29 | 29 | |
30 | - $value = wp_kses_post( $value ); |
|
30 | + $value = wp_kses_post($value); |
|
31 | 31 | echo "<div class='col-12'><strong>$key:</strong></div><div class='col-12 form-group'>$value</div>"; |
32 | 32 | } |
33 | 33 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param WP_Post $post |
42 | 42 | */ |
43 | - public static function output_shortcode( $post ) { |
|
43 | + public static function output_shortcode($post) { |
|
44 | 44 | |
45 | - if ( ! is_numeric( $post ) ) { |
|
45 | + if (!is_numeric($post)) { |
|
46 | 46 | $post = $post->ID; |
47 | 47 | } |
48 | 48 | |
49 | - if ( $post == wpinv_get_default_payment_form() ) { |
|
49 | + if ($post == wpinv_get_default_payment_form()) { |
|
50 | 50 | echo '—'; |
51 | 51 | return; |
52 | 52 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; // Exit if accessed directly |
10 | 10 | } |
11 | 11 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param WP_Post $post |
21 | 21 | */ |
22 | - public static function output( $post ) { |
|
22 | + public static function output($post) { |
|
23 | 23 | |
24 | 24 | // Fetch the invoice. |
25 | - $invoice = new WPInv_Invoice( $post ); |
|
25 | + $invoice = new WPInv_Invoice($post); |
|
26 | 26 | |
27 | - do_action( 'wpinv_metabox_resend_invoice_before', $invoice ); |
|
27 | + do_action('wpinv_metabox_resend_invoice_before', $invoice); |
|
28 | 28 | |
29 | 29 | $invoice_actions = array( |
30 | 30 | 'resend-email' => array( |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | 'getpaid-nonce', |
39 | 39 | 'getpaid-nonce' |
40 | 40 | ), |
41 | - 'label' => __( 'Resend Invoice', 'invoicing' ), |
|
41 | + 'label' => __('Resend Invoice', 'invoicing'), |
|
42 | 42 | ), |
43 | 43 | ); |
44 | 44 | |
45 | - if ( $invoice->needs_payment() ) { |
|
45 | + if ($invoice->needs_payment()) { |
|
46 | 46 | |
47 | 47 | $invoice_actions['send-reminder'] = array( |
48 | 48 | 'url' => wp_nonce_url( |
@@ -55,29 +55,29 @@ discard block |
||
55 | 55 | 'getpaid-nonce', |
56 | 56 | 'getpaid-nonce' |
57 | 57 | ), |
58 | - 'label' => __( 'Send Reminder', 'invoicing' ), |
|
58 | + 'label' => __('Send Reminder', 'invoicing'), |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | - $invoice_actions = apply_filters( 'getpaid_edit_invoice_actions', $invoice_actions, $invoice ); |
|
63 | + $invoice_actions = apply_filters('getpaid_edit_invoice_actions', $invoice_actions, $invoice); |
|
64 | 64 | |
65 | - foreach ( $invoice_actions as $key => $action ) { |
|
65 | + foreach ($invoice_actions as $key => $action) { |
|
66 | 66 | |
67 | - if ( 'resend-email' === $key ) { |
|
68 | - echo wpautop( __( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ) ); |
|
67 | + if ('resend-email' === $key) { |
|
68 | + echo wpautop(__("This will send a copy of the invoice to the customer's email address.", 'invoicing')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | printf( |
72 | 72 | '<p class="wpi-meta-row wpi-%s"><a href="%s" class="button button-secondary">%s</a>', |
73 | - esc_attr( $key ), |
|
74 | - esc_url( $action['url'] ), |
|
75 | - esc_html( $action['label'] ) |
|
73 | + esc_attr($key), |
|
74 | + esc_url($action['url']), |
|
75 | + esc_html($action['label']) |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | } |
79 | 79 | |
80 | - do_action( 'wpinv_metabox_resend_invoice_after', $invoice ); |
|
80 | + do_action('wpinv_metabox_resend_invoice_after', $invoice); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Payment_Meta { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $invoice->is_draft() ) { |
44 | 44 | |
45 | - // Set gateway. |
|
46 | - echo aui()->select( |
|
47 | - array( |
|
45 | + // Set gateway. |
|
46 | + echo aui()->select( |
|
47 | + array( |
|
48 | 48 | 'id' => 'wpinv_gateway', |
49 | 49 | 'name' => 'wpinv_gateway', |
50 | 50 | 'label' => __( 'Gateway:', 'invoicing' ), |
@@ -54,143 +54,143 @@ discard block |
||
54 | 54 | 'select2' => true, |
55 | 55 | 'data-allow-clear' => 'false', |
56 | 56 | 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
57 | - ) |
|
58 | - ); |
|
57 | + ) |
|
58 | + ); |
|
59 | 59 | |
60 | 60 | } else { |
61 | - // Invoice key. |
|
62 | - echo aui()->input( |
|
63 | - array( |
|
61 | + // Invoice key. |
|
62 | + echo aui()->input( |
|
63 | + array( |
|
64 | 64 | 'type' => 'text', |
65 | 65 | 'id' => 'wpinv_key', |
66 | 66 | 'name' => 'wpinv_key', |
67 | 67 | 'label' => sprintf( |
68 | - __( '%s Key:', 'invoicing' ), |
|
69 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
68 | + __( '%s Key:', 'invoicing' ), |
|
69 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
70 | 70 | ), |
71 | 71 | 'label_type' => 'vertical', |
72 | 72 | 'class' => 'form-control-sm', |
73 | 73 | 'value' => $invoice->get_key( 'edit' ), |
74 | 74 | 'extra_attributes' => array( |
75 | - 'onclick' => 'this.select();', |
|
76 | - 'readonly' => 'true', |
|
75 | + 'onclick' => 'this.select();', |
|
76 | + 'readonly' => 'true', |
|
77 | 77 | ), |
78 | - ) |
|
79 | - ); |
|
78 | + ) |
|
79 | + ); |
|
80 | 80 | |
81 | - // View URL. |
|
82 | - echo aui()->input( |
|
83 | - array( |
|
81 | + // View URL. |
|
82 | + echo aui()->input( |
|
83 | + array( |
|
84 | 84 | 'type' => 'text', |
85 | 85 | 'id' => 'wpinv_view_url', |
86 | 86 | 'name' => 'wpinv_view_url', |
87 | 87 | 'label' => sprintf( |
88 | - __( '%s URL:', 'invoicing' ), |
|
89 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
88 | + __( '%s URL:', 'invoicing' ), |
|
89 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
90 | 90 | ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
91 | 91 | 'label_type' => 'vertical', |
92 | 92 | 'class' => 'form-control-sm', |
93 | 93 | 'value' => $invoice->get_view_url(), |
94 | 94 | 'extra_attributes' => array( |
95 | - 'onclick' => 'this.select();', |
|
96 | - 'readonly' => 'true', |
|
95 | + 'onclick' => 'this.select();', |
|
96 | + 'readonly' => 'true', |
|
97 | 97 | ), |
98 | - ) |
|
99 | - ); |
|
100 | - |
|
101 | - // If the invoice is paid... |
|
102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | - |
|
104 | - // Gateway. |
|
105 | - echo aui()->input( |
|
106 | - array( |
|
107 | - 'type' => 'text', |
|
108 | - 'id' => 'wpinv_gateway', |
|
109 | - 'name' => '', |
|
110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | - 'label_type' => 'vertical', |
|
112 | - 'class' => 'form-control-sm', |
|
113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | - 'extra_attributes' => array( |
|
115 | - 'onclick' => 'this.select();', |
|
116 | - 'readonly' => 'true', |
|
117 | - ), |
|
118 | - ) |
|
119 | - ); |
|
120 | - |
|
121 | - // Transaction ID. |
|
122 | - $transaction_url = $invoice->get_transaction_url(); |
|
123 | - echo aui()->input( |
|
124 | - array( |
|
125 | - 'type' => 'text', |
|
126 | - 'id' => 'wpinv_transaction_id', |
|
127 | - 'name' => 'wpinv_transaction_id', |
|
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | - 'label_type' => 'vertical', |
|
130 | - 'class' => 'form-control-sm', |
|
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | - 'extra_attributes' => array( |
|
134 | - 'onclick' => 'this.select();', |
|
135 | - 'readonly' => 'true', |
|
136 | - ), |
|
137 | - ) |
|
138 | - ); |
|
139 | - |
|
140 | - // Currency. |
|
141 | - echo aui()->input( |
|
142 | - array( |
|
143 | - 'type' => 'text', |
|
144 | - 'id' => 'wpinv_currency', |
|
145 | - 'name' => 'wpinv_currency', |
|
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | - 'label_type' => 'vertical', |
|
148 | - 'class' => 'form-control-sm', |
|
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
150 | - 'extra_attributes' => array( |
|
151 | - 'onclick' => 'this.select();', |
|
152 | - 'readonly' => 'true', |
|
153 | - ), |
|
154 | - ) |
|
155 | - ); |
|
156 | - |
|
157 | - } else { |
|
158 | - |
|
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | - |
|
161 | - // Payment URL. |
|
162 | - echo aui()->input( |
|
163 | - array( |
|
164 | - 'type' => 'text', |
|
165 | - 'id' => 'wpinv_payment_url', |
|
166 | - 'name' => 'wpinv_payment_url', |
|
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | - 'label_type' => 'vertical', |
|
169 | - 'class' => 'form-control-sm', |
|
170 | - 'value' => $invoice->get_checkout_payment_url(), |
|
171 | - 'extra_attributes' => array( |
|
172 | - 'onclick' => 'this.select();', |
|
173 | - 'readonly' => 'true', |
|
174 | - ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - // Set gateway. |
|
179 | - echo aui()->select( |
|
180 | - array( |
|
181 | - 'id' => 'wpinv_gateway', |
|
182 | - 'name' => 'wpinv_gateway', |
|
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | - 'label_type' => 'vertical', |
|
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | - 'select2' => true, |
|
188 | - 'data-allow-clear' => 'false', |
|
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | - ) |
|
191 | - ); |
|
192 | - |
|
193 | - } |
|
98 | + ) |
|
99 | + ); |
|
100 | + |
|
101 | + // If the invoice is paid... |
|
102 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
103 | + |
|
104 | + // Gateway. |
|
105 | + echo aui()->input( |
|
106 | + array( |
|
107 | + 'type' => 'text', |
|
108 | + 'id' => 'wpinv_gateway', |
|
109 | + 'name' => '', |
|
110 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | + 'label_type' => 'vertical', |
|
112 | + 'class' => 'form-control-sm', |
|
113 | + 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | + 'extra_attributes' => array( |
|
115 | + 'onclick' => 'this.select();', |
|
116 | + 'readonly' => 'true', |
|
117 | + ), |
|
118 | + ) |
|
119 | + ); |
|
120 | + |
|
121 | + // Transaction ID. |
|
122 | + $transaction_url = $invoice->get_transaction_url(); |
|
123 | + echo aui()->input( |
|
124 | + array( |
|
125 | + 'type' => 'text', |
|
126 | + 'id' => 'wpinv_transaction_id', |
|
127 | + 'name' => 'wpinv_transaction_id', |
|
128 | + 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
129 | + 'label_type' => 'vertical', |
|
130 | + 'class' => 'form-control-sm', |
|
131 | + 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | + 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
133 | + 'extra_attributes' => array( |
|
134 | + 'onclick' => 'this.select();', |
|
135 | + 'readonly' => 'true', |
|
136 | + ), |
|
137 | + ) |
|
138 | + ); |
|
139 | + |
|
140 | + // Currency. |
|
141 | + echo aui()->input( |
|
142 | + array( |
|
143 | + 'type' => 'text', |
|
144 | + 'id' => 'wpinv_currency', |
|
145 | + 'name' => 'wpinv_currency', |
|
146 | + 'label' => __( 'Currency:', 'invoicing' ), |
|
147 | + 'label_type' => 'vertical', |
|
148 | + 'class' => 'form-control-sm', |
|
149 | + 'value' => $invoice->get_currency( 'edit' ), |
|
150 | + 'extra_attributes' => array( |
|
151 | + 'onclick' => 'this.select();', |
|
152 | + 'readonly' => 'true', |
|
153 | + ), |
|
154 | + ) |
|
155 | + ); |
|
156 | + |
|
157 | + } else { |
|
158 | + |
|
159 | + if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
160 | + |
|
161 | + // Payment URL. |
|
162 | + echo aui()->input( |
|
163 | + array( |
|
164 | + 'type' => 'text', |
|
165 | + 'id' => 'wpinv_payment_url', |
|
166 | + 'name' => 'wpinv_payment_url', |
|
167 | + 'label' => __( 'Payment URL:', 'invoicing' ), |
|
168 | + 'label_type' => 'vertical', |
|
169 | + 'class' => 'form-control-sm', |
|
170 | + 'value' => $invoice->get_checkout_payment_url(), |
|
171 | + 'extra_attributes' => array( |
|
172 | + 'onclick' => 'this.select();', |
|
173 | + 'readonly' => 'true', |
|
174 | + ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + // Set gateway. |
|
179 | + echo aui()->select( |
|
180 | + array( |
|
181 | + 'id' => 'wpinv_gateway', |
|
182 | + 'name' => 'wpinv_gateway', |
|
183 | + 'label' => __( 'Gateway:', 'invoicing' ), |
|
184 | + 'label_type' => 'vertical', |
|
185 | + 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | + 'value' => $invoice->get_gateway( 'edit' ), |
|
187 | + 'select2' => true, |
|
188 | + 'data-allow-clear' => 'false', |
|
189 | + 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
190 | + ) |
|
191 | + ); |
|
192 | + |
|
193 | + } |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | ?> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | |
41 | 41 | <?php |
42 | 42 | |
43 | - if ( $invoice->is_draft() ) { |
|
43 | + if ($invoice->is_draft()) { |
|
44 | 44 | |
45 | 45 | // Set gateway. |
46 | 46 | echo aui()->select( |
47 | 47 | array( |
48 | 48 | 'id' => 'wpinv_gateway', |
49 | 49 | 'name' => 'wpinv_gateway', |
50 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
50 | + 'label' => __('Gateway:', 'invoicing'), |
|
51 | 51 | 'label_type' => 'vertical', |
52 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
52 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
53 | 53 | 'value' => wpinv_get_default_gateway(), |
54 | 54 | 'select2' => true, |
55 | 55 | 'data-allow-clear' => 'false', |
56 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
56 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | 'id' => 'wpinv_key', |
66 | 66 | 'name' => 'wpinv_key', |
67 | 67 | 'label' => sprintf( |
68 | - __( '%s Key:', 'invoicing' ), |
|
69 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
68 | + __('%s Key:', 'invoicing'), |
|
69 | + ucfirst($invoice->get_invoice_quote_type()) |
|
70 | 70 | ), |
71 | 71 | 'label_type' => 'vertical', |
72 | 72 | 'class' => 'form-control-sm', |
73 | - 'value' => $invoice->get_key( 'edit' ), |
|
73 | + 'value' => $invoice->get_key('edit'), |
|
74 | 74 | 'extra_attributes' => array( |
75 | 75 | 'onclick' => 'this.select();', |
76 | 76 | 'readonly' => 'true', |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | 'id' => 'wpinv_view_url', |
86 | 86 | 'name' => 'wpinv_view_url', |
87 | 87 | 'label' => sprintf( |
88 | - __( '%s URL:', 'invoicing' ), |
|
89 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
90 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
88 | + __('%s URL:', 'invoicing'), |
|
89 | + ucfirst($invoice->get_invoice_quote_type()) |
|
90 | + ) . ' <a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
91 | 91 | 'label_type' => 'vertical', |
92 | 92 | 'class' => 'form-control-sm', |
93 | 93 | 'value' => $invoice->get_view_url(), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ); |
100 | 100 | |
101 | 101 | // If the invoice is paid... |
102 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
102 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
103 | 103 | |
104 | 104 | // Gateway. |
105 | 105 | echo aui()->input( |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | 'type' => 'text', |
108 | 108 | 'id' => 'wpinv_gateway', |
109 | 109 | 'name' => '', |
110 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
110 | + 'label' => __('Gateway:', 'invoicing'), |
|
111 | 111 | 'label_type' => 'vertical', |
112 | 112 | 'class' => 'form-control-sm', |
113 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
113 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
114 | 114 | 'extra_attributes' => array( |
115 | 115 | 'onclick' => 'this.select();', |
116 | 116 | 'readonly' => 'true', |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | 'type' => 'text', |
126 | 126 | 'id' => 'wpinv_transaction_id', |
127 | 127 | 'name' => 'wpinv_transaction_id', |
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
128 | + 'label' => __('Transaction ID:', 'invoicing') . ($transaction_url ? ' <a href="' . esc_url($transaction_url) . '" title="' . __('View details', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : ''), |
|
129 | 129 | 'label_type' => 'vertical', |
130 | 130 | 'class' => 'form-control-sm', |
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
131 | + 'value' => $invoice->get_transaction_id('edit'), |
|
132 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
133 | 133 | 'extra_attributes' => array( |
134 | 134 | 'onclick' => 'this.select();', |
135 | 135 | 'readonly' => 'true', |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | 'type' => 'text', |
144 | 144 | 'id' => 'wpinv_currency', |
145 | 145 | 'name' => 'wpinv_currency', |
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
146 | + 'label' => __('Currency:', 'invoicing'), |
|
147 | 147 | 'label_type' => 'vertical', |
148 | 148 | 'class' => 'form-control-sm', |
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
149 | + 'value' => $invoice->get_currency('edit'), |
|
150 | 150 | 'extra_attributes' => array( |
151 | 151 | 'onclick' => 'this.select();', |
152 | 152 | 'readonly' => 'true', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } else { |
158 | 158 | |
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
159 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
160 | 160 | |
161 | 161 | // Payment URL. |
162 | 162 | echo aui()->input( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_payment_url', |
166 | 166 | 'name' => 'wpinv_payment_url', |
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
167 | + 'label' => __('Payment URL:', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'class' => 'form-control-sm', |
170 | 170 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | array( |
181 | 181 | 'id' => 'wpinv_gateway', |
182 | 182 | 'name' => 'wpinv_gateway', |
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
183 | + 'label' => __('Gateway:', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
185 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
186 | + 'value' => $invoice->get_gateway('edit'), |
|
187 | 187 | 'select2' => true, |
188 | 188 | 'data-allow-clear' => 'false', |
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
189 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; // Exit if accessed directly |
|
10 | + exit; // Exit if accessed directly |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class GetPaid_Meta_Box_Invoice_Shipping_Address { |
17 | 17 | |
18 | - /** |
|
19 | - * Output the metabox. |
|
20 | - * |
|
21 | - * @param WP_Post $post |
|
22 | - */ |
|
23 | - public static function output( $post ) { |
|
18 | + /** |
|
19 | + * Output the metabox. |
|
20 | + * |
|
21 | + * @param WP_Post $post |
|
22 | + */ |
|
23 | + public static function output( $post ) { |
|
24 | 24 | |
25 | - // Retrieve shipping address. |
|
26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
25 | + // Retrieve shipping address. |
|
26 | + $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
27 | 27 | |
28 | - // Abort if it is invalid. |
|
29 | - if ( ! is_array( $shipping_address ) ) { |
|
30 | - return; |
|
31 | - } |
|
28 | + // Abort if it is invalid. |
|
29 | + if ( ! is_array( $shipping_address ) ) { |
|
30 | + return; |
|
31 | + } |
|
32 | 32 | |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | |
35 | 35 | <div class="bsui"> |
36 | 36 | |
@@ -68,31 +68,31 @@ discard block |
||
68 | 68 | |
69 | 69 | <?php |
70 | 70 | |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Prepares a value. |
|
75 | - * |
|
76 | - * @param array $address |
|
77 | - * @param string $key |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public static function prepare_for_display( $address, $key ) { |
|
73 | + /** |
|
74 | + * Prepares a value. |
|
75 | + * |
|
76 | + * @param array $address |
|
77 | + * @param string $key |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public static function prepare_for_display( $address, $key ) { |
|
81 | 81 | |
82 | - // Prepare the value. |
|
83 | - $value = $address[ $key ]; |
|
82 | + // Prepare the value. |
|
83 | + $value = $address[ $key ]; |
|
84 | 84 | |
85 | - if ( $key == 'country' ) { |
|
86 | - $value = wpinv_country_name( $value ); |
|
87 | - } |
|
85 | + if ( $key == 'country' ) { |
|
86 | + $value = wpinv_country_name( $value ); |
|
87 | + } |
|
88 | 88 | |
89 | - if ( $key == 'state' ) { |
|
90 | - $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
91 | - $value = wpinv_state_name( $value, $country ); |
|
92 | - } |
|
89 | + if ( $key == 'state' ) { |
|
90 | + $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
91 | + $value = wpinv_state_name( $value, $country ); |
|
92 | + } |
|
93 | 93 | |
94 | - return esc_html( $value ); |
|
94 | + return esc_html( $value ); |
|
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | |
25 | 25 | // Retrieve shipping address. |
26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
26 | + $shipping_address = get_post_meta($post->ID, 'shipping_address', true); |
|
27 | 27 | |
28 | 28 | // Abort if it is invalid. |
29 | - if ( ! is_array( $shipping_address ) ) { |
|
29 | + if (!is_array($shipping_address)) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | |
35 | 35 | <div class="bsui"> |
36 | 36 | |
37 | - <?php if ( ! empty( $shipping_address['method'] ) ) : ?> |
|
37 | + <?php if (!empty($shipping_address['method'])) : ?> |
|
38 | 38 | |
39 | 39 | <div class="form-group form-row" style="color: green;"> |
40 | 40 | <div class="col"> |
41 | - <span style="font-weight: 600"><?php esc_html_e( 'Shipping Method', 'invoicing' ); ?>:</span> |
|
41 | + <span style="font-weight: 600"><?php esc_html_e('Shipping Method', 'invoicing'); ?>:</span> |
|
42 | 42 | </div> |
43 | 43 | <div class="col"> |
44 | - <?php echo wp_kses_post( $shipping_address['method'] ); ?> |
|
44 | + <?php echo wp_kses_post($shipping_address['method']); ?> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | |
48 | 48 | <?php endif; ?> |
49 | 49 | |
50 | - <?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?> |
|
50 | + <?php foreach (getpaid_user_address_fields() as $key => $label) : ?> |
|
51 | 51 | |
52 | - <?php if ( ! empty( $shipping_address[ $key ] ) ) : ?> |
|
52 | + <?php if (!empty($shipping_address[$key])) : ?> |
|
53 | 53 | |
54 | 54 | <div class="form-group form-row"> |
55 | 55 | <div class="col"> |
56 | - <span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span> |
|
56 | + <span style="font-weight: 600"><?php echo esc_html($label); ?>:</span> |
|
57 | 57 | </div> |
58 | 58 | <div class="col"> |
59 | - <?php echo self::prepare_for_display( $shipping_address, $key ); ?> |
|
59 | + <?php echo self::prepare_for_display($shipping_address, $key); ?> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | 62 | |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * @param string $key |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public static function prepare_for_display( $address, $key ) { |
|
80 | + public static function prepare_for_display($address, $key) { |
|
81 | 81 | |
82 | 82 | // Prepare the value. |
83 | - $value = $address[ $key ]; |
|
83 | + $value = $address[$key]; |
|
84 | 84 | |
85 | - if ( $key == 'country' ) { |
|
86 | - $value = wpinv_country_name( $value ); |
|
85 | + if ($key == 'country') { |
|
86 | + $value = wpinv_country_name($value); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( $key == 'state' ) { |
|
90 | - $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
91 | - $value = wpinv_state_name( $value, $country ); |
|
89 | + if ($key == 'state') { |
|
90 | + $country = isset($address['country']) ? $address['country'] : wpinv_get_default_country(); |
|
91 | + $value = wpinv_state_name($value, $country); |
|
92 | 92 | } |
93 | 93 | |
94 | - return esc_html( $value ); |
|
94 | + return esc_html($value); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 |