Completed
Push — master ( 5ead7b...3567a2 )
by Sébastien
02:56
created
wc-satt-stt.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
  * License: GNU General Public License v3.0
18 18
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
19 19
  */
20
-if ( ! defined('ABSPATH') ) exit; // Exit if accessed directly.
20
+if (!defined('ABSPATH')) exit; // Exit if accessed directly.
21 21
 
22
-if ( ! class_exists( 'WCSATT_STT' ) ) {
22
+if (!class_exists('WCSATT_STT')) {
23 23
 	class WCSATT_STT {
24 24
 
25 25
 		/* Plugin version. */
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		 * @since 1.0.0
53 53
 		 */
54 54
 		public static function instance() {
55
-			if ( is_null( self::$_instance ) ) {
55
+			if (is_null(self::$_instance)) {
56 56
 				self::$_instance = new self();
57 57
 			}
58 58
 			return self::$_instance;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		 * @since 1.0.0
65 65
 		 */
66 66
 		public function __clone() {
67
-			_doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
67
+			_doing_it_wrong(__FUNCTION__, __('Foul!'), '1.0.0');
68 68
 		}
69 69
 
70 70
 		/**
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 		 * @since 1.0.0
74 74
 		 */
75 75
 		public function __wakeup() {
76
-			_doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
76
+			_doing_it_wrong(__FUNCTION__, __('Foul!'), '1.0.0');
77 77
 		}
78 78
 
79 79
 		/**
80 80
 		 * Load the plugin.
81 81
 		 */
82 82
 		public function __construct() {
83
-			add_action( 'plugins_loaded', array( $this, 'load_plugin' ) );
84
-			add_action( 'init', array( $this, 'init_plugin' ) );
85
-			add_action( 'admin_init', array( $this, 'admin_wcsatt_stt_product_meta' ) );
86
-			add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_links' ), 10, 4 );
83
+			add_action('plugins_loaded', array($this, 'load_plugin'));
84
+			add_action('init', array($this, 'init_plugin'));
85
+			add_action('admin_init', array($this, 'admin_wcsatt_stt_product_meta'));
86
+			add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 4);
87 87
 		}
88 88
 
89 89
 		public function plugin_path() {
90
-			return untrailingslashit( plugin_dir_path( __FILE__ ) );
90
+			return untrailingslashit(plugin_dir_path(__FILE__));
91 91
 		} // END plugin_path()
92 92
 
93 93
 		/*
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 			global $woocommerce;
98 98
 
99 99
 			// Check that the required WooCommerce is running.
100
-			if ( version_compare( $woocommerce->version, self::REQ_WC_VERSION, '<' ) ) {
101
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_wc_admin_notice' ) );
100
+			if (version_compare($woocommerce->version, self::REQ_WC_VERSION, '<')) {
101
+				add_action('admin_notices', array($this, 'wcsatt_stt_wc_admin_notice'));
102 102
 				return false;
103 103
 			}
104 104
 
105 105
 			// Checks that WooCommerce Subscribe All the Things is running or is less than the required version.
106
-			if ( ! class_exists( 'WCS_ATT' ) || version_compare( WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<' ) ) {
107
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_admin_notice' ) );
106
+			if (!class_exists('WCS_ATT') || version_compare(WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<')) {
107
+				add_action('admin_notices', array($this, 'wcsatt_stt_admin_notice'));
108 108
 				return false;
109 109
 			}
110 110
 		} // END load_plugin()
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		 * @return void
116 116
 		 */
117 117
 		public function wcsatt_stt_wc_admin_notice() {
118
-			echo '<div class="error"><p>' . sprintf( __( '%1$s requires at least %2$s v%3$s in order to function. Please upgrade %2$s.', 'wc-satt-stt' ), 'Sign up and Trial Options Add-on for WCSATT', 'WooCommerce', self::REQ_WC_VERSION ) . '</p></div>';
118
+			echo '<div class="error"><p>'.sprintf(__('%1$s requires at least %2$s v%3$s in order to function. Please upgrade %2$s.', 'wc-satt-stt'), 'Sign up and Trial Options Add-on for WCSATT', 'WooCommerce', self::REQ_WC_VERSION).'</p></div>';
119 119
 		} // END wcsatt_stt_wc_admin_notice()
120 120
 
121 121
 		/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		 * @return void
125 125
 		 */
126 126
 		public function wcsatt_stt_admin_notice() {
127
-			echo '<div class="error"><p>' . sprintf( __( '%1$s requires at least %2$s v%3$s in order to function. Please upgrade %2$s.', 'wc-satt-stt' ), 'Sign up and Trial Options Add-on', 'WooCommerce Subscribe to All the Things', self::REQ_WCSATT_VERSION ) . '</p></div>';
127
+			echo '<div class="error"><p>'.sprintf(__('%1$s requires at least %2$s v%3$s in order to function. Please upgrade %2$s.', 'wc-satt-stt'), 'Sign up and Trial Options Add-on', 'WooCommerce Subscribe to All the Things', self::REQ_WCSATT_VERSION).'</p></div>';
128 128
 		} // END wcsatt_stt_admin_notice()
129 129
 
130 130
 		/**
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 		 */
135 135
 		public function init_plugin() {
136 136
 			// Load text domain.
137
-			load_plugin_textdomain( 'wc-satt-stt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
137
+			load_plugin_textdomain('wc-satt-stt', false, dirname(plugin_basename(__FILE__)).'/languages/');
138 138
 
139 139
 			// Adds the sign up fee and trial data to the price html on the 'wcsatt_overridden_subscription_prices_product' filter.
140
-			add_filter( 'wcsatt_overridden_subscription_prices_product', array( $this, 'add_sub_scheme_data_price_html' ), 10, 3 );
140
+			add_filter('wcsatt_overridden_subscription_prices_product', array($this, 'add_sub_scheme_data_price_html'), 10, 3);
141 141
 
142 142
 			// Adds the extra subscription scheme data to the product object on the 'wcsatt_sub_product_scheme_option' filter.
143
-			add_filter( 'wcsatt_sub_product_scheme_option', array( $this, 'sub_product_scheme_option' ), 10, 2 );
143
+			add_filter('wcsatt_sub_product_scheme_option', array($this, 'sub_product_scheme_option'), 10, 2);
144 144
 
145 145
 			// Filters the price string to include the sign up fee and/or trial to pass per scheme option on the 'wcsatt_get_single_product_price_string' filter.
146
-			add_filter( 'wcsatt_get_single_product_price_string', array( $this, 'get_price_string' ), 10, 2 );
146
+			add_filter('wcsatt_get_single_product_price_string', array($this, 'get_price_string'), 10, 2);
147 147
 
148 148
 			// Filters the suffix price html on the 'wcsatt_suffix_price_html' filter.
149 149
 			//add_filter( 'wcsatt_suffix_price_html', array( $this, 'filter_suffix_price_html' ), 10, 1 );
150 150
 
151 151
 			// Adds the sign-up and/or trial data to the subscription scheme prices on the 'wcsatt_subscription_scheme_prices' filter.
152
-			add_filter( 'wcsatt_subscription_scheme_prices', array( $this, 'add_subscription_scheme_prices' ), 10, 2 );
152
+			add_filter('wcsatt_subscription_scheme_prices', array($this, 'add_subscription_scheme_prices'), 10, 2);
153 153
 
154 154
 			// Overrides the price of the subscription for sign up fee and/or trial on the 'wcsatt_cart_item' filter.
155
-			add_filter( 'wcsatt_cart_item', array( $this, 'update_cart_item_sub_data' ), 10, 1 );
155
+			add_filter('wcsatt_cart_item', array($this, 'update_cart_item_sub_data'), 10, 1);
156 156
 		} // END init_plugin()
157 157
 
158 158
 		/**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 			//add_action( 'wcsatt_subscription_scheme_content', array( $this, 'wcsatt_stt_fields' ), 15, 3 );
166 166
 
167 167
 			// Subscription scheme options displayed on the 'wcsatt_subscription_scheme_product_content' action.
168
-			add_action( 'wcsatt_subscription_scheme_product_content', array( $this, 'wcsatt_stt_fields' ), 15, 3 );
168
+			add_action('wcsatt_subscription_scheme_product_content', array($this, 'wcsatt_stt_fields'), 15, 3);
169 169
 
170 170
 			// Filter the subscription scheme data to process the sign up and trial options on the ''wcsatt_subscription_scheme_process_scheme_data' filter.
171
-			add_filter( 'wcsatt_subscription_scheme_process_scheme_data', array( $this, 'wcsatt_stt_process_scheme_data' ), 10, 2 );
171
+			add_filter('wcsatt_subscription_scheme_process_scheme_data', array($this, 'wcsatt_stt_process_scheme_data'), 10, 2);
172 172
 		} // END admin_wcsatt_stt_product_meta()
173 173
 
174 174
 		/**
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 		 * @param mixed $file  Plugin Base file
179 179
 		 * @return array
180 180
 		 */
181
-		public function plugin_meta_links( $links, $file, $data, $status ) {
182
-			if ( $file == plugin_basename( __FILE__ ) ) {
183
-				$author1 = '<a href="' . $data[ 'AuthorURI' ] . '">' . $data[ 'Author' ] . '</a>';
184
-				$links[ 1 ] = sprintf( __( 'By %s', WCSATT_STT::TEXT_DOMAIN ), $author1 );
181
+		public function plugin_meta_links($links, $file, $data, $status) {
182
+			if ($file == plugin_basename(__FILE__)) {
183
+				$author1 = '<a href="'.$data['AuthorURI'].'">'.$data['Author'].'</a>';
184
+				$links[1] = sprintf(__('By %s', WCSATT_STT::TEXT_DOMAIN), $author1);
185 185
 			}
186 186
 
187 187
 			return $links;
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 		 * @param  array $defaults
194 194
 		 * @return void
195 195
 		 */
196
-		public static function add_default_subscription_schemes_content( $defaults ) {
196
+		public static function add_default_subscription_schemes_content($defaults) {
197 197
 			$new_defaults = array(
198 198
 				'subscription_sign_up_fee'  => '',
199 199
 				'subscription_trial_length' => '',
200 200
 				'subscription_trial_period' => ''
201 201
 			);
202 202
 
203
-			return array_merge( $new_defaults, $defaults );
203
+			return array_merge($new_defaults, $defaults);
204 204
 		} // END add_default_subscription_schemes_content()
205 205
 
206 206
 		/**
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 		 * @param  int   $post_id
212 212
 		 * @return void
213 213
 		 */
214
-		public function wcsatt_stt_fields( $index, $scheme_data, $post_id ) {
215
-			if ( ! empty( $scheme_data ) ) {
216
-				$subscription_sign_up_fee = ! empty( $scheme_data[ 'subscription_sign_up_fee' ] ) ? $scheme_data[ 'subscription_sign_up_fee' ] : '';
217
-				$subscription_trial_length = isset( $scheme_data[ 'subscription_trial_length' ] ) ? $scheme_data[ 'subscription_trial_length' ] : 0;
218
-				$subscription_trial_period = isset( $scheme_data[ 'subscription_trial_period' ] ) ? $scheme_data[ 'subscription_trial_period' ] : '';
214
+		public function wcsatt_stt_fields($index, $scheme_data, $post_id) {
215
+			if (!empty($scheme_data)) {
216
+				$subscription_sign_up_fee = !empty($scheme_data['subscription_sign_up_fee']) ? $scheme_data['subscription_sign_up_fee'] : '';
217
+				$subscription_trial_length = isset($scheme_data['subscription_trial_length']) ? $scheme_data['subscription_trial_length'] : 0;
218
+				$subscription_trial_period = isset($scheme_data['subscription_trial_period']) ? $scheme_data['subscription_trial_period'] : '';
219 219
 			} else {
220 220
 				$subscription_sign_up_fee = '';
221 221
 				$subscription_trial_length = 0;
@@ -223,45 +223,45 @@  discard block
 block discarded – undo
223 223
 			}
224 224
 
225 225
 			// Sign-up Fee
226
-			woocommerce_wp_text_input( array(
226
+			woocommerce_wp_text_input(array(
227 227
 				'id'          => '_subscription_sign_up_fee',
228 228
 				'class'       => 'wc_input_subscription_intial_price',
229 229
 				// translators: %s is a currency symbol / code
230
-				'label'       => sprintf( __( 'Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN ), get_woocommerce_currency_symbol() ),
231
-				'placeholder' => _x( 'e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN ),
232
-				'description' => __( 'Optionally include an amount to be charged at the outset of the subscription. The sign-up fee will be charged immediately, even if the product has a free trial or the payment dates are synced.', WCSATT_STT::TEXT_DOMAIN ),
230
+				'label'       => sprintf(__('Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN), get_woocommerce_currency_symbol()),
231
+				'placeholder' => _x('e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN),
232
+				'description' => __('Optionally include an amount to be charged at the outset of the subscription. The sign-up fee will be charged immediately, even if the product has a free trial or the payment dates are synced.', WCSATT_STT::TEXT_DOMAIN),
233 233
 				'desc_tip'    => true,
234 234
 				'type'        => 'text',
235 235
 				'custom_attributes' => array(
236 236
 					'step' => 'any',
237 237
 					'min'  => '0',
238 238
 				),
239
-				'name'        => 'wcsatt_schemes[' . $index . '][subscription_sign_up_fee]',
239
+				'name'        => 'wcsatt_schemes['.$index.'][subscription_sign_up_fee]',
240 240
 				'value'       => $subscription_sign_up_fee
241
-			) );
241
+			));
242 242
 
243 243
 			// Trial Length
244
-			woocommerce_wp_text_input( array(
244
+			woocommerce_wp_text_input(array(
245 245
 				'id'          => '_subscription_trial_length',
246 246
 				'class'       => 'wc_input_subscription_trial_length',
247
-				'label'       => __( 'Free Trial', WCSATT_STT::TEXT_DOMAIN ),
248
-				'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_length]',
247
+				'label'       => __('Free Trial', WCSATT_STT::TEXT_DOMAIN),
248
+				'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_length]',
249 249
 				'value'       => $subscription_trial_length
250
-			) );
250
+			));
251 251
 
252 252
 			// Trial Period
253
-			woocommerce_wp_select( array(
253
+			woocommerce_wp_select(array(
254 254
 				'id'          => '_subscription_trial_period',
255 255
 				'class'       => 'wc_input_subscription_trial_period',
256
-				'label'       => __( 'Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN ),
256
+				'label'       => __('Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN),
257 257
 				'options'     => wcs_get_available_time_periods(),
258 258
 				// translators: placeholder is trial period validation message if passed an invalid value (e.g. "Trial period can not exceed 4 weeks")
259
-				'description' => sprintf( _x( 'An optional period of time to wait before charging the first recurring payment. Any sign up fee will still be charged at the outset of the subscription. %s', 'Trial period dropdown\'s description in pricing fields', WCSATT_STT::TEXT_DOMAIN ), WC_Subscriptions_Admin::get_trial_period_validation_message() ),
259
+				'description' => sprintf(_x('An optional period of time to wait before charging the first recurring payment. Any sign up fee will still be charged at the outset of the subscription. %s', 'Trial period dropdown\'s description in pricing fields', WCSATT_STT::TEXT_DOMAIN), WC_Subscriptions_Admin::get_trial_period_validation_message()),
260 260
 				'desc_tip'    => true,
261
-				'value'       => WC_Subscriptions_Product::get_trial_period( $post_id ), // Explicitly set value in to ensure backward compatibility
262
-				'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_period]',
261
+				'value'       => WC_Subscriptions_Product::get_trial_period($post_id), // Explicitly set value in to ensure backward compatibility
262
+				'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_period]',
263 263
 				'value'       => $subscription_trial_period
264
-		) );
264
+		));
265 265
 		} // END wcsatt_stt_fields()
266 266
 
267 267
 		/**
@@ -272,38 +272,38 @@  discard block
 block discarded – undo
272 272
 		 * @param  string $product_type
273 273
 		 * @return void
274 274
 		 */
275
-		public function wcsatt_stt_process_scheme_data( $posted_scheme, $product_type ) {
275
+		public function wcsatt_stt_process_scheme_data($posted_scheme, $product_type) {
276 276
 			// Copy variable type fields.
277
-			if ( 'variable' == $product_type ) {
278
-				if ( isset( $posted_scheme[ 'subscription_sign_up_fee_variable' ] ) ) {
279
-					$posted_scheme[ 'subscription_sign_up_fee' ] = $posted_scheme[ 'subscription_sign_up_fee_variable' ];
277
+			if ('variable' == $product_type) {
278
+				if (isset($posted_scheme['subscription_sign_up_fee_variable'])) {
279
+					$posted_scheme['subscription_sign_up_fee'] = $posted_scheme['subscription_sign_up_fee_variable'];
280 280
 				}
281
-				if ( isset( $posted_scheme[ 'subscription_trial_length_variable' ] ) ) {
282
-					$posted_scheme[ 'subscription_trial_length' ] = $posted_scheme[ 'subscription_trial_length_variable' ];
281
+				if (isset($posted_scheme['subscription_trial_length_variable'])) {
282
+					$posted_scheme['subscription_trial_length'] = $posted_scheme['subscription_trial_length_variable'];
283 283
 				}
284
-				if ( isset( $posted_scheme[ 'subscription_trial_period_variable' ] ) ) {
285
-					$posted_scheme[ 'subscription_trial_period' ] = $posted_scheme[ 'subscription_trial_period_variable'];
284
+				if (isset($posted_scheme['subscription_trial_period_variable'])) {
285
+					$posted_scheme['subscription_trial_period'] = $posted_scheme['subscription_trial_period_variable'];
286 286
 				}
287 287
 			}
288 288
 
289 289
 			// Format subscription sign up fee.
290
-			if ( isset( $posted_scheme[ 'subscription_sign_up_fee' ] ) ) {
291
-				$posted_scheme[ 'subscription_sign_up_fee' ] = ( $posted_scheme[ 'subscription_sign_up_fee' ] === '' ) ? '' : wc_format_decimal( $posted_scheme[ 'subscription_sign_up_fee' ] );
290
+			if (isset($posted_scheme['subscription_sign_up_fee'])) {
291
+				$posted_scheme['subscription_sign_up_fee'] = ($posted_scheme['subscription_sign_up_fee'] === '') ? '' : wc_format_decimal($posted_scheme['subscription_sign_up_fee']);
292 292
 			}
293 293
 
294 294
 			// Make sure trial period is within allowable range.
295 295
 			$subscription_ranges = wcs_get_subscription_ranges();
296
-			$max_trial_length = count( $subscription_ranges[ $posted_scheme[ 'subscription_trial_period' ] ] ) - 1;
296
+			$max_trial_length = count($subscription_ranges[$posted_scheme['subscription_trial_period']]) - 1;
297 297
 
298 298
 			// Format subscription trial length.
299
-			if ( isset( $posted_scheme[ 'subscription_trial_length' ] ) && $posted_scheme[ 'subscription_trial_length' ] > $max_trial_length ) {
300
-				$posted_scheme[ 'subscription_trial_length' ] = ( $posted_scheme[ 'subscription_trial_length' ] === '' ) ? '' : absint( $posted_scheme[ 'subscription_trial_length' ] );
299
+			if (isset($posted_scheme['subscription_trial_length']) && $posted_scheme['subscription_trial_length'] > $max_trial_length) {
300
+				$posted_scheme['subscription_trial_length'] = ($posted_scheme['subscription_trial_length'] === '') ? '' : absint($posted_scheme['subscription_trial_length']);
301 301
 			}
302 302
 
303 303
 			// Format subscription trial period.
304
-			$trial_periods = apply_filters( 'wcsatt_stt_trial_periods', array( 'day', 'week', 'month', 'year' ) );
305
-			if ( isset( $posted_scheme[ 'subscription_trial_period' ] ) && in_array( $posted_scheme[ 'subscription_trial_period' ], $trial_periods ) ) {
306
-				$posted_scheme[ 'subscription_trial_period' ] = trim( $posted_scheme[ 'subscription_trial_period' ] );
304
+			$trial_periods = apply_filters('wcsatt_stt_trial_periods', array('day', 'week', 'month', 'year'));
305
+			if (isset($posted_scheme['subscription_trial_period']) && in_array($posted_scheme['subscription_trial_period'], $trial_periods)) {
306
+				$posted_scheme['subscription_trial_period'] = trim($posted_scheme['subscription_trial_period']);
307 307
 			}
308 308
 
309 309
 			return $posted_scheme;
@@ -317,17 +317,17 @@  discard block
 block discarded – undo
317 317
 		 * @param  WC_Product $product
318 318
 		 * @return string
319 319
 		 */
320
-		public function add_sub_scheme_data_price_html( $_product, $subscription_scheme, $product ) {
321
-			if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) ) {
322
-				$_product->subscription_sign_up_fee = $subscription_scheme[ 'subscription_sign_up_fee' ];
320
+		public function add_sub_scheme_data_price_html($_product, $subscription_scheme, $product) {
321
+			if (isset($subscription_scheme['subscription_sign_up_fee'])) {
322
+				$_product->subscription_sign_up_fee = $subscription_scheme['subscription_sign_up_fee'];
323 323
 			}
324 324
 
325
-			if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
326
-				$_product->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
325
+			if (isset($subscription_scheme['subscription_trial_length'])) {
326
+				$_product->subscription_trial_length = $subscription_scheme['subscription_trial_length'];
327 327
 			}
328 328
 
329
-			if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
330
-				$_product->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
329
+			if (isset($subscription_scheme['subscription_trial_period'])) {
330
+				$_product->subscription_trial_period = $subscription_scheme['subscription_trial_period'];
331 331
 			}
332 332
 
333 333
 			return $_product;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 		 * @param  array  $subscription_scheme
343 343
 		 * @return object
344 344
 		 */
345
-		public function sub_product_scheme_option( $_cloned, $subscription_scheme ) {
346
-			if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) && $subscription_scheme[ 'subscription_sign_up_fee' ] > 0 ) {
347
-				$_cloned->subscription_sign_up_fee = $subscription_scheme[ 'subscription_sign_up_fee' ];
345
+		public function sub_product_scheme_option($_cloned, $subscription_scheme) {
346
+			if (isset($subscription_scheme['subscription_sign_up_fee']) && $subscription_scheme['subscription_sign_up_fee'] > 0) {
347
+				$_cloned->subscription_sign_up_fee = $subscription_scheme['subscription_sign_up_fee'];
348 348
 			}
349 349
 
350
-			if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
351
-				$_cloned->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
352
-				$_cloned->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
350
+			if (isset($subscription_scheme['subscription_trial_length']) && 0 != $subscription_scheme['subscription_trial_length']) {
351
+				$_cloned->subscription_trial_length = $subscription_scheme['subscription_trial_length'];
352
+				$_cloned->subscription_trial_period = $subscription_scheme['subscription_trial_period'];
353 353
 			}
354 354
 
355 355
 			return $_cloned;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 		 * @param  array $subscription_scheme
364 364
 		 * @return array
365 365
 		 */
366
-		public function get_price_string( $prices, $subscription_scheme ) {
367
-			if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) && $subscription_scheme[ 'subscription_sign_up_fee' ] > 0 ) {
368
-				$prices[ 'sign_up_fee' ] = true;
366
+		public function get_price_string($prices, $subscription_scheme) {
367
+			if (isset($subscription_scheme['subscription_sign_up_fee']) && $subscription_scheme['subscription_sign_up_fee'] > 0) {
368
+				$prices['sign_up_fee'] = true;
369 369
 			}
370 370
 
371
-			if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
372
-				$prices[ 'trial_length' ] = true;
371
+			if (isset($subscription_scheme['subscription_trial_length']) && 0 != $subscription_scheme['subscription_trial_length']) {
372
+				$prices['trial_length'] = true;
373 373
 			}
374 374
 
375 375
 			return $prices;
@@ -413,17 +413,17 @@  discard block
 block discarded – undo
413 413
 		 * @param  array $subscription_scheme
414 414
 		 * @return array
415 415
 		 */
416
-		public function add_subscription_scheme_prices( $prices, $subscription_scheme ) {
417
-			if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) ) {
418
-				$prices[ 'sign_up_fee' ] = $subscription_scheme[ 'subscription_sign_up_fee' ];
416
+		public function add_subscription_scheme_prices($prices, $subscription_scheme) {
417
+			if (isset($subscription_scheme['subscription_sign_up_fee'])) {
418
+				$prices['sign_up_fee'] = $subscription_scheme['subscription_sign_up_fee'];
419 419
 			}
420 420
 
421
-			if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
422
-				$prices[ 'trial_length' ] = $subscription_scheme[ 'subscription_trial_length' ];
421
+			if (isset($subscription_scheme['subscription_trial_length'])) {
422
+				$prices['trial_length'] = $subscription_scheme['subscription_trial_length'];
423 423
 			}
424 424
 
425
-			if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
426
-				$prices[ 'trial_period' ] = $subscription_scheme[ 'subscription_trial_period' ];
425
+			if (isset($subscription_scheme['subscription_trial_period'])) {
426
+				$prices['trial_period'] = $subscription_scheme['subscription_trial_period'];
427 427
 			}
428 428
 
429 429
 			return $prices;
@@ -436,32 +436,32 @@  discard block
 block discarded – undo
436 436
 		 * @param  array $cart_item
437 437
 		 * @return array
438 438
 		 */
439
-		public function update_cart_item_sub_data( $cart_item ) {
440
-			$active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme( $cart_item );
439
+		public function update_cart_item_sub_data($cart_item) {
440
+			$active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme($cart_item);
441 441
 
442
-			$subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices( $cart_item, $active_scheme );
442
+			$subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices($cart_item, $active_scheme);
443 443
 
444
-			if ( $active_scheme && $cart_item['data']->is_converted_to_sub == 'yes' ) {
444
+			if ($active_scheme && $cart_item['data']->is_converted_to_sub == 'yes') {
445 445
 
446 446
 				// Subscription Price
447 447
 				$price = $cart_item['data']->subscription_price;
448 448
 
449 449
 				// Is there a sign up fee?
450
-				$sign_up_fee = isset( $subscription_prices['sign_up_fee'] ) ? $subscription_prices['sign_up_fee'] : '';
450
+				$sign_up_fee = isset($subscription_prices['sign_up_fee']) ? $subscription_prices['sign_up_fee'] : '';
451 451
 
452 452
 				// Put them both together.
453 453
 				$new_price = $price + $sign_up_fee;
454 454
 
455
-				if ( $sign_up_fee > 0 ) {
455
+				if ($sign_up_fee > 0) {
456 456
 					$cart_item['data']->initial_amount = $new_price;
457 457
 					$cart_item['data']->subscription_sign_up_fee = $sign_up_fee;
458 458
 				}
459 459
 
460
-				$trial_length = isset( $subscription_prices['trial_length'] ) ? $subscription_prices['trial_length'] : 0;
461
-				$trial_period = isset( $subscription_prices['trial_period'] ) ? $subscription_prices['trial_period'] : '';
460
+				$trial_length = isset($subscription_prices['trial_length']) ? $subscription_prices['trial_length'] : 0;
461
+				$trial_period = isset($subscription_prices['trial_period']) ? $subscription_prices['trial_period'] : '';
462 462
 
463 463
 				// If a trial length is more than zero then re-adjust the price.
464
-				if ( $trial_length > 0 ) {
464
+				if ($trial_length > 0) {
465 465
 
466 466
 					/*$cart_item['data']->price = $new_price;
467 467
 					$cart_item['data']->subscription_price = $new_price;
Please login to merge, or discard this patch.