@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | 11 | |
12 | 12 | /** |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class EE_Messages_Html_Receipt_Validator extends EE_Messages_Validator { |
26 | 26 | |
27 | - public function __construct( $fields, $context ) { |
|
27 | + public function __construct($fields, $context) { |
|
28 | 28 | $this->_m_name = 'html'; |
29 | 29 | $this->_mt_name = 'receipt'; |
30 | 30 | |
31 | - parent::__construct( $fields, $context ); |
|
31 | + parent::__construct($fields, $context); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | * allows gateways to be used by different systems other than Event Espresso |
7 | 7 | */ |
8 | -interface EEI_Payment extends EEI_Base{ |
|
8 | +interface EEI_Payment extends EEI_Base { |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * @return string indicating which the payment is approved, pending, cancelled or failed |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * Interface EEI_Payment_Method |
154 | 154 | */ |
155 | -interface EEI_Payment_Method{ |
|
155 | +interface EEI_Payment_Method { |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $model_name |
172 | 172 | * @return EE_Log |
173 | 173 | */ |
174 | - function gateway_log($message,$id,$model_name); |
|
174 | + function gateway_log($message, $id, $model_name); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 |
@@ -214,7 +214,7 @@ |
||
214 | 214 | if($payment instanceof EEI_Payment){ |
215 | 215 | $type='Payment'; |
216 | 216 | $id = $payment->ID(); |
217 | - }else{ |
|
217 | + } else{ |
|
218 | 218 | $type = 'Payment_Method'; |
219 | 219 | $id = $this->_ID; |
220 | 220 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @subpackage core/libraries/payment_methods |
16 | 16 | * @author Mike Nelson |
17 | 17 | */ |
18 | -abstract class EE_Gateway{ |
|
18 | +abstract class EE_Gateway { |
|
19 | 19 | /** |
20 | 20 | * a constant used as a possible value for $_currencies_supported to indicate |
21 | 21 | * that ALL currencies are supported by this gateway |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @return EE_Gateway |
95 | 95 | */ |
96 | - public function __construct(){ |
|
96 | + public function __construct() { |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * beginning again) |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function __sleep(){ |
|
108 | + public function __sleep() { |
|
109 | 109 | $properties = get_object_vars($this); |
110 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
110 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
111 | 111 | return array_keys($properties); |
112 | 112 | } |
113 | 113 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * see $_supports_sending_refunds |
116 | 116 | * @return boolean |
117 | 117 | */ |
118 | - public function supports_sending_refunds(){ |
|
118 | + public function supports_sending_refunds() { |
|
119 | 119 | return $this->_supports_sending_refunds; |
120 | 120 | } |
121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * see $_supports_receiving_refunds |
124 | 124 | * @return boolean |
125 | 125 | */ |
126 | - public function supports_receiving_refunds(){ |
|
126 | + public function supports_receiving_refunds() { |
|
127 | 127 | return $this->_supports_receiving_refunds; |
128 | 128 | } |
129 | 129 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return EE_Payment for the refund |
139 | 139 | * @throws EE_Error |
140 | 140 | */ |
141 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
141 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
142 | 142 | return NULL; |
143 | 143 | } |
144 | 144 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * etc |
150 | 150 | * @param array $settings_array |
151 | 151 | */ |
152 | - public function set_settings($settings_array){ |
|
153 | - foreach($settings_array as $name => $value){ |
|
152 | + public function set_settings($settings_array) { |
|
153 | + foreach ($settings_array as $name => $value) { |
|
154 | 154 | $property_name = "_".$name; |
155 | 155 | $this->{$property_name} = $value; |
156 | 156 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * See this class description |
160 | 160 | * @param EEMI_Payment $payment_model |
161 | 161 | */ |
162 | - public function set_payment_model($payment_model){ |
|
162 | + public function set_payment_model($payment_model) { |
|
163 | 163 | $this->_pay_model = $payment_model; |
164 | 164 | } |
165 | 165 | /** |
166 | 166 | * See this class description |
167 | 167 | * @param EEMI_Payment_Log $payment_log_model |
168 | 168 | */ |
169 | - public function set_payment_log($payment_log_model){ |
|
169 | + public function set_payment_log($payment_log_model) { |
|
170 | 170 | $this->_pay_log = $payment_log_model; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEHI_Template $template_helper |
176 | 176 | */ |
177 | - public function set_template_helper($template_helper){ |
|
177 | + public function set_template_helper($template_helper) { |
|
178 | 178 | $this->_template = $template_helper; |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * See this class description |
183 | 183 | * @param EEHI_Line_Item $line_item_helper |
184 | 184 | */ |
185 | - public function set_line_item_helper( $line_item_helper ){ |
|
185 | + public function set_line_item_helper($line_item_helper) { |
|
186 | 186 | $this->_line_item = $line_item_helper; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Money $money_helper |
192 | 192 | */ |
193 | - public function set_money_helper( $money_helper ){ |
|
193 | + public function set_money_helper($money_helper) { |
|
194 | 194 | $this->_money = $money_helper; |
195 | 195 | } |
196 | 196 | |
@@ -199,23 +199,23 @@ discard block |
||
199 | 199 | * @param $message |
200 | 200 | * @param $payment |
201 | 201 | */ |
202 | - public function log($message,$payment){ |
|
203 | - if($payment instanceof EEI_Payment){ |
|
204 | - $type='Payment'; |
|
202 | + public function log($message, $payment) { |
|
203 | + if ($payment instanceof EEI_Payment) { |
|
204 | + $type = 'Payment'; |
|
205 | 205 | $id = $payment->ID(); |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | $type = 'Payment_Method'; |
208 | 208 | $id = $this->_ID; |
209 | 209 | } |
210 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
210 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
211 | 211 | } |
212 | 212 | /** |
213 | 213 | * Formats the amount so it can generally be sent to gateways |
214 | 214 | * @param float $amount |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function format_currency($amount){ |
|
218 | - return number_format( $amount, 2, '.', '' ); |
|
217 | + public function format_currency($amount) { |
|
218 | + return number_format($amount, 2, '.', ''); |
|
219 | 219 | // return $this->_template->format_currency($amount, true); |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
225 | 225 | * @return mixed array or string |
226 | 226 | */ |
227 | - public function currencies_supported(){ |
|
227 | + public function currencies_supported() { |
|
228 | 228 | return $this->_currencies_supported; |
229 | 229 | } |
230 | 230 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * @param EE_Transaction $transaction |
237 | 237 | * @return float |
238 | 238 | */ |
239 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
239 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
240 | 240 | $total_line_item = $transaction->total_line_item(); |
241 | 241 | $total = 0; |
242 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
243 | - $total += max( $item_line_item->total(), 0 ); |
|
242 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
243 | + $total += max($item_line_item->total(), 0); |
|
244 | 244 | } |
245 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
246 | - $total += max( $tax_line_item->total(), 0 ); |
|
245 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
246 | + $total += max($tax_line_item->total(), 0); |
|
247 | 247 | } |
248 | 248 | return $total; |
249 | 249 | } |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | * @param EEI_Payment $payment |
255 | 255 | * @return boolean |
256 | 256 | */ |
257 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
257 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
258 | 258 | return $this->_money->compare_floats( |
259 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
259 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
260 | 260 | $payment->transaction()->total() ) && |
261 | 261 | $this->_money->compare_floats( |
262 | 262 | $payment->amount(), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param EE_Payment $payment |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - public function update_txn_based_on_payment( $payment ){ |
|
277 | + public function update_txn_based_on_payment($payment) { |
|
278 | 278 | //maybe update the transaction or line items or registrations |
279 | 279 | //but most gateways don't need to do this, because they only update the payment |
280 | 280 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * ------------------------------------------------------------------------ |
26 | 26 | */ |
27 | -abstract class EE_Onsite_Gateway extends EE_Gateway{ |
|
27 | +abstract class EE_Onsite_Gateway extends EE_Gateway { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @return EE_Onsite_Gateway |
@@ -53,5 +53,5 @@ discard block |
||
53 | 53 | * } unless a child class specifies these array keys are NOT present |
54 | 54 | * @return EE_Payment updated |
55 | 55 | */ |
56 | - public abstract function do_direct_payment($payment,$billing_info = null); |
|
56 | + public abstract function do_direct_payment($payment, $billing_info = null); |
|
57 | 57 | } |
@@ -2,10 +2,10 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * payment_details_content |
|
6 | - * @var EE_Payment $payment |
|
7 | - * @var EE_Payment_Method $payment_method |
|
8 | - */ |
|
5 | + * payment_details_content |
|
6 | + * @var EE_Payment $payment |
|
7 | + * @var EE_Payment_Method $payment_method |
|
8 | + */ |
|
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | 10 | if ( ! empty( $gateway_response )) { |
11 | 11 | echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * payment_details_content |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @var EE_Payment_Method $payment_method |
8 | 8 | */ |
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | -if ( ! empty( $gateway_response )) { |
|
11 | - echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
10 | +if ( ! empty($gateway_response)) { |
|
11 | + echo '<span class="error payment-problem">'.$gateway_response.'</span>'; |
|
12 | 12 | } |
13 | 13 | // End of file payment_details_content.template.php |
14 | 14 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | +} |
|
4 | 5 | /** |
5 | 6 | * payment_details_content |
6 | 7 | * @var EE_Payment $payment |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $setup_args an array of key value pairs of info for registering the component |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - public static function register( $ID = NULL, $setup_args = array() ); |
|
37 | + public static function register($ID = NULL, $setup_args = array()); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
@@ -45,5 +45,5 @@ discard block |
||
45 | 45 | * @param string $ID a unique name or ID for the component being registered |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public static function deregister( $ID = NULL ); |
|
48 | + public static function deregister($ID = NULL); |
|
49 | 49 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * This interface is used to define the common methods shared by all "plugin api" classes. |
@@ -275,7 +275,7 @@ |
||
275 | 275 | //we know it was just activated and the request will end soon |
276 | 276 | } |
277 | 277 | return; |
278 | - }else{ |
|
278 | + } else{ |
|
279 | 279 | // make sure this was called in the right place! |
280 | 280 | if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
281 | 281 | EE_Error::doing_it_wrong( |
@@ -138,10 +138,10 @@ |
||
138 | 138 | * An array of message types with the key as the message type name and the values as below: |
139 | 139 | * @type string $mtfilename The filename of the message type being registered. This will be the main |
140 | 140 | * EE_{Messagetype_Name}_message_type class. (eg. EE_Declined_Registration_message_type.class.php). Required. |
141 | - * @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required. |
|
142 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
143 | - * type should activate with. Each value in the array should match the name property of a EE_messenger. Optional. |
|
144 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
141 | + * @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required. |
|
142 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
143 | + * type should activate with. Each value in the array should match the name property of a EE_messenger. Optional. |
|
144 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
145 | 145 | * type should validate with. Each value in the array should match the name property of an EE_messenger. Optional. |
146 | 146 | * } |
147 | 147 | * @type array $custom_post_types |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param string $min_core_version |
67 | 67 | * @return string always like '4.3.0.rc.000' |
68 | 68 | */ |
69 | - protected static function _effective_version( $min_core_version ) { |
|
69 | + protected static function _effective_version($min_core_version) { |
|
70 | 70 | // versions: 4 . 3 . 1 . p . 123 |
71 | 71 | // offsets: 0 . 1 . 2 . 3 . 4 |
72 | - $version_parts = explode( '.', $min_core_version ); |
|
72 | + $version_parts = explode('.', $min_core_version); |
|
73 | 73 | //check they specified the micro version (after 2nd period) |
74 | - if( ! isset( $version_parts[ 2 ] ) ) { |
|
75 | - $version_parts[ 2] = '0'; |
|
74 | + if ( ! isset($version_parts[2])) { |
|
75 | + $version_parts[2] = '0'; |
|
76 | 76 | } |
77 | 77 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
78 | 78 | //soon we can assume that's 'rc', but this current version is 'alpha' |
79 | - if( ! isset( $version_parts[ 3 ] ) ) { |
|
80 | - $version_parts[ 3 ] = 'dev'; |
|
79 | + if ( ! isset($version_parts[3])) { |
|
80 | + $version_parts[3] = 'dev'; |
|
81 | 81 | } |
82 | - if( ! isset( $version_parts[ 4 ] ) ) { |
|
83 | - $version_parts[ 4 ] = '000'; |
|
82 | + if ( ! isset($version_parts[4])) { |
|
83 | + $version_parts[4] = '000'; |
|
84 | 84 | } |
85 | - return implode( '.', $version_parts ); |
|
85 | + return implode('.', $version_parts); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $actual_core_version the actual core version, optional |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public static function _meets_min_core_version_requirement( $min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION ) { |
|
96 | - return version_compare( self::_effective_version( $actual_core_version ), self::_effective_version( $min_core_version ), '>=' ); |
|
95 | + public static function _meets_min_core_version_requirement($min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION) { |
|
96 | + return version_compare(self::_effective_version($actual_core_version), self::_effective_version($min_core_version), '>='); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -155,112 +155,112 @@ discard block |
||
155 | 155 | * @throws EE_Error |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public static function register( $addon_name = '', $setup_args = array() ) { |
|
158 | + public static function register($addon_name = '', $setup_args = array()) { |
|
159 | 159 | // required fields MUST be present, so let's make sure they are. |
160 | - if ( empty( $addon_name ) || ! is_array( $setup_args )) { |
|
161 | - throw new EE_Error( __( 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso' )); |
|
160 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
161 | + throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso')); |
|
162 | 162 | } |
163 | - if ( ! isset($setup_args[ 'main_file_path' ]) || empty( $setup_args[ 'main_file_path' ] ) ){ |
|
164 | - throw new EE_Error( sprintf( __( 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso' ), implode(",", array_keys( $setup_args ) ) ) ); |
|
163 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
164 | + throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args)))); |
|
165 | 165 | } |
166 | 166 | // check that addon has not already been registered with that name |
167 | - if ( isset( self::$_settings[ $addon_name ] ) && ! did_action( 'activate_plugin' ) ) { |
|
168 | - throw new EE_Error( sprintf( __( 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso' ), $addon_name )); |
|
167 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
168 | + throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | // no class name for addon? |
173 | - if ( empty( $setup_args['class_name'] )) { |
|
173 | + if (empty($setup_args['class_name'])) { |
|
174 | 174 | // generate one by first separating name with spaces |
175 | - $class_name = str_replace( array( '-', '_' ), ' ', trim( $addon_name )); |
|
175 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
176 | 176 | //capitalize, then replace spaces with underscores |
177 | - $class_name = str_replace( ' ', '_', ucwords( $class_name )); |
|
177 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
178 | 178 | } else { |
179 | 179 | $class_name = $setup_args['class_name']; |
180 | 180 | } |
181 | - $class_name = strpos( $class_name, 'EE_' ) === 0 ? $class_name : 'EE_' . $class_name; |
|
181 | + $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
182 | 182 | //setup $_settings array from incoming values. |
183 | 183 | $addon_settings = array( |
184 | 184 | // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
185 | 185 | 'class_name' => $class_name, |
186 | 186 | // the addon slug for use in URLs, etc |
187 | - 'plugin_slug' => isset( $setup_args['plugin_slug'] ) ? (string)$setup_args['plugin_slug'] : '', |
|
187 | + 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', |
|
188 | 188 | // page slug to be used when generating the "Settings" link on the WP plugin page |
189 | - 'plugin_action_slug' => isset( $setup_args[ 'plugin_action_slug' ] ) ? (string)$setup_args[ 'plugin_action_slug' ] : '', |
|
189 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', |
|
190 | 190 | // the "software" version for the addon |
191 | - 'version' => isset( $setup_args['version'] ) ? (string)$setup_args['version'] : '', |
|
191 | + 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', |
|
192 | 192 | // the minimum version of EE Core that the addon will work with |
193 | - 'min_core_version' => isset( $setup_args['min_core_version'] ) ? (string)$setup_args['min_core_version'] : '', |
|
193 | + 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', |
|
194 | 194 | // the minimum version of WordPress that the addon will work with |
195 | - 'min_wp_version' => isset( $setup_args['min_wp_version'] ) ? (string)$setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
195 | + 'min_wp_version' => isset($setup_args['min_wp_version']) ? (string) $setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
196 | 196 | // full server path to main file (file loaded directly by WP) |
197 | - 'main_file_path' => isset( $setup_args['main_file_path'] ) ? (string)$setup_args['main_file_path'] : '', |
|
197 | + 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', |
|
198 | 198 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
199 | - 'admin_path' => isset( $setup_args['admin_path'] ) ? (string)$setup_args['admin_path'] : '', |
|
199 | + 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', |
|
200 | 200 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
201 | - 'admin_callback' => isset( $setup_args['admin_callback'] ) ? (string)$setup_args['admin_callback'] : '', |
|
201 | + 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', |
|
202 | 202 | // the section name for this addon's configuration settings section (defaults to "addons") |
203 | - 'config_section' => isset( $setup_args['config_section'] ) ? (string)$setup_args['config_section'] : 'addons', |
|
203 | + 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', |
|
204 | 204 | // the class name for this addon's configuration settings object |
205 | - 'config_class' => isset( $setup_args['config_class'] ) ? (string)$setup_args['config_class'] : '', |
|
205 | + 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', |
|
206 | 206 | //the name given to the config for this addons' configuration settings object (optional) |
207 | - 'config_name' => isset( $setup_args['config_name'] ) ? (string) $setup_args['config_name']: '', |
|
207 | + 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', |
|
208 | 208 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
209 | - 'autoloader_paths' => isset( $setup_args['autoloader_paths'] ) ? (array)$setup_args['autoloader_paths'] : array(), |
|
209 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), |
|
210 | 210 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
211 | - 'autoloader_folders' => isset( $setup_args['autoloader_folders'] ) ? (array)$setup_args['autoloader_folders'] : array(), |
|
211 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), |
|
212 | 212 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
213 | - 'dms_paths' => isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array(), |
|
213 | + 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), |
|
214 | 214 | // array of full server paths to any EED_Modules used by the addon |
215 | - 'module_paths' => isset( $setup_args['module_paths'] ) ? (array)$setup_args['module_paths'] : array(), |
|
215 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
216 | 216 | // array of full server paths to any EES_Shortcodes used by the addon |
217 | - 'shortcode_paths' => isset( $setup_args['shortcode_paths'] ) ? (array)$setup_args['shortcode_paths'] : array(), |
|
217 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), |
|
218 | 218 | // array of full server paths to any WP_Widgets used by the addon |
219 | - 'widget_paths' => isset( $setup_args['widget_paths'] ) ? (array)$setup_args['widget_paths'] : array(), |
|
219 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
220 | 220 | // array of PUE options used by the addon |
221 | - 'pue_options' => isset( $setup_args['pue_options'] ) ? (array)$setup_args['pue_options'] : array(), |
|
222 | - 'message_types' => isset( $setup_args['message_types'] ) ? (array) $setup_args['message_types'] : array(), |
|
223 | - 'capabilities' => isset( $setup_args['capabilities'] ) ? (array) $setup_args['capabilities'] : array(), |
|
224 | - 'capability_maps' => isset( $setup_args['capability_maps'] ) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | - 'model_paths' => isset( $setup_args['model_paths'] ) ? (array) $setup_args['model_paths'] : array(), |
|
226 | - 'class_paths' => isset( $setup_args['class_paths'] ) ? (array) $setup_args['class_paths'] : array(), |
|
227 | - 'model_extension_paths' => isset( $setup_args['model_extension_paths'] ) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | - 'class_extension_paths' => isset( $setup_args['class_extension_paths'] ) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | - 'custom_post_types' => isset( $setup_args['custom_post_types'] ) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | - 'custom_taxonomies' => isset( $setup_args['custom_taxonomies'] ) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | - 'payment_method_paths' => isset( $setup_args[ 'payment_method_paths' ] ) ? (array) $setup_args[ 'payment_method_paths' ] : array(), |
|
232 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array(), |
|
221 | + 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), |
|
222 | + 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), |
|
223 | + 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), |
|
224 | + 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | + 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), |
|
226 | + 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), |
|
227 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | + 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), |
|
232 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), |
|
233 | 233 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page that can be used for adding upgrading/marketing info |
234 | - 'plugins_page_row' => isset( $setup_args['plugins_page_row'] ) ? $setup_args['plugins_page_row'] : '', |
|
234 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '', |
|
235 | 235 | ); |
236 | 236 | |
237 | 237 | // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page |
238 | - $addon_settings[ 'plugin_action_slug' ] = empty( $addon_settings[ 'plugin_action_slug' ] ) && ! empty( $addon_settings[ 'admin_path' ] ) ? $addon_settings[ 'plugin_slug' ] : $addon_settings[ 'plugin_action_slug' ]; |
|
238 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && ! empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug']; |
|
239 | 239 | // full server path to main file (file loaded directly by WP) |
240 | - $addon_settings['plugin_basename'] = plugin_basename( $addon_settings[ 'main_file_path' ] ); |
|
240 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
241 | 241 | |
242 | 242 | global $wp_version; |
243 | 243 | //check whether this addon version is compatible with EE core |
244 | - if ( isset( EE_Register_Addon::$_incompatible_addons[ $addon_name ] ) && |
|
245 | - ! self::_meets_min_core_version_requirement( EE_Register_Addon::$_incompatible_addons[ $addon_name ], $addon_settings[ 'version' ] ) ) { |
|
244 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && |
|
245 | + ! self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) { |
|
246 | 246 | $incompatibility_message = sprintf( |
247 | - __( 'The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso' ), |
|
247 | + __('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), |
|
248 | 248 | $addon_name, |
249 | 249 | '<br />', |
250 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ] |
|
250 | + EE_Register_Addon::$_incompatible_addons[$addon_name] |
|
251 | 251 | ); |
252 | - } else if ( ! self::_meets_min_core_version_requirement( $addon_settings[ 'min_core_version' ], espresso_version() ) ) { |
|
252 | + } else if ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())) { |
|
253 | 253 | $incompatibility_message = sprintf( |
254 | 254 | __( |
255 | 255 | 'The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', |
256 | 256 | 'event_espresso' |
257 | 257 | ), |
258 | 258 | $addon_name, |
259 | - self::_effective_version( $addon_settings[ 'min_core_version' ] ), |
|
260 | - self::_effective_version( espresso_version() ), |
|
259 | + self::_effective_version($addon_settings['min_core_version']), |
|
260 | + self::_effective_version(espresso_version()), |
|
261 | 261 | '<br />' |
262 | 262 | ); |
263 | - } else if (version_compare( $wp_version, $addon_settings['min_wp_version'], '<' )) { |
|
263 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
264 | 264 | $incompatibility_message = sprintf( |
265 | 265 | __( |
266 | 266 | 'The Event Espresso "%1$s" addon could not be activated because it requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
@@ -269,137 +269,137 @@ discard block |
||
269 | 269 | $addon_name, |
270 | 270 | $addon_settings['min_wp_version'], |
271 | 271 | '<br />' |
272 | - );; |
|
272 | + ); ; |
|
273 | 273 | } else { |
274 | 274 | $incompatibility_message = ''; |
275 | 275 | } |
276 | - if ( ! empty( $incompatibility_message ) ) { |
|
276 | + if ( ! empty($incompatibility_message)) { |
|
277 | 277 | //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the |
278 | 278 | //plugin activated fine when it didn't |
279 | - if( isset( $_GET[ 'activate' ]) ) { |
|
280 | - unset( $_GET[ 'activate' ] ); |
|
279 | + if (isset($_GET['activate'])) { |
|
280 | + unset($_GET['activate']); |
|
281 | 281 | } |
282 | - if( isset( $_REQUEST[ 'activate' ] ) ){ |
|
283 | - unset( $_REQUEST[ 'activate' ] ); |
|
282 | + if (isset($_REQUEST['activate'])) { |
|
283 | + unset($_REQUEST['activate']); |
|
284 | 284 | } |
285 | 285 | //and show an error message indicating the plugin didn't activate properly |
286 | - EE_Error::add_error( $incompatibility_message, __FILE__, __FUNCTION__, __LINE__ ); |
|
287 | - if ( current_user_can( 'activate_plugins' )) { |
|
288 | - require_once( ABSPATH.'wp-admin/includes/plugin.php' ); |
|
289 | - deactivate_plugins( plugin_basename( $addon_settings[ 'main_file_path' ] ), TRUE ); |
|
286 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
287 | + if (current_user_can('activate_plugins')) { |
|
288 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
289 | + deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE); |
|
290 | 290 | } |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | //this is an activation request |
294 | - if( did_action( 'activate_plugin' ) ){ |
|
294 | + if (did_action('activate_plugin')) { |
|
295 | 295 | //to find if THIS is the addon that was activated, |
296 | 296 | //just check if we have already registered it or not |
297 | 297 | //(as the newly-activated addon wasn't around the first time addons were registered) |
298 | - if( ! isset( self::$_settings[ $addon_name ] ) ){ |
|
299 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
298 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
299 | + self::$_settings[$addon_name] = $addon_settings; |
|
300 | 300 | $addon = self::_load_and_init_addon_class($addon_name); |
301 | 301 | $addon->set_activation_indicator_option(); |
302 | 302 | //dont bother setting up the rest of the addon. |
303 | 303 | //we know it was just activated and the request will end soon |
304 | 304 | } |
305 | 305 | return; |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | // make sure this was called in the right place! |
308 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
|
308 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
309 | 309 | EE_Error::doing_it_wrong( |
310 | 310 | __METHOD__, |
311 | 311 | sprintf( |
312 | - __( 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.','event_espresso'), |
|
312 | + __('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), |
|
313 | 313 | $addon_name |
314 | 314 | ), |
315 | 315 | '4.3.0' |
316 | 316 | ); |
317 | 317 | } |
318 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
318 | + self::$_settings[$addon_name] = $addon_settings; |
|
319 | 319 | } |
320 | 320 | // we need cars |
321 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_paths'] )) { |
|
321 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
322 | 322 | // setup autoloader for single file |
323 | - EEH_Autoloader::instance()->register_autoloader( self::$_settings[ $addon_name ]['autoloader_paths'] ); |
|
323 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
324 | 324 | } |
325 | 325 | // setup autoloaders for folders |
326 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_folders'] )) { |
|
327 | - foreach ( self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder ) { |
|
328 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $autoloader_folder ); |
|
326 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
327 | + foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
328 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | // register new models |
332 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
333 | - EE_Register_Model::register( $addon_name, array( 'model_paths' => self::$_settings[ $addon_name ]['model_paths'] , 'class_paths' => self::$_settings[ $addon_name ]['class_paths'])); |
|
332 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
333 | + EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths'])); |
|
334 | 334 | } |
335 | 335 | // register model extensions |
336 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
337 | - EE_Register_Model_Extensions::register( $addon_name, array( 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'] , 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'])); |
|
336 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
337 | + EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'])); |
|
338 | 338 | } |
339 | 339 | // setup DMS |
340 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
341 | - EE_Register_Data_Migration_Scripts::register( $addon_name, array( 'dms_paths' => self::$_settings[ $addon_name ]['dms_paths'] )); |
|
340 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
341 | + EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])); |
|
342 | 342 | } |
343 | 343 | // if config_class is present let's register config. |
344 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
344 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
345 | 345 | EE_Register_Config::register( |
346 | - self::$_settings[ $addon_name ]['config_class'], |
|
346 | + self::$_settings[$addon_name]['config_class'], |
|
347 | 347 | array( |
348 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
349 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'] |
|
348 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
349 | + 'config_name' => self::$_settings[$addon_name]['config_name'] |
|
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | } |
353 | 353 | // register admin page |
354 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
355 | - EE_Register_Admin_Page::register( $addon_name, array( 'page_path' => self::$_settings[ $addon_name ]['admin_path'] )); |
|
354 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
355 | + EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path'])); |
|
356 | 356 | |
357 | 357 | } |
358 | 358 | // add to list of modules to be registered |
359 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
360 | - EE_Register_Module::register( $addon_name, array( 'module_paths' => self::$_settings[ $addon_name ]['module_paths'] )); |
|
359 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
360 | + EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths'])); |
|
361 | 361 | } |
362 | 362 | // add to list of shortcodes to be registered |
363 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
364 | - EE_Register_Shortcode::register( $addon_name, array( 'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] )); |
|
363 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
364 | + EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])); |
|
365 | 365 | } |
366 | 366 | // add to list of widgets to be registered |
367 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
368 | - EE_Register_Widget::register( $addon_name, array( 'widget_paths' => self::$_settings[ $addon_name ]['widget_paths'] )); |
|
367 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
368 | + EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | //register capability related stuff. |
372 | - if ( ! empty( self::$_settings[ $addon_name ]['capabilities'] ) ) { |
|
373 | - EE_Register_Capabilities::register( $addon_name , array( 'capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'] ) ); |
|
372 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
373 | + EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'])); |
|
374 | 374 | } |
375 | 375 | //any message type to register? |
376 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
377 | - add_action( 'EE_Brewing_Regular___messages_caf', array( 'EE_Register_Addon', 'register_message_types' ) ); |
|
376 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
377 | + add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types')); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // if plugin update engine is being used for auto-updates (not needed if PUE is not being used) |
381 | - if ( ! empty( $setup_args['pue_options'] )) { |
|
382 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
383 | - 'pue_plugin_slug' => isset( $setup_args['pue_options']['pue_plugin_slug'] ) ? (string)$setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower( $class_name ), |
|
384 | - 'plugin_basename' => isset( $setup_args['pue_options']['plugin_basename'] ) ? (string)$setup_args['pue_options']['plugin_basename'] : plugin_basename( self::$_settings[ $addon_name ]['main_file_path'] ), |
|
385 | - 'checkPeriod' => isset( $setup_args['pue_options']['checkPeriod'] ) ? (string)$setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | - 'use_wp_update' => isset( $setup_args['pue_options']['use_wp_update'] ) ? (string)$setup_args['pue_options']['use_wp_update'] : FALSE |
|
381 | + if ( ! empty($setup_args['pue_options'])) { |
|
382 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
383 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_'.strtolower($class_name), |
|
384 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), |
|
385 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE |
|
387 | 387 | ); |
388 | - add_action( 'AHEE__EE_System__brew_espresso__after_pue_init', array( 'EE_Register_Addon', 'load_pue_update' )); |
|
388 | + add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update')); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | //any custom post type/ custom capabilities or default terms to register |
392 | - if ( !empty( self::$_settings[$addon_name]['custom_post_types'] ) || !empty( self::$_settings[$addon_name]['custom_taxonomies'] ) ) { |
|
393 | - EE_Register_CPT::register( $addon_name, array( 'cpts' => self::$_settings[$addon_name]['custom_post_types'] , 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'] ) ); |
|
392 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])) { |
|
393 | + EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'])); |
|
394 | 394 | } |
395 | - if( ! empty( self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ){ |
|
396 | - EE_Register_Payment_Method::register($addon_name, array( 'payment_method_paths' => self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ); |
|
395 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
396 | + EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])); |
|
397 | 397 | } |
398 | 398 | // load and instantiate main addon class |
399 | 399 | $addon = self::_load_and_init_addon_class($addon_name); |
400 | 400 | // call any additional admin_callback functions during load_admin_controller hook |
401 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_callback'] )) { |
|
402 | - add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $addon, self::$_settings[ $addon_name ]['admin_callback'] )); |
|
401 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
402 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback'])); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | * @param string $addon_name |
411 | 411 | * @return EE_Addon |
412 | 412 | */ |
413 | - private static function _load_and_init_addon_class($addon_name){ |
|
414 | - $addon = EE_Registry::instance()->load_addon( dirname( self::$_settings[ $addon_name ]['main_file_path'] ), self::$_settings[ $addon_name ]['class_name'] ); |
|
415 | - $addon->set_name( $addon_name ); |
|
416 | - $addon->set_plugin_slug( self::$_settings[ $addon_name ][ 'plugin_slug' ] ); |
|
417 | - $addon->set_plugin_basename( self::$_settings[ $addon_name ][ 'plugin_basename' ] ); |
|
418 | - $addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] ); |
|
419 | - $addon->set_plugin_action_slug( self::$_settings[ $addon_name ][ 'plugin_action_slug' ] ); |
|
420 | - $addon->set_plugins_page_row( self::$_settings[ $addon_name ][ 'plugins_page_row' ] ); |
|
421 | - $addon->set_version( self::$_settings[ $addon_name ]['version'] ); |
|
422 | - $addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) ); |
|
423 | - $addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] ); |
|
424 | - $addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] ); |
|
425 | - $addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] ); |
|
413 | + private static function _load_and_init_addon_class($addon_name) { |
|
414 | + $addon = EE_Registry::instance()->load_addon(dirname(self::$_settings[$addon_name]['main_file_path']), self::$_settings[$addon_name]['class_name']); |
|
415 | + $addon->set_name($addon_name); |
|
416 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
417 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
418 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
419 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
420 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
421 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
422 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
423 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
424 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
425 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
426 | 426 | //unfortunately this can't be hooked in upon construction, because we don't have |
427 | 427 | //the plugin mainfile's path upon construction. |
428 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon,'deactivation')); |
|
428 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
429 | 429 | return $addon; |
430 | 430 | } |
431 | 431 | |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public static function load_pue_update() { |
440 | 440 | // load PUE client |
441 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
441 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
442 | 442 | // cycle thru settings |
443 | - foreach ( self::$_settings as $settings ) { |
|
444 | - if ( ! empty( $settings['pue_options'] )) { |
|
443 | + foreach (self::$_settings as $settings) { |
|
444 | + if ( ! empty($settings['pue_options'])) { |
|
445 | 445 | // initiate the class and start the plugin update engine! |
446 | 446 | new PluginUpdateEngineChecker( |
447 | 447 | // host file URL |
448 | 448 | 'https://eventespresso.com', |
449 | 449 | // plugin slug(s) |
450 | 450 | array( |
451 | - 'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ), |
|
452 | - 'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' ) |
|
451 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
452 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr') |
|
453 | 453 | ), |
454 | 454 | // options |
455 | 455 | array( |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @return void |
478 | 478 | */ |
479 | 479 | public static function register_message_types() { |
480 | - foreach ( self::$_settings as $settings ) { |
|
481 | - foreach( $settings['message_types'] as $message_type => $message_type_settings ) { |
|
482 | - EE_Register_Message_Type::register( $message_type, $message_type_settings ); |
|
480 | + foreach (self::$_settings as $settings) { |
|
481 | + foreach ($settings['message_types'] as $message_type => $message_type_settings) { |
|
482 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
@@ -495,60 +495,60 @@ discard block |
||
495 | 495 | * @throws EE_Error |
496 | 496 | * @return void |
497 | 497 | */ |
498 | - public static function deregister( $addon_name = NULL ) { |
|
499 | - if ( isset( self::$_settings[ $addon_name ] )) { |
|
500 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
501 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
498 | + public static function deregister($addon_name = NULL) { |
|
499 | + if (isset(self::$_settings[$addon_name])) { |
|
500 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
501 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
502 | 502 | // setup DMS |
503 | - EE_Register_Data_Migration_Scripts::deregister( $addon_name ); |
|
503 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
504 | 504 | } |
505 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
505 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
506 | 506 | // register admin page |
507 | - EE_Register_Admin_Page::deregister( $addon_name ); |
|
507 | + EE_Register_Admin_Page::deregister($addon_name); |
|
508 | 508 | } |
509 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
509 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
510 | 510 | // add to list of modules to be registered |
511 | - EE_Register_Module::deregister( $addon_name ); |
|
511 | + EE_Register_Module::deregister($addon_name); |
|
512 | 512 | } |
513 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
513 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
514 | 514 | // add to list of shortcodes to be registered |
515 | - EE_Register_Shortcode::deregister( $addon_name ); |
|
515 | + EE_Register_Shortcode::deregister($addon_name); |
|
516 | 516 | } |
517 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
517 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
518 | 518 | // if config_class present let's register config. |
519 | - EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class']); |
|
519 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
520 | 520 | } |
521 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
521 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
522 | 522 | // add to list of widgets to be registered |
523 | - EE_Register_Widget::deregister( $addon_name ); |
|
523 | + EE_Register_Widget::deregister($addon_name); |
|
524 | 524 | } |
525 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || |
|
526 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
525 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || |
|
526 | + ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
527 | 527 | // add to list of shortcodes to be registered |
528 | - EE_Register_Model::deregister( $addon_name ); |
|
528 | + EE_Register_Model::deregister($addon_name); |
|
529 | 529 | } |
530 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || |
|
531 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
530 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || |
|
531 | + ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
532 | 532 | // add to list of shortcodes to be registered |
533 | - EE_Register_Model_Extensions::deregister( $addon_name ); |
|
533 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
534 | 534 | } |
535 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
536 | - foreach( self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings ) { |
|
537 | - EE_Register_Message_Type::deregister( $message_type ); |
|
535 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
536 | + foreach (self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
537 | + EE_Register_Message_Type::deregister($message_type); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | //deregister capabilities for addon |
541 | - if ( ! empty( self::$_settings[$addon_name]['capabilities'] ) || ! empty( self::$_settings[$addon_name]['capability_maps']) ) { |
|
542 | - EE_Register_Capabilities::deregister( $addon_name ); |
|
541 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) || ! empty(self::$_settings[$addon_name]['capability_maps'])) { |
|
542 | + EE_Register_Capabilities::deregister($addon_name); |
|
543 | 543 | } |
544 | 544 | //deregister custom_post_types for addon |
545 | - if ( ! empty( self::$_settings[$addon_name]['custom_post_types'] ) ) { |
|
546 | - EE_Register_CPT::deregister( $addon_name ); |
|
545 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
546 | + EE_Register_CPT::deregister($addon_name); |
|
547 | 547 | } |
548 | - remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) ); |
|
549 | - remove_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) ); |
|
548 | + remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')); |
|
549 | + remove_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')); |
|
550 | 550 | unset(EE_Registry::instance()->addons->{$class_name}); |
551 | - unset( self::$_settings[ $addon_name ] ); |
|
551 | + unset(self::$_settings[$addon_name]); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 |
@@ -18,30 +18,30 @@ discard block |
||
18 | 18 | class EE_Register_Admin_Page implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Holds registered EE_Admin_Pages |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_admin_page_registry = array(); |
|
21 | + /** |
|
22 | + * Holds registered EE_Admin_Pages |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_admin_page_registry = array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | - * |
|
33 | - * @since 4.3.0 |
|
34 | - * |
|
30 | + /** |
|
31 | + * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | + * |
|
33 | + * @since 4.3.0 |
|
34 | + * |
|
35 | 35 | * @param string $page_basename This string represents the basename of the Admin Page init. |
36 | 36 | * The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php). |
37 | - * @param array $config { An array of configuration options that will be used in different circumstances |
|
37 | + * @param array $config { An array of configuration options that will be used in different circumstances |
|
38 | 38 | * |
39 | 39 | * @type string $page_path This is the path where the registered admin pages reside ( used to setup autoloaders). |
40 | 40 | * |
41 | 41 | * } |
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function register( $page_basename = NULL, $config = array() ) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | 47 | if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
62 | - EE_Error::doing_it_wrong( |
|
62 | + EE_Error::doing_it_wrong( |
|
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | 65 | __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | ), |
68 | 68 | '4.3' |
69 | 69 | ); |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - //add incoming stuff to our registry property |
|
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | - 'page_path' => $config['page_path'], |
|
75 | - 'config' => $config |
|
76 | - ); |
|
72 | + //add incoming stuff to our registry property |
|
73 | + self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | + 'page_path' => $config['page_path'], |
|
75 | + 'config' => $config |
|
76 | + ); |
|
77 | 77 | |
78 | - //add filters |
|
78 | + //add filters |
|
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | - * page being deregistered is loaded. |
|
90 | - * |
|
91 | - * @since 4.3.0 |
|
92 | - * |
|
93 | - * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | - } |
|
87 | + /** |
|
88 | + * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | + * page being deregistered is loaded. |
|
90 | + * |
|
91 | + * @since 4.3.0 |
|
92 | + * |
|
93 | + * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public static function deregister( $page_basename = NULL ) { |
|
97 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | $installed_refs[ $basename ] = $args['page_path']; |
113 | 113 | } |
114 | 114 | } |
115 | - return $installed_refs; |
|
116 | - } |
|
115 | + return $installed_refs; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | 126 | public static function set_page_path( $paths ) { |
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
129 | - } |
|
130 | - return $paths; |
|
131 | - } |
|
127 | + foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | + $paths[ $basename ] = $args['page_path']; |
|
129 | + } |
|
130 | + return $paths; |
|
131 | + } |
|
132 | 132 | } |
@@ -41,28 +41,28 @@ discard block |
||
41 | 41 | * } |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
44 | + public static function register($page_basename = NULL, $config = array()) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | - if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
|
48 | - throw new EE_Error( sprintf( __( 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso' ), $page_basename )); |
|
47 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
48 | + throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // required fields MUST be present, so let's make sure they are. |
52 | - if ( empty( $page_basename ) || ! is_array( $config ) || empty( $config['page_path'] )) { |
|
53 | - throw new EE_Error( __( 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso' )); |
|
52 | + if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) { |
|
53 | + throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we don't register twice |
57 | - if( isset( self::$_ee_admin_page_registry[ $page_basename ] ) ){ |
|
57 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
|
61 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
62 | 62 | EE_Error::doing_it_wrong( |
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | - __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
|
65 | + __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'), |
|
66 | 66 | $page_basename |
67 | 67 | ), |
68 | 68 | '4.3' |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
73 | + self::$_ee_admin_page_registry[$page_basename] = array( |
|
74 | 74 | 'page_path' => $config['page_path'], |
75 | 75 | 'config' => $config |
76 | 76 | ); |
77 | 77 | |
78 | 78 | //add filters |
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param string $page_basename Use whatever string was used to register the admin page. |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
96 | + public static function deregister($page_basename = NULL) { |
|
97 | + if ( ! empty(self::$_ee_admin_page_registry[$page_basename])) |
|
98 | + unset(self::$_ee_admin_page_registry[$page_basename]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param $installed_refs |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - public static function set_page_basename( $installed_refs ) { |
|
110 | - if ( ! empty( self::$_ee_admin_page_registry )) { |
|
111 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
112 | - $installed_refs[ $basename ] = $args['page_path']; |
|
109 | + public static function set_page_basename($installed_refs) { |
|
110 | + if ( ! empty(self::$_ee_admin_page_registry)) { |
|
111 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
112 | + $installed_refs[$basename] = $args['page_path']; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | return $installed_refs; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param $paths |
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | - public static function set_page_path( $paths ) { |
|
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
126 | + public static function set_page_path($paths) { |
|
127 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
128 | + $paths[$basename] = $args['page_path']; |
|
129 | 129 | } |
130 | 130 | return $paths; |
131 | 131 | } |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister an EE Admin Page. |
@@ -94,8 +96,9 @@ discard block |
||
94 | 96 | * @return void |
95 | 97 | */ |
96 | 98 | public static function deregister( $page_basename = NULL ) { |
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) { |
|
100 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
101 | + } |
|
99 | 102 | } |
100 | 103 | |
101 | 104 |
@@ -66,33 +66,33 @@ discard block |
||
66 | 66 | * @throws EE_Error |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - public static function register( $cpt_ref = NULL, $setup_args = array() ) { |
|
69 | + public static function register($cpt_ref = NULL, $setup_args = array()) { |
|
70 | 70 | |
71 | 71 | //check for requred params |
72 | - if ( empty( $cpt_ref ) ) { |
|
72 | + if (empty($cpt_ref)) { |
|
73 | 73 | throw new EE_Error( |
74 | - __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso' ) |
|
74 | + __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso') |
|
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - if ( ! is_array( $setup_args ) || ( empty( $setup_args['cpts'] ) && empty( $setup_args['cts'] ) ) ) { |
|
78 | + if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
79 | 79 | throw new EE_Error( |
80 | - __( 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso' ) |
|
80 | + __('In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso') |
|
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | 84 | //make sure we don't register twice |
85 | - if( isset( self::$_registry[ $cpt_ref ] ) ){ |
|
85 | + if (isset(self::$_registry[$cpt_ref])) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | 89 | //make sure cpt ref is unique. |
90 | - if ( isset( self::$_registry[$cpt_ref] ) ) { |
|
91 | - $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
90 | + if (isset(self::$_registry[$cpt_ref])) { |
|
91 | + $cpt_ref = uniqid().'_'.$cpt_ref; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | //make sure this was called in the right place! |
95 | - if ( did_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ) ) { |
|
95 | + if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) { |
|
96 | 96 | EE_Error::doing_it_wrong( |
97 | 97 | __METHOD__, |
98 | 98 | sprintf( |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | |
106 | 106 | //validate incoming args |
107 | 107 | $validated = array( |
108 | - 'cpts' => isset( $setup_args['cpts'] ) ? (array) $setup_args['cpts'] : array(), |
|
109 | - 'cts' => isset( $setup_args['cts'] ) ? (array) $setup_args['cts'] : array(), |
|
110 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array() |
|
108 | + 'cpts' => isset($setup_args['cpts']) ? (array) $setup_args['cpts'] : array(), |
|
109 | + 'cts' => isset($setup_args['cts']) ? (array) $setup_args['cts'] : array(), |
|
110 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array() |
|
111 | 111 | ); |
112 | 112 | |
113 | 113 | self::$_registry[$cpt_ref] = $validated; |
114 | 114 | |
115 | 115 | //hook into to cpt system |
116 | - add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( __CLASS__, 'filter_cpts' ), 5 ); |
|
117 | - add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( __CLASS__, 'filter_cts' ), 5 ); |
|
118 | - add_action( 'AHEE__EE_Register_CPTs__construct_end', array( __CLASS__, 'default_terms'), 5 ); |
|
116 | + add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(__CLASS__, 'filter_cpts'), 5); |
|
117 | + add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(__CLASS__, 'filter_cts'), 5); |
|
118 | + add_action('AHEE__EE_Register_CPTs__construct_end', array(__CLASS__, 'default_terms'), 5); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array new array of cpts and their registration information |
131 | 131 | */ |
132 | - public static function filter_cpts( $cpts ) { |
|
133 | - foreach( self::$_registry as $registries ) { |
|
134 | - foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) { |
|
132 | + public static function filter_cpts($cpts) { |
|
133 | + foreach (self::$_registry as $registries) { |
|
134 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
135 | 135 | $cpts[$cpt_name] = $cpt_settings; |
136 | 136 | } |
137 | 137 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array new array of cts and their registration information. |
150 | 150 | */ |
151 | - public static function filter_cts( $cts ) { |
|
152 | - foreach( self::$_registry as $registries ) { |
|
153 | - foreach( $registries['cts'] as $ct_name => $ct_settings ) { |
|
151 | + public static function filter_cts($cts) { |
|
152 | + foreach (self::$_registry as $registries) { |
|
153 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
154 | 154 | $cts[$ct_name] = $ct_settings; |
155 | 155 | } |
156 | 156 | } |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return void |
169 | 169 | */ |
170 | - public static function default_terms( EE_Register_CPTs $cpt_class ) { |
|
171 | - foreach( self::$_registry as $registries ) { |
|
172 | - foreach( $registries['default_terms'] as $taxonomy => $terms ) { |
|
173 | - foreach ( $terms as $term => $cpts ) { |
|
174 | - $cpt_class->set_default_term( $taxonomy, $term, $cpts ); |
|
170 | + public static function default_terms(EE_Register_CPTs $cpt_class) { |
|
171 | + foreach (self::$_registry as $registries) { |
|
172 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
173 | + foreach ($terms as $term => $cpts) { |
|
174 | + $cpt_class->set_default_term($taxonomy, $term, $cpts); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public static function deregister( $cpt_ref = null ) { |
|
192 | - if ( !empty( self::$_registry[$cpt_ref] ) ) { |
|
193 | - unset( self::$_registry[$cpt_ref] ); |
|
191 | + public static function deregister($cpt_ref = null) { |
|
192 | + if ( ! empty(self::$_registry[$cpt_ref])) { |
|
193 | + unset(self::$_registry[$cpt_ref]); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } //end class EE_Register_CPT |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, custom post type, custom taxonomy |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new custom post type or custom taxonomy for the EE CPT system. |