@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | <?php |
45 | 45 | |
46 | 46 | if ( wpinv_is_gateway_active( $id ) ) { |
47 | - echo "<i class='text-success fa fa-check'></i>"; |
|
47 | + echo "<i class='text-success fa fa-check'></i>"; |
|
48 | 48 | } else { |
49 | - echo "<i class='text-dark fa fa-times'></i>"; |
|
49 | + echo "<i class='text-dark fa fa-times'></i>"; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | ?> |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
59 | 59 | |
60 | 60 | if ( $supports ) { |
61 | - echo "<i class='text-success fa fa-check'></i>"; |
|
61 | + echo "<i class='text-success fa fa-check'></i>"; |
|
62 | 62 | } else { |
63 | - echo "<i class='text-dark fa fa-times'></i>"; |
|
63 | + echo "<i class='text-dark fa fa-times'></i>"; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | ?> |
@@ -27,7 +27,7 @@ |
||
27 | 27 | <input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="custom-control-input" |
28 | 28 | <?php |
29 | 29 | if ( is_plugin_active( $plugin['slug'] ) ) { |
30 | - echo 'checked';} |
|
30 | + echo 'checked';} |
|
31 | 31 | ?> |
32 | 32 | > |
33 | 33 | <label class="custom-control-label" for="ac-setting-updates"></label> |
@@ -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 | } |
@@ -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 | } |
@@ -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_Discount_Details { |
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 discount. |
@@ -396,35 +396,35 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * Save meta box data. |
|
400 | - * |
|
401 | - * @param int $post_id |
|
402 | - */ |
|
403 | - public static function save( $post_id ) { |
|
399 | + * Save meta box data. |
|
400 | + * |
|
401 | + * @param int $post_id |
|
402 | + */ |
|
403 | + public static function save( $post_id ) { |
|
404 | 404 | |
405 | 405 | // Prepare the discount. |
406 | 406 | $discount = new WPInv_Discount( $post_id ); |
407 | 407 | |
408 | 408 | // Load new data. |
409 | 409 | $discount->set_props( |
410 | - array( |
|
411 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, |
|
412 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, |
|
413 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
414 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
415 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), |
|
410 | + array( |
|
411 | + 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, |
|
412 | + 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, |
|
413 | + 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
414 | + 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
415 | + 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), |
|
416 | 416 | 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, |
417 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), |
|
418 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), |
|
419 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), |
|
417 | + 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), |
|
418 | + 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), |
|
419 | + 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), |
|
420 | 420 | 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), |
421 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, |
|
422 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, |
|
423 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, |
|
424 | - ) |
|
421 | + 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, |
|
422 | + 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, |
|
423 | + 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, |
|
424 | + ) |
|
425 | 425 | ); |
426 | 426 | |
427 | - $discount->save(); |
|
428 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
429 | - } |
|
427 | + $discount->save(); |
|
428 | + do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
429 | + } |
|
430 | 430 | } |
@@ -5,110 +5,110 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
8 | - exit; // Exit if accessed directly |
|
8 | + exit; // Exit if accessed directly |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
12 | 12 | |
13 | - /** |
|
14 | - * GetPaid_Admin_Profile Class. |
|
15 | - */ |
|
16 | - class GetPaid_Admin_Profile { |
|
17 | - |
|
18 | - /** |
|
19 | - * Hook in tabs. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | - |
|
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Get Address Fields for the edit user pages. |
|
31 | - * |
|
32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | - */ |
|
34 | - public function get_customer_meta_fields() { |
|
35 | - |
|
36 | - $show_fields = apply_filters( |
|
37 | - 'getpaid_customer_meta_fields', |
|
38 | - array( |
|
39 | - 'billing' => array( |
|
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | - 'fields' => array( |
|
42 | - '_wpinv_first_name' => array( |
|
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
44 | - 'description' => '', |
|
45 | - ), |
|
46 | - '_wpinv_last_name' => array( |
|
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
48 | - 'description' => '', |
|
49 | - ), |
|
50 | - '_wpinv_company' => array( |
|
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
52 | - 'description' => '', |
|
53 | - ), |
|
54 | - '_wpinv_company_id' => array( |
|
55 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
56 | - 'description' => '', |
|
57 | - ), |
|
58 | - '_wpinv_address' => array( |
|
59 | - 'label' => __( 'Address', 'invoicing' ), |
|
60 | - 'description' => '', |
|
61 | - ), |
|
62 | - '_wpinv_city' => array( |
|
63 | - 'label' => __( 'City', 'invoicing' ), |
|
64 | - 'description' => '', |
|
65 | - ), |
|
66 | - '_wpinv_zip' => array( |
|
67 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
68 | - 'description' => '', |
|
69 | - ), |
|
70 | - '_wpinv_country' => array( |
|
71 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
72 | - 'description' => '', |
|
73 | - 'class' => 'getpaid_js_field-country', |
|
74 | - 'type' => 'select', |
|
75 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
76 | - ), |
|
77 | - '_wpinv_state' => array( |
|
78 | - 'label' => __( 'State / County', 'invoicing' ), |
|
79 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
80 | - 'class' => 'getpaid_js_field-state regular-text', |
|
81 | - ), |
|
82 | - '_wpinv_phone' => array( |
|
83 | - 'label' => __( 'Phone', 'invoicing' ), |
|
84 | - 'description' => '', |
|
85 | - ), |
|
86 | - '_wpinv_vat_number' => array( |
|
87 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
88 | - 'description' => '', |
|
89 | - ), |
|
90 | - ), |
|
91 | - ), |
|
92 | - ) |
|
93 | - ); |
|
94 | - return $show_fields; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Show Address Fields on edit user pages. |
|
99 | - * |
|
100 | - * @param WP_User $user |
|
101 | - */ |
|
102 | - public function add_customer_meta_fields( $user ) { |
|
103 | - |
|
104 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
105 | - return; |
|
106 | - } |
|
107 | - |
|
108 | - $show_fields = $this->get_customer_meta_fields(); |
|
109 | - |
|
110 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
111 | - ?> |
|
13 | + /** |
|
14 | + * GetPaid_Admin_Profile Class. |
|
15 | + */ |
|
16 | + class GetPaid_Admin_Profile { |
|
17 | + |
|
18 | + /** |
|
19 | + * Hook in tabs. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | + |
|
25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Get Address Fields for the edit user pages. |
|
31 | + * |
|
32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | + */ |
|
34 | + public function get_customer_meta_fields() { |
|
35 | + |
|
36 | + $show_fields = apply_filters( |
|
37 | + 'getpaid_customer_meta_fields', |
|
38 | + array( |
|
39 | + 'billing' => array( |
|
40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | + 'fields' => array( |
|
42 | + '_wpinv_first_name' => array( |
|
43 | + 'label' => __( 'First name', 'invoicing' ), |
|
44 | + 'description' => '', |
|
45 | + ), |
|
46 | + '_wpinv_last_name' => array( |
|
47 | + 'label' => __( 'Last name', 'invoicing' ), |
|
48 | + 'description' => '', |
|
49 | + ), |
|
50 | + '_wpinv_company' => array( |
|
51 | + 'label' => __( 'Company', 'invoicing' ), |
|
52 | + 'description' => '', |
|
53 | + ), |
|
54 | + '_wpinv_company_id' => array( |
|
55 | + 'label' => __( 'Company ID', 'invoicing' ), |
|
56 | + 'description' => '', |
|
57 | + ), |
|
58 | + '_wpinv_address' => array( |
|
59 | + 'label' => __( 'Address', 'invoicing' ), |
|
60 | + 'description' => '', |
|
61 | + ), |
|
62 | + '_wpinv_city' => array( |
|
63 | + 'label' => __( 'City', 'invoicing' ), |
|
64 | + 'description' => '', |
|
65 | + ), |
|
66 | + '_wpinv_zip' => array( |
|
67 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
68 | + 'description' => '', |
|
69 | + ), |
|
70 | + '_wpinv_country' => array( |
|
71 | + 'label' => __( 'Country / Region', 'invoicing' ), |
|
72 | + 'description' => '', |
|
73 | + 'class' => 'getpaid_js_field-country', |
|
74 | + 'type' => 'select', |
|
75 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
76 | + ), |
|
77 | + '_wpinv_state' => array( |
|
78 | + 'label' => __( 'State / County', 'invoicing' ), |
|
79 | + 'description' => __( 'State / County or state code', 'invoicing' ), |
|
80 | + 'class' => 'getpaid_js_field-state regular-text', |
|
81 | + ), |
|
82 | + '_wpinv_phone' => array( |
|
83 | + 'label' => __( 'Phone', 'invoicing' ), |
|
84 | + 'description' => '', |
|
85 | + ), |
|
86 | + '_wpinv_vat_number' => array( |
|
87 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
88 | + 'description' => '', |
|
89 | + ), |
|
90 | + ), |
|
91 | + ), |
|
92 | + ) |
|
93 | + ); |
|
94 | + return $show_fields; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Show Address Fields on edit user pages. |
|
99 | + * |
|
100 | + * @param WP_User $user |
|
101 | + */ |
|
102 | + public function add_customer_meta_fields( $user ) { |
|
103 | + |
|
104 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
105 | + return; |
|
106 | + } |
|
107 | + |
|
108 | + $show_fields = $this->get_customer_meta_fields(); |
|
109 | + |
|
110 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
111 | + ?> |
|
112 | 112 | <h2><?php echo esc_html( $fieldset['title'] ); ?></h2> |
113 | 113 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
114 | 114 | <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
121 | 121 | <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
122 | 122 | <?php |
123 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
124 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
125 | - ?> |
|
123 | + $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
124 | + foreach ( $field['options'] as $option_key => $option_value ) : |
|
125 | + ?> |
|
126 | 126 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
127 | 127 | <?php endforeach; ?> |
128 | 128 | </select> |
@@ -137,52 +137,52 @@ discard block |
||
137 | 137 | <?php endforeach; ?> |
138 | 138 | </table> |
139 | 139 | <?php |
140 | - endforeach; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Save Address Fields on edit user pages. |
|
145 | - * |
|
146 | - * @param int $user_id User ID of the user being saved |
|
147 | - */ |
|
148 | - public function save_customer_meta_fields( $user_id ) { |
|
149 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
150 | - return; |
|
151 | - } |
|
152 | - |
|
153 | - $save_fields = $this->get_customer_meta_fields(); |
|
154 | - |
|
155 | - foreach ( $save_fields as $fieldset ) { |
|
156 | - |
|
157 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
158 | - |
|
159 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
160 | - update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); |
|
161 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
162 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
170 | - * |
|
171 | - * @since 3.1.0 |
|
172 | - * @param int $user_id User ID of the user being edited |
|
173 | - * @param string $key Key for user meta field |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - protected function get_user_meta( $user_id, $key ) { |
|
177 | - $value = get_user_meta( $user_id, $key, true ); |
|
178 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
179 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
180 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
181 | - } |
|
182 | - |
|
183 | - return $value; |
|
184 | - } |
|
185 | - } |
|
140 | + endforeach; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Save Address Fields on edit user pages. |
|
145 | + * |
|
146 | + * @param int $user_id User ID of the user being saved |
|
147 | + */ |
|
148 | + public function save_customer_meta_fields( $user_id ) { |
|
149 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
150 | + return; |
|
151 | + } |
|
152 | + |
|
153 | + $save_fields = $this->get_customer_meta_fields(); |
|
154 | + |
|
155 | + foreach ( $save_fields as $fieldset ) { |
|
156 | + |
|
157 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
158 | + |
|
159 | + if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
160 | + update_user_meta( $user_id, $key, ! empty( $_POST[ $key ] ) ); |
|
161 | + } elseif ( isset( $_POST[ $key ] ) ) { |
|
162 | + update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
170 | + * |
|
171 | + * @since 3.1.0 |
|
172 | + * @param int $user_id User ID of the user being edited |
|
173 | + * @param string $key Key for user meta field |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + protected function get_user_meta( $user_id, $key ) { |
|
177 | + $value = get_user_meta( $user_id, $key, true ); |
|
178 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
179 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
180 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
181 | + } |
|
182 | + |
|
183 | + return $value; |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | 187 | endif; |
188 | 188 |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | 'getpaid-nonce', |
58 | 58 | 'getpaid-nonce' |
59 | 59 | ); |
60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
60 | + $anchor = __( 'Deactivate', 'invoicing' ); |
|
61 | + $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
63 | 63 | |
64 | 64 | } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | 'getpaid-nonce', |
74 | 74 | 'getpaid-nonce' |
75 | 75 | ); |
76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
76 | + $anchor = __( 'Activate', 'invoicing' ); |
|
77 | + $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
79 | 79 | |
80 | 80 | } |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'getpaid-nonce' |
92 | 92 | ) |
93 | 93 | ); |
94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
94 | + $anchor = __( 'Delete', 'invoicing' ); |
|
95 | + $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
97 | 97 | |
98 | 98 | $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $types = wpinv_get_discount_types(); |
119 | 119 | |
120 | 120 | foreach ( $types as $name => $type ) { |
121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
121 | + echo '<option value="' . esc_attr( $name ) . '"'; |
|
122 | 122 | |
123 | - if ( isset( $_GET['discount_type'] ) ) { |
|
124 | - selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
123 | + if ( isset( $_GET['discount_type'] ) ) { |
|
124 | + selected( $name, sanitize_text_field( $_GET['discount_type'] ) ); |
|
125 | 125 | } |
126 | 126 | |
127 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
127 | + echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </select> |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | // Filter vat rule type |
152 | 152 | if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
153 | 153 | $meta_query[] = array( |
154 | - 'key' => '_wpi_discount_type', |
|
155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
156 | - 'compare' => '=', |
|
157 | - ); |
|
158 | - } |
|
154 | + 'key' => '_wpi_discount_type', |
|
155 | + 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
156 | + 'compare' => '=', |
|
157 | + ); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | if ( ! empty( $meta_query ) ) { |
161 | 161 | $vars['meta_query'] = $meta_query; |
162 | - } |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $vars; |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | - * Highlights sub menus. |
|
28 | - */ |
|
29 | - public function set_admin_menu_class() { |
|
30 | - global $current_screen, $parent_file, $submenu_file; |
|
27 | + * Highlights sub menus. |
|
28 | + */ |
|
29 | + public function set_admin_menu_class() { |
|
30 | + global $current_screen, $parent_file, $submenu_file; |
|
31 | 31 | |
32 | 32 | if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
33 | - $parent_file = 'wpinv'; |
|
34 | - $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
33 | + $parent_file = 'wpinv'; |
|
34 | + $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
166 | 166 | $tab_url = add_query_arg( |
167 | 167 | array( |
168 | - 'settings-updated' => false, |
|
169 | - 'tab' => $tab_id, |
|
168 | + 'settings-updated' => false, |
|
169 | + 'tab' => $tab_id, |
|
170 | 170 | ), |
171 | 171 | 'admin.php?page=wpinv-settings' |
172 | 172 | ); |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | $number++; |
194 | 194 | $tab_url = add_query_arg( |
195 | 195 | array( |
196 | - 'settings-updated' => false, |
|
197 | - 'tab' => $active_tab, |
|
198 | - 'section' => $section_id, |
|
196 | + 'settings-updated' => false, |
|
197 | + 'tab' => $active_tab, |
|
198 | + 'section' => $section_id, |
|
199 | 199 | ), |
200 | 200 | admin_url( 'admin.php?page=wpinv-settings' ) |
201 | 201 | ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,92 +15,92 @@ discard block |
||
15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Get the extensions page tabs. |
|
20 | - * |
|
21 | - * @return array of tabs. |
|
22 | - */ |
|
23 | - public function get_tabs() { |
|
24 | - $tabs = array( |
|
25 | - 'addons' => __( 'Addons', 'invoicing' ), |
|
18 | + /** |
|
19 | + * Get the extensions page tabs. |
|
20 | + * |
|
21 | + * @return array of tabs. |
|
22 | + */ |
|
23 | + public function get_tabs() { |
|
24 | + $tabs = array( |
|
25 | + 'addons' => __( 'Addons', 'invoicing' ), |
|
26 | 26 | 'gateways' => __( 'Payment Gateways', 'invoicing' ), |
27 | 27 | 'recommended_plugins' => __( 'Recommended plugins', 'invoicing' ), |
28 | 28 | 'membership' => __( 'Membership', 'invoicing' ), |
29 | - ); |
|
30 | - |
|
31 | - return $tabs; |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Get section content for the addons screen. |
|
36 | - * |
|
37 | - * @param string $section_id |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
43 | - $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
44 | - $section_data = new stdClass(); |
|
45 | - |
|
46 | - if ( $section_id == 'recommended_plugins' ) { |
|
47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | - } elseif ( ! empty( $section ) ) { |
|
49 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
50 | - //if ( 1==1) { |
|
51 | - |
|
52 | - $query_args = array( |
|
53 | - 'category' => $section_id, |
|
54 | - 'number' => 100, |
|
55 | - ); |
|
56 | - $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
57 | - |
|
58 | - $raw_section = wp_safe_remote_get( |
|
29 | + ); |
|
30 | + |
|
31 | + return $tabs; |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Get section content for the addons screen. |
|
36 | + * |
|
37 | + * @param string $section_id |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function get_section_data( $section_id ) { |
|
42 | + $section = self::get_tab( $section_id ); |
|
43 | + $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
44 | + $section_data = new stdClass(); |
|
45 | + |
|
46 | + if ( $section_id == 'recommended_plugins' ) { |
|
47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | + } elseif ( ! empty( $section ) ) { |
|
49 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
50 | + //if ( 1==1) { |
|
51 | + |
|
52 | + $query_args = array( |
|
53 | + 'category' => $section_id, |
|
54 | + 'number' => 100, |
|
55 | + ); |
|
56 | + $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
57 | + |
|
58 | + $raw_section = wp_safe_remote_get( |
|
59 | 59 | esc_url_raw( add_query_arg( $query_args, $api_url ) ), |
60 | 60 | array( |
61 | - 'user-agent' => 'Invoicing Addons Page', |
|
62 | - 'timeout' => 15, |
|
61 | + 'user-agent' => 'Invoicing Addons Page', |
|
62 | + 'timeout' => 15, |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! is_wp_error( $raw_section ) ) { |
|
67 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
66 | + if ( ! is_wp_error( $raw_section ) ) { |
|
67 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
68 | 68 | |
69 | - if ( ! empty( $section_data->products ) ) { |
|
70 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
69 | + if ( ! empty( $section_data->products ) ) { |
|
70 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | - $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | - if ( 'addons' == $section_id ) { |
|
78 | - |
|
79 | - $quotes = new stdClass(); |
|
80 | - $quotes->info = new stdClass(); |
|
81 | - $quotes->info->id = ''; |
|
82 | - $quotes->info->slug = 'invoicing-quotes'; |
|
83 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
85 | - $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
86 | - $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
87 | - |
|
88 | - $products[] = $quotes; |
|
89 | - } |
|
90 | - |
|
91 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Outputs a button. |
|
96 | - *ccc |
|
97 | - * @param string $url |
|
98 | - * @param string $text |
|
99 | - * @param string $theme |
|
100 | - * @param string $plugin |
|
101 | - */ |
|
102 | - public function output_button( $addon ) { |
|
103 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
76 | + $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | + if ( 'addons' == $section_id ) { |
|
78 | + |
|
79 | + $quotes = new stdClass(); |
|
80 | + $quotes->info = new stdClass(); |
|
81 | + $quotes->info->id = ''; |
|
82 | + $quotes->info->slug = 'invoicing-quotes'; |
|
83 | + $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | + $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
85 | + $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
86 | + $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
87 | + |
|
88 | + $products[] = $quotes; |
|
89 | + } |
|
90 | + |
|
91 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Outputs a button. |
|
96 | + *ccc |
|
97 | + * @param string $url |
|
98 | + * @param string $text |
|
99 | + * @param string $theme |
|
100 | + * @param string $plugin |
|
101 | + */ |
|
102 | + public function output_button( $addon ) { |
|
103 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
104 | 104 | // $button_text = __('Free','invoicing'); |
105 | 105 | // $licensing = false; |
106 | 106 | // $installed = false; |
@@ -112,128 +112,128 @@ discard block |
||
112 | 112 | // $install_status = 'get'; |
113 | 113 | // $onclick = ''; |
114 | 114 | |
115 | - $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
116 | - |
|
117 | - $button_args = array( |
|
118 | - 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
119 | - 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
120 | - 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
121 | - 'button_text' => __( 'Free', 'invoicing' ), |
|
122 | - 'price_text' => __( 'Free', 'invoicing' ), |
|
123 | - 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
124 | - 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
125 | - 'class' => 'button-primary', |
|
126 | - 'install_status' => 'get', |
|
127 | - 'installed' => false, |
|
128 | - 'price' => '', |
|
129 | - 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
130 | - 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
131 | - 'onclick' => '', |
|
132 | - 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
133 | - 'active' => false, |
|
134 | - 'file' => '', |
|
135 | - 'update_url' => '', |
|
136 | - ); |
|
137 | - |
|
138 | - if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
139 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
140 | - $status = install_plugin_install_status( |
|
115 | + $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
116 | + |
|
117 | + $button_args = array( |
|
118 | + 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
119 | + 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
120 | + 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
121 | + 'button_text' => __( 'Free', 'invoicing' ), |
|
122 | + 'price_text' => __( 'Free', 'invoicing' ), |
|
123 | + 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
124 | + 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
125 | + 'class' => 'button-primary', |
|
126 | + 'install_status' => 'get', |
|
127 | + 'installed' => false, |
|
128 | + 'price' => '', |
|
129 | + 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
130 | + 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
131 | + 'onclick' => '', |
|
132 | + 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
133 | + 'active' => false, |
|
134 | + 'file' => '', |
|
135 | + 'update_url' => '', |
|
136 | + ); |
|
137 | + |
|
138 | + if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
139 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
140 | + $status = install_plugin_install_status( |
|
141 | 141 | array( |
142 | - 'slug' => $button_args['slug'], |
|
143 | - 'version' => '', |
|
142 | + 'slug' => $button_args['slug'], |
|
143 | + 'version' => '', |
|
144 | 144 | ) |
145 | 145 | ); |
146 | - $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
147 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
148 | - } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
149 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
150 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
146 | + $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
147 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
148 | + } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
149 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
150 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
151 | 151 | $button_args['slug'] = $addon->licensing->edd_slug;} |
152 | - $status = self::install_plugin_install_status( $addon ); |
|
153 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
154 | - if ( isset( $status['status'] ) ) { |
|
152 | + $status = self::install_plugin_install_status( $addon ); |
|
153 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
154 | + if ( isset( $status['status'] ) ) { |
|
155 | 155 | $button_args['install_status'] = $status['status'];} |
156 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
157 | - } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
158 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
156 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
157 | + } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
158 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
159 | 159 | $button_args['slug'] = $addon->licensing->edd_slug;} |
160 | - $button_args['installed'] = self::is_theme_installed( $addon ); |
|
161 | - if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
162 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - // set price |
|
167 | - if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
168 | - if ( is_object( $addon->pricing ) ) { |
|
169 | - $prices = (array)$addon->pricing; |
|
170 | - $button_args['price'] = reset( $prices ); |
|
171 | - } elseif ( isset( $addon->pricing ) ) { |
|
172 | - $button_args['price'] = $addon->pricing; |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - // set price text |
|
177 | - if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
178 | - $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
179 | - } |
|
180 | - |
|
181 | - // set if installed |
|
182 | - if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
183 | - $button_args['installed'] = true; |
|
184 | - } |
|
160 | + $button_args['installed'] = self::is_theme_installed( $addon ); |
|
161 | + if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
162 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + // set price |
|
167 | + if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
168 | + if ( is_object( $addon->pricing ) ) { |
|
169 | + $prices = (array)$addon->pricing; |
|
170 | + $button_args['price'] = reset( $prices ); |
|
171 | + } elseif ( isset( $addon->pricing ) ) { |
|
172 | + $button_args['price'] = $addon->pricing; |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + // set price text |
|
177 | + if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
178 | + $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
179 | + } |
|
180 | + |
|
181 | + // set if installed |
|
182 | + if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
183 | + $button_args['installed'] = true; |
|
184 | + } |
|
185 | 185 | |
186 | 186 | // print_r($button_args); |
187 | - // set if active |
|
188 | - if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
189 | - if ( $button_args['type'] != 'themes' ) { |
|
190 | - $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
191 | - } else { |
|
192 | - $button_args['active'] = self::is_theme_active( $addon ); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - // set button text and class |
|
197 | - if ( $button_args['active'] ) { |
|
198 | - $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
199 | - $button_args['class'] = ' button-secondary disabled '; |
|
200 | - } elseif ( $button_args['installed'] ) { |
|
201 | - $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
202 | - |
|
203 | - if ( $button_args['type'] != 'themes' ) { |
|
204 | - if ( current_user_can( 'manage_options' ) ) { |
|
205 | - $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
206 | - } else { |
|
207 | - $button_args['url'] = '#'; |
|
208 | - } |
|
209 | - } else { |
|
210 | - if ( current_user_can( 'switch_themes' ) ) { |
|
211 | - $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
212 | - } else { |
|
213 | - $button_args['url'] = '#'; |
|
214 | - } |
|
215 | - } |
|
187 | + // set if active |
|
188 | + if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
189 | + if ( $button_args['type'] != 'themes' ) { |
|
190 | + $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
191 | + } else { |
|
192 | + $button_args['active'] = self::is_theme_active( $addon ); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + // set button text and class |
|
197 | + if ( $button_args['active'] ) { |
|
198 | + $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
199 | + $button_args['class'] = ' button-secondary disabled '; |
|
200 | + } elseif ( $button_args['installed'] ) { |
|
201 | + $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
202 | + |
|
203 | + if ( $button_args['type'] != 'themes' ) { |
|
204 | + if ( current_user_can( 'manage_options' ) ) { |
|
205 | + $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
206 | + } else { |
|
207 | + $button_args['url'] = '#'; |
|
208 | + } |
|
209 | + } else { |
|
210 | + if ( current_user_can( 'switch_themes' ) ) { |
|
211 | + $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
212 | + } else { |
|
213 | + $button_args['url'] = '#'; |
|
214 | + } |
|
215 | + } |
|
216 | 216 | } else { |
217 | - if ( $button_args['type'] == 'recommended_plugins' ) { |
|
218 | - $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
219 | - } else { |
|
220 | - $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
217 | + if ( $button_args['type'] == 'recommended_plugins' ) { |
|
218 | + $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
219 | + } else { |
|
220 | + $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
221 | 221 | |
222 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
222 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
223 | 223 | $button_args['button_text'] = __('Install','invoicing'); |
224 | 224 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
225 | 225 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
226 | 226 | }*/ |
227 | 227 | |
228 | - } |
|
229 | - } |
|
228 | + } |
|
229 | + } |
|
230 | 230 | |
231 | - // filter the button arguments |
|
232 | - $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
231 | + // filter the button arguments |
|
232 | + $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
233 | 233 | // print_r($button_args); |
234 | - // set price text |
|
235 | - if ( isset( $button_args['price_text'] ) ) { |
|
236 | - ?> |
|
234 | + // set price text |
|
235 | + if ( isset( $button_args['price_text'] ) ) { |
|
236 | + ?> |
|
237 | 237 | <a |
238 | 238 | target="_blank" |
239 | 239 | class="addons-price-text" |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | <?php echo esc_html( $button_args['price_text'] ); ?> |
242 | 242 | </a> |
243 | 243 | <?php |
244 | - } |
|
244 | + } |
|
245 | 245 | |
246 | - ?> |
|
246 | + ?> |
|
247 | 247 | <a |
248 | 248 | data-licence="<?php echo esc_attr( $button_args['license'] ); ?>" |
249 | 249 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
@@ -267,33 +267,33 @@ discard block |
||
267 | 267 | </a> |
268 | 268 | <?php |
269 | 269 | |
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Handles output of the addons page in admin. |
|
275 | - */ |
|
276 | - public function output() { |
|
277 | - $tabs = self::get_tabs(); |
|
278 | - $sections = self::get_sections(); |
|
279 | - $theme = wp_get_theme(); |
|
280 | - $section_keys = array_keys( $sections ); |
|
281 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
282 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
283 | - include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * A list of recommended wp.org plugins. |
|
288 | - * @return array |
|
289 | - */ |
|
290 | - public function get_recommend_wp_plugins() { |
|
291 | - $plugins = array( |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * Handles output of the addons page in admin. |
|
275 | + */ |
|
276 | + public function output() { |
|
277 | + $tabs = self::get_tabs(); |
|
278 | + $sections = self::get_sections(); |
|
279 | + $theme = wp_get_theme(); |
|
280 | + $section_keys = array_keys( $sections ); |
|
281 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
282 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
283 | + include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * A list of recommended wp.org plugins. |
|
288 | + * @return array |
|
289 | + */ |
|
290 | + public function get_recommend_wp_plugins() { |
|
291 | + $plugins = array( |
|
292 | 292 | 'invoicing-quotes' => array( |
293 | 293 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
294 | 294 | 'slug' => 'invoicing-quotes', |
295 | - 'name' => 'Quotes', |
|
296 | - 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
295 | + 'name' => 'Quotes', |
|
296 | + 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
297 | 297 | 'desc' => __( 'Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing' ), |
298 | 298 | ), |
299 | 299 | 'geodirectory' => array( |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | 'name' => 'UsersWP', |
309 | 309 | 'desc' => __( 'Allow frontend user login and registration as well as have slick profile pages.', 'invoicing' ), |
310 | 310 | ), |
311 | - ); |
|
311 | + ); |
|
312 | 312 | |
313 | - return $plugins; |
|
314 | - } |
|
313 | + return $plugins; |
|
314 | + } |
|
315 | 315 | } |