@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | 'subscription_initial_payment' => 'get_subscription_initial', |
26 | 26 | ); |
27 | 27 | |
28 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
29 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), array( __CLASS__, $function ) ); |
|
28 | + foreach ($shortcodes as $shortcode => $function) { |
|
29 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), array(__CLASS__, $function)); |
|
30 | 30 | } // END foreach() |
31 | 31 | |
32 | 32 | // Adds support for product types that have subscription scheme options. |
33 | - add_filter( 'woocommerce_is_subscription', array( __CLASS__, 'force_is_subscription' ), 10, 3 ); |
|
33 | + add_filter('woocommerce_is_subscription', array(__CLASS__, 'force_is_subscription'), 10, 3); |
|
34 | 34 | |
35 | 35 | // Adds alternative subscription price from the WooCommerce extension "Subscribe to All the Things" and returns the lowest scheme price. |
36 | - add_action( 'woocommerce_subscriptions_shortcode_get_price', array( __CLASS__, 'get_satt_lowest_price' ), 10, 1 ); |
|
36 | + add_action('woocommerce_subscriptions_shortcode_get_price', array(__CLASS__, 'get_satt_lowest_price'), 10, 1); |
|
37 | 37 | } // END init() |
38 | 38 | |
39 | 39 | /** |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @return array |
45 | 45 | */ |
46 | 46 | public static function get_supported_product_types() { |
47 | - return apply_filters( 'wcss_product_types', array( |
|
47 | + return apply_filters('wcss_product_types', array( |
|
48 | 48 | 'subscription', |
49 | 49 | 'subscription-variation', |
50 | - ) ); |
|
50 | + )); |
|
51 | 51 | } // END get_supported_product_types() |
52 | 52 | |
53 | 53 | /** |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | * @param object $product |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - public static function force_is_subscription( $is_subscription, $product_id, $product ) { |
|
62 | - if ( is_object( $product_id ) ) { |
|
61 | + public static function force_is_subscription($is_subscription, $product_id, $product) { |
|
62 | + if (is_object($product_id)) { |
|
63 | 63 | $product = $product_id; |
64 | 64 | $product_id = $product->id; |
65 | - } elseif ( is_numeric( $product_id ) ) { |
|
66 | - $product = wc_get_product( $product_id ); |
|
65 | + } elseif (is_numeric($product_id)) { |
|
66 | + $product = wc_get_product($product_id); |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( in_array( $product->product_type, self::get_supported_product_types() ) ) { |
|
70 | - if ( class_exists( 'WCS_ATT_Schemes' ) && WCS_ATT_Schemes::get_product_subscription_schemes( $product ) ) { |
|
69 | + if (in_array($product->product_type, self::get_supported_product_types())) { |
|
70 | + if (class_exists('WCS_ATT_Schemes') && WCS_ATT_Schemes::get_product_subscription_schemes($product)) { |
|
71 | 71 | $is_subscription = true; |
72 | 72 | } |
73 | 73 | } |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | * @param WC_Product $product |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public static function get_price( $product ) { |
|
85 | - if ( WC_Subscriptions_Product::get_price( $product->id ) > 0 ) { |
|
84 | + public static function get_price($product) { |
|
85 | + if (WC_Subscriptions_Product::get_price($product->id) > 0) { |
|
86 | 86 | |
87 | - return ecs_html( WC_Subscriptions_Product::get_price( $product->id, array( |
|
87 | + return ecs_html(WC_Subscriptions_Product::get_price($product->id, array( |
|
88 | 88 | 'subscription_period' => false, |
89 | 89 | 'subscription_length' => false, |
90 | 90 | 'sign_up_fee' => false, |
91 | 91 | 'trial_length' => false, |
92 | - ) ) ); |
|
92 | + ))); |
|
93 | 93 | |
94 | 94 | } else { |
95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * hooked: get_satt_lowest_price - 10 |
100 | 100 | */ |
101 | - do_action( 'woocommerce_subscriptions_shortcode_get_price', $product ); |
|
101 | + do_action('woocommerce_subscriptions_shortcode_get_price', $product); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | } // END get_price() |
@@ -109,34 +109,34 @@ discard block |
||
109 | 109 | * @param WC_Product $product |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public static function get_satt_lowest_price( $product ) { |
|
113 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
114 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product ); |
|
112 | + public static function get_satt_lowest_price($product) { |
|
113 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
114 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product); |
|
115 | 115 | |
116 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product, $product_level_schemes ); |
|
116 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product, $product_level_schemes); |
|
117 | 117 | |
118 | 118 | // Override price? |
119 | - $override = $lowest_scheme['scheme']['subscription_pricing_method']; |
|
119 | + $override = $lowest_scheme[ 'scheme' ][ 'subscription_pricing_method' ]; |
|
120 | 120 | |
121 | 121 | // Discount? |
122 | - $discount = $lowest_scheme['scheme']['subscription_discount']; |
|
122 | + $discount = $lowest_scheme[ 'scheme' ][ 'subscription_discount' ]; |
|
123 | 123 | |
124 | 124 | // Prices |
125 | 125 | $prices = array( |
126 | - 'price' => $lowest_scheme['price'], |
|
127 | - 'regular_price' => $lowest_scheme['regular_price'], |
|
128 | - 'sale_price' => $lowest_scheme['sale_price'], |
|
129 | - 'subscription_price' => $lowest_scheme['scheme']['subscription_price'], |
|
130 | - 'subscription_regular_price' => $lowest_scheme['scheme']['subscription_regular_price'], |
|
131 | - 'subscription_sale_price' => $lowest_scheme['scheme']['subscription_sale_price'] |
|
126 | + 'price' => $lowest_scheme[ 'price' ], |
|
127 | + 'regular_price' => $lowest_scheme[ 'regular_price' ], |
|
128 | + 'sale_price' => $lowest_scheme[ 'sale_price' ], |
|
129 | + 'subscription_price' => $lowest_scheme[ 'scheme' ][ 'subscription_price' ], |
|
130 | + 'subscription_regular_price' => $lowest_scheme[ 'scheme' ][ 'subscription_regular_price' ], |
|
131 | + 'subscription_sale_price' => $lowest_scheme[ 'scheme' ][ 'subscription_sale_price' ] |
|
132 | 132 | ); |
133 | 133 | |
134 | - if ( $override === 'inherit' && ! empty( $discount ) && $prices[ 'price' ] > 0 ) { |
|
135 | - $price = empty( $discount ) ? $price : ( empty( $prices[ 'regular_price' ] ) ? $prices[ 'regular_price' ] : round( ( double ) $prices[ 'regular_price' ] * ( 100 - $discount ) / 100, wc_get_price_decimals() ) ); |
|
134 | + if ($override === 'inherit' && ! empty($discount) && $prices[ 'price' ] > 0) { |
|
135 | + $price = empty($discount) ? $price : (empty($prices[ 'regular_price' ]) ? $prices[ 'regular_price' ] : round((double) $prices[ 'regular_price' ] * (100 - $discount) / 100, wc_get_price_decimals())); |
|
136 | 136 | } else { |
137 | - $price = $prices['subscription_price']; |
|
137 | + $price = $prices[ 'subscription_price' ]; |
|
138 | 138 | |
139 | - if ( $prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ] ) { |
|
139 | + if ($prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ]) { |
|
140 | 140 | $price = $prices[ 'subscription_sale_price' ]; |
141 | 141 | } |
142 | 142 | } |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | * @param array $atts |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public static function get_subscription_price( $atts ) { |
|
157 | + public static function get_subscription_price($atts) { |
|
158 | 158 | global $wpdb, $post; |
159 | 159 | |
160 | - $defaults = shortcode_atts( array( |
|
160 | + $defaults = shortcode_atts(array( |
|
161 | 161 | 'id' => '', |
162 | 162 | 'sku' => '', |
163 | 163 | 'period' => false, |
@@ -166,47 +166,47 @@ discard block |
||
166 | 166 | 'trial_length' => false, |
167 | 167 | 'before_price' => '', |
168 | 168 | 'after_price' => '', |
169 | - ), $atts ); |
|
169 | + ), $atts); |
|
170 | 170 | |
171 | - $atts = wp_parse_args( $atts, $defaults ); |
|
171 | + $atts = wp_parse_args($atts, $defaults); |
|
172 | 172 | |
173 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
174 | - $product_data = wc_get_product( $atts['id'] ); |
|
175 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
176 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
177 | - $product_data = get_post( $product_id ); |
|
173 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
174 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
175 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
176 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
177 | + $product_data = get_post($product_id); |
|
178 | 178 | } else { |
179 | - $product_data = wc_get_product( $post->ID ); |
|
179 | + $product_data = wc_get_product($post->ID); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Check that the product type is supported. Return blank if not supported. |
183 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
183 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
184 | 184 | return ''; |
185 | 185 | } |
186 | 186 | |
187 | 187 | ob_start(); |
188 | 188 | |
189 | - $price_html = WC_Subscriptions_Product::get_price_string( $product_data->id, array( |
|
190 | - 'price' => self::get_price( $product_data ), |
|
191 | - 'subscription_period' => isset( $atts['period'] ) ? $atts['period'] : true, |
|
192 | - 'subscription_length' => isset( $atts['length'] ) ? $atts['length'] : true, |
|
193 | - 'sign_up_fee' => isset( $atts['sign_up_fee'] ) ? $atts['sign_up_fee'] : true, |
|
194 | - 'trial_length' => isset( $atts['trial_length'] ) ? $atts['trial_length'] : true, |
|
195 | - ) ); |
|
189 | + $price_html = WC_Subscriptions_Product::get_price_string($product_data->id, array( |
|
190 | + 'price' => self::get_price($product_data), |
|
191 | + 'subscription_period' => isset($atts[ 'period' ]) ? $atts[ 'period' ] : true, |
|
192 | + 'subscription_length' => isset($atts[ 'length' ]) ? $atts[ 'length' ] : true, |
|
193 | + 'sign_up_fee' => isset($atts[ 'sign_up_fee' ]) ? $atts[ 'sign_up_fee' ] : true, |
|
194 | + 'trial_length' => isset($atts[ 'trial_length' ]) ? $atts[ 'trial_length' ] : true, |
|
195 | + )); |
|
196 | 196 | |
197 | 197 | // Clean the subscription price wrapper. |
198 | 198 | $price_html = str_replace('<span class="subscription-details">', '', $price_html); |
199 | 199 | $price_html = str_replace('</span">', '', $price_html); |
200 | 200 | |
201 | 201 | // Trim the whitespace. |
202 | - $price_html = trim( $price_html ); |
|
202 | + $price_html = trim($price_html); |
|
203 | 203 | |
204 | 204 | // Convert to Price Tag. |
205 | - $price_html = wc_price( $price_html ); |
|
205 | + $price_html = wc_price($price_html); |
|
206 | 206 | |
207 | - $price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price_html, $atts['after_price'] ); |
|
207 | + $price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price_html, $atts[ 'after_price' ]); |
|
208 | 208 | |
209 | - echo html_entity_decode( $price_html ); |
|
209 | + echo html_entity_decode($price_html); |
|
210 | 210 | |
211 | 211 | return ob_get_clean(); |
212 | 212 | } // END get_subscription_price() |
@@ -219,27 +219,27 @@ discard block |
||
219 | 219 | * @param array $atts |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - public static function get_subscription_discount( $atts ) { |
|
222 | + public static function get_subscription_discount($atts) { |
|
223 | 223 | global $wpdb, $post; |
224 | 224 | |
225 | - $defaults = shortcode_atts( array( |
|
225 | + $defaults = shortcode_atts(array( |
|
226 | 226 | 'id' => '', |
227 | 227 | 'sku' => '', |
228 | - ), $atts ); |
|
228 | + ), $atts); |
|
229 | 229 | |
230 | - $atts = wp_parse_args( $atts, $defaults ); |
|
230 | + $atts = wp_parse_args($atts, $defaults); |
|
231 | 231 | |
232 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
233 | - $product_data = wc_get_product( $atts['id'] ); |
|
234 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
235 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
236 | - $product_data = get_post( $product_id ); |
|
232 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
233 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
234 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
235 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
236 | + $product_data = get_post($product_id); |
|
237 | 237 | } else { |
238 | - $product_data = wc_get_product( $post->ID ); |
|
238 | + $product_data = wc_get_product($post->ID); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // Check that the product type is supported. Return blank if not supported. |
242 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
242 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
243 | 243 | return ''; |
244 | 244 | } |
245 | 245 | |
@@ -248,16 +248,16 @@ discard block |
||
248 | 248 | $discount = ''; // Returns empty by default. |
249 | 249 | |
250 | 250 | // Get Subscription Discount |
251 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
252 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
251 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
252 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
253 | 253 | |
254 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
254 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
255 | 255 | |
256 | - $discount = $lowest_scheme['scheme']['subscription_discount']; |
|
256 | + $discount = $lowest_scheme[ 'scheme' ][ 'subscription_discount' ]; |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( ! empty( $discount ) && is_numeric( $discount ) ) { |
|
260 | - echo sprintf( __( '%s%s %s', WCSS::TEXT_DOMAIN ), $discount, '%', apply_filters( 'wcs_shortcodes_sub_discount_string', __( 'discount', WCSS::TEXT_DOMAIN ) ) ); |
|
259 | + if ( ! empty($discount) && is_numeric($discount)) { |
|
260 | + echo sprintf(__('%s%s %s', WCSS::TEXT_DOMAIN), $discount, '%', apply_filters('wcs_shortcodes_sub_discount_string', __('discount', WCSS::TEXT_DOMAIN))); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return ob_get_clean(); |
@@ -269,49 +269,49 @@ discard block |
||
269 | 269 | * @param array $atts |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function get_subscription_period( $atts ) { |
|
272 | + public static function get_subscription_period($atts) { |
|
273 | 273 | global $wpdb, $post; |
274 | 274 | |
275 | - $defaults = shortcode_atts( array( |
|
275 | + $defaults = shortcode_atts(array( |
|
276 | 276 | 'id' => '', |
277 | 277 | 'sku' => '', |
278 | 278 | 'just_period' => true |
279 | - ), $atts ); |
|
279 | + ), $atts); |
|
280 | 280 | |
281 | - $atts = wp_parse_args( $atts, $defaults ); |
|
281 | + $atts = wp_parse_args($atts, $defaults); |
|
282 | 282 | |
283 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
284 | - $product_data = wc_get_product( $atts['id'] ); |
|
285 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
286 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
287 | - $product_data = get_post( $product_id ); |
|
283 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
284 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
285 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
286 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
287 | + $product_data = get_post($product_id); |
|
288 | 288 | } else { |
289 | - $product_data = wc_get_product( $post->ID ); |
|
289 | + $product_data = wc_get_product($post->ID); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Check that the product type is supported. Return blank if not supported. |
293 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
293 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
294 | 294 | return ''; |
295 | 295 | } |
296 | 296 | |
297 | 297 | ob_start(); |
298 | 298 | |
299 | 299 | // Get Subscription Period |
300 | - $period = WC_Subscriptions_Product::get_period( $product_data ); |
|
300 | + $period = WC_Subscriptions_Product::get_period($product_data); |
|
301 | 301 | |
302 | 302 | // If the period is empty, look for alternative. |
303 | - if ( empty( $period ) ) { |
|
304 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
305 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
303 | + if (empty($period)) { |
|
304 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
305 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
306 | 306 | |
307 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
307 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
308 | 308 | |
309 | - $period = $lowest_scheme['scheme']['subscription_period']; |
|
309 | + $period = $lowest_scheme[ 'scheme' ][ 'subscription_period' ]; |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - if ( $atts['just_period'] ) { |
|
314 | - $period = sprintf( __( 'Per %s', WCSS::TEXT_DOMAIN ), $period ); |
|
313 | + if ($atts[ 'just_period' ]) { |
|
314 | + $period = sprintf(__('Per %s', WCSS::TEXT_DOMAIN), $period); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | echo ucwords($period); |
@@ -325,43 +325,43 @@ discard block |
||
325 | 325 | * @param array $atts |
326 | 326 | * @return string |
327 | 327 | */ |
328 | - public static function get_subscription_period_interval( $atts ) { |
|
328 | + public static function get_subscription_period_interval($atts) { |
|
329 | 329 | global $wpdb, $post; |
330 | 330 | |
331 | - $defaults = shortcode_atts( array( |
|
331 | + $defaults = shortcode_atts(array( |
|
332 | 332 | 'id' => '', |
333 | 333 | 'sku' => '', |
334 | - ), $atts ); |
|
334 | + ), $atts); |
|
335 | 335 | |
336 | - $atts = wp_parse_args( $atts, $defaults ); |
|
336 | + $atts = wp_parse_args($atts, $defaults); |
|
337 | 337 | |
338 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
339 | - $product_data = wc_get_product( $atts['id'] ); |
|
340 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
341 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
342 | - $product_data = get_post( $product_id ); |
|
338 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
339 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
340 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
341 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
342 | + $product_data = get_post($product_id); |
|
343 | 343 | } else { |
344 | - $product_data = wc_get_product( $post->ID ); |
|
344 | + $product_data = wc_get_product($post->ID); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | // Check that the product type is supported. Return blank if not supported. |
348 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
348 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
349 | 349 | return ''; |
350 | 350 | } |
351 | 351 | |
352 | 352 | ob_start(); |
353 | 353 | |
354 | 354 | // Get Subscription Period Interval |
355 | - $period_interval = WC_Subscriptions_Product::get_interval( $product_data ); |
|
355 | + $period_interval = WC_Subscriptions_Product::get_interval($product_data); |
|
356 | 356 | |
357 | 357 | // If the period is empty, look for alternative. |
358 | - if ( empty( $period_interval ) ) { |
|
359 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
360 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
358 | + if (empty($period_interval)) { |
|
359 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
360 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
361 | 361 | |
362 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
362 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
363 | 363 | |
364 | - $period_interval = $lowest_scheme['scheme']['subscription_period_interval']; |
|
364 | + $period_interval = $lowest_scheme[ 'scheme' ][ 'subscription_period_interval' ]; |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
@@ -376,49 +376,49 @@ discard block |
||
376 | 376 | * @param array $atts |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public static function get_subscription_length( $atts ) { |
|
379 | + public static function get_subscription_length($atts) { |
|
380 | 380 | global $wpdb, $post; |
381 | 381 | |
382 | - $defaults = shortcode_atts( array( |
|
382 | + $defaults = shortcode_atts(array( |
|
383 | 383 | 'id' => '', |
384 | 384 | 'sku' => '', |
385 | - ), $atts ); |
|
385 | + ), $atts); |
|
386 | 386 | |
387 | - $atts = wp_parse_args( $atts, $defaults ); |
|
387 | + $atts = wp_parse_args($atts, $defaults); |
|
388 | 388 | |
389 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
390 | - $product_data = wc_get_product( $atts['id'] ); |
|
391 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
392 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
393 | - $product_data = get_post( $product_id ); |
|
389 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
390 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
391 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
392 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
393 | + $product_data = get_post($product_id); |
|
394 | 394 | } else { |
395 | - $product_data = wc_get_product( $post->ID ); |
|
395 | + $product_data = wc_get_product($post->ID); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | // Check that the product type is supported. Return blank if not supported. |
399 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
399 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
400 | 400 | return ''; |
401 | 401 | } |
402 | 402 | |
403 | 403 | ob_start(); |
404 | 404 | |
405 | 405 | // Get Subscription Length |
406 | - $length = WC_Subscriptions_Product::get_length( $product_data ); |
|
406 | + $length = WC_Subscriptions_Product::get_length($product_data); |
|
407 | 407 | |
408 | 408 | // If the length is empty, look for alternative. |
409 | - if ( empty( $length ) ) { |
|
410 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
411 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
409 | + if (empty($length)) { |
|
410 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
411 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
412 | 412 | |
413 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
413 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
414 | 414 | |
415 | - $period = self::get_subscription_period( array( 'id' => $product_data->id, 'just_period' => false ) ); |
|
416 | - $length = $lowest_scheme['scheme']['subscription_length']; |
|
415 | + $period = self::get_subscription_period(array('id' => $product_data->id, 'just_period' => false)); |
|
416 | + $length = $lowest_scheme[ 'scheme' ][ 'subscription_length' ]; |
|
417 | 417 | |
418 | - if ( $length > 0 ) { |
|
419 | - $length = sprintf( '%s %s', $length, $period ); |
|
418 | + if ($length > 0) { |
|
419 | + $length = sprintf('%s %s', $length, $period); |
|
420 | 420 | } else { |
421 | - $length = sprintf( __( 'Every %s', WCSS::TEXT_DOMAIN ), $period ); |
|
421 | + $length = sprintf(__('Every %s', WCSS::TEXT_DOMAIN), $period); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
@@ -434,56 +434,56 @@ discard block |
||
434 | 434 | * @param array $atts |
435 | 435 | * @return string |
436 | 436 | */ |
437 | - public static function get_subscription_sign_up_fee( $atts ) { |
|
437 | + public static function get_subscription_sign_up_fee($atts) { |
|
438 | 438 | global $wpdb, $post; |
439 | 439 | |
440 | - $defaults = shortcode_atts( array( |
|
440 | + $defaults = shortcode_atts(array( |
|
441 | 441 | 'id' => '', |
442 | 442 | 'sku' => '', |
443 | 443 | 'before_price' => '', |
444 | 444 | 'after_price' => '', |
445 | - ), $atts ); |
|
445 | + ), $atts); |
|
446 | 446 | |
447 | - $atts = wp_parse_args( $atts, $defaults ); |
|
447 | + $atts = wp_parse_args($atts, $defaults); |
|
448 | 448 | |
449 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
450 | - $product_data = wc_get_product( $atts['id'] ); |
|
451 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
452 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
453 | - $product_data = get_post( $product_id ); |
|
449 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
450 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
451 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
452 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
453 | + $product_data = get_post($product_id); |
|
454 | 454 | } else { |
455 | - $product_data = wc_get_product( $post->ID ); |
|
455 | + $product_data = wc_get_product($post->ID); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | // Check that the product type is supported. Return blank if not supported. |
459 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
459 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
460 | 460 | return ''; |
461 | 461 | } |
462 | 462 | |
463 | 463 | ob_start(); |
464 | 464 | |
465 | 465 | // Get Subscription Sign Up Fee |
466 | - $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee( $product_data ); |
|
466 | + $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee($product_data); |
|
467 | 467 | |
468 | 468 | // If the sign up fee is empty, look for alternative. |
469 | - if ( empty( $sign_up_fee ) ) { |
|
470 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
471 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
469 | + if (empty($sign_up_fee)) { |
|
470 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
471 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
472 | 472 | |
473 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
473 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
474 | 474 | |
475 | - $sign_up_fee = $lowest_scheme['scheme']['subscription_sign_up_fee']; |
|
475 | + $sign_up_fee = $lowest_scheme[ 'scheme' ][ 'subscription_sign_up_fee' ]; |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | 479 | // Convert number into a price tag. |
480 | - if ( is_numeric( $sign_up_fee ) ) { |
|
481 | - $price_html = wc_price( $sign_up_fee ); |
|
480 | + if (is_numeric($sign_up_fee)) { |
|
481 | + $price_html = wc_price($sign_up_fee); |
|
482 | 482 | } |
483 | 483 | |
484 | - $price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price_html, $atts['after_price'] ); |
|
484 | + $price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price_html, $atts[ 'after_price' ]); |
|
485 | 485 | |
486 | - echo html_entity_decode( $price_html ); |
|
486 | + echo html_entity_decode($price_html); |
|
487 | 487 | |
488 | 488 | return ob_get_clean(); |
489 | 489 | } // END get_subscription_sign_up_fee() |
@@ -494,43 +494,43 @@ discard block |
||
494 | 494 | * @param array $atts |
495 | 495 | * @return string |
496 | 496 | */ |
497 | - public static function get_subscription_trial_length( $atts ) { |
|
497 | + public static function get_subscription_trial_length($atts) { |
|
498 | 498 | global $wpdb, $post; |
499 | 499 | |
500 | - $defaults = shortcode_atts( array( |
|
500 | + $defaults = shortcode_atts(array( |
|
501 | 501 | 'id' => '', |
502 | 502 | 'sku' => '', |
503 | - ), $atts ); |
|
503 | + ), $atts); |
|
504 | 504 | |
505 | - $atts = wp_parse_args( $atts, $defaults ); |
|
505 | + $atts = wp_parse_args($atts, $defaults); |
|
506 | 506 | |
507 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
508 | - $product_data = wc_get_product( $atts['id'] ); |
|
509 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
510 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
511 | - $product_data = get_post( $product_id ); |
|
507 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
508 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
509 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
510 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
511 | + $product_data = get_post($product_id); |
|
512 | 512 | } else { |
513 | - $product_data = wc_get_product( $post->ID ); |
|
513 | + $product_data = wc_get_product($post->ID); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | // Check that the product type is supported. Return blank if not supported. |
517 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
517 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
518 | 518 | return ''; |
519 | 519 | } |
520 | 520 | |
521 | 521 | ob_start(); |
522 | 522 | |
523 | 523 | // Get Subscription Trial Length |
524 | - $trial_length = WC_Subscriptions_Product::get_trial_length( $product_data ); |
|
524 | + $trial_length = WC_Subscriptions_Product::get_trial_length($product_data); |
|
525 | 525 | |
526 | 526 | // If the trial length is empty, look for alternative. |
527 | - if ( empty( $trial_length ) ) { |
|
528 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
529 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
527 | + if (empty($trial_length)) { |
|
528 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
529 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
530 | 530 | |
531 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
531 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
532 | 532 | |
533 | - $trial_length = $lowest_scheme['scheme']['subscription_trial_length']; |
|
533 | + $trial_length = $lowest_scheme[ 'scheme' ][ 'subscription_trial_length' ]; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | |
@@ -545,47 +545,47 @@ discard block |
||
545 | 545 | * @param array $atts |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public static function get_subscription_trial_period( $atts ) { |
|
548 | + public static function get_subscription_trial_period($atts) { |
|
549 | 549 | global $wpdb, $post; |
550 | 550 | |
551 | - $defaults = shortcode_atts( array( |
|
551 | + $defaults = shortcode_atts(array( |
|
552 | 552 | 'id' => '', |
553 | 553 | 'sku' => '', |
554 | - ), $atts ); |
|
554 | + ), $atts); |
|
555 | 555 | |
556 | - $atts = wp_parse_args( $atts, $defaults ); |
|
556 | + $atts = wp_parse_args($atts, $defaults); |
|
557 | 557 | |
558 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
559 | - $product_data = wc_get_product( $atts['id'] ); |
|
560 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
561 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
562 | - $product_data = get_post( $product_id ); |
|
558 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
559 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
560 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
561 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
562 | + $product_data = get_post($product_id); |
|
563 | 563 | } else { |
564 | - $product_data = wc_get_product( $post->ID ); |
|
564 | + $product_data = wc_get_product($post->ID); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | // Check that the product type is supported. Return blank if not supported. |
568 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
568 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
569 | 569 | return ''; |
570 | 570 | } |
571 | 571 | |
572 | 572 | ob_start(); |
573 | 573 | |
574 | 574 | // Get Subscription Trial Period |
575 | - $trial_period = WC_Subscriptions_Product::get_trial_period( $product_data ); |
|
575 | + $trial_period = WC_Subscriptions_Product::get_trial_period($product_data); |
|
576 | 576 | |
577 | 577 | // If the trial period is empty, look for alternative. |
578 | - if ( empty( $trial_period ) ) { |
|
579 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
580 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product_data ); |
|
578 | + if (empty($trial_period)) { |
|
579 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
580 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product_data); |
|
581 | 581 | |
582 | - $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product_data, $product_level_schemes ); |
|
582 | + $lowest_scheme = WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product_data, $product_level_schemes); |
|
583 | 583 | |
584 | - $trial_length = $lowest_scheme['scheme']['subscription_trial_length']; |
|
585 | - $trial_period = $lowest_scheme['scheme']['subscription_trial_period']; |
|
584 | + $trial_length = $lowest_scheme[ 'scheme' ][ 'subscription_trial_length' ]; |
|
585 | + $trial_period = $lowest_scheme[ 'scheme' ][ 'subscription_trial_period' ]; |
|
586 | 586 | |
587 | - if ( ! empty( $trial_length ) && $trial_length > 0 ) { |
|
588 | - $trial_period = sprintf( __( '%s%s', WCSS::TEXT_DOMAIN ), $trial_period, __( 's', WCSS::TEXT_DOMAIN ) ); |
|
587 | + if ( ! empty($trial_length) && $trial_length > 0) { |
|
588 | + $trial_period = sprintf(__('%s%s', WCSS::TEXT_DOMAIN), $trial_period, __('s', WCSS::TEXT_DOMAIN)); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | } |
@@ -601,84 +601,84 @@ discard block |
||
601 | 601 | * @param array $atts |
602 | 602 | * @return string |
603 | 603 | */ |
604 | - public static function get_subscription_first_payment( $atts ) { |
|
604 | + public static function get_subscription_first_payment($atts) { |
|
605 | 605 | global $wpdb, $post; |
606 | 606 | |
607 | - $defaults = shortcode_atts( array( |
|
607 | + $defaults = shortcode_atts(array( |
|
608 | 608 | 'id' => '', |
609 | 609 | 'sku' => '', |
610 | 610 | 'show_time' => false, |
611 | 611 | 'from_date' => '', |
612 | 612 | 'timezone' => 'gmt', |
613 | 613 | 'format' => 'timestamp' |
614 | - ), $atts ); |
|
614 | + ), $atts); |
|
615 | 615 | |
616 | - $atts = wp_parse_args( $atts, $defaults ); |
|
616 | + $atts = wp_parse_args($atts, $defaults); |
|
617 | 617 | |
618 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
619 | - $product_data = wc_get_product( $atts['id'] ); |
|
620 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
621 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
622 | - $product_data = get_post( $product_id ); |
|
618 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
619 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
620 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
621 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
622 | + $product_data = get_post($product_id); |
|
623 | 623 | } else { |
624 | - $product_data = wc_get_product( $post->ID ); |
|
624 | + $product_data = wc_get_product($post->ID); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | // Check that the product type is supported. Return blank if not supported. |
628 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
628 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
629 | 629 | return ''; |
630 | 630 | } |
631 | 631 | |
632 | 632 | ob_start(); |
633 | 633 | |
634 | - $billing_interval = self::get_subscription_period_interval( array( 'id' => $product_data->id ) ); |
|
635 | - $billing_length = self::get_subscription_length( array( 'id' => $product_data->id ) ); |
|
636 | - $trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) ); |
|
634 | + $billing_interval = self::get_subscription_period_interval(array('id' => $product_data->id)); |
|
635 | + $billing_length = self::get_subscription_length(array('id' => $product_data->id)); |
|
636 | + $trial_length = self::get_subscription_trial_length(array('id' => $product_data->id)); |
|
637 | 637 | |
638 | - $from_date = $atts['from_date']; |
|
638 | + $from_date = $atts[ 'from_date' ]; |
|
639 | 639 | |
640 | - if ( $billing_interval != $billing_length || $trial_length > 0 ) { |
|
641 | - if ( empty( $from_date ) ) { |
|
642 | - $from_date = gmdate( 'Y-m-d H:i:s' ); |
|
640 | + if ($billing_interval != $billing_length || $trial_length > 0) { |
|
641 | + if (empty($from_date)) { |
|
642 | + $from_date = gmdate('Y-m-d H:i:s'); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | // If the subscription has a free trial period, the first renewal is the same as the expiration of the free trial |
646 | - if ( $trial_length > 0 ) { |
|
647 | - $first_renewal_timestamp = strtotime( WC_Subscriptions_Product::get_trial_expiration_date( $product_data->id, $from_date ) ); |
|
646 | + if ($trial_length > 0) { |
|
647 | + $first_renewal_timestamp = strtotime(WC_Subscriptions_Product::get_trial_expiration_date($product_data->id, $from_date)); |
|
648 | 648 | } else { |
649 | - $from_timestamp = strtotime( $from_date ); |
|
650 | - $billing_period = self::get_subscription_period( array( 'id' => $product_data->id ) ); |
|
649 | + $from_timestamp = strtotime($from_date); |
|
650 | + $billing_period = self::get_subscription_period(array('id' => $product_data->id)); |
|
651 | 651 | |
652 | - if ( 'month' == $billing_period ) { |
|
653 | - $first_renewal_timestamp = wcs_add_months( $from_timestamp, $billing_interval ); |
|
652 | + if ('month' == $billing_period) { |
|
653 | + $first_renewal_timestamp = wcs_add_months($from_timestamp, $billing_interval); |
|
654 | 654 | } else { |
655 | - $first_renewal_timestamp = strtotime( "+ $billing_interval {$billing_period}s", $from_timestamp ); |
|
655 | + $first_renewal_timestamp = strtotime("+ $billing_interval {$billing_period}s", $from_timestamp); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( 'site' == $atts['timezone'] ) { |
|
659 | - $first_renewal_timestamp += ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
|
658 | + if ('site' == $atts[ 'timezone' ]) { |
|
659 | + $first_renewal_timestamp += (get_option('gmt_offset') * HOUR_IN_SECONDS); |
|
660 | 660 | } |
661 | 661 | } |
662 | 662 | } else { |
663 | 663 | $first_renewal_timestamp = 0; |
664 | 664 | } |
665 | 665 | |
666 | - if ( $first_renewal_timestamp > 0 ) { |
|
667 | - if ( $atts['show_time'] ) { |
|
668 | - if ( 'timestamp' == $atts['format'] ) { |
|
666 | + if ($first_renewal_timestamp > 0) { |
|
667 | + if ($atts[ 'show_time' ]) { |
|
668 | + if ('timestamp' == $atts[ 'format' ]) { |
|
669 | 669 | $date_format = 'Y-m-d H:i:s'; |
670 | 670 | } else { |
671 | 671 | $date_format = 'D jS M Y H:i A'; |
672 | 672 | } |
673 | 673 | } else { |
674 | - if ( 'timestamp' == $atts['format'] ) { |
|
674 | + if ('timestamp' == $atts[ 'format' ]) { |
|
675 | 675 | $date_format = 'Y-m-d'; |
676 | 676 | } else { |
677 | 677 | $date_format = 'D jS M Y'; |
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | - $first_payment = date( $date_format, $first_renewal_timestamp ); |
|
681 | + $first_payment = date($date_format, $first_renewal_timestamp); |
|
682 | 682 | } else { |
683 | 683 | $first_payment = ''; |
684 | 684 | } |
@@ -694,27 +694,27 @@ discard block |
||
694 | 694 | * @param array $atts |
695 | 695 | * @return string |
696 | 696 | */ |
697 | - public static function get_subscription_initial( $atts ) { |
|
697 | + public static function get_subscription_initial($atts) { |
|
698 | 698 | global $wpdb, $post; |
699 | 699 | |
700 | - $defaults = shortcode_atts( array( |
|
700 | + $defaults = shortcode_atts(array( |
|
701 | 701 | 'id' => '', |
702 | 702 | 'sku' => '', |
703 | - ), $atts ); |
|
703 | + ), $atts); |
|
704 | 704 | |
705 | - $atts = wp_parse_args( $atts, $defaults ); |
|
705 | + $atts = wp_parse_args($atts, $defaults); |
|
706 | 706 | |
707 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
708 | - $product_data = wc_get_product( $atts['id'] ); |
|
709 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
710 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
711 | - $product_data = get_post( $product_id ); |
|
707 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
708 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
709 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
710 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
711 | + $product_data = get_post($product_id); |
|
712 | 712 | } else { |
713 | - $product_data = wc_get_product( $post->ID ); |
|
713 | + $product_data = wc_get_product($post->ID); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | // Check that the product type is supported. Return blank if not supported. |
717 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
717 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
718 | 718 | return ''; |
719 | 719 | } |
720 | 720 |