@@ -7,45 +7,45 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // The payment methods select title. |
13 | -if ( empty( $text ) ) { |
|
14 | - $text = __( 'Select Payment Method', 'invoicing' ); |
|
13 | +if (empty($text)) { |
|
14 | + $text = __('Select Payment Method', 'invoicing'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | // An array of active payment methods. |
18 | -$gateways = wpinv_get_enabled_payment_gateways( true ); |
|
18 | +$gateways = wpinv_get_enabled_payment_gateways(true); |
|
19 | 19 | |
20 | 20 | // The current invoice id. |
21 | 21 | $invoice_id = 0; |
22 | 22 | $chosen_gateway = wpinv_get_default_gateway(); |
23 | 23 | |
24 | -if ( ! empty( $form->invoice ) ) { |
|
24 | +if (!empty($form->invoice)) { |
|
25 | 25 | $invoice_id = $form->invoice->get_id(); |
26 | 26 | $chosen_gateway = $form->invoice->get_gateway(); |
27 | 27 | } |
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | - <?php do_action( 'getpaid_before_payment_form_gateway_select', $form ); ?> |
|
31 | + <?php do_action('getpaid_before_payment_form_gateway_select', $form); ?> |
|
32 | 32 | <div class="mt-4 mb-4 getpaid-gateways"> |
33 | 33 | |
34 | - <?php do_action( 'wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
34 | + <?php do_action('wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
35 | 35 | |
36 | 36 | <div class="getpaid-select-gateway-title-div"> |
37 | - <h6><?php echo sanitize_text_field( $text ); ?></h6> |
|
37 | + <h6><?php echo sanitize_text_field($text); ?></h6> |
|
38 | 38 | </div> |
39 | 39 | |
40 | 40 | <div class="getpaid-available-gateways-div"> |
41 | 41 | |
42 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
42 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
43 | 43 | |
44 | - <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class( $gateway ) ;?>" data-checkout-label='<?php echo esc_attr( apply_filters( "getpaid_gateway_{$gateway}_checkout_button_label", '' ) ); ?>'> |
|
44 | + <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class($gateway); ?>" data-checkout-label='<?php echo esc_attr(apply_filters("getpaid_gateway_{$gateway}_checkout_button_label", '')); ?>'> |
|
45 | 45 | |
46 | 46 | <label class="d-block w-100 getpaid-gateway-radio"> |
47 | - <input type="radio" value="<?php echo esc_attr( $gateway ) ;?>" <?php checked( $gateway, $chosen_gateway ) ;?> name="wpi-gateway"> |
|
48 | - <span><?php echo sanitize_text_field( wpinv_get_gateway_checkout_label( $gateway ) ); ?></span> |
|
47 | + <input type="radio" value="<?php echo esc_attr($gateway); ?>" <?php checked($gateway, $chosen_gateway); ?> name="wpi-gateway"> |
|
48 | + <span><?php echo sanitize_text_field(wpinv_get_gateway_checkout_label($gateway)); ?></span> |
|
49 | 49 | </label> |
50 | 50 | |
51 | 51 | </div> |
@@ -56,22 +56,22 @@ discard block |
||
56 | 56 | |
57 | 57 | <div class="getpaid-gateway-descriptions-div"> |
58 | 58 | |
59 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
59 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
60 | 60 | |
61 | - <div class="my-2 p-3 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class( $gateway ) ;?>" style="display: none;"> |
|
61 | + <div class="my-2 p-3 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class($gateway); ?>" style="display: none;"> |
|
62 | 62 | <?php |
63 | 63 | |
64 | - $description = wpinv_get_gateway_description( $gateway ); |
|
64 | + $description = wpinv_get_gateway_description($gateway); |
|
65 | 65 | |
66 | - if ( wpinv_is_test_mode( $gateway ) ) { |
|
67 | - $sandbox_notice = apply_filters( "getpaid_{$gateway}_sandbox_notice", __( 'SANDBOX ENABLED: No real payments will occur.', 'invoicing' ) ); |
|
66 | + if (wpinv_is_test_mode($gateway)) { |
|
67 | + $sandbox_notice = apply_filters("getpaid_{$gateway}_sandbox_notice", __('SANDBOX ENABLED: No real payments will occur.', 'invoicing')); |
|
68 | 68 | $description = "$description $sandbox_notice"; |
69 | 69 | } |
70 | 70 | |
71 | - echo wpautop( wp_kses_post( $description ) ); |
|
71 | + echo wpautop(wp_kses_post($description)); |
|
72 | 72 | |
73 | - do_action( 'wpinv_' . $gateway . '_checkout_fields', $invoice_id ) ; |
|
74 | - do_action( 'wpinv_' . $gateway . '_cc_form', $invoice_id, $form ) ; |
|
73 | + do_action('wpinv_' . $gateway . '_checkout_fields', $invoice_id); |
|
74 | + do_action('wpinv_' . $gateway . '_cc_form', $invoice_id, $form); |
|
75 | 75 | |
76 | 76 | ?> |
77 | 77 | </div> |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | <?php |
85 | 85 | echo aui()->alert( |
86 | 86 | array( |
87 | - 'content' => __( 'None of the available payment gateways support purchasing recurring items.', 'invoicing' ), |
|
87 | + 'content' => __('None of the available payment gateways support purchasing recurring items.', 'invoicing'), |
|
88 | 88 | 'type' => 'danger', |
89 | 89 | ) |
90 | 90 | ); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | <?php |
96 | 96 | echo aui()->alert( |
97 | 97 | array( |
98 | - 'content' => __( 'None of the available payment gateways support purchasing multiple subscriptions in a single order.', 'invoicing' ), |
|
98 | + 'content' => __('None of the available payment gateways support purchasing multiple subscriptions in a single order.', 'invoicing'), |
|
99 | 99 | 'type' => 'danger', |
100 | 100 | ) |
101 | 101 | ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | <?php |
107 | 107 | echo aui()->alert( |
108 | 108 | array( |
109 | - 'content' => __( 'None of the available payment gateways support purchasing multiple subscriptions with different billing schedules in a single order.', 'invoicing' ), |
|
109 | + 'content' => __('None of the available payment gateways support purchasing multiple subscriptions with different billing schedules in a single order.', 'invoicing'), |
|
110 | 110 | 'type' => 'danger', |
111 | 111 | ) |
112 | 112 | ); |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | <?php |
118 | 118 | echo aui()->alert( |
119 | 119 | array( |
120 | - 'content' => __( 'There is no active payment gateway available to process your request.', 'invoicing' ), |
|
120 | + 'content' => __('There is no active payment gateway available to process your request.', 'invoicing'), |
|
121 | 121 | 'type' => 'danger', |
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | ?> |
125 | 125 | </div> |
126 | 126 | |
127 | - <?php do_action( 'wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
127 | + <?php do_action('wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
128 | 128 | |
129 | 129 | </div> |
130 | - <?php do_action( 'getpaid_after_payment_form_gateway_select', $form ); ?> |
|
130 | + <?php do_action('getpaid_after_payment_form_gateway_select', $form); ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,30 +10,30 @@ discard block |
||
10 | 10 | class WPInv_Item extends GetPaid_Data { |
11 | 11 | |
12 | 12 | /** |
13 | - * Which data store to load. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
13 | + * Which data store to load. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | protected $data_store_name = 'item'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'item'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'item'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Item Data array. This is the core item data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'parent_id' => 0, |
|
34 | - 'status' => 'draft', |
|
35 | - 'version' => '', |
|
36 | - 'date_created' => null, |
|
27 | + * Item Data array. This is the core item data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'parent_id' => 0, |
|
34 | + 'status' => 'draft', |
|
35 | + 'version' => '', |
|
36 | + 'date_created' => null, |
|
37 | 37 | 'date_modified' => null, |
38 | 38 | 'name' => '', |
39 | 39 | 'description' => '', |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | /** |
61 | - * Stores meta in cache for future reads. |
|
62 | - * |
|
63 | - * A group must be set to to enable caching. |
|
64 | - * |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - protected $cache_group = 'getpaid_items'; |
|
61 | + * Stores meta in cache for future reads. |
|
62 | + * |
|
63 | + * A group must be set to to enable caching. |
|
64 | + * |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + protected $cache_group = 'getpaid_items'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Stores a reference to the original WP_Post object |
@@ -74,37 +74,37 @@ discard block |
||
74 | 74 | protected $post = null; |
75 | 75 | |
76 | 76 | /** |
77 | - * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | - * |
|
79 | - * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | - */ |
|
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | - $this->set_id( $item ); |
|
86 | - } elseif ( $item instanceof self ) { |
|
87 | - $this->set_id( $item->get_id() ); |
|
88 | - } elseif ( ! empty( $item->ID ) ) { |
|
89 | - $this->set_id( $item->ID ); |
|
90 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | - $this->set_id( $item_id ); |
|
92 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | - $this->set_id( $item_id ); |
|
94 | - } else { |
|
95 | - $this->set_object_read( true ); |
|
96 | - } |
|
77 | + * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | + * |
|
79 | + * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | + */ |
|
81 | + public function __construct( $item = 0 ) { |
|
82 | + parent::__construct( $item ); |
|
83 | + |
|
84 | + if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | + $this->set_id( $item ); |
|
86 | + } elseif ( $item instanceof self ) { |
|
87 | + $this->set_id( $item->get_id() ); |
|
88 | + } elseif ( ! empty( $item->ID ) ) { |
|
89 | + $this->set_id( $item->ID ); |
|
90 | + } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | + $this->set_id( $item_id ); |
|
92 | + } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | + $this->set_id( $item_id ); |
|
94 | + } else { |
|
95 | + $this->set_object_read( true ); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | // Load the datastore. |
99 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
99 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
100 | 100 | |
101 | - if ( $this->get_id() > 0 ) { |
|
101 | + if ( $this->get_id() > 0 ) { |
|
102 | 102 | $this->post = get_post( $this->get_id() ); |
103 | 103 | $this->ID = $this->get_id(); |
104 | - $this->data_store->read( $this ); |
|
104 | + $this->data_store->read( $this ); |
|
105 | 105 | } |
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | |-------------------------------------------------------------------------- |
@@ -122,401 +122,401 @@ discard block |
||
122 | 122 | */ |
123 | 123 | |
124 | 124 | /** |
125 | - * Get parent item ID. |
|
126 | - * |
|
127 | - * @since 1.0.19 |
|
128 | - * @param string $context View or edit context. |
|
129 | - * @return int |
|
130 | - */ |
|
131 | - public function get_parent_id( $context = 'view' ) { |
|
132 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
125 | + * Get parent item ID. |
|
126 | + * |
|
127 | + * @since 1.0.19 |
|
128 | + * @param string $context View or edit context. |
|
129 | + * @return int |
|
130 | + */ |
|
131 | + public function get_parent_id( $context = 'view' ) { |
|
132 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Get item status. |
|
137 | - * |
|
138 | - * @since 1.0.19 |
|
139 | - * @param string $context View or edit context. |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function get_status( $context = 'view' ) { |
|
143 | - return $this->get_prop( 'status', $context ); |
|
136 | + * Get item status. |
|
137 | + * |
|
138 | + * @since 1.0.19 |
|
139 | + * @param string $context View or edit context. |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function get_status( $context = 'view' ) { |
|
143 | + return $this->get_prop( 'status', $context ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Get plugin version when the item was created. |
|
148 | - * |
|
149 | - * @since 1.0.19 |
|
150 | - * @param string $context View or edit context. |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function get_version( $context = 'view' ) { |
|
154 | - return $this->get_prop( 'version', $context ); |
|
147 | + * Get plugin version when the item was created. |
|
148 | + * |
|
149 | + * @since 1.0.19 |
|
150 | + * @param string $context View or edit context. |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function get_version( $context = 'view' ) { |
|
154 | + return $this->get_prop( 'version', $context ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | - * Get date when the item was created. |
|
159 | - * |
|
160 | - * @since 1.0.19 |
|
161 | - * @param string $context View or edit context. |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function get_date_created( $context = 'view' ) { |
|
165 | - return $this->get_prop( 'date_created', $context ); |
|
158 | + * Get date when the item was created. |
|
159 | + * |
|
160 | + * @since 1.0.19 |
|
161 | + * @param string $context View or edit context. |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function get_date_created( $context = 'view' ) { |
|
165 | + return $this->get_prop( 'date_created', $context ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Get GMT date when the item was created. |
|
170 | - * |
|
171 | - * @since 1.0.19 |
|
172 | - * @param string $context View or edit context. |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function get_date_created_gmt( $context = 'view' ) { |
|
169 | + * Get GMT date when the item was created. |
|
170 | + * |
|
171 | + * @since 1.0.19 |
|
172 | + * @param string $context View or edit context. |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function get_date_created_gmt( $context = 'view' ) { |
|
176 | 176 | $date = $this->get_date_created( $context ); |
177 | 177 | |
178 | 178 | if ( $date ) { |
179 | 179 | $date = get_gmt_from_date( $date ); |
180 | 180 | } |
181 | - return $date; |
|
181 | + return $date; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Get date when the item was last modified. |
|
186 | - * |
|
187 | - * @since 1.0.19 |
|
188 | - * @param string $context View or edit context. |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function get_date_modified( $context = 'view' ) { |
|
192 | - return $this->get_prop( 'date_modified', $context ); |
|
185 | + * Get date when the item was last modified. |
|
186 | + * |
|
187 | + * @since 1.0.19 |
|
188 | + * @param string $context View or edit context. |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function get_date_modified( $context = 'view' ) { |
|
192 | + return $this->get_prop( 'date_modified', $context ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * Get GMT date when the item was last modified. |
|
197 | - * |
|
198 | - * @since 1.0.19 |
|
199 | - * @param string $context View or edit context. |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
196 | + * Get GMT date when the item was last modified. |
|
197 | + * |
|
198 | + * @since 1.0.19 |
|
199 | + * @param string $context View or edit context. |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
203 | 203 | $date = $this->get_date_modified( $context ); |
204 | 204 | |
205 | 205 | if ( $date ) { |
206 | 206 | $date = get_gmt_from_date( $date ); |
207 | 207 | } |
208 | - return $date; |
|
208 | + return $date; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | - * Get the item name. |
|
213 | - * |
|
214 | - * @since 1.0.19 |
|
215 | - * @param string $context View or edit context. |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - public function get_name( $context = 'view' ) { |
|
219 | - return $this->get_prop( 'name', $context ); |
|
212 | + * Get the item name. |
|
213 | + * |
|
214 | + * @since 1.0.19 |
|
215 | + * @param string $context View or edit context. |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + public function get_name( $context = 'view' ) { |
|
219 | + return $this->get_prop( 'name', $context ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | - * Alias of self::get_name(). |
|
224 | - * |
|
225 | - * @since 1.0.19 |
|
226 | - * @param string $context View or edit context. |
|
227 | - * @return string |
|
228 | - */ |
|
229 | - public function get_title( $context = 'view' ) { |
|
230 | - return $this->get_name( $context ); |
|
223 | + * Alias of self::get_name(). |
|
224 | + * |
|
225 | + * @since 1.0.19 |
|
226 | + * @param string $context View or edit context. |
|
227 | + * @return string |
|
228 | + */ |
|
229 | + public function get_title( $context = 'view' ) { |
|
230 | + return $this->get_name( $context ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Get the item description. |
|
235 | - * |
|
236 | - * @since 1.0.19 |
|
237 | - * @param string $context View or edit context. |
|
238 | - * @return string |
|
239 | - */ |
|
240 | - public function get_description( $context = 'view' ) { |
|
241 | - return $this->get_prop( 'description', $context ); |
|
234 | + * Get the item description. |
|
235 | + * |
|
236 | + * @since 1.0.19 |
|
237 | + * @param string $context View or edit context. |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + public function get_description( $context = 'view' ) { |
|
241 | + return $this->get_prop( 'description', $context ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | - * Alias of self::get_description(). |
|
246 | - * |
|
247 | - * @since 1.0.19 |
|
248 | - * @param string $context View or edit context. |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function get_excerpt( $context = 'view' ) { |
|
252 | - return $this->get_description( $context ); |
|
245 | + * Alias of self::get_description(). |
|
246 | + * |
|
247 | + * @since 1.0.19 |
|
248 | + * @param string $context View or edit context. |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function get_excerpt( $context = 'view' ) { |
|
252 | + return $this->get_description( $context ); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | - * Alias of self::get_description(). |
|
257 | - * |
|
258 | - * @since 1.0.19 |
|
259 | - * @param string $context View or edit context. |
|
260 | - * @return string |
|
261 | - */ |
|
262 | - public function get_summary( $context = 'view' ) { |
|
263 | - return $this->get_description( $context ); |
|
256 | + * Alias of self::get_description(). |
|
257 | + * |
|
258 | + * @since 1.0.19 |
|
259 | + * @param string $context View or edit context. |
|
260 | + * @return string |
|
261 | + */ |
|
262 | + public function get_summary( $context = 'view' ) { |
|
263 | + return $this->get_description( $context ); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | - * Get the owner of the item. |
|
268 | - * |
|
269 | - * @since 1.0.19 |
|
270 | - * @param string $context View or edit context. |
|
271 | - * @return int |
|
272 | - */ |
|
273 | - public function get_author( $context = 'view' ) { |
|
274 | - return (int) $this->get_prop( 'author', $context ); |
|
275 | - } |
|
267 | + * Get the owner of the item. |
|
268 | + * |
|
269 | + * @since 1.0.19 |
|
270 | + * @param string $context View or edit context. |
|
271 | + * @return int |
|
272 | + */ |
|
273 | + public function get_author( $context = 'view' ) { |
|
274 | + return (int) $this->get_prop( 'author', $context ); |
|
275 | + } |
|
276 | 276 | |
277 | - /** |
|
278 | - * Alias of self::get_author(). |
|
279 | - * |
|
280 | - * @since 1.0.19 |
|
281 | - * @param string $context View or edit context. |
|
282 | - * @return int |
|
283 | - */ |
|
284 | - public function get_owner( $context = 'view' ) { |
|
285 | - return $this->get_author( $context ); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Get the price of the item. |
|
290 | - * |
|
291 | - * @since 1.0.19 |
|
292 | - * @param string $context View or edit context. |
|
293 | - * @return float |
|
294 | - */ |
|
295 | - public function get_price( $context = 'view' ) { |
|
277 | + /** |
|
278 | + * Alias of self::get_author(). |
|
279 | + * |
|
280 | + * @since 1.0.19 |
|
281 | + * @param string $context View or edit context. |
|
282 | + * @return int |
|
283 | + */ |
|
284 | + public function get_owner( $context = 'view' ) { |
|
285 | + return $this->get_author( $context ); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Get the price of the item. |
|
290 | + * |
|
291 | + * @since 1.0.19 |
|
292 | + * @param string $context View or edit context. |
|
293 | + * @return float |
|
294 | + */ |
|
295 | + public function get_price( $context = 'view' ) { |
|
296 | 296 | return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
297 | - } |
|
297 | + } |
|
298 | 298 | |
299 | - /** |
|
300 | - * Get the inital price of the item. |
|
301 | - * |
|
302 | - * @since 1.0.19 |
|
303 | - * @param string $context View or edit context. |
|
304 | - * @return float |
|
305 | - */ |
|
306 | - public function get_initial_price( $context = 'view' ) { |
|
299 | + /** |
|
300 | + * Get the inital price of the item. |
|
301 | + * |
|
302 | + * @since 1.0.19 |
|
303 | + * @param string $context View or edit context. |
|
304 | + * @return float |
|
305 | + */ |
|
306 | + public function get_initial_price( $context = 'view' ) { |
|
307 | 307 | |
308 | - $price = (float) $this->get_price( $context ); |
|
308 | + $price = (float) $this->get_price( $context ); |
|
309 | 309 | |
310 | - if ( $this->has_free_trial() ) { |
|
311 | - $price = 0; |
|
312 | - } |
|
310 | + if ( $this->has_free_trial() ) { |
|
311 | + $price = 0; |
|
312 | + } |
|
313 | 313 | |
314 | 314 | return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | - * Returns a formated price. |
|
319 | - * |
|
320 | - * @since 1.0.19 |
|
321 | - * @param string $context View or edit context. |
|
322 | - * @return string |
|
323 | - */ |
|
318 | + * Returns a formated price. |
|
319 | + * |
|
320 | + * @since 1.0.19 |
|
321 | + * @param string $context View or edit context. |
|
322 | + * @return string |
|
323 | + */ |
|
324 | 324 | public function get_the_price() { |
325 | 325 | return wpinv_price( $this->get_price() ); |
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Returns the formated initial price. |
|
330 | - * |
|
331 | - * @since 1.0.19 |
|
332 | - * @param string $context View or edit context. |
|
333 | - * @return string |
|
334 | - */ |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Returns the formated initial price. |
|
330 | + * |
|
331 | + * @since 1.0.19 |
|
332 | + * @param string $context View or edit context. |
|
333 | + * @return string |
|
334 | + */ |
|
335 | 335 | public function get_the_initial_price() { |
336 | 336 | return wpinv_price( $this->get_initial_price() ); |
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Get the VAT rule of the item. |
|
341 | - * |
|
342 | - * @since 1.0.19 |
|
343 | - * @param string $context View or edit context. |
|
344 | - * @return string |
|
345 | - */ |
|
346 | - public function get_vat_rule( $context = 'view' ) { |
|
340 | + * Get the VAT rule of the item. |
|
341 | + * |
|
342 | + * @since 1.0.19 |
|
343 | + * @param string $context View or edit context. |
|
344 | + * @return string |
|
345 | + */ |
|
346 | + public function get_vat_rule( $context = 'view' ) { |
|
347 | 347 | return $this->get_prop( 'vat_rule', $context ); |
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | - * Get the VAT class of the item. |
|
352 | - * |
|
353 | - * @since 1.0.19 |
|
354 | - * @param string $context View or edit context. |
|
355 | - * @return string |
|
356 | - */ |
|
357 | - public function get_vat_class( $context = 'view' ) { |
|
351 | + * Get the VAT class of the item. |
|
352 | + * |
|
353 | + * @since 1.0.19 |
|
354 | + * @param string $context View or edit context. |
|
355 | + * @return string |
|
356 | + */ |
|
357 | + public function get_vat_class( $context = 'view' ) { |
|
358 | 358 | return $this->get_prop( 'vat_class', $context ); |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Get the type of the item. |
|
363 | - * |
|
364 | - * @since 1.0.19 |
|
365 | - * @param string $context View or edit context. |
|
366 | - * @return string |
|
367 | - */ |
|
368 | - public function get_type( $context = 'view' ) { |
|
362 | + * Get the type of the item. |
|
363 | + * |
|
364 | + * @since 1.0.19 |
|
365 | + * @param string $context View or edit context. |
|
366 | + * @return string |
|
367 | + */ |
|
368 | + public function get_type( $context = 'view' ) { |
|
369 | 369 | return $this->get_prop( 'type', $context ); |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | - * Get the custom id of the item. |
|
374 | - * |
|
375 | - * @since 1.0.19 |
|
376 | - * @param string $context View or edit context. |
|
377 | - * @return string |
|
378 | - */ |
|
379 | - public function get_custom_id( $context = 'view' ) { |
|
373 | + * Get the custom id of the item. |
|
374 | + * |
|
375 | + * @since 1.0.19 |
|
376 | + * @param string $context View or edit context. |
|
377 | + * @return string |
|
378 | + */ |
|
379 | + public function get_custom_id( $context = 'view' ) { |
|
380 | 380 | return $this->get_prop( 'custom_id', $context ); |
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | - * Get the custom name of the item. |
|
385 | - * |
|
386 | - * @since 1.0.19 |
|
387 | - * @param string $context View or edit context. |
|
388 | - * @return string |
|
389 | - */ |
|
390 | - public function get_custom_name( $context = 'view' ) { |
|
384 | + * Get the custom name of the item. |
|
385 | + * |
|
386 | + * @since 1.0.19 |
|
387 | + * @param string $context View or edit context. |
|
388 | + * @return string |
|
389 | + */ |
|
390 | + public function get_custom_name( $context = 'view' ) { |
|
391 | 391 | return $this->get_prop( 'custom_name', $context ); |
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | - * Get the custom singular name of the item. |
|
396 | - * |
|
397 | - * @since 1.0.19 |
|
398 | - * @param string $context View or edit context. |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public function get_custom_singular_name( $context = 'view' ) { |
|
395 | + * Get the custom singular name of the item. |
|
396 | + * |
|
397 | + * @since 1.0.19 |
|
398 | + * @param string $context View or edit context. |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public function get_custom_singular_name( $context = 'view' ) { |
|
402 | 402 | return $this->get_prop( 'custom_singular_name', $context ); |
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
406 | - * Checks if an item is editable.. |
|
407 | - * |
|
408 | - * @since 1.0.19 |
|
409 | - * @param string $context View or edit context. |
|
410 | - * @return int |
|
411 | - */ |
|
412 | - public function get_is_editable( $context = 'view' ) { |
|
406 | + * Checks if an item is editable.. |
|
407 | + * |
|
408 | + * @since 1.0.19 |
|
409 | + * @param string $context View or edit context. |
|
410 | + * @return int |
|
411 | + */ |
|
412 | + public function get_is_editable( $context = 'view' ) { |
|
413 | 413 | return (int) $this->get_prop( 'is_editable', $context ); |
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
417 | - * Alias of self::get_is_editable(). |
|
418 | - * |
|
419 | - * @since 1.0.19 |
|
420 | - * @param string $context View or edit context. |
|
421 | - * @return int |
|
422 | - */ |
|
423 | - public function get_editable( $context = 'view' ) { |
|
424 | - return $this->get_is_editable( $context ); |
|
417 | + * Alias of self::get_is_editable(). |
|
418 | + * |
|
419 | + * @since 1.0.19 |
|
420 | + * @param string $context View or edit context. |
|
421 | + * @return int |
|
422 | + */ |
|
423 | + public function get_editable( $context = 'view' ) { |
|
424 | + return $this->get_is_editable( $context ); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
428 | - * Checks if dynamic pricing is enabled. |
|
429 | - * |
|
430 | - * @since 1.0.19 |
|
431 | - * @param string $context View or edit context. |
|
432 | - * @return int |
|
433 | - */ |
|
434 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
428 | + * Checks if dynamic pricing is enabled. |
|
429 | + * |
|
430 | + * @since 1.0.19 |
|
431 | + * @param string $context View or edit context. |
|
432 | + * @return int |
|
433 | + */ |
|
434 | + public function get_is_dynamic_pricing( $context = 'view' ) { |
|
435 | 435 | return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Returns the minimum price if dynamic pricing is enabled. |
|
440 | - * |
|
441 | - * @since 1.0.19 |
|
442 | - * @param string $context View or edit context. |
|
443 | - * @return float |
|
444 | - */ |
|
445 | - public function get_minimum_price( $context = 'view' ) { |
|
439 | + * Returns the minimum price if dynamic pricing is enabled. |
|
440 | + * |
|
441 | + * @since 1.0.19 |
|
442 | + * @param string $context View or edit context. |
|
443 | + * @return float |
|
444 | + */ |
|
445 | + public function get_minimum_price( $context = 'view' ) { |
|
446 | 446 | return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * Checks if this is a recurring item. |
|
451 | - * |
|
452 | - * @since 1.0.19 |
|
453 | - * @param string $context View or edit context. |
|
454 | - * @return int |
|
455 | - */ |
|
456 | - public function get_is_recurring( $context = 'view' ) { |
|
450 | + * Checks if this is a recurring item. |
|
451 | + * |
|
452 | + * @since 1.0.19 |
|
453 | + * @param string $context View or edit context. |
|
454 | + * @return int |
|
455 | + */ |
|
456 | + public function get_is_recurring( $context = 'view' ) { |
|
457 | 457 | return (int) $this->get_prop( 'is_recurring', $context ); |
458 | - } |
|
458 | + } |
|
459 | 459 | |
460 | - /** |
|
461 | - * Get the recurring price of the item. |
|
462 | - * |
|
463 | - * @since 1.0.19 |
|
464 | - * @param string $context View or edit context. |
|
465 | - * @return float |
|
466 | - */ |
|
467 | - public function get_recurring_price( $context = 'view' ) { |
|
468 | - $price = $this->get_price( $context ); |
|
460 | + /** |
|
461 | + * Get the recurring price of the item. |
|
462 | + * |
|
463 | + * @since 1.0.19 |
|
464 | + * @param string $context View or edit context. |
|
465 | + * @return float |
|
466 | + */ |
|
467 | + public function get_recurring_price( $context = 'view' ) { |
|
468 | + $price = $this->get_price( $context ); |
|
469 | 469 | return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Get the formatted recurring price of the item. |
|
474 | - * |
|
475 | - * @since 1.0.19 |
|
476 | - * @param string $context View or edit context. |
|
477 | - * @return string |
|
478 | - */ |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Get the formatted recurring price of the item. |
|
474 | + * |
|
475 | + * @since 1.0.19 |
|
476 | + * @param string $context View or edit context. |
|
477 | + * @return string |
|
478 | + */ |
|
479 | 479 | public function get_the_recurring_price() { |
480 | 480 | return wpinv_price( $this->get_recurring_price() ); |
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Get the first renewal date (in timestamps) of the item. |
|
485 | - * |
|
486 | - * @since 1.0.19 |
|
487 | - * @return int |
|
488 | - */ |
|
489 | - public function get_first_renewal_date() { |
|
490 | - |
|
491 | - $periods = array( |
|
492 | - 'D' => 'days', |
|
493 | - 'W' => 'weeks', |
|
494 | - 'M' => 'months', |
|
495 | - 'Y' => 'years', |
|
496 | - ); |
|
497 | - |
|
498 | - $period = $this->get_recurring_period(); |
|
499 | - $interval = $this->get_recurring_interval(); |
|
500 | - |
|
501 | - if ( $this->has_free_trial() ) { |
|
502 | - $period = $this->get_trial_period(); |
|
503 | - $interval = $this->get_trial_interval(); |
|
504 | - } |
|
505 | - |
|
506 | - $period = $periods[ $period ]; |
|
507 | - $interval = empty( $interval ) ? 1 : $interval; |
|
508 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Get the first renewal date (in timestamps) of the item. |
|
485 | + * |
|
486 | + * @since 1.0.19 |
|
487 | + * @return int |
|
488 | + */ |
|
489 | + public function get_first_renewal_date() { |
|
490 | + |
|
491 | + $periods = array( |
|
492 | + 'D' => 'days', |
|
493 | + 'W' => 'weeks', |
|
494 | + 'M' => 'months', |
|
495 | + 'Y' => 'years', |
|
496 | + ); |
|
497 | + |
|
498 | + $period = $this->get_recurring_period(); |
|
499 | + $interval = $this->get_recurring_interval(); |
|
500 | + |
|
501 | + if ( $this->has_free_trial() ) { |
|
502 | + $period = $this->get_trial_period(); |
|
503 | + $interval = $this->get_trial_interval(); |
|
504 | + } |
|
505 | + |
|
506 | + $period = $periods[ $period ]; |
|
507 | + $interval = empty( $interval ) ? 1 : $interval; |
|
508 | + $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
509 | 509 | return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
513 | - * Get the recurring period. |
|
514 | - * |
|
515 | - * @since 1.0.19 |
|
516 | - * @param bool $full Return abbreviation or in full. |
|
517 | - * @return string |
|
518 | - */ |
|
519 | - public function get_recurring_period( $full = false ) { |
|
513 | + * Get the recurring period. |
|
514 | + * |
|
515 | + * @since 1.0.19 |
|
516 | + * @param bool $full Return abbreviation or in full. |
|
517 | + * @return string |
|
518 | + */ |
|
519 | + public function get_recurring_period( $full = false ) { |
|
520 | 520 | $period = $this->get_prop( 'recurring_period', 'view' ); |
521 | 521 | |
522 | 522 | if ( $full && ! is_bool( $full ) ) { |
@@ -527,58 +527,58 @@ discard block |
||
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
530 | - * Get the recurring interval. |
|
531 | - * |
|
532 | - * @since 1.0.19 |
|
533 | - * @param string $context View or edit context. |
|
534 | - * @return int |
|
535 | - */ |
|
536 | - public function get_recurring_interval( $context = 'view' ) { |
|
537 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
538 | - return max( 1, $interval ); |
|
530 | + * Get the recurring interval. |
|
531 | + * |
|
532 | + * @since 1.0.19 |
|
533 | + * @param string $context View or edit context. |
|
534 | + * @return int |
|
535 | + */ |
|
536 | + public function get_recurring_interval( $context = 'view' ) { |
|
537 | + $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
538 | + return max( 1, $interval ); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
542 | - * Get the recurring limit. |
|
543 | - * |
|
544 | - * @since 1.0.19 |
|
545 | - * @param string $context View or edit context. |
|
546 | - * @return int |
|
547 | - */ |
|
548 | - public function get_recurring_limit( $context = 'view' ) { |
|
542 | + * Get the recurring limit. |
|
543 | + * |
|
544 | + * @since 1.0.19 |
|
545 | + * @param string $context View or edit context. |
|
546 | + * @return int |
|
547 | + */ |
|
548 | + public function get_recurring_limit( $context = 'view' ) { |
|
549 | 549 | return (int) $this->get_prop( 'recurring_limit', $context ); |
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
553 | - * Checks if we have a free trial. |
|
554 | - * |
|
555 | - * @since 1.0.19 |
|
556 | - * @param string $context View or edit context. |
|
557 | - * @return int |
|
558 | - */ |
|
559 | - public function get_is_free_trial( $context = 'view' ) { |
|
553 | + * Checks if we have a free trial. |
|
554 | + * |
|
555 | + * @since 1.0.19 |
|
556 | + * @param string $context View or edit context. |
|
557 | + * @return int |
|
558 | + */ |
|
559 | + public function get_is_free_trial( $context = 'view' ) { |
|
560 | 560 | return (int) $this->get_prop( 'is_free_trial', $context ); |
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
564 | - * Alias for self::get_is_free_trial(). |
|
565 | - * |
|
566 | - * @since 1.0.19 |
|
567 | - * @param string $context View or edit context. |
|
568 | - * @return int |
|
569 | - */ |
|
570 | - public function get_free_trial( $context = 'view' ) { |
|
564 | + * Alias for self::get_is_free_trial(). |
|
565 | + * |
|
566 | + * @since 1.0.19 |
|
567 | + * @param string $context View or edit context. |
|
568 | + * @return int |
|
569 | + */ |
|
570 | + public function get_free_trial( $context = 'view' ) { |
|
571 | 571 | return $this->get_is_free_trial( $context ); |
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
575 | - * Get the trial period. |
|
576 | - * |
|
577 | - * @since 1.0.19 |
|
578 | - * @param bool $full Return abbreviation or in full. |
|
579 | - * @return string |
|
580 | - */ |
|
581 | - public function get_trial_period( $full = false ) { |
|
575 | + * Get the trial period. |
|
576 | + * |
|
577 | + * @since 1.0.19 |
|
578 | + * @param bool $full Return abbreviation or in full. |
|
579 | + * @return string |
|
580 | + */ |
|
581 | + public function get_trial_period( $full = false ) { |
|
582 | 582 | $period = $this->get_prop( 'trial_period', 'view' ); |
583 | 583 | |
584 | 584 | if ( $full && ! is_bool( $full ) ) { |
@@ -589,104 +589,104 @@ discard block |
||
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
592 | - * Get the trial interval. |
|
593 | - * |
|
594 | - * @since 1.0.19 |
|
595 | - * @param string $context View or edit context. |
|
596 | - * @return int |
|
597 | - */ |
|
598 | - public function get_trial_interval( $context = 'view' ) { |
|
592 | + * Get the trial interval. |
|
593 | + * |
|
594 | + * @since 1.0.19 |
|
595 | + * @param string $context View or edit context. |
|
596 | + * @return int |
|
597 | + */ |
|
598 | + public function get_trial_interval( $context = 'view' ) { |
|
599 | 599 | return (int) $this->get_prop( 'trial_interval', $context ); |
600 | - } |
|
600 | + } |
|
601 | 601 | |
602 | - /** |
|
603 | - * Get the item's edit url. |
|
604 | - * |
|
605 | - * @since 1.0.19 |
|
606 | - * @return string |
|
607 | - */ |
|
608 | - public function get_edit_url() { |
|
602 | + /** |
|
603 | + * Get the item's edit url. |
|
604 | + * |
|
605 | + * @since 1.0.19 |
|
606 | + * @return string |
|
607 | + */ |
|
608 | + public function get_edit_url() { |
|
609 | 609 | return get_edit_post_link( $this->get_id(), 'edit' ); |
610 | - } |
|
611 | - |
|
612 | - /** |
|
613 | - * Given an item's name/custom id, it returns its id. |
|
614 | - * |
|
615 | - * |
|
616 | - * @static |
|
617 | - * @param string $value The item name or custom id. |
|
618 | - * @param string $field Either name or custom_id. |
|
619 | - * @param string $type in case you need to search for a given type. |
|
620 | - * @since 1.0.15 |
|
621 | - * @return int |
|
622 | - */ |
|
623 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
624 | - |
|
625 | - // Trim the value. |
|
626 | - $value = sanitize_text_field( $value ); |
|
627 | - if ( empty( $value ) ) { |
|
628 | - return 0; |
|
629 | - } |
|
610 | + } |
|
611 | + |
|
612 | + /** |
|
613 | + * Given an item's name/custom id, it returns its id. |
|
614 | + * |
|
615 | + * |
|
616 | + * @static |
|
617 | + * @param string $value The item name or custom id. |
|
618 | + * @param string $field Either name or custom_id. |
|
619 | + * @param string $type in case you need to search for a given type. |
|
620 | + * @since 1.0.15 |
|
621 | + * @return int |
|
622 | + */ |
|
623 | + public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
624 | + |
|
625 | + // Trim the value. |
|
626 | + $value = sanitize_text_field( $value ); |
|
627 | + if ( empty( $value ) ) { |
|
628 | + return 0; |
|
629 | + } |
|
630 | 630 | |
631 | 631 | // Valid fields. |
632 | 632 | $fields = array( 'custom_id', 'name', 'slug' ); |
633 | 633 | |
634 | - // Ensure a field has been passed. |
|
635 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
636 | - return 0; |
|
637 | - } |
|
638 | - |
|
639 | - if ( $field == 'name' ) { |
|
640 | - $field = 'slug'; |
|
641 | - } |
|
642 | - |
|
643 | - // Maybe retrieve from the cache. |
|
644 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
645 | - if ( ! empty( $item_id ) ) { |
|
646 | - return $item_id; |
|
647 | - } |
|
648 | - |
|
649 | - // Fetch from the db. |
|
650 | - $items = array(); |
|
651 | - if ( $field == 'slug' ) { |
|
652 | - $items = get_posts( |
|
653 | - array( |
|
654 | - 'post_type' => 'wpi_item', |
|
655 | - 'name' => $value, |
|
656 | - 'posts_per_page' => 1, |
|
657 | - 'post_status' => 'any', |
|
658 | - ) |
|
659 | - ); |
|
660 | - } |
|
661 | - |
|
662 | - if ( $field =='custom_id' ) { |
|
663 | - $items = get_posts( |
|
664 | - array( |
|
665 | - 'post_type' => 'wpi_item', |
|
666 | - 'posts_per_page' => 1, |
|
667 | - 'post_status' => 'any', |
|
668 | - 'meta_query' => array( |
|
669 | - array( |
|
670 | - 'key' => '_wpinv_type', |
|
671 | - 'value' => $type, |
|
672 | - ), |
|
673 | - array( |
|
674 | - 'key' => '_wpinv_custom_id', |
|
675 | - 'value' => $value, |
|
676 | - ) |
|
677 | - ) |
|
678 | - ) |
|
679 | - ); |
|
680 | - } |
|
681 | - |
|
682 | - if ( empty( $items ) ) { |
|
683 | - return 0; |
|
684 | - } |
|
685 | - |
|
686 | - // Update the cache with our data |
|
687 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
688 | - |
|
689 | - return $items[0]->ID; |
|
634 | + // Ensure a field has been passed. |
|
635 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
636 | + return 0; |
|
637 | + } |
|
638 | + |
|
639 | + if ( $field == 'name' ) { |
|
640 | + $field = 'slug'; |
|
641 | + } |
|
642 | + |
|
643 | + // Maybe retrieve from the cache. |
|
644 | + $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
645 | + if ( ! empty( $item_id ) ) { |
|
646 | + return $item_id; |
|
647 | + } |
|
648 | + |
|
649 | + // Fetch from the db. |
|
650 | + $items = array(); |
|
651 | + if ( $field == 'slug' ) { |
|
652 | + $items = get_posts( |
|
653 | + array( |
|
654 | + 'post_type' => 'wpi_item', |
|
655 | + 'name' => $value, |
|
656 | + 'posts_per_page' => 1, |
|
657 | + 'post_status' => 'any', |
|
658 | + ) |
|
659 | + ); |
|
660 | + } |
|
661 | + |
|
662 | + if ( $field =='custom_id' ) { |
|
663 | + $items = get_posts( |
|
664 | + array( |
|
665 | + 'post_type' => 'wpi_item', |
|
666 | + 'posts_per_page' => 1, |
|
667 | + 'post_status' => 'any', |
|
668 | + 'meta_query' => array( |
|
669 | + array( |
|
670 | + 'key' => '_wpinv_type', |
|
671 | + 'value' => $type, |
|
672 | + ), |
|
673 | + array( |
|
674 | + 'key' => '_wpinv_custom_id', |
|
675 | + 'value' => $value, |
|
676 | + ) |
|
677 | + ) |
|
678 | + ) |
|
679 | + ); |
|
680 | + } |
|
681 | + |
|
682 | + if ( empty( $items ) ) { |
|
683 | + return 0; |
|
684 | + } |
|
685 | + |
|
686 | + // Update the cache with our data |
|
687 | + wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
688 | + |
|
689 | + return $items[0]->ID; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -719,52 +719,52 @@ discard block |
||
719 | 719 | */ |
720 | 720 | |
721 | 721 | /** |
722 | - * Set parent order ID. |
|
723 | - * |
|
724 | - * @since 1.0.19 |
|
725 | - */ |
|
726 | - public function set_parent_id( $value ) { |
|
727 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
728 | - return; |
|
729 | - } |
|
730 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * Sets item status. |
|
735 | - * |
|
736 | - * @since 1.0.19 |
|
737 | - * @param string $status New status. |
|
738 | - * @return array details of change. |
|
739 | - */ |
|
740 | - public function set_status( $status ) { |
|
722 | + * Set parent order ID. |
|
723 | + * |
|
724 | + * @since 1.0.19 |
|
725 | + */ |
|
726 | + public function set_parent_id( $value ) { |
|
727 | + if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
728 | + return; |
|
729 | + } |
|
730 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Sets item status. |
|
735 | + * |
|
736 | + * @since 1.0.19 |
|
737 | + * @param string $status New status. |
|
738 | + * @return array details of change. |
|
739 | + */ |
|
740 | + public function set_status( $status ) { |
|
741 | 741 | $old_status = $this->get_status(); |
742 | 742 | |
743 | 743 | $this->set_prop( 'status', $status ); |
744 | 744 | |
745 | - return array( |
|
746 | - 'from' => $old_status, |
|
747 | - 'to' => $status, |
|
748 | - ); |
|
745 | + return array( |
|
746 | + 'from' => $old_status, |
|
747 | + 'to' => $status, |
|
748 | + ); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
752 | - * Set plugin version when the item was created. |
|
753 | - * |
|
754 | - * @since 1.0.19 |
|
755 | - */ |
|
756 | - public function set_version( $value ) { |
|
757 | - $this->set_prop( 'version', $value ); |
|
752 | + * Set plugin version when the item was created. |
|
753 | + * |
|
754 | + * @since 1.0.19 |
|
755 | + */ |
|
756 | + public function set_version( $value ) { |
|
757 | + $this->set_prop( 'version', $value ); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
761 | - * Set date when the item was created. |
|
762 | - * |
|
763 | - * @since 1.0.19 |
|
764 | - * @param string $value Value to set. |
|
761 | + * Set date when the item was created. |
|
762 | + * |
|
763 | + * @since 1.0.19 |
|
764 | + * @param string $value Value to set. |
|
765 | 765 | * @return bool Whether or not the date was set. |
766 | - */ |
|
767 | - public function set_date_created( $value ) { |
|
766 | + */ |
|
767 | + public function set_date_created( $value ) { |
|
768 | 768 | $date = strtotime( $value ); |
769 | 769 | |
770 | 770 | if ( $date ) { |
@@ -777,13 +777,13 @@ discard block |
||
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
780 | - * Set date when the item was last modified. |
|
781 | - * |
|
782 | - * @since 1.0.19 |
|
783 | - * @param string $value Value to set. |
|
780 | + * Set date when the item was last modified. |
|
781 | + * |
|
782 | + * @since 1.0.19 |
|
783 | + * @param string $value Value to set. |
|
784 | 784 | * @return bool Whether or not the date was set. |
785 | - */ |
|
786 | - public function set_date_modified( $value ) { |
|
785 | + */ |
|
786 | + public function set_date_modified( $value ) { |
|
787 | 787 | $date = strtotime( $value ); |
788 | 788 | |
789 | 789 | if ( $date ) { |
@@ -796,115 +796,115 @@ discard block |
||
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
799 | - * Set the item name. |
|
800 | - * |
|
801 | - * @since 1.0.19 |
|
802 | - * @param string $value New name. |
|
803 | - */ |
|
804 | - public function set_name( $value ) { |
|
799 | + * Set the item name. |
|
800 | + * |
|
801 | + * @since 1.0.19 |
|
802 | + * @param string $value New name. |
|
803 | + */ |
|
804 | + public function set_name( $value ) { |
|
805 | 805 | $name = sanitize_text_field( $value ); |
806 | - $this->set_prop( 'name', $name ); |
|
806 | + $this->set_prop( 'name', $name ); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
810 | - * Alias of self::set_name(). |
|
811 | - * |
|
812 | - * @since 1.0.19 |
|
813 | - * @param string $value New name. |
|
814 | - */ |
|
815 | - public function set_title( $value ) { |
|
816 | - $this->set_name( $value ); |
|
810 | + * Alias of self::set_name(). |
|
811 | + * |
|
812 | + * @since 1.0.19 |
|
813 | + * @param string $value New name. |
|
814 | + */ |
|
815 | + public function set_title( $value ) { |
|
816 | + $this->set_name( $value ); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
820 | - * Set the item description. |
|
821 | - * |
|
822 | - * @since 1.0.19 |
|
823 | - * @param string $value New description. |
|
824 | - */ |
|
825 | - public function set_description( $value ) { |
|
826 | - $description = wp_kses_post( $value ); |
|
827 | - return $this->set_prop( 'description', $description ); |
|
820 | + * Set the item description. |
|
821 | + * |
|
822 | + * @since 1.0.19 |
|
823 | + * @param string $value New description. |
|
824 | + */ |
|
825 | + public function set_description( $value ) { |
|
826 | + $description = wp_kses_post( $value ); |
|
827 | + return $this->set_prop( 'description', $description ); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
831 | - * Alias of self::set_description(). |
|
832 | - * |
|
833 | - * @since 1.0.19 |
|
834 | - * @param string $value New description. |
|
835 | - */ |
|
836 | - public function set_excerpt( $value ) { |
|
837 | - $this->set_description( $value ); |
|
831 | + * Alias of self::set_description(). |
|
832 | + * |
|
833 | + * @since 1.0.19 |
|
834 | + * @param string $value New description. |
|
835 | + */ |
|
836 | + public function set_excerpt( $value ) { |
|
837 | + $this->set_description( $value ); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
841 | - * Alias of self::set_description(). |
|
842 | - * |
|
843 | - * @since 1.0.19 |
|
844 | - * @param string $value New description. |
|
845 | - */ |
|
846 | - public function set_summary( $value ) { |
|
847 | - $this->set_description( $value ); |
|
841 | + * Alias of self::set_description(). |
|
842 | + * |
|
843 | + * @since 1.0.19 |
|
844 | + * @param string $value New description. |
|
845 | + */ |
|
846 | + public function set_summary( $value ) { |
|
847 | + $this->set_description( $value ); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
851 | - * Set the owner of the item. |
|
852 | - * |
|
853 | - * @since 1.0.19 |
|
854 | - * @param int $value New author. |
|
855 | - */ |
|
856 | - public function set_author( $value ) { |
|
857 | - $this->set_prop( 'author', (int) $value ); |
|
858 | - } |
|
851 | + * Set the owner of the item. |
|
852 | + * |
|
853 | + * @since 1.0.19 |
|
854 | + * @param int $value New author. |
|
855 | + */ |
|
856 | + public function set_author( $value ) { |
|
857 | + $this->set_prop( 'author', (int) $value ); |
|
858 | + } |
|
859 | 859 | |
860 | - /** |
|
861 | - * Alias of self::set_author(). |
|
862 | - * |
|
863 | - * @since 1.0.19 |
|
864 | - * @param int $value New author. |
|
865 | - */ |
|
866 | - public function set_owner( $value ) { |
|
867 | - $this->set_author( $value ); |
|
868 | - } |
|
869 | - |
|
870 | - /** |
|
871 | - * Set the price of the item. |
|
872 | - * |
|
873 | - * @since 1.0.19 |
|
874 | - * @param float $value New price. |
|
875 | - */ |
|
876 | - public function set_price( $value ) { |
|
860 | + /** |
|
861 | + * Alias of self::set_author(). |
|
862 | + * |
|
863 | + * @since 1.0.19 |
|
864 | + * @param int $value New author. |
|
865 | + */ |
|
866 | + public function set_owner( $value ) { |
|
867 | + $this->set_author( $value ); |
|
868 | + } |
|
869 | + |
|
870 | + /** |
|
871 | + * Set the price of the item. |
|
872 | + * |
|
873 | + * @since 1.0.19 |
|
874 | + * @param float $value New price. |
|
875 | + */ |
|
876 | + public function set_price( $value ) { |
|
877 | 877 | $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
881 | - * Set the VAT rule of the item. |
|
882 | - * |
|
883 | - * @since 1.0.19 |
|
884 | - * @param string $value new rule. |
|
885 | - */ |
|
886 | - public function set_vat_rule( $value ) { |
|
881 | + * Set the VAT rule of the item. |
|
882 | + * |
|
883 | + * @since 1.0.19 |
|
884 | + * @param string $value new rule. |
|
885 | + */ |
|
886 | + public function set_vat_rule( $value ) { |
|
887 | 887 | $this->set_prop( 'vat_rule', $value ); |
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
891 | - * Set the VAT class of the item. |
|
892 | - * |
|
893 | - * @since 1.0.19 |
|
894 | - * @param string $value new class. |
|
895 | - */ |
|
896 | - public function set_vat_class( $value ) { |
|
891 | + * Set the VAT class of the item. |
|
892 | + * |
|
893 | + * @since 1.0.19 |
|
894 | + * @param string $value new class. |
|
895 | + */ |
|
896 | + public function set_vat_class( $value ) { |
|
897 | 897 | $this->set_prop( 'vat_class', $value ); |
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
901 | - * Set the type of the item. |
|
902 | - * |
|
903 | - * @since 1.0.19 |
|
904 | - * @param string $value new item type. |
|
905 | - * @return string |
|
906 | - */ |
|
907 | - public function set_type( $value ) { |
|
901 | + * Set the type of the item. |
|
902 | + * |
|
903 | + * @since 1.0.19 |
|
904 | + * @param string $value new item type. |
|
905 | + * @return string |
|
906 | + */ |
|
907 | + public function set_type( $value ) { |
|
908 | 908 | |
909 | 909 | if ( empty( $value ) ) { |
910 | 910 | $value = 'custom'; |
@@ -914,132 +914,132 @@ discard block |
||
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
917 | - * Set the custom id of the item. |
|
918 | - * |
|
919 | - * @since 1.0.19 |
|
920 | - * @param string $value new custom id. |
|
921 | - */ |
|
922 | - public function set_custom_id( $value ) { |
|
917 | + * Set the custom id of the item. |
|
918 | + * |
|
919 | + * @since 1.0.19 |
|
920 | + * @param string $value new custom id. |
|
921 | + */ |
|
922 | + public function set_custom_id( $value ) { |
|
923 | 923 | $this->set_prop( 'custom_id', $value ); |
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
927 | - * Set the custom name of the item. |
|
928 | - * |
|
929 | - * @since 1.0.19 |
|
930 | - * @param string $value new custom name. |
|
931 | - */ |
|
932 | - public function set_custom_name( $value ) { |
|
927 | + * Set the custom name of the item. |
|
928 | + * |
|
929 | + * @since 1.0.19 |
|
930 | + * @param string $value new custom name. |
|
931 | + */ |
|
932 | + public function set_custom_name( $value ) { |
|
933 | 933 | $this->set_prop( 'custom_name', $value ); |
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
937 | - * Set the custom singular name of the item. |
|
938 | - * |
|
939 | - * @since 1.0.19 |
|
940 | - * @param string $value new custom singular name. |
|
941 | - */ |
|
942 | - public function set_custom_singular_name( $value ) { |
|
937 | + * Set the custom singular name of the item. |
|
938 | + * |
|
939 | + * @since 1.0.19 |
|
940 | + * @param string $value new custom singular name. |
|
941 | + */ |
|
942 | + public function set_custom_singular_name( $value ) { |
|
943 | 943 | $this->set_prop( 'custom_singular_name', $value ); |
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
947 | - * Sets if an item is editable.. |
|
948 | - * |
|
949 | - * @since 1.0.19 |
|
950 | - * @param int|bool $value whether or not the item is editable. |
|
951 | - */ |
|
952 | - public function set_is_editable( $value ) { |
|
953 | - $this->set_prop( 'is_editable', (int) $value ); |
|
947 | + * Sets if an item is editable.. |
|
948 | + * |
|
949 | + * @since 1.0.19 |
|
950 | + * @param int|bool $value whether or not the item is editable. |
|
951 | + */ |
|
952 | + public function set_is_editable( $value ) { |
|
953 | + $this->set_prop( 'is_editable', (int) $value ); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
957 | - * Sets if dynamic pricing is enabled. |
|
958 | - * |
|
959 | - * @since 1.0.19 |
|
960 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
961 | - */ |
|
962 | - public function set_is_dynamic_pricing( $value ) { |
|
957 | + * Sets if dynamic pricing is enabled. |
|
958 | + * |
|
959 | + * @since 1.0.19 |
|
960 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
961 | + */ |
|
962 | + public function set_is_dynamic_pricing( $value ) { |
|
963 | 963 | $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
967 | - * Sets the minimum price if dynamic pricing is enabled. |
|
968 | - * |
|
969 | - * @since 1.0.19 |
|
970 | - * @param float $value minimum price. |
|
971 | - */ |
|
972 | - public function set_minimum_price( $value ) { |
|
967 | + * Sets the minimum price if dynamic pricing is enabled. |
|
968 | + * |
|
969 | + * @since 1.0.19 |
|
970 | + * @param float $value minimum price. |
|
971 | + */ |
|
972 | + public function set_minimum_price( $value ) { |
|
973 | 973 | $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
977 | - * Sets if this is a recurring item. |
|
978 | - * |
|
979 | - * @since 1.0.19 |
|
980 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
981 | - */ |
|
982 | - public function set_is_recurring( $value ) { |
|
977 | + * Sets if this is a recurring item. |
|
978 | + * |
|
979 | + * @since 1.0.19 |
|
980 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
981 | + */ |
|
982 | + public function set_is_recurring( $value ) { |
|
983 | 983 | $this->set_prop( 'is_recurring', (int) $value ); |
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
987 | - * Set the recurring period. |
|
988 | - * |
|
989 | - * @since 1.0.19 |
|
990 | - * @param string $value new period. |
|
991 | - */ |
|
992 | - public function set_recurring_period( $value ) { |
|
987 | + * Set the recurring period. |
|
988 | + * |
|
989 | + * @since 1.0.19 |
|
990 | + * @param string $value new period. |
|
991 | + */ |
|
992 | + public function set_recurring_period( $value ) { |
|
993 | 993 | $this->set_prop( 'recurring_period', $value ); |
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
997 | - * Set the recurring interval. |
|
998 | - * |
|
999 | - * @since 1.0.19 |
|
1000 | - * @param int $value recurring interval. |
|
1001 | - */ |
|
1002 | - public function set_recurring_interval( $value ) { |
|
997 | + * Set the recurring interval. |
|
998 | + * |
|
999 | + * @since 1.0.19 |
|
1000 | + * @param int $value recurring interval. |
|
1001 | + */ |
|
1002 | + public function set_recurring_interval( $value ) { |
|
1003 | 1003 | return $this->set_prop( 'recurring_interval', (int) $value ); |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
1007 | - * Get the recurring limit. |
|
1008 | - * @since 1.0.19 |
|
1009 | - * @param int $value The recurring limit. |
|
1010 | - * @return int |
|
1011 | - */ |
|
1012 | - public function set_recurring_limit( $value ) { |
|
1007 | + * Get the recurring limit. |
|
1008 | + * @since 1.0.19 |
|
1009 | + * @param int $value The recurring limit. |
|
1010 | + * @return int |
|
1011 | + */ |
|
1012 | + public function set_recurring_limit( $value ) { |
|
1013 | 1013 | $this->set_prop( 'recurring_limit', (int) $value ); |
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
1017 | - * Checks if we have a free trial. |
|
1018 | - * |
|
1019 | - * @since 1.0.19 |
|
1020 | - * @param int|bool $value whether or not it has a free trial. |
|
1021 | - */ |
|
1022 | - public function set_is_free_trial( $value ) { |
|
1017 | + * Checks if we have a free trial. |
|
1018 | + * |
|
1019 | + * @since 1.0.19 |
|
1020 | + * @param int|bool $value whether or not it has a free trial. |
|
1021 | + */ |
|
1022 | + public function set_is_free_trial( $value ) { |
|
1023 | 1023 | $this->set_prop( 'is_free_trial', (int) $value ); |
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
1027 | - * Set the trial period. |
|
1028 | - * |
|
1029 | - * @since 1.0.19 |
|
1030 | - * @param string $value trial period. |
|
1031 | - */ |
|
1032 | - public function set_trial_period( $value ) { |
|
1027 | + * Set the trial period. |
|
1028 | + * |
|
1029 | + * @since 1.0.19 |
|
1030 | + * @param string $value trial period. |
|
1031 | + */ |
|
1032 | + public function set_trial_period( $value ) { |
|
1033 | 1033 | $this->set_prop( 'trial_period', $value ); |
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
1037 | - * Set the trial interval. |
|
1038 | - * |
|
1039 | - * @since 1.0.19 |
|
1040 | - * @param int $value trial interval. |
|
1041 | - */ |
|
1042 | - public function set_trial_interval( $value ) { |
|
1037 | + * Set the trial interval. |
|
1038 | + * |
|
1039 | + * @since 1.0.19 |
|
1040 | + * @param int $value trial interval. |
|
1041 | + */ |
|
1042 | + public function set_trial_interval( $value ) { |
|
1043 | 1043 | $this->set_prop( 'trial_interval', $value ); |
1044 | 1044 | } |
1045 | 1045 | |
@@ -1047,17 +1047,17 @@ discard block |
||
1047 | 1047 | * Create an item. For backwards compatibilty. |
1048 | 1048 | * |
1049 | 1049 | * @deprecated |
1050 | - * @return int item id |
|
1050 | + * @return int item id |
|
1051 | 1051 | */ |
1052 | 1052 | public function create( $data = array() ) { |
1053 | 1053 | |
1054 | - // Set the properties. |
|
1055 | - if ( is_array( $data ) ) { |
|
1056 | - $this->set_props( $data ); |
|
1057 | - } |
|
1054 | + // Set the properties. |
|
1055 | + if ( is_array( $data ) ) { |
|
1056 | + $this->set_props( $data ); |
|
1057 | + } |
|
1058 | 1058 | |
1059 | - // Save the item. |
|
1060 | - return $this->save(); |
|
1059 | + // Save the item. |
|
1060 | + return $this->save(); |
|
1061 | 1061 | |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * Updates an item. For backwards compatibilty. |
1066 | 1066 | * |
1067 | 1067 | * @deprecated |
1068 | - * @return int item id |
|
1068 | + * @return int item id |
|
1069 | 1069 | */ |
1070 | 1070 | public function update( $data = array() ) { |
1071 | 1071 | return $this->create( $data ); |
@@ -1081,93 +1081,93 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | |
1083 | 1083 | /** |
1084 | - * Checks whether the item has enabled dynamic pricing. |
|
1085 | - * |
|
1086 | - * @since 1.0.19 |
|
1087 | - * @return bool |
|
1088 | - */ |
|
1089 | - public function user_can_set_their_price() { |
|
1084 | + * Checks whether the item has enabled dynamic pricing. |
|
1085 | + * |
|
1086 | + * @since 1.0.19 |
|
1087 | + * @return bool |
|
1088 | + */ |
|
1089 | + public function user_can_set_their_price() { |
|
1090 | 1090 | return (bool) $this->get_is_dynamic_pricing(); |
1091 | - } |
|
1091 | + } |
|
1092 | 1092 | |
1093 | - /** |
|
1094 | - * Checks whether the item is recurring. |
|
1095 | - * |
|
1096 | - * @since 1.0.19 |
|
1097 | - * @return bool |
|
1098 | - */ |
|
1099 | - public function is_recurring() { |
|
1093 | + /** |
|
1094 | + * Checks whether the item is recurring. |
|
1095 | + * |
|
1096 | + * @since 1.0.19 |
|
1097 | + * @return bool |
|
1098 | + */ |
|
1099 | + public function is_recurring() { |
|
1100 | 1100 | return (bool) $this->get_is_recurring(); |
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | /** |
1104 | - * Checks whether the item has a free trial. |
|
1105 | - * |
|
1106 | - * @since 1.0.19 |
|
1107 | - * @return bool |
|
1108 | - */ |
|
1104 | + * Checks whether the item has a free trial. |
|
1105 | + * |
|
1106 | + * @since 1.0.19 |
|
1107 | + * @return bool |
|
1108 | + */ |
|
1109 | 1109 | public function has_free_trial() { |
1110 | 1110 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1111 | 1111 | return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | /** |
1115 | - * Checks whether the item is free. |
|
1116 | - * |
|
1117 | - * @since 1.0.19 |
|
1118 | - * @return bool |
|
1119 | - */ |
|
1115 | + * Checks whether the item is free. |
|
1116 | + * |
|
1117 | + * @since 1.0.19 |
|
1118 | + * @return bool |
|
1119 | + */ |
|
1120 | 1120 | public function is_free() { |
1121 | 1121 | $is_free = $this->get_price() == 0; |
1122 | 1122 | return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | /** |
1126 | - * Checks the item status against a passed in status. |
|
1127 | - * |
|
1128 | - * @param array|string $status Status to check. |
|
1129 | - * @return bool |
|
1130 | - */ |
|
1131 | - public function has_status( $status ) { |
|
1132 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1133 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1126 | + * Checks the item status against a passed in status. |
|
1127 | + * |
|
1128 | + * @param array|string $status Status to check. |
|
1129 | + * @return bool |
|
1130 | + */ |
|
1131 | + public function has_status( $status ) { |
|
1132 | + $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1133 | + return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
1137 | - * Checks the item type against a passed in types. |
|
1138 | - * |
|
1139 | - * @param array|string $type Type to check. |
|
1140 | - * @return bool |
|
1141 | - */ |
|
1142 | - public function is_type( $type ) { |
|
1143 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1144 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1145 | - } |
|
1137 | + * Checks the item type against a passed in types. |
|
1138 | + * |
|
1139 | + * @param array|string $type Type to check. |
|
1140 | + * @return bool |
|
1141 | + */ |
|
1142 | + public function is_type( $type ) { |
|
1143 | + $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1144 | + return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1145 | + } |
|
1146 | 1146 | |
1147 | 1147 | /** |
1148 | - * Checks whether the item is editable. |
|
1149 | - * |
|
1150 | - * @since 1.0.19 |
|
1151 | - * @return bool |
|
1152 | - */ |
|
1148 | + * Checks whether the item is editable. |
|
1149 | + * |
|
1150 | + * @since 1.0.19 |
|
1151 | + * @return bool |
|
1152 | + */ |
|
1153 | 1153 | public function is_editable() { |
1154 | 1154 | $is_editable = $this->get_is_editable(); |
1155 | 1155 | return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
1156 | - } |
|
1156 | + } |
|
1157 | 1157 | |
1158 | - /** |
|
1159 | - * Returns an array of cart fees. |
|
1160 | - */ |
|
1161 | - public function get_fees() { |
|
1158 | + /** |
|
1159 | + * Returns an array of cart fees. |
|
1160 | + */ |
|
1161 | + public function get_fees() { |
|
1162 | 1162 | return array(); |
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | /** |
1166 | - * Checks whether the item is purchasable. |
|
1167 | - * |
|
1168 | - * @since 1.0.19 |
|
1169 | - * @return bool |
|
1170 | - */ |
|
1166 | + * Checks whether the item is purchasable. |
|
1167 | + * |
|
1168 | + * @since 1.0.19 |
|
1169 | + * @return bool |
|
1170 | + */ |
|
1171 | 1171 | public function can_purchase() { |
1172 | 1172 | $can_purchase = $this->exists(); |
1173 | 1173 | |
@@ -1179,11 +1179,11 @@ discard block |
||
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | /** |
1182 | - * Checks whether the item supports dynamic pricing. |
|
1183 | - * |
|
1184 | - * @since 1.0.19 |
|
1185 | - * @return bool |
|
1186 | - */ |
|
1182 | + * Checks whether the item supports dynamic pricing. |
|
1183 | + * |
|
1184 | + * @since 1.0.19 |
|
1185 | + * @return bool |
|
1186 | + */ |
|
1187 | 1187 | public function supports_dynamic_pricing() { |
1188 | 1188 | return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
1189 | 1189 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -78,30 +78,30 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param int|object|WPInv_Item|WP_Post $item Item to read. |
80 | 80 | */ |
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | - $this->set_id( $item ); |
|
86 | - } elseif ( $item instanceof self ) { |
|
87 | - $this->set_id( $item->get_id() ); |
|
88 | - } elseif ( ! empty( $item->ID ) ) { |
|
89 | - $this->set_id( $item->ID ); |
|
90 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | - $this->set_id( $item_id ); |
|
92 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | - $this->set_id( $item_id ); |
|
81 | + public function __construct($item = 0) { |
|
82 | + parent::__construct($item); |
|
83 | + |
|
84 | + if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) { |
|
85 | + $this->set_id($item); |
|
86 | + } elseif ($item instanceof self) { |
|
87 | + $this->set_id($item->get_id()); |
|
88 | + } elseif (!empty($item->ID)) { |
|
89 | + $this->set_id($item->ID); |
|
90 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) { |
|
91 | + $this->set_id($item_id); |
|
92 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) { |
|
93 | + $this->set_id($item_id); |
|
94 | 94 | } else { |
95 | - $this->set_object_read( true ); |
|
95 | + $this->set_object_read(true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Load the datastore. |
99 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
99 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
100 | 100 | |
101 | - if ( $this->get_id() > 0 ) { |
|
102 | - $this->post = get_post( $this->get_id() ); |
|
101 | + if ($this->get_id() > 0) { |
|
102 | + $this->post = get_post($this->get_id()); |
|
103 | 103 | $this->ID = $this->get_id(); |
104 | - $this->data_store->read( $this ); |
|
104 | + $this->data_store->read($this); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param string $context View or edit context. |
129 | 129 | * @return int |
130 | 130 | */ |
131 | - public function get_parent_id( $context = 'view' ) { |
|
132 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
131 | + public function get_parent_id($context = 'view') { |
|
132 | + return (int) $this->get_prop('parent_id', $context); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $context View or edit context. |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public function get_status( $context = 'view' ) { |
|
143 | - return $this->get_prop( 'status', $context ); |
|
142 | + public function get_status($context = 'view') { |
|
143 | + return $this->get_prop('status', $context); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string $context View or edit context. |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_version( $context = 'view' ) { |
|
154 | - return $this->get_prop( 'version', $context ); |
|
153 | + public function get_version($context = 'view') { |
|
154 | + return $this->get_prop('version', $context); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param string $context View or edit context. |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function get_date_created( $context = 'view' ) { |
|
165 | - return $this->get_prop( 'date_created', $context ); |
|
164 | + public function get_date_created($context = 'view') { |
|
165 | + return $this->get_prop('date_created', $context); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | * @param string $context View or edit context. |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_date_created_gmt( $context = 'view' ) { |
|
176 | - $date = $this->get_date_created( $context ); |
|
175 | + public function get_date_created_gmt($context = 'view') { |
|
176 | + $date = $this->get_date_created($context); |
|
177 | 177 | |
178 | - if ( $date ) { |
|
179 | - $date = get_gmt_from_date( $date ); |
|
178 | + if ($date) { |
|
179 | + $date = get_gmt_from_date($date); |
|
180 | 180 | } |
181 | 181 | return $date; |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param string $context View or edit context. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function get_date_modified( $context = 'view' ) { |
|
192 | - return $this->get_prop( 'date_modified', $context ); |
|
191 | + public function get_date_modified($context = 'view') { |
|
192 | + return $this->get_prop('date_modified', $context); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
203 | - $date = $this->get_date_modified( $context ); |
|
202 | + public function get_date_modified_gmt($context = 'view') { |
|
203 | + $date = $this->get_date_modified($context); |
|
204 | 204 | |
205 | - if ( $date ) { |
|
206 | - $date = get_gmt_from_date( $date ); |
|
205 | + if ($date) { |
|
206 | + $date = get_gmt_from_date($date); |
|
207 | 207 | } |
208 | 208 | return $date; |
209 | 209 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $context View or edit context. |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function get_name( $context = 'view' ) { |
|
219 | - return $this->get_prop( 'name', $context ); |
|
218 | + public function get_name($context = 'view') { |
|
219 | + return $this->get_prop('name', $context); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $context View or edit context. |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public function get_title( $context = 'view' ) { |
|
230 | - return $this->get_name( $context ); |
|
229 | + public function get_title($context = 'view') { |
|
230 | + return $this->get_name($context); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @param string $context View or edit context. |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public function get_description( $context = 'view' ) { |
|
241 | - return $this->get_prop( 'description', $context ); |
|
240 | + public function get_description($context = 'view') { |
|
241 | + return $this->get_prop('description', $context); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function get_excerpt( $context = 'view' ) { |
|
252 | - return $this->get_description( $context ); |
|
251 | + public function get_excerpt($context = 'view') { |
|
252 | + return $this->get_description($context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @param string $context View or edit context. |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - public function get_summary( $context = 'view' ) { |
|
263 | - return $this->get_description( $context ); |
|
262 | + public function get_summary($context = 'view') { |
|
263 | + return $this->get_description($context); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @param string $context View or edit context. |
271 | 271 | * @return int |
272 | 272 | */ |
273 | - public function get_author( $context = 'view' ) { |
|
274 | - return (int) $this->get_prop( 'author', $context ); |
|
273 | + public function get_author($context = 'view') { |
|
274 | + return (int) $this->get_prop('author', $context); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @param string $context View or edit context. |
282 | 282 | * @return int |
283 | 283 | */ |
284 | - public function get_owner( $context = 'view' ) { |
|
285 | - return $this->get_author( $context ); |
|
284 | + public function get_owner($context = 'view') { |
|
285 | + return $this->get_author($context); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $context View or edit context. |
293 | 293 | * @return float |
294 | 294 | */ |
295 | - public function get_price( $context = 'view' ) { |
|
296 | - return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
|
295 | + public function get_price($context = 'view') { |
|
296 | + return wpinv_sanitize_amount($this->get_prop('price', $context)); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | * @param string $context View or edit context. |
304 | 304 | * @return float |
305 | 305 | */ |
306 | - public function get_initial_price( $context = 'view' ) { |
|
306 | + public function get_initial_price($context = 'view') { |
|
307 | 307 | |
308 | - $price = (float) $this->get_price( $context ); |
|
308 | + $price = (float) $this->get_price($context); |
|
309 | 309 | |
310 | - if ( $this->has_free_trial() ) { |
|
310 | + if ($this->has_free_trial()) { |
|
311 | 311 | $price = 0; |
312 | 312 | } |
313 | 313 | |
314 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
|
314 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return string |
323 | 323 | */ |
324 | 324 | public function get_the_price() { |
325 | - return wpinv_price( $this->get_price() ); |
|
325 | + return wpinv_price($this->get_price()); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return string |
334 | 334 | */ |
335 | 335 | public function get_the_initial_price() { |
336 | - return wpinv_price( $this->get_initial_price() ); |
|
336 | + return wpinv_price($this->get_initial_price()); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * @param string $context View or edit context. |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public function get_vat_rule( $context = 'view' ) { |
|
347 | - return $this->get_prop( 'vat_rule', $context ); |
|
346 | + public function get_vat_rule($context = 'view') { |
|
347 | + return $this->get_prop('vat_rule', $context); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $context View or edit context. |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public function get_vat_class( $context = 'view' ) { |
|
358 | - return $this->get_prop( 'vat_class', $context ); |
|
357 | + public function get_vat_class($context = 'view') { |
|
358 | + return $this->get_prop('vat_class', $context); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $context View or edit context. |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function get_type( $context = 'view' ) { |
|
369 | - return $this->get_prop( 'type', $context ); |
|
368 | + public function get_type($context = 'view') { |
|
369 | + return $this->get_prop('type', $context); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_custom_id( $context = 'view' ) { |
|
380 | - return $this->get_prop( 'custom_id', $context ); |
|
379 | + public function get_custom_id($context = 'view') { |
|
380 | + return $this->get_prop('custom_id', $context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_custom_name( $context = 'view' ) { |
|
391 | - return $this->get_prop( 'custom_name', $context ); |
|
390 | + public function get_custom_name($context = 'view') { |
|
391 | + return $this->get_prop('custom_name', $context); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * @param string $context View or edit context. |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function get_custom_singular_name( $context = 'view' ) { |
|
402 | - return $this->get_prop( 'custom_singular_name', $context ); |
|
401 | + public function get_custom_singular_name($context = 'view') { |
|
402 | + return $this->get_prop('custom_singular_name', $context); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * @param string $context View or edit context. |
410 | 410 | * @return int |
411 | 411 | */ |
412 | - public function get_is_editable( $context = 'view' ) { |
|
413 | - return (int) $this->get_prop( 'is_editable', $context ); |
|
412 | + public function get_is_editable($context = 'view') { |
|
413 | + return (int) $this->get_prop('is_editable', $context); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * @param string $context View or edit context. |
421 | 421 | * @return int |
422 | 422 | */ |
423 | - public function get_editable( $context = 'view' ) { |
|
424 | - return $this->get_is_editable( $context ); |
|
423 | + public function get_editable($context = 'view') { |
|
424 | + return $this->get_is_editable($context); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return int |
433 | 433 | */ |
434 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
435 | - return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
|
434 | + public function get_is_dynamic_pricing($context = 'view') { |
|
435 | + return (int) $this->get_prop('is_dynamic_pricing', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return float |
444 | 444 | */ |
445 | - public function get_minimum_price( $context = 'view' ) { |
|
446 | - return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
|
445 | + public function get_minimum_price($context = 'view') { |
|
446 | + return wpinv_sanitize_amount($this->get_prop('minimum_price', $context)); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return int |
455 | 455 | */ |
456 | - public function get_is_recurring( $context = 'view' ) { |
|
457 | - return (int) $this->get_prop( 'is_recurring', $context ); |
|
456 | + public function get_is_recurring($context = 'view') { |
|
457 | + return (int) $this->get_prop('is_recurring', $context); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | * @param string $context View or edit context. |
465 | 465 | * @return float |
466 | 466 | */ |
467 | - public function get_recurring_price( $context = 'view' ) { |
|
468 | - $price = $this->get_price( $context ); |
|
469 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
|
467 | + public function get_recurring_price($context = 'view') { |
|
468 | + $price = $this->get_price($context); |
|
469 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID)); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return string |
478 | 478 | */ |
479 | 479 | public function get_the_recurring_price() { |
480 | - return wpinv_price( $this->get_recurring_price() ); |
|
480 | + return wpinv_price($this->get_recurring_price()); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | $period = $this->get_recurring_period(); |
499 | 499 | $interval = $this->get_recurring_interval(); |
500 | 500 | |
501 | - if ( $this->has_free_trial() ) { |
|
501 | + if ($this->has_free_trial()) { |
|
502 | 502 | $period = $this->get_trial_period(); |
503 | 503 | $interval = $this->get_trial_interval(); |
504 | 504 | } |
505 | 505 | |
506 | - $period = $periods[ $period ]; |
|
507 | - $interval = empty( $interval ) ? 1 : $interval; |
|
508 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
509 | - return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
|
506 | + $period = $periods[$period]; |
|
507 | + $interval = empty($interval) ? 1 : $interval; |
|
508 | + $next_renewal = strtotime("+$interval $period", current_time('timestamp')); |
|
509 | + return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -516,14 +516,14 @@ discard block |
||
516 | 516 | * @param bool $full Return abbreviation or in full. |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - public function get_recurring_period( $full = false ) { |
|
520 | - $period = $this->get_prop( 'recurring_period', 'view' ); |
|
519 | + public function get_recurring_period($full = false) { |
|
520 | + $period = $this->get_prop('recurring_period', 'view'); |
|
521 | 521 | |
522 | - if ( $full && ! is_bool( $full ) ) { |
|
522 | + if ($full && !is_bool($full)) { |
|
523 | 523 | $full = false; |
524 | 524 | } |
525 | 525 | |
526 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
526 | + return getpaid_sanitize_recurring_period($period, $full); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -533,9 +533,9 @@ discard block |
||
533 | 533 | * @param string $context View or edit context. |
534 | 534 | * @return int |
535 | 535 | */ |
536 | - public function get_recurring_interval( $context = 'view' ) { |
|
537 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
538 | - return max( 1, $interval ); |
|
536 | + public function get_recurring_interval($context = 'view') { |
|
537 | + $interval = absint($this->get_prop('recurring_interval', $context)); |
|
538 | + return max(1, $interval); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
@@ -545,8 +545,8 @@ discard block |
||
545 | 545 | * @param string $context View or edit context. |
546 | 546 | * @return int |
547 | 547 | */ |
548 | - public function get_recurring_limit( $context = 'view' ) { |
|
549 | - return (int) $this->get_prop( 'recurring_limit', $context ); |
|
548 | + public function get_recurring_limit($context = 'view') { |
|
549 | + return (int) $this->get_prop('recurring_limit', $context); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | * @param string $context View or edit context. |
557 | 557 | * @return int |
558 | 558 | */ |
559 | - public function get_is_free_trial( $context = 'view' ) { |
|
560 | - return (int) $this->get_prop( 'is_free_trial', $context ); |
|
559 | + public function get_is_free_trial($context = 'view') { |
|
560 | + return (int) $this->get_prop('is_free_trial', $context); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -567,8 +567,8 @@ discard block |
||
567 | 567 | * @param string $context View or edit context. |
568 | 568 | * @return int |
569 | 569 | */ |
570 | - public function get_free_trial( $context = 'view' ) { |
|
571 | - return $this->get_is_free_trial( $context ); |
|
570 | + public function get_free_trial($context = 'view') { |
|
571 | + return $this->get_is_free_trial($context); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | * @param bool $full Return abbreviation or in full. |
579 | 579 | * @return string |
580 | 580 | */ |
581 | - public function get_trial_period( $full = false ) { |
|
582 | - $period = $this->get_prop( 'trial_period', 'view' ); |
|
581 | + public function get_trial_period($full = false) { |
|
582 | + $period = $this->get_prop('trial_period', 'view'); |
|
583 | 583 | |
584 | - if ( $full && ! is_bool( $full ) ) { |
|
584 | + if ($full && !is_bool($full)) { |
|
585 | 585 | $full = false; |
586 | 586 | } |
587 | 587 | |
588 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
588 | + return getpaid_sanitize_recurring_period($period, $full); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | * @param string $context View or edit context. |
596 | 596 | * @return int |
597 | 597 | */ |
598 | - public function get_trial_interval( $context = 'view' ) { |
|
599 | - return (int) $this->get_prop( 'trial_interval', $context ); |
|
598 | + public function get_trial_interval($context = 'view') { |
|
599 | + return (int) $this->get_prop('trial_interval', $context); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @return string |
607 | 607 | */ |
608 | 608 | public function get_edit_url() { |
609 | - return get_edit_post_link( $this->get_id(), 'edit' ); |
|
609 | + return get_edit_post_link($this->get_id(), 'edit'); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -620,35 +620,35 @@ discard block |
||
620 | 620 | * @since 1.0.15 |
621 | 621 | * @return int |
622 | 622 | */ |
623 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
623 | + public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') { |
|
624 | 624 | |
625 | 625 | // Trim the value. |
626 | - $value = sanitize_text_field( $value ); |
|
627 | - if ( empty( $value ) ) { |
|
626 | + $value = sanitize_text_field($value); |
|
627 | + if (empty($value)) { |
|
628 | 628 | return 0; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Valid fields. |
632 | - $fields = array( 'custom_id', 'name', 'slug' ); |
|
632 | + $fields = array('custom_id', 'name', 'slug'); |
|
633 | 633 | |
634 | 634 | // Ensure a field has been passed. |
635 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
635 | + if (empty($field) || !in_array($field, $fields)) { |
|
636 | 636 | return 0; |
637 | 637 | } |
638 | 638 | |
639 | - if ( $field == 'name' ) { |
|
639 | + if ($field == 'name') { |
|
640 | 640 | $field = 'slug'; |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Maybe retrieve from the cache. |
644 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
645 | - if ( ! empty( $item_id ) ) { |
|
644 | + $item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
645 | + if (!empty($item_id)) { |
|
646 | 646 | return $item_id; |
647 | 647 | } |
648 | 648 | |
649 | 649 | // Fetch from the db. |
650 | 650 | $items = array(); |
651 | - if ( $field == 'slug' ) { |
|
651 | + if ($field == 'slug') { |
|
652 | 652 | $items = get_posts( |
653 | 653 | array( |
654 | 654 | 'post_type' => 'wpi_item', |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | ); |
660 | 660 | } |
661 | 661 | |
662 | - if ( $field =='custom_id' ) { |
|
662 | + if ($field == 'custom_id') { |
|
663 | 663 | $items = get_posts( |
664 | 664 | array( |
665 | 665 | 'post_type' => 'wpi_item', |
@@ -679,12 +679,12 @@ discard block |
||
679 | 679 | ); |
680 | 680 | } |
681 | 681 | |
682 | - if ( empty( $items ) ) { |
|
682 | + if (empty($items)) { |
|
683 | 683 | return 0; |
684 | 684 | } |
685 | 685 | |
686 | 686 | // Update the cache with our data |
687 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
687 | + wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
688 | 688 | |
689 | 689 | return $items[0]->ID; |
690 | 690 | } |
@@ -692,19 +692,19 @@ discard block |
||
692 | 692 | /** |
693 | 693 | * Margic method for retrieving a property. |
694 | 694 | */ |
695 | - public function __get( $key ) { |
|
695 | + public function __get($key) { |
|
696 | 696 | |
697 | 697 | // Check if we have a helper method for that. |
698 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
699 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
698 | + if (method_exists($this, 'get_' . $key)) { |
|
699 | + return call_user_func(array($this, 'get_' . $key)); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | // Check if the key is in the associated $post object. |
703 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
703 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
704 | 704 | return $this->post->$key; |
705 | 705 | } |
706 | 706 | |
707 | - return $this->get_prop( $key ); |
|
707 | + return $this->get_prop($key); |
|
708 | 708 | |
709 | 709 | } |
710 | 710 | |
@@ -723,11 +723,11 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @since 1.0.19 |
725 | 725 | */ |
726 | - public function set_parent_id( $value ) { |
|
727 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
726 | + public function set_parent_id($value) { |
|
727 | + if ($value && ($value === $this->get_id() || !get_post($value))) { |
|
728 | 728 | return; |
729 | 729 | } |
730 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
730 | + $this->set_prop('parent_id', absint($value)); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | * @param string $status New status. |
738 | 738 | * @return array details of change. |
739 | 739 | */ |
740 | - public function set_status( $status ) { |
|
740 | + public function set_status($status) { |
|
741 | 741 | $old_status = $this->get_status(); |
742 | 742 | |
743 | - $this->set_prop( 'status', $status ); |
|
743 | + $this->set_prop('status', $status); |
|
744 | 744 | |
745 | 745 | return array( |
746 | 746 | 'from' => $old_status, |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @since 1.0.19 |
755 | 755 | */ |
756 | - public function set_version( $value ) { |
|
757 | - $this->set_prop( 'version', $value ); |
|
756 | + public function set_version($value) { |
|
757 | + $this->set_prop('version', $value); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
@@ -764,11 +764,11 @@ discard block |
||
764 | 764 | * @param string $value Value to set. |
765 | 765 | * @return bool Whether or not the date was set. |
766 | 766 | */ |
767 | - public function set_date_created( $value ) { |
|
768 | - $date = strtotime( $value ); |
|
767 | + public function set_date_created($value) { |
|
768 | + $date = strtotime($value); |
|
769 | 769 | |
770 | - if ( $date ) { |
|
771 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
770 | + if ($date) { |
|
771 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
772 | 772 | return true; |
773 | 773 | } |
774 | 774 | |
@@ -783,11 +783,11 @@ discard block |
||
783 | 783 | * @param string $value Value to set. |
784 | 784 | * @return bool Whether or not the date was set. |
785 | 785 | */ |
786 | - public function set_date_modified( $value ) { |
|
787 | - $date = strtotime( $value ); |
|
786 | + public function set_date_modified($value) { |
|
787 | + $date = strtotime($value); |
|
788 | 788 | |
789 | - if ( $date ) { |
|
790 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
789 | + if ($date) { |
|
790 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
791 | 791 | return true; |
792 | 792 | } |
793 | 793 | |
@@ -801,9 +801,9 @@ discard block |
||
801 | 801 | * @since 1.0.19 |
802 | 802 | * @param string $value New name. |
803 | 803 | */ |
804 | - public function set_name( $value ) { |
|
805 | - $name = sanitize_text_field( $value ); |
|
806 | - $this->set_prop( 'name', $name ); |
|
804 | + public function set_name($value) { |
|
805 | + $name = sanitize_text_field($value); |
|
806 | + $this->set_prop('name', $name); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | * @since 1.0.19 |
813 | 813 | * @param string $value New name. |
814 | 814 | */ |
815 | - public function set_title( $value ) { |
|
816 | - $this->set_name( $value ); |
|
815 | + public function set_title($value) { |
|
816 | + $this->set_name($value); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
@@ -822,9 +822,9 @@ discard block |
||
822 | 822 | * @since 1.0.19 |
823 | 823 | * @param string $value New description. |
824 | 824 | */ |
825 | - public function set_description( $value ) { |
|
826 | - $description = wp_kses_post( $value ); |
|
827 | - return $this->set_prop( 'description', $description ); |
|
825 | + public function set_description($value) { |
|
826 | + $description = wp_kses_post($value); |
|
827 | + return $this->set_prop('description', $description); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | * @since 1.0.19 |
834 | 834 | * @param string $value New description. |
835 | 835 | */ |
836 | - public function set_excerpt( $value ) { |
|
837 | - $this->set_description( $value ); |
|
836 | + public function set_excerpt($value) { |
|
837 | + $this->set_description($value); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -843,8 +843,8 @@ discard block |
||
843 | 843 | * @since 1.0.19 |
844 | 844 | * @param string $value New description. |
845 | 845 | */ |
846 | - public function set_summary( $value ) { |
|
847 | - $this->set_description( $value ); |
|
846 | + public function set_summary($value) { |
|
847 | + $this->set_description($value); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
@@ -853,8 +853,8 @@ discard block |
||
853 | 853 | * @since 1.0.19 |
854 | 854 | * @param int $value New author. |
855 | 855 | */ |
856 | - public function set_author( $value ) { |
|
857 | - $this->set_prop( 'author', (int) $value ); |
|
856 | + public function set_author($value) { |
|
857 | + $this->set_prop('author', (int) $value); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * @since 1.0.19 |
864 | 864 | * @param int $value New author. |
865 | 865 | */ |
866 | - public function set_owner( $value ) { |
|
867 | - $this->set_author( $value ); |
|
866 | + public function set_owner($value) { |
|
867 | + $this->set_author($value); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -873,8 +873,8 @@ discard block |
||
873 | 873 | * @since 1.0.19 |
874 | 874 | * @param float $value New price. |
875 | 875 | */ |
876 | - public function set_price( $value ) { |
|
877 | - $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
|
876 | + public function set_price($value) { |
|
877 | + $this->set_prop('price', (float) wpinv_sanitize_amount($value)); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
@@ -883,8 +883,8 @@ discard block |
||
883 | 883 | * @since 1.0.19 |
884 | 884 | * @param string $value new rule. |
885 | 885 | */ |
886 | - public function set_vat_rule( $value ) { |
|
887 | - $this->set_prop( 'vat_rule', $value ); |
|
886 | + public function set_vat_rule($value) { |
|
887 | + $this->set_prop('vat_rule', $value); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -893,8 +893,8 @@ discard block |
||
893 | 893 | * @since 1.0.19 |
894 | 894 | * @param string $value new class. |
895 | 895 | */ |
896 | - public function set_vat_class( $value ) { |
|
897 | - $this->set_prop( 'vat_class', $value ); |
|
896 | + public function set_vat_class($value) { |
|
897 | + $this->set_prop('vat_class', $value); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
@@ -904,13 +904,13 @@ discard block |
||
904 | 904 | * @param string $value new item type. |
905 | 905 | * @return string |
906 | 906 | */ |
907 | - public function set_type( $value ) { |
|
907 | + public function set_type($value) { |
|
908 | 908 | |
909 | - if ( empty( $value ) ) { |
|
909 | + if (empty($value)) { |
|
910 | 910 | $value = 'custom'; |
911 | 911 | } |
912 | 912 | |
913 | - $this->set_prop( 'type', $value ); |
|
913 | + $this->set_prop('type', $value); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
@@ -919,8 +919,8 @@ discard block |
||
919 | 919 | * @since 1.0.19 |
920 | 920 | * @param string $value new custom id. |
921 | 921 | */ |
922 | - public function set_custom_id( $value ) { |
|
923 | - $this->set_prop( 'custom_id', $value ); |
|
922 | + public function set_custom_id($value) { |
|
923 | + $this->set_prop('custom_id', $value); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -929,8 +929,8 @@ discard block |
||
929 | 929 | * @since 1.0.19 |
930 | 930 | * @param string $value new custom name. |
931 | 931 | */ |
932 | - public function set_custom_name( $value ) { |
|
933 | - $this->set_prop( 'custom_name', $value ); |
|
932 | + public function set_custom_name($value) { |
|
933 | + $this->set_prop('custom_name', $value); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | * @since 1.0.19 |
940 | 940 | * @param string $value new custom singular name. |
941 | 941 | */ |
942 | - public function set_custom_singular_name( $value ) { |
|
943 | - $this->set_prop( 'custom_singular_name', $value ); |
|
942 | + public function set_custom_singular_name($value) { |
|
943 | + $this->set_prop('custom_singular_name', $value); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
@@ -949,8 +949,8 @@ discard block |
||
949 | 949 | * @since 1.0.19 |
950 | 950 | * @param int|bool $value whether or not the item is editable. |
951 | 951 | */ |
952 | - public function set_is_editable( $value ) { |
|
953 | - $this->set_prop( 'is_editable', (int) $value ); |
|
952 | + public function set_is_editable($value) { |
|
953 | + $this->set_prop('is_editable', (int) $value); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | * @since 1.0.19 |
960 | 960 | * @param int|bool $value whether or not dynamic pricing is allowed. |
961 | 961 | */ |
962 | - public function set_is_dynamic_pricing( $value ) { |
|
963 | - $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
|
962 | + public function set_is_dynamic_pricing($value) { |
|
963 | + $this->set_prop('is_dynamic_pricing', (int) $value); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -969,8 +969,8 @@ discard block |
||
969 | 969 | * @since 1.0.19 |
970 | 970 | * @param float $value minimum price. |
971 | 971 | */ |
972 | - public function set_minimum_price( $value ) { |
|
973 | - $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
|
972 | + public function set_minimum_price($value) { |
|
973 | + $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value)); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -979,8 +979,8 @@ discard block |
||
979 | 979 | * @since 1.0.19 |
980 | 980 | * @param int|bool $value whether or not dynamic pricing is allowed. |
981 | 981 | */ |
982 | - public function set_is_recurring( $value ) { |
|
983 | - $this->set_prop( 'is_recurring', (int) $value ); |
|
982 | + public function set_is_recurring($value) { |
|
983 | + $this->set_prop('is_recurring', (int) $value); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | * @since 1.0.19 |
990 | 990 | * @param string $value new period. |
991 | 991 | */ |
992 | - public function set_recurring_period( $value ) { |
|
993 | - $this->set_prop( 'recurring_period', $value ); |
|
992 | + public function set_recurring_period($value) { |
|
993 | + $this->set_prop('recurring_period', $value); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | * @since 1.0.19 |
1000 | 1000 | * @param int $value recurring interval. |
1001 | 1001 | */ |
1002 | - public function set_recurring_interval( $value ) { |
|
1003 | - return $this->set_prop( 'recurring_interval', (int) $value ); |
|
1002 | + public function set_recurring_interval($value) { |
|
1003 | + return $this->set_prop('recurring_interval', (int) $value); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | * @param int $value The recurring limit. |
1010 | 1010 | * @return int |
1011 | 1011 | */ |
1012 | - public function set_recurring_limit( $value ) { |
|
1013 | - $this->set_prop( 'recurring_limit', (int) $value ); |
|
1012 | + public function set_recurring_limit($value) { |
|
1013 | + $this->set_prop('recurring_limit', (int) $value); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1019,8 +1019,8 @@ discard block |
||
1019 | 1019 | * @since 1.0.19 |
1020 | 1020 | * @param int|bool $value whether or not it has a free trial. |
1021 | 1021 | */ |
1022 | - public function set_is_free_trial( $value ) { |
|
1023 | - $this->set_prop( 'is_free_trial', (int) $value ); |
|
1022 | + public function set_is_free_trial($value) { |
|
1023 | + $this->set_prop('is_free_trial', (int) $value); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @since 1.0.19 |
1030 | 1030 | * @param string $value trial period. |
1031 | 1031 | */ |
1032 | - public function set_trial_period( $value ) { |
|
1033 | - $this->set_prop( 'trial_period', $value ); |
|
1032 | + public function set_trial_period($value) { |
|
1033 | + $this->set_prop('trial_period', $value); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1039,8 +1039,8 @@ discard block |
||
1039 | 1039 | * @since 1.0.19 |
1040 | 1040 | * @param int $value trial interval. |
1041 | 1041 | */ |
1042 | - public function set_trial_interval( $value ) { |
|
1043 | - $this->set_prop( 'trial_interval', $value ); |
|
1042 | + public function set_trial_interval($value) { |
|
1043 | + $this->set_prop('trial_interval', $value); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | /** |
@@ -1049,11 +1049,11 @@ discard block |
||
1049 | 1049 | * @deprecated |
1050 | 1050 | * @return int item id |
1051 | 1051 | */ |
1052 | - public function create( $data = array() ) { |
|
1052 | + public function create($data = array()) { |
|
1053 | 1053 | |
1054 | 1054 | // Set the properties. |
1055 | - if ( is_array( $data ) ) { |
|
1056 | - $this->set_props( $data ); |
|
1055 | + if (is_array($data)) { |
|
1056 | + $this->set_props($data); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | // Save the item. |
@@ -1067,8 +1067,8 @@ discard block |
||
1067 | 1067 | * @deprecated |
1068 | 1068 | * @return int item id |
1069 | 1069 | */ |
1070 | - public function update( $data = array() ) { |
|
1071 | - return $this->create( $data ); |
|
1070 | + public function update($data = array()) { |
|
1071 | + return $this->create($data); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | /* |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | */ |
1109 | 1109 | public function has_free_trial() { |
1110 | 1110 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1111 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
1111 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | /** |
@@ -1118,8 +1118,8 @@ discard block |
||
1118 | 1118 | * @return bool |
1119 | 1119 | */ |
1120 | 1120 | public function is_free() { |
1121 | - $is_free = $this->get_price() == 0; |
|
1122 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
1121 | + $is_free = $this->get_price() == 0; |
|
1122 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | /** |
@@ -1128,9 +1128,9 @@ discard block |
||
1128 | 1128 | * @param array|string $status Status to check. |
1129 | 1129 | * @return bool |
1130 | 1130 | */ |
1131 | - public function has_status( $status ) { |
|
1132 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1133 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1131 | + public function has_status($status) { |
|
1132 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
1133 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1139,9 +1139,9 @@ discard block |
||
1139 | 1139 | * @param array|string $type Type to check. |
1140 | 1140 | * @return bool |
1141 | 1141 | */ |
1142 | - public function is_type( $type ) { |
|
1143 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1144 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1142 | + public function is_type($type) { |
|
1143 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
1144 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function is_editable() { |
1154 | 1154 | $is_editable = $this->get_is_editable(); |
1155 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
1155 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | /** |
@@ -1171,11 +1171,11 @@ discard block |
||
1171 | 1171 | public function can_purchase() { |
1172 | 1172 | $can_purchase = $this->exists(); |
1173 | 1173 | |
1174 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1174 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1175 | 1175 | $can_purchase = false; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1178 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | /** |
@@ -1185,6 +1185,6 @@ discard block |
||
1185 | 1185 | * @return bool |
1186 | 1186 | */ |
1187 | 1187 | public function supports_dynamic_pricing() { |
1188 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1188 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1189 | 1189 | } |
1190 | 1190 | } |
@@ -7,64 +7,64 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | +$invoice = new WPInv_Invoice($invoice); |
|
14 | 14 | |
15 | 15 | // @deprecated |
16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
16 | +do_action('wpinv_success_content_before', $invoice); |
|
17 | +do_action('wpinv_before_receipt', $invoice); |
|
18 | 18 | |
19 | 19 | wpinv_print_errors(); |
20 | 20 | |
21 | 21 | // Prepare header text. |
22 | -if ( $invoice->is_paid() ) { |
|
22 | +if ($invoice->is_paid()) { |
|
23 | 23 | |
24 | 24 | $alert = aui()->alert( |
25 | 25 | array( |
26 | 26 | 'type' => 'success', |
27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
28 | 28 | ) |
29 | 29 | ); |
30 | 30 | |
31 | -} else if ( $invoice->is_refunded() ) { |
|
31 | +} else if ($invoice->is_refunded()) { |
|
32 | 32 | |
33 | 33 | $alert = aui()->alert( |
34 | 34 | array( |
35 | 35 | 'type' => 'info', |
36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | -} else if ( $invoice->is_held() ) { |
|
40 | +} else if ($invoice->is_held()) { |
|
41 | 41 | |
42 | 42 | $alert = aui()->alert( |
43 | 43 | array( |
44 | 44 | 'type' => 'info', |
45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | -} else if ( $invoice->needs_payment() ) { |
|
49 | +} else if ($invoice->needs_payment()) { |
|
50 | 50 | |
51 | - if ( ! empty( $_GET['token'] ) ) { |
|
51 | + if (!empty($_GET['token'])) { |
|
52 | 52 | |
53 | 53 | $alert = aui()->alert( |
54 | 54 | array( |
55 | 55 | 'type' => 'info', |
56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - } else if ( $invoice->is_due() ) { |
|
60 | + } else if ($invoice->is_due()) { |
|
61 | 61 | |
62 | 62 | $alert = aui()->alert( |
63 | 63 | array( |
64 | 64 | 'type' => 'danger', |
65 | 65 | 'content' => sprintf( |
66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
66 | + __('This invoice was due on %.', 'invoicing'), |
|
67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
68 | 68 | ), |
69 | 69 | ) |
70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $alert = aui()->alert( |
75 | 75 | array( |
76 | 76 | 'type' => 'warning', |
77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | |
90 | 90 | 'pay' => array( |
91 | 91 | 'url' => $invoice->get_checkout_payment_url(), |
92 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
92 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
93 | 93 | 'class' => 'btn-success', |
94 | 94 | ), |
95 | 95 | |
96 | 96 | 'view' => array( |
97 | 97 | 'url' => $invoice->get_view_url(), |
98 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
98 | + 'name' => __('View Invoice', 'invoicing'), |
|
99 | 99 | 'class' => 'btn-primary', |
100 | 100 | ), |
101 | 101 | |
102 | 102 | 'history' => array( |
103 | 103 | 'url' => wpinv_get_history_page_uri(), |
104 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
104 | + 'name' => __('Invoice History', 'invoicing'), |
|
105 | 105 | 'class' => 'btn-warning', |
106 | 106 | ), |
107 | 107 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | |
111 | 111 | ); |
112 | 112 | |
113 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) { |
|
114 | - unset( $actions['pay'] ); |
|
113 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) { |
|
114 | + unset($actions['pay']); |
|
115 | 115 | } |
116 | 116 | |
117 | -if ( ! is_user_logged_in() && isset( $actions['history'] ) ) { |
|
118 | - unset( $actions['history'] ); |
|
117 | +if (!is_user_logged_in() && isset($actions['history'])) { |
|
118 | + unset($actions['history']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | ?> |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | |
125 | 125 | <?php |
126 | 126 | |
127 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
127 | + do_action('wpinv_receipt_start', $invoice); |
|
128 | 128 | |
129 | - if ( ! empty( $actions ) ) { |
|
129 | + if (!empty($actions)) { |
|
130 | 130 | |
131 | 131 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
132 | 132 | |
133 | - foreach ( $actions as $key => $action ) { |
|
133 | + foreach ($actions as $key => $action) { |
|
134 | 134 | |
135 | - $key = sanitize_html_class( $key ); |
|
136 | - $class = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] ); |
|
137 | - $url = empty( $action['url'] ) ? '#' : esc_url( $action['url'] ); |
|
138 | - $attrs = empty( $action['attrs'] ) ? '' : $action['attrs']; |
|
139 | - $anchor = sanitize_text_field( $action['name'] ); |
|
135 | + $key = sanitize_html_class($key); |
|
136 | + $class = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']); |
|
137 | + $url = empty($action['url']) ? '#' : esc_url($action['url']); |
|
138 | + $attrs = empty($action['attrs']) ? '' : $action['attrs']; |
|
139 | + $anchor = sanitize_text_field($action['name']); |
|
140 | 140 | |
141 | 141 | echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"; |
142 | 142 | } |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | <div class="wpinv-receipt-details"> |
153 | 153 | |
154 | 154 | <h4 class="wpinv-details-t mb-3 mt-3"> |
155 | - <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?> |
|
155 | + <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?> |
|
156 | 156 | </h4> |
157 | 157 | |
158 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
158 | + <?php getpaid_invoice_meta($invoice); ?> |
|
159 | 159 | |
160 | 160 | </div> |
161 | 161 | |
162 | - <?php echo getpaid_display_invoice_subscriptions( $invoice ); ?> |
|
162 | + <?php echo getpaid_display_invoice_subscriptions($invoice); ?> |
|
163 | 163 | |
164 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
164 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
165 | 165 | |
166 | 166 | </div> |
167 | 167 | |
168 | 168 | <?php |
169 | 169 | |
170 | 170 | // @deprecated |
171 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
172 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
171 | +do_action('wpinv_success_content_after', $invoice); |
|
172 | +do_action('wpinv_after_receipt', $invoice); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | <?php |
5 | 5 | echo |
6 | 6 | wp_sprintf( |
7 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
8 | - esc_url_raw( remove_query_arg( 'payment-confirm' ) ) |
|
7 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
8 | + esc_url_raw(remove_query_arg('payment-confirm')) |
|
9 | 9 | ); |
10 | 10 | ?> |
11 | 11 | <i class="fa fa-spin fa-refresh"></i> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | <script type="text/javascript"> |
15 | 15 | setTimeout( |
16 | 16 | function(){ |
17 | - window.location.href = '<?php echo esc_url_raw( remove_query_arg( 'payment-confirm' ) ) ;?>'; |
|
17 | + window.location.href = '<?php echo esc_url_raw(remove_query_arg('payment-confirm')); ?>'; |
|
18 | 18 | }, |
19 | 19 | 10000 |
20 | 20 | ); |
@@ -12,276 +12,276 @@ |
||
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; |
|
21 | - |
|
22 | 15 | /** |
23 | - * Hook in methods. |
|
24 | - */ |
|
25 | - public static function init() { |
|
26 | - |
|
27 | - // Register metaboxes. |
|
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
29 | - |
|
30 | - // Remove metaboxes. |
|
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
32 | - |
|
33 | - // Rename metaboxes. |
|
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
35 | - |
|
36 | - // Save metaboxes. |
|
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Register core metaboxes. |
|
42 | - */ |
|
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
16 | + * Only save metaboxes once. |
|
17 | + * |
|
18 | + * @var boolean |
|
19 | + */ |
|
20 | + private static $saved_meta_boxes = false; |
|
44 | 21 | |
45 | - // For invoices... |
|
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
47 | - |
|
48 | - // For payment forms. |
|
49 | - self::add_payment_form_meta_boxes( $post_type ); |
|
50 | - |
|
51 | - // For invoice items. |
|
52 | - self::add_item_meta_boxes( $post_type ); |
|
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 | - } |
|
58 | - |
|
59 | - } |
|
22 | + /** |
|
23 | + * Hook in methods. |
|
24 | + */ |
|
25 | + public static function init() { |
|
60 | 26 | |
61 | - /** |
|
62 | - * Register core metaboxes. |
|
63 | - */ |
|
64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
27 | + // Register metaboxes. |
|
28 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
65 | 29 | |
66 | - // For payment forms. |
|
67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
30 | + // Remove metaboxes. |
|
31 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
68 | 32 | |
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' ); |
|
33 | + // Rename metaboxes. |
|
34 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
71 | 35 | |
72 | - // Payment form information. |
|
73 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
36 | + // Save metaboxes. |
|
37 | + add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | + } |
|
74 | 39 | |
75 | - } |
|
40 | + /** |
|
41 | + * Register core metaboxes. |
|
42 | + */ |
|
43 | + public static function add_meta_boxes( $post_type, $post ) { |
|
76 | 44 | |
77 | - } |
|
45 | + // For invoices... |
|
46 | + self::add_invoice_meta_boxes( $post_type, $post ); |
|
78 | 47 | |
79 | - /** |
|
80 | - * Register core metaboxes. |
|
81 | - */ |
|
82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
48 | + // For payment forms. |
|
49 | + self::add_payment_form_meta_boxes( $post_type ); |
|
83 | 50 | |
84 | - if ( $post_type == 'wpi_item' ) { |
|
51 | + // For invoice items. |
|
52 | + self::add_item_meta_boxes( $post_type ); |
|
85 | 53 | |
86 | - // Item details. |
|
87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
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 | + } |
|
88 | 58 | |
89 | - // If taxes are enabled, register the tax metabox. |
|
90 | - if ( wpinv_use_taxes() ) { |
|
91 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
92 | - } |
|
59 | + } |
|
93 | 60 | |
94 | - // Item info. |
|
95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
61 | + /** |
|
62 | + * Register core metaboxes. |
|
63 | + */ |
|
64 | + protected static function add_payment_form_meta_boxes( $post_type ) { |
|
96 | 65 | |
97 | - } |
|
66 | + // For payment forms. |
|
67 | + if ( $post_type == 'wpi_payment_form' ) { |
|
98 | 68 | |
99 | - } |
|
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' ); |
|
100 | 71 | |
101 | - /** |
|
102 | - * Register invoice metaboxes. |
|
103 | - */ |
|
104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
72 | + // Payment form information. |
|
73 | + add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
105 | 74 | |
106 | - // For invoices... |
|
107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | - $invoice = new WPInv_Invoice( $post ); |
|
75 | + } |
|
109 | 76 | |
110 | - // Resend invoice. |
|
111 | - if ( ! $invoice->is_draft() ) { |
|
77 | + } |
|
112 | 78 | |
113 | - add_meta_box( |
|
114 | - 'wpinv-mb-resend-invoice', |
|
115 | - sprintf( |
|
116 | - __( 'Resend %s', 'invoicing' ), |
|
117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
118 | - ), |
|
119 | - 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
120 | - $post_type, |
|
121 | - 'side', |
|
122 | - 'low' |
|
123 | - ); |
|
79 | + /** |
|
80 | + * Register core metaboxes. |
|
81 | + */ |
|
82 | + protected static function add_item_meta_boxes( $post_type ) { |
|
124 | 83 | |
125 | - } |
|
84 | + if ( $post_type == 'wpi_item' ) { |
|
126 | 85 | |
127 | - // Subscriptions. |
|
128 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
129 | - if ( ! empty( $subscriptions ) ) { |
|
86 | + // Item details. |
|
87 | + add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
130 | 88 | |
131 | - if ( is_array( $subscriptions ) ) { |
|
132 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
133 | - } else { |
|
134 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
135 | - } |
|
89 | + // If taxes are enabled, register the tax metabox. |
|
90 | + if ( wpinv_use_taxes() ) { |
|
91 | + add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
92 | + } |
|
136 | 93 | |
137 | - if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
138 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
139 | - } |
|
94 | + // Item info. |
|
95 | + add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
140 | 96 | |
141 | - } |
|
97 | + } |
|
142 | 98 | |
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 | - if ( ! $invoice->is_draft() ) { |
|
157 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
158 | - } |
|
99 | + } |
|
159 | 100 | |
160 | - // Billing details. |
|
161 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
101 | + /** |
|
102 | + * Register invoice metaboxes. |
|
103 | + */ |
|
104 | + protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
105 | + |
|
106 | + // For invoices... |
|
107 | + if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | + $invoice = new WPInv_Invoice( $post ); |
|
109 | + |
|
110 | + // Resend invoice. |
|
111 | + if ( ! $invoice->is_draft() ) { |
|
112 | + |
|
113 | + add_meta_box( |
|
114 | + 'wpinv-mb-resend-invoice', |
|
115 | + sprintf( |
|
116 | + __( 'Resend %s', 'invoicing' ), |
|
117 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
118 | + ), |
|
119 | + 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
120 | + $post_type, |
|
121 | + 'side', |
|
122 | + 'low' |
|
123 | + ); |
|
124 | + |
|
125 | + } |
|
126 | + |
|
127 | + // Subscriptions. |
|
128 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
129 | + if ( ! empty( $subscriptions ) ) { |
|
130 | + |
|
131 | + if ( is_array( $subscriptions ) ) { |
|
132 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
133 | + } else { |
|
134 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
135 | + } |
|
136 | + |
|
137 | + if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
138 | + add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
139 | + } |
|
140 | + |
|
141 | + } |
|
142 | + |
|
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 | + if ( ! $invoice->is_draft() ) { |
|
157 | + add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
158 | + } |
|
159 | + |
|
160 | + // Billing details. |
|
161 | + add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
162 | 162 | |
163 | - // Invoice items. |
|
164 | - add_meta_box( |
|
165 | - 'wpinv-items', |
|
166 | - sprintf( |
|
167 | - __( '%s Items', 'invoicing' ), |
|
168 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
169 | - ), |
|
170 | - 'GetPaid_Meta_Box_Invoice_Items::output', |
|
171 | - $post_type, |
|
172 | - 'normal', |
|
173 | - 'high' |
|
174 | - ); |
|
163 | + // Invoice items. |
|
164 | + add_meta_box( |
|
165 | + 'wpinv-items', |
|
166 | + sprintf( |
|
167 | + __( '%s Items', 'invoicing' ), |
|
168 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
169 | + ), |
|
170 | + 'GetPaid_Meta_Box_Invoice_Items::output', |
|
171 | + $post_type, |
|
172 | + 'normal', |
|
173 | + 'high' |
|
174 | + ); |
|
175 | 175 | |
176 | - // Invoice notes. |
|
177 | - add_meta_box( |
|
178 | - 'wpinv-notes', |
|
179 | - sprintf( |
|
180 | - __( '%s Notes', 'invoicing' ), |
|
181 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
182 | - ), |
|
183 | - 'WPInv_Meta_Box_Notes::output', |
|
184 | - $post_type, |
|
185 | - 'side', |
|
186 | - 'low' |
|
187 | - ); |
|
188 | - |
|
189 | - // Shipping Address. |
|
190 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
191 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
192 | - } |
|
193 | - |
|
194 | - // Payment form information. |
|
195 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
196 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
197 | - } |
|
198 | - |
|
199 | - } |
|
200 | - |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Remove some metaboxes. |
|
205 | - */ |
|
206 | - public static function remove_meta_boxes() { |
|
207 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Rename other metaboxes. |
|
212 | - */ |
|
213 | - public static function rename_meta_boxes() { |
|
176 | + // Invoice notes. |
|
177 | + add_meta_box( |
|
178 | + 'wpinv-notes', |
|
179 | + sprintf( |
|
180 | + __( '%s Notes', 'invoicing' ), |
|
181 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
182 | + ), |
|
183 | + 'WPInv_Meta_Box_Notes::output', |
|
184 | + $post_type, |
|
185 | + 'side', |
|
186 | + 'low' |
|
187 | + ); |
|
188 | + |
|
189 | + // Shipping Address. |
|
190 | + if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
191 | + add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
192 | + } |
|
193 | + |
|
194 | + // Payment form information. |
|
195 | + if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
196 | + add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
197 | + } |
|
198 | + |
|
199 | + } |
|
200 | + |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Remove some metaboxes. |
|
205 | + */ |
|
206 | + public static function remove_meta_boxes() { |
|
207 | + remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Rename other metaboxes. |
|
212 | + */ |
|
213 | + public static function rename_meta_boxes() { |
|
214 | 214 | |
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Check if we're saving, then trigger an action based on the post type. |
|
219 | - * |
|
220 | - * @param int $post_id Post ID. |
|
221 | - * @param object $post Post object. |
|
222 | - */ |
|
223 | - public static function save_meta_boxes( $post_id, $post ) { |
|
224 | - $post_id = absint( $post_id ); |
|
225 | - $data = wp_unslash( $_POST ); |
|
226 | - |
|
227 | - // Do not save for ajax requests. |
|
228 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
229 | - return; |
|
230 | - } |
|
231 | - |
|
232 | - // $post_id and $post are required |
|
233 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
234 | - return; |
|
235 | - } |
|
236 | - |
|
237 | - // Dont' save meta boxes for revisions or autosaves. |
|
238 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
239 | - return; |
|
240 | - } |
|
241 | - |
|
242 | - // Check the nonce. |
|
243 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
244 | - return; |
|
245 | - } |
|
246 | - |
|
247 | - // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
248 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
249 | - return; |
|
250 | - } |
|
251 | - |
|
252 | - // Check user has permission to edit. |
|
253 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
254 | - return; |
|
255 | - } |
|
256 | - |
|
257 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
258 | - |
|
259 | - // We need this save event to run once to avoid potential endless loops. |
|
260 | - self::$saved_meta_boxes = true; |
|
261 | - |
|
262 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
263 | - |
|
264 | - } |
|
265 | - |
|
266 | - // Ensure this is our post type. |
|
267 | - $post_types_map = array( |
|
268 | - 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
269 | - 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
270 | - 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
271 | - ); |
|
272 | - |
|
273 | - // Is this our post type? |
|
274 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
275 | - return; |
|
276 | - } |
|
277 | - |
|
278 | - // We need this save event to run once to avoid potential endless loops. |
|
279 | - self::$saved_meta_boxes = true; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Check if we're saving, then trigger an action based on the post type. |
|
219 | + * |
|
220 | + * @param int $post_id Post ID. |
|
221 | + * @param object $post Post object. |
|
222 | + */ |
|
223 | + public static function save_meta_boxes( $post_id, $post ) { |
|
224 | + $post_id = absint( $post_id ); |
|
225 | + $data = wp_unslash( $_POST ); |
|
226 | + |
|
227 | + // Do not save for ajax requests. |
|
228 | + if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
229 | + return; |
|
230 | + } |
|
231 | + |
|
232 | + // $post_id and $post are required |
|
233 | + if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
234 | + return; |
|
235 | + } |
|
236 | + |
|
237 | + // Dont' save meta boxes for revisions or autosaves. |
|
238 | + if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
239 | + return; |
|
240 | + } |
|
241 | + |
|
242 | + // Check the nonce. |
|
243 | + if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
244 | + return; |
|
245 | + } |
|
246 | + |
|
247 | + // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
248 | + if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
249 | + return; |
|
250 | + } |
|
251 | + |
|
252 | + // Check user has permission to edit. |
|
253 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
254 | + return; |
|
255 | + } |
|
256 | + |
|
257 | + if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
258 | + |
|
259 | + // We need this save event to run once to avoid potential endless loops. |
|
260 | + self::$saved_meta_boxes = true; |
|
261 | + |
|
262 | + return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
263 | + |
|
264 | + } |
|
265 | + |
|
266 | + // Ensure this is our post type. |
|
267 | + $post_types_map = array( |
|
268 | + 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
269 | + 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
270 | + 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
271 | + ); |
|
272 | + |
|
273 | + // Is this our post type? |
|
274 | + if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
275 | + return; |
|
276 | + } |
|
277 | + |
|
278 | + // We need this save event to run once to avoid potential endless loops. |
|
279 | + self::$saved_meta_boxes = true; |
|
280 | 280 | |
281 | - // Save the post. |
|
282 | - $class = $post_types_map[ $post->post_type ]; |
|
283 | - $class::save( $post_id, $_POST, $post ); |
|
281 | + // Save the post. |
|
282 | + $class = $post_types_map[ $post->post_type ]; |
|
283 | + $class::save( $post_id, $_POST, $post ); |
|
284 | 284 | |
285 | - } |
|
285 | + } |
|
286 | 286 | |
287 | 287 | } |
@@ -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 ); |
|
49 | + self::add_payment_form_meta_boxes($post_type); |
|
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,16 +61,16 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Register core metaboxes. |
63 | 63 | */ |
64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
64 | + protected static function add_payment_form_meta_boxes($post_type) { |
|
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 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
73 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Register core metaboxes. |
81 | 81 | */ |
82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
82 | + protected static function add_item_meta_boxes($post_type) { |
|
83 | 83 | |
84 | - if ( $post_type == 'wpi_item' ) { |
|
84 | + if ($post_type == 'wpi_item') { |
|
85 | 85 | |
86 | 86 | // Item details. |
87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
87 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
88 | 88 | |
89 | 89 | // If taxes are enabled, register the tax metabox. |
90 | - if ( wpinv_use_taxes() ) { |
|
91 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
90 | + if (wpinv_use_taxes()) { |
|
91 | + add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Item info. |
95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
95 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Register invoice metaboxes. |
103 | 103 | */ |
104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
104 | + protected static function add_invoice_meta_boxes($post_type, $post) { |
|
105 | 105 | |
106 | 106 | // For invoices... |
107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | - $invoice = new WPInv_Invoice( $post ); |
|
107 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
108 | + $invoice = new WPInv_Invoice($post); |
|
109 | 109 | |
110 | 110 | // Resend invoice. |
111 | - if ( ! $invoice->is_draft() ) { |
|
111 | + if (!$invoice->is_draft()) { |
|
112 | 112 | |
113 | 113 | add_meta_box( |
114 | 114 | 'wpinv-mb-resend-invoice', |
115 | 115 | sprintf( |
116 | - __( 'Resend %s', 'invoicing' ), |
|
117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
116 | + __('Resend %s', 'invoicing'), |
|
117 | + ucfirst($invoice->get_invoice_quote_type()) |
|
118 | 118 | ), |
119 | 119 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
120 | 120 | $post_type, |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | // Subscriptions. |
128 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
129 | - if ( ! empty( $subscriptions ) ) { |
|
128 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
129 | + if (!empty($subscriptions)) { |
|
130 | 130 | |
131 | - if ( is_array( $subscriptions ) ) { |
|
132 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' ); |
|
131 | + if (is_array($subscriptions)) { |
|
132 | + add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced'); |
|
133 | 133 | } else { |
134 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
134 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) { |
|
138 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
137 | + if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) { |
|
138 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
@@ -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,19 +153,19 @@ discard block |
||
153 | 153 | ); |
154 | 154 | |
155 | 155 | // Payment details. |
156 | - if ( ! $invoice->is_draft() ) { |
|
157 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
156 | + if (!$invoice->is_draft()) { |
|
157 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // Billing details. |
161 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
161 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
162 | 162 | |
163 | 163 | // Invoice items. |
164 | 164 | add_meta_box( |
165 | 165 | 'wpinv-items', |
166 | 166 | sprintf( |
167 | - __( '%s Items', 'invoicing' ), |
|
168 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
167 | + __('%s Items', 'invoicing'), |
|
168 | + ucfirst($invoice->get_invoice_quote_type()) |
|
169 | 169 | ), |
170 | 170 | 'GetPaid_Meta_Box_Invoice_Items::output', |
171 | 171 | $post_type, |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | add_meta_box( |
178 | 178 | 'wpinv-notes', |
179 | 179 | sprintf( |
180 | - __( '%s Notes', 'invoicing' ), |
|
181 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
180 | + __('%s Notes', 'invoicing'), |
|
181 | + ucfirst($invoice->get_invoice_quote_type()) |
|
182 | 182 | ), |
183 | 183 | 'WPInv_Meta_Box_Notes::output', |
184 | 184 | $post_type, |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | ); |
188 | 188 | |
189 | 189 | // Shipping Address. |
190 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
191 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
190 | + if (get_post_meta($invoice->get_id(), 'shipping_address', true)) { |
|
191 | + add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | // Payment form information. |
195 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
196 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
195 | + if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) { |
|
196 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * Remove some metaboxes. |
205 | 205 | */ |
206 | 206 | public static function remove_meta_boxes() { |
207 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
207 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -220,46 +220,46 @@ discard block |
||
220 | 220 | * @param int $post_id Post ID. |
221 | 221 | * @param object $post Post object. |
222 | 222 | */ |
223 | - public static function save_meta_boxes( $post_id, $post ) { |
|
224 | - $post_id = absint( $post_id ); |
|
225 | - $data = wp_unslash( $_POST ); |
|
223 | + public static function save_meta_boxes($post_id, $post) { |
|
224 | + $post_id = absint($post_id); |
|
225 | + $data = wp_unslash($_POST); |
|
226 | 226 | |
227 | 227 | // Do not save for ajax requests. |
228 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
228 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // $post_id and $post are required |
233 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
233 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
234 | 234 | return; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Dont' save meta boxes for revisions or autosaves. |
238 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
238 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Check the nonce. |
243 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
243 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | 247 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
248 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
248 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
249 | 249 | return; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Check user has permission to edit. |
253 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
253 | + if (!current_user_can('edit_post', $post_id)) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
257 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
258 | 258 | |
259 | 259 | // We need this save event to run once to avoid potential endless loops. |
260 | 260 | self::$saved_meta_boxes = true; |
261 | 261 | |
262 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
262 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ); |
272 | 272 | |
273 | 273 | // Is this our post type? |
274 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
274 | + if (!isset($post_types_map[$post->post_type])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | self::$saved_meta_boxes = true; |
280 | 280 | |
281 | 281 | // Save the post. |
282 | - $class = $post_types_map[ $post->post_type ]; |
|
283 | - $class::save( $post_id, $_POST, $post ); |
|
282 | + $class = $post_types_map[$post->post_type]; |
|
283 | + $class::save($post_id, $_POST, $post); |
|
284 | 284 | |
285 | 285 | } |
286 | 286 |
@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Make sure that the form is active. |
13 | -if ( ! $form->is_active() ) { |
|
13 | +if (!$form->is_active()) { |
|
14 | 14 | echo aui()->alert( |
15 | 15 | array( |
16 | 16 | 'type' => 'warning', |
17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
18 | 18 | ) |
19 | 19 | ); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Fires before displaying a payment form. |
24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
24 | +do_action('getpaid_before_payment_form', $form); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>'> |
|
27 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>'> |
|
28 | 28 | |
29 | 29 | |
30 | 30 | <?php |
31 | 31 | |
32 | 32 | // Fires when printing the top of a payment form. |
33 | - do_action( 'getpaid_payment_form_top', $form ); |
|
33 | + do_action('getpaid_payment_form_top', $form); |
|
34 | 34 | |
35 | 35 | // And the optional invoice id. |
36 | - if ( ! empty( $form->invoice ) ) { |
|
37 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
36 | + if (!empty($form->invoice)) { |
|
37 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // We also want to include the form id. |
41 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
41 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
42 | 42 | |
43 | 43 | // And an indication that this is a payment form submission. |
44 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
44 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
45 | 45 | |
46 | 46 | // Fires before displaying payment form elements. |
47 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
47 | + do_action('getpaid_payment_form_before_elements', $form); |
|
48 | 48 | |
49 | 49 | // Display the elements. |
50 | 50 | ?> |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | <div class="row"> |
53 | 53 | <?php |
54 | 54 | |
55 | - foreach ( $form->get_elements() as $element ) { |
|
55 | + foreach ($form->get_elements() as $element) { |
|
56 | 56 | |
57 | - if ( isset( $element['type'] ) ) { |
|
58 | - $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) ); |
|
57 | + if (isset($element['type'])) { |
|
58 | + $grid_class = esc_attr(getpaid_get_form_element_grid_class($element)); |
|
59 | 59 | echo "<div class='$grid_class'>"; |
60 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
61 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
60 | + do_action('getpaid_payment_form_element', $element, $form); |
|
61 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
62 | 62 | echo "</div>"; |
63 | 63 | } |
64 | 64 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | // Fires after displaying payment form elements. |
73 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
73 | + do_action('getpaid_payment_form_after_elements', $form); |
|
74 | 74 | |
75 | 75 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
76 | 76 | |
77 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
77 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
78 | 78 | |
79 | 79 | edit_post_link( |
80 | - __( 'Edit this form.', 'invoicing' ), |
|
80 | + __('Edit this form.', 'invoicing'), |
|
81 | 81 | '<small class="form-text text-muted">', |
82 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
82 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
83 | 83 | $form->get_id(), |
84 | 84 | 'text-danger' |
85 | 85 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;"> |
93 | 93 | <div class="spinner-border mx-auto align-self-center text-white" role="status"> |
94 | - <span class="sr-only"><?php _e( 'Loading...', 'invoicing' );?></span> |
|
94 | + <span class="sr-only"><?php _e('Loading...', 'invoicing'); ?></span> |
|
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | |
@@ -100,4 +100,4 @@ discard block |
||
100 | 100 | <?php |
101 | 101 | |
102 | 102 | // Fires after displaying a payment form. |
103 | -do_action( 'getpaid_after_payment_form', $form ); |
|
103 | +do_action('getpaid_after_payment_form', $form); |
@@ -7,27 +7,27 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Cart table columns. |
13 | 13 | $columns = array( |
14 | - 'name' => __( 'Item', 'invoicing' ), |
|
15 | - 'price' => __( 'Price', 'invoicing' ), |
|
16 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
14 | + 'name' => __('Item', 'invoicing'), |
|
15 | + 'price' => __('Price', 'invoicing'), |
|
16 | + 'quantity' => __('Quantity', 'invoicing'), |
|
17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
18 | 18 | ); |
19 | 19 | |
20 | -if ( ! empty( $form->invoice ) ) { |
|
21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
20 | +if (!empty($form->invoice)) { |
|
21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
22 | 22 | } |
23 | 23 | |
24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
25 | - unset( $columns['tax_rate'] ); |
|
24 | +if (isset($columns['tax_rate'])) { |
|
25 | + unset($columns['tax_rate']); |
|
26 | 26 | } |
27 | 27 | |
28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
28 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
29 | 29 | |
30 | -do_action( 'getpaid_before_payment_form_cart', $form ); |
|
30 | +do_action('getpaid_before_payment_form_cart', $form); |
|
31 | 31 | |
32 | 32 | ?> |
33 | 33 | <div class="getpaid-payment-form-items-cart border form-group"> |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | |
36 | 36 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
37 | 37 | <div class="form-row"> |
38 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
39 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>"> |
|
40 | - <?php echo sanitize_text_field( $label ); ?> |
|
38 | + <?php foreach ($columns as $key => $label) : ?> |
|
39 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>"> |
|
40 | + <?php echo sanitize_text_field($label); ?> |
|
41 | 41 | </div> |
42 | 42 | <?php endforeach; ?> |
43 | 43 | </div> |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | <?php |
47 | 47 | |
48 | 48 | // Display the item totals. |
49 | - foreach ( $form->get_items() as $item ) { |
|
50 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
49 | + foreach ($form->get_items() as $item) { |
|
50 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Display the cart totals. |
54 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
54 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
55 | 55 | |
56 | 56 | ?> |
57 | 57 | </div> |
58 | 58 | |
59 | 59 | <?php |
60 | 60 | |
61 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
61 | +do_action('getpaid_after_payment_form_cart', $form); |
@@ -126,8 +126,12 @@ discard block |
||
126 | 126 | public function constants(){ |
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
130 | + define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + if (!defined('AUI_SECONDARY_COLOR')) { |
|
133 | + define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
134 | + } |
|
131 | 135 | } |
132 | 136 | |
133 | 137 | /** |
@@ -233,7 +237,7 @@ discard block |
||
233 | 237 | |
234 | 238 | if( is_admin() && !$this->is_aui_screen()){ |
235 | 239 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
240 | + } else{ |
|
237 | 241 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 242 | |
239 | 243 | $rtl = is_rtl() ? '-rtl' : ''; |
@@ -1051,7 +1055,7 @@ discard block |
||
1051 | 1055 | |
1052 | 1056 | if( is_admin() && !$this->is_aui_screen()){ |
1053 | 1057 | // don't add wp-admin scripts if not requested to |
1054 | - }else { |
|
1058 | + } else { |
|
1055 | 1059 | |
1056 | 1060 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
1057 | 1061 | |
@@ -2093,7 +2097,9 @@ discard block |
||
2093 | 2097 | * @return mixed |
2094 | 2098 | */ |
2095 | 2099 | public static function minify_js($input) { |
2096 | - if(trim($input) === "") return $input; |
|
2100 | + if(trim($input) === "") { |
|
2101 | + return $input; |
|
2102 | + } |
|
2097 | 2103 | return preg_replace( |
2098 | 2104 | array( |
2099 | 2105 | // Remove comment(s) |
@@ -2125,7 +2131,9 @@ discard block |
||
2125 | 2131 | * @return mixed |
2126 | 2132 | */ |
2127 | 2133 | public static function minify_css($input) { |
2128 | - if(trim($input) === "") return $input; |
|
2134 | + if(trim($input) === "") { |
|
2135 | + return $input; |
|
2136 | + } |
|
2129 | 2137 | return preg_replace( |
2130 | 2138 | array( |
2131 | 2139 | // Remove comment(s) |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
16 | - exit; |
|
16 | + exit; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,236 +21,236 @@ discard block |
||
21 | 21 | */ |
22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
23 | 23 | |
24 | - /** |
|
25 | - * A Class to be able to change settings for Font Awesome. |
|
26 | - * |
|
27 | - * Class AyeCode_UI_Settings |
|
28 | - * @ver 1.0.0 |
|
29 | - * @todo decide how to implement textdomain |
|
30 | - */ |
|
31 | - class AyeCode_UI_Settings { |
|
32 | - |
|
33 | - /** |
|
34 | - * Class version version. |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public $version = '0.1.51'; |
|
39 | - |
|
40 | - /** |
|
41 | - * Class textdomain. |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - public $textdomain = 'aui'; |
|
46 | - |
|
47 | - /** |
|
48 | - * Latest version of Bootstrap at time of publish published. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - public $latest = "4.5.3"; |
|
53 | - |
|
54 | - /** |
|
55 | - * Current version of select2 being used. |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - public $select2_version = "4.0.11"; |
|
60 | - |
|
61 | - /** |
|
62 | - * The title. |
|
63 | - * |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - public $name = 'AyeCode UI'; |
|
67 | - |
|
68 | - /** |
|
69 | - * The relative url to the assets. |
|
70 | - * |
|
71 | - * @var string |
|
72 | - */ |
|
73 | - public $url = ''; |
|
74 | - |
|
75 | - /** |
|
76 | - * Holds the settings values. |
|
77 | - * |
|
78 | - * @var array |
|
79 | - */ |
|
80 | - private $settings; |
|
81 | - |
|
82 | - /** |
|
83 | - * AyeCode_UI_Settings instance. |
|
84 | - * |
|
85 | - * @access private |
|
86 | - * @since 1.0.0 |
|
87 | - * @var AyeCode_UI_Settings There can be only one! |
|
88 | - */ |
|
89 | - private static $instance = null; |
|
90 | - |
|
91 | - /** |
|
92 | - * Main AyeCode_UI_Settings Instance. |
|
93 | - * |
|
94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | - * |
|
96 | - * @since 1.0.0 |
|
97 | - * @static |
|
98 | - * @return AyeCode_UI_Settings - Main instance. |
|
99 | - */ |
|
100 | - public static function instance() { |
|
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | - |
|
103 | - self::$instance = new AyeCode_UI_Settings; |
|
104 | - |
|
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | - |
|
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | - |
|
111 | - // Maybe show example page |
|
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | - } |
|
114 | - |
|
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | - |
|
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | - } |
|
119 | - |
|
120 | - return self::$instance; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Setup some constants. |
|
125 | - */ |
|
126 | - public function constants(){ |
|
127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Initiate the settings and add the required action hooks. |
|
135 | - */ |
|
136 | - public function init() { |
|
137 | - $this->constants(); |
|
138 | - $this->settings = $this->get_settings(); |
|
139 | - $this->url = $this->get_url(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Maybe load CSS |
|
143 | - * |
|
144 | - * We load super early in case there is a theme version that might change the colors |
|
145 | - */ |
|
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | - } |
|
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | - } |
|
152 | - |
|
153 | - // maybe load JS |
|
154 | - if ( $this->settings['js'] ) { |
|
155 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | - } |
|
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | - } |
|
161 | - |
|
162 | - // Maybe set the HTML font size |
|
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Check if we should load the admin scripts or not. |
|
172 | - * |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - public function load_admin_scripts(){ |
|
176 | - $result = true; |
|
177 | - |
|
178 | - // check if specifically disabled |
|
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | - return false; // return early, no point checking further |
|
184 | - } |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $result; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Add a html font size to the footer. |
|
193 | - */ |
|
194 | - public function html_font_size(){ |
|
195 | - $this->settings = $this->get_settings(); |
|
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | - } |
|
24 | + /** |
|
25 | + * A Class to be able to change settings for Font Awesome. |
|
26 | + * |
|
27 | + * Class AyeCode_UI_Settings |
|
28 | + * @ver 1.0.0 |
|
29 | + * @todo decide how to implement textdomain |
|
30 | + */ |
|
31 | + class AyeCode_UI_Settings { |
|
32 | + |
|
33 | + /** |
|
34 | + * Class version version. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $version = '0.1.51'; |
|
39 | + |
|
40 | + /** |
|
41 | + * Class textdomain. |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + public $textdomain = 'aui'; |
|
46 | + |
|
47 | + /** |
|
48 | + * Latest version of Bootstrap at time of publish published. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + public $latest = "4.5.3"; |
|
53 | + |
|
54 | + /** |
|
55 | + * Current version of select2 being used. |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + public $select2_version = "4.0.11"; |
|
60 | + |
|
61 | + /** |
|
62 | + * The title. |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + public $name = 'AyeCode UI'; |
|
67 | + |
|
68 | + /** |
|
69 | + * The relative url to the assets. |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + public $url = ''; |
|
74 | + |
|
75 | + /** |
|
76 | + * Holds the settings values. |
|
77 | + * |
|
78 | + * @var array |
|
79 | + */ |
|
80 | + private $settings; |
|
81 | + |
|
82 | + /** |
|
83 | + * AyeCode_UI_Settings instance. |
|
84 | + * |
|
85 | + * @access private |
|
86 | + * @since 1.0.0 |
|
87 | + * @var AyeCode_UI_Settings There can be only one! |
|
88 | + */ |
|
89 | + private static $instance = null; |
|
90 | + |
|
91 | + /** |
|
92 | + * Main AyeCode_UI_Settings Instance. |
|
93 | + * |
|
94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | + * |
|
96 | + * @since 1.0.0 |
|
97 | + * @static |
|
98 | + * @return AyeCode_UI_Settings - Main instance. |
|
99 | + */ |
|
100 | + public static function instance() { |
|
101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | + |
|
103 | + self::$instance = new AyeCode_UI_Settings; |
|
104 | + |
|
105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | + |
|
107 | + if ( is_admin() ) { |
|
108 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | + |
|
111 | + // Maybe show example page |
|
112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | + } |
|
198 | 114 | |
199 | - /** |
|
200 | - * Check if the current admin screen should load scripts. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - public function is_aui_screen(){ |
|
205 | - $load = false; |
|
206 | - // check if we should load or not |
|
207 | - if ( is_admin() ) { |
|
208 | - // Only enable on set pages |
|
209 | - $aui_screens = array( |
|
210 | - 'page', |
|
211 | - 'post', |
|
212 | - 'settings_page_ayecode-ui-settings', |
|
213 | - 'appearance_page_gutenberg-widgets' |
|
214 | - ); |
|
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | - |
|
217 | - $screen = get_current_screen(); |
|
115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | + |
|
117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | + } |
|
119 | + |
|
120 | + return self::$instance; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Setup some constants. |
|
125 | + */ |
|
126 | + public function constants(){ |
|
127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Initiate the settings and add the required action hooks. |
|
135 | + */ |
|
136 | + public function init() { |
|
137 | + $this->constants(); |
|
138 | + $this->settings = $this->get_settings(); |
|
139 | + $this->url = $this->get_url(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Maybe load CSS |
|
143 | + * |
|
144 | + * We load super early in case there is a theme version that might change the colors |
|
145 | + */ |
|
146 | + if ( $this->settings['css'] ) { |
|
147 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | + } |
|
149 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | + } |
|
152 | + |
|
153 | + // maybe load JS |
|
154 | + if ( $this->settings['js'] ) { |
|
155 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | + } |
|
158 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | + } |
|
161 | + |
|
162 | + // Maybe set the HTML font size |
|
163 | + if ( $this->settings['html_font_size'] ) { |
|
164 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Check if we should load the admin scripts or not. |
|
172 | + * |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + public function load_admin_scripts(){ |
|
176 | + $result = true; |
|
177 | + |
|
178 | + // check if specifically disabled |
|
179 | + if(!empty($this->settings['disable_admin'])){ |
|
180 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | + foreach($url_parts as $part){ |
|
182 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | + return false; // return early, no point checking further |
|
184 | + } |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $result; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Add a html font size to the footer. |
|
193 | + */ |
|
194 | + public function html_font_size(){ |
|
195 | + $this->settings = $this->get_settings(); |
|
196 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Check if the current admin screen should load scripts. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + public function is_aui_screen(){ |
|
205 | + $load = false; |
|
206 | + // check if we should load or not |
|
207 | + if ( is_admin() ) { |
|
208 | + // Only enable on set pages |
|
209 | + $aui_screens = array( |
|
210 | + 'page', |
|
211 | + 'post', |
|
212 | + 'settings_page_ayecode-ui-settings', |
|
213 | + 'appearance_page_gutenberg-widgets' |
|
214 | + ); |
|
215 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | + |
|
217 | + $screen = get_current_screen(); |
|
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | - $load = true; |
|
223 | - } |
|
224 | - } |
|
221 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | + $load = true; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - return $load; |
|
227 | - } |
|
226 | + return $load; |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * Adds the styles. |
|
231 | - */ |
|
232 | - public function enqueue_style() { |
|
229 | + /** |
|
230 | + * Adds the styles. |
|
231 | + */ |
|
232 | + public function enqueue_style() { |
|
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
235 | - // don't add wp-admin scripts if not requested to |
|
236 | - }else{ |
|
237 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
234 | + if( is_admin() && !$this->is_aui_screen()){ |
|
235 | + // don't add wp-admin scripts if not requested to |
|
236 | + }else{ |
|
237 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
238 | 238 | |
239 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
239 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if($this->settings[$css_setting]){ |
|
242 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | + wp_enqueue_style( 'ayecode-ui' ); |
|
246 | 246 | |
247 | - // flatpickr |
|
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
247 | + // flatpickr |
|
248 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
249 | 249 | |
250 | 250 | |
251 | - // fix some wp-admin issues |
|
252 | - if(is_admin()){ |
|
253 | - $custom_css = " |
|
251 | + // fix some wp-admin issues |
|
252 | + if(is_admin()){ |
|
253 | + $custom_css = " |
|
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
256 | 256 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -292,35 +292,35 @@ discard block |
||
292 | 292 | } |
293 | 293 | "; |
294 | 294 | |
295 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | - $custom_css .= " |
|
295 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | + $custom_css .= " |
|
297 | 297 | .edit-post-sidebar input[type=color].components-text-control__input{ |
298 | 298 | padding: 0; |
299 | 299 | } |
300 | 300 | "; |
301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | - } |
|
301 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | + } |
|
303 | 303 | |
304 | - // custom changes |
|
305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
304 | + // custom changes |
|
305 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
306 | 306 | |
307 | - } |
|
308 | - } |
|
307 | + } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Get inline script used if bootstrap enqueued |
|
315 | + * |
|
316 | + * If this remains small then its best to use this than to add another JS file. |
|
317 | + */ |
|
318 | + public function inline_script() { |
|
319 | + // Flatpickr calendar locale |
|
320 | + $flatpickr_locale = self::flatpickr_locale(); |
|
312 | 321 | |
313 | - /** |
|
314 | - * Get inline script used if bootstrap enqueued |
|
315 | - * |
|
316 | - * If this remains small then its best to use this than to add another JS file. |
|
317 | - */ |
|
318 | - public function inline_script() { |
|
319 | - // Flatpickr calendar locale |
|
320 | - $flatpickr_locale = self::flatpickr_locale(); |
|
321 | - |
|
322 | - ob_start(); |
|
323 | - ?> |
|
322 | + ob_start(); |
|
323 | + ?> |
|
324 | 324 | <script> |
325 | 325 | /** |
326 | 326 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -1009,29 +1009,29 @@ discard block |
||
1009 | 1009 | }); |
1010 | 1010 | </script> |
1011 | 1011 | <?php |
1012 | - $output = ob_get_clean(); |
|
1012 | + $output = ob_get_clean(); |
|
1013 | 1013 | |
1014 | 1014 | |
1015 | 1015 | |
1016 | - /* |
|
1016 | + /* |
|
1017 | 1017 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1018 | 1018 | */ |
1019 | - return str_replace( array( |
|
1020 | - '<script>', |
|
1021 | - '</script>' |
|
1022 | - ), '', self::minify_js($output) ); |
|
1023 | - } |
|
1024 | - |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1028 | - * |
|
1029 | - * @TODO we may need this when other conflicts arrise. |
|
1030 | - * @return mixed |
|
1031 | - */ |
|
1032 | - public static function bs3_compat_js() { |
|
1033 | - ob_start(); |
|
1034 | - ?> |
|
1019 | + return str_replace( array( |
|
1020 | + '<script>', |
|
1021 | + '</script>' |
|
1022 | + ), '', self::minify_js($output) ); |
|
1023 | + } |
|
1024 | + |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1028 | + * |
|
1029 | + * @TODO we may need this when other conflicts arrise. |
|
1030 | + * @return mixed |
|
1031 | + */ |
|
1032 | + public static function bs3_compat_js() { |
|
1033 | + ob_start(); |
|
1034 | + ?> |
|
1035 | 1035 | <script> |
1036 | 1036 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
1037 | 1037 | /* With Avada builder */ |
@@ -1039,20 +1039,20 @@ discard block |
||
1039 | 1039 | <?php } ?> |
1040 | 1040 | </script> |
1041 | 1041 | <?php |
1042 | - return str_replace( array( |
|
1043 | - '<script>', |
|
1044 | - '</script>' |
|
1045 | - ), '', ob_get_clean()); |
|
1046 | - } |
|
1047 | - |
|
1048 | - /** |
|
1049 | - * Get inline script used if bootstrap file browser enqueued. |
|
1050 | - * |
|
1051 | - * If this remains small then its best to use this than to add another JS file. |
|
1052 | - */ |
|
1053 | - public function inline_script_file_browser(){ |
|
1054 | - ob_start(); |
|
1055 | - ?> |
|
1042 | + return str_replace( array( |
|
1043 | + '<script>', |
|
1044 | + '</script>' |
|
1045 | + ), '', ob_get_clean()); |
|
1046 | + } |
|
1047 | + |
|
1048 | + /** |
|
1049 | + * Get inline script used if bootstrap file browser enqueued. |
|
1050 | + * |
|
1051 | + * If this remains small then its best to use this than to add another JS file. |
|
1052 | + */ |
|
1053 | + public function inline_script_file_browser(){ |
|
1054 | + ob_start(); |
|
1055 | + ?> |
|
1056 | 1056 | <script> |
1057 | 1057 | // run on doc ready |
1058 | 1058 | jQuery(document).ready(function () { |
@@ -1060,192 +1060,192 @@ discard block |
||
1060 | 1060 | }); |
1061 | 1061 | </script> |
1062 | 1062 | <?php |
1063 | - $output = ob_get_clean(); |
|
1063 | + $output = ob_get_clean(); |
|
1064 | 1064 | |
1065 | - /* |
|
1065 | + /* |
|
1066 | 1066 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1067 | 1067 | */ |
1068 | - return str_replace( array( |
|
1069 | - '<script>', |
|
1070 | - '</script>' |
|
1071 | - ), '', $output ); |
|
1072 | - } |
|
1073 | - |
|
1074 | - /** |
|
1075 | - * Adds the Font Awesome JS. |
|
1076 | - */ |
|
1077 | - public function enqueue_scripts() { |
|
1078 | - |
|
1079 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1080 | - // don't add wp-admin scripts if not requested to |
|
1081 | - }else { |
|
1082 | - |
|
1083 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1084 | - |
|
1085 | - // select2 |
|
1086 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1087 | - |
|
1088 | - // flatpickr |
|
1089 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1090 | - |
|
1091 | - // Bootstrap file browser |
|
1092 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1093 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1094 | - |
|
1095 | - $load_inline = false; |
|
1096 | - |
|
1097 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1098 | - // Bootstrap bundle |
|
1099 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1100 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1101 | - 'select2', |
|
1102 | - 'jquery' |
|
1103 | - ), $this->latest, $this->is_bs3_compat() ); |
|
1104 | - // if in admin then add to footer for compatibility. |
|
1105 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1106 | - $script = $this->inline_script(); |
|
1107 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1108 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1109 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
1110 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1111 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1112 | - $load_inline = true; |
|
1113 | - } else { |
|
1114 | - $load_inline = true; |
|
1115 | - } |
|
1116 | - |
|
1117 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1118 | - if ( $load_inline ) { |
|
1119 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1120 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
1121 | - $script = $this->inline_script(); |
|
1122 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1123 | - } |
|
1124 | - } |
|
1125 | - |
|
1126 | - } |
|
1127 | - |
|
1128 | - /** |
|
1129 | - * Enqueue flatpickr if called. |
|
1130 | - */ |
|
1131 | - public function enqueue_flatpickr(){ |
|
1132 | - wp_enqueue_style( 'flatpickr' ); |
|
1133 | - wp_enqueue_script( 'flatpickr' ); |
|
1134 | - } |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * Get the url path to the current folder. |
|
1138 | - * |
|
1139 | - * @return string |
|
1140 | - */ |
|
1141 | - public function get_url() { |
|
1142 | - |
|
1143 | - $url = ''; |
|
1144 | - // check if we are inside a plugin |
|
1145 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1146 | - |
|
1147 | - // add check in-case user has changed wp-content dir name. |
|
1148 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1149 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1150 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1151 | - |
|
1152 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1153 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1154 | - } |
|
1155 | - |
|
1156 | - return $url; |
|
1157 | - } |
|
1158 | - |
|
1159 | - /** |
|
1160 | - * Register the database settings with WordPress. |
|
1161 | - */ |
|
1162 | - public function register_settings() { |
|
1163 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1164 | - } |
|
1165 | - |
|
1166 | - /** |
|
1167 | - * Add the WordPress settings menu item. |
|
1168 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1169 | - */ |
|
1170 | - public function menu_item() { |
|
1171 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1172 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1173 | - $this, |
|
1174 | - 'settings_page' |
|
1175 | - ) ); |
|
1176 | - } |
|
1177 | - |
|
1178 | - /** |
|
1179 | - * Get a list of themes and their default JS settings. |
|
1180 | - * |
|
1181 | - * @return array |
|
1182 | - */ |
|
1183 | - public function theme_js_settings(){ |
|
1184 | - return array( |
|
1185 | - 'ayetheme' => 'popper', |
|
1186 | - 'listimia' => 'required', |
|
1187 | - 'listimia_backend' => 'core-popper', |
|
1188 | - //'avada' => 'required', // removed as we now add compatibility |
|
1189 | - ); |
|
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * Get the current Font Awesome output settings. |
|
1194 | - * |
|
1195 | - * @return array The array of settings. |
|
1196 | - */ |
|
1197 | - public function get_settings() { |
|
1198 | - |
|
1199 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1200 | - $js_default = 'core-popper'; |
|
1201 | - $js_default_backend = $js_default; |
|
1202 | - |
|
1203 | - // maybe set defaults (if no settings set) |
|
1204 | - if(empty($db_settings)){ |
|
1205 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1206 | - $theme_js_settings = self::theme_js_settings(); |
|
1207 | - if(isset($theme_js_settings[$active_theme])){ |
|
1208 | - $js_default = $theme_js_settings[$active_theme]; |
|
1209 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1210 | - } |
|
1211 | - } |
|
1212 | - |
|
1213 | - $defaults = array( |
|
1214 | - 'css' => 'compatibility', // core, compatibility |
|
1215 | - 'js' => $js_default, // js to load, core-popper, popper |
|
1216 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
1217 | - 'css_backend' => 'compatibility', // core, compatibility |
|
1218 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1219 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1220 | - ); |
|
1221 | - |
|
1222 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * Filter the Bootstrap settings. |
|
1226 | - * |
|
1227 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1228 | - */ |
|
1229 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1230 | - } |
|
1231 | - |
|
1068 | + return str_replace( array( |
|
1069 | + '<script>', |
|
1070 | + '</script>' |
|
1071 | + ), '', $output ); |
|
1072 | + } |
|
1073 | + |
|
1074 | + /** |
|
1075 | + * Adds the Font Awesome JS. |
|
1076 | + */ |
|
1077 | + public function enqueue_scripts() { |
|
1078 | + |
|
1079 | + if( is_admin() && !$this->is_aui_screen()){ |
|
1080 | + // don't add wp-admin scripts if not requested to |
|
1081 | + }else { |
|
1082 | + |
|
1083 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1084 | + |
|
1085 | + // select2 |
|
1086 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1087 | + |
|
1088 | + // flatpickr |
|
1089 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1090 | + |
|
1091 | + // Bootstrap file browser |
|
1092 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1093 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1094 | + |
|
1095 | + $load_inline = false; |
|
1096 | + |
|
1097 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1098 | + // Bootstrap bundle |
|
1099 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1100 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1101 | + 'select2', |
|
1102 | + 'jquery' |
|
1103 | + ), $this->latest, $this->is_bs3_compat() ); |
|
1104 | + // if in admin then add to footer for compatibility. |
|
1105 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1106 | + $script = $this->inline_script(); |
|
1107 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1108 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1109 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
1110 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1111 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1112 | + $load_inline = true; |
|
1113 | + } else { |
|
1114 | + $load_inline = true; |
|
1115 | + } |
|
1232 | 1116 | |
1233 | - /** |
|
1234 | - * The settings page html output. |
|
1235 | - */ |
|
1236 | - public function settings_page() { |
|
1237 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1238 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1239 | - } |
|
1240 | - ?> |
|
1117 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1118 | + if ( $load_inline ) { |
|
1119 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1120 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
1121 | + $script = $this->inline_script(); |
|
1122 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1123 | + } |
|
1124 | + } |
|
1125 | + |
|
1126 | + } |
|
1127 | + |
|
1128 | + /** |
|
1129 | + * Enqueue flatpickr if called. |
|
1130 | + */ |
|
1131 | + public function enqueue_flatpickr(){ |
|
1132 | + wp_enqueue_style( 'flatpickr' ); |
|
1133 | + wp_enqueue_script( 'flatpickr' ); |
|
1134 | + } |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * Get the url path to the current folder. |
|
1138 | + * |
|
1139 | + * @return string |
|
1140 | + */ |
|
1141 | + public function get_url() { |
|
1142 | + |
|
1143 | + $url = ''; |
|
1144 | + // check if we are inside a plugin |
|
1145 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1146 | + |
|
1147 | + // add check in-case user has changed wp-content dir name. |
|
1148 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1149 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1150 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1151 | + |
|
1152 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1153 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1154 | + } |
|
1155 | + |
|
1156 | + return $url; |
|
1157 | + } |
|
1158 | + |
|
1159 | + /** |
|
1160 | + * Register the database settings with WordPress. |
|
1161 | + */ |
|
1162 | + public function register_settings() { |
|
1163 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * Add the WordPress settings menu item. |
|
1168 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1169 | + */ |
|
1170 | + public function menu_item() { |
|
1171 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1172 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1173 | + $this, |
|
1174 | + 'settings_page' |
|
1175 | + ) ); |
|
1176 | + } |
|
1177 | + |
|
1178 | + /** |
|
1179 | + * Get a list of themes and their default JS settings. |
|
1180 | + * |
|
1181 | + * @return array |
|
1182 | + */ |
|
1183 | + public function theme_js_settings(){ |
|
1184 | + return array( |
|
1185 | + 'ayetheme' => 'popper', |
|
1186 | + 'listimia' => 'required', |
|
1187 | + 'listimia_backend' => 'core-popper', |
|
1188 | + //'avada' => 'required', // removed as we now add compatibility |
|
1189 | + ); |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * Get the current Font Awesome output settings. |
|
1194 | + * |
|
1195 | + * @return array The array of settings. |
|
1196 | + */ |
|
1197 | + public function get_settings() { |
|
1198 | + |
|
1199 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1200 | + $js_default = 'core-popper'; |
|
1201 | + $js_default_backend = $js_default; |
|
1202 | + |
|
1203 | + // maybe set defaults (if no settings set) |
|
1204 | + if(empty($db_settings)){ |
|
1205 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
1206 | + $theme_js_settings = self::theme_js_settings(); |
|
1207 | + if(isset($theme_js_settings[$active_theme])){ |
|
1208 | + $js_default = $theme_js_settings[$active_theme]; |
|
1209 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1210 | + } |
|
1211 | + } |
|
1212 | + |
|
1213 | + $defaults = array( |
|
1214 | + 'css' => 'compatibility', // core, compatibility |
|
1215 | + 'js' => $js_default, // js to load, core-popper, popper |
|
1216 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
1217 | + 'css_backend' => 'compatibility', // core, compatibility |
|
1218 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1219 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1220 | + ); |
|
1221 | + |
|
1222 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * Filter the Bootstrap settings. |
|
1226 | + * |
|
1227 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1228 | + */ |
|
1229 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1230 | + } |
|
1231 | + |
|
1232 | + |
|
1233 | + /** |
|
1234 | + * The settings page html output. |
|
1235 | + */ |
|
1236 | + public function settings_page() { |
|
1237 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
1238 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1239 | + } |
|
1240 | + ?> |
|
1241 | 1241 | <div class="wrap"> |
1242 | 1242 | <h1><?php echo $this->name; ?></h1> |
1243 | 1243 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
1244 | 1244 | <form method="post" action="options.php"> |
1245 | 1245 | <?php |
1246 | - settings_fields( 'ayecode-ui-settings' ); |
|
1247 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1248 | - ?> |
|
1246 | + settings_fields( 'ayecode-ui-settings' ); |
|
1247 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
1248 | + ?> |
|
1249 | 1249 | |
1250 | 1250 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
1251 | 1251 | <table class="form-table wpbs-table-settings"> |
@@ -1325,60 +1325,60 @@ discard block |
||
1325 | 1325 | </table> |
1326 | 1326 | |
1327 | 1327 | <?php |
1328 | - submit_button(); |
|
1329 | - ?> |
|
1328 | + submit_button(); |
|
1329 | + ?> |
|
1330 | 1330 | </form> |
1331 | 1331 | |
1332 | 1332 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
1333 | 1333 | </div> |
1334 | 1334 | |
1335 | 1335 | <?php |
1336 | - } |
|
1337 | - |
|
1338 | - public function customizer_settings($wp_customize){ |
|
1339 | - $wp_customize->add_section('aui_settings', array( |
|
1340 | - 'title' => __('AyeCode UI','aui'), |
|
1341 | - 'priority' => 120, |
|
1342 | - )); |
|
1343 | - |
|
1344 | - // ============================= |
|
1345 | - // = Color Picker = |
|
1346 | - // ============================= |
|
1347 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1348 | - 'default' => AUI_PRIMARY_COLOR, |
|
1349 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1350 | - 'capability' => 'edit_theme_options', |
|
1351 | - 'type' => 'option', |
|
1352 | - 'transport' => 'refresh', |
|
1353 | - )); |
|
1354 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1355 | - 'label' => __('Primary Color','aui'), |
|
1356 | - 'section' => 'aui_settings', |
|
1357 | - 'settings' => 'aui_options[color_primary]', |
|
1358 | - ))); |
|
1359 | - |
|
1360 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1361 | - 'default' => '#6c757d', |
|
1362 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1363 | - 'capability' => 'edit_theme_options', |
|
1364 | - 'type' => 'option', |
|
1365 | - 'transport' => 'refresh', |
|
1366 | - )); |
|
1367 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1368 | - 'label' => __('Secondary Color','aui'), |
|
1369 | - 'section' => 'aui_settings', |
|
1370 | - 'settings' => 'aui_options[color_secondary]', |
|
1371 | - ))); |
|
1372 | - } |
|
1373 | - |
|
1374 | - /** |
|
1375 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1376 | - * |
|
1377 | - * @return mixed |
|
1378 | - */ |
|
1379 | - public static function bs3_compat_css() { |
|
1380 | - ob_start(); |
|
1381 | - ?> |
|
1336 | + } |
|
1337 | + |
|
1338 | + public function customizer_settings($wp_customize){ |
|
1339 | + $wp_customize->add_section('aui_settings', array( |
|
1340 | + 'title' => __('AyeCode UI','aui'), |
|
1341 | + 'priority' => 120, |
|
1342 | + )); |
|
1343 | + |
|
1344 | + // ============================= |
|
1345 | + // = Color Picker = |
|
1346 | + // ============================= |
|
1347 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1348 | + 'default' => AUI_PRIMARY_COLOR, |
|
1349 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1350 | + 'capability' => 'edit_theme_options', |
|
1351 | + 'type' => 'option', |
|
1352 | + 'transport' => 'refresh', |
|
1353 | + )); |
|
1354 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1355 | + 'label' => __('Primary Color','aui'), |
|
1356 | + 'section' => 'aui_settings', |
|
1357 | + 'settings' => 'aui_options[color_primary]', |
|
1358 | + ))); |
|
1359 | + |
|
1360 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1361 | + 'default' => '#6c757d', |
|
1362 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1363 | + 'capability' => 'edit_theme_options', |
|
1364 | + 'type' => 'option', |
|
1365 | + 'transport' => 'refresh', |
|
1366 | + )); |
|
1367 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1368 | + 'label' => __('Secondary Color','aui'), |
|
1369 | + 'section' => 'aui_settings', |
|
1370 | + 'settings' => 'aui_options[color_secondary]', |
|
1371 | + ))); |
|
1372 | + } |
|
1373 | + |
|
1374 | + /** |
|
1375 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1376 | + * |
|
1377 | + * @return mixed |
|
1378 | + */ |
|
1379 | + public static function bs3_compat_css() { |
|
1380 | + ob_start(); |
|
1381 | + ?> |
|
1382 | 1382 | <style> |
1383 | 1383 | /* Bootstrap 3 compatibility */ |
1384 | 1384 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1404,579 +1404,579 @@ discard block |
||
1404 | 1404 | <?php } ?> |
1405 | 1405 | </style> |
1406 | 1406 | <?php |
1407 | - return str_replace( array( |
|
1408 | - '<style>', |
|
1409 | - '</style>' |
|
1410 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1411 | - } |
|
1407 | + return str_replace( array( |
|
1408 | + '<style>', |
|
1409 | + '</style>' |
|
1410 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1411 | + } |
|
1412 | 1412 | |
1413 | 1413 | |
1414 | - public static function custom_css($compatibility = true) { |
|
1415 | - $settings = get_option('aui_options'); |
|
1414 | + public static function custom_css($compatibility = true) { |
|
1415 | + $settings = get_option('aui_options'); |
|
1416 | 1416 | |
1417 | - ob_start(); |
|
1417 | + ob_start(); |
|
1418 | 1418 | |
1419 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1420 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1421 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
1422 | - ?> |
|
1419 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1420 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1421 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
1422 | + ?> |
|
1423 | 1423 | <style> |
1424 | 1424 | <?php |
1425 | 1425 | |
1426 | - // BS v3 compat |
|
1427 | - if( self::is_bs3_compat() ){ |
|
1428 | - echo self::bs3_compat_css(); |
|
1429 | - } |
|
1426 | + // BS v3 compat |
|
1427 | + if( self::is_bs3_compat() ){ |
|
1428 | + echo self::bs3_compat_css(); |
|
1429 | + } |
|
1430 | 1430 | |
1431 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1432 | - echo self::css_primary($primary_color,$compatibility); |
|
1433 | - } |
|
1431 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1432 | + echo self::css_primary($primary_color,$compatibility); |
|
1433 | + } |
|
1434 | 1434 | |
1435 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1436 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1437 | - } |
|
1435 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1436 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1437 | + } |
|
1438 | 1438 | |
1439 | - // Set admin bar z-index lower when modal is open. |
|
1440 | - echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1439 | + // Set admin bar z-index lower when modal is open. |
|
1440 | + echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1441 | 1441 | ?> |
1442 | 1442 | </style> |
1443 | 1443 | <?php |
1444 | 1444 | |
1445 | 1445 | |
1446 | - /* |
|
1446 | + /* |
|
1447 | 1447 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1448 | 1448 | */ |
1449 | - return str_replace( array( |
|
1450 | - '<style>', |
|
1451 | - '</style>' |
|
1452 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * Check if we should add booststrap 3 compatibility changes. |
|
1457 | - * |
|
1458 | - * @return bool |
|
1459 | - */ |
|
1460 | - public static function is_bs3_compat(){ |
|
1461 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1462 | - } |
|
1463 | - |
|
1464 | - public static function css_primary($color_code,$compatibility){; |
|
1465 | - $color_code = sanitize_hex_color($color_code); |
|
1466 | - if(!$color_code){return '';} |
|
1467 | - /** |
|
1468 | - * c = color, b = background color, o = border-color, f = fill |
|
1469 | - */ |
|
1470 | - $selectors = array( |
|
1471 | - 'a' => array('c'), |
|
1472 | - '.btn-primary' => array('b','o'), |
|
1473 | - '.btn-primary.disabled' => array('b','o'), |
|
1474 | - '.btn-primary:disabled' => array('b','o'), |
|
1475 | - '.btn-outline-primary' => array('c','o'), |
|
1476 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1477 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1478 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1479 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1480 | - '.btn-link' => array('c'), |
|
1481 | - '.dropdown-item.active' => array('b'), |
|
1482 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1483 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1449 | + return str_replace( array( |
|
1450 | + '<style>', |
|
1451 | + '</style>' |
|
1452 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * Check if we should add booststrap 3 compatibility changes. |
|
1457 | + * |
|
1458 | + * @return bool |
|
1459 | + */ |
|
1460 | + public static function is_bs3_compat(){ |
|
1461 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1462 | + } |
|
1463 | + |
|
1464 | + public static function css_primary($color_code,$compatibility){; |
|
1465 | + $color_code = sanitize_hex_color($color_code); |
|
1466 | + if(!$color_code){return '';} |
|
1467 | + /** |
|
1468 | + * c = color, b = background color, o = border-color, f = fill |
|
1469 | + */ |
|
1470 | + $selectors = array( |
|
1471 | + 'a' => array('c'), |
|
1472 | + '.btn-primary' => array('b','o'), |
|
1473 | + '.btn-primary.disabled' => array('b','o'), |
|
1474 | + '.btn-primary:disabled' => array('b','o'), |
|
1475 | + '.btn-outline-primary' => array('c','o'), |
|
1476 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1477 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1478 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1479 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1480 | + '.btn-link' => array('c'), |
|
1481 | + '.dropdown-item.active' => array('b'), |
|
1482 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1483 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1484 | 1484 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1485 | 1485 | // '.custom-range::-moz-range-thumb' => array('b'), |
1486 | 1486 | // '.custom-range::-ms-thumb' => array('b'), |
1487 | - '.nav-pills .nav-link.active' => array('b'), |
|
1488 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1489 | - '.page-link' => array('c'), |
|
1490 | - '.page-item.active .page-link' => array('b','o'), |
|
1491 | - '.badge-primary' => array('b'), |
|
1492 | - '.alert-primary' => array('b','o'), |
|
1493 | - '.progress-bar' => array('b'), |
|
1494 | - '.list-group-item.active' => array('b','o'), |
|
1495 | - '.bg-primary' => array('b','f'), |
|
1496 | - '.btn-link.btn-primary' => array('c'), |
|
1497 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1498 | - ); |
|
1499 | - |
|
1500 | - $important_selectors = array( |
|
1501 | - '.bg-primary' => array('b','f'), |
|
1502 | - '.border-primary' => array('o'), |
|
1503 | - '.text-primary' => array('c'), |
|
1504 | - ); |
|
1505 | - |
|
1506 | - $color = array(); |
|
1507 | - $color_i = array(); |
|
1508 | - $background = array(); |
|
1509 | - $background_i = array(); |
|
1510 | - $border = array(); |
|
1511 | - $border_i = array(); |
|
1512 | - $fill = array(); |
|
1513 | - $fill_i = array(); |
|
1514 | - |
|
1515 | - $output = ''; |
|
1516 | - |
|
1517 | - // build rules into each type |
|
1518 | - foreach($selectors as $selector => $types){ |
|
1519 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1520 | - $types = array_combine($types,$types); |
|
1521 | - if(isset($types['c'])){$color[] = $selector;} |
|
1522 | - if(isset($types['b'])){$background[] = $selector;} |
|
1523 | - if(isset($types['o'])){$border[] = $selector;} |
|
1524 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1525 | - } |
|
1526 | - |
|
1527 | - // build rules into each type |
|
1528 | - foreach($important_selectors as $selector => $types){ |
|
1529 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1530 | - $types = array_combine($types,$types); |
|
1531 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1532 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1533 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1534 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1535 | - } |
|
1536 | - |
|
1537 | - // add any color rules |
|
1538 | - if(!empty($color)){ |
|
1539 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1540 | - } |
|
1541 | - if(!empty($color_i)){ |
|
1542 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1543 | - } |
|
1544 | - |
|
1545 | - // add any background color rules |
|
1546 | - if(!empty($background)){ |
|
1547 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1548 | - } |
|
1549 | - if(!empty($background_i)){ |
|
1550 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1551 | - } |
|
1552 | - |
|
1553 | - // add any border color rules |
|
1554 | - if(!empty($border)){ |
|
1555 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1556 | - } |
|
1557 | - if(!empty($border_i)){ |
|
1558 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1559 | - } |
|
1560 | - |
|
1561 | - // add any fill color rules |
|
1562 | - if(!empty($fill)){ |
|
1563 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1564 | - } |
|
1565 | - if(!empty($fill_i)){ |
|
1566 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1567 | - } |
|
1568 | - |
|
1569 | - |
|
1570 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1571 | - |
|
1572 | - // darken |
|
1573 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1574 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1575 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1576 | - |
|
1577 | - // lighten |
|
1578 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1579 | - |
|
1580 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1581 | - $op_25 = $color_code."40"; // 25% opacity |
|
1582 | - |
|
1583 | - |
|
1584 | - // button states |
|
1585 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1586 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1587 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1588 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1589 | - |
|
1590 | - |
|
1591 | - // dropdown's |
|
1592 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1593 | - |
|
1594 | - |
|
1595 | - // input states |
|
1596 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1597 | - |
|
1598 | - // page link |
|
1599 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1600 | - |
|
1601 | - return $output; |
|
1602 | - } |
|
1603 | - |
|
1604 | - public static function css_secondary($color_code,$compatibility){; |
|
1605 | - $color_code = sanitize_hex_color($color_code); |
|
1606 | - if(!$color_code){return '';} |
|
1607 | - /** |
|
1608 | - * c = color, b = background color, o = border-color, f = fill |
|
1609 | - */ |
|
1610 | - $selectors = array( |
|
1611 | - '.btn-secondary' => array('b','o'), |
|
1612 | - '.btn-secondary.disabled' => array('b','o'), |
|
1613 | - '.btn-secondary:disabled' => array('b','o'), |
|
1614 | - '.btn-outline-secondary' => array('c','o'), |
|
1615 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1616 | - '.btn-outline-secondary.disabled' => array('c'), |
|
1617 | - '.btn-outline-secondary:disabled' => array('c'), |
|
1618 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1619 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1620 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1621 | - '.badge-secondary' => array('b'), |
|
1622 | - '.alert-secondary' => array('b','o'), |
|
1623 | - '.btn-link.btn-secondary' => array('c'), |
|
1624 | - ); |
|
1625 | - |
|
1626 | - $important_selectors = array( |
|
1627 | - '.bg-secondary' => array('b','f'), |
|
1628 | - '.border-secondary' => array('o'), |
|
1629 | - '.text-secondary' => array('c'), |
|
1630 | - ); |
|
1631 | - |
|
1632 | - $color = array(); |
|
1633 | - $color_i = array(); |
|
1634 | - $background = array(); |
|
1635 | - $background_i = array(); |
|
1636 | - $border = array(); |
|
1637 | - $border_i = array(); |
|
1638 | - $fill = array(); |
|
1639 | - $fill_i = array(); |
|
1640 | - |
|
1641 | - $output = ''; |
|
1642 | - |
|
1643 | - // build rules into each type |
|
1644 | - foreach($selectors as $selector => $types){ |
|
1645 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1646 | - $types = array_combine($types,$types); |
|
1647 | - if(isset($types['c'])){$color[] = $selector;} |
|
1648 | - if(isset($types['b'])){$background[] = $selector;} |
|
1649 | - if(isset($types['o'])){$border[] = $selector;} |
|
1650 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1651 | - } |
|
1652 | - |
|
1653 | - // build rules into each type |
|
1654 | - foreach($important_selectors as $selector => $types){ |
|
1655 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1656 | - $types = array_combine($types,$types); |
|
1657 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1658 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1659 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1660 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1661 | - } |
|
1662 | - |
|
1663 | - // add any color rules |
|
1664 | - if(!empty($color)){ |
|
1665 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1666 | - } |
|
1667 | - if(!empty($color_i)){ |
|
1668 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1669 | - } |
|
1670 | - |
|
1671 | - // add any background color rules |
|
1672 | - if(!empty($background)){ |
|
1673 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1674 | - } |
|
1675 | - if(!empty($background_i)){ |
|
1676 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1677 | - } |
|
1678 | - |
|
1679 | - // add any border color rules |
|
1680 | - if(!empty($border)){ |
|
1681 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1682 | - } |
|
1683 | - if(!empty($border_i)){ |
|
1684 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1685 | - } |
|
1686 | - |
|
1687 | - // add any fill color rules |
|
1688 | - if(!empty($fill)){ |
|
1689 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1690 | - } |
|
1691 | - if(!empty($fill_i)){ |
|
1692 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1693 | - } |
|
1694 | - |
|
1695 | - |
|
1696 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1697 | - |
|
1698 | - // darken |
|
1699 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1700 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1701 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1702 | - |
|
1703 | - // lighten |
|
1704 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1705 | - |
|
1706 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1707 | - $op_25 = $color_code."40"; // 25% opacity |
|
1708 | - |
|
1709 | - |
|
1710 | - // button states |
|
1711 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1712 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1713 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1714 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1715 | - |
|
1716 | - |
|
1717 | - return $output; |
|
1718 | - } |
|
1719 | - |
|
1720 | - /** |
|
1721 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1722 | - * |
|
1723 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1724 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1725 | - * |
|
1726 | - * @return string |
|
1727 | - */ |
|
1728 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1729 | - $hexCode = ltrim($hexCode, '#'); |
|
1730 | - |
|
1731 | - if (strlen($hexCode) == 3) { |
|
1732 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1733 | - } |
|
1734 | - |
|
1735 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1736 | - |
|
1737 | - foreach ($hexCode as & $color) { |
|
1738 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1739 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1740 | - |
|
1741 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1742 | - } |
|
1743 | - |
|
1744 | - return '#' . implode($hexCode); |
|
1745 | - } |
|
1746 | - |
|
1747 | - /** |
|
1748 | - * Check if we should display examples. |
|
1749 | - */ |
|
1750 | - public function maybe_show_examples(){ |
|
1751 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1752 | - echo "<head>"; |
|
1753 | - wp_head(); |
|
1754 | - echo "</head>"; |
|
1755 | - echo "<body>"; |
|
1756 | - echo $this->get_examples(); |
|
1757 | - echo "</body>"; |
|
1758 | - exit; |
|
1759 | - } |
|
1760 | - } |
|
1761 | - |
|
1762 | - /** |
|
1763 | - * Get developer examples. |
|
1764 | - * |
|
1765 | - * @return string |
|
1766 | - */ |
|
1767 | - public function get_examples(){ |
|
1768 | - $output = ''; |
|
1769 | - |
|
1770 | - |
|
1771 | - // open form |
|
1772 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1773 | - |
|
1774 | - // input example |
|
1775 | - $output .= aui()->input(array( |
|
1776 | - 'type' => 'text', |
|
1777 | - 'id' => 'text-example', |
|
1778 | - 'name' => 'text-example', |
|
1779 | - 'placeholder' => 'text placeholder', |
|
1780 | - 'title' => 'Text input example', |
|
1781 | - 'value' => '', |
|
1782 | - 'required' => false, |
|
1783 | - 'help_text' => 'help text', |
|
1784 | - 'label' => 'Text input example label' |
|
1785 | - )); |
|
1786 | - |
|
1787 | - // input example |
|
1788 | - $output .= aui()->input(array( |
|
1789 | - 'type' => 'url', |
|
1790 | - 'id' => 'text-example2', |
|
1791 | - 'name' => 'text-example', |
|
1792 | - 'placeholder' => 'url placeholder', |
|
1793 | - 'title' => 'Text input example', |
|
1794 | - 'value' => '', |
|
1795 | - 'required' => false, |
|
1796 | - 'help_text' => 'help text', |
|
1797 | - 'label' => 'Text input example label' |
|
1798 | - )); |
|
1799 | - |
|
1800 | - // checkbox example |
|
1801 | - $output .= aui()->input(array( |
|
1802 | - 'type' => 'checkbox', |
|
1803 | - 'id' => 'checkbox-example', |
|
1804 | - 'name' => 'checkbox-example', |
|
1805 | - 'placeholder' => 'checkbox-example', |
|
1806 | - 'title' => 'Checkbox example', |
|
1807 | - 'value' => '1', |
|
1808 | - 'checked' => true, |
|
1809 | - 'required' => false, |
|
1810 | - 'help_text' => 'help text', |
|
1811 | - 'label' => 'Checkbox checked' |
|
1812 | - )); |
|
1813 | - |
|
1814 | - // checkbox example |
|
1815 | - $output .= aui()->input(array( |
|
1816 | - 'type' => 'checkbox', |
|
1817 | - 'id' => 'checkbox-example2', |
|
1818 | - 'name' => 'checkbox-example2', |
|
1819 | - 'placeholder' => 'checkbox-example', |
|
1820 | - 'title' => 'Checkbox example', |
|
1821 | - 'value' => '1', |
|
1822 | - 'checked' => false, |
|
1823 | - 'required' => false, |
|
1824 | - 'help_text' => 'help text', |
|
1825 | - 'label' => 'Checkbox un-checked' |
|
1826 | - )); |
|
1827 | - |
|
1828 | - // switch example |
|
1829 | - $output .= aui()->input(array( |
|
1830 | - 'type' => 'checkbox', |
|
1831 | - 'id' => 'switch-example', |
|
1832 | - 'name' => 'switch-example', |
|
1833 | - 'placeholder' => 'checkbox-example', |
|
1834 | - 'title' => 'Switch example', |
|
1835 | - 'value' => '1', |
|
1836 | - 'checked' => true, |
|
1837 | - 'switch' => true, |
|
1838 | - 'required' => false, |
|
1839 | - 'help_text' => 'help text', |
|
1840 | - 'label' => 'Switch on' |
|
1841 | - )); |
|
1842 | - |
|
1843 | - // switch example |
|
1844 | - $output .= aui()->input(array( |
|
1845 | - 'type' => 'checkbox', |
|
1846 | - 'id' => 'switch-example2', |
|
1847 | - 'name' => 'switch-example2', |
|
1848 | - 'placeholder' => 'checkbox-example', |
|
1849 | - 'title' => 'Switch example', |
|
1850 | - 'value' => '1', |
|
1851 | - 'checked' => false, |
|
1852 | - 'switch' => true, |
|
1853 | - 'required' => false, |
|
1854 | - 'help_text' => 'help text', |
|
1855 | - 'label' => 'Switch off' |
|
1856 | - )); |
|
1857 | - |
|
1858 | - // close form |
|
1859 | - $output .= "</form>"; |
|
1860 | - |
|
1861 | - return $output; |
|
1862 | - } |
|
1863 | - |
|
1864 | - /** |
|
1865 | - * Calendar params. |
|
1866 | - * |
|
1867 | - * @since 0.1.44 |
|
1868 | - * |
|
1869 | - * @return array Calendar params. |
|
1870 | - */ |
|
1871 | - public static function calendar_params() { |
|
1872 | - $params = array( |
|
1873 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1874 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1875 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1876 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1877 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1878 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1879 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1880 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1881 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1882 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1883 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1884 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1885 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1886 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1887 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1888 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1889 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1890 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1891 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1892 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1893 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1894 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1895 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1896 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1897 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1898 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1899 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1900 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1901 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1902 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1903 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1904 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1905 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1906 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1907 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1908 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1909 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1910 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1911 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1912 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1913 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1914 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1915 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1916 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1917 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1918 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1919 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1920 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1921 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1922 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1923 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1924 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1925 | - 'am_lower' => __( 'am', 'aui' ), |
|
1926 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1927 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1928 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1929 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1930 | - 'time_24hr' => false, |
|
1931 | - 'year' => __( 'Year', 'aui' ), |
|
1932 | - 'hour' => __( 'Hour', 'aui' ), |
|
1933 | - 'minute' => __( 'Minute', 'aui' ), |
|
1934 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1935 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1936 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1937 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1938 | - ); |
|
1939 | - |
|
1940 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1941 | - } |
|
1942 | - |
|
1943 | - /** |
|
1944 | - * Flatpickr calendar localize. |
|
1945 | - * |
|
1946 | - * @since 0.1.44 |
|
1947 | - * |
|
1948 | - * @return string Calendar locale. |
|
1949 | - */ |
|
1950 | - public static function flatpickr_locale() { |
|
1951 | - $params = self::calendar_params(); |
|
1952 | - |
|
1953 | - if ( is_string( $params ) ) { |
|
1954 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1955 | - } else { |
|
1956 | - foreach ( (array) $params as $key => $value ) { |
|
1957 | - if ( ! is_scalar( $value ) ) { |
|
1958 | - continue; |
|
1959 | - } |
|
1960 | - |
|
1961 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1962 | - } |
|
1963 | - } |
|
1487 | + '.nav-pills .nav-link.active' => array('b'), |
|
1488 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1489 | + '.page-link' => array('c'), |
|
1490 | + '.page-item.active .page-link' => array('b','o'), |
|
1491 | + '.badge-primary' => array('b'), |
|
1492 | + '.alert-primary' => array('b','o'), |
|
1493 | + '.progress-bar' => array('b'), |
|
1494 | + '.list-group-item.active' => array('b','o'), |
|
1495 | + '.bg-primary' => array('b','f'), |
|
1496 | + '.btn-link.btn-primary' => array('c'), |
|
1497 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1498 | + ); |
|
1499 | + |
|
1500 | + $important_selectors = array( |
|
1501 | + '.bg-primary' => array('b','f'), |
|
1502 | + '.border-primary' => array('o'), |
|
1503 | + '.text-primary' => array('c'), |
|
1504 | + ); |
|
1505 | + |
|
1506 | + $color = array(); |
|
1507 | + $color_i = array(); |
|
1508 | + $background = array(); |
|
1509 | + $background_i = array(); |
|
1510 | + $border = array(); |
|
1511 | + $border_i = array(); |
|
1512 | + $fill = array(); |
|
1513 | + $fill_i = array(); |
|
1514 | + |
|
1515 | + $output = ''; |
|
1516 | + |
|
1517 | + // build rules into each type |
|
1518 | + foreach($selectors as $selector => $types){ |
|
1519 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1520 | + $types = array_combine($types,$types); |
|
1521 | + if(isset($types['c'])){$color[] = $selector;} |
|
1522 | + if(isset($types['b'])){$background[] = $selector;} |
|
1523 | + if(isset($types['o'])){$border[] = $selector;} |
|
1524 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1525 | + } |
|
1526 | + |
|
1527 | + // build rules into each type |
|
1528 | + foreach($important_selectors as $selector => $types){ |
|
1529 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1530 | + $types = array_combine($types,$types); |
|
1531 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1532 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1533 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1534 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1535 | + } |
|
1536 | + |
|
1537 | + // add any color rules |
|
1538 | + if(!empty($color)){ |
|
1539 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1540 | + } |
|
1541 | + if(!empty($color_i)){ |
|
1542 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1543 | + } |
|
1544 | + |
|
1545 | + // add any background color rules |
|
1546 | + if(!empty($background)){ |
|
1547 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1548 | + } |
|
1549 | + if(!empty($background_i)){ |
|
1550 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1551 | + } |
|
1552 | + |
|
1553 | + // add any border color rules |
|
1554 | + if(!empty($border)){ |
|
1555 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1556 | + } |
|
1557 | + if(!empty($border_i)){ |
|
1558 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1559 | + } |
|
1560 | + |
|
1561 | + // add any fill color rules |
|
1562 | + if(!empty($fill)){ |
|
1563 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1564 | + } |
|
1565 | + if(!empty($fill_i)){ |
|
1566 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1567 | + } |
|
1568 | + |
|
1569 | + |
|
1570 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1571 | + |
|
1572 | + // darken |
|
1573 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1574 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1575 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1576 | + |
|
1577 | + // lighten |
|
1578 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1579 | + |
|
1580 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1581 | + $op_25 = $color_code."40"; // 25% opacity |
|
1582 | + |
|
1583 | + |
|
1584 | + // button states |
|
1585 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1586 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1587 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1588 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1589 | + |
|
1590 | + |
|
1591 | + // dropdown's |
|
1592 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1593 | + |
|
1594 | + |
|
1595 | + // input states |
|
1596 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1597 | + |
|
1598 | + // page link |
|
1599 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1600 | + |
|
1601 | + return $output; |
|
1602 | + } |
|
1603 | + |
|
1604 | + public static function css_secondary($color_code,$compatibility){; |
|
1605 | + $color_code = sanitize_hex_color($color_code); |
|
1606 | + if(!$color_code){return '';} |
|
1607 | + /** |
|
1608 | + * c = color, b = background color, o = border-color, f = fill |
|
1609 | + */ |
|
1610 | + $selectors = array( |
|
1611 | + '.btn-secondary' => array('b','o'), |
|
1612 | + '.btn-secondary.disabled' => array('b','o'), |
|
1613 | + '.btn-secondary:disabled' => array('b','o'), |
|
1614 | + '.btn-outline-secondary' => array('c','o'), |
|
1615 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
1616 | + '.btn-outline-secondary.disabled' => array('c'), |
|
1617 | + '.btn-outline-secondary:disabled' => array('c'), |
|
1618 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1619 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1620 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1621 | + '.badge-secondary' => array('b'), |
|
1622 | + '.alert-secondary' => array('b','o'), |
|
1623 | + '.btn-link.btn-secondary' => array('c'), |
|
1624 | + ); |
|
1625 | + |
|
1626 | + $important_selectors = array( |
|
1627 | + '.bg-secondary' => array('b','f'), |
|
1628 | + '.border-secondary' => array('o'), |
|
1629 | + '.text-secondary' => array('c'), |
|
1630 | + ); |
|
1631 | + |
|
1632 | + $color = array(); |
|
1633 | + $color_i = array(); |
|
1634 | + $background = array(); |
|
1635 | + $background_i = array(); |
|
1636 | + $border = array(); |
|
1637 | + $border_i = array(); |
|
1638 | + $fill = array(); |
|
1639 | + $fill_i = array(); |
|
1640 | + |
|
1641 | + $output = ''; |
|
1642 | + |
|
1643 | + // build rules into each type |
|
1644 | + foreach($selectors as $selector => $types){ |
|
1645 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1646 | + $types = array_combine($types,$types); |
|
1647 | + if(isset($types['c'])){$color[] = $selector;} |
|
1648 | + if(isset($types['b'])){$background[] = $selector;} |
|
1649 | + if(isset($types['o'])){$border[] = $selector;} |
|
1650 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1651 | + } |
|
1652 | + |
|
1653 | + // build rules into each type |
|
1654 | + foreach($important_selectors as $selector => $types){ |
|
1655 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1656 | + $types = array_combine($types,$types); |
|
1657 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1658 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1659 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1660 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1661 | + } |
|
1662 | + |
|
1663 | + // add any color rules |
|
1664 | + if(!empty($color)){ |
|
1665 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1666 | + } |
|
1667 | + if(!empty($color_i)){ |
|
1668 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1669 | + } |
|
1670 | + |
|
1671 | + // add any background color rules |
|
1672 | + if(!empty($background)){ |
|
1673 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1674 | + } |
|
1675 | + if(!empty($background_i)){ |
|
1676 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1677 | + } |
|
1678 | + |
|
1679 | + // add any border color rules |
|
1680 | + if(!empty($border)){ |
|
1681 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1682 | + } |
|
1683 | + if(!empty($border_i)){ |
|
1684 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1685 | + } |
|
1686 | + |
|
1687 | + // add any fill color rules |
|
1688 | + if(!empty($fill)){ |
|
1689 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1690 | + } |
|
1691 | + if(!empty($fill_i)){ |
|
1692 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1693 | + } |
|
1694 | + |
|
1695 | + |
|
1696 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1697 | + |
|
1698 | + // darken |
|
1699 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1700 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1701 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1702 | + |
|
1703 | + // lighten |
|
1704 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1705 | + |
|
1706 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1707 | + $op_25 = $color_code."40"; // 25% opacity |
|
1708 | + |
|
1709 | + |
|
1710 | + // button states |
|
1711 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1712 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1713 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1714 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1715 | + |
|
1716 | + |
|
1717 | + return $output; |
|
1718 | + } |
|
1719 | + |
|
1720 | + /** |
|
1721 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1722 | + * |
|
1723 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1724 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1725 | + * |
|
1726 | + * @return string |
|
1727 | + */ |
|
1728 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1729 | + $hexCode = ltrim($hexCode, '#'); |
|
1730 | + |
|
1731 | + if (strlen($hexCode) == 3) { |
|
1732 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1733 | + } |
|
1734 | + |
|
1735 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1736 | + |
|
1737 | + foreach ($hexCode as & $color) { |
|
1738 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1739 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1740 | + |
|
1741 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1742 | + } |
|
1743 | + |
|
1744 | + return '#' . implode($hexCode); |
|
1745 | + } |
|
1746 | + |
|
1747 | + /** |
|
1748 | + * Check if we should display examples. |
|
1749 | + */ |
|
1750 | + public function maybe_show_examples(){ |
|
1751 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1752 | + echo "<head>"; |
|
1753 | + wp_head(); |
|
1754 | + echo "</head>"; |
|
1755 | + echo "<body>"; |
|
1756 | + echo $this->get_examples(); |
|
1757 | + echo "</body>"; |
|
1758 | + exit; |
|
1759 | + } |
|
1760 | + } |
|
1761 | + |
|
1762 | + /** |
|
1763 | + * Get developer examples. |
|
1764 | + * |
|
1765 | + * @return string |
|
1766 | + */ |
|
1767 | + public function get_examples(){ |
|
1768 | + $output = ''; |
|
1769 | + |
|
1770 | + |
|
1771 | + // open form |
|
1772 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1773 | + |
|
1774 | + // input example |
|
1775 | + $output .= aui()->input(array( |
|
1776 | + 'type' => 'text', |
|
1777 | + 'id' => 'text-example', |
|
1778 | + 'name' => 'text-example', |
|
1779 | + 'placeholder' => 'text placeholder', |
|
1780 | + 'title' => 'Text input example', |
|
1781 | + 'value' => '', |
|
1782 | + 'required' => false, |
|
1783 | + 'help_text' => 'help text', |
|
1784 | + 'label' => 'Text input example label' |
|
1785 | + )); |
|
1786 | + |
|
1787 | + // input example |
|
1788 | + $output .= aui()->input(array( |
|
1789 | + 'type' => 'url', |
|
1790 | + 'id' => 'text-example2', |
|
1791 | + 'name' => 'text-example', |
|
1792 | + 'placeholder' => 'url placeholder', |
|
1793 | + 'title' => 'Text input example', |
|
1794 | + 'value' => '', |
|
1795 | + 'required' => false, |
|
1796 | + 'help_text' => 'help text', |
|
1797 | + 'label' => 'Text input example label' |
|
1798 | + )); |
|
1799 | + |
|
1800 | + // checkbox example |
|
1801 | + $output .= aui()->input(array( |
|
1802 | + 'type' => 'checkbox', |
|
1803 | + 'id' => 'checkbox-example', |
|
1804 | + 'name' => 'checkbox-example', |
|
1805 | + 'placeholder' => 'checkbox-example', |
|
1806 | + 'title' => 'Checkbox example', |
|
1807 | + 'value' => '1', |
|
1808 | + 'checked' => true, |
|
1809 | + 'required' => false, |
|
1810 | + 'help_text' => 'help text', |
|
1811 | + 'label' => 'Checkbox checked' |
|
1812 | + )); |
|
1813 | + |
|
1814 | + // checkbox example |
|
1815 | + $output .= aui()->input(array( |
|
1816 | + 'type' => 'checkbox', |
|
1817 | + 'id' => 'checkbox-example2', |
|
1818 | + 'name' => 'checkbox-example2', |
|
1819 | + 'placeholder' => 'checkbox-example', |
|
1820 | + 'title' => 'Checkbox example', |
|
1821 | + 'value' => '1', |
|
1822 | + 'checked' => false, |
|
1823 | + 'required' => false, |
|
1824 | + 'help_text' => 'help text', |
|
1825 | + 'label' => 'Checkbox un-checked' |
|
1826 | + )); |
|
1827 | + |
|
1828 | + // switch example |
|
1829 | + $output .= aui()->input(array( |
|
1830 | + 'type' => 'checkbox', |
|
1831 | + 'id' => 'switch-example', |
|
1832 | + 'name' => 'switch-example', |
|
1833 | + 'placeholder' => 'checkbox-example', |
|
1834 | + 'title' => 'Switch example', |
|
1835 | + 'value' => '1', |
|
1836 | + 'checked' => true, |
|
1837 | + 'switch' => true, |
|
1838 | + 'required' => false, |
|
1839 | + 'help_text' => 'help text', |
|
1840 | + 'label' => 'Switch on' |
|
1841 | + )); |
|
1842 | + |
|
1843 | + // switch example |
|
1844 | + $output .= aui()->input(array( |
|
1845 | + 'type' => 'checkbox', |
|
1846 | + 'id' => 'switch-example2', |
|
1847 | + 'name' => 'switch-example2', |
|
1848 | + 'placeholder' => 'checkbox-example', |
|
1849 | + 'title' => 'Switch example', |
|
1850 | + 'value' => '1', |
|
1851 | + 'checked' => false, |
|
1852 | + 'switch' => true, |
|
1853 | + 'required' => false, |
|
1854 | + 'help_text' => 'help text', |
|
1855 | + 'label' => 'Switch off' |
|
1856 | + )); |
|
1857 | + |
|
1858 | + // close form |
|
1859 | + $output .= "</form>"; |
|
1860 | + |
|
1861 | + return $output; |
|
1862 | + } |
|
1863 | + |
|
1864 | + /** |
|
1865 | + * Calendar params. |
|
1866 | + * |
|
1867 | + * @since 0.1.44 |
|
1868 | + * |
|
1869 | + * @return array Calendar params. |
|
1870 | + */ |
|
1871 | + public static function calendar_params() { |
|
1872 | + $params = array( |
|
1873 | + 'month_long_1' => __( 'January', 'aui' ), |
|
1874 | + 'month_long_2' => __( 'February', 'aui' ), |
|
1875 | + 'month_long_3' => __( 'March', 'aui' ), |
|
1876 | + 'month_long_4' => __( 'April', 'aui' ), |
|
1877 | + 'month_long_5' => __( 'May', 'aui' ), |
|
1878 | + 'month_long_6' => __( 'June', 'aui' ), |
|
1879 | + 'month_long_7' => __( 'July', 'aui' ), |
|
1880 | + 'month_long_8' => __( 'August', 'aui' ), |
|
1881 | + 'month_long_9' => __( 'September', 'aui' ), |
|
1882 | + 'month_long_10' => __( 'October', 'aui' ), |
|
1883 | + 'month_long_11' => __( 'November', 'aui' ), |
|
1884 | + 'month_long_12' => __( 'December', 'aui' ), |
|
1885 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1886 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1887 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1888 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1889 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1890 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1891 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1892 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1893 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1894 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1895 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1896 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1897 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1898 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1899 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1900 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1901 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1902 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1903 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1904 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
1905 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1906 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1907 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
1908 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
1909 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1910 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1911 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1912 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1913 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1914 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1915 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1916 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1917 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1918 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1919 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1920 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1921 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1922 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1923 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1924 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1925 | + 'am_lower' => __( 'am', 'aui' ), |
|
1926 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
1927 | + 'am_upper' => __( 'AM', 'aui' ), |
|
1928 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
1929 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1930 | + 'time_24hr' => false, |
|
1931 | + 'year' => __( 'Year', 'aui' ), |
|
1932 | + 'hour' => __( 'Hour', 'aui' ), |
|
1933 | + 'minute' => __( 'Minute', 'aui' ), |
|
1934 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1935 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1936 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1937 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1938 | + ); |
|
1939 | + |
|
1940 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1941 | + } |
|
1942 | + |
|
1943 | + /** |
|
1944 | + * Flatpickr calendar localize. |
|
1945 | + * |
|
1946 | + * @since 0.1.44 |
|
1947 | + * |
|
1948 | + * @return string Calendar locale. |
|
1949 | + */ |
|
1950 | + public static function flatpickr_locale() { |
|
1951 | + $params = self::calendar_params(); |
|
1952 | + |
|
1953 | + if ( is_string( $params ) ) { |
|
1954 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1955 | + } else { |
|
1956 | + foreach ( (array) $params as $key => $value ) { |
|
1957 | + if ( ! is_scalar( $value ) ) { |
|
1958 | + continue; |
|
1959 | + } |
|
1960 | + |
|
1961 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1962 | + } |
|
1963 | + } |
|
1964 | 1964 | |
1965 | - $day_s3 = array(); |
|
1966 | - $day_s5 = array(); |
|
1965 | + $day_s3 = array(); |
|
1966 | + $day_s5 = array(); |
|
1967 | 1967 | |
1968 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1969 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1970 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1971 | - } |
|
1968 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
1969 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1970 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1971 | + } |
|
1972 | 1972 | |
1973 | - $month_s = array(); |
|
1974 | - $month_long = array(); |
|
1973 | + $month_s = array(); |
|
1974 | + $month_long = array(); |
|
1975 | 1975 | |
1976 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1977 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1978 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1979 | - } |
|
1976 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
1977 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1978 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1979 | + } |
|
1980 | 1980 | |
1981 | 1981 | ob_start(); |
1982 | 1982 | if ( 0 ) { ?><script><?php } ?> |
@@ -2018,184 +2018,184 @@ discard block |
||
2018 | 2018 | } |
2019 | 2019 | <?php if ( 0 ) { ?></script><?php } ?> |
2020 | 2020 | <?php |
2021 | - $locale = ob_get_clean(); |
|
2022 | - |
|
2023 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2024 | - } |
|
2025 | - |
|
2026 | - /** |
|
2027 | - * Select2 JS params. |
|
2028 | - * |
|
2029 | - * @since 0.1.44 |
|
2030 | - * |
|
2031 | - * @return array Select2 JS params. |
|
2032 | - */ |
|
2033 | - public static function select2_params() { |
|
2034 | - $params = array( |
|
2035 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2036 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2037 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2038 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2039 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2040 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2041 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2042 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2043 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2044 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2045 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2046 | - ); |
|
2047 | - |
|
2048 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2049 | - } |
|
2050 | - |
|
2051 | - /** |
|
2052 | - * Select2 JS localize. |
|
2053 | - * |
|
2054 | - * @since 0.1.44 |
|
2055 | - * |
|
2056 | - * @return string Select2 JS locale. |
|
2057 | - */ |
|
2058 | - public static function select2_locale() { |
|
2059 | - $params = self::select2_params(); |
|
2060 | - |
|
2061 | - foreach ( (array) $params as $key => $value ) { |
|
2062 | - if ( ! is_scalar( $value ) ) { |
|
2063 | - continue; |
|
2064 | - } |
|
2065 | - |
|
2066 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2067 | - } |
|
2068 | - |
|
2069 | - $locale = json_encode( $params ); |
|
2070 | - |
|
2071 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2072 | - } |
|
2073 | - |
|
2074 | - /** |
|
2075 | - * Time ago JS localize. |
|
2076 | - * |
|
2077 | - * @since 0.1.47 |
|
2078 | - * |
|
2079 | - * @return string Time ago JS locale. |
|
2080 | - */ |
|
2081 | - public static function timeago_locale() { |
|
2082 | - $params = array( |
|
2083 | - 'prefix_ago' => '', |
|
2084 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2085 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2086 | - 'suffix_after' => '', |
|
2087 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2088 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2089 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2090 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2091 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2092 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2093 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2094 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2095 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2096 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2097 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2098 | - ); |
|
2099 | - |
|
2100 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2101 | - |
|
2102 | - foreach ( (array) $params as $key => $value ) { |
|
2103 | - if ( ! is_scalar( $value ) ) { |
|
2104 | - continue; |
|
2105 | - } |
|
2106 | - |
|
2107 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2108 | - } |
|
2109 | - |
|
2110 | - $locale = json_encode( $params ); |
|
2111 | - |
|
2112 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2113 | - } |
|
2114 | - |
|
2115 | - /** |
|
2116 | - * JavaScript Minifier |
|
2117 | - * |
|
2118 | - * @param $input |
|
2119 | - * |
|
2120 | - * @return mixed |
|
2121 | - */ |
|
2122 | - public static function minify_js($input) { |
|
2123 | - if(trim($input) === "") return $input; |
|
2124 | - return preg_replace( |
|
2125 | - array( |
|
2126 | - // Remove comment(s) |
|
2127 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2128 | - // Remove white-space(s) outside the string and regex |
|
2129 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2130 | - // Remove the last semicolon |
|
2131 | - '#;+\}#', |
|
2132 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2133 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2134 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2135 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2136 | - ), |
|
2137 | - array( |
|
2138 | - '$1', |
|
2139 | - '$1$2', |
|
2140 | - '}', |
|
2141 | - '$1$3', |
|
2142 | - '$1.$3' |
|
2143 | - ), |
|
2144 | - $input); |
|
2145 | - } |
|
2021 | + $locale = ob_get_clean(); |
|
2022 | + |
|
2023 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2024 | + } |
|
2025 | + |
|
2026 | + /** |
|
2027 | + * Select2 JS params. |
|
2028 | + * |
|
2029 | + * @since 0.1.44 |
|
2030 | + * |
|
2031 | + * @return array Select2 JS params. |
|
2032 | + */ |
|
2033 | + public static function select2_params() { |
|
2034 | + $params = array( |
|
2035 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2036 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2037 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2038 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2039 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2040 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2041 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2042 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2043 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2044 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2045 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2046 | + ); |
|
2047 | + |
|
2048 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2049 | + } |
|
2050 | + |
|
2051 | + /** |
|
2052 | + * Select2 JS localize. |
|
2053 | + * |
|
2054 | + * @since 0.1.44 |
|
2055 | + * |
|
2056 | + * @return string Select2 JS locale. |
|
2057 | + */ |
|
2058 | + public static function select2_locale() { |
|
2059 | + $params = self::select2_params(); |
|
2060 | + |
|
2061 | + foreach ( (array) $params as $key => $value ) { |
|
2062 | + if ( ! is_scalar( $value ) ) { |
|
2063 | + continue; |
|
2064 | + } |
|
2146 | 2065 | |
2147 | - /** |
|
2148 | - * Minify CSS |
|
2149 | - * |
|
2150 | - * @param $input |
|
2151 | - * |
|
2152 | - * @return mixed |
|
2153 | - */ |
|
2154 | - public static function minify_css($input) { |
|
2155 | - if(trim($input) === "") return $input; |
|
2156 | - return preg_replace( |
|
2157 | - array( |
|
2158 | - // Remove comment(s) |
|
2159 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2160 | - // Remove unused white-space(s) |
|
2161 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2162 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2163 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2164 | - // Replace `:0 0 0 0` with `:0` |
|
2165 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2166 | - // Replace `background-position:0` with `background-position:0 0` |
|
2167 | - '#(background-position):0(?=[;\}])#si', |
|
2168 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2169 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2170 | - // Minify string value |
|
2171 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2172 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2173 | - // Minify HEX color code |
|
2174 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2175 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2176 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2177 | - // Remove empty selector(s) |
|
2178 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2179 | - ), |
|
2180 | - array( |
|
2181 | - '$1', |
|
2182 | - '$1$2$3$4$5$6$7', |
|
2183 | - '$1', |
|
2184 | - ':0', |
|
2185 | - '$1:0 0', |
|
2186 | - '.$1', |
|
2187 | - '$1$3', |
|
2188 | - '$1$2$4$5', |
|
2189 | - '$1$2$3', |
|
2190 | - '$1:0', |
|
2191 | - '$1$2' |
|
2192 | - ), |
|
2193 | - $input); |
|
2194 | - } |
|
2195 | - } |
|
2066 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2067 | + } |
|
2068 | + |
|
2069 | + $locale = json_encode( $params ); |
|
2070 | + |
|
2071 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2072 | + } |
|
2073 | + |
|
2074 | + /** |
|
2075 | + * Time ago JS localize. |
|
2076 | + * |
|
2077 | + * @since 0.1.47 |
|
2078 | + * |
|
2079 | + * @return string Time ago JS locale. |
|
2080 | + */ |
|
2081 | + public static function timeago_locale() { |
|
2082 | + $params = array( |
|
2083 | + 'prefix_ago' => '', |
|
2084 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2085 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2086 | + 'suffix_after' => '', |
|
2087 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2088 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2089 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2090 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2091 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2092 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2093 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2094 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2095 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2096 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2097 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2098 | + ); |
|
2099 | + |
|
2100 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2101 | + |
|
2102 | + foreach ( (array) $params as $key => $value ) { |
|
2103 | + if ( ! is_scalar( $value ) ) { |
|
2104 | + continue; |
|
2105 | + } |
|
2196 | 2106 | |
2197 | - /** |
|
2198 | - * Run the class if found. |
|
2199 | - */ |
|
2200 | - AyeCode_UI_Settings::instance(); |
|
2107 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2108 | + } |
|
2109 | + |
|
2110 | + $locale = json_encode( $params ); |
|
2111 | + |
|
2112 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2113 | + } |
|
2114 | + |
|
2115 | + /** |
|
2116 | + * JavaScript Minifier |
|
2117 | + * |
|
2118 | + * @param $input |
|
2119 | + * |
|
2120 | + * @return mixed |
|
2121 | + */ |
|
2122 | + public static function minify_js($input) { |
|
2123 | + if(trim($input) === "") return $input; |
|
2124 | + return preg_replace( |
|
2125 | + array( |
|
2126 | + // Remove comment(s) |
|
2127 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2128 | + // Remove white-space(s) outside the string and regex |
|
2129 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2130 | + // Remove the last semicolon |
|
2131 | + '#;+\}#', |
|
2132 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2133 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2134 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2135 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2136 | + ), |
|
2137 | + array( |
|
2138 | + '$1', |
|
2139 | + '$1$2', |
|
2140 | + '}', |
|
2141 | + '$1$3', |
|
2142 | + '$1.$3' |
|
2143 | + ), |
|
2144 | + $input); |
|
2145 | + } |
|
2146 | + |
|
2147 | + /** |
|
2148 | + * Minify CSS |
|
2149 | + * |
|
2150 | + * @param $input |
|
2151 | + * |
|
2152 | + * @return mixed |
|
2153 | + */ |
|
2154 | + public static function minify_css($input) { |
|
2155 | + if(trim($input) === "") return $input; |
|
2156 | + return preg_replace( |
|
2157 | + array( |
|
2158 | + // Remove comment(s) |
|
2159 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2160 | + // Remove unused white-space(s) |
|
2161 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2162 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2163 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2164 | + // Replace `:0 0 0 0` with `:0` |
|
2165 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2166 | + // Replace `background-position:0` with `background-position:0 0` |
|
2167 | + '#(background-position):0(?=[;\}])#si', |
|
2168 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2169 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2170 | + // Minify string value |
|
2171 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2172 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2173 | + // Minify HEX color code |
|
2174 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2175 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2176 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2177 | + // Remove empty selector(s) |
|
2178 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2179 | + ), |
|
2180 | + array( |
|
2181 | + '$1', |
|
2182 | + '$1$2$3$4$5$6$7', |
|
2183 | + '$1', |
|
2184 | + ':0', |
|
2185 | + '$1:0 0', |
|
2186 | + '.$1', |
|
2187 | + '$1$3', |
|
2188 | + '$1$2$4$5', |
|
2189 | + '$1$2$3', |
|
2190 | + '$1:0', |
|
2191 | + '$1$2' |
|
2192 | + ), |
|
2193 | + $input); |
|
2194 | + } |
|
2195 | + } |
|
2196 | + |
|
2197 | + /** |
|
2198 | + * Run the class if found. |
|
2199 | + */ |
|
2200 | + AyeCode_UI_Settings::instance(); |
|
2201 | 2201 | } |
2202 | 2202 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | 178 | // check if specifically disabled |
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
179 | + if (!empty($this->settings['disable_admin'])) { |
|
180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
181 | + foreach ($url_parts as $part) { |
|
182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
183 | 183 | return false; // return early, no point checking further |
184 | 184 | } |
185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * Add a html font size to the footer. |
193 | 193 | */ |
194 | - public function html_font_size(){ |
|
194 | + public function html_font_size() { |
|
195 | 195 | $this->settings = $this->get_settings(); |
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - public function is_aui_screen(){ |
|
204 | + public function is_aui_screen() { |
|
205 | 205 | $load = false; |
206 | 206 | // check if we should load or not |
207 | - if ( is_admin() ) { |
|
207 | + if (is_admin()) { |
|
208 | 208 | // Only enable on set pages |
209 | 209 | $aui_screens = array( |
210 | 210 | 'page', |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'settings_page_ayecode-ui-settings', |
213 | 213 | 'appearance_page_gutenberg-widgets' |
214 | 214 | ); |
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
215 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
216 | 216 | |
217 | 217 | $screen = get_current_screen(); |
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
221 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
222 | 222 | $load = true; |
223 | 223 | } |
224 | 224 | } |
@@ -231,25 +231,25 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function enqueue_style() { |
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
234 | + if (is_admin() && !$this->is_aui_screen()) { |
|
235 | 235 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 238 | |
239 | 239 | $rtl = is_rtl() ? '-rtl' : ''; |
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if ($this->settings[$css_setting]) { |
|
242 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
244 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
245 | + wp_enqueue_style('ayecode-ui'); |
|
246 | 246 | |
247 | 247 | // flatpickr |
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
248 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
249 | 249 | |
250 | 250 | |
251 | 251 | // fix some wp-admin issues |
252 | - if(is_admin()){ |
|
252 | + if (is_admin()) { |
|
253 | 253 | $custom_css = " |
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
@@ -298,11 +298,11 @@ discard block |
||
298 | 298 | padding: 0; |
299 | 299 | } |
300 | 300 | "; |
301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
301 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | // custom changes |
305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
305 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | function aui_init_flatpickr(){ |
563 | 563 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
564 | 564 | $aui_doing_init_flatpickr = true; |
565 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
565 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
566 | 566 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
567 | 567 | } |
568 | 568 | $aui_doing_init_flatpickr = false; |
@@ -1016,10 +1016,10 @@ discard block |
||
1016 | 1016 | /* |
1017 | 1017 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1018 | 1018 | */ |
1019 | - return str_replace( array( |
|
1019 | + return str_replace(array( |
|
1020 | 1020 | '<script>', |
1021 | 1021 | '</script>' |
1022 | - ), '', self::minify_js($output) ); |
|
1022 | + ), '', self::minify_js($output)); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1033,13 +1033,13 @@ discard block |
||
1033 | 1033 | ob_start(); |
1034 | 1034 | ?> |
1035 | 1035 | <script> |
1036 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1036 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1037 | 1037 | /* With Avada builder */ |
1038 | 1038 | |
1039 | 1039 | <?php } ?> |
1040 | 1040 | </script> |
1041 | 1041 | <?php |
1042 | - return str_replace( array( |
|
1042 | + return str_replace(array( |
|
1043 | 1043 | '<script>', |
1044 | 1044 | '</script>' |
1045 | 1045 | ), '', ob_get_clean()); |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | * |
1051 | 1051 | * If this remains small then its best to use this than to add another JS file. |
1052 | 1052 | */ |
1053 | - public function inline_script_file_browser(){ |
|
1053 | + public function inline_script_file_browser() { |
|
1054 | 1054 | ob_start(); |
1055 | 1055 | ?> |
1056 | 1056 | <script> |
@@ -1065,10 +1065,10 @@ discard block |
||
1065 | 1065 | /* |
1066 | 1066 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1067 | 1067 | */ |
1068 | - return str_replace( array( |
|
1068 | + return str_replace(array( |
|
1069 | 1069 | '<script>', |
1070 | 1070 | '</script>' |
1071 | - ), '', $output ); |
|
1071 | + ), '', $output); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | /** |
@@ -1076,50 +1076,50 @@ discard block |
||
1076 | 1076 | */ |
1077 | 1077 | public function enqueue_scripts() { |
1078 | 1078 | |
1079 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1079 | + if (is_admin() && !$this->is_aui_screen()) { |
|
1080 | 1080 | // don't add wp-admin scripts if not requested to |
1081 | - }else { |
|
1081 | + } else { |
|
1082 | 1082 | |
1083 | 1083 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
1084 | 1084 | |
1085 | 1085 | // select2 |
1086 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1086 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
1087 | 1087 | |
1088 | 1088 | // flatpickr |
1089 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1089 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
1090 | 1090 | |
1091 | 1091 | // Bootstrap file browser |
1092 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1093 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1092 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
1093 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
1094 | 1094 | |
1095 | 1095 | $load_inline = false; |
1096 | 1096 | |
1097 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1097 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
1098 | 1098 | // Bootstrap bundle |
1099 | 1099 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
1100 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1100 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
1101 | 1101 | 'select2', |
1102 | 1102 | 'jquery' |
1103 | - ), $this->latest, $this->is_bs3_compat() ); |
|
1103 | + ), $this->latest, $this->is_bs3_compat()); |
|
1104 | 1104 | // if in admin then add to footer for compatibility. |
1105 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1105 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
1106 | 1106 | $script = $this->inline_script(); |
1107 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1108 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1107 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
1108 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
1109 | 1109 | $url = $this->url . 'assets/js/popper.min.js'; |
1110 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1111 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1110 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
1111 | + wp_enqueue_script('bootstrap-js-popper'); |
|
1112 | 1112 | $load_inline = true; |
1113 | 1113 | } else { |
1114 | 1114 | $load_inline = true; |
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
1118 | - if ( $load_inline ) { |
|
1119 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1120 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
1118 | + if ($load_inline) { |
|
1119 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
1120 | + wp_enqueue_script('bootstrap-dummy'); |
|
1121 | 1121 | $script = $this->inline_script(); |
1122 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1122 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
1123 | 1123 | } |
1124 | 1124 | } |
1125 | 1125 | |
@@ -1128,9 +1128,9 @@ discard block |
||
1128 | 1128 | /** |
1129 | 1129 | * Enqueue flatpickr if called. |
1130 | 1130 | */ |
1131 | - public function enqueue_flatpickr(){ |
|
1132 | - wp_enqueue_style( 'flatpickr' ); |
|
1133 | - wp_enqueue_script( 'flatpickr' ); |
|
1131 | + public function enqueue_flatpickr() { |
|
1132 | + wp_enqueue_style('flatpickr'); |
|
1133 | + wp_enqueue_script('flatpickr'); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1142,15 +1142,15 @@ discard block |
||
1142 | 1142 | |
1143 | 1143 | $url = ''; |
1144 | 1144 | // check if we are inside a plugin |
1145 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1145 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
1146 | 1146 | |
1147 | 1147 | // add check in-case user has changed wp-content dir name. |
1148 | 1148 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
1149 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1150 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1149 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
1150 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
1151 | 1151 | |
1152 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1153 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1152 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
1153 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | return $url; |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | * Register the database settings with WordPress. |
1161 | 1161 | */ |
1162 | 1162 | public function register_settings() { |
1163 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1163 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1169,10 +1169,10 @@ discard block |
||
1169 | 1169 | */ |
1170 | 1170 | public function menu_item() { |
1171 | 1171 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
1172 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1172 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1173 | 1173 | $this, |
1174 | 1174 | 'settings_page' |
1175 | - ) ); |
|
1175 | + )); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | /** |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | * |
1181 | 1181 | * @return array |
1182 | 1182 | */ |
1183 | - public function theme_js_settings(){ |
|
1183 | + public function theme_js_settings() { |
|
1184 | 1184 | return array( |
1185 | 1185 | 'ayetheme' => 'popper', |
1186 | 1186 | 'listimia' => 'required', |
@@ -1196,17 +1196,17 @@ discard block |
||
1196 | 1196 | */ |
1197 | 1197 | public function get_settings() { |
1198 | 1198 | |
1199 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1199 | + $db_settings = get_option('ayecode-ui-settings'); |
|
1200 | 1200 | $js_default = 'core-popper'; |
1201 | 1201 | $js_default_backend = $js_default; |
1202 | 1202 | |
1203 | 1203 | // maybe set defaults (if no settings set) |
1204 | - if(empty($db_settings)){ |
|
1205 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1204 | + if (empty($db_settings)) { |
|
1205 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
1206 | 1206 | $theme_js_settings = self::theme_js_settings(); |
1207 | - if(isset($theme_js_settings[$active_theme])){ |
|
1207 | + if (isset($theme_js_settings[$active_theme])) { |
|
1208 | 1208 | $js_default = $theme_js_settings[$active_theme]; |
1209 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1209 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | |
@@ -1219,14 +1219,14 @@ discard block |
||
1219 | 1219 | 'disable_admin' => '', // URL snippets to disable loading on admin |
1220 | 1220 | ); |
1221 | 1221 | |
1222 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1222 | + $settings = wp_parse_args($db_settings, $defaults); |
|
1223 | 1223 | |
1224 | 1224 | /** |
1225 | 1225 | * Filter the Bootstrap settings. |
1226 | 1226 | * |
1227 | 1227 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
1228 | 1228 | */ |
1229 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1229 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | |
@@ -1234,90 +1234,90 @@ discard block |
||
1234 | 1234 | * The settings page html output. |
1235 | 1235 | */ |
1236 | 1236 | public function settings_page() { |
1237 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1238 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1237 | + if (!current_user_can('manage_options')) { |
|
1238 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
1239 | 1239 | } |
1240 | 1240 | ?> |
1241 | 1241 | <div class="wrap"> |
1242 | 1242 | <h1><?php echo $this->name; ?></h1> |
1243 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
1243 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
1244 | 1244 | <form method="post" action="options.php"> |
1245 | 1245 | <?php |
1246 | - settings_fields( 'ayecode-ui-settings' ); |
|
1247 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1246 | + settings_fields('ayecode-ui-settings'); |
|
1247 | + do_settings_sections('ayecode-ui-settings'); |
|
1248 | 1248 | ?> |
1249 | 1249 | |
1250 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
1250 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
1251 | 1251 | <table class="form-table wpbs-table-settings"> |
1252 | 1252 | <tr valign="top"> |
1253 | 1253 | <th scope="row"><label |
1254 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1254 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1255 | 1255 | <td> |
1256 | 1256 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1257 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1258 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1259 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1257 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1258 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1259 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1260 | 1260 | </select> |
1261 | 1261 | </td> |
1262 | 1262 | </tr> |
1263 | 1263 | |
1264 | 1264 | <tr valign="top"> |
1265 | 1265 | <th scope="row"><label |
1266 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1266 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1267 | 1267 | <td> |
1268 | 1268 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1269 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1270 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1271 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1272 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1269 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1270 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1271 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1272 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1273 | 1273 | </select> |
1274 | 1274 | </td> |
1275 | 1275 | </tr> |
1276 | 1276 | |
1277 | 1277 | <tr valign="top"> |
1278 | 1278 | <th scope="row"><label |
1279 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1279 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1280 | 1280 | <td> |
1281 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1282 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
1281 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1282 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
1283 | 1283 | </td> |
1284 | 1284 | </tr> |
1285 | 1285 | |
1286 | 1286 | </table> |
1287 | 1287 | |
1288 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1288 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1289 | 1289 | <table class="form-table wpbs-table-settings"> |
1290 | 1290 | <tr valign="top"> |
1291 | 1291 | <th scope="row"><label |
1292 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1292 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1293 | 1293 | <td> |
1294 | 1294 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1295 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1296 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1297 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1295 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1296 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1297 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1298 | 1298 | </select> |
1299 | 1299 | </td> |
1300 | 1300 | </tr> |
1301 | 1301 | |
1302 | 1302 | <tr valign="top"> |
1303 | 1303 | <th scope="row"><label |
1304 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1304 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1305 | 1305 | <td> |
1306 | 1306 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1307 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1308 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1309 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1310 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1307 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1308 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1309 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1310 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1311 | 1311 | </select> |
1312 | 1312 | </td> |
1313 | 1313 | </tr> |
1314 | 1314 | |
1315 | 1315 | <tr valign="top"> |
1316 | 1316 | <th scope="row"><label |
1317 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1317 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1318 | 1318 | <td> |
1319 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1320 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1319 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1320 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1321 | 1321 | |
1322 | 1322 | </td> |
1323 | 1323 | </tr> |
@@ -1335,9 +1335,9 @@ discard block |
||
1335 | 1335 | <?php |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - public function customizer_settings($wp_customize){ |
|
1338 | + public function customizer_settings($wp_customize) { |
|
1339 | 1339 | $wp_customize->add_section('aui_settings', array( |
1340 | - 'title' => __('AyeCode UI','aui'), |
|
1340 | + 'title' => __('AyeCode UI', 'aui'), |
|
1341 | 1341 | 'priority' => 120, |
1342 | 1342 | )); |
1343 | 1343 | |
@@ -1351,8 +1351,8 @@ discard block |
||
1351 | 1351 | 'type' => 'option', |
1352 | 1352 | 'transport' => 'refresh', |
1353 | 1353 | )); |
1354 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1355 | - 'label' => __('Primary Color','aui'), |
|
1354 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1355 | + 'label' => __('Primary Color', 'aui'), |
|
1356 | 1356 | 'section' => 'aui_settings', |
1357 | 1357 | 'settings' => 'aui_options[color_primary]', |
1358 | 1358 | ))); |
@@ -1364,8 +1364,8 @@ discard block |
||
1364 | 1364 | 'type' => 'option', |
1365 | 1365 | 'transport' => 'refresh', |
1366 | 1366 | )); |
1367 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1368 | - 'label' => __('Secondary Color','aui'), |
|
1367 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1368 | + 'label' => __('Secondary Color', 'aui'), |
|
1369 | 1369 | 'section' => 'aui_settings', |
1370 | 1370 | 'settings' => 'aui_options[color_secondary]', |
1371 | 1371 | ))); |
@@ -1391,12 +1391,12 @@ discard block |
||
1391 | 1391 | .collapse.show:not(.in){display: inherit;} |
1392 | 1392 | .fade.show{opacity: 1;} |
1393 | 1393 | |
1394 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1394 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1395 | 1395 | /* KLEO theme specific */ |
1396 | 1396 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;} |
1397 | 1397 | <?php } ?> |
1398 | 1398 | |
1399 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1399 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1400 | 1400 | /* With Avada builder */ |
1401 | 1401 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1402 | 1402 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1404,10 +1404,10 @@ discard block |
||
1404 | 1404 | <?php } ?> |
1405 | 1405 | </style> |
1406 | 1406 | <?php |
1407 | - return str_replace( array( |
|
1407 | + return str_replace(array( |
|
1408 | 1408 | '<style>', |
1409 | 1409 | '</style>' |
1410 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1410 | + ), '', self::minify_css(ob_get_clean())); |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | |
@@ -1424,16 +1424,16 @@ discard block |
||
1424 | 1424 | <?php |
1425 | 1425 | |
1426 | 1426 | // BS v3 compat |
1427 | - if( self::is_bs3_compat() ){ |
|
1427 | + if (self::is_bs3_compat()) { |
|
1428 | 1428 | echo self::bs3_compat_css(); |
1429 | 1429 | } |
1430 | 1430 | |
1431 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1432 | - echo self::css_primary($primary_color,$compatibility); |
|
1431 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1432 | + echo self::css_primary($primary_color, $compatibility); |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1436 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1435 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1436 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | // Set admin bar z-index lower when modal is open. |
@@ -1446,10 +1446,10 @@ discard block |
||
1446 | 1446 | /* |
1447 | 1447 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1448 | 1448 | */ |
1449 | - return str_replace( array( |
|
1449 | + return str_replace(array( |
|
1450 | 1450 | '<style>', |
1451 | 1451 | '</style>' |
1452 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1452 | + ), '', self::minify_css(ob_get_clean())); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | /** |
@@ -1457,48 +1457,48 @@ discard block |
||
1457 | 1457 | * |
1458 | 1458 | * @return bool |
1459 | 1459 | */ |
1460 | - public static function is_bs3_compat(){ |
|
1460 | + public static function is_bs3_compat() { |
|
1461 | 1461 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - public static function css_primary($color_code,$compatibility){; |
|
1464 | + public static function css_primary($color_code, $compatibility) {; |
|
1465 | 1465 | $color_code = sanitize_hex_color($color_code); |
1466 | - if(!$color_code){return '';} |
|
1466 | + if (!$color_code) {return ''; } |
|
1467 | 1467 | /** |
1468 | 1468 | * c = color, b = background color, o = border-color, f = fill |
1469 | 1469 | */ |
1470 | 1470 | $selectors = array( |
1471 | 1471 | 'a' => array('c'), |
1472 | - '.btn-primary' => array('b','o'), |
|
1473 | - '.btn-primary.disabled' => array('b','o'), |
|
1474 | - '.btn-primary:disabled' => array('b','o'), |
|
1475 | - '.btn-outline-primary' => array('c','o'), |
|
1476 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1477 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1478 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1479 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1472 | + '.btn-primary' => array('b', 'o'), |
|
1473 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1474 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1475 | + '.btn-outline-primary' => array('c', 'o'), |
|
1476 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1477 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1478 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1479 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1480 | 1480 | '.btn-link' => array('c'), |
1481 | 1481 | '.dropdown-item.active' => array('b'), |
1482 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1483 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1482 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1483 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1484 | 1484 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1485 | 1485 | // '.custom-range::-moz-range-thumb' => array('b'), |
1486 | 1486 | // '.custom-range::-ms-thumb' => array('b'), |
1487 | 1487 | '.nav-pills .nav-link.active' => array('b'), |
1488 | 1488 | '.nav-pills .show>.nav-link' => array('b'), |
1489 | 1489 | '.page-link' => array('c'), |
1490 | - '.page-item.active .page-link' => array('b','o'), |
|
1490 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1491 | 1491 | '.badge-primary' => array('b'), |
1492 | - '.alert-primary' => array('b','o'), |
|
1492 | + '.alert-primary' => array('b', 'o'), |
|
1493 | 1493 | '.progress-bar' => array('b'), |
1494 | - '.list-group-item.active' => array('b','o'), |
|
1495 | - '.bg-primary' => array('b','f'), |
|
1494 | + '.list-group-item.active' => array('b', 'o'), |
|
1495 | + '.bg-primary' => array('b', 'f'), |
|
1496 | 1496 | '.btn-link.btn-primary' => array('c'), |
1497 | 1497 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1498 | 1498 | ); |
1499 | 1499 | |
1500 | 1500 | $important_selectors = array( |
1501 | - '.bg-primary' => array('b','f'), |
|
1501 | + '.bg-primary' => array('b', 'f'), |
|
1502 | 1502 | '.border-primary' => array('o'), |
1503 | 1503 | '.text-primary' => array('c'), |
1504 | 1504 | ); |
@@ -1515,116 +1515,116 @@ discard block |
||
1515 | 1515 | $output = ''; |
1516 | 1516 | |
1517 | 1517 | // build rules into each type |
1518 | - foreach($selectors as $selector => $types){ |
|
1519 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1520 | - $types = array_combine($types,$types); |
|
1521 | - if(isset($types['c'])){$color[] = $selector;} |
|
1522 | - if(isset($types['b'])){$background[] = $selector;} |
|
1523 | - if(isset($types['o'])){$border[] = $selector;} |
|
1524 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1518 | + foreach ($selectors as $selector => $types) { |
|
1519 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1520 | + $types = array_combine($types, $types); |
|
1521 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1522 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1523 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1524 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | // build rules into each type |
1528 | - foreach($important_selectors as $selector => $types){ |
|
1529 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1530 | - $types = array_combine($types,$types); |
|
1531 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1532 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1533 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1534 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1528 | + foreach ($important_selectors as $selector => $types) { |
|
1529 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1530 | + $types = array_combine($types, $types); |
|
1531 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1532 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1533 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1534 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | // add any color rules |
1538 | - if(!empty($color)){ |
|
1539 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1538 | + if (!empty($color)) { |
|
1539 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1540 | 1540 | } |
1541 | - if(!empty($color_i)){ |
|
1542 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1541 | + if (!empty($color_i)) { |
|
1542 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | // add any background color rules |
1546 | - if(!empty($background)){ |
|
1547 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1546 | + if (!empty($background)) { |
|
1547 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1548 | 1548 | } |
1549 | - if(!empty($background_i)){ |
|
1550 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1549 | + if (!empty($background_i)) { |
|
1550 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | // add any border color rules |
1554 | - if(!empty($border)){ |
|
1555 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1554 | + if (!empty($border)) { |
|
1555 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1556 | 1556 | } |
1557 | - if(!empty($border_i)){ |
|
1558 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1557 | + if (!empty($border_i)) { |
|
1558 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | // add any fill color rules |
1562 | - if(!empty($fill)){ |
|
1563 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1562 | + if (!empty($fill)) { |
|
1563 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1564 | 1564 | } |
1565 | - if(!empty($fill_i)){ |
|
1566 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1565 | + if (!empty($fill_i)) { |
|
1566 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | 1569 | |
1570 | 1570 | $prefix = $compatibility ? ".bsui " : ""; |
1571 | 1571 | |
1572 | 1572 | // darken |
1573 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1574 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1575 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1573 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1574 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1575 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1576 | 1576 | |
1577 | 1577 | // lighten |
1578 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1578 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1579 | 1579 | |
1580 | 1580 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1581 | - $op_25 = $color_code."40"; // 25% opacity |
|
1581 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1582 | 1582 | |
1583 | 1583 | |
1584 | 1584 | // button states |
1585 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1586 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1587 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1588 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1585 | + $output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1586 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1587 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1588 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1589 | 1589 | |
1590 | 1590 | |
1591 | 1591 | // dropdown's |
1592 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1592 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1593 | 1593 | |
1594 | 1594 | |
1595 | 1595 | // input states |
1596 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1596 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1597 | 1597 | |
1598 | 1598 | // page link |
1599 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1599 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1600 | 1600 | |
1601 | 1601 | return $output; |
1602 | 1602 | } |
1603 | 1603 | |
1604 | - public static function css_secondary($color_code,$compatibility){; |
|
1604 | + public static function css_secondary($color_code, $compatibility) {; |
|
1605 | 1605 | $color_code = sanitize_hex_color($color_code); |
1606 | - if(!$color_code){return '';} |
|
1606 | + if (!$color_code) {return ''; } |
|
1607 | 1607 | /** |
1608 | 1608 | * c = color, b = background color, o = border-color, f = fill |
1609 | 1609 | */ |
1610 | 1610 | $selectors = array( |
1611 | - '.btn-secondary' => array('b','o'), |
|
1612 | - '.btn-secondary.disabled' => array('b','o'), |
|
1613 | - '.btn-secondary:disabled' => array('b','o'), |
|
1614 | - '.btn-outline-secondary' => array('c','o'), |
|
1615 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1611 | + '.btn-secondary' => array('b', 'o'), |
|
1612 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1613 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1614 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1615 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1616 | 1616 | '.btn-outline-secondary.disabled' => array('c'), |
1617 | 1617 | '.btn-outline-secondary:disabled' => array('c'), |
1618 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1619 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1620 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1618 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1619 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1620 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1621 | 1621 | '.badge-secondary' => array('b'), |
1622 | - '.alert-secondary' => array('b','o'), |
|
1622 | + '.alert-secondary' => array('b', 'o'), |
|
1623 | 1623 | '.btn-link.btn-secondary' => array('c'), |
1624 | 1624 | ); |
1625 | 1625 | |
1626 | 1626 | $important_selectors = array( |
1627 | - '.bg-secondary' => array('b','f'), |
|
1627 | + '.bg-secondary' => array('b', 'f'), |
|
1628 | 1628 | '.border-secondary' => array('o'), |
1629 | 1629 | '.text-secondary' => array('c'), |
1630 | 1630 | ); |
@@ -1641,77 +1641,77 @@ discard block |
||
1641 | 1641 | $output = ''; |
1642 | 1642 | |
1643 | 1643 | // build rules into each type |
1644 | - foreach($selectors as $selector => $types){ |
|
1645 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1646 | - $types = array_combine($types,$types); |
|
1647 | - if(isset($types['c'])){$color[] = $selector;} |
|
1648 | - if(isset($types['b'])){$background[] = $selector;} |
|
1649 | - if(isset($types['o'])){$border[] = $selector;} |
|
1650 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1644 | + foreach ($selectors as $selector => $types) { |
|
1645 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1646 | + $types = array_combine($types, $types); |
|
1647 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1648 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1649 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1650 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | // build rules into each type |
1654 | - foreach($important_selectors as $selector => $types){ |
|
1655 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1656 | - $types = array_combine($types,$types); |
|
1657 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1658 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1659 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1660 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1654 | + foreach ($important_selectors as $selector => $types) { |
|
1655 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1656 | + $types = array_combine($types, $types); |
|
1657 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1658 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1659 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1660 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | // add any color rules |
1664 | - if(!empty($color)){ |
|
1665 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1664 | + if (!empty($color)) { |
|
1665 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1666 | 1666 | } |
1667 | - if(!empty($color_i)){ |
|
1668 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1667 | + if (!empty($color_i)) { |
|
1668 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | // add any background color rules |
1672 | - if(!empty($background)){ |
|
1673 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1672 | + if (!empty($background)) { |
|
1673 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1674 | 1674 | } |
1675 | - if(!empty($background_i)){ |
|
1676 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1675 | + if (!empty($background_i)) { |
|
1676 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | // add any border color rules |
1680 | - if(!empty($border)){ |
|
1681 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1680 | + if (!empty($border)) { |
|
1681 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1682 | 1682 | } |
1683 | - if(!empty($border_i)){ |
|
1684 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1683 | + if (!empty($border_i)) { |
|
1684 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1685 | 1685 | } |
1686 | 1686 | |
1687 | 1687 | // add any fill color rules |
1688 | - if(!empty($fill)){ |
|
1689 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1688 | + if (!empty($fill)) { |
|
1689 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1690 | 1690 | } |
1691 | - if(!empty($fill_i)){ |
|
1692 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1691 | + if (!empty($fill_i)) { |
|
1692 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | |
1696 | 1696 | $prefix = $compatibility ? ".bsui " : ""; |
1697 | 1697 | |
1698 | 1698 | // darken |
1699 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1700 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1701 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1699 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1700 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1701 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1702 | 1702 | |
1703 | 1703 | // lighten |
1704 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1704 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1705 | 1705 | |
1706 | 1706 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1707 | - $op_25 = $color_code."40"; // 25% opacity |
|
1707 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1708 | 1708 | |
1709 | 1709 | |
1710 | 1710 | // button states |
1711 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1712 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1713 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1714 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1711 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1712 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1713 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1714 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1715 | 1715 | |
1716 | 1716 | |
1717 | 1717 | return $output; |
@@ -1747,8 +1747,8 @@ discard block |
||
1747 | 1747 | /** |
1748 | 1748 | * Check if we should display examples. |
1749 | 1749 | */ |
1750 | - public function maybe_show_examples(){ |
|
1751 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1750 | + public function maybe_show_examples() { |
|
1751 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1752 | 1752 | echo "<head>"; |
1753 | 1753 | wp_head(); |
1754 | 1754 | echo "</head>"; |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | * |
1765 | 1765 | * @return string |
1766 | 1766 | */ |
1767 | - public function get_examples(){ |
|
1767 | + public function get_examples() { |
|
1768 | 1768 | $output = ''; |
1769 | 1769 | |
1770 | 1770 | |
@@ -1870,74 +1870,74 @@ discard block |
||
1870 | 1870 | */ |
1871 | 1871 | public static function calendar_params() { |
1872 | 1872 | $params = array( |
1873 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1874 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1875 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1876 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1877 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1878 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1879 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1880 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1881 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1882 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1883 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1884 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1885 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1886 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1887 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1888 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1889 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1890 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1891 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1892 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1893 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1894 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1895 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1896 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1897 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1898 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1899 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1900 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1901 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1902 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1903 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1904 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1905 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1906 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1907 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1908 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1909 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1910 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1911 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1912 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1913 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1914 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1915 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1916 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1917 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1918 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1919 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1920 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1921 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1922 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1923 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1924 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1925 | - 'am_lower' => __( 'am', 'aui' ), |
|
1926 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1927 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1928 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1929 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1873 | + 'month_long_1' => __('January', 'aui'), |
|
1874 | + 'month_long_2' => __('February', 'aui'), |
|
1875 | + 'month_long_3' => __('March', 'aui'), |
|
1876 | + 'month_long_4' => __('April', 'aui'), |
|
1877 | + 'month_long_5' => __('May', 'aui'), |
|
1878 | + 'month_long_6' => __('June', 'aui'), |
|
1879 | + 'month_long_7' => __('July', 'aui'), |
|
1880 | + 'month_long_8' => __('August', 'aui'), |
|
1881 | + 'month_long_9' => __('September', 'aui'), |
|
1882 | + 'month_long_10' => __('October', 'aui'), |
|
1883 | + 'month_long_11' => __('November', 'aui'), |
|
1884 | + 'month_long_12' => __('December', 'aui'), |
|
1885 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
1886 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
1887 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
1888 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
1889 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
1890 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
1891 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
1892 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
1893 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
1894 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
1895 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
1896 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
1897 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
1898 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
1899 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
1900 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
1901 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
1902 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
1903 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
1904 | + 'day_s2_1' => __('Su', 'aui'), |
|
1905 | + 'day_s2_2' => __('Mo', 'aui'), |
|
1906 | + 'day_s2_3' => __('Tu', 'aui'), |
|
1907 | + 'day_s2_4' => __('We', 'aui'), |
|
1908 | + 'day_s2_5' => __('Th', 'aui'), |
|
1909 | + 'day_s2_6' => __('Fr', 'aui'), |
|
1910 | + 'day_s2_7' => __('Sa', 'aui'), |
|
1911 | + 'day_s3_1' => __('Sun', 'aui'), |
|
1912 | + 'day_s3_2' => __('Mon', 'aui'), |
|
1913 | + 'day_s3_3' => __('Tue', 'aui'), |
|
1914 | + 'day_s3_4' => __('Wed', 'aui'), |
|
1915 | + 'day_s3_5' => __('Thu', 'aui'), |
|
1916 | + 'day_s3_6' => __('Fri', 'aui'), |
|
1917 | + 'day_s3_7' => __('Sat', 'aui'), |
|
1918 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
1919 | + 'day_s5_2' => __('Monday', 'aui'), |
|
1920 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
1921 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
1922 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
1923 | + 'day_s5_6' => __('Friday', 'aui'), |
|
1924 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
1925 | + 'am_lower' => __('am', 'aui'), |
|
1926 | + 'pm_lower' => __('pm', 'aui'), |
|
1927 | + 'am_upper' => __('AM', 'aui'), |
|
1928 | + 'pm_upper' => __('PM', 'aui'), |
|
1929 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
1930 | 1930 | 'time_24hr' => false, |
1931 | - 'year' => __( 'Year', 'aui' ), |
|
1932 | - 'hour' => __( 'Hour', 'aui' ), |
|
1933 | - 'minute' => __( 'Minute', 'aui' ), |
|
1934 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1935 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1936 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1937 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1931 | + 'year' => __('Year', 'aui'), |
|
1932 | + 'hour' => __('Hour', 'aui'), |
|
1933 | + 'minute' => __('Minute', 'aui'), |
|
1934 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
1935 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
1936 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
1937 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
1938 | 1938 | ); |
1939 | 1939 | |
1940 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1940 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
1941 | 1941 | } |
1942 | 1942 | |
1943 | 1943 | /** |
@@ -1950,47 +1950,47 @@ discard block |
||
1950 | 1950 | public static function flatpickr_locale() { |
1951 | 1951 | $params = self::calendar_params(); |
1952 | 1952 | |
1953 | - if ( is_string( $params ) ) { |
|
1954 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1953 | + if (is_string($params)) { |
|
1954 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
1955 | 1955 | } else { |
1956 | - foreach ( (array) $params as $key => $value ) { |
|
1957 | - if ( ! is_scalar( $value ) ) { |
|
1956 | + foreach ((array) $params as $key => $value) { |
|
1957 | + if (!is_scalar($value)) { |
|
1958 | 1958 | continue; |
1959 | 1959 | } |
1960 | 1960 | |
1961 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1961 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1962 | 1962 | } |
1963 | 1963 | } |
1964 | 1964 | |
1965 | 1965 | $day_s3 = array(); |
1966 | 1966 | $day_s5 = array(); |
1967 | 1967 | |
1968 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1969 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1970 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1968 | + for ($i = 1; $i <= 7; $i++) { |
|
1969 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
1970 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
1971 | 1971 | } |
1972 | 1972 | |
1973 | 1973 | $month_s = array(); |
1974 | 1974 | $month_long = array(); |
1975 | 1975 | |
1976 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1977 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1978 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1976 | + for ($i = 1; $i <= 12; $i++) { |
|
1977 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
1978 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
1979 | 1979 | } |
1980 | 1980 | |
1981 | 1981 | ob_start(); |
1982 | -if ( 0 ) { ?><script><?php } ?> |
|
1982 | +if (0) { ?><script><?php } ?> |
|
1983 | 1983 | { |
1984 | 1984 | weekdays: { |
1985 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
1986 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
1985 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
1986 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
1987 | 1987 | }, |
1988 | 1988 | months: { |
1989 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
1990 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
1989 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
1990 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
1991 | 1991 | }, |
1992 | 1992 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
1993 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
1993 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
1994 | 1994 | ordinal: function (nth) { |
1995 | 1995 | var s = nth % 100; |
1996 | 1996 | if (s > 3 && s < 21) |
@@ -2006,21 +2006,21 @@ discard block |
||
2006 | 2006 | return "th"; |
2007 | 2007 | } |
2008 | 2008 | }, |
2009 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
2010 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
2011 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
2012 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
2013 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
2014 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
2015 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
2016 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
2017 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
2009 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
2010 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
2011 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
2012 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
2013 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
2014 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
2015 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
2016 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
2017 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
2018 | 2018 | } |
2019 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
2019 | +<?php if (0) { ?></script><?php } ?> |
|
2020 | 2020 | <?php |
2021 | 2021 | $locale = ob_get_clean(); |
2022 | 2022 | |
2023 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2023 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
2024 | 2024 | } |
2025 | 2025 | |
2026 | 2026 | /** |
@@ -2032,20 +2032,20 @@ discard block |
||
2032 | 2032 | */ |
2033 | 2033 | public static function select2_params() { |
2034 | 2034 | $params = array( |
2035 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2036 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2037 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2038 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2039 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2040 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2041 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2042 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2043 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2044 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2045 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2035 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
2036 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
2037 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
2038 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
2039 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
2040 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
2041 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
2042 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
2043 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
2044 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
2045 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
2046 | 2046 | ); |
2047 | 2047 | |
2048 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2048 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
2049 | 2049 | } |
2050 | 2050 | |
2051 | 2051 | /** |
@@ -2058,17 +2058,17 @@ discard block |
||
2058 | 2058 | public static function select2_locale() { |
2059 | 2059 | $params = self::select2_params(); |
2060 | 2060 | |
2061 | - foreach ( (array) $params as $key => $value ) { |
|
2062 | - if ( ! is_scalar( $value ) ) { |
|
2061 | + foreach ((array) $params as $key => $value) { |
|
2062 | + if (!is_scalar($value)) { |
|
2063 | 2063 | continue; |
2064 | 2064 | } |
2065 | 2065 | |
2066 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2066 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | - $locale = json_encode( $params ); |
|
2069 | + $locale = json_encode($params); |
|
2070 | 2070 | |
2071 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2071 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
2072 | 2072 | } |
2073 | 2073 | |
2074 | 2074 | /** |
@@ -2081,35 +2081,35 @@ discard block |
||
2081 | 2081 | public static function timeago_locale() { |
2082 | 2082 | $params = array( |
2083 | 2083 | 'prefix_ago' => '', |
2084 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2085 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2084 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'), |
|
2085 | + 'prefix_after' => _x('after', 'time ago', 'aui') . ' ', |
|
2086 | 2086 | 'suffix_after' => '', |
2087 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2088 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2089 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2090 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2091 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2092 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2093 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2094 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2095 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2096 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2097 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2087 | + 'seconds' => _x('less than a minute', 'time ago', 'aui'), |
|
2088 | + 'minute' => _x('about a minute', 'time ago', 'aui'), |
|
2089 | + 'minutes' => _x('%d minutes', 'time ago', 'aui'), |
|
2090 | + 'hour' => _x('about an hour', 'time ago', 'aui'), |
|
2091 | + 'hours' => _x('about %d hours', 'time ago', 'aui'), |
|
2092 | + 'day' => _x('a day', 'time ago', 'aui'), |
|
2093 | + 'days' => _x('%d days', 'time ago', 'aui'), |
|
2094 | + 'month' => _x('about a month', 'time ago', 'aui'), |
|
2095 | + 'months' => _x('%d months', 'time ago', 'aui'), |
|
2096 | + 'year' => _x('about a year', 'time ago', 'aui'), |
|
2097 | + 'years' => _x('%d years', 'time ago', 'aui'), |
|
2098 | 2098 | ); |
2099 | 2099 | |
2100 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2100 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
2101 | 2101 | |
2102 | - foreach ( (array) $params as $key => $value ) { |
|
2103 | - if ( ! is_scalar( $value ) ) { |
|
2102 | + foreach ((array) $params as $key => $value) { |
|
2103 | + if (!is_scalar($value)) { |
|
2104 | 2104 | continue; |
2105 | 2105 | } |
2106 | 2106 | |
2107 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2107 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2108 | 2108 | } |
2109 | 2109 | |
2110 | - $locale = json_encode( $params ); |
|
2110 | + $locale = json_encode($params); |
|
2111 | 2111 | |
2112 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2112 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
2113 | 2113 | } |
2114 | 2114 | |
2115 | 2115 | /** |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | * @return mixed |
2121 | 2121 | */ |
2122 | 2122 | public static function minify_js($input) { |
2123 | - if(trim($input) === "") return $input; |
|
2123 | + if (trim($input) === "") return $input; |
|
2124 | 2124 | return preg_replace( |
2125 | 2125 | array( |
2126 | 2126 | // Remove comment(s) |
@@ -2152,7 +2152,7 @@ discard block |
||
2152 | 2152 | * @return mixed |
2153 | 2153 | */ |
2154 | 2154 | public static function minify_css($input) { |
2155 | - if(trim($input) === "") return $input; |
|
2155 | + if (trim($input) === "") return $input; |
|
2156 | 2156 | return preg_replace( |
2157 | 2157 | array( |
2158 | 2158 | // Remove comment(s) |
@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | class GetPaid_Notification_Email_Sender { |
14 | 14 | |
15 | 15 | /** |
16 | - * Whether or not we should inline CSS into the email. |
|
17 | - */ |
|
18 | - public $inline_css = true; |
|
16 | + * Whether or not we should inline CSS into the email. |
|
17 | + */ |
|
18 | + public $inline_css = true; |
|
19 | 19 | |
20 | 20 | /** |
21 | - * The wp_mail() data. |
|
22 | - */ |
|
21 | + * The wp_mail() data. |
|
22 | + */ |
|
23 | 23 | public $wp_mail_data = null; |
24 | 24 | |
25 | 25 | /** |
26 | - * Sends a new email. |
|
26 | + * Sends a new email. |
|
27 | 27 | * |
28 | 28 | * @param string|array $to The recipients email or an array of recipient emails. |
29 | 29 | * @param string $subject The email's subject. |
@@ -31,49 +31,49 @@ discard block |
||
31 | 31 | * @param array $attachments The email attachments. |
32 | 32 | * |
33 | 33 | * @return bool |
34 | - */ |
|
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
34 | + */ |
|
35 | + public function send( $to, $subject, $email, $attachments = array() ) { |
|
36 | 36 | |
37 | - /* |
|
37 | + /* |
|
38 | 38 | * Allow to filter data on per-email basis. |
39 | 39 | */ |
40 | - $data = apply_filters( |
|
41 | - 'getpaid_email_data', |
|
42 | - array( |
|
43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
46 | - 'headers' => $this->get_headers(), |
|
47 | - 'attachments' => $attachments, |
|
48 | - ), |
|
49 | - $this |
|
50 | - ); |
|
40 | + $data = apply_filters( |
|
41 | + 'getpaid_email_data', |
|
42 | + array( |
|
43 | + 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | + 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
45 | + 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
46 | + 'headers' => $this->get_headers(), |
|
47 | + 'attachments' => $attachments, |
|
48 | + ), |
|
49 | + $this |
|
50 | + ); |
|
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | 53 | $data = (array) wp_unslash( $data ); |
54 | 54 | |
55 | 55 | // Cache it. |
56 | - $this->wp_mail_data = $data; |
|
56 | + $this->wp_mail_data = $data; |
|
57 | 57 | |
58 | - // Attach our own hooks. |
|
59 | - $this->before_sending(); |
|
58 | + // Attach our own hooks. |
|
59 | + $this->before_sending(); |
|
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | 63 | foreach ( $this->wp_mail_data['to'] as $to ) { |
64 | - $result = $this->_send( $to, $data ); |
|
64 | + $result = $this->_send( $to, $data ); |
|
65 | 65 | } |
66 | 66 | |
67 | - // Remove our hooks. |
|
68 | - $this->after_sending(); |
|
67 | + // Remove our hooks. |
|
68 | + $this->after_sending(); |
|
69 | 69 | |
70 | - $this->wp_mail_data = null; |
|
70 | + $this->wp_mail_data = null; |
|
71 | 71 | |
72 | - return $result; |
|
73 | - } |
|
72 | + return $result; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Does the actual sending. |
|
75 | + /** |
|
76 | + * Does the actual sending. |
|
77 | 77 | * |
78 | 78 | * @param string $to The recipient's email. |
79 | 79 | * @param array $data The email's data. |
@@ -81,81 +81,81 @@ discard block |
||
81 | 81 | * @param array $attachments The email attachments. |
82 | 82 | * |
83 | 83 | * @return bool |
84 | - */ |
|
85 | - protected function _send( $to, $data ) { |
|
86 | - |
|
87 | - // Prepare the sending function. |
|
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
89 | - |
|
90 | - // Send the actual email. |
|
91 | - $result = call_user_func( |
|
92 | - $sending_function, |
|
93 | - $to, |
|
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
95 | - $data['email'], |
|
96 | - $data['headers'], |
|
97 | - $data['attachments'] |
|
98 | - ); |
|
99 | - |
|
100 | - if ( ! $result ) { |
|
101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
103 | - } |
|
104 | - |
|
105 | - return $result; |
|
106 | - } |
|
84 | + */ |
|
85 | + protected function _send( $to, $data ) { |
|
86 | + |
|
87 | + // Prepare the sending function. |
|
88 | + $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
89 | + |
|
90 | + // Send the actual email. |
|
91 | + $result = call_user_func( |
|
92 | + $sending_function, |
|
93 | + $to, |
|
94 | + html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
95 | + $data['email'], |
|
96 | + $data['headers'], |
|
97 | + $data['attachments'] |
|
98 | + ); |
|
99 | + |
|
100 | + if ( ! $result ) { |
|
101 | + $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | + wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
103 | + } |
|
104 | + |
|
105 | + return $result; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | - * Retrieves email headers. |
|
110 | - */ |
|
111 | - public function get_headers() { |
|
109 | + * Retrieves email headers. |
|
110 | + */ |
|
111 | + public function get_headers() { |
|
112 | 112 | |
113 | - $name = $this->get_from_name(); |
|
114 | - $reply_to = $this->get_reply_to(); |
|
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
113 | + $name = $this->get_from_name(); |
|
114 | + $reply_to = $this->get_reply_to(); |
|
115 | + $headers = array( "Reply-To:$name <$reply_to>" ); |
|
116 | 116 | |
117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
117 | + return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
118 | 118 | |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | - * Fires before an email is sent |
|
123 | - * |
|
124 | - * @since 1.0.0 |
|
125 | - */ |
|
126 | - public function before_sending() { |
|
122 | + * Fires before an email is sent |
|
123 | + * |
|
124 | + * @since 1.0.0 |
|
125 | + */ |
|
126 | + public function before_sending() { |
|
127 | 127 | |
128 | 128 | do_action( 'getpaid_before_send_email', $this ); |
129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
129 | + add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | + add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | + add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | + add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
133 | 133 | |
134 | - } |
|
134 | + } |
|
135 | 135 | |
136 | 136 | /** |
137 | - * Returns the from name. |
|
138 | - */ |
|
139 | - public function get_from_name() { |
|
137 | + * Returns the from name. |
|
138 | + */ |
|
139 | + public function get_from_name() { |
|
140 | 140 | |
141 | 141 | $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
142 | 142 | |
143 | - if ( empty( $from_name ) ) { |
|
144 | - $from_name = get_bloginfo( 'name' ); |
|
143 | + if ( empty( $from_name ) ) { |
|
144 | + $from_name = get_bloginfo( 'name' ); |
|
145 | 145 | } |
146 | 146 | |
147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
147 | + return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Returns the from email. |
|
152 | - */ |
|
153 | - public function get_from_address() { |
|
151 | + * Returns the from email. |
|
152 | + */ |
|
153 | + public function get_from_address() { |
|
154 | 154 | |
155 | 155 | $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
156 | 156 | |
157 | - if ( ! is_email( $from_address ) ) { |
|
158 | - $from_address = $this->default_from_address(); |
|
157 | + if ( ! is_email( $from_address ) ) { |
|
158 | + $from_address = $this->default_from_address(); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $from_address; |
@@ -163,75 +163,75 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * The default emails from address. |
|
167 | - * |
|
168 | - * Defaults to wordpress@$sitename |
|
169 | - * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
170 | - * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
171 | - * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
172 | - * |
|
173 | - */ |
|
174 | - public function default_from_address() { |
|
175 | - |
|
176 | - // Get the site domain and get rid of www. |
|
177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | - $sitename = substr( $sitename, 4 ); |
|
180 | - } |
|
181 | - |
|
182 | - $from_email = 'wordpress@' . $sitename; |
|
183 | - |
|
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
166 | + * The default emails from address. |
|
167 | + * |
|
168 | + * Defaults to wordpress@$sitename |
|
169 | + * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
170 | + * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
171 | + * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
172 | + * |
|
173 | + */ |
|
174 | + public function default_from_address() { |
|
175 | + |
|
176 | + // Get the site domain and get rid of www. |
|
177 | + $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | + if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | + $sitename = substr( $sitename, 4 ); |
|
180 | + } |
|
181 | + |
|
182 | + $from_email = 'wordpress@' . $sitename; |
|
183 | + |
|
184 | + return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | - * Get the email reply-to. |
|
190 | - * |
|
191 | - * |
|
192 | - * @return string The email reply-to address. |
|
193 | - */ |
|
194 | - public function get_reply_to() { |
|
189 | + * Get the email reply-to. |
|
190 | + * |
|
191 | + * |
|
192 | + * @return string The email reply-to address. |
|
193 | + */ |
|
194 | + public function get_reply_to() { |
|
195 | 195 | |
196 | - $reply_to = wpinv_get_admin_email(); |
|
196 | + $reply_to = wpinv_get_admin_email(); |
|
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
200 | - } |
|
198 | + if ( ! is_email( $reply_to ) ) { |
|
199 | + $reply_to = get_option( 'admin_email' ); |
|
200 | + } |
|
201 | 201 | |
202 | - return $reply_to; |
|
202 | + return $reply_to; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Get the email content type. |
|
207 | - * |
|
208 | - */ |
|
209 | - public function get_content_type() { |
|
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
206 | + * Get the email content type. |
|
207 | + * |
|
208 | + */ |
|
209 | + public function get_content_type() { |
|
210 | + return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * Ensures that our email messages are not messed up by template plugins. |
|
215 | - * |
|
216 | - * @return array wp_mail_data. |
|
217 | - */ |
|
218 | - public function ensure_email_content( $args ) { |
|
219 | - $args['message'] = $this->wp_mail_data['email']; |
|
220 | - return $args; |
|
214 | + * Ensures that our email messages are not messed up by template plugins. |
|
215 | + * |
|
216 | + * @return array wp_mail_data. |
|
217 | + */ |
|
218 | + public function ensure_email_content( $args ) { |
|
219 | + $args['message'] = $this->wp_mail_data['email']; |
|
220 | + return $args; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * A little house keeping after an email is sent. |
|
225 | - * |
|
226 | - */ |
|
227 | - public function after_sending() { |
|
224 | + * A little house keeping after an email is sent. |
|
225 | + * |
|
226 | + */ |
|
227 | + public function after_sending() { |
|
228 | 228 | |
229 | 229 | do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
230 | + remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | + remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | + remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | + remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
234 | 234 | |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | 237 | } |
@@ -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 | * This function is responsible for sending emails. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
35 | + public function send($to, $subject, $email, $attachments = array()) { |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Allow to filter data on per-email basis. |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $data = apply_filters( |
41 | 41 | 'getpaid_email_data', |
42 | 42 | array( |
43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
45 | + 'email' => apply_filters('wpinv_mail_content', $email), |
|
46 | 46 | 'headers' => $this->get_headers(), |
47 | 47 | 'attachments' => $attachments, |
48 | 48 | ), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | - $data = (array) wp_unslash( $data ); |
|
53 | + $data = (array) wp_unslash($data); |
|
54 | 54 | |
55 | 55 | // Cache it. |
56 | 56 | $this->wp_mail_data = $data; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | - foreach ( $this->wp_mail_data['to'] as $to ) { |
|
64 | - $result = $this->_send( $to, $data ); |
|
63 | + foreach ($this->wp_mail_data['to'] as $to) { |
|
64 | + $result = $this->_send($to, $data); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Remove our hooks. |
@@ -82,24 +82,24 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - protected function _send( $to, $data ) { |
|
85 | + protected function _send($to, $data) { |
|
86 | 86 | |
87 | 87 | // Prepare the sending function. |
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
88 | + $sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail'); |
|
89 | 89 | |
90 | 90 | // Send the actual email. |
91 | 91 | $result = call_user_func( |
92 | 92 | $sending_function, |
93 | 93 | $to, |
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
94 | + html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')), |
|
95 | 95 | $data['email'], |
96 | 96 | $data['headers'], |
97 | 97 | $data['attachments'] |
98 | 98 | ); |
99 | 99 | |
100 | - if ( ! $result ) { |
|
101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
100 | + if (!$result) { |
|
101 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']); |
|
102 | + wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $result; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $name = $this->get_from_name(); |
114 | 114 | $reply_to = $this->get_reply_to(); |
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
115 | + $headers = array("Reply-To:$name <$reply_to>"); |
|
116 | 116 | |
117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
117 | + return apply_filters('getpaid_email_headers', $headers, $this); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function before_sending() { |
127 | 127 | |
128 | - do_action( 'getpaid_before_send_email', $this ); |
|
129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
128 | + do_action('getpaid_before_send_email', $this); |
|
129 | + add_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
130 | + add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
131 | + add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
132 | + add_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function get_from_name() { |
140 | 140 | |
141 | - $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
|
141 | + $from_name = wpinv_get_option('email_from_name', get_bloginfo('name')); |
|
142 | 142 | |
143 | - if ( empty( $from_name ) ) { |
|
144 | - $from_name = get_bloginfo( 'name' ); |
|
143 | + if (empty($from_name)) { |
|
144 | + $from_name = get_bloginfo('name'); |
|
145 | 145 | } |
146 | 146 | |
147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
147 | + return wp_specialchars_decode($from_name, ENT_QUOTES); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function get_from_address() { |
154 | 154 | |
155 | - $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
|
155 | + $from_address = wpinv_get_option('email_from', $this->default_from_address()); |
|
156 | 156 | |
157 | - if ( ! is_email( $from_address ) ) { |
|
158 | - $from_address = $this->default_from_address(); |
|
157 | + if (!is_email($from_address)) { |
|
158 | + $from_address = $this->default_from_address(); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $from_address; |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | public function default_from_address() { |
175 | 175 | |
176 | 176 | // Get the site domain and get rid of www. |
177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | - $sitename = substr( $sitename, 4 ); |
|
177 | + $sitename = strtolower($_SERVER['SERVER_NAME']); |
|
178 | + if (substr($sitename, 0, 4) == 'www.') { |
|
179 | + $sitename = substr($sitename, 4); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $from_email = 'wordpress@' . $sitename; |
183 | 183 | |
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
184 | + return apply_filters('getpaid_default_from_address', $from_email); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | |
196 | 196 | $reply_to = wpinv_get_admin_email(); |
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
198 | + if (!is_email($reply_to)) { |
|
199 | + $reply_to = get_option('admin_email'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $reply_to; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | */ |
209 | 209 | public function get_content_type() { |
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
210 | + return apply_filters('getpaid_email_content_type', 'text/html', $this); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return array wp_mail_data. |
217 | 217 | */ |
218 | - public function ensure_email_content( $args ) { |
|
218 | + public function ensure_email_content($args) { |
|
219 | 219 | $args['message'] = $this->wp_mail_data['email']; |
220 | 220 | return $args; |
221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function after_sending() { |
228 | 228 | |
229 | - do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
|
230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
229 | + do_action('getpaid_after_send_email', $this->wp_mail_data); |
|
230 | + remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
231 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
232 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
233 | + remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 |