Completed
Push — master ( d6f625...0d8432 )
by Sébastien
01:23
created
includes/class-wcsatt-stt-display.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -16,22 +16,22 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	public static function init() {
18 18
 		// Adds the sign up fee and trial data to the price html on the 'wcsatt_overridden_subscription_prices_product' filter.
19
-		add_filter( 'wcsatt_overridden_subscription_prices_product', __CLASS__ . '::add_sub_scheme_data_price_html', 10, 3 );
19
+		add_filter('wcsatt_overridden_subscription_prices_product', __CLASS__.'::add_sub_scheme_data_price_html', 10, 3);
20 20
 
21 21
 		// Adds the extra subscription scheme data to the product object on the 'wcsatt_converted_product_for_scheme_option' filter.
22
-		add_filter( 'wcsatt_converted_product_for_scheme_option', __CLASS__ . '::sub_product_scheme_option', 10, 2 );
22
+		add_filter('wcsatt_converted_product_for_scheme_option', __CLASS__.'::sub_product_scheme_option', 10, 2);
23 23
 
24 24
 		// Filters the price string to include the sign up fee and/or trial to pass per scheme option on the 'wcsatt_single_product_subscription_scheme_price_html' filter.
25
-		add_filter( 'wcsatt_single_product_subscription_scheme_price_html', __CLASS__ . '::get_price_string', 10, 2 );
25
+		add_filter('wcsatt_single_product_subscription_scheme_price_html', __CLASS__.'::get_price_string', 10, 2);
26 26
 
27 27
 		// Filters the lowest price string to include the sign up fee on the 'wcsatt_get_single_product_lowest_price_string' filter.
28
-		add_filter( 'wcsatt_get_single_product_lowest_price_string', __CLASS__ . '::get_lowest_price_string', 10, 2 );
28
+		add_filter('wcsatt_get_single_product_lowest_price_string', __CLASS__.'::get_lowest_price_string', 10, 2);
29 29
 
30 30
 		// Filters the lowest price subscription scheme data on the 'wcsatt_get_lowest_price_sub_scheme_data' filter.
31
-		add_filter( 'wcsatt_get_lowest_price_sub_scheme_data', __CLASS__ . '::get_lowest_price_sub_scheme_data', 10, 2 );
31
+		add_filter('wcsatt_get_lowest_price_sub_scheme_data', __CLASS__.'::get_lowest_price_sub_scheme_data', 10, 2);
32 32
 
33 33
 		// Adds the sign-up and/or trial data to the subscription scheme prices on the 'wcsatt_subscription_scheme_prices' filter.
34
-		add_filter( 'wcsatt_subscription_scheme_prices', __CLASS__ . '::add_subscription_scheme_prices', 10, 2 );
34
+		add_filter('wcsatt_subscription_scheme_prices', __CLASS__.'::add_subscription_scheme_prices', 10, 2);
35 35
 	}
36 36
 
37 37
 	/**
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	 * @param  WC_Product $product
45 45
 	 * @return string
46 46
 	 */
47
-	public static function add_sub_scheme_data_price_html( $_product, $subscription_scheme, $product ) {
48
-		if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) ) {
49
-			$_product->subscription_sign_up_fee = $subscription_scheme[ 'subscription_sign_up_fee' ];
47
+	public static function add_sub_scheme_data_price_html($_product, $subscription_scheme, $product) {
48
+		if (isset($subscription_scheme['subscription_sign_up_fee'])) {
49
+			$_product->subscription_sign_up_fee = $subscription_scheme['subscription_sign_up_fee'];
50 50
 		}
51 51
 
52
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
53
-			$_product->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
52
+		if (isset($subscription_scheme['subscription_trial_length'])) {
53
+			$_product->subscription_trial_length = $subscription_scheme['subscription_trial_length'];
54 54
 		}
55 55
 
56
-		if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
57
-			$_product->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
56
+		if (isset($subscription_scheme['subscription_trial_period'])) {
57
+			$_product->subscription_trial_period = $subscription_scheme['subscription_trial_period'];
58 58
 		}
59 59
 
60 60
 		return $_product;
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 * @param  array  $subscription_scheme
72 72
 	 * @return object
73 73
 	 */
74
-	public static function sub_product_scheme_option( $_cloned, $subscription_scheme ) {
75
-		if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) && $subscription_scheme[ 'subscription_sign_up_fee' ] > 0 ) {
76
-			$_cloned->subscription_sign_up_fee = $subscription_scheme[ 'subscription_sign_up_fee' ];
74
+	public static function sub_product_scheme_option($_cloned, $subscription_scheme) {
75
+		if (isset($subscription_scheme['subscription_sign_up_fee']) && $subscription_scheme['subscription_sign_up_fee'] > 0) {
76
+			$_cloned->subscription_sign_up_fee = $subscription_scheme['subscription_sign_up_fee'];
77 77
 		}
78 78
 
79
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
80
-			$_cloned->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
81
-			$_cloned->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
79
+		if (isset($subscription_scheme['subscription_trial_length']) && 0 != $subscription_scheme['subscription_trial_length']) {
80
+			$_cloned->subscription_trial_length = $subscription_scheme['subscription_trial_length'];
81
+			$_cloned->subscription_trial_period = $subscription_scheme['subscription_trial_period'];
82 82
 		}
83 83
 
84 84
 		return $_cloned;
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	 * @param  array $subscription_scheme
95 95
 	 * @return array
96 96
 	 */
97
-	public static function get_price_string( $prices, $subscription_scheme ) {
98
-		if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) && $subscription_scheme[ 'subscription_sign_up_fee' ] > 0 ) {
99
-			$prices[ 'sign_up_fee' ] = $subscription_scheme[ 'subscription_sign_up_fee' ];
97
+	public static function get_price_string($prices, $subscription_scheme) {
98
+		if (isset($subscription_scheme['subscription_sign_up_fee']) && $subscription_scheme['subscription_sign_up_fee'] > 0) {
99
+			$prices['sign_up_fee'] = $subscription_scheme['subscription_sign_up_fee'];
100 100
 		}
101 101
 
102
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
103
-			$prices[ 'trial_length' ] = true;
102
+		if (isset($subscription_scheme['subscription_trial_length']) && 0 != $subscription_scheme['subscription_trial_length']) {
103
+			$prices['trial_length'] = true;
104 104
 		}
105 105
 
106 106
 		return $prices;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @param  array $lowest_subscription_scheme
117 117
 	 * @return array
118 118
 	 */
119
-	public static function get_lowest_price_string( $prices,  $lowest_subscription_scheme ) {
120
-		if ( isset( $lowest_subscription_scheme[ 'sign_up_fee' ] ) && $lowest_subscription_scheme[ 'sign_up_fee' ] > 0 ) {
121
-			$prices[ 'sign_up_fee' ] = $lowest_subscription_scheme[ 'sign_up_fee' ];
119
+	public static function get_lowest_price_string($prices, $lowest_subscription_scheme) {
120
+		if (isset($lowest_subscription_scheme['sign_up_fee']) && $lowest_subscription_scheme['sign_up_fee'] > 0) {
121
+			$prices['sign_up_fee'] = $lowest_subscription_scheme['sign_up_fee'];
122 122
 		}
123 123
 
124 124
 		return $prices;
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @param array $lowest_scheme
134 134
 	 * @return array
135 135
 	 */
136
-	public static function get_lowest_price_sub_scheme_data( $data, $lowest_scheme ) {
137
-		if ( isset( $lowest_scheme['subscription_sign_up_fee'] ) && $lowest_scheme['subscription_sign_up_fee'] > 0 ) {
136
+	public static function get_lowest_price_sub_scheme_data($data, $lowest_scheme) {
137
+		if (isset($lowest_scheme['subscription_sign_up_fee']) && $lowest_scheme['subscription_sign_up_fee'] > 0) {
138 138
 			$data['sign_up_fee'] = $lowest_scheme['subscription_sign_up_fee'];
139 139
 		}
140 140
 
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 	 * @param  array $subscription_scheme
151 151
 	 * @return array
152 152
 	 */
153
-	public static function add_subscription_scheme_prices( $prices, $subscription_scheme ) {
154
-		if ( isset( $subscription_scheme[ 'subscription_sign_up_fee' ] ) ) {
155
-			$prices[ 'sign_up_fee' ] = $subscription_scheme[ 'subscription_sign_up_fee' ];
153
+	public static function add_subscription_scheme_prices($prices, $subscription_scheme) {
154
+		if (isset($subscription_scheme['subscription_sign_up_fee'])) {
155
+			$prices['sign_up_fee'] = $subscription_scheme['subscription_sign_up_fee'];
156 156
 		}
157 157
 
158
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
159
-			$prices[ 'trial_length' ] = $subscription_scheme[ 'subscription_trial_length' ];
158
+		if (isset($subscription_scheme['subscription_trial_length'])) {
159
+			$prices['trial_length'] = $subscription_scheme['subscription_trial_length'];
160 160
 		}
161 161
 
162
-		if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
163
-			$prices[ 'trial_period' ] = $subscription_scheme[ 'subscription_trial_period' ];
162
+		if (isset($subscription_scheme['subscription_trial_period'])) {
163
+			$prices['trial_period'] = $subscription_scheme['subscription_trial_period'];
164 164
 		}
165 165
 
166 166
 		return $prices;
Please login to merge, or discard this patch.
includes/class-wcsatt-stt-cart.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	public static function init() {
18 18
 		// Overrides the price of the subscription for sign up fee and/or trial on the 'wcsatt_cart_item' filter.
19
-		add_filter( 'wcsatt_cart_item', __CLASS__ . '::update_cart_item_sub_data', 10, 1 );
19
+		add_filter('wcsatt_cart_item', __CLASS__.'::update_cart_item_sub_data', 10, 1);
20 20
 	}
21 21
 
22 22
 	/**
@@ -28,38 +28,38 @@  discard block
 block discarded – undo
28 28
 	 * @param  array $cart_item
29 29
 	 * @return array
30 30
 	 */
31
-	public static function update_cart_item_sub_data( $cart_item ) {
32
-		$active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme( $cart_item );
31
+	public static function update_cart_item_sub_data($cart_item) {
32
+		$active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme($cart_item);
33 33
 
34
-		$subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices( $cart_item, $active_scheme );
34
+		$subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices($cart_item, $active_scheme);
35 35
 
36
-		if ( $active_scheme && $cart_item['data']->is_converted_to_sub == 'yes' ) {
36
+		if ($active_scheme && $cart_item['data']->is_converted_to_sub == 'yes') {
37 37
 
38 38
 			// Subscription Price
39 39
 			$price = $cart_item['data']->subscription_price;
40 40
 
41 41
 			// Is there a sign up fee?
42
-			$sign_up_fee = isset( $subscription_prices['sign_up_fee'] ) ? $subscription_prices['sign_up_fee'] : '';
42
+			$sign_up_fee = isset($subscription_prices['sign_up_fee']) ? $subscription_prices['sign_up_fee'] : '';
43 43
 
44 44
 			// Checks if the cart item is a supported bundle type child.
45
-			$container_key = WCS_ATT_Integrations::has_bundle_type_container( $cart_item );
45
+			$container_key = WCS_ATT_Integrations::has_bundle_type_container($cart_item);
46 46
 
47 47
 			// If the cart item is a child item then reset the sign-up fee.
48
-			if ( false !== $container_key ) { $sign_up_fee = ''; }
48
+			if (false !== $container_key) { $sign_up_fee = ''; }
49 49
 
50 50
 			// Put both the subscription price and the sign-up fee together.
51
-			$new_price = round( $price + $sign_up_fee, wc_get_price_decimals() );
51
+			$new_price = round($price + $sign_up_fee, wc_get_price_decimals());
52 52
 
53
-			if ( $sign_up_fee > 0 ) {
53
+			if ($sign_up_fee > 0) {
54 54
 				$cart_item['data']->initial_amount = $new_price;
55 55
 				$cart_item['data']->subscription_sign_up_fee = $sign_up_fee;
56 56
 			}
57 57
 
58
-			$trial_length = isset( $subscription_prices['trial_length'] ) ? $subscription_prices['trial_length'] : 0;
59
-			$trial_period = isset( $subscription_prices['trial_period'] ) ? $subscription_prices['trial_period'] : '';
58
+			$trial_length = isset($subscription_prices['trial_length']) ? $subscription_prices['trial_length'] : 0;
59
+			$trial_period = isset($subscription_prices['trial_period']) ? $subscription_prices['trial_period'] : '';
60 60
 
61 61
 			// If a trial length is more than zero then set the conditions for the cart.
62
-			if ( $trial_length > 0 ) {
62
+			if ($trial_length > 0) {
63 63
 				$cart_item['data']->subscription_trial_length = $trial_length;
64 64
 				$cart_item['data']->subscription_trial_period = $trial_period;
65 65
 			} else {
Please login to merge, or discard this patch.
includes/admin/class-wcsatt-stt-admin.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	public static function init() {
18 18
 		// Admin scripts and styles.
19
-		add_action( 'admin_enqueue_scripts', __CLASS__ . '::admin_style' );
19
+		add_action('admin_enqueue_scripts', __CLASS__.'::admin_style');
20 20
 
21 21
 		// Adds to the default values for subscriptions schemes content.
22
-		add_filter( 'wcsatt_default_subscription_scheme', __CLASS__ . '::subscription_schemes_content', 10, 1 );
22
+		add_filter('wcsatt_default_subscription_scheme', __CLASS__.'::subscription_schemes_content', 10, 1);
23 23
 
24 24
 		// Subscription scheme options displayed on the 'wcsatt_subscription_scheme_product_content' action.
25
-		add_action( 'wcsatt_subscription_scheme_product_content', __CLASS__ . '::wcsatt_stt_fields', 15, 3 );
25
+		add_action('wcsatt_subscription_scheme_product_content', __CLASS__.'::wcsatt_stt_fields', 15, 3);
26 26
 
27 27
 		// Filter the subscription scheme data to process the sign up and trial options on the ''wcsatt_subscription_scheme_process_scheme_data' filter.
28
-		add_filter( 'wcsatt_subscription_scheme_process_scheme_data', __CLASS__ . '::wcsatt_stt_process_scheme_data', 10, 2 );
28
+		add_filter('wcsatt_subscription_scheme_process_scheme_data', __CLASS__.'::wcsatt_stt_process_scheme_data', 10, 2);
29 29
 	}
30 30
 
31 31
 	/**
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 		$screen    = get_current_screen();
39 39
 		$screen_id = $screen ? $screen->id : '';
40 40
 
41
-		if ( in_array( $screen_id, array( 'edit-product', 'product' ) ) ) {
42
-			wp_register_style( 'wcsatt_stt_writepanel', WCSATT_STT::plugin_url() . '/assets/css/wcsatt-stt-write-panel.css', array( 'woocommerce_admin_styles' ), WCSATT_STT::VERSION );
43
-			wp_enqueue_style( 'wcsatt_stt_writepanel' );
41
+		if (in_array($screen_id, array('edit-product', 'product'))) {
42
+			wp_register_style('wcsatt_stt_writepanel', WCSATT_STT::plugin_url().'/assets/css/wcsatt-stt-write-panel.css', array('woocommerce_admin_styles'), WCSATT_STT::VERSION);
43
+			wp_enqueue_style('wcsatt_stt_writepanel');
44 44
 		}
45 45
 
46 46
 	} // END admin_style()
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 	 * @param  array $defaults
54 54
 	 * @return void
55 55
 	 */
56
-	public static function subscription_schemes_content( $defaults ) {
56
+	public static function subscription_schemes_content($defaults) {
57 57
 		$new_defaults = array(
58 58
 			'subscription_sign_up_fee'  => '',
59 59
 			'subscription_trial_length' => '',
60 60
 			'subscription_trial_period' => ''
61 61
 		);
62 62
 
63
-		return array_merge( $new_defaults, $defaults );
63
+		return array_merge($new_defaults, $defaults);
64 64
 	} // END subscription_schemes_content()
65 65
 
66 66
 	/**
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 * @param  int   $post_id
74 74
 	 * @return void
75 75
 	 */
76
-	public static function wcsatt_stt_fields( $index, $scheme_data, $post_id ) {
77
-		if ( ! empty( $scheme_data ) ) {
78
-			$subscription_sign_up_fee = ! empty( $scheme_data[ 'subscription_sign_up_fee' ] ) ? $scheme_data[ 'subscription_sign_up_fee' ] : '';
79
-			$subscription_trial_length = isset( $scheme_data[ 'subscription_trial_length' ] ) ? $scheme_data[ 'subscription_trial_length' ] : 0;
80
-			$subscription_trial_period = isset( $scheme_data[ 'subscription_trial_period' ] ) ? $scheme_data[ 'subscription_trial_period' ] : '';
76
+	public static function wcsatt_stt_fields($index, $scheme_data, $post_id) {
77
+		if (!empty($scheme_data)) {
78
+			$subscription_sign_up_fee = !empty($scheme_data['subscription_sign_up_fee']) ? $scheme_data['subscription_sign_up_fee'] : '';
79
+			$subscription_trial_length = isset($scheme_data['subscription_trial_length']) ? $scheme_data['subscription_trial_length'] : 0;
80
+			$subscription_trial_period = isset($scheme_data['subscription_trial_period']) ? $scheme_data['subscription_trial_period'] : '';
81 81
 		} else {
82 82
 			$subscription_sign_up_fee = '';
83 83
 			$subscription_trial_length = 0;
@@ -87,47 +87,47 @@  discard block
 block discarded – undo
87 87
 		echo '<div class="options_group subscription_scheme_product_data sign_up_trial_scheme">';
88 88
 
89 89
 		// Sign-up Fee
90
-		woocommerce_wp_text_input( array(
90
+		woocommerce_wp_text_input(array(
91 91
 			'id'          => '_subscription_sign_up_fee',
92 92
 			'class'       => 'wc_input_subscription_intial_price',
93 93
 			// translators: %s is a currency symbol / code
94
-			'label'       => sprintf( __( 'Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN ), get_woocommerce_currency_symbol() ),
95
-			'placeholder' => _x( 'e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN ),
96
-			'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 ),
94
+			'label'       => sprintf(__('Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN), get_woocommerce_currency_symbol()),
95
+			'placeholder' => _x('e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN),
96
+			'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),
97 97
 			'desc_tip'    => true,
98 98
 			'type'        => 'text',
99 99
 			'custom_attributes' => array(
100 100
 				'step' => 'any',
101 101
 				'min'  => '0',
102 102
 			),
103
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_sign_up_fee]',
103
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_sign_up_fee]',
104 104
 			'value'       => $subscription_sign_up_fee
105
-		) );
105
+		));
106 106
 
107 107
 		echo '<div class="subscription_trial">';
108 108
 
109 109
 		// Trial Length
110
-		woocommerce_wp_text_input( array(
110
+		woocommerce_wp_text_input(array(
111 111
 			'id'          => '_subscription_trial_length',
112 112
 			'class'       => 'wc_input_subscription_trial_length',
113
-			'label'       => __( 'Free Trial', WCSATT_STT::TEXT_DOMAIN ),
114
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_length]',
113
+			'label'       => __('Free Trial', WCSATT_STT::TEXT_DOMAIN),
114
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_length]',
115 115
 			'value'       => $subscription_trial_length
116
-		) );
116
+		));
117 117
 
118 118
 		// Trial Period
119
-		woocommerce_wp_select( array(
119
+		woocommerce_wp_select(array(
120 120
 			'id'          => '_subscription_trial_period',
121 121
 			'class'       => 'wc_input_subscription_trial_period',
122
-			'label'       => __( 'Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN ),
122
+			'label'       => __('Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN),
123 123
 			'options'     => wcs_get_available_time_periods(),
124 124
 			// translators: placeholder is trial period validation message if passed an invalid value (e.g. "Trial period can not exceed 4 weeks")
125
-			'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() ),
125
+			'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()),
126 126
 			'desc_tip'    => true,
127
-			'value'       => WC_Subscriptions_Product::get_trial_period( $post_id ), // Explicitly set value in to ensure backward compatibility
128
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_period]',
127
+			'value'       => WC_Subscriptions_Product::get_trial_period($post_id), // Explicitly set value in to ensure backward compatibility
128
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_period]',
129 129
 			'value'       => $subscription_trial_period
130
-	) );
130
+	));
131 131
 
132 132
 		echo '</div>';
133 133
 
@@ -144,38 +144,38 @@  discard block
 block discarded – undo
144 144
 	 * @param  string $product_type
145 145
 	 * @return void
146 146
 	 */
147
-	public static function wcsatt_stt_process_scheme_data( $posted_scheme, $product_type ) {
147
+	public static function wcsatt_stt_process_scheme_data($posted_scheme, $product_type) {
148 148
 		// Copy variable type fields.
149
-		if ( 'variable' == $product_type ) {
150
-			if ( isset( $posted_scheme[ 'subscription_sign_up_fee_variable' ] ) ) {
151
-				$posted_scheme[ 'subscription_sign_up_fee' ] = $posted_scheme[ 'subscription_sign_up_fee_variable' ];
149
+		if ('variable' == $product_type) {
150
+			if (isset($posted_scheme['subscription_sign_up_fee_variable'])) {
151
+				$posted_scheme['subscription_sign_up_fee'] = $posted_scheme['subscription_sign_up_fee_variable'];
152 152
 			}
153
-			if ( isset( $posted_scheme[ 'subscription_trial_length_variable' ] ) ) {
154
-				$posted_scheme[ 'subscription_trial_length' ] = $posted_scheme[ 'subscription_trial_length_variable' ];
153
+			if (isset($posted_scheme['subscription_trial_length_variable'])) {
154
+				$posted_scheme['subscription_trial_length'] = $posted_scheme['subscription_trial_length_variable'];
155 155
 			}
156
-			if ( isset( $posted_scheme[ 'subscription_trial_period_variable' ] ) ) {
157
-				$posted_scheme[ 'subscription_trial_period' ] = $posted_scheme[ 'subscription_trial_period_variable'];
156
+			if (isset($posted_scheme['subscription_trial_period_variable'])) {
157
+				$posted_scheme['subscription_trial_period'] = $posted_scheme['subscription_trial_period_variable'];
158 158
 			}
159 159
 		}
160 160
 
161 161
 		// Format subscription sign up fee.
162
-		if ( isset( $posted_scheme[ 'subscription_sign_up_fee' ] ) ) {
163
-			$posted_scheme[ 'subscription_sign_up_fee' ] = ( $posted_scheme[ 'subscription_sign_up_fee' ] === '' ) ? '' : wc_format_decimal( $posted_scheme[ 'subscription_sign_up_fee' ] );
162
+		if (isset($posted_scheme['subscription_sign_up_fee'])) {
163
+			$posted_scheme['subscription_sign_up_fee'] = ($posted_scheme['subscription_sign_up_fee'] === '') ? '' : wc_format_decimal($posted_scheme['subscription_sign_up_fee']);
164 164
 		}
165 165
 
166 166
 		// Make sure trial period is within allowable range.
167 167
 		$subscription_ranges = wcs_get_subscription_ranges();
168
-		$max_trial_length = count( $subscription_ranges[ $posted_scheme[ 'subscription_trial_period' ] ] ) - 1;
168
+		$max_trial_length = count($subscription_ranges[$posted_scheme['subscription_trial_period']]) - 1;
169 169
 
170 170
 		// Format subscription trial length.
171
-		if ( isset( $posted_scheme[ 'subscription_trial_length' ] ) && $posted_scheme[ 'subscription_trial_length' ] > $max_trial_length ) {
172
-			$posted_scheme[ 'subscription_trial_length' ] = ( $posted_scheme[ 'subscription_trial_length' ] === '' ) ? '' : absint( $posted_scheme[ 'subscription_trial_length' ] );
171
+		if (isset($posted_scheme['subscription_trial_length']) && $posted_scheme['subscription_trial_length'] > $max_trial_length) {
172
+			$posted_scheme['subscription_trial_length'] = ($posted_scheme['subscription_trial_length'] === '') ? '' : absint($posted_scheme['subscription_trial_length']);
173 173
 		}
174 174
 
175 175
 		// Format subscription trial period.
176
-		$trial_periods = apply_filters( 'wcsatt_stt_trial_periods', array( 'day', 'week', 'month', 'year' ) );
177
-		if ( isset( $posted_scheme[ 'subscription_trial_period' ] ) && in_array( $posted_scheme[ 'subscription_trial_period' ], $trial_periods ) ) {
178
-			$posted_scheme[ 'subscription_trial_period' ] = trim( $posted_scheme[ 'subscription_trial_period' ] );
176
+		$trial_periods = apply_filters('wcsatt_stt_trial_periods', array('day', 'week', 'month', 'year'));
177
+		if (isset($posted_scheme['subscription_trial_period']) && in_array($posted_scheme['subscription_trial_period'], $trial_periods)) {
178
+			$posted_scheme['subscription_trial_period'] = trim($posted_scheme['subscription_trial_period']);
179 179
 		}
180 180
 
181 181
 		return $posted_scheme;
Please login to merge, or discard this patch.
wc-satt-stt.php 1 patch
Spacing   +25 added lines, -25 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,24 +73,24 @@  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' ), 11 );
84
-			add_action( 'init', array( $this, 'init_plugin' ) );
85
-			add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_links' ), 10, 4 );
83
+			add_action('plugins_loaded', array($this, 'load_plugin'), 11);
84
+			add_action('init', array($this, 'init_plugin'));
85
+			add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 4);
86 86
 		}
87 87
 
88 88
 		public static function plugin_url() {
89
-			return plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) );
89
+			return plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__));
90 90
 		} // END plugin_url()
91 91
 
92 92
 		public static function plugin_path() {
93
-			return untrailingslashit( plugin_dir_path( __FILE__ ) );
93
+			return untrailingslashit(plugin_dir_path(__FILE__));
94 94
 		} // END plugin_path()
95 95
 
96 96
 		/*
@@ -102,23 +102,23 @@  discard block
 block discarded – undo
102 102
 			global $woocommerce;
103 103
 
104 104
 			// Check that the required WooCommerce is running.
105
-			if ( version_compare( $woocommerce->version, self::REQ_WC_VERSION, '<' ) ) {
106
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_wc_admin_notice' ) );
105
+			if (version_compare($woocommerce->version, self::REQ_WC_VERSION, '<')) {
106
+				add_action('admin_notices', array($this, 'wcsatt_stt_wc_admin_notice'));
107 107
 				return false;
108 108
 			}
109 109
 
110 110
 			// Checks that WooCommerce Subscribe All the Things is running or is less than the required version.
111
-			if ( ! class_exists( 'WCS_ATT' ) || version_compare( WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<' ) ) {
112
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_admin_notice' ) );
111
+			if (!class_exists('WCS_ATT') || version_compare(WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<')) {
112
+				add_action('admin_notices', array($this, 'wcsatt_stt_admin_notice'));
113 113
 				return false;
114 114
 			}
115 115
 
116
-			require_once( 'includes/class-wcsatt-stt-cart.php' );
117
-			require_once( 'includes/class-wcsatt-stt-display.php' );
116
+			require_once('includes/class-wcsatt-stt-cart.php');
117
+			require_once('includes/class-wcsatt-stt-display.php');
118 118
 
119 119
 			// Admin includes
120
-			if ( is_admin() ) {
121
-				require_once( 'includes/admin/class-wcsatt-stt-admin.php' );
120
+			if (is_admin()) {
121
+				require_once('includes/admin/class-wcsatt-stt-admin.php');
122 122
 			}
123 123
 
124 124
 		} // END load_plugin()
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		 * @return void
130 130
 		 */
131 131
 		public function wcsatt_stt_wc_admin_notice() {
132
-			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' ), 'WooCommerce Subscribe All the Things: Sign-up and Trial Add-on', 'WooCommerce', self::REQ_WC_VERSION ) . '</p></div>';
132
+			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'), 'WooCommerce Subscribe All the Things: Sign-up and Trial Add-on', 'WooCommerce', self::REQ_WC_VERSION).'</p></div>';
133 133
 		} // END wcsatt_stt_wc_admin_notice()
134 134
 
135 135
 		/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		 * @return void
139 139
 		 */
140 140
 		public function wcsatt_stt_admin_notice() {
141
-			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' ), 'WooCommerce Subscribe All the Things: Sign-up and Trial Add-on', 'WooCommerce Subscribe All the Things', self::REQ_WCSATT_VERSION ) . '</p></div>';
141
+			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'), 'WooCommerce Subscribe All the Things: Sign-up and Trial Add-on', 'WooCommerce Subscribe All the Things', self::REQ_WCSATT_VERSION).'</p></div>';
142 142
 		} // END wcsatt_stt_admin_notice()
143 143
 
144 144
 		/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		 */
149 149
 		public function init_plugin() {
150 150
 			// Load text domain.
151
-			load_plugin_textdomain( 'wc-satt-stt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
151
+			load_plugin_textdomain('wc-satt-stt', false, dirname(plugin_basename(__FILE__)).'/languages/');
152 152
 		} // END init_plugin()
153 153
 
154 154
 		/**
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 		 * @param  array $data  Plugin Data
160 160
 		 * @return array
161 161
 		 */
162
-		public function plugin_meta_links( $links, $file, $data, $status ) {
163
-			if ( $file == plugin_basename( __FILE__ ) ) {
164
-				$author1 = '<a href="' . $data[ 'AuthorURI' ] . '">' . $data[ 'Author' ] . '</a>';
162
+		public function plugin_meta_links($links, $file, $data, $status) {
163
+			if ($file == plugin_basename(__FILE__)) {
164
+				$author1 = '<a href="'.$data['AuthorURI'].'">'.$data['Author'].'</a>';
165 165
 				$author2 = '<a href="http://www.subscriptiongroup.co.uk/">Subscription Group Limited</a>';
166
-				$links[ 1 ] = sprintf( __( 'By %s', self::TEXT_DOMAIN ), sprintf( __( '%s and %s', self::TEXT_DOMAIN ), $author1, $author2 ) );
166
+				$links[1] = sprintf(__('By %s', self::TEXT_DOMAIN), sprintf(__('%s and %s', self::TEXT_DOMAIN), $author1, $author2));
167 167
 			}
168 168
 
169 169
 			return $links;
Please login to merge, or discard this patch.