Completed
Push — master ( 9c0c61...cda7a3 )
by Sébastien
04:00 queued 01:54
created
wc-satt-stt.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,10 @@
 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') ) {
21
+    exit;
22
+}
23
+// Exit if accessed directly.
21 24
 
22 25
 if ( ! class_exists( 'WCSATT_STT' ) ) {
23 26
 	class WCSATT_STT {
Please login to merge, or discard this patch.
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -20,152 +20,152 @@
 block discarded – undo
20 20
 if ( ! defined('ABSPATH') ) exit; // Exit if accessed directly.
21 21
 
22 22
 if ( ! class_exists( 'WCSATT_STT' ) ) {
23
-	class WCSATT_STT {
24
-
25
-		/* Plugin version. */
26
-		const VERSION = '1.0.0';
27
-
28
-		/* Required WC version. */
29
-		const REQ_WC_VERSION = '2.3.0';
30
-
31
-		/* Required WCSATT version */
32
-		const REQ_WCSATT_VERSION = '1.1.0';
33
-
34
-		/* Text domain. */
35
-		const TEXT_DOMAIN = 'wc-satt-stt';
36
-
37
-		/**
38
-		 * @var WCSATT_STT - the single instance of the class.
39
-		 *
40
-		 * @since 1.0.0
41
-		 */
42
-		protected static $_instance = null;
43
-
44
-		/**
45
-		 * Main WCSATT_STT Instance.
46
-		 *
47
-		 * Ensures only one instance of WCSATT_STT is loaded or can be loaded.
48
-		 *
49
-		 * @static
50
-		 * @see WCSATT_STT()
51
-		 * @return WCSATT_STT - Main instance
52
-		 * @since 1.0.0
53
-		 */
54
-		public static function instance() {
55
-			if ( is_null( self::$_instance ) ) {
56
-				self::$_instance = new self();
57
-			}
58
-			return self::$_instance;
59
-		}
60
-
61
-		/**
62
-		 * Cloning is forbidden.
63
-		 *
64
-		 * @since 1.0.0
65
-		 */
66
-		public function __clone() {
67
-			_doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
68
-		}
69
-
70
-		/**
71
-		 * Unserializing instances of this class is forbidden.
72
-		 *
73
-		 * @since 1.0.0
74
-		 */
75
-		public function __wakeup() {
76
-			_doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
77
-		}
78
-
79
-		/**
80
-		 * Load the plugin.
81
-		 */
82
-		public function __construct() {
83
-			add_action( 'plugins_loaded', array( $this, 'load_plugin' ) );
84
-			add_action( 'init', array( $this, 'init_plugin' ) );
85
-			add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_links' ), 10, 4 );
86
-		}
87
-
88
-		public function plugin_path() {
89
-			return untrailingslashit( plugin_dir_path( __FILE__ ) );
90
-		} // END plugin_path()
91
-
92
-		/*
23
+    class WCSATT_STT {
24
+
25
+        /* Plugin version. */
26
+        const VERSION = '1.0.0';
27
+
28
+        /* Required WC version. */
29
+        const REQ_WC_VERSION = '2.3.0';
30
+
31
+        /* Required WCSATT version */
32
+        const REQ_WCSATT_VERSION = '1.1.0';
33
+
34
+        /* Text domain. */
35
+        const TEXT_DOMAIN = 'wc-satt-stt';
36
+
37
+        /**
38
+         * @var WCSATT_STT - the single instance of the class.
39
+         *
40
+         * @since 1.0.0
41
+         */
42
+        protected static $_instance = null;
43
+
44
+        /**
45
+         * Main WCSATT_STT Instance.
46
+         *
47
+         * Ensures only one instance of WCSATT_STT is loaded or can be loaded.
48
+         *
49
+         * @static
50
+         * @see WCSATT_STT()
51
+         * @return WCSATT_STT - Main instance
52
+         * @since 1.0.0
53
+         */
54
+        public static function instance() {
55
+            if ( is_null( self::$_instance ) ) {
56
+                self::$_instance = new self();
57
+            }
58
+            return self::$_instance;
59
+        }
60
+
61
+        /**
62
+         * Cloning is forbidden.
63
+         *
64
+         * @since 1.0.0
65
+         */
66
+        public function __clone() {
67
+            _doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
68
+        }
69
+
70
+        /**
71
+         * Unserializing instances of this class is forbidden.
72
+         *
73
+         * @since 1.0.0
74
+         */
75
+        public function __wakeup() {
76
+            _doing_it_wrong( __FUNCTION__, __( 'Foul!' ), '1.0.0' );
77
+        }
78
+
79
+        /**
80
+         * Load the plugin.
81
+         */
82
+        public function __construct() {
83
+            add_action( 'plugins_loaded', array( $this, 'load_plugin' ) );
84
+            add_action( 'init', array( $this, 'init_plugin' ) );
85
+            add_filter( 'plugin_row_meta', array( $this, 'plugin_meta_links' ), 10, 4 );
86
+        }
87
+
88
+        public function plugin_path() {
89
+            return untrailingslashit( plugin_dir_path( __FILE__ ) );
90
+        } // END plugin_path()
91
+
92
+        /*
93 93
 		 * Check requirements on activation.
94 94
 		 *
95 95
 		 * @global $woocommerce
96 96
 		 */
97
-		public function load_plugin() {
98
-			global $woocommerce;
99
-
100
-			// Check that the required WooCommerce is running.
101
-			if ( version_compare( $woocommerce->version, self::REQ_WC_VERSION, '<' ) ) {
102
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_wc_admin_notice' ) );
103
-				return false;
104
-			}
105
-
106
-			// Checks that WooCommerce Subscribe All the Things is running or is less than the required version.
107
-			if ( ! class_exists( 'WCS_ATT' ) || version_compare( WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<' ) ) {
108
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_admin_notice' ) );
109
-				return false;
110
-			}
111
-
112
-			require_once( 'includes/class-wcsatt-stt-cart.php' );
113
-			require_once( 'includes/class-wcsatt-stt-display.php' );
114
-
115
-			// Admin includes
116
-			if ( is_admin() ) {
117
-				require_once( 'includes/admin/class-wcsatt-stt-admin.php' );
118
-			}
119
-
120
-		} // END load_plugin()
121
-
122
-		/**
123
-		 * Display a warning message if minimum version of WooCommerce check fails.
124
-		 *
125
-		 * @return void
126
-		 */
127
-		public function wcsatt_stt_wc_admin_notice() {
128
-			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>';
129
-		} // END wcsatt_stt_wc_admin_notice()
130
-
131
-		/**
132
-		 * Display a warning message if minimum version of WooCommerce Subscribe All the Things check fails.
133
-		 *
134
-		 * @return void
135
-		 */
136
-		public function wcsatt_stt_admin_notice() {
137
-			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>';
138
-		} // END wcsatt_stt_admin_notice()
139
-
140
-		/**
141
-		 * Initialize the plugin if ready.
142
-		 *
143
-		 * @return void
144
-		 */
145
-		public function init_plugin() {
146
-			// Load text domain.
147
-			load_plugin_textdomain( 'wc-satt-stt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
148
-		} // END init_plugin()
149
-
150
-		/**
151
-		 * Show row meta on the plugin screen.
152
-		 *
153
-		 * @param  mixed $links Plugin Row Meta
154
-		 * @param  mixed $file  Plugin Base file
155
-		 * @param  array $data  Plugin Data
156
-		 * @return array
157
-		 */
158
-		public function plugin_meta_links( $links, $file, $data, $status ) {
159
-			if ( $file == plugin_basename( __FILE__ ) ) {
160
-				$author1 = '<a href="' . $data[ 'AuthorURI' ] . '">' . $data[ 'Author' ] . '</a>';
161
-				$author2 = '<a href="http://www.subscriptiongroup.co.uk/">Subscription Group Limited</a>';
162
-				$links[ 1 ] = sprintf( __( 'By %s', self::TEXT_DOMAIN ), sprintf( __( '%s and %s', self::TEXT_DOMAIN ), $author1, $author2 ) );
163
-			}
164
-
165
-			return $links;
166
-		} // END plugin_meta_links()
167
-
168
-	} // END class
97
+        public function load_plugin() {
98
+            global $woocommerce;
99
+
100
+            // Check that the required WooCommerce is running.
101
+            if ( version_compare( $woocommerce->version, self::REQ_WC_VERSION, '<' ) ) {
102
+                add_action( 'admin_notices', array( $this, 'wcsatt_stt_wc_admin_notice' ) );
103
+                return false;
104
+            }
105
+
106
+            // Checks that WooCommerce Subscribe All the Things is running or is less than the required version.
107
+            if ( ! class_exists( 'WCS_ATT' ) || version_compare( WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<' ) ) {
108
+                add_action( 'admin_notices', array( $this, 'wcsatt_stt_admin_notice' ) );
109
+                return false;
110
+            }
111
+
112
+            require_once( 'includes/class-wcsatt-stt-cart.php' );
113
+            require_once( 'includes/class-wcsatt-stt-display.php' );
114
+
115
+            // Admin includes
116
+            if ( is_admin() ) {
117
+                require_once( 'includes/admin/class-wcsatt-stt-admin.php' );
118
+            }
119
+
120
+        } // END load_plugin()
121
+
122
+        /**
123
+         * Display a warning message if minimum version of WooCommerce check fails.
124
+         *
125
+         * @return void
126
+         */
127
+        public function wcsatt_stt_wc_admin_notice() {
128
+            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>';
129
+        } // END wcsatt_stt_wc_admin_notice()
130
+
131
+        /**
132
+         * Display a warning message if minimum version of WooCommerce Subscribe All the Things check fails.
133
+         *
134
+         * @return void
135
+         */
136
+        public function wcsatt_stt_admin_notice() {
137
+            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>';
138
+        } // END wcsatt_stt_admin_notice()
139
+
140
+        /**
141
+         * Initialize the plugin if ready.
142
+         *
143
+         * @return void
144
+         */
145
+        public function init_plugin() {
146
+            // Load text domain.
147
+            load_plugin_textdomain( 'wc-satt-stt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
148
+        } // END init_plugin()
149
+
150
+        /**
151
+         * Show row meta on the plugin screen.
152
+         *
153
+         * @param  mixed $links Plugin Row Meta
154
+         * @param  mixed $file  Plugin Base file
155
+         * @param  array $data  Plugin Data
156
+         * @return array
157
+         */
158
+        public function plugin_meta_links( $links, $file, $data, $status ) {
159
+            if ( $file == plugin_basename( __FILE__ ) ) {
160
+                $author1 = '<a href="' . $data[ 'AuthorURI' ] . '">' . $data[ 'Author' ] . '</a>';
161
+                $author2 = '<a href="http://www.subscriptiongroup.co.uk/">Subscription Group Limited</a>';
162
+                $links[ 1 ] = sprintf( __( 'By %s', self::TEXT_DOMAIN ), sprintf( __( '%s and %s', self::TEXT_DOMAIN ), $author1, $author2 ) );
163
+            }
164
+
165
+            return $links;
166
+        } // END plugin_meta_links()
167
+
168
+    } // END class
169 169
 
170 170
 } // END if class exists
171 171
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 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,20 +73,20 @@  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_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_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 4);
86 86
 		}
87 87
 
88 88
 		public function plugin_path() {
89
-			return untrailingslashit( plugin_dir_path( __FILE__ ) );
89
+			return untrailingslashit(plugin_dir_path(__FILE__));
90 90
 		} // END plugin_path()
91 91
 
92 92
 		/*
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
 			global $woocommerce;
99 99
 
100 100
 			// Check that the required WooCommerce is running.
101
-			if ( version_compare( $woocommerce->version, self::REQ_WC_VERSION, '<' ) ) {
102
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_wc_admin_notice' ) );
101
+			if (version_compare($woocommerce->version, self::REQ_WC_VERSION, '<')) {
102
+				add_action('admin_notices', array($this, 'wcsatt_stt_wc_admin_notice'));
103 103
 				return false;
104 104
 			}
105 105
 
106 106
 			// Checks that WooCommerce Subscribe All the Things is running or is less than the required version.
107
-			if ( ! class_exists( 'WCS_ATT' ) || version_compare( WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<' ) ) {
108
-				add_action( 'admin_notices', array( $this, 'wcsatt_stt_admin_notice' ) );
107
+			if (!class_exists('WCS_ATT') || version_compare(WCS_ATT::VERSION, self::REQ_WCSATT_VERSION, '<')) {
108
+				add_action('admin_notices', array($this, 'wcsatt_stt_admin_notice'));
109 109
 				return false;
110 110
 			}
111 111
 
112
-			require_once( 'includes/class-wcsatt-stt-cart.php' );
113
-			require_once( 'includes/class-wcsatt-stt-display.php' );
112
+			require_once('includes/class-wcsatt-stt-cart.php');
113
+			require_once('includes/class-wcsatt-stt-display.php');
114 114
 
115 115
 			// Admin includes
116
-			if ( is_admin() ) {
117
-				require_once( 'includes/admin/class-wcsatt-stt-admin.php' );
116
+			if (is_admin()) {
117
+				require_once('includes/admin/class-wcsatt-stt-admin.php');
118 118
 			}
119 119
 
120 120
 		} // END load_plugin()
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		 * @return void
126 126
 		 */
127 127
 		public function wcsatt_stt_wc_admin_notice() {
128
-			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>';
128
+			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>';
129 129
 		} // END wcsatt_stt_wc_admin_notice()
130 130
 
131 131
 		/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 * @return void
135 135
 		 */
136 136
 		public function wcsatt_stt_admin_notice() {
137
-			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>';
137
+			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>';
138 138
 		} // END wcsatt_stt_admin_notice()
139 139
 
140 140
 		/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		 */
145 145
 		public function init_plugin() {
146 146
 			// Load text domain.
147
-			load_plugin_textdomain( 'wc-satt-stt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
147
+			load_plugin_textdomain('wc-satt-stt', false, dirname(plugin_basename(__FILE__)).'/languages/');
148 148
 		} // END init_plugin()
149 149
 
150 150
 		/**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 		 * @param  array $data  Plugin Data
156 156
 		 * @return array
157 157
 		 */
158
-		public function plugin_meta_links( $links, $file, $data, $status ) {
159
-			if ( $file == plugin_basename( __FILE__ ) ) {
160
-				$author1 = '<a href="' . $data[ 'AuthorURI' ] . '">' . $data[ 'Author' ] . '</a>';
158
+		public function plugin_meta_links($links, $file, $data, $status) {
159
+			if ($file == plugin_basename(__FILE__)) {
160
+				$author1 = '<a href="'.$data['AuthorURI'].'">'.$data['Author'].'</a>';
161 161
 				$author2 = '<a href="http://www.subscriptiongroup.co.uk/">Subscription Group Limited</a>';
162
-				$links[ 1 ] = sprintf( __( 'By %s', self::TEXT_DOMAIN ), sprintf( __( '%s and %s', self::TEXT_DOMAIN ), $author1, $author2 ) );
162
+				$links[1] = sprintf(__('By %s', self::TEXT_DOMAIN), sprintf(__('%s and %s', self::TEXT_DOMAIN), $author1, $author2));
163 163
 			}
164 164
 
165 165
 			return $links;
Please login to merge, or discard this patch.
includes/admin/class-wcsatt-stt-admin.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -8,150 +8,150 @@
 block discarded – undo
8 8
 
9 9
 class WCSATT_STT_Admin extends WCS_ATT_Admin {
10 10
 
11
-	/**
12
-	 * Initialize the product meta.
13
-	 *
14
-	 * @access public
15
-	 * @static
16
-	 */
17
-	public static function init() {
18
-		// Adds to the default values for subscriptions schemes content.
19
-		add_filter( 'wcsatt_default_subscription_scheme', __CLASS__ . '::subscription_schemes_content', 10, 1 );
20
-
21
-		// Subscription scheme options displayed on the 'wcsatt_subscription_scheme_product_content' action.
22
-		add_action( 'wcsatt_subscription_scheme_product_content', __CLASS__ . '::wcsatt_stt_fields', 15, 3 );
23
-
24
-		// Filter the subscription scheme data to process the sign up and trial options on the ''wcsatt_subscription_scheme_process_scheme_data' filter.
25
-		add_filter( 'wcsatt_subscription_scheme_process_scheme_data', __CLASS__ . '::wcsatt_stt_process_scheme_data', 10, 2 );
26
-	}
27
-
28
-	/**
29
-	 * Adds the default values for subscriptions schemes content.
30
-	 *
31
-	 * @access public
32
-	 * @static
33
-	 * @param  array $defaults
34
-	 * @return void
35
-	 */
36
-	public static function subscription_schemes_content( $defaults ) {
37
-		$new_defaults = array(
38
-			'subscription_sign_up_fee'  => '',
39
-			'subscription_trial_length' => '',
40
-			'subscription_trial_period' => ''
41
-		);
42
-
43
-		return array_merge( $new_defaults, $defaults );
44
-	} // END subscription_schemes_content()
45
-
46
-	/**
47
-	 * Adds the trial and sign up fields under the subscription section.
48
-	 *
49
-	 * @access public
50
-	 * @static
51
-	 * @param  int   $index
52
-	 * @param  array $scheme_data
53
-	 * @param  int   $post_id
54
-	 * @return void
55
-	 */
56
-	public static function wcsatt_stt_fields( $index, $scheme_data, $post_id ) {
57
-		if ( ! empty( $scheme_data ) ) {
58
-			$subscription_sign_up_fee = ! empty( $scheme_data[ 'subscription_sign_up_fee' ] ) ? $scheme_data[ 'subscription_sign_up_fee' ] : '';
59
-			$subscription_trial_length = isset( $scheme_data[ 'subscription_trial_length' ] ) ? $scheme_data[ 'subscription_trial_length' ] : 0;
60
-			$subscription_trial_period = isset( $scheme_data[ 'subscription_trial_period' ] ) ? $scheme_data[ 'subscription_trial_period' ] : '';
61
-		} else {
62
-			$subscription_sign_up_fee = '';
63
-			$subscription_trial_length = 0;
64
-			$subscription_trial_period = '';
65
-		}
66
-
67
-		// Sign-up Fee
68
-		woocommerce_wp_text_input( array(
69
-			'id'          => '_subscription_sign_up_fee',
70
-			'class'       => 'wc_input_subscription_intial_price',
71
-			// translators: %s is a currency symbol / code
72
-			'label'       => sprintf( __( 'Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN ), get_woocommerce_currency_symbol() ),
73
-			'placeholder' => _x( 'e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN ),
74
-			'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 ),
75
-			'desc_tip'    => true,
76
-			'type'        => 'text',
77
-			'custom_attributes' => array(
78
-				'step' => 'any',
79
-				'min'  => '0',
80
-			),
81
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_sign_up_fee]',
82
-			'value'       => $subscription_sign_up_fee
83
-		) );
84
-
85
-		// Trial Length
86
-		woocommerce_wp_text_input( array(
87
-			'id'          => '_subscription_trial_length',
88
-			'class'       => 'wc_input_subscription_trial_length',
89
-			'label'       => __( 'Free Trial', WCSATT_STT::TEXT_DOMAIN ),
90
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_length]',
91
-			'value'       => $subscription_trial_length
92
-		) );
93
-
94
-		// Trial Period
95
-		woocommerce_wp_select( array(
96
-			'id'          => '_subscription_trial_period',
97
-			'class'       => 'wc_input_subscription_trial_period',
98
-			'label'       => __( 'Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN ),
99
-			'options'     => wcs_get_available_time_periods(),
100
-			// translators: placeholder is trial period validation message if passed an invalid value (e.g. "Trial period can not exceed 4 weeks")
101
-			'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() ),
102
-			'desc_tip'    => true,
103
-			'value'       => WC_Subscriptions_Product::get_trial_period( $post_id ), // Explicitly set value in to ensure backward compatibility
104
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_period]',
105
-			'value'       => $subscription_trial_period
106
-	) );
107
-	} // END wcsatt_stt_fields()
108
-
109
-	/**
110
-	 * Filters the subscription scheme data to pass the 
111
-	 * sign up and trial options when saving.
112
-	 *
113
-	 * @access public
114
-	 * @static
115
-	 * @param  ini    $posted_scheme
116
-	 * @param  string $product_type
117
-	 * @return void
118
-	 */
119
-	public static function wcsatt_stt_process_scheme_data( $posted_scheme, $product_type ) {
120
-		// Copy variable type fields.
121
-		if ( 'variable' == $product_type ) {
122
-			if ( isset( $posted_scheme[ 'subscription_sign_up_fee_variable' ] ) ) {
123
-				$posted_scheme[ 'subscription_sign_up_fee' ] = $posted_scheme[ 'subscription_sign_up_fee_variable' ];
124
-			}
125
-			if ( isset( $posted_scheme[ 'subscription_trial_length_variable' ] ) ) {
126
-				$posted_scheme[ 'subscription_trial_length' ] = $posted_scheme[ 'subscription_trial_length_variable' ];
127
-			}
128
-			if ( isset( $posted_scheme[ 'subscription_trial_period_variable' ] ) ) {
129
-				$posted_scheme[ 'subscription_trial_period' ] = $posted_scheme[ 'subscription_trial_period_variable'];
130
-			}
131
-		}
132
-
133
-		// Format subscription sign up fee.
134
-		if ( isset( $posted_scheme[ 'subscription_sign_up_fee' ] ) ) {
135
-			$posted_scheme[ 'subscription_sign_up_fee' ] = ( $posted_scheme[ 'subscription_sign_up_fee' ] === '' ) ? '' : wc_format_decimal( $posted_scheme[ 'subscription_sign_up_fee' ] );
136
-		}
137
-
138
-		// Make sure trial period is within allowable range.
139
-		$subscription_ranges = wcs_get_subscription_ranges();
140
-		$max_trial_length = count( $subscription_ranges[ $posted_scheme[ 'subscription_trial_period' ] ] ) - 1;
141
-
142
-		// Format subscription trial length.
143
-		if ( isset( $posted_scheme[ 'subscription_trial_length' ] ) && $posted_scheme[ 'subscription_trial_length' ] > $max_trial_length ) {
144
-			$posted_scheme[ 'subscription_trial_length' ] = ( $posted_scheme[ 'subscription_trial_length' ] === '' ) ? '' : absint( $posted_scheme[ 'subscription_trial_length' ] );
145
-		}
146
-
147
-		// Format subscription trial period.
148
-		$trial_periods = apply_filters( 'wcsatt_stt_trial_periods', array( 'day', 'week', 'month', 'year' ) );
149
-		if ( isset( $posted_scheme[ 'subscription_trial_period' ] ) && in_array( $posted_scheme[ 'subscription_trial_period' ], $trial_periods ) ) {
150
-			$posted_scheme[ 'subscription_trial_period' ] = trim( $posted_scheme[ 'subscription_trial_period' ] );
151
-		}
152
-
153
-		return $posted_scheme;
154
-	} // END wcsatt_stt_process_scheme_data()
11
+    /**
12
+     * Initialize the product meta.
13
+     *
14
+     * @access public
15
+     * @static
16
+     */
17
+    public static function init() {
18
+        // Adds to the default values for subscriptions schemes content.
19
+        add_filter( 'wcsatt_default_subscription_scheme', __CLASS__ . '::subscription_schemes_content', 10, 1 );
20
+
21
+        // Subscription scheme options displayed on the 'wcsatt_subscription_scheme_product_content' action.
22
+        add_action( 'wcsatt_subscription_scheme_product_content', __CLASS__ . '::wcsatt_stt_fields', 15, 3 );
23
+
24
+        // Filter the subscription scheme data to process the sign up and trial options on the ''wcsatt_subscription_scheme_process_scheme_data' filter.
25
+        add_filter( 'wcsatt_subscription_scheme_process_scheme_data', __CLASS__ . '::wcsatt_stt_process_scheme_data', 10, 2 );
26
+    }
27
+
28
+    /**
29
+     * Adds the default values for subscriptions schemes content.
30
+     *
31
+     * @access public
32
+     * @static
33
+     * @param  array $defaults
34
+     * @return void
35
+     */
36
+    public static function subscription_schemes_content( $defaults ) {
37
+        $new_defaults = array(
38
+            'subscription_sign_up_fee'  => '',
39
+            'subscription_trial_length' => '',
40
+            'subscription_trial_period' => ''
41
+        );
42
+
43
+        return array_merge( $new_defaults, $defaults );
44
+    } // END subscription_schemes_content()
45
+
46
+    /**
47
+     * Adds the trial and sign up fields under the subscription section.
48
+     *
49
+     * @access public
50
+     * @static
51
+     * @param  int   $index
52
+     * @param  array $scheme_data
53
+     * @param  int   $post_id
54
+     * @return void
55
+     */
56
+    public static function wcsatt_stt_fields( $index, $scheme_data, $post_id ) {
57
+        if ( ! empty( $scheme_data ) ) {
58
+            $subscription_sign_up_fee = ! empty( $scheme_data[ 'subscription_sign_up_fee' ] ) ? $scheme_data[ 'subscription_sign_up_fee' ] : '';
59
+            $subscription_trial_length = isset( $scheme_data[ 'subscription_trial_length' ] ) ? $scheme_data[ 'subscription_trial_length' ] : 0;
60
+            $subscription_trial_period = isset( $scheme_data[ 'subscription_trial_period' ] ) ? $scheme_data[ 'subscription_trial_period' ] : '';
61
+        } else {
62
+            $subscription_sign_up_fee = '';
63
+            $subscription_trial_length = 0;
64
+            $subscription_trial_period = '';
65
+        }
66
+
67
+        // Sign-up Fee
68
+        woocommerce_wp_text_input( array(
69
+            'id'          => '_subscription_sign_up_fee',
70
+            'class'       => 'wc_input_subscription_intial_price',
71
+            // translators: %s is a currency symbol / code
72
+            'label'       => sprintf( __( 'Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN ), get_woocommerce_currency_symbol() ),
73
+            'placeholder' => _x( 'e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN ),
74
+            '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 ),
75
+            'desc_tip'    => true,
76
+            'type'        => 'text',
77
+            'custom_attributes' => array(
78
+                'step' => 'any',
79
+                'min'  => '0',
80
+            ),
81
+            'name'        => 'wcsatt_schemes[' . $index . '][subscription_sign_up_fee]',
82
+            'value'       => $subscription_sign_up_fee
83
+        ) );
84
+
85
+        // Trial Length
86
+        woocommerce_wp_text_input( array(
87
+            'id'          => '_subscription_trial_length',
88
+            'class'       => 'wc_input_subscription_trial_length',
89
+            'label'       => __( 'Free Trial', WCSATT_STT::TEXT_DOMAIN ),
90
+            'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_length]',
91
+            'value'       => $subscription_trial_length
92
+        ) );
93
+
94
+        // Trial Period
95
+        woocommerce_wp_select( array(
96
+            'id'          => '_subscription_trial_period',
97
+            'class'       => 'wc_input_subscription_trial_period',
98
+            'label'       => __( 'Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN ),
99
+            'options'     => wcs_get_available_time_periods(),
100
+            // translators: placeholder is trial period validation message if passed an invalid value (e.g. "Trial period can not exceed 4 weeks")
101
+            '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() ),
102
+            'desc_tip'    => true,
103
+            'value'       => WC_Subscriptions_Product::get_trial_period( $post_id ), // Explicitly set value in to ensure backward compatibility
104
+            'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_period]',
105
+            'value'       => $subscription_trial_period
106
+    ) );
107
+    } // END wcsatt_stt_fields()
108
+
109
+    /**
110
+     * Filters the subscription scheme data to pass the 
111
+     * sign up and trial options when saving.
112
+     *
113
+     * @access public
114
+     * @static
115
+     * @param  ini    $posted_scheme
116
+     * @param  string $product_type
117
+     * @return void
118
+     */
119
+    public static function wcsatt_stt_process_scheme_data( $posted_scheme, $product_type ) {
120
+        // Copy variable type fields.
121
+        if ( 'variable' == $product_type ) {
122
+            if ( isset( $posted_scheme[ 'subscription_sign_up_fee_variable' ] ) ) {
123
+                $posted_scheme[ 'subscription_sign_up_fee' ] = $posted_scheme[ 'subscription_sign_up_fee_variable' ];
124
+            }
125
+            if ( isset( $posted_scheme[ 'subscription_trial_length_variable' ] ) ) {
126
+                $posted_scheme[ 'subscription_trial_length' ] = $posted_scheme[ 'subscription_trial_length_variable' ];
127
+            }
128
+            if ( isset( $posted_scheme[ 'subscription_trial_period_variable' ] ) ) {
129
+                $posted_scheme[ 'subscription_trial_period' ] = $posted_scheme[ 'subscription_trial_period_variable'];
130
+            }
131
+        }
132
+
133
+        // Format subscription sign up fee.
134
+        if ( isset( $posted_scheme[ 'subscription_sign_up_fee' ] ) ) {
135
+            $posted_scheme[ 'subscription_sign_up_fee' ] = ( $posted_scheme[ 'subscription_sign_up_fee' ] === '' ) ? '' : wc_format_decimal( $posted_scheme[ 'subscription_sign_up_fee' ] );
136
+        }
137
+
138
+        // Make sure trial period is within allowable range.
139
+        $subscription_ranges = wcs_get_subscription_ranges();
140
+        $max_trial_length = count( $subscription_ranges[ $posted_scheme[ 'subscription_trial_period' ] ] ) - 1;
141
+
142
+        // Format subscription trial length.
143
+        if ( isset( $posted_scheme[ 'subscription_trial_length' ] ) && $posted_scheme[ 'subscription_trial_length' ] > $max_trial_length ) {
144
+            $posted_scheme[ 'subscription_trial_length' ] = ( $posted_scheme[ 'subscription_trial_length' ] === '' ) ? '' : absint( $posted_scheme[ 'subscription_trial_length' ] );
145
+        }
146
+
147
+        // Format subscription trial period.
148
+        $trial_periods = apply_filters( 'wcsatt_stt_trial_periods', array( 'day', 'week', 'month', 'year' ) );
149
+        if ( isset( $posted_scheme[ 'subscription_trial_period' ] ) && in_array( $posted_scheme[ 'subscription_trial_period' ], $trial_periods ) ) {
150
+            $posted_scheme[ 'subscription_trial_period' ] = trim( $posted_scheme[ 'subscription_trial_period' ] );
151
+        }
152
+
153
+        return $posted_scheme;
154
+    } // END wcsatt_stt_process_scheme_data()
155 155
 
156 156
 }
157 157
 
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	public static function init() {
18 18
 		// Adds to the default values for subscriptions schemes content.
19
-		add_filter( 'wcsatt_default_subscription_scheme', __CLASS__ . '::subscription_schemes_content', 10, 1 );
19
+		add_filter('wcsatt_default_subscription_scheme', __CLASS__.'::subscription_schemes_content', 10, 1);
20 20
 
21 21
 		// Subscription scheme options displayed on the 'wcsatt_subscription_scheme_product_content' action.
22
-		add_action( 'wcsatt_subscription_scheme_product_content', __CLASS__ . '::wcsatt_stt_fields', 15, 3 );
22
+		add_action('wcsatt_subscription_scheme_product_content', __CLASS__.'::wcsatt_stt_fields', 15, 3);
23 23
 
24 24
 		// Filter the subscription scheme data to process the sign up and trial options on the ''wcsatt_subscription_scheme_process_scheme_data' filter.
25
-		add_filter( 'wcsatt_subscription_scheme_process_scheme_data', __CLASS__ . '::wcsatt_stt_process_scheme_data', 10, 2 );
25
+		add_filter('wcsatt_subscription_scheme_process_scheme_data', __CLASS__.'::wcsatt_stt_process_scheme_data', 10, 2);
26 26
 	}
27 27
 
28 28
 	/**
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	 * @param  array $defaults
34 34
 	 * @return void
35 35
 	 */
36
-	public static function subscription_schemes_content( $defaults ) {
36
+	public static function subscription_schemes_content($defaults) {
37 37
 		$new_defaults = array(
38 38
 			'subscription_sign_up_fee'  => '',
39 39
 			'subscription_trial_length' => '',
40 40
 			'subscription_trial_period' => ''
41 41
 		);
42 42
 
43
-		return array_merge( $new_defaults, $defaults );
43
+		return array_merge($new_defaults, $defaults);
44 44
 	} // END subscription_schemes_content()
45 45
 
46 46
 	/**
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 * @param  int   $post_id
54 54
 	 * @return void
55 55
 	 */
56
-	public static function wcsatt_stt_fields( $index, $scheme_data, $post_id ) {
57
-		if ( ! empty( $scheme_data ) ) {
58
-			$subscription_sign_up_fee = ! empty( $scheme_data[ 'subscription_sign_up_fee' ] ) ? $scheme_data[ 'subscription_sign_up_fee' ] : '';
59
-			$subscription_trial_length = isset( $scheme_data[ 'subscription_trial_length' ] ) ? $scheme_data[ 'subscription_trial_length' ] : 0;
60
-			$subscription_trial_period = isset( $scheme_data[ 'subscription_trial_period' ] ) ? $scheme_data[ 'subscription_trial_period' ] : '';
56
+	public static function wcsatt_stt_fields($index, $scheme_data, $post_id) {
57
+		if (!empty($scheme_data)) {
58
+			$subscription_sign_up_fee = !empty($scheme_data['subscription_sign_up_fee']) ? $scheme_data['subscription_sign_up_fee'] : '';
59
+			$subscription_trial_length = isset($scheme_data['subscription_trial_length']) ? $scheme_data['subscription_trial_length'] : 0;
60
+			$subscription_trial_period = isset($scheme_data['subscription_trial_period']) ? $scheme_data['subscription_trial_period'] : '';
61 61
 		} else {
62 62
 			$subscription_sign_up_fee = '';
63 63
 			$subscription_trial_length = 0;
@@ -65,45 +65,45 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 
67 67
 		// Sign-up Fee
68
-		woocommerce_wp_text_input( array(
68
+		woocommerce_wp_text_input(array(
69 69
 			'id'          => '_subscription_sign_up_fee',
70 70
 			'class'       => 'wc_input_subscription_intial_price',
71 71
 			// translators: %s is a currency symbol / code
72
-			'label'       => sprintf( __( 'Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN ), get_woocommerce_currency_symbol() ),
73
-			'placeholder' => _x( 'e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN ),
74
-			'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 ),
72
+			'label'       => sprintf(__('Sign-up Fee (%s)', WCSATT_STT::TEXT_DOMAIN), get_woocommerce_currency_symbol()),
73
+			'placeholder' => _x('e.g. 9.90', 'example price', WCSATT_STT::TEXT_DOMAIN),
74
+			'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),
75 75
 			'desc_tip'    => true,
76 76
 			'type'        => 'text',
77 77
 			'custom_attributes' => array(
78 78
 				'step' => 'any',
79 79
 				'min'  => '0',
80 80
 			),
81
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_sign_up_fee]',
81
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_sign_up_fee]',
82 82
 			'value'       => $subscription_sign_up_fee
83
-		) );
83
+		));
84 84
 
85 85
 		// Trial Length
86
-		woocommerce_wp_text_input( array(
86
+		woocommerce_wp_text_input(array(
87 87
 			'id'          => '_subscription_trial_length',
88 88
 			'class'       => 'wc_input_subscription_trial_length',
89
-			'label'       => __( 'Free Trial', WCSATT_STT::TEXT_DOMAIN ),
90
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_length]',
89
+			'label'       => __('Free Trial', WCSATT_STT::TEXT_DOMAIN),
90
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_length]',
91 91
 			'value'       => $subscription_trial_length
92
-		) );
92
+		));
93 93
 
94 94
 		// Trial Period
95
-		woocommerce_wp_select( array(
95
+		woocommerce_wp_select(array(
96 96
 			'id'          => '_subscription_trial_period',
97 97
 			'class'       => 'wc_input_subscription_trial_period',
98
-			'label'       => __( 'Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN ),
98
+			'label'       => __('Subscription Trial Period', WCSATT_STT::TEXT_DOMAIN),
99 99
 			'options'     => wcs_get_available_time_periods(),
100 100
 			// translators: placeholder is trial period validation message if passed an invalid value (e.g. "Trial period can not exceed 4 weeks")
101
-			'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() ),
101
+			'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()),
102 102
 			'desc_tip'    => true,
103
-			'value'       => WC_Subscriptions_Product::get_trial_period( $post_id ), // Explicitly set value in to ensure backward compatibility
104
-			'name'        => 'wcsatt_schemes[' . $index . '][subscription_trial_period]',
103
+			'value'       => WC_Subscriptions_Product::get_trial_period($post_id), // Explicitly set value in to ensure backward compatibility
104
+			'name'        => 'wcsatt_schemes['.$index.'][subscription_trial_period]',
105 105
 			'value'       => $subscription_trial_period
106
-	) );
106
+	));
107 107
 	} // END wcsatt_stt_fields()
108 108
 
109 109
 	/**
@@ -116,38 +116,38 @@  discard block
 block discarded – undo
116 116
 	 * @param  string $product_type
117 117
 	 * @return void
118 118
 	 */
119
-	public static function wcsatt_stt_process_scheme_data( $posted_scheme, $product_type ) {
119
+	public static function wcsatt_stt_process_scheme_data($posted_scheme, $product_type) {
120 120
 		// Copy variable type fields.
121
-		if ( 'variable' == $product_type ) {
122
-			if ( isset( $posted_scheme[ 'subscription_sign_up_fee_variable' ] ) ) {
123
-				$posted_scheme[ 'subscription_sign_up_fee' ] = $posted_scheme[ 'subscription_sign_up_fee_variable' ];
121
+		if ('variable' == $product_type) {
122
+			if (isset($posted_scheme['subscription_sign_up_fee_variable'])) {
123
+				$posted_scheme['subscription_sign_up_fee'] = $posted_scheme['subscription_sign_up_fee_variable'];
124 124
 			}
125
-			if ( isset( $posted_scheme[ 'subscription_trial_length_variable' ] ) ) {
126
-				$posted_scheme[ 'subscription_trial_length' ] = $posted_scheme[ 'subscription_trial_length_variable' ];
125
+			if (isset($posted_scheme['subscription_trial_length_variable'])) {
126
+				$posted_scheme['subscription_trial_length'] = $posted_scheme['subscription_trial_length_variable'];
127 127
 			}
128
-			if ( isset( $posted_scheme[ 'subscription_trial_period_variable' ] ) ) {
129
-				$posted_scheme[ 'subscription_trial_period' ] = $posted_scheme[ 'subscription_trial_period_variable'];
128
+			if (isset($posted_scheme['subscription_trial_period_variable'])) {
129
+				$posted_scheme['subscription_trial_period'] = $posted_scheme['subscription_trial_period_variable'];
130 130
 			}
131 131
 		}
132 132
 
133 133
 		// Format subscription sign up fee.
134
-		if ( isset( $posted_scheme[ 'subscription_sign_up_fee' ] ) ) {
135
-			$posted_scheme[ 'subscription_sign_up_fee' ] = ( $posted_scheme[ 'subscription_sign_up_fee' ] === '' ) ? '' : wc_format_decimal( $posted_scheme[ 'subscription_sign_up_fee' ] );
134
+		if (isset($posted_scheme['subscription_sign_up_fee'])) {
135
+			$posted_scheme['subscription_sign_up_fee'] = ($posted_scheme['subscription_sign_up_fee'] === '') ? '' : wc_format_decimal($posted_scheme['subscription_sign_up_fee']);
136 136
 		}
137 137
 
138 138
 		// Make sure trial period is within allowable range.
139 139
 		$subscription_ranges = wcs_get_subscription_ranges();
140
-		$max_trial_length = count( $subscription_ranges[ $posted_scheme[ 'subscription_trial_period' ] ] ) - 1;
140
+		$max_trial_length = count($subscription_ranges[$posted_scheme['subscription_trial_period']]) - 1;
141 141
 
142 142
 		// Format subscription trial length.
143
-		if ( isset( $posted_scheme[ 'subscription_trial_length' ] ) && $posted_scheme[ 'subscription_trial_length' ] > $max_trial_length ) {
144
-			$posted_scheme[ 'subscription_trial_length' ] = ( $posted_scheme[ 'subscription_trial_length' ] === '' ) ? '' : absint( $posted_scheme[ 'subscription_trial_length' ] );
143
+		if (isset($posted_scheme['subscription_trial_length']) && $posted_scheme['subscription_trial_length'] > $max_trial_length) {
144
+			$posted_scheme['subscription_trial_length'] = ($posted_scheme['subscription_trial_length'] === '') ? '' : absint($posted_scheme['subscription_trial_length']);
145 145
 		}
146 146
 
147 147
 		// Format subscription trial period.
148
-		$trial_periods = apply_filters( 'wcsatt_stt_trial_periods', array( 'day', 'week', 'month', 'year' ) );
149
-		if ( isset( $posted_scheme[ 'subscription_trial_period' ] ) && in_array( $posted_scheme[ 'subscription_trial_period' ], $trial_periods ) ) {
150
-			$posted_scheme[ 'subscription_trial_period' ] = trim( $posted_scheme[ 'subscription_trial_period' ] );
148
+		$trial_periods = apply_filters('wcsatt_stt_trial_periods', array('day', 'week', 'month', 'year'));
149
+		if (isset($posted_scheme['subscription_trial_period']) && in_array($posted_scheme['subscription_trial_period'], $trial_periods)) {
150
+			$posted_scheme['subscription_trial_period'] = trim($posted_scheme['subscription_trial_period']);
151 151
 		}
152 152
 
153 153
 		return $posted_scheme;
Please login to merge, or discard this patch.
includes/class-wcsatt-stt-display.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -8,163 +8,163 @@
 block discarded – undo
8 8
 
9 9
 class WCSATT_STT_Display extends WCS_ATT_Display {
10 10
 
11
-	/**
12
-	 * Initialize the display.
13
-	 *
14
-	 * @access public
15
-	 * @static
16
-	 */
17
-	public static function init() {
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 );
20
-
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 );
23
-
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 );
26
-
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 );
29
-
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 );
32
-
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 );
35
-	}
36
-
37
-	/**
38
-	 * Adds the additional subscription scheme data for products with attached subscription schemes.
39
-	 *
40
-	 * @access public
41
-	 * @static
42
-	 * @param  object     $_product
43
-	 * @param  array      $subscription_scheme
44
-	 * @param  WC_Product $product
45
-	 * @return string
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' ];
50
-		}
51
-
52
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
53
-			$_product->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
54
-		}
55
-
56
-		if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
57
-			$_product->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
58
-		}
59
-
60
-		return $_product;
61
-	} // END add_sub_scheme_data_price_html()
62
-
63
-	/**
64
-	 * Adds the extra subscription scheme data to the product object.
65
-	 * This allows the subscription price to change the initial and
66
-	 * recurring subscriptions.
67
-	 *
68
-	 * @access public
69
-	 * @static
70
-	 * @param  object $_cloned
71
-	 * @param  array  $subscription_scheme
72
-	 * @return object
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' ];
77
-		}
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' ];
82
-		}
83
-
84
-		return $_cloned;
85
-	} // END sub_product_scheme_option()
86
-
87
-	/**
88
-	 * Filters the price string to include the sign up fee and/or trial 
89
-	 * to pass per subscription scheme option.
90
-	 *
91
-	 * @access public
92
-	 * @static
93
-	 * @param  array $prices
94
-	 * @param  array $subscription_scheme
95
-	 * @return array
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' ];
100
-		}
101
-
102
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
103
-			$prices[ 'trial_length' ] = true;
104
-		}
105
-
106
-		return $prices;
107
-	} // END get_price_string()
108
-
109
-	/**
110
-	 * Filters the price string to include the sign up 
111
-	 * fee on the lowest subscription scheme.
112
-	 *
113
-	 * @access public
114
-	 * @static
115
-	 * @param  array $prices
116
-	 * @param  array $lowest_subscription_scheme
117
-	 * @return array
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' ];
122
-		}
123
-
124
-		return $prices;
125
-	} // END get_lowest_price_string()
126
-
127
-	/**
128
-	 * Adds the sign-up fee to the lowest subscription scheme option.
129
-	 *
130
-	 * @access public
131
-	 * @static
132
-	 * @param array $data
133
-	 * @param array $lowest_scheme
134
-	 * @return array
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 ) {
138
-			$data['sign_up_fee'] = $lowest_scheme['subscription_sign_up_fee'];
139
-		}
140
-
141
-		return $data;
142
-	} // END get_lowest_price_sub_scheme_data()
143
-
144
-	/**
145
-	 * Adds the sign-up and/or trial data to the subscription scheme prices.
146
-	 *
147
-	 * @access public
148
-	 * @static
149
-	 * @param  array $prices
150
-	 * @param  array $subscription_scheme
151
-	 * @return array
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' ];
156
-		}
157
-
158
-		if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
159
-			$prices[ 'trial_length' ] = $subscription_scheme[ 'subscription_trial_length' ];
160
-		}
161
-
162
-		if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
163
-			$prices[ 'trial_period' ] = $subscription_scheme[ 'subscription_trial_period' ];
164
-		}
165
-
166
-		return $prices;
167
-	} // END add_subscription_scheme_prices()
11
+    /**
12
+     * Initialize the display.
13
+     *
14
+     * @access public
15
+     * @static
16
+     */
17
+    public static function init() {
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 );
20
+
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 );
23
+
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 );
26
+
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 );
29
+
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 );
32
+
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 );
35
+    }
36
+
37
+    /**
38
+     * Adds the additional subscription scheme data for products with attached subscription schemes.
39
+     *
40
+     * @access public
41
+     * @static
42
+     * @param  object     $_product
43
+     * @param  array      $subscription_scheme
44
+     * @param  WC_Product $product
45
+     * @return string
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' ];
50
+        }
51
+
52
+        if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
53
+            $_product->subscription_trial_length = $subscription_scheme[ 'subscription_trial_length' ];
54
+        }
55
+
56
+        if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
57
+            $_product->subscription_trial_period = $subscription_scheme[ 'subscription_trial_period' ];
58
+        }
59
+
60
+        return $_product;
61
+    } // END add_sub_scheme_data_price_html()
62
+
63
+    /**
64
+     * Adds the extra subscription scheme data to the product object.
65
+     * This allows the subscription price to change the initial and
66
+     * recurring subscriptions.
67
+     *
68
+     * @access public
69
+     * @static
70
+     * @param  object $_cloned
71
+     * @param  array  $subscription_scheme
72
+     * @return object
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' ];
77
+        }
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' ];
82
+        }
83
+
84
+        return $_cloned;
85
+    } // END sub_product_scheme_option()
86
+
87
+    /**
88
+     * Filters the price string to include the sign up fee and/or trial 
89
+     * to pass per subscription scheme option.
90
+     *
91
+     * @access public
92
+     * @static
93
+     * @param  array $prices
94
+     * @param  array $subscription_scheme
95
+     * @return array
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' ];
100
+        }
101
+
102
+        if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) && 0 != $subscription_scheme[ 'subscription_trial_length' ] ) {
103
+            $prices[ 'trial_length' ] = true;
104
+        }
105
+
106
+        return $prices;
107
+    } // END get_price_string()
108
+
109
+    /**
110
+     * Filters the price string to include the sign up 
111
+     * fee on the lowest subscription scheme.
112
+     *
113
+     * @access public
114
+     * @static
115
+     * @param  array $prices
116
+     * @param  array $lowest_subscription_scheme
117
+     * @return array
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' ];
122
+        }
123
+
124
+        return $prices;
125
+    } // END get_lowest_price_string()
126
+
127
+    /**
128
+     * Adds the sign-up fee to the lowest subscription scheme option.
129
+     *
130
+     * @access public
131
+     * @static
132
+     * @param array $data
133
+     * @param array $lowest_scheme
134
+     * @return array
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 ) {
138
+            $data['sign_up_fee'] = $lowest_scheme['subscription_sign_up_fee'];
139
+        }
140
+
141
+        return $data;
142
+    } // END get_lowest_price_sub_scheme_data()
143
+
144
+    /**
145
+     * Adds the sign-up and/or trial data to the subscription scheme prices.
146
+     *
147
+     * @access public
148
+     * @static
149
+     * @param  array $prices
150
+     * @param  array $subscription_scheme
151
+     * @return array
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' ];
156
+        }
157
+
158
+        if ( isset( $subscription_scheme[ 'subscription_trial_length' ] ) ) {
159
+            $prices[ 'trial_length' ] = $subscription_scheme[ 'subscription_trial_length' ];
160
+        }
161
+
162
+        if ( isset( $subscription_scheme[ 'subscription_trial_period' ] ) ) {
163
+            $prices[ 'trial_period' ] = $subscription_scheme[ 'subscription_trial_period' ];
164
+        }
165
+
166
+        return $prices;
167
+    } // END add_subscription_scheme_prices()
168 168
 
169 169
 }
170 170
 
Please login to merge, or discard this 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 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -8,69 +8,69 @@
 block discarded – undo
8 8
 
9 9
 class WCSATT_STT_Cart extends WCS_ATT_Cart {
10 10
 
11
-	/**
12
-	 * Initialize the cart.
13
-	 *
14
-	 * @access public
15
-	 * @static
16
-	 */
17
-	public static function init() {
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 );
20
-	}
21
-
22
-	/**
23
-	 * Updates the cart item data for a subscription product that
24
-	 * has a sign-up fee and/or trial period applied.
25
-	 *
26
-	 * @access public
27
-	 * @static
28
-	 * @param  array $cart_item
29
-	 * @return array
30
-	 */
31
-	public static function update_cart_item_sub_data( $cart_item ) {
32
-		$active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme( $cart_item );
33
-
34
-		$subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices( $cart_item, $active_scheme );
35
-
36
-		if ( $active_scheme && $cart_item['data']->is_converted_to_sub == 'yes' ) {
37
-
38
-			// Subscription Price
39
-			$price = $cart_item['data']->subscription_price;
40
-
41
-			// Is there a sign up fee?
42
-			$sign_up_fee = isset( $subscription_prices['sign_up_fee'] ) ? $subscription_prices['sign_up_fee'] : '';
43
-
44
-			// Checks if the cart item is a supported bundle type child.
45
-			$container_key = WCS_ATT_Integrations::has_bundle_type_container( $cart_item );
46
-
47
-			// If the cart item is a child item then reset the sign-up fee.
48
-			if ( false !== $container_key ) { $sign_up_fee = ''; }
49
-
50
-			// Put both the subscription price and the sign-up fee together.
51
-			$new_price = round( $price + $sign_up_fee, wc_get_price_decimals() );
52
-
53
-			if ( $sign_up_fee > 0 ) {
54
-				$cart_item['data']->initial_amount = $new_price;
55
-				$cart_item['data']->subscription_sign_up_fee = $sign_up_fee;
56
-			}
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'] : '';
60
-
61
-			// If a trial length is more than zero then set the conditions for the cart.
62
-			if ( $trial_length > 0 ) {
63
-				$cart_item['data']->subscription_trial_length = $trial_length;
64
-				$cart_item['data']->subscription_trial_period = $trial_period;
65
-			} else {
66
-				$cart_item['data']->subscription_trial_length = 0;
67
-				$cart_item['data']->subscription_trial_period = '';
68
-			}
69
-
70
-		}
71
-
72
-		return $cart_item;
73
-	} // END update_cart_item_sub_data()
11
+    /**
12
+     * Initialize the cart.
13
+     *
14
+     * @access public
15
+     * @static
16
+     */
17
+    public static function init() {
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 );
20
+    }
21
+
22
+    /**
23
+     * Updates the cart item data for a subscription product that
24
+     * has a sign-up fee and/or trial period applied.
25
+     *
26
+     * @access public
27
+     * @static
28
+     * @param  array $cart_item
29
+     * @return array
30
+     */
31
+    public static function update_cart_item_sub_data( $cart_item ) {
32
+        $active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme( $cart_item );
33
+
34
+        $subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices( $cart_item, $active_scheme );
35
+
36
+        if ( $active_scheme && $cart_item['data']->is_converted_to_sub == 'yes' ) {
37
+
38
+            // Subscription Price
39
+            $price = $cart_item['data']->subscription_price;
40
+
41
+            // Is there a sign up fee?
42
+            $sign_up_fee = isset( $subscription_prices['sign_up_fee'] ) ? $subscription_prices['sign_up_fee'] : '';
43
+
44
+            // Checks if the cart item is a supported bundle type child.
45
+            $container_key = WCS_ATT_Integrations::has_bundle_type_container( $cart_item );
46
+
47
+            // If the cart item is a child item then reset the sign-up fee.
48
+            if ( false !== $container_key ) { $sign_up_fee = ''; }
49
+
50
+            // Put both the subscription price and the sign-up fee together.
51
+            $new_price = round( $price + $sign_up_fee, wc_get_price_decimals() );
52
+
53
+            if ( $sign_up_fee > 0 ) {
54
+                $cart_item['data']->initial_amount = $new_price;
55
+                $cart_item['data']->subscription_sign_up_fee = $sign_up_fee;
56
+            }
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'] : '';
60
+
61
+            // If a trial length is more than zero then set the conditions for the cart.
62
+            if ( $trial_length > 0 ) {
63
+                $cart_item['data']->subscription_trial_length = $trial_length;
64
+                $cart_item['data']->subscription_trial_period = $trial_period;
65
+            } else {
66
+                $cart_item['data']->subscription_trial_length = 0;
67
+                $cart_item['data']->subscription_trial_period = '';
68
+            }
69
+
70
+        }
71
+
72
+        return $cart_item;
73
+    } // END update_cart_item_sub_data()
74 74
 
75 75
 }
76 76
 
Please login to merge, or discard this 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.