Completed
Push — master ( e2b75e...467e55 )
by Sébastien
02:30
created
includes/class-wcs-shortcodes.php 1 patch
Spacing   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
 			'subscription_initial_payment' => 'get_subscription_initial',
28 28
 		);
29 29
 
30
-		foreach ( $shortcodes as $shortcode => $function ) {
31
-			add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), array( __CLASS__, $function ) );
30
+		foreach ($shortcodes as $shortcode => $function) {
31
+			add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), array(__CLASS__, $function));
32 32
 		} // END foreach()
33 33
 
34 34
 		// Adds support for product types that have subscription scheme options.
35
-		add_filter( 'woocommerce_is_subscription', array( __CLASS__, 'force_is_subscription' ), 10, 3 );
35
+		add_filter('woocommerce_is_subscription', array(__CLASS__, 'force_is_subscription'), 10, 3);
36 36
 
37 37
 		// Adds alternative subscription price from the WooCommerce extension "Subscribe to All the Things" and returns the lowest scheme price.
38
-		add_action( 'woocommerce_subscriptions_shortcode_get_price', array( __CLASS__, 'get_satt_lowest_price' ), 10, 1 );
38
+		add_action('woocommerce_subscriptions_shortcode_get_price', array(__CLASS__, 'get_satt_lowest_price'), 10, 1);
39 39
 
40 40
 		// Adds the product types supported from the WooCommerce extension "Subscribe to All the Things".
41
-		add_filter( 'wcss_product_types', array( __CLASS__, 'support_product_types_for_wc_satt' ), 10, 1 );
41
+		add_filter('wcss_product_types', array(__CLASS__, 'support_product_types_for_wc_satt'), 10, 1);
42 42
 	} // END init()
43 43
 
44 44
 	/**
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 	 * @return array
50 50
 	 */
51 51
 	public static function get_supported_product_types() {
52
-		return apply_filters( 'wcss_product_types', array(
52
+		return apply_filters('wcss_product_types', array(
53 53
 			'subscription', 
54 54
 			'subscription-variation', 
55
-		) );
55
+		));
56 56
 	} // END get_supported_product_types()
57 57
 
58 58
 	/**
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
 	 * @param  object $product
64 64
 	 * @return bool
65 65
 	 */
66
-	public static function force_is_subscription( $is_subscription, $product_id, $product ) {
66
+	public static function force_is_subscription($is_subscription, $product_id, $product) {
67 67
 		/*if ( is_object( $product ) ) {
68 68
 			$product = $product;
69 69
 		} elseif ( is_numeric( $product_id ) ) {
70 70
 			$product = wc_get_product( $product_id );
71 71
 		}*/
72 72
 
73
-		if ( in_array( $product->product_type, self::get_supported_product_types() ) ) {
74
-			if ( class_exists( 'WCS_ATT_Schemes' ) && WCS_ATT_Schemes::get_product_subscription_schemes( $product ) ) {
73
+		if (in_array($product->product_type, self::get_supported_product_types())) {
74
+			if (class_exists('WCS_ATT_Schemes') && WCS_ATT_Schemes::get_product_subscription_schemes($product)) {
75 75
 				$is_subscription = true;
76 76
 			}
77 77
 		}
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
 	 * @param  WC_Product $product
86 86
 	 * @return string
87 87
 	 */
88
-	public static function get_price( $product ) {
89
-		if ( WC_Subscriptions_Product::get_price( $product->id ) > 0 ) {
88
+	public static function get_price($product) {
89
+		if (WC_Subscriptions_Product::get_price($product->id) > 0) {
90 90
 
91
-			return ecs_html( WC_Subscriptions_Product::get_price( $product->id, array(
91
+			return ecs_html(WC_Subscriptions_Product::get_price($product->id, array(
92 92
 				'subscription_period' => false,
93 93
 				'subscription_length' => false,
94 94
 				'sign_up_fee'         => false,
95 95
 				'trial_length'        => false,
96
-			) ) );
96
+			)));
97 97
 
98 98
 		} else {
99 99
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			 *
103 103
 			 * hooked: get_satt_lowest_price - 10
104 104
 			 */
105
-			do_action( 'woocommerce_subscriptions_shortcode_get_price', $product );
105
+			do_action('woocommerce_subscriptions_shortcode_get_price', $product);
106 106
 
107 107
 		}
108 108
 	} // END get_price()
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 	 * @param  WC_Product $product
115 115
 	 * @return string
116 116
 	 */
117
-	public static function get_satt_lowest_scheme_data( $product ) {
118
-		if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) {
119
-			$product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product );
117
+	public static function get_satt_lowest_scheme_data($product) {
118
+		if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) {
119
+			$product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product);
120 120
 
121
-			return WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product, $product_level_schemes );
121
+			return WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product, $product_level_schemes);
122 122
 		}
123 123
 	} // END get_satt_lowest_scheme()
124 124
 
@@ -129,42 +129,42 @@  discard block
 block discarded – undo
129 129
 	 * @param  WC_Product $product
130 130
 	 * @return string
131 131
 	 */
132
-	public static function get_satt_lowest_price( $product ) {
133
-		$scheme = self::get_satt_lowest_scheme_data( $product );
132
+	public static function get_satt_lowest_price($product) {
133
+		$scheme = self::get_satt_lowest_scheme_data($product);
134 134
 
135
-		if ( !empty( $scheme ) && is_array( $scheme ) ) {
135
+		if ( ! empty($scheme) && is_array($scheme)) {
136 136
 			// Override price?
137
-			$override = $scheme['scheme']['subscription_pricing_method'];
137
+			$override = $scheme[ 'scheme' ][ 'subscription_pricing_method' ];
138 138
 
139 139
 			// Discount?
140
-			$discount = $scheme['scheme']['subscription_discount'];
140
+			$discount = $scheme[ 'scheme' ][ 'subscription_discount' ];
141 141
 
142 142
 			// Prices
143 143
 			$prices = array(
144
-				'price'                      => $scheme['price'],
145
-				'regular_price'              => $scheme['regular_price'],
146
-				'sale_price'                 => $scheme['sale_price'],
147
-				'subscription_price'         => $scheme['scheme']['subscription_price'],
148
-				'subscription_regular_price' => $scheme['scheme']['subscription_regular_price'],
149
-				'subscription_sale_price'    => $scheme['scheme']['subscription_sale_price']
144
+				'price'                      => $scheme[ 'price' ],
145
+				'regular_price'              => $scheme[ 'regular_price' ],
146
+				'sale_price'                 => $scheme[ 'sale_price' ],
147
+				'subscription_price'         => $scheme[ 'scheme' ][ 'subscription_price' ],
148
+				'subscription_regular_price' => $scheme[ 'scheme' ][ 'subscription_regular_price' ],
149
+				'subscription_sale_price'    => $scheme[ 'scheme' ][ 'subscription_sale_price' ]
150 150
 			);
151 151
 
152 152
 			// Prepare the price
153 153
 			$price = '';
154 154
 
155
-			if ( 'inherit' == $override ) {
156
-				$price = empty( $discount ) ? $price : ( empty( $prices[ 'regular_price' ] ) ? $prices[ 'regular_price' ] : round( ( double ) $prices[ 'regular_price' ] * ( 100 - $discount ) / 100, wc_get_price_decimals() ) );
157
-			} else if ( 'override' == $override ) {
158
-				$price = $prices['subscription_price'];
155
+			if ('inherit' == $override) {
156
+				$price = empty($discount) ? $price : (empty($prices[ 'regular_price' ]) ? $prices[ 'regular_price' ] : round((double) $prices[ 'regular_price' ] * (100 - $discount) / 100, wc_get_price_decimals()));
157
+			} else if ('override' == $override) {
158
+				$price = $prices[ 'subscription_price' ];
159 159
 
160
-				if ( $prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ] ) {
160
+				if ($prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ]) {
161 161
 					$price = $prices[ 'subscription_sale_price' ];
162 162
 				}
163 163
 			}
164 164
 
165 165
 			// If the price is returned as an array, return just the first.
166
-			if ( is_array( $price ) ) {
167
-				$price = $price[0];
166
+			if (is_array($price)) {
167
+				$price = $price[ 0 ];
168 168
 			}
169 169
 
170 170
 			return $price;
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 	 * @param  array   $atts
181 181
 	 * @return string
182 182
 	 */
183
-	public static function get_subscription_price( $atts ) {
183
+	public static function get_subscription_price($atts) {
184 184
 		global $wpdb, $post;
185 185
 
186
-		$defaults = shortcode_atts( array(
186
+		$defaults = shortcode_atts(array(
187 187
 			'id'           => '',
188 188
 			'sku'          => '',
189 189
 			'period'       => false,
@@ -192,47 +192,47 @@  discard block
 block discarded – undo
192 192
 			'trial_length' => false,
193 193
 			'before_price' => '<span class="price subscription-price">',
194 194
 			'after_price'  => '</span>',
195
-		), $atts );
195
+		), $atts);
196 196
 
197
-		$atts = wp_parse_args( $atts, $defaults );
197
+		$atts = wp_parse_args($atts, $defaults);
198 198
 
199
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
200
-			$product_data = wc_get_product( $atts['id'] );
201
-		} elseif ( ! empty( $atts['sku'] ) ) {
202
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
203
-			$product_data = get_post( $product_id );
199
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
200
+			$product_data = wc_get_product($atts[ 'id' ]);
201
+		} elseif ( ! empty($atts[ 'sku' ])) {
202
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
203
+			$product_data = get_post($product_id);
204 204
 		} else {
205
-			$product_data = wc_get_product( $post->ID );
205
+			$product_data = wc_get_product($post->ID);
206 206
 		}
207 207
 
208 208
 		// Check that the product type is supported. Return blank if not supported.
209
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
209
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
210 210
 			return '';
211 211
 		}
212 212
 
213 213
 		ob_start();
214 214
 
215
-		$price_html = WC_Subscriptions_Product::get_price_string( $product_data->id, array(
216
-			'price'               => self::get_price( $product_data ),
217
-			'subscription_period' => isset( $atts['period'] ) ? $atts['period'] : true,
218
-			'subscription_length' => isset( $atts['length'] ) ? $atts['length'] : true,
219
-			'sign_up_fee'         => isset( $atts['sign_up_fee'] ) ? $atts['sign_up_fee'] : true,
220
-			'trial_length'        => isset( $atts['trial_length'] ) ? $atts['trial_length'] : true,
221
-		) );
215
+		$price_html = WC_Subscriptions_Product::get_price_string($product_data->id, array(
216
+			'price'               => self::get_price($product_data),
217
+			'subscription_period' => isset($atts[ 'period' ]) ? $atts[ 'period' ] : true,
218
+			'subscription_length' => isset($atts[ 'length' ]) ? $atts[ 'length' ] : true,
219
+			'sign_up_fee'         => isset($atts[ 'sign_up_fee' ]) ? $atts[ 'sign_up_fee' ] : true,
220
+			'trial_length'        => isset($atts[ 'trial_length' ]) ? $atts[ 'trial_length' ] : true,
221
+		));
222 222
 
223 223
 		// Clean the subscription price wrapper.
224 224
 		$price_html = str_replace('<span class="subscription-details">', '', $price_html);
225 225
 		$price_html = str_replace('</span">', '', $price_html);
226 226
 
227 227
 		// Trim the whitespace.
228
-		$price_html = trim( $price_html );
228
+		$price_html = trim($price_html);
229 229
 
230 230
 		// Convert to Price Tag.
231
-		$price_html = wc_price( $price_html );
231
+		$price_html = wc_price($price_html);
232 232
 
233
-		$price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price_html, $atts['after_price'] );
233
+		$price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price_html, $atts[ 'after_price' ]);
234 234
 
235
-		echo html_entity_decode( $price_html );
235
+		echo html_entity_decode($price_html);
236 236
 
237 237
 		return ob_get_clean();
238 238
 	} // END get_subscription_price()
@@ -245,72 +245,72 @@  discard block
 block discarded – undo
245 245
 	 * @param  array   $atts
246 246
 	 * @return string
247 247
 	 */
248
-	public static function get_subscription_price_meta( $atts ) {
248
+	public static function get_subscription_price_meta($atts) {
249 249
 		global $wpdb, $post;
250 250
 
251
-		$defaults = shortcode_atts( array(
251
+		$defaults = shortcode_atts(array(
252 252
 			'id'           => '',
253 253
 			'sku'          => '',
254 254
 			'meta'         => 'both',
255 255
 			'before_price' => '',
256 256
 			'after_price'  => '',
257
-		), $atts );
257
+		), $atts);
258 258
 
259
-		$atts = wp_parse_args( $atts, $defaults );
259
+		$atts = wp_parse_args($atts, $defaults);
260 260
 
261
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
262
-			$product_data = wc_get_product( $atts['id'] );
263
-		} elseif ( ! empty( $atts['sku'] ) ) {
264
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
265
-			$product_data = get_post( $product_id );
261
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
262
+			$product_data = wc_get_product($atts[ 'id' ]);
263
+		} elseif ( ! empty($atts[ 'sku' ])) {
264
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
265
+			$product_data = get_post($product_id);
266 266
 		} else {
267
-			$product_data = wc_get_product( $post->ID );
267
+			$product_data = wc_get_product($post->ID);
268 268
 		}
269 269
 
270 270
 		// Check that the product type is supported. Return blank if not supported.
271
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
271
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
272 272
 			return '';
273 273
 		}
274 274
 
275 275
 		ob_start();
276 276
 
277
-		$price = WC_Subscriptions_Product::get_price( $product_data->id );
277
+		$price = WC_Subscriptions_Product::get_price($product_data->id);
278 278
 
279 279
 		// Remove the subscription price wrapper.
280 280
 		$price_html = str_replace('<span class="subscription-details">', '', $price);
281 281
 		$price = str_replace('</span">', '', $price_html);
282 282
 
283 283
 		// If the subscription product has no price, then look for alternative.
284
-		if ( empty( $price ) ) {
285
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
284
+		if (empty($price)) {
285
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
286 286
 
287
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
287
+			if ( ! empty($scheme) && is_array($scheme)) {
288 288
 
289 289
 				$prices = array(
290
-					'price'                      => $scheme['price'],
291
-					'regular_price'              => $scheme['regular_price'],
292
-					'sale_price'                 => $scheme['sale_price'],
293
-					'method'                     => $scheme['scheme']['subscription_pricing_method'],
294
-					'subscription_price'         => $scheme['scheme']['subscription_price'],
295
-					'subscription_regular_price' => $scheme['scheme']['subscription_regular_price'],
296
-					'subscription_sale_price'    => $scheme['scheme']['subscription_sale_price']
290
+					'price'                      => $scheme[ 'price' ],
291
+					'regular_price'              => $scheme[ 'regular_price' ],
292
+					'sale_price'                 => $scheme[ 'sale_price' ],
293
+					'method'                     => $scheme[ 'scheme' ][ 'subscription_pricing_method' ],
294
+					'subscription_price'         => $scheme[ 'scheme' ][ 'subscription_price' ],
295
+					'subscription_regular_price' => $scheme[ 'scheme' ][ 'subscription_regular_price' ],
296
+					'subscription_sale_price'    => $scheme[ 'scheme' ][ 'subscription_sale_price' ]
297 297
 				);
298 298
 
299 299
 				// Return the subscription price based on the pricing method.
300
-				switch( $prices['method'] ) {
300
+				switch ($prices[ 'method' ]) {
301 301
 					case 'override':
302
-						$price         = $prices['subscription_price'];
303
-						$regular_price = $prices['subscription_regular_price'];
304
-						$sale_price    = $prices['subscription_sale_price'];
302
+						$price         = $prices[ 'subscription_price' ];
303
+						$regular_price = $prices[ 'subscription_regular_price' ];
304
+						$sale_price    = $prices[ 'subscription_sale_price' ];
305 305
 						break;
306 306
 					case 'inherit':
307
-						$discount      = $scheme['scheme']['subscription_discount'];
308
-						$price         = $prices['price'];
309
-						$regular_price = $prices['regular_price'];
310
-						$sale_price    = $prices['sale_price'];
307
+						$discount      = $scheme[ 'scheme' ][ 'subscription_discount' ];
308
+						$price         = $prices[ 'price' ];
309
+						$regular_price = $prices[ 'regular_price' ];
310
+						$sale_price    = $prices[ 'sale_price' ];
311 311
 
312
-						if ( !empty( $discount ) && $discount > 0 ) {
313
-							$sale_price = round( ( double ) $regular_price * ( 100 - $discount ) / 100, wc_get_price_decimals() );
312
+						if ( ! empty($discount) && $discount > 0) {
313
+							$sale_price = round((double) $regular_price * (100 - $discount) / 100, wc_get_price_decimals());
314 314
 						}
315 315
 
316 316
 						break;
@@ -318,39 +318,39 @@  discard block
 block discarded – undo
318 318
 
319 319
 				// Display both the regular price striked out and the sale price 
320 320
 				// should the active price be less than the regular price.
321
-				if ( $atts['meta'] != 'active' && !empty( $sale_price ) && $price < $regular_price ) {
322
-					$price = '<del>' . ( ( is_numeric( $regular_price ) ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( ( is_numeric( $sale_price ) ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>';
321
+				if ($atts[ 'meta' ] != 'active' && ! empty($sale_price) && $price < $regular_price) {
322
+					$price = '<del>' . ((is_numeric($regular_price)) ? wc_price($regular_price) : $regular_price) . '</del> <ins>' . ((is_numeric($sale_price)) ? wc_price($sale_price) : $sale_price) . '</ins>';
323 323
 
324 324
 					// Trim the whitespace.
325
-					$price = trim( $price );
325
+					$price = trim($price);
326 326
 				}
327 327
 
328 328
 				// Override the value should only one value be returned.
329
-				if ( $atts['meta'] != 'both' ) {
330
-					if ( $atts['meta'] == 'active' ) {
329
+				if ($atts[ 'meta' ] != 'both') {
330
+					if ($atts[ 'meta' ] == 'active') {
331 331
 						$price = $price;
332 332
 					}
333 333
 
334
-					if ( $atts['meta'] == 'regular' ) {
334
+					if ($atts[ 'meta' ] == 'regular') {
335 335
 						$price = $regular_price;
336 336
 					}
337 337
 
338
-					if ( $atts['meta'] == 'sale' ) {
338
+					if ($atts[ 'meta' ] == 'sale') {
339 339
 						$price = $sale_price;
340 340
 					}
341 341
 				}
342 342
 
343
-				if ( is_numeric( $price ) ) {
344
-					$price = wc_price( $price );
343
+				if (is_numeric($price)) {
344
+					$price = wc_price($price);
345 345
 				}
346 346
 
347 347
 			}
348 348
 
349 349
 		}
350 350
 
351
-		$price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price, $atts['after_price'] );
351
+		$price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price, $atts[ 'after_price' ]);
352 352
 
353
-		echo html_entity_decode( $price_html );
353
+		echo html_entity_decode($price_html);
354 354
 
355 355
 		return ob_get_clean();
356 356
 	} // END get_subscription_price_meta()
@@ -363,27 +363,27 @@  discard block
 block discarded – undo
363 363
 	 * @param  array $atts
364 364
 	 * @return string
365 365
 	 */
366
-	public static function get_subscription_discount( $atts ) {
366
+	public static function get_subscription_discount($atts) {
367 367
 		global $wpdb, $post;
368 368
 
369
-		$defaults = shortcode_atts( array(
369
+		$defaults = shortcode_atts(array(
370 370
 			'id'  => '',
371 371
 			'sku' => '',
372
-		), $atts );
372
+		), $atts);
373 373
 
374
-		$atts = wp_parse_args( $atts, $defaults );
374
+		$atts = wp_parse_args($atts, $defaults);
375 375
 
376
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
377
-			$product_data = wc_get_product( $atts['id'] );
378
-		} elseif ( ! empty( $atts['sku'] ) ) {
379
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
380
-			$product_data = get_post( $product_id );
376
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
377
+			$product_data = wc_get_product($atts[ 'id' ]);
378
+		} elseif ( ! empty($atts[ 'sku' ])) {
379
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
380
+			$product_data = get_post($product_id);
381 381
 		} else {
382
-			$product_data = wc_get_product( $post->ID );
382
+			$product_data = wc_get_product($post->ID);
383 383
 		}
384 384
 
385 385
 		// Check that the product type is supported. Return blank if not supported.
386
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
386
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
387 387
 			return '';
388 388
 		}
389 389
 
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 		$discount = ''; // Returns empty by default.
393 393
 
394 394
 		// Get Subscription Discount - Only available with the WooCommerce extension "Subscribe to All the Things".
395
-		$scheme = self::get_satt_lowest_scheme_data( $product_data );
395
+		$scheme = self::get_satt_lowest_scheme_data($product_data);
396 396
 
397
-		if ( !empty( $scheme ) && is_array( $scheme ) ) {
397
+		if ( ! empty($scheme) && is_array($scheme)) {
398 398
 			// Override price?
399
-			$override = $scheme['scheme']['subscription_pricing_method'];
399
+			$override = $scheme[ 'scheme' ][ 'subscription_pricing_method' ];
400 400
 
401 401
 			// Discount ?
402
-			$discount = $scheme['scheme']['subscription_discount'];
402
+			$discount = $scheme[ 'scheme' ][ 'subscription_discount' ];
403 403
 		}
404 404
 
405
-		if ( ! empty( $discount ) && is_numeric( $discount ) && $override == 'inherit' ) {
406
-			$discount = sprintf( __( '%s%s %s', WCSS::TEXT_DOMAIN ), $discount, '%', apply_filters( 'wcs_shortcodes_sub_discount_string', __( 'discount', WCSS::TEXT_DOMAIN ) ) );
405
+		if ( ! empty($discount) && is_numeric($discount) && $override == 'inherit') {
406
+			$discount = sprintf(__('%s%s %s', WCSS::TEXT_DOMAIN), $discount, '%', apply_filters('wcs_shortcodes_sub_discount_string', __('discount', WCSS::TEXT_DOMAIN)));
407 407
 		}
408 408
 
409 409
 		echo $discount;
@@ -417,47 +417,47 @@  discard block
 block discarded – undo
417 417
 	 * @param  array $atts
418 418
 	 * @return string
419 419
 	 */
420
-	public static function get_subscription_period( $atts ) {
420
+	public static function get_subscription_period($atts) {
421 421
 		global $wpdb, $post;
422 422
 
423
-		$defaults = shortcode_atts( array(
423
+		$defaults = shortcode_atts(array(
424 424
 			'id'  => '',
425 425
 			'sku' => '',
426 426
 			'raw' => false
427
-		), $atts );
427
+		), $atts);
428 428
 
429
-		$atts = wp_parse_args( $atts, $defaults );
429
+		$atts = wp_parse_args($atts, $defaults);
430 430
 
431
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
432
-			$product_data = wc_get_product( $atts['id'] );
433
-		} elseif ( ! empty( $atts['sku'] ) ) {
434
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
435
-			$product_data = get_post( $product_id );
431
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
432
+			$product_data = wc_get_product($atts[ 'id' ]);
433
+		} elseif ( ! empty($atts[ 'sku' ])) {
434
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
435
+			$product_data = get_post($product_id);
436 436
 		} else {
437
-			$product_data = wc_get_product( $post->ID );
437
+			$product_data = wc_get_product($post->ID);
438 438
 		}
439 439
 
440 440
 		// Check that the product type is supported. Return blank if not supported.
441
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
441
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
442 442
 			return '';
443 443
 		}
444 444
 
445 445
 		ob_start();
446 446
 
447 447
 		// Get Subscription Period
448
-		$period = WC_Subscriptions_Product::get_period( $product_data );
448
+		$period = WC_Subscriptions_Product::get_period($product_data);
449 449
 
450 450
 		// If the period is empty, look for alternative.
451
-		if ( empty( $period ) ) {
452
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
451
+		if (empty($period)) {
452
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
453 453
 
454
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
455
-				$period = $scheme['scheme']['subscription_period'];
454
+			if ( ! empty($scheme) && is_array($scheme)) {
455
+				$period = $scheme[ 'scheme' ][ 'subscription_period' ];
456 456
 			}
457 457
 		}
458 458
 
459
-		if ( ! $atts['raw'] ) {
460
-			$period = sprintf( __( 'Per %s', WCSS::TEXT_DOMAIN ), $period );
459
+		if ( ! $atts[ 'raw' ]) {
460
+			$period = sprintf(__('Per %s', WCSS::TEXT_DOMAIN), $period);
461 461
 			$period = ucwords($period);
462 462
 		}
463 463
 
@@ -472,41 +472,41 @@  discard block
 block discarded – undo
472 472
 	 * @param  array $atts
473 473
 	 * @return string
474 474
 	 */
475
-	public static function get_subscription_period_interval( $atts ) {
475
+	public static function get_subscription_period_interval($atts) {
476 476
 		global $wpdb, $post;
477 477
 
478
-		$defaults = shortcode_atts( array(
478
+		$defaults = shortcode_atts(array(
479 479
 			'id'  => '',
480 480
 			'sku' => '',
481
-		), $atts );
481
+		), $atts);
482 482
 
483
-		$atts = wp_parse_args( $atts, $defaults );
483
+		$atts = wp_parse_args($atts, $defaults);
484 484
 
485
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
486
-			$product_data = wc_get_product( $atts['id'] );
487
-		} elseif ( ! empty( $atts['sku'] ) ) {
488
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
489
-			$product_data = get_post( $product_id );
485
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
486
+			$product_data = wc_get_product($atts[ 'id' ]);
487
+		} elseif ( ! empty($atts[ 'sku' ])) {
488
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
489
+			$product_data = get_post($product_id);
490 490
 		} else {
491
-			$product_data = wc_get_product( $post->ID );
491
+			$product_data = wc_get_product($post->ID);
492 492
 		}
493 493
 
494 494
 		// Check that the product type is supported. Return blank if not supported.
495
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
495
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
496 496
 			return '';
497 497
 		}
498 498
 
499 499
 		ob_start();
500 500
 
501 501
 		// Get Subscription Period Interval
502
-		$period_interval = WC_Subscriptions_Product::get_interval( $product_data );
502
+		$period_interval = WC_Subscriptions_Product::get_interval($product_data);
503 503
 
504 504
 		// If the period is empty, look for alternative.
505
-		if ( empty( $period_interval ) ) {
506
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
505
+		if (empty($period_interval)) {
506
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
507 507
 
508
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
509
-				$period_interval = $scheme['scheme']['subscription_period_interval'];
508
+			if ( ! empty($scheme) && is_array($scheme)) {
509
+				$period_interval = $scheme[ 'scheme' ][ 'subscription_period_interval' ];
510 510
 			}
511 511
 		}
512 512
 
@@ -521,52 +521,52 @@  discard block
 block discarded – undo
521 521
 	 * @param  array $atts
522 522
 	 * @return string
523 523
 	 */
524
-	public static function get_subscription_length( $atts ) {
524
+	public static function get_subscription_length($atts) {
525 525
 		global $wpdb, $post;
526 526
 
527
-		$defaults = shortcode_atts( array(
527
+		$defaults = shortcode_atts(array(
528 528
 			'id'  => '',
529 529
 			'sku' => '',
530 530
 			'raw' => false,
531
-		), $atts );
531
+		), $atts);
532 532
 
533
-		$atts = wp_parse_args( $atts, $defaults );
533
+		$atts = wp_parse_args($atts, $defaults);
534 534
 
535
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
536
-			$product_data = wc_get_product( $atts['id'] );
537
-		} elseif ( ! empty( $atts['sku'] ) ) {
538
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
539
-			$product_data = get_post( $product_id );
535
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
536
+			$product_data = wc_get_product($atts[ 'id' ]);
537
+		} elseif ( ! empty($atts[ 'sku' ])) {
538
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
539
+			$product_data = get_post($product_id);
540 540
 		} else {
541
-			$product_data = wc_get_product( $post->ID );
541
+			$product_data = wc_get_product($post->ID);
542 542
 		}
543 543
 
544 544
 		// Check that the product type is supported. Return blank if not supported.
545
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
545
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
546 546
 			return '';
547 547
 		}
548 548
 
549 549
 		ob_start();
550 550
 
551 551
 		// Get Subscription Length
552
-		$length = WC_Subscriptions_Product::get_length( $product_data );
552
+		$length = WC_Subscriptions_Product::get_length($product_data);
553 553
 
554 554
 		// If the length is empty, look for alternative.
555
-		if ( empty( $length ) ) {
556
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
555
+		if (empty($length)) {
556
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
557 557
 
558
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
558
+			if ( ! empty($scheme) && is_array($scheme)) {
559 559
 
560
-				$period = self::get_subscription_period( array( 'id' => $product_data->id, 'raw' => true ) );
561
-				$length = $scheme['scheme']['subscription_length'];
560
+				$period = self::get_subscription_period(array('id' => $product_data->id, 'raw' => true));
561
+				$length = $scheme[ 'scheme' ][ 'subscription_length' ];
562 562
 
563 563
 				// If we are not returning raw data then making it readable for humans.
564
-				if ( ! $atts['raw'] ) {
564
+				if ( ! $atts[ 'raw' ]) {
565 565
 
566
-					if ( $length > 0 ) {
567
-						$length = sprintf( '%s %s', $length, $period );
566
+					if ($length > 0) {
567
+						$length = sprintf('%s %s', $length, $period);
568 568
 					} else {
569
-						$length = sprintf( __( 'Every %s', WCSS::TEXT_DOMAIN ), $period );
569
+						$length = sprintf(__('Every %s', WCSS::TEXT_DOMAIN), $period);
570 570
 					}
571 571
 
572 572
 					$length = ucfirst($length);
@@ -588,54 +588,54 @@  discard block
 block discarded – undo
588 588
 	 * @param  array $atts
589 589
 	 * @return string
590 590
 	 */
591
-	public static function get_subscription_sign_up_fee( $atts ) {
591
+	public static function get_subscription_sign_up_fee($atts) {
592 592
 		global $wpdb, $post;
593 593
 
594
-		$defaults = shortcode_atts( array(
594
+		$defaults = shortcode_atts(array(
595 595
 			'id'           => '',
596 596
 			'sku'          => '',
597 597
 			'before_price' => '',
598 598
 			'after_price'  => '',
599
-		), $atts );
599
+		), $atts);
600 600
 
601
-		$atts = wp_parse_args( $atts, $defaults );
601
+		$atts = wp_parse_args($atts, $defaults);
602 602
 
603
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
604
-			$product_data = wc_get_product( $atts['id'] );
605
-		} elseif ( ! empty( $atts['sku'] ) ) {
606
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
607
-			$product_data = get_post( $product_id );
603
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
604
+			$product_data = wc_get_product($atts[ 'id' ]);
605
+		} elseif ( ! empty($atts[ 'sku' ])) {
606
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
607
+			$product_data = get_post($product_id);
608 608
 		} else {
609
-			$product_data = wc_get_product( $post->ID );
609
+			$product_data = wc_get_product($post->ID);
610 610
 		}
611 611
 
612 612
 		// Check that the product type is supported. Return blank if not supported.
613
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
613
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
614 614
 			return '';
615 615
 		}
616 616
 
617 617
 		ob_start();
618 618
 
619 619
 		// Get Subscription Sign Up Fee
620
-		$sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee( $product_data );
620
+		$sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee($product_data);
621 621
 
622 622
 		// If the sign up fee is empty, look for alternative.
623
-		if ( empty( $sign_up_fee ) ) {
624
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
623
+		if (empty($sign_up_fee)) {
624
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
625 625
 
626
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
627
-				$sign_up_fee = $scheme['scheme']['subscription_sign_up_fee'];
626
+			if ( ! empty($scheme) && is_array($scheme)) {
627
+				$sign_up_fee = $scheme[ 'scheme' ][ 'subscription_sign_up_fee' ];
628 628
 			}
629 629
 		}
630 630
 
631 631
 		// Convert number into a price tag.
632
-		if ( is_numeric( $sign_up_fee ) ) {
633
-			$sign_up_fee = wc_price( $sign_up_fee );
632
+		if (is_numeric($sign_up_fee)) {
633
+			$sign_up_fee = wc_price($sign_up_fee);
634 634
 		}
635 635
 
636
-		$price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $sign_up_fee, $atts['after_price'] );
636
+		$price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $sign_up_fee, $atts[ 'after_price' ]);
637 637
 
638
-		echo html_entity_decode( $price_html );
638
+		echo html_entity_decode($price_html);
639 639
 
640 640
 		return ob_get_clean();
641 641
 	} // END get_subscription_sign_up_fee()
@@ -646,55 +646,55 @@  discard block
 block discarded – undo
646 646
 	 * @param  array $atts
647 647
 	 * @return string
648 648
 	 */
649
-	public static function get_subscription_trial_string( $atts ) {
649
+	public static function get_subscription_trial_string($atts) {
650 650
 		global $wpdb, $post;
651 651
 
652
-		$defaults = shortcode_atts( array(
652
+		$defaults = shortcode_atts(array(
653 653
 			'id'  => '',
654 654
 			'sku' => '',
655
-		), $atts );
655
+		), $atts);
656 656
 
657
-		$atts = wp_parse_args( $atts, $defaults );
657
+		$atts = wp_parse_args($atts, $defaults);
658 658
 
659
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
660
-			$product_data = wc_get_product( $atts['id'] );
661
-		} elseif ( ! empty( $atts['sku'] ) ) {
662
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
663
-			$product_data = get_post( $product_id );
659
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
660
+			$product_data = wc_get_product($atts[ 'id' ]);
661
+		} elseif ( ! empty($atts[ 'sku' ])) {
662
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
663
+			$product_data = get_post($product_id);
664 664
 		} else {
665
-			$product_data = wc_get_product( $post->ID );
665
+			$product_data = wc_get_product($post->ID);
666 666
 		}
667 667
 
668 668
 		// Check that the product type is supported. Return blank if not supported.
669
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
669
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
670 670
 			return '';
671 671
 		}
672 672
 
673 673
 		ob_start();
674 674
 
675 675
 		// Get Subscription Trial Length
676
-		$trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) );
676
+		$trial_length = self::get_subscription_trial_length(array('id' => $product_data->id));
677 677
 
678 678
 		// Get Subscription Trial Period
679
-		$trial_period = self::get_subscription_trial_period( array( 'id' => $product_data->id, 'raw' => true ) );
679
+		$trial_period = self::get_subscription_trial_period(array('id' => $product_data->id, 'raw' => true));
680 680
 
681
-		if ( ! empty( $trial_length ) && $trial_length > 0 ) {
681
+		if ( ! empty($trial_length) && $trial_length > 0) {
682 682
 
683
-			switch ( $trial_period ) {
683
+			switch ($trial_period) {
684 684
 				case 'day':
685
-					echo sprintf( _n( '%s day', '%s days', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length );
685
+					echo sprintf(_n('%s day', '%s days', $trial_length, WCSS::TEXT_DOMAIN), $trial_length);
686 686
 					break;
687 687
 
688 688
 				case 'week':
689
-					echo sprintf( _n( '%s week', '%s weeks', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length );
689
+					echo sprintf(_n('%s week', '%s weeks', $trial_length, WCSS::TEXT_DOMAIN), $trial_length);
690 690
 					break;
691 691
 
692 692
 				case 'month':
693
-					echo sprintf( _n( '%s month', '%s months', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length );
693
+					echo sprintf(_n('%s month', '%s months', $trial_length, WCSS::TEXT_DOMAIN), $trial_length);
694 694
 					break;
695 695
 
696 696
 				case 'year':
697
-					echo sprintf( _n( '%s year', '%s years', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length );
697
+					echo sprintf(_n('%s year', '%s years', $trial_length, WCSS::TEXT_DOMAIN), $trial_length);
698 698
 					break;
699 699
 			}
700 700
 
@@ -709,41 +709,41 @@  discard block
 block discarded – undo
709 709
 	 * @param  array $atts
710 710
 	 * @return string
711 711
 	 */
712
-	public static function get_subscription_trial_length( $atts ) {
712
+	public static function get_subscription_trial_length($atts) {
713 713
 		global $wpdb, $post;
714 714
 
715
-		$defaults = shortcode_atts( array(
715
+		$defaults = shortcode_atts(array(
716 716
 			'id'  => '',
717 717
 			'sku' => '',
718
-		), $atts );
718
+		), $atts);
719 719
 
720
-		$atts = wp_parse_args( $atts, $defaults );
720
+		$atts = wp_parse_args($atts, $defaults);
721 721
 
722
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
723
-			$product_data = wc_get_product( $atts['id'] );
724
-		} elseif ( ! empty( $atts['sku'] ) ) {
725
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
726
-			$product_data = get_post( $product_id );
722
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
723
+			$product_data = wc_get_product($atts[ 'id' ]);
724
+		} elseif ( ! empty($atts[ 'sku' ])) {
725
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
726
+			$product_data = get_post($product_id);
727 727
 		} else {
728
-			$product_data = wc_get_product( $post->ID );
728
+			$product_data = wc_get_product($post->ID);
729 729
 		}
730 730
 
731 731
 		// Check that the product type is supported. Return blank if not supported.
732
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
732
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
733 733
 			return '';
734 734
 		}
735 735
 
736 736
 		ob_start();
737 737
 
738 738
 		// Get Subscription Trial Length
739
-		$trial_length = WC_Subscriptions_Product::get_trial_length( $product_data );
739
+		$trial_length = WC_Subscriptions_Product::get_trial_length($product_data);
740 740
 
741 741
 		// If the trial length is empty, look for alternative.
742
-		if ( empty( $trial_length ) ) {
743
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
742
+		if (empty($trial_length)) {
743
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
744 744
 
745
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
746
-				$trial_length = $scheme['scheme']['subscription_trial_length'];
745
+			if ( ! empty($scheme) && is_array($scheme)) {
746
+				$trial_length = $scheme[ 'scheme' ][ 'subscription_trial_length' ];
747 747
 			}
748 748
 		}
749 749
 
@@ -758,52 +758,52 @@  discard block
 block discarded – undo
758 758
 	 * @param  array $atts
759 759
 	 * @return string
760 760
 	 */
761
-	public static function get_subscription_trial_period( $atts ) {
761
+	public static function get_subscription_trial_period($atts) {
762 762
 		global $wpdb, $post;
763 763
 
764
-		$defaults = shortcode_atts( array(
764
+		$defaults = shortcode_atts(array(
765 765
 			'id'  => '',
766 766
 			'sku' => '',
767 767
 			'raw' => false,
768
-		), $atts );
768
+		), $atts);
769 769
 
770
-		$atts = wp_parse_args( $atts, $defaults );
770
+		$atts = wp_parse_args($atts, $defaults);
771 771
 
772
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
773
-			$product_data = wc_get_product( $atts['id'] );
774
-		} elseif ( ! empty( $atts['sku'] ) ) {
775
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
776
-			$product_data = get_post( $product_id );
772
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
773
+			$product_data = wc_get_product($atts[ 'id' ]);
774
+		} elseif ( ! empty($atts[ 'sku' ])) {
775
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
776
+			$product_data = get_post($product_id);
777 777
 		} else {
778
-			$product_data = wc_get_product( $post->ID );
778
+			$product_data = wc_get_product($post->ID);
779 779
 		}
780 780
 
781 781
 		// Check that the product type is supported. Return blank if not supported.
782
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
782
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
783 783
 			return '';
784 784
 		}
785 785
 
786 786
 		ob_start();
787 787
 
788 788
 		// Get Subscription Trial Length
789
-		$trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) );
789
+		$trial_length = self::get_subscription_trial_length(array('id' => $product_data->id));
790 790
 
791 791
 		// Get Subscription Trial Period
792
-		$trial_period = WC_Subscriptions_Product::get_trial_period( $product_data );
792
+		$trial_period = WC_Subscriptions_Product::get_trial_period($product_data);
793 793
 
794 794
 		// If the trial length is empty or is not zero, look for alternative.
795
-		if ( empty( $trial_length ) || $trial_length != 0 ) {
796
-			$scheme = self::get_satt_lowest_scheme_data( $product_data );
795
+		if (empty($trial_length) || $trial_length != 0) {
796
+			$scheme = self::get_satt_lowest_scheme_data($product_data);
797 797
 
798
-			if ( !empty( $scheme ) && is_array( $scheme ) ) {
799
-				$trial_length = $scheme['scheme']['subscription_trial_length'];
800
-				$trial_period = $scheme['scheme']['subscription_trial_period'];
798
+			if ( ! empty($scheme) && is_array($scheme)) {
799
+				$trial_length = $scheme[ 'scheme' ][ 'subscription_trial_length' ];
800
+				$trial_period = $scheme[ 'scheme' ][ 'subscription_trial_period' ];
801 801
 			}
802 802
 		}
803 803
 
804
-		if ( ! empty( $trial_length ) && $trial_length > 0 ) {
804
+		if ( ! empty($trial_length) && $trial_length > 0) {
805 805
 
806
-			if ( ! $atts['raw'] ) {
806
+			if ( ! $atts[ 'raw' ]) {
807 807
 				$trial_period = ucfirst($trial_period);
808 808
 			}
809 809
 
@@ -820,84 +820,84 @@  discard block
 block discarded – undo
820 820
 	 * @param  array $atts
821 821
 	 * @return string
822 822
 	 */
823
-	public static function get_subscription_first_payment( $atts ) {
823
+	public static function get_subscription_first_payment($atts) {
824 824
 		global $wpdb, $post;
825 825
 
826
-		$defaults = shortcode_atts( array(
826
+		$defaults = shortcode_atts(array(
827 827
 			'id'        => '',
828 828
 			'sku'       => '',
829 829
 			'show_time' => false,
830 830
 			'from_date' => '',
831 831
 			'timezone'  => 'gmt',
832 832
 			'format'    => 'timestamp'
833
-		), $atts );
833
+		), $atts);
834 834
 
835
-		$atts = wp_parse_args( $atts, $defaults );
835
+		$atts = wp_parse_args($atts, $defaults);
836 836
 
837
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
838
-			$product_data = wc_get_product( $atts['id'] );
839
-		} elseif ( ! empty( $atts['sku'] ) ) {
840
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
841
-			$product_data = get_post( $product_id );
837
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
838
+			$product_data = wc_get_product($atts[ 'id' ]);
839
+		} elseif ( ! empty($atts[ 'sku' ])) {
840
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
841
+			$product_data = get_post($product_id);
842 842
 		} else {
843
-			$product_data = wc_get_product( $post->ID );
843
+			$product_data = wc_get_product($post->ID);
844 844
 		}
845 845
 
846 846
 		// Check that the product type is supported. Return blank if not supported.
847
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
847
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
848 848
 			return '';
849 849
 		}
850 850
 
851 851
 		ob_start();
852 852
 
853
-		$billing_interval = self::get_subscription_period_interval( array( 'id' => $product_data->id ) );
854
-		$billing_length   = self::get_subscription_length( array( 'id' => $product_data->id, 'raw' => true ) );
855
-		$trial_length     = self::get_subscription_trial_length( array( 'id' => $product_data->id ) );
853
+		$billing_interval = self::get_subscription_period_interval(array('id' => $product_data->id));
854
+		$billing_length   = self::get_subscription_length(array('id' => $product_data->id, 'raw' => true));
855
+		$trial_length     = self::get_subscription_trial_length(array('id' => $product_data->id));
856 856
 
857
-		$from_date = $atts['from_date'];
857
+		$from_date = $atts[ 'from_date' ];
858 858
 
859
-		if ( $billing_interval != $billing_length || $trial_length > 0 ) {
860
-			if ( empty( $from_date ) ) {
861
-				$from_date = gmdate( 'Y-m-d H:i:s' );
859
+		if ($billing_interval != $billing_length || $trial_length > 0) {
860
+			if (empty($from_date)) {
861
+				$from_date = gmdate('Y-m-d H:i:s');
862 862
 			}
863 863
 
864 864
 			// If the subscription has a free trial period, the first renewal is the same as the expiration of the free trial
865
-			if ( $trial_length > 0 ) {
866
-				$first_renewal_timestamp = strtotime( WC_Subscriptions_Product::get_trial_expiration_date( $product_data->id, $from_date ) );
865
+			if ($trial_length > 0) {
866
+				$first_renewal_timestamp = strtotime(WC_Subscriptions_Product::get_trial_expiration_date($product_data->id, $from_date));
867 867
 			} else {
868
-				$from_timestamp = strtotime( $from_date );
869
-				$billing_period = self::get_subscription_period( array( 'id' => $product_data->id, 'raw' => true ) );
868
+				$from_timestamp = strtotime($from_date);
869
+				$billing_period = self::get_subscription_period(array('id' => $product_data->id, 'raw' => true));
870 870
 
871
-				if ( 'month' == $billing_period ) {
872
-					$first_renewal_timestamp = wcs_add_months( $from_timestamp, $billing_interval );
871
+				if ('month' == $billing_period) {
872
+					$first_renewal_timestamp = wcs_add_months($from_timestamp, $billing_interval);
873 873
 				} else {
874
-					$first_renewal_timestamp = strtotime( "+ $billing_interval {$billing_period}s", $from_timestamp );
874
+					$first_renewal_timestamp = strtotime("+ $billing_interval {$billing_period}s", $from_timestamp);
875 875
 				}
876 876
 
877
-				if ( 'site' == $atts['timezone'] ) {
878
-					$first_renewal_timestamp += ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
877
+				if ('site' == $atts[ 'timezone' ]) {
878
+					$first_renewal_timestamp += (get_option('gmt_offset') * HOUR_IN_SECONDS);
879 879
 				}
880 880
 			}
881 881
 		} else {
882 882
 			$first_renewal_timestamp = 0;
883 883
 		}
884 884
 
885
-		if ( $first_renewal_timestamp > 0 ) {
886
-			if ( $atts['show_time'] ) {
887
-				if ( 'timestamp' == $atts['format'] ) {
885
+		if ($first_renewal_timestamp > 0) {
886
+			if ($atts[ 'show_time' ]) {
887
+				if ('timestamp' == $atts[ 'format' ]) {
888 888
 					$date_format = 'Y-m-d H:i:s';
889
-				} else if ( 'string' == $atts['format'] ) {
889
+				} else if ('string' == $atts[ 'format' ]) {
890 890
 					$date_format = 'D jS M Y H:i A';
891 891
 				}
892 892
 			} else {
893
-				if ( 'timestamp' == $atts['format'] ) {
893
+				if ('timestamp' == $atts[ 'format' ]) {
894 894
 					$date_format = 'Y-m-d';
895
-				} else if ( 'string' == $atts['format'] ) {
895
+				} else if ('string' == $atts[ 'format' ]) {
896 896
 					$date_format = 'D jS M Y';
897 897
 				}
898 898
 			}
899 899
 
900
-			$first_payment = date( $date_format, $first_renewal_timestamp );
900
+			$first_payment = date($date_format, $first_renewal_timestamp);
901 901
 		} else {
902 902
 			$first_payment = '';
903 903
 		}
@@ -913,49 +913,49 @@  discard block
 block discarded – undo
913 913
 	 * @param  array $atts
914 914
 	 * @return string
915 915
 	 */
916
-	public static function get_subscription_initial( $atts ) {
916
+	public static function get_subscription_initial($atts) {
917 917
 		global $wpdb, $post;
918 918
 
919
-		$defaults = shortcode_atts( array(
919
+		$defaults = shortcode_atts(array(
920 920
 			'id'        => '',
921 921
 			'sku'       => '',
922
-		), $atts );
922
+		), $atts);
923 923
 
924
-		$atts = wp_parse_args( $atts, $defaults );
924
+		$atts = wp_parse_args($atts, $defaults);
925 925
 
926
-		if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) {
927
-			$product_data = wc_get_product( $atts['id'] );
928
-		} elseif ( ! empty( $atts['sku'] ) ) {
929
-			$product_id   = wc_get_product_id_by_sku( $atts['sku'] );
930
-			$product_data = get_post( $product_id );
926
+		if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) {
927
+			$product_data = wc_get_product($atts[ 'id' ]);
928
+		} elseif ( ! empty($atts[ 'sku' ])) {
929
+			$product_id   = wc_get_product_id_by_sku($atts[ 'sku' ]);
930
+			$product_data = get_post($product_id);
931 931
 		} else {
932
-			$product_data = wc_get_product( $post->ID );
932
+			$product_data = wc_get_product($post->ID);
933 933
 		}
934 934
 
935 935
 		// Check that the product type is supported. Return blank if not supported.
936
-		if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) {
936
+		if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) {
937 937
 			return '';
938 938
 		}
939 939
 
940 940
 		ob_start();
941 941
 
942 942
 		// Subscription Active Price
943
-		$initial_payment = self::get_subscription_price_meta( array( 'id' => $product_data->id, 'meta' => 'active' ) );
943
+		$initial_payment = self::get_subscription_price_meta(array('id' => $product_data->id, 'meta' => 'active'));
944 944
 
945 945
 		// Free Trial ?
946
-		$trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) );
946
+		$trial_length = self::get_subscription_trial_length(array('id' => $product_data->id));
947 947
 
948 948
 		// If there is a free trial then the initial payment is Zero.
949
-		if ( $trial_length > 0 ) {
950
-			$initial_payment = self::get_subscription_trial_string( array( 'id' => $product_data->id ) );
949
+		if ($trial_length > 0) {
950
+			$initial_payment = self::get_subscription_trial_string(array('id' => $product_data->id));
951 951
 		}
952 952
 
953 953
 		// Sign up fee ?
954
-		$sign_up_fee = self::get_subscription_sign_up_fee( array( 'id' => $product_data->id ) );
954
+		$sign_up_fee = self::get_subscription_sign_up_fee(array('id' => $product_data->id));
955 955
 
956 956
 		// Apply the sign up fee if it exists.
957
-		if ( !empty( $sign_up_fee ) && $sign_up_fee > 0 ) {
958
-			$initial_payment = sprintf( __( '%s with a %s', WCSS::TEXT_DOMAIN ), $initial_payment, $sign_up_fee );
957
+		if ( ! empty($sign_up_fee) && $sign_up_fee > 0) {
958
+			$initial_payment = sprintf(__('%s with a %s', WCSS::TEXT_DOMAIN), $initial_payment, $sign_up_fee);
959 959
 		}
960 960
 
961 961
 		echo $initial_payment;
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
 	 * @param  $product_types
970 970
 	 * @return array
971 971
 	 */
972
-	public static function support_product_types_for_wc_satt( $product_types ) {
972
+	public static function support_product_types_for_wc_satt($product_types) {
973 973
 		// Only add the product types from the WooCommerce extension "Subscribe to All the Things" if it is active.
974
-		if ( class_exists( 'WCS_ATT' ) ) {
974
+		if (class_exists('WCS_ATT')) {
975 975
 			$satt_product_types = WCS_ATT()->get_supported_product_types();
976
-			$product_types = array_merge( $satt_product_types, $product_types );
976
+			$product_types = array_merge($satt_product_types, $product_types);
977 977
 		}
978 978
 
979 979
 		return $product_types;
Please login to merge, or discard this patch.