@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Array describing conditions necessary to make the input required. |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @param string $validation_error_message |
25 | 25 | * @param array $requirement_conditions |
26 | 26 | */ |
27 | - public function __construct( $validation_error_message = null, $requirement_conditions = array() ) { |
|
28 | - if( ! $validation_error_message ){ |
|
27 | + public function __construct($validation_error_message = null, $requirement_conditions = array()) { |
|
28 | + if ( ! $validation_error_message) { |
|
29 | 29 | $validation_error_message = __("This field is required.", "event_espresso"); |
30 | 30 | } |
31 | - $this->set_requirement_conditions( $requirement_conditions ); |
|
32 | - parent::__construct( $validation_error_message ); |
|
31 | + $this->set_requirement_conditions($requirement_conditions); |
|
32 | + parent::__construct($validation_error_message); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @throws \EE_Validation_Error |
45 | 45 | */ |
46 | 46 | public function validate($normalized_value) { |
47 | - if( |
|
47 | + if ( |
|
48 | 48 | ( |
49 | 49 | $normalized_value === '' |
50 | 50 | || $normalized_value === null |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | ) |
53 | 53 | && $this->_input_is_required_server_side() |
54 | 54 | ) { |
55 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
56 | - }else{ |
|
55 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
56 | + } else { |
|
57 | 57 | return true; |
58 | 58 | } |
59 | 59 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | * @throws \EE_Error |
66 | 66 | */ |
67 | - public function get_jquery_validation_rule_array(){ |
|
67 | + public function get_jquery_validation_rule_array() { |
|
68 | 68 | return array( |
69 | 69 | 'required'=> $this->_get_jquery_requirement_value(), |
70 | 70 | 'messages' => array( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param array $requirement_conditions |
84 | 84 | */ |
85 | - public function set_requirement_conditions( $requirement_conditions ) { |
|
85 | + public function set_requirement_conditions($requirement_conditions) { |
|
86 | 86 | $this->requirement_conditions = (array) $requirement_conditions; |
87 | 87 | } |
88 | 88 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | protected function _get_jquery_requirement_value() { |
109 | 109 | $requirement_value = ''; |
110 | 110 | $conditions = $this->get_requirement_conditions(); |
111 | - if( ! is_array( $conditions ) ){ |
|
111 | + if ( ! is_array($conditions)) { |
|
112 | 112 | EE_Error::throw_exception_if_debugging( |
113 | 113 | sprintf( |
114 | - __( 'Input requirement conditions must be an array. You provided %1$s', 'event_espresso' ), |
|
114 | + __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
|
115 | 115 | $this->_input->name() |
116 | 116 | ), |
117 | 117 | __FILE__, |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | ); |
121 | 121 | return true; |
122 | 122 | } |
123 | - if( count( $conditions ) > 1 ) { |
|
123 | + if (count($conditions) > 1) { |
|
124 | 124 | EE_Error::throw_exception_if_debugging( |
125 | 125 | sprintf( |
126 | - __( 'Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso' ), |
|
126 | + __('Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso'), |
|
127 | 127 | $this->_input->name() |
128 | 128 | ), |
129 | 129 | __FILE__, |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | __LINE__ |
132 | 132 | ); |
133 | 133 | } |
134 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
135 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
136 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
134 | + foreach ($conditions as $input_path => $op_and_value) { |
|
135 | + $input = $this->_input->find_section_from_path($input_path); |
|
136 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
137 | 137 | EE_Error::throw_exception_if_debugging( |
138 | 138 | sprintf( |
139 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
139 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
140 | 140 | $this->_input->name(), |
141 | 141 | $input_path |
142 | 142 | ), |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | ); |
147 | 147 | return false; |
148 | 148 | } |
149 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
149 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
150 | 150 | //ok now the jquery dependency expression depends on the input's display strategy. |
151 | - if( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy ) { |
|
151 | + if ( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
152 | 152 | EE_Error::throw_exception_if_debugging( |
153 | 153 | sprintf( |
154 | - __( 'Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso' ), |
|
154 | + __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
|
155 | 155 | $input->name(), |
156 | - get_class( $input->get_display_strategy() ), |
|
156 | + get_class($input->get_display_strategy()), |
|
157 | 157 | $this->_input->name() |
158 | 158 | ), |
159 | 159 | __FILE__, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | __LINE__ |
162 | 162 | ); |
163 | 163 | } |
164 | - $requirement_value = $input->html_id( true ) . ' option[value="' . $value . '"]:selected'; |
|
164 | + $requirement_value = $input->html_id(true).' option[value="'.$value.'"]:selected'; |
|
165 | 165 | } |
166 | 166 | return $requirement_value; |
167 | 167 | } |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | protected function _input_is_required_server_side() { |
180 | 180 | $meets_all_requirements = true; |
181 | 181 | $conditions = $this->get_requirement_conditions(); |
182 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
183 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
184 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
182 | + foreach ($conditions as $input_path => $op_and_value) { |
|
183 | + $input = $this->_input->find_section_from_path($input_path); |
|
184 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
185 | 185 | EE_Error::throw_exception_if_debugging( |
186 | 186 | sprintf( |
187 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
187 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
188 | 188 | $this->_input->name(), |
189 | 189 | $input_path |
190 | 190 | ), |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | ); |
195 | 195 | return false; |
196 | 196 | } |
197 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
198 | - switch( $op ) { |
|
197 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
198 | + switch ($op) { |
|
199 | 199 | case '=': |
200 | 200 | default: |
201 | 201 | $meets_all_requirements = $input->normalized_value() === $value; |
202 | 202 | } |
203 | - if( ! $meets_all_requirements ) { |
|
203 | + if ( ! $meets_all_requirements) { |
|
204 | 204 | break; |
205 | 205 | } |
206 | 206 | } |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * @return array |
218 | 218 | * @throws \EE_Error |
219 | 219 | */ |
220 | - protected function _validate_op_and_value( $op_and_value ) { |
|
221 | - if( ! isset( $op_and_value[ 0 ], $op_and_value[ 1 ] ) ) { |
|
220 | + protected function _validate_op_and_value($op_and_value) { |
|
221 | + if ( ! isset($op_and_value[0], $op_and_value[1])) { |
|
222 | 222 | EE_Error::throw_exception_if_debugging( |
223 | 223 | sprintf( |
224 | - __( 'Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso' ), |
|
224 | + __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
|
225 | 225 | $this->_input->name() |
226 | 226 | ), |
227 | 227 | __FILE__, |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | __LINE__ |
230 | 230 | ); |
231 | 231 | } |
232 | - $operator = $op_and_value[ 0 ]; |
|
233 | - $value = (string) $op_and_value[ 1 ]; |
|
234 | - if( $operator !== '=' ) { |
|
232 | + $operator = $op_and_value[0]; |
|
233 | + $value = (string) $op_and_value[1]; |
|
234 | + if ($operator !== '=') { |
|
235 | 235 | EE_Error::throw_exception_if_debugging( |
236 | 236 | sprintf( |
237 | - __( 'Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso' ), |
|
237 | + __('Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso'), |
|
238 | 238 | $this->_input->name() |
239 | 239 | ), |
240 | 240 | __FILE__, |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | __LINE__ |
243 | 243 | ); |
244 | 244 | } |
245 | - return array( $operator, $value ); |
|
245 | + return array($operator, $value); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | && $this->_input_is_required_server_side() |
54 | 54 | ) { |
55 | 55 | throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
56 | - }else{ |
|
56 | + } else{ |
|
57 | 57 | return true; |
58 | 58 | } |
59 | 59 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | ! isset( $input_settings['include_whats_this_link'] ) |
34 | 34 | || ( |
35 | 35 | isset( $input_settings['include_whats_this_link'] ) |
36 | - && $input_settings['include_whats_this_link'] === true |
|
36 | + && $input_settings['include_whats_this_link'] === true |
|
37 | 37 | ) |
38 | 38 | ) { |
39 | 39 | $this->_html_label_text = sprintf( |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_CVV_Input extends EE_Text_Input{ |
|
11 | +class EE_CVV_Input extends EE_Text_Input { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings { |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
20 | 20 | $this->_add_validation_strategy( |
21 | 21 | new EE_Text_Validation_Strategy( |
22 | - isset( $input_settings[ 'validation_error_message' ] ) |
|
23 | - ? $input_settings[ 'validation_error_message' ] |
|
22 | + isset($input_settings['validation_error_message']) |
|
23 | + ? $input_settings['validation_error_message'] |
|
24 | 24 | : __( |
25 | 25 | 'The CVV is either a 3 digit number on the back of your card, or 4 digit number on the front', |
26 | 26 | 'event_espresso' |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | parent::__construct($input_settings); |
32 | - if( |
|
33 | - ! isset( $input_settings['include_whats_this_link'] ) |
|
32 | + if ( |
|
33 | + ! isset($input_settings['include_whats_this_link']) |
|
34 | 34 | || ( |
35 | - isset( $input_settings['include_whats_this_link'] ) |
|
35 | + isset($input_settings['include_whats_this_link']) |
|
36 | 36 | && $input_settings['include_whats_this_link'] === true |
37 | 37 | ) |
38 | 38 | ) { |
@@ -21,9 +21,12 @@ |
||
21 | 21 | <title><?php echo $title; ?></title> |
22 | 22 | <?php if ( $enqueue_wp_assets ) : ?> |
23 | 23 | <?php wp_head(); ?> |
24 | -<?php else : ?> |
|
24 | +<?php else { |
|
25 | + : ?> |
|
25 | 26 | <?php foreach ( $css as $url ) : ?> |
26 | - <link rel="stylesheet" type="text/css" href="<?php echo $url;?>"> |
|
27 | + <link rel="stylesheet" type="text/css" href="<?php echo $url; |
|
28 | +} |
|
29 | +?>"> |
|
27 | 30 | <?php endforeach; ?> |
28 | 31 | <script type="text/javascript"> |
29 | 32 | <?php echo $eei18n; ?> |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | <html> |
23 | 23 | <head> |
24 | 24 | <title><?php echo $title; ?></title> |
25 | -<?php if ( $enqueue_wp_assets ) : ?> |
|
25 | +<?php if ($enqueue_wp_assets) : ?> |
|
26 | 26 | <?php wp_head(); ?> |
27 | 27 | <?php else : ?> |
28 | - <?php foreach ( $css as $url ) : ?> |
|
29 | - <link rel="stylesheet" type="text/css" href="<?php echo $url;?>"> |
|
28 | + <?php foreach ($css as $url) : ?> |
|
29 | + <link rel="stylesheet" type="text/css" href="<?php echo $url; ?>"> |
|
30 | 30 | <?php endforeach; ?> |
31 | 31 | <script type="text/javascript"> |
32 | 32 | <?php echo $eei18n; ?> |
33 | 33 | </script> |
34 | - <?php foreach ( $header_js as $key => $url ) : ?> |
|
35 | - <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?> |
|
34 | + <?php foreach ($header_js as $key => $url) : ?> |
|
35 | + <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?> |
|
36 | 36 | <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $header_attributes; ?>></script> |
37 | 37 | <?php endforeach; ?> |
38 | 38 | <?php endif; ?> |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | <div style="padding: 1em;"> |
43 | 43 | <?php echo $content; ?> |
44 | 44 | </div> |
45 | - <?php foreach ( $footer_js as $key => $url ) : ?> |
|
46 | - <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[ $key ] : ''; ?> |
|
47 | - <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $footer_attributes;?>></script> |
|
45 | + <?php foreach ($footer_js as $key => $url) : ?> |
|
46 | + <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?> |
|
47 | + <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $footer_attributes; ?>></script> |
|
48 | 48 | <?php endforeach; ?> |
49 | -<?php if ( $enqueue_wp_assets ) : ?> |
|
49 | +<?php if ($enqueue_wp_assets) : ?> |
|
50 | 50 | <?php wp_footer(); ?> |
51 | 51 | <?php endif; ?> |
52 | 52 | </body> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <?php _e('Adjust the settings for the Authorize.net AIM payment gateway.', 'event_espresso'); ?> |
4 | 4 | </p> |
5 | 5 | <p> |
6 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso' ), "<a href='http://www.authorize.net/international/' target='_blank'>","</a>" ); ?> |
|
6 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso'), "<a href='http://www.authorize.net/international/' target='_blank'>", "</a>"); ?> |
|
7 | 7 | </p> |
8 | 8 | <p><strong><?php _e('Authorize.net AIM Settings', 'event_espresso'); ?></strong></p> |
9 | 9 | <ul> |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | <?php _e('By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.', 'event_espresso'); ?> |
29 | 29 | <br> |
30 | 30 | <?php printf( |
31 | - __( 'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'), |
|
31 | + __('To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'), |
|
32 | 32 | '<a href="http://authorize.net" target="_blank">', |
33 | 33 | '</a>', |
34 | 34 | '<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank">', |
35 | 35 | '<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank">', |
36 | - '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">');?> |
|
36 | + '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">'); ?> |
|
37 | 37 | </li> |
38 | 38 | <li> |
39 | - <strong><?php _e( 'Server', 'event_espresso');?></strong> |
|
40 | - <?php _e( 'Use this setting to change the server where Authorize.net AIM requests are sent. Change this to "Authorize.net/Akamai" before June 30th 2016 to verify your server wil work with Authorize.net\'s servers which will be in use after that date.', 'event_espresso' );?> |
|
39 | + <strong><?php _e('Server', 'event_espresso'); ?></strong> |
|
40 | + <?php _e('Use this setting to change the server where Authorize.net AIM requests are sent. Change this to "Authorize.net/Akamai" before June 30th 2016 to verify your server wil work with Authorize.net\'s servers which will be in use after that date.', 'event_espresso'); ?> |
|
41 | 41 | </li> |
42 | 42 | <li> |
43 | 43 | <strong><?php _e('Button Image URL', 'event_espresso'); ?></strong><br /> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * @param array $arguments |
36 | 36 | * @return \EE_CPT_Default_Strategy |
37 | 37 | */ |
38 | - public function __construct( $arguments = array() ) { |
|
39 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : null; |
|
38 | + public function __construct($arguments = array()) { |
|
39 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
40 | 40 | // $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : null; |
41 | 41 | //EEH_Debug_Tools::printr( $this->CPT, '$this->CPT <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
42 | 42 | // add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 999 ); |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @param \WP_Query $WP_Query |
53 | 53 | * @return \WP_Query |
54 | 54 | */ |
55 | - public function pre_get_posts( WP_Query $WP_Query ) { |
|
55 | + public function pre_get_posts(WP_Query $WP_Query) { |
|
56 | 56 | //EEH_Debug_Tools::printr( $WP_Query, '$WP_Query <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
57 | - if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive() ) { |
|
57 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
58 | 58 | return $WP_Query; |
59 | 59 | } |
60 | 60 | // $WP_Query->set( 'post_type', array( $this->CPT['post_type'] )); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param \WP_Query $WP_Query |
73 | 73 | * @return \WP_Post[] |
74 | 74 | */ |
75 | - public function the_posts( $posts, WP_Query $WP_Query ) { |
|
75 | + public function the_posts($posts, WP_Query $WP_Query) { |
|
76 | 76 | return $posts; |
77 | 77 | } |
78 | 78 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $single |
89 | 89 | * @return mixed |
90 | 90 | */ |
91 | - public function get_EE_post_type_metadata( $meta_value = null, $post_id, $meta_key, $single ) { |
|
91 | + public function get_EE_post_type_metadata($meta_value = null, $post_id, $meta_key, $single) { |
|
92 | 92 | return $meta_value; |
93 | 93 | } |
94 | 94 |
@@ -447,14 +447,14 @@ |
||
447 | 447 | global $wpdb; |
448 | 448 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
449 | 449 | $SQL .= ' LEFT JOIN ' |
450 | - . $this->meta_table->get_table_name() |
|
451 | - . ' ON ( ' |
|
452 | - . $this->meta_table->get_table_name() |
|
453 | - . '.' |
|
454 | - . $this->meta_table->get_fk_on_table() |
|
455 | - . ' = ' |
|
456 | - . $wpdb->posts |
|
457 | - . '.ID ) '; |
|
450 | + . $this->meta_table->get_table_name() |
|
451 | + . ' ON ( ' |
|
452 | + . $this->meta_table->get_table_name() |
|
453 | + . '.' |
|
454 | + . $this->meta_table->get_fk_on_table() |
|
455 | + . ' = ' |
|
456 | + . $wpdb->posts |
|
457 | + . '.ID ) '; |
|
458 | 458 | } |
459 | 459 | remove_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
460 | 460 | return $SQL; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\CPTs; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | \WP_Query $WP_Query, |
81 | 81 | \EE_Request_Handler $request |
82 | 82 | ) { |
83 | - $this->setRequest( $request ); |
|
84 | - $this->setWpQuery( $WP_Query ); |
|
85 | - $this->setPostType( $post_type ); |
|
86 | - $this->setCptDetails( $cpt_details ); |
|
83 | + $this->setRequest($request); |
|
84 | + $this->setWpQuery($WP_Query); |
|
85 | + $this->setPostType($post_type); |
|
86 | + $this->setCptDetails($cpt_details); |
|
87 | 87 | $this->init(); |
88 | 88 | } |
89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @param string $post_type |
103 | 103 | */ |
104 | - protected function setPostType( $post_type ) { |
|
104 | + protected function setPostType($post_type) { |
|
105 | 105 | $this->post_type = $post_type; |
106 | 106 | } |
107 | 107 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param array $cpt_details |
121 | 121 | */ |
122 | - protected function setCptDetails( $cpt_details ) { |
|
122 | + protected function setCptDetails($cpt_details) { |
|
123 | 123 | $this->cpt_details = $cpt_details; |
124 | 124 | } |
125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @param \EE_Table_Base[] $model_tables |
139 | 139 | */ |
140 | - protected function setModelTables( $model_tables ) { |
|
140 | + protected function setModelTables($model_tables) { |
|
141 | 141 | $this->model_tables = $model_tables; |
142 | 142 | } |
143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return array |
148 | 148 | */ |
149 | 149 | public function taxonomies() { |
150 | - if ( empty( $this->taxonomies ) ) { |
|
150 | + if (empty($this->taxonomies)) { |
|
151 | 151 | $this->initializeTaxonomies(); |
152 | 152 | } |
153 | 153 | return $this->taxonomies; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @param array $taxonomies |
160 | 160 | */ |
161 | - protected function setTaxonomies( array $taxonomies ) { |
|
161 | + protected function setTaxonomies(array $taxonomies) { |
|
162 | 162 | $this->taxonomies = $taxonomies; |
163 | 163 | } |
164 | 164 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * @param \EE_Secondary_Table $meta_table |
178 | 178 | */ |
179 | - public function setMetaTable( \EE_Secondary_Table $meta_table ) { |
|
179 | + public function setMetaTable(\EE_Secondary_Table $meta_table) { |
|
180 | 180 | $this->meta_table = $meta_table; |
181 | 181 | } |
182 | 182 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | /** |
195 | 195 | * @param \EEM_Base $CPT_model |
196 | 196 | */ |
197 | - protected function setModel( \EEM_Base $CPT_model ) { |
|
197 | + protected function setModel(\EEM_Base $CPT_model) { |
|
198 | 198 | $this->model = $CPT_model; |
199 | 199 | } |
200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * @param \EE_Request_Handler $request |
214 | 214 | */ |
215 | - protected function setRequest( \EE_Request_Handler $request ) { |
|
215 | + protected function setRequest(\EE_Request_Handler $request) { |
|
216 | 216 | $this->request = $request; |
217 | 217 | } |
218 | 218 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | /** |
231 | 231 | * @param \WP_Query $wp_query |
232 | 232 | */ |
233 | - public function setWpQuery( \WP_Query $wp_query ) { |
|
233 | + public function setWpQuery(\WP_Query $wp_query) { |
|
234 | 234 | $this->wp_query = $wp_query; |
235 | 235 | } |
236 | 236 | |
@@ -245,22 +245,22 @@ discard block |
||
245 | 245 | protected function initializeTaxonomies() { |
246 | 246 | // check if taxonomies have already been set and that this CPT has taxonomies registered for it |
247 | 247 | if ( |
248 | - empty( $this->taxonomies ) |
|
249 | - && isset( $this->cpt_details['args'], $this->cpt_details['args']['taxonomies'] ) |
|
248 | + empty($this->taxonomies) |
|
249 | + && isset($this->cpt_details['args'], $this->cpt_details['args']['taxonomies']) |
|
250 | 250 | ) { |
251 | 251 | // if so then grab them, but we want the taxonomy name as the key |
252 | - $taxonomies = array_flip( $this->cpt_details['args']['taxonomies'] ); |
|
252 | + $taxonomies = array_flip($this->cpt_details['args']['taxonomies']); |
|
253 | 253 | // then grab the list of ALL taxonomies |
254 | 254 | $all_taxonomies = \EE_Register_CPTs::get_taxonomies(); |
255 | - foreach ( $taxonomies as $taxonomy => &$details ) { |
|
255 | + foreach ($taxonomies as $taxonomy => &$details) { |
|
256 | 256 | // add details to our taxonomies if they exist |
257 | - $details = isset( $all_taxonomies[ $taxonomy ] ) |
|
258 | - ? $all_taxonomies[ $taxonomy ] |
|
257 | + $details = isset($all_taxonomies[$taxonomy]) |
|
258 | + ? $all_taxonomies[$taxonomy] |
|
259 | 259 | : array(); |
260 | 260 | } |
261 | 261 | // ALWAYS unset() variables that were passed by reference |
262 | - unset( $details ); |
|
263 | - $this->setTaxonomies( $taxonomies ); |
|
262 | + unset($details); |
|
263 | + $this->setTaxonomies($taxonomies); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | $this->setAdditionalCptDetails(); |
271 | 271 | $this->setRequestVarsIfCpt(); |
272 | 272 | // convert post_type to model name |
273 | - $model_name = str_replace( 'EE_', '', $this->cpt_details['class_name'] ); |
|
273 | + $model_name = str_replace('EE_', '', $this->cpt_details['class_name']); |
|
274 | 274 | // load all tables related to CPT |
275 | - $this->setupModelsAndTables( $model_name ); |
|
275 | + $this->setupModelsAndTables($model_name); |
|
276 | 276 | // load and instantiate CPT_*_Strategy |
277 | - $CPT_Strategy = $this->cptStrategyClass( $model_name ); |
|
277 | + $CPT_Strategy = $this->cptStrategyClass($model_name); |
|
278 | 278 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
279 | 279 | // here's the list of available filters in the WP_Query object |
280 | 280 | // 'posts_where_paged' |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | // 'post_limits' |
286 | 286 | // 'posts_fields' |
287 | 287 | // 'posts_join' |
288 | - add_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
289 | - add_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
288 | + add_filter('posts_fields', array($this, 'postsFields')); |
|
289 | + add_filter('posts_join', array($this, 'postsJoin')); |
|
290 | 290 | add_filter( |
291 | - 'get_' . $this->post_type . '_metadata', |
|
292 | - array( $CPT_Strategy, 'get_EE_post_type_metadata' ), |
|
291 | + 'get_'.$this->post_type.'_metadata', |
|
292 | + array($CPT_Strategy, 'get_EE_post_type_metadata'), |
|
293 | 293 | 1, |
294 | 294 | 4 |
295 | 295 | ); |
296 | - add_filter( 'the_posts', array( $this, 'thePosts' ), 1, 1 ); |
|
297 | - if ( $this->wp_query->is_main_query() ) { |
|
298 | - add_filter( 'get_edit_post_link', array( $this, 'getEditPostLink' ), 10, 2 ); |
|
296 | + add_filter('the_posts', array($this, 'thePosts'), 1, 1); |
|
297 | + if ($this->wp_query->is_main_query()) { |
|
298 | + add_filter('get_edit_post_link', array($this, 'getEditPostLink'), 10, 2); |
|
299 | 299 | $this->addTemplateFilters(); |
300 | 300 | } |
301 | 301 | } |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | // the post or category or term that is triggering EE |
313 | 313 | $this->cpt_details['espresso_page'] = $this->request->is_espresso_page(); |
314 | 314 | // requested post name |
315 | - $this->cpt_details['post_name'] = $this->request->get( 'post_name' ); |
|
315 | + $this->cpt_details['post_name'] = $this->request->get('post_name'); |
|
316 | 316 | // add support for viewing 'private', 'draft', or 'pending' posts |
317 | 317 | if ( |
318 | - isset( $this->wp_query->query_vars['p'] ) |
|
318 | + isset($this->wp_query->query_vars['p']) |
|
319 | 319 | && $this->wp_query->query_vars['p'] !== 0 |
320 | 320 | && is_user_logged_in() |
321 | - && current_user_can( 'edit_post', $this->wp_query->query_vars['p'] ) |
|
321 | + && current_user_can('edit_post', $this->wp_query->query_vars['p']) |
|
322 | 322 | ) { |
323 | 323 | // we can just inject directly into the WP_Query object |
324 | - $this->wp_query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
324 | + $this->wp_query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
325 | 325 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
326 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
326 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function setRequestVarsIfCpt() { |
342 | 342 | // check if ee action var has been set |
343 | - if ( ! $this->request->is_set( 'ee' ) ) { |
|
343 | + if ( ! $this->request->is_set('ee')) { |
|
344 | 344 | // check that route exists for CPT archive slug |
345 | - if ( is_archive() && \EE_Config::get_route( $this->cpt_details['plural_slug'] ) ) { |
|
345 | + if (is_archive() && \EE_Config::get_route($this->cpt_details['plural_slug'])) { |
|
346 | 346 | // ie: set "ee" to "events" |
347 | - $this->request->set( 'ee', $this->cpt_details['plural_slug'] ); |
|
347 | + $this->request->set('ee', $this->cpt_details['plural_slug']); |
|
348 | 348 | // or does it match a single page CPT like /event/ |
349 | - } else if ( is_single() && \EE_Config::get_route( $this->cpt_details['singular_slug'] ) ) { |
|
349 | + } else if (is_single() && \EE_Config::get_route($this->cpt_details['singular_slug'])) { |
|
350 | 350 | // ie: set "ee" to "event" |
351 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
351 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | } |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | * @param string $model_name |
363 | 363 | * @throws \EE_Error |
364 | 364 | */ |
365 | - protected function setupModelsAndTables( $model_name ) { |
|
365 | + protected function setupModelsAndTables($model_name) { |
|
366 | 366 | // get CPT table data via CPT Model |
367 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
368 | - if ( ! $model instanceof \EEM_Base ) { |
|
369 | - throw new \EE_Error ( |
|
367 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
368 | + if ( ! $model instanceof \EEM_Base) { |
|
369 | + throw new \EE_Error( |
|
370 | 370 | sprintf( |
371 | 371 | __( |
372 | 372 | 'The "%1$s" model could not be loaded.', |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | ) |
377 | 377 | ); |
378 | 378 | } |
379 | - $this->setModel( $model ); |
|
380 | - $this->setModelTables( $this->model->get_tables() ); |
|
379 | + $this->setModel($model); |
|
380 | + $this->setModelTables($this->model->get_tables()); |
|
381 | 381 | // is there a Meta Table for this CPT? |
382 | 382 | if ( |
383 | - isset( $this->cpt_details['tables'][ $model_name . '_Meta' ] ) |
|
384 | - && $this->cpt_details['tables'][ $model_name . '_Meta' ] instanceof \EE_Secondary_Table |
|
383 | + isset($this->cpt_details['tables'][$model_name.'_Meta']) |
|
384 | + && $this->cpt_details['tables'][$model_name.'_Meta'] instanceof \EE_Secondary_Table |
|
385 | 385 | ) { |
386 | - $this->setMetaTable( $this->cpt_details['tables'][ $model_name . '_Meta' ] ); |
|
386 | + $this->setMetaTable($this->cpt_details['tables'][$model_name.'_Meta']); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -396,18 +396,18 @@ discard block |
||
396 | 396 | * @param string $model_name |
397 | 397 | * @return string |
398 | 398 | */ |
399 | - protected function cptStrategyClass( $model_name ) { |
|
399 | + protected function cptStrategyClass($model_name) { |
|
400 | 400 | // creates classname like: CPT_Event_Strategy |
401 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
401 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
402 | 402 | // load and instantiate |
403 | 403 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
404 | 404 | $CPT_Strategy_class_name, |
405 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
405 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
406 | 406 | ); |
407 | - if ( $CPT_Strategy === null ) { |
|
407 | + if ($CPT_Strategy === null) { |
|
408 | 408 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
409 | 409 | 'CPT_Default_Strategy', |
410 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
410 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
411 | 411 | ); |
412 | 412 | } |
413 | 413 | return $CPT_Strategy; |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | * @param $SQL |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public function postsFields( $SQL ) { |
|
425 | + public function postsFields($SQL) { |
|
426 | 426 | // does this CPT have a meta table ? |
427 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
427 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
428 | 428 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
429 | - $SQL .= ', ' . $this->meta_table->get_table_name() . '.* '; |
|
429 | + $SQL .= ', '.$this->meta_table->get_table_name().'.* '; |
|
430 | 430 | } |
431 | - remove_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
431 | + remove_filter('posts_fields', array($this, 'postsFields')); |
|
432 | 432 | return $SQL; |
433 | 433 | } |
434 | 434 | |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | * @param $SQL |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public function postsJoin( $SQL ) { |
|
444 | + public function postsJoin($SQL) { |
|
445 | 445 | // does this CPT have a meta table ? |
446 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
446 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
447 | 447 | global $wpdb; |
448 | 448 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
449 | 449 | $SQL .= ' LEFT JOIN ' |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | . $wpdb->posts |
457 | 457 | . '.ID ) '; |
458 | 458 | } |
459 | - remove_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
459 | + remove_filter('posts_join', array($this, 'postsJoin')); |
|
460 | 460 | return $SQL; |
461 | 461 | } |
462 | 462 | |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | * @param \WP_Post[] $posts |
470 | 470 | * @return \WP_Post[] |
471 | 471 | */ |
472 | - public function thePosts( $posts ) { |
|
472 | + public function thePosts($posts) { |
|
473 | 473 | $CPT_class = $this->cpt_details['class_name']; |
474 | 474 | // loop thru posts |
475 | - if ( is_array( $posts ) && $this->model instanceof \EEM_CPT_Base ) { |
|
476 | - foreach ( $posts as $key => $post ) { |
|
477 | - if ( $post->post_type === $this->post_type ) { |
|
478 | - $post->{$CPT_class} = $this->model->instantiate_class_from_post_object( $post ); |
|
475 | + if (is_array($posts) && $this->model instanceof \EEM_CPT_Base) { |
|
476 | + foreach ($posts as $key => $post) { |
|
477 | + if ($post->post_type === $this->post_type) { |
|
478 | + $post->{$CPT_class} = $this->model->instantiate_class_from_post_object($post); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | } |
482 | - remove_filter( 'the_posts', array( $this, 'thePosts' ), 1 ); |
|
482 | + remove_filter('the_posts', array($this, 'thePosts'), 1); |
|
483 | 483 | return $posts; |
484 | 484 | } |
485 | 485 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param $ID |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - public function getEditPostLink( $url, $ID ) { |
|
493 | + public function getEditPostLink($url, $ID) { |
|
494 | 494 | // need to make sure we only edit links if our cpt |
495 | 495 | global $post; |
496 | 496 | //notice if the cpt is registered with `show_ee_ui` set to false, we take that to mean that the WordPress core ui |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | ! $post instanceof \WP_Post |
500 | 500 | || $post->post_type !== $this->post_type |
501 | 501 | || ( |
502 | - isset( $this->cpt_details['args']['show_ee_ui'] ) |
|
502 | + isset($this->cpt_details['args']['show_ee_ui']) |
|
503 | 503 | && ! $this->cpt_details['args']['show_ee_ui'] |
504 | 504 | ) |
505 | 505 | ) { |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | //k made it here so all is good. |
509 | 509 | return wp_nonce_url( |
510 | 510 | add_query_arg( |
511 | - array( 'page' => $this->post_type, 'post' => $ID, 'action' => 'edit' ), |
|
512 | - admin_url( 'admin.php' ) |
|
511 | + array('page' => $this->post_type, 'post' => $ID, 'action' => 'edit'), |
|
512 | + admin_url('admin.php') |
|
513 | 513 | ), |
514 | 514 | 'edit', |
515 | 515 | 'edit_nonce' |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | */ |
527 | 527 | public function addTemplateFilters() { |
528 | 528 | // if requested cpt supports page_templates and it's the main query |
529 | - if ( ! empty( $this->cpt_details['args']['page_templates'] ) && $this->wp_query->is_main_query() ) { |
|
529 | + if ( ! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) { |
|
530 | 530 | // then let's hook into the appropriate query_template hook |
531 | - add_filter( 'single_template', array( $this, 'singleCptTemplate' ) ); |
|
531 | + add_filter('single_template', array($this, 'singleCptTemplate')); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
@@ -542,20 +542,20 @@ discard block |
||
542 | 542 | * @param string $current_template Existing default template path derived for this page call. |
543 | 543 | * @return string the path to the full template file. |
544 | 544 | */ |
545 | - public function singleCptTemplate( $current_template ) { |
|
545 | + public function singleCptTemplate($current_template) { |
|
546 | 546 | $object = get_queried_object(); |
547 | 547 | //does this called object HAVE a page template set that is something other than the default. |
548 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
548 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
549 | 549 | //exit early if default or not set or invalid path (accounts for theme changes) |
550 | 550 | if ( |
551 | 551 | $template === 'default' |
552 | - || empty( $template ) |
|
553 | - || ! is_readable( get_stylesheet_directory() . '/' . $template ) |
|
552 | + || empty($template) |
|
553 | + || ! is_readable(get_stylesheet_directory().'/'.$template) |
|
554 | 554 | ) { |
555 | 555 | return $current_template; |
556 | 556 | } |
557 | 557 | //made it here so we SHOULD be able to just locate the template and then return it. |
558 | - return locate_template( array( $template ) ); |
|
558 | + return locate_template(array($template)); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Select_Reveal_Input |
4 | 4 | * |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.6 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Select_Reveal_Input extends EE_Select_Input{ |
|
14 | +class EE_Select_Reveal_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $answer_options Array keys which match a sibling section's name |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array $input_settings |
28 | 28 | */ |
29 | - public function __construct( $answer_options, $input_settings = array() ){ |
|
30 | - parent::__construct( $answer_options, $input_settings ); |
|
29 | + public function __construct($answer_options, $input_settings = array()) { |
|
30 | + parent::__construct($answer_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function sibling_sections_controlled() { |
38 | 38 | $sibling_sections = array(); |
39 | - foreach( $this->options() as $sibling_section_name => $sibling_section ) { |
|
39 | + foreach ($this->options() as $sibling_section_name => $sibling_section) { |
|
40 | 40 | //if it's an empty string just leave it alone |
41 | - if( empty( $sibling_section_name ) ) { |
|
41 | + if (empty($sibling_section_name)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | - $sibling_section = $this->find_section_from_path( '../' . $sibling_section_name ); |
|
45 | - if( |
|
44 | + $sibling_section = $this->find_section_from_path('../'.$sibling_section_name); |
|
45 | + if ( |
|
46 | 46 | $sibling_section instanceof EE_Form_Section_Base |
47 | - && ! empty( $sibling_section_name ) |
|
47 | + && ! empty($sibling_section_name) |
|
48 | 48 | ) { |
49 | - $sibling_sections[ $sibling_section_name ] = $sibling_section; |
|
49 | + $sibling_sections[$sibling_section_name] = $sibling_section; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | return $sibling_sections; |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | * @param array $form_other_js_data |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
63 | - $form_other_js_data = parent::get_other_js_data( $form_other_js_data ); |
|
64 | - if( ! isset($form_other_js_data[ 'select_reveal_inputs' ] ) ) { |
|
65 | - $form_other_js_data[ 'select_reveal_inputs' ] = array(); |
|
62 | + public function get_other_js_data($form_other_js_data = array()) { |
|
63 | + $form_other_js_data = parent::get_other_js_data($form_other_js_data); |
|
64 | + if ( ! isset($form_other_js_data['select_reveal_inputs'])) { |
|
65 | + $form_other_js_data['select_reveal_inputs'] = array(); |
|
66 | 66 | } |
67 | 67 | $sibling_input_to_html_id_map = array(); |
68 | - foreach( $this->sibling_sections_controlled() as $sibling_section_path => $sibling_section ) { |
|
69 | - $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id(); |
|
68 | + foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) { |
|
69 | + $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id(); |
|
70 | 70 | } |
71 | - $form_other_js_data[ 'select_reveal_inputs' ][ $this->html_id() ] = $sibling_input_to_html_id_map; |
|
71 | + $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map; |
|
72 | 72 | return $form_other_js_data; |
73 | 73 | } |
74 | 74 |
@@ -84,6 +84,7 @@ |
||
84 | 84 | * |
85 | 85 | * @access public |
86 | 86 | * @param mixed |
87 | + * @param string $info |
|
87 | 88 | * @return null | object |
88 | 89 | */ |
89 | 90 | public function get_by_info( $info ) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Class EE_Object_Collection |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @param mixed $info |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public function add( $object, $info = null ) { |
|
40 | + public function add($object, $info = null) { |
|
41 | 41 | $class = $this->interface; |
42 | - if ( ! $object instanceof $class ) { |
|
42 | + if ( ! $object instanceof $class) { |
|
43 | 43 | return false; |
44 | 44 | } |
45 | - $this->attach( $object ); |
|
46 | - $this->set_info( $object, $info ); |
|
47 | - return $this->contains( $object ); |
|
45 | + $this->attach($object); |
|
46 | + $this->set_info($object, $info); |
|
47 | + return $this->contains($object); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param mixed $info |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function set_info( $object, $info = null ) { |
|
64 | - $info = ! empty( $info ) ? $info : spl_object_hash( $object ); |
|
63 | + public function set_info($object, $info = null) { |
|
64 | + $info = ! empty($info) ? $info : spl_object_hash($object); |
|
65 | 65 | $this->rewind(); |
66 | - while ( $this->valid() ) { |
|
67 | - if ( $object == $this->current() ) { |
|
68 | - $this->setInfo( $info ); |
|
66 | + while ($this->valid()) { |
|
67 | + if ($object == $this->current()) { |
|
68 | + $this->setInfo($info); |
|
69 | 69 | $this->rewind(); |
70 | 70 | return true; |
71 | 71 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * @param mixed |
87 | 87 | * @return null | object |
88 | 88 | */ |
89 | - public function get_by_info( $info ) { |
|
89 | + public function get_by_info($info) { |
|
90 | 90 | $this->rewind(); |
91 | - while ( $this->valid() ) { |
|
92 | - if ( $info === $this->getInfo() ) { |
|
91 | + while ($this->valid()) { |
|
92 | + if ($info === $this->getInfo()) { |
|
93 | 93 | $object = $this->current(); |
94 | 94 | $this->rewind(); |
95 | 95 | return $object; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param object $object |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public function has( $object ) { |
|
114 | - return $this->contains( $object ); |
|
113 | + public function has($object) { |
|
114 | + return $this->contains($object); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param $object |
126 | 126 | * @return bool |
127 | 127 | */ |
128 | - public function remove( $object ) { |
|
129 | - $this->detach( $object ); |
|
128 | + public function remove($object) { |
|
129 | + $this->detach($object); |
|
130 | 130 | return true; |
131 | 131 | } |
132 | 132 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * @param $object |
142 | 142 | * @return void |
143 | 143 | */ |
144 | - public function set_current( $object ) { |
|
144 | + public function set_current($object) { |
|
145 | 145 | $this->rewind(); |
146 | - while ( $this->valid() ) { |
|
147 | - if ( $this->current() === $object ) { |
|
146 | + while ($this->valid()) { |
|
147 | + if ($this->current() === $object) { |
|
148 | 148 | break; |
149 | 149 | } |
150 | 150 | $this->next(); |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @param $info |
163 | 163 | * @return void |
164 | 164 | */ |
165 | - public function set_current_by_info( $info ) { |
|
165 | + public function set_current_by_info($info) { |
|
166 | 166 | $this->rewind(); |
167 | - while ( $this->valid() ) { |
|
168 | - if ( $info === $this->getInfo() ) { |
|
167 | + while ($this->valid()) { |
|
168 | + if ($info === $this->getInfo()) { |
|
169 | 169 | break; |
170 | 170 | } |
171 | 171 | $this->next(); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * Loads the class file for a given class name. |
133 | 133 | * |
134 | 134 | * @param string $class The fully-qualified class name. |
135 | - * @return mixed The mapped file name on success, or boolean false on |
|
135 | + * @return string|false The mapped file name on success, or boolean false on |
|
136 | 136 | * failure. |
137 | 137 | */ |
138 | 138 | public function loadClass( $class ) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param string $prefix The namespace prefix. |
167 | 167 | * @param string $relative_class The relative class name. |
168 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
168 | + * @return string|false Boolean false if no mapped file can be loaded, or the |
|
169 | 169 | * name of the mapped file that was loaded. |
170 | 170 | */ |
171 | 171 | protected function loadMappedFile( $prefix, $relative_class ) { |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * @param string $prefix |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public function prefixes( $prefix = '' ) { |
|
81 | - if ( ! empty( $prefix ) ) { |
|
80 | + public function prefixes($prefix = '') { |
|
81 | + if ( ! empty($prefix)) { |
|
82 | 82 | // are there any base directories for this namespace prefix? |
83 | - return isset( $this->prefixes[ $prefix ] ) ? $this->prefixes[ $prefix ] : array(); |
|
83 | + return isset($this->prefixes[$prefix]) ? $this->prefixes[$prefix] : array(); |
|
84 | 84 | } |
85 | 85 | return $this->prefixes; |
86 | 86 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function register() { |
96 | - spl_autoload_register( array( $this, 'loadClass' ) ); |
|
96 | + spl_autoload_register(array($this, 'loadClass')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | * than last. |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - public function addNamespace( $prefix, $base_dir, $prepend = false ) { |
|
112 | + public function addNamespace($prefix, $base_dir, $prepend = false) { |
|
113 | 113 | // normalize namespace prefix |
114 | - $prefix = trim( $prefix, Psr4Autoloader::NS ) . Psr4Autoloader::NS; |
|
114 | + $prefix = trim($prefix, Psr4Autoloader::NS).Psr4Autoloader::NS; |
|
115 | 115 | // normalize the base directory with a trailing separator |
116 | - $base_dir = \EEH_File::standardise_and_end_with_directory_separator( $base_dir ); |
|
116 | + $base_dir = \EEH_File::standardise_and_end_with_directory_separator($base_dir); |
|
117 | 117 | // initialize the namespace prefix array |
118 | - if ( isset( $this->prefixes[ $prefix ] ) === false ) { |
|
119 | - $this->prefixes[ $prefix ] = array(); |
|
118 | + if (isset($this->prefixes[$prefix]) === false) { |
|
119 | + $this->prefixes[$prefix] = array(); |
|
120 | 120 | } |
121 | 121 | // retain the base directory for the namespace prefix |
122 | - if ( $prepend ) { |
|
123 | - array_unshift( $this->prefixes[ $prefix ], $base_dir ); |
|
122 | + if ($prepend) { |
|
123 | + array_unshift($this->prefixes[$prefix], $base_dir); |
|
124 | 124 | } else { |
125 | - $this->prefixes[ $prefix ][] = $base_dir; |
|
125 | + $this->prefixes[$prefix][] = $base_dir; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -135,24 +135,24 @@ discard block |
||
135 | 135 | * @return mixed The mapped file name on success, or boolean false on |
136 | 136 | * failure. |
137 | 137 | */ |
138 | - public function loadClass( $class ) { |
|
138 | + public function loadClass($class) { |
|
139 | 139 | // the current namespace prefix |
140 | 140 | $prefix = $class; |
141 | 141 | // work backwards through the namespace names of the fully-qualified |
142 | 142 | // class name to find a mapped file name |
143 | - while ( false !== $pos = strrpos( $prefix, Psr4Autoloader::NS ) ) { |
|
143 | + while (false !== $pos = strrpos($prefix, Psr4Autoloader::NS)) { |
|
144 | 144 | // retain the trailing namespace separator in the prefix |
145 | - $prefix = substr( $class, 0, $pos + 1 ); |
|
145 | + $prefix = substr($class, 0, $pos + 1); |
|
146 | 146 | // the rest is the relative class name |
147 | - $relative_class = substr( $class, $pos + 1 ); |
|
147 | + $relative_class = substr($class, $pos + 1); |
|
148 | 148 | // try to load a mapped file for the prefix and relative class |
149 | - $mapped_file = $this->loadMappedFile( $prefix, $relative_class ); |
|
150 | - if ( $mapped_file ) { |
|
149 | + $mapped_file = $this->loadMappedFile($prefix, $relative_class); |
|
150 | + if ($mapped_file) { |
|
151 | 151 | return $mapped_file; |
152 | 152 | } |
153 | 153 | // remove the trailing namespace separator for the next iteration |
154 | 154 | // of strrpos() |
155 | - $prefix = rtrim( $prefix, Psr4Autoloader::NS ); |
|
155 | + $prefix = rtrim($prefix, Psr4Autoloader::NS); |
|
156 | 156 | } |
157 | 157 | // never found a mapped file |
158 | 158 | return false; |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | * @return mixed Boolean false if no mapped file can be loaded, or the |
169 | 169 | * name of the mapped file that was loaded. |
170 | 170 | */ |
171 | - protected function loadMappedFile( $prefix, $relative_class ) { |
|
171 | + protected function loadMappedFile($prefix, $relative_class) { |
|
172 | 172 | // look through base directories for this namespace prefix |
173 | - foreach ( $this->prefixes( $prefix ) as $base_dir ) { |
|
173 | + foreach ($this->prefixes($prefix) as $base_dir) { |
|
174 | 174 | // replace the namespace prefix with the base directory, |
175 | 175 | // replace namespace separators with directory separators |
176 | 176 | // in the relative class name, append with .php |
177 | 177 | $file = $base_dir |
178 | - . str_replace( Psr4Autoloader::NS, DS, $relative_class ) |
|
178 | + . str_replace(Psr4Autoloader::NS, DS, $relative_class) |
|
179 | 179 | . '.php'; |
180 | 180 | // if the mapped file exists, require it |
181 | - if ( $this->requireFile( $file ) ) { |
|
181 | + if ($this->requireFile($file)) { |
|
182 | 182 | // yes, we're done |
183 | 183 | return $file; |
184 | 184 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param string $file The file to require. |
196 | 196 | * @return bool True if the file exists, false if not. |
197 | 197 | */ |
198 | - protected function requireFile( $file ) { |
|
199 | - if ( file_exists( $file ) ) { |
|
198 | + protected function requireFile($file) { |
|
199 | + if (file_exists($file)) { |
|
200 | 200 | require $file; |
201 | 201 | return true; |
202 | 202 | } |