@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Prepares incoming data from the json or $_REQUEST parameters for the models' |
57 | 57 | * "$query_params". |
58 | - * @param EE_Model_Field_Base $field_obj |
|
58 | + * @param \EE_Model_Field_Base $field_obj |
|
59 | 59 | * @param mixed $original_value |
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
@@ -77,6 +77,7 @@ discard block |
||
77 | 77 | * Prepares a field's value for display in the API |
78 | 78 | * @param \EE_Model_Field_Base $field_obj |
79 | 79 | * @param mixed $original_value |
80 | + * @param string $requested_version |
|
80 | 81 | * @return mixed |
81 | 82 | */ |
82 | 83 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
@@ -131,6 +132,9 @@ discard block |
||
131 | 132 | return $query_param_for_models; |
132 | 133 | } |
133 | 134 | |
135 | + /** |
|
136 | + * @return string |
|
137 | + */ |
|
134 | 138 | public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
135 | 139 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 140 | if($pos_of_star === FALSE){ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
25 | - exit( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | + exit('No direct script access allowed'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $requested_version |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
44 | - if( is_array( $original_value_maybe_array ) ) { |
|
43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
44 | + if (is_array($original_value_maybe_array)) { |
|
45 | 45 | $new_value_maybe_array = array(); |
46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
47 | - $new_value_maybe_array[ $array_key ] = self::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
47 | + $new_value_maybe_array[$array_key] = self::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $new_value_maybe_array = self::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
50 | + $new_value_maybe_array = self::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
51 | 51 | } |
52 | 52 | return $new_value_maybe_array; |
53 | 53 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
63 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
64 | 64 | $new_value = null; |
65 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
65 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | + && in_array($original_value, array(null, ''), true)) { |
|
67 | 67 | $new_value = EE_INF; |
68 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
69 | - $new_value = rest_parse_date( $original_value ); |
|
68 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
69 | + $new_value = rest_parse_date($original_value); |
|
70 | 70 | } else { |
71 | 71 | $new_value = $original_value; |
72 | 72 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | * @param mixed $original_value |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
83 | - if( $original_value === EE_INF ) { |
|
82 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
83 | + if ($original_value === EE_INF) { |
|
84 | 84 | $new_value = self::ee_inf_in_rest; |
85 | - } elseif( $field_obj instanceof \EE_Datetime_Field && |
|
86 | - $original_value instanceof \DateTime ) { |
|
87 | - $new_value = $original_value->format( 'c' ); |
|
88 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
85 | + } elseif ($field_obj instanceof \EE_Datetime_Field && |
|
86 | + $original_value instanceof \DateTime) { |
|
87 | + $new_value = $original_value->format('c'); |
|
88 | + $new_value = mysql_to_rfc3339($new_value); |
|
89 | 89 | } else { |
90 | 90 | $new_value = $original_value; |
91 | 91 | } |
92 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
92 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
93 | 93 | $new_value, |
94 | 94 | $field_obj, |
95 | 95 | $original_value, |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | * @param string $requested_version |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
108 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
109 | 109 | $query_param_for_models = array(); |
110 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
110 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
111 | 111 | $field = self::deduce_field_from_query_param( |
112 | - self::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
112 | + self::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
113 | 113 | $model |
114 | 114 | ); |
115 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
115 | + if ($field instanceof \EE_Model_Field_Base) { |
|
116 | 116 | //did they specify an operator? |
117 | - if( is_array( $query_param_value ) ) { |
|
118 | - $op = $query_param_value[ 0 ]; |
|
119 | - $value = $query_param_value[ 1 ]; |
|
120 | - $new_value = self::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
121 | - $translated_value = array( $op, $new_value ); |
|
117 | + if (is_array($query_param_value)) { |
|
118 | + $op = $query_param_value[0]; |
|
119 | + $value = $query_param_value[1]; |
|
120 | + $new_value = self::prepare_field_values_from_json($field, $value, $requested_version); |
|
121 | + $translated_value = array($op, $new_value); |
|
122 | 122 | } else { |
123 | - $translated_value = self::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
123 | + $translated_value = self::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
124 | 124 | } |
125 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
125 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
126 | 126 | } else { |
127 | 127 | //so it's not for a field, assume it's a logic query param key |
128 | - $query_param_for_models[ $query_param_key ] = self::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
128 | + $query_param_for_models[$query_param_key] = self::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | return $query_param_for_models; |
132 | 132 | } |
133 | 133 | |
134 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
134 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | - if($pos_of_star === FALSE){ |
|
136 | + if ($pos_of_star === FALSE) { |
|
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else { |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | * @throws EE_Error |
148 | 148 | * @return EE_Model_Field_Base |
149 | 149 | */ |
150 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
150 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
151 | 151 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
152 | 152 | //which will help us find the database table and column |
153 | 153 | |
154 | - $query_param_parts = explode(".",$query_param_name); |
|
155 | - if(empty($query_param_parts)){ |
|
156 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
154 | + $query_param_parts = explode(".", $query_param_name); |
|
155 | + if (empty($query_param_parts)) { |
|
156 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
157 | 157 | } |
158 | 158 | $number_of_parts = count($query_param_parts); |
159 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
160 | - if($number_of_parts == 1){ |
|
159 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
160 | + if ($number_of_parts == 1) { |
|
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else {// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
165 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
166 | 166 | } |
167 | - try{ |
|
167 | + try { |
|
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch (\EE_Error $e) { |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 136 | if($pos_of_star === FALSE){ |
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else{ |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
160 | 160 | if($number_of_parts == 1){ |
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else{// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | 165 | $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
166 | 166 | } |
167 | 167 | try{ |
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch(\EE_Error $e){ |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | /** |
4 | - * |
|
5 | - * Class Model_Data_Translator |
|
6 | - * |
|
7 | - * Class for translating data between the EE4 models and JSON. |
|
8 | - * Some of this class needs to interpret an incoming array of query params from |
|
9 | - * the REST API and prepare it for use by the models. Some of this code seems duplicated |
|
10 | - * fromt he models but it's anticipated to diverge (because providing parameters |
|
11 | - * in the REST API is sometimes more difficult than in PHP directly. Eg, providing an array like |
|
12 | - * array( 'where' => array( 'EVT_ID' => array( '<', 100 ) ) ) in PHP is easy, but in a querystring it needs to look like |
|
13 | - * "where[EVT_ID][]=<&where[EVT_ID][]=100" is less intuitive, so we may want |
|
14 | - * to allow REST API query parameters to diverge from the format accepted by models) |
|
15 | - * |
|
16 | - * @package Event Espresso |
|
17 | - * @subpackage |
|
18 | - * @author Mike Nelson |
|
19 | - * @since 4.8.36 |
|
20 | - * |
|
21 | - */ |
|
4 | + * |
|
5 | + * Class Model_Data_Translator |
|
6 | + * |
|
7 | + * Class for translating data between the EE4 models and JSON. |
|
8 | + * Some of this class needs to interpret an incoming array of query params from |
|
9 | + * the REST API and prepare it for use by the models. Some of this code seems duplicated |
|
10 | + * fromt he models but it's anticipated to diverge (because providing parameters |
|
11 | + * in the REST API is sometimes more difficult than in PHP directly. Eg, providing an array like |
|
12 | + * array( 'where' => array( 'EVT_ID' => array( '<', 100 ) ) ) in PHP is easy, but in a querystring it needs to look like |
|
13 | + * "where[EVT_ID][]=<&where[EVT_ID][]=100" is less intuitive, so we may want |
|
14 | + * to allow REST API query parameters to diverge from the format accepted by models) |
|
15 | + * |
|
16 | + * @package Event Espresso |
|
17 | + * @subpackage |
|
18 | + * @author Mike Nelson |
|
19 | + * @since 4.8.36 |
|
20 | + * |
|
21 | + */ |
|
22 | 22 | |
23 | 23 | |
24 | 24 | if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Prepares a field's value for display in the API |
|
78 | - * @param \EE_Model_Field_Base $field_obj |
|
79 | - * @param mixed $original_value |
|
80 | - * @return mixed |
|
81 | - */ |
|
77 | + * Prepares a field's value for display in the API |
|
78 | + * @param \EE_Model_Field_Base $field_obj |
|
79 | + * @param mixed $original_value |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | 82 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
83 | 83 | if( $original_value === EE_INF ) { |
84 | 84 | $new_value = self::ee_inf_in_rest; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $original_value, |
96 | 96 | $requested_version |
97 | 97 | ); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Prepares condition-query-parameters (like what's in where and having) from |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\model; |
3 | 3 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
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 | /** |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * @param \WP_REST_Request $request |
24 | 24 | * @return array|\WP_REST_Response |
25 | 25 | */ |
26 | - public static function handle_request_models_meta( \WP_REST_Request $request ) { |
|
26 | + public static function handle_request_models_meta(\WP_REST_Request $request) { |
|
27 | 27 | $controller = new Meta(); |
28 | - try{ |
|
28 | + try { |
|
29 | 29 | $matches = $controller->parse_route( |
30 | 30 | $request->get_route(), |
31 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . 'resources~', |
|
32 | - array( 'version' ) ); |
|
33 | - if( $matches instanceof \WP_REST_Response ) { |
|
31 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'resources~', |
|
32 | + array('version') ); |
|
33 | + if ($matches instanceof \WP_REST_Response) { |
|
34 | 34 | return $matches; |
35 | 35 | } |
36 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
37 | - return $controller->send_response( $controller->_get_models_metadata_entity() ); |
|
38 | - } catch( \Exception $e ) { |
|
39 | - return $controller->send_response( $e ); |
|
36 | + $controller->set_requested_version($matches['version']); |
|
37 | + return $controller->send_response($controller->_get_models_metadata_entity()); |
|
38 | + } catch (\Exception $e) { |
|
39 | + return $controller->send_response($e); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | * Gets the model metadata resource entity |
45 | 45 | * @return array for JSON response, describing all the models available in teh requested version |
46 | 46 | */ |
47 | - protected function _get_models_metadata_entity(){ |
|
47 | + protected function _get_models_metadata_entity() { |
|
48 | 48 | $response = array(); |
49 | - foreach( $this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname ){ |
|
50 | - $model = $this->get_model_version_info()->load_model( $model_name ); |
|
49 | + foreach ($this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname) { |
|
50 | + $model = $this->get_model_version_info()->load_model($model_name); |
|
51 | 51 | $fields_json = array(); |
52 | - foreach( $this->get_model_version_info()->fields_on_model_in_this_version( $model ) as $field_name => $field_obj ) { |
|
53 | - if( $this->get_model_version_info()->field_is_ignored( $field_obj ) ) { |
|
52 | + foreach ($this->get_model_version_info()->fields_on_model_in_this_version($model) as $field_name => $field_obj) { |
|
53 | + if ($this->get_model_version_info()->field_is_ignored($field_obj)) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | - if( $field_obj instanceof \EE_Boolean_Field ) { |
|
56 | + if ($field_obj instanceof \EE_Boolean_Field) { |
|
57 | 57 | $datatype = 'Boolean'; |
58 | - }elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
58 | + }elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
59 | 59 | $datatype = 'Number'; |
60 | - }elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
60 | + }elseif ($field_name instanceof \EE_Serialized_Text_Field) { |
|
61 | 61 | $datatype = 'Object'; |
62 | - }else{ |
|
62 | + } else { |
|
63 | 63 | $datatype = 'String'; |
64 | 64 | } |
65 | 65 | $default_value = Model_Data_Translator::prepare_field_value_for_json( |
@@ -70,30 +70,30 @@ discard block |
||
70 | 70 | $field_json = array( |
71 | 71 | 'name' => $field_name, |
72 | 72 | 'nicename' => $field_obj->get_nicename(), |
73 | - 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format( $field_obj ), |
|
74 | - 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format( $field_obj ), |
|
75 | - 'type' => str_replace('EE_', '', get_class( $field_obj ) ), |
|
73 | + 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format($field_obj), |
|
74 | + 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format($field_obj), |
|
75 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
76 | 76 | 'datatype' => $datatype, |
77 | 77 | 'nullable' => $field_obj->is_nullable(), |
78 | 78 | 'default' => $default_value, |
79 | 79 | 'table_alias' => $field_obj->get_table_alias(), |
80 | 80 | 'table_column' => $field_obj->get_table_column(), |
81 | 81 | ); |
82 | - $fields_json[ $field_json[ 'name' ] ] = $field_json; |
|
82 | + $fields_json[$field_json['name']] = $field_json; |
|
83 | 83 | |
84 | 84 | } |
85 | - $fields_json = array_merge( $fields_json, $this->get_model_version_info()->extra_resource_properties_for_model( $model ) ); |
|
86 | - $response[ $model_name ]['fields'] = apply_filters( 'FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model ); |
|
85 | + $fields_json = array_merge($fields_json, $this->get_model_version_info()->extra_resource_properties_for_model($model)); |
|
86 | + $response[$model_name]['fields'] = apply_filters('FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model); |
|
87 | 87 | $relations_json = array(); |
88 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
88 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
89 | 89 | $relation_json = array( |
90 | 90 | 'name' => $relation_name, |
91 | - 'type' => str_replace( 'EE_', '', get_class( $relation_obj ) ), |
|
91 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
92 | 92 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
93 | 93 | ); |
94 | - $relations_json[ $relation_name ] = $relation_json; |
|
94 | + $relations_json[$relation_name] = $relation_json; |
|
95 | 95 | } |
96 | - $response[ $model_name ][ 'relations' ] = apply_filters( 'FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model ); |
|
96 | + $response[$model_name]['relations'] = apply_filters('FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model); |
|
97 | 97 | } |
98 | 98 | return $response; |
99 | 99 | } |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @param \WP_REST_Response $rest_response_obj |
104 | 104 | * @return \WP_REST_Response |
105 | 105 | */ |
106 | - public static function filter_ee_metadata_into_index( \WP_REST_Response $rest_response_obj ) { |
|
106 | + public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj) { |
|
107 | 107 | $response_data = $rest_response_obj->get_data(); |
108 | 108 | $addons = array(); |
109 | - foreach( \EE_Registry::instance()->addons as $addon){ |
|
109 | + foreach (\EE_Registry::instance()->addons as $addon) { |
|
110 | 110 | $addon_json = array( |
111 | 111 | 'name' => $addon->name(), |
112 | 112 | 'version' => $addon->version() |
113 | 113 | ); |
114 | - $addons[ $addon_json[ 'name' ] ] = $addon_json; |
|
114 | + $addons[$addon_json['name']] = $addon_json; |
|
115 | 115 | } |
116 | - $response_data[ 'ee' ] = array( |
|
116 | + $response_data['ee'] = array( |
|
117 | 117 | 'version' => \EEM_System_Status::instance()->get_ee_version(), |
118 | 118 | 'addons' => $addons, |
119 | 119 | 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), |
120 | - 'served_core_versions' => array_keys( \EED_Core_Rest_Api::versions_served() ) |
|
120 | + 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()) |
|
121 | 121 | ); |
122 | - $rest_response_obj->set_data( $response_data ); |
|
122 | + $rest_response_obj->set_data($response_data); |
|
123 | 123 | return $rest_response_obj; |
124 | 124 | } |
125 | 125 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers; |
3 | 3 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
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 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | public function __construct() { |
52 | - $this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false; |
|
52 | + $this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Sets the version the user requested |
58 | 58 | * @param string $version eg '4.8' |
59 | 59 | */ |
60 | - public function set_requested_version( $version ) { |
|
60 | + public function set_requested_version($version) { |
|
61 | 61 | $this->_requested_version = $version; |
62 | 62 | } |
63 | 63 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @param string $key |
67 | 67 | * @param string|array $info |
68 | 68 | */ |
69 | - protected function _set_debug_info( $key, $info ){ |
|
70 | - $this->_debug_info[ $key ] = $info; |
|
69 | + protected function _set_debug_info($key, $info) { |
|
70 | + $this->_debug_info[$key] = $info; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @param boolean $use_ee_prefix whether to use the EE prefix on the header, or fallback to |
80 | 80 | * the standard WP one |
81 | 81 | */ |
82 | - protected function _set_response_header( $header_key, $value, $use_ee_prefix = true ) { |
|
83 | - if( is_array( $value ) ) { |
|
84 | - foreach( $value as $value_key => $value_value ) { |
|
85 | - $this->_set_response_header( $header_key . '[' . $value_key . ']', $value_value ); |
|
82 | + protected function _set_response_header($header_key, $value, $use_ee_prefix = true) { |
|
83 | + if (is_array($value)) { |
|
84 | + foreach ($value as $value_key => $value_value) { |
|
85 | + $this->_set_response_header($header_key.'['.$value_key.']', $value_value); |
|
86 | 86 | } |
87 | 87 | } else { |
88 | 88 | $prefix = $use_ee_prefix ? Base::header_prefix_for_ee : Base::header_prefix_for_wp; |
89 | - $this->_response_headers[ $prefix . $header_key ] = $value; |
|
89 | + $this->_response_headers[$prefix.$header_key] = $value; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return array |
96 | 96 | */ |
97 | 97 | protected function _get_response_headers() { |
98 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
98 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
99 | 99 | $this->_response_headers, |
100 | 100 | $this, |
101 | 101 | $this->_requested_version |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param \WP_Error $wp_error_response |
108 | 108 | * @return \WP_Error |
109 | 109 | */ |
110 | - protected function _add_ee_errors_to_response( \WP_Error $wp_error_response ) { |
|
110 | + protected function _add_ee_errors_to_response(\WP_Error $wp_error_response) { |
|
111 | 111 | $notices_during_checkin = \EE_Error::get_raw_notices(); |
112 | - if( ! empty( $notices_during_checkin[ 'errors' ] ) ) { |
|
113 | - foreach( $notices_during_checkin[ 'errors' ] as $error_code => $error_message ) { |
|
112 | + if ( ! empty($notices_during_checkin['errors'])) { |
|
113 | + foreach ($notices_during_checkin['errors'] as $error_code => $error_message) { |
|
114 | 114 | $wp_error_response->add( |
115 | - sanitize_key( $error_code ), |
|
116 | - strip_tags( $error_message ) ); |
|
115 | + sanitize_key($error_code), |
|
116 | + strip_tags($error_message) ); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | return $wp_error_response; |
@@ -131,27 +131,27 @@ discard block |
||
131 | 131 | * @param array|\WP_Error|\Exception $response |
132 | 132 | * @return \WP_REST_Response |
133 | 133 | */ |
134 | - public function send_response( $response ) { |
|
135 | - if( $response instanceof Rest_Exception ) { |
|
136 | - $response = new \WP_Error( $response->get_string_code(), $response->getMessage(), $response->get_data() ); |
|
134 | + public function send_response($response) { |
|
135 | + if ($response instanceof Rest_Exception) { |
|
136 | + $response = new \WP_Error($response->get_string_code(), $response->getMessage(), $response->get_data()); |
|
137 | 137 | } |
138 | - if( $response instanceof \Exception ) { |
|
138 | + if ($response instanceof \Exception) { |
|
139 | 139 | $code = $response->getCode() ? $response->getCode() : 'error_occurred'; |
140 | - $response = new \WP_Error( $code, $response->getMessage() ); |
|
140 | + $response = new \WP_Error($code, $response->getMessage()); |
|
141 | 141 | } |
142 | - if( $response instanceof \WP_Error ) { |
|
143 | - $response = $this->_add_ee_errors_to_response( $response ); |
|
144 | - $rest_response = $this->_create_rest_response_from_wp_error( $response ); |
|
145 | - }else{ |
|
146 | - $rest_response = new \WP_REST_Response( $response, 200 ); |
|
142 | + if ($response instanceof \WP_Error) { |
|
143 | + $response = $this->_add_ee_errors_to_response($response); |
|
144 | + $rest_response = $this->_create_rest_response_from_wp_error($response); |
|
145 | + } else { |
|
146 | + $rest_response = new \WP_REST_Response($response, 200); |
|
147 | 147 | } |
148 | 148 | $headers = array(); |
149 | - if( $this->_debug_mode && is_array( $this->_debug_info ) ) { |
|
150 | - foreach( $this->_debug_info as $debug_key => $debug_info ) { |
|
151 | - if( is_array( $debug_info ) ) { |
|
152 | - $debug_info = json_encode( $debug_info ); |
|
149 | + if ($this->_debug_mode && is_array($this->_debug_info)) { |
|
150 | + foreach ($this->_debug_info as $debug_key => $debug_info) { |
|
151 | + if (is_array($debug_info)) { |
|
152 | + $debug_info = json_encode($debug_info); |
|
153 | 153 | } |
154 | - $headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info; |
|
154 | + $headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | $headers = array_merge( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $this->_get_headers_from_ee_notices() |
161 | 161 | ); |
162 | 162 | |
163 | - $rest_response->set_headers( $headers ); |
|
163 | + $rest_response->set_headers($headers); |
|
164 | 164 | return $rest_response; |
165 | 165 | } |
166 | 166 | |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | * @param \WP_Error $wp_error |
172 | 172 | * @return \WP_REST_Response |
173 | 173 | */ |
174 | - protected function _create_rest_response_from_wp_error( \WP_Error $wp_error ) { |
|
174 | + protected function _create_rest_response_from_wp_error(\WP_Error $wp_error) { |
|
175 | 175 | $error_data = $wp_error->get_error_data(); |
176 | - if ( is_array( $error_data ) && isset( $error_data['status'] ) ) { |
|
176 | + if (is_array($error_data) && isset($error_data['status'])) { |
|
177 | 177 | $status = $error_data['status']; |
178 | 178 | } else { |
179 | 179 | $status = 500; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $errors = array(); |
183 | - foreach ( (array) $wp_error->errors as $code => $messages ) { |
|
184 | - foreach ( (array) $messages as $message ) { |
|
183 | + foreach ((array) $wp_error->errors as $code => $messages) { |
|
184 | + foreach ((array) $messages as $message) { |
|
185 | 185 | $errors[] = array( |
186 | 186 | 'code' => $code, |
187 | 187 | 'message' => $message, |
188 | - 'data' => $wp_error->get_error_data( $code ) |
|
188 | + 'data' => $wp_error->get_error_data($code) |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | } |
192 | - $data = isset( $errors[0] ) ? $errors[0] : array(); |
|
193 | - if ( count( $errors ) > 1 ) { |
|
192 | + $data = isset($errors[0]) ? $errors[0] : array(); |
|
193 | + if (count($errors) > 1) { |
|
194 | 194 | // Remove the primary error. |
195 | - array_shift( $errors ); |
|
195 | + array_shift($errors); |
|
196 | 196 | $data['additional_errors'] = $errors; |
197 | 197 | } |
198 | - return new \WP_REST_Response( $data, $status ); |
|
198 | + return new \WP_REST_Response($data, $status); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | protected function _get_headers_from_ee_notices() { |
206 | 206 | $headers = array(); |
207 | 207 | $notices = \EE_Error::get_raw_notices(); |
208 | - foreach( $notices as $notice_type => $sub_notices ) { |
|
209 | - if( ! is_array( $sub_notices ) ) { |
|
208 | + foreach ($notices as $notice_type => $sub_notices) { |
|
209 | + if ( ! is_array($sub_notices)) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - foreach( $sub_notices as $notice_code => $sub_notice ) { |
|
213 | - $headers[ 'X-EE4-Notices-' . \EEH_Inflector::humanize( $notice_type ) . '[' . $notice_code . ']' ] = strip_tags( $sub_notice ); |
|
212 | + foreach ($sub_notices as $notice_code => $sub_notice) { |
|
213 | + $headers['X-EE4-Notices-'.\EEH_Inflector::humanize($notice_type).'['.$notice_code.']'] = strip_tags($sub_notice); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | return apply_filters( |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * @param string $route |
229 | 229 | * @return string |
230 | 230 | */ |
231 | - public function get_requested_version( $route = null ) { |
|
231 | + public function get_requested_version($route = null) { |
|
232 | 232 | $matches = $this->parse_route( |
233 | 233 | $route, |
234 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '~', |
|
235 | - array( 'version' ) |
|
234 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'~', |
|
235 | + array('version') |
|
236 | 236 | ); |
237 | - if( isset( $matches[ 'version' ] ) ) { |
|
238 | - return $matches[ 'version' ]; |
|
237 | + if (isset($matches['version'])) { |
|
238 | + return $matches['version']; |
|
239 | 239 | } else { |
240 | 240 | return \EED_Core_Rest_Api::latest_rest_api_version(); |
241 | 241 | } |
@@ -260,23 +260,23 @@ discard block |
||
260 | 260 | * array( 'model' => 'foo', 'id' => 'bar' ) |
261 | 261 | * @throws \EE_Error if it couldn't be parsed |
262 | 262 | */ |
263 | - public function parse_route( $route, $regex, $match_keys ) { |
|
263 | + public function parse_route($route, $regex, $match_keys) { |
|
264 | 264 | $indexed_matches = array(); |
265 | - $success = preg_match( $regex, $route, $matches ); |
|
266 | - if( |
|
267 | - is_array( $matches ) ) { |
|
265 | + $success = preg_match($regex, $route, $matches); |
|
266 | + if ( |
|
267 | + is_array($matches) ) { |
|
268 | 268 | //skip the overall regex match. Who cares |
269 | - for( $i = 1; $i <= count( $match_keys ); $i++ ) { |
|
270 | - if( ! isset( $matches[ $i ] ) ) { |
|
269 | + for ($i = 1; $i <= count($match_keys); $i++) { |
|
270 | + if ( ! isset($matches[$i])) { |
|
271 | 271 | $success = false; |
272 | 272 | } else { |
273 | - $indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ]; |
|
273 | + $indexed_matches[$match_keys[$i - 1]] = $matches[$i]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
277 | - if( ! $success ) { |
|
277 | + if ( ! $success) { |
|
278 | 278 | throw new \EE_Error( |
279 | - __( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ), |
|
279 | + __('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'), |
|
280 | 280 | 'endpoint_parsing_error' |
281 | 281 | ); |
282 | 282 | } |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Base { |
21 | - protected static function _verify_current_user_can( $required_permission, $attempted_calculation ) { |
|
22 | - if( ! current_user_can( $required_permission ) ) { |
|
21 | + protected static function _verify_current_user_can($required_permission, $attempted_calculation) { |
|
22 | + if ( ! current_user_can($required_permission)) { |
|
23 | 23 | throw new Rest_Exception( |
24 | 24 | 'permission_denied', |
25 | 25 | sprintf( |
26 | - __( 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso' ), |
|
26 | + __('Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso'), |
|
27 | 27 | $attempted_calculation, |
28 | - \EEH_Inflector::pluralize_and_lower( self::get_resource_name() ), |
|
28 | + \EEH_Inflector::pluralize_and_lower(self::get_resource_name()), |
|
29 | 29 | $required_permission |
30 | 30 | ) |
31 | 31 | ); |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function get_resource_name() { |
40 | 40 | $classname = get_called_class(); |
41 | - return substr( $classname, strrpos( $classname, '\\' ) + 1 ); |
|
41 | + return substr($classname, strrpos($classname, '\\') + 1); |
|
42 | 42 | } |
43 | 43 | } |
@@ -3,18 +3,18 @@ |
||
3 | 3 | use EventEspresso\core\libraries\rest_api\controllers\Base; |
4 | 4 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
5 | 5 | /** |
6 | - * |
|
7 | - * Class Calculationshelpers |
|
8 | - * |
|
9 | - * Class for defining which model fields can be calculated, and performing those calculations |
|
10 | - * as requested |
|
11 | - * |
|
12 | - * @package Event Espresso |
|
13 | - * @subpackage |
|
14 | - * @author Mike Nelson |
|
15 | - * @since 4.8.35.rc.001 |
|
16 | - * |
|
17 | - */ |
|
6 | + * |
|
7 | + * Class Calculationshelpers |
|
8 | + * |
|
9 | + * Class for defining which model fields can be calculated, and performing those calculations |
|
10 | + * as requested |
|
11 | + * |
|
12 | + * @package Event Espresso |
|
13 | + * @subpackage |
|
14 | + * @author Mike Nelson |
|
15 | + * @since 4.8.35.rc.001 |
|
16 | + * |
|
17 | + */ |
|
18 | 18 | if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
19 | 19 | exit( 'No direct script access allowed' ); |
20 | 20 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since 4.8.35.rc.001 |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Calculated_Model_Fields { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * the WP_Request object, |
39 | 39 | * the controller object |
40 | 40 | */ |
41 | - public function mapping( $refresh = false ) { |
|
42 | - if( ! $this->_mapping || $refresh ) { |
|
41 | + public function mapping($refresh = false) { |
|
42 | + if ( ! $this->_mapping || $refresh) { |
|
43 | 43 | $this->_mapping = $this->_generate_new_mapping(); |
44 | 44 | } |
45 | 45 | return $this->_mapping; |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function _generate_new_mapping() { |
54 | 54 | $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
55 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
56 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
55 | + $event_calculations_class = $rest_api_calculations_namespace.'Event'; |
|
56 | + $datetime_calculations_class = $rest_api_calculations_namespace.'Datetime'; |
|
57 | 57 | return apply_filters( |
58 | 58 | 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
59 | 59 | array( |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @param \EEM_Base $model |
82 | 82 | * @return array allowable values for this field |
83 | 83 | */ |
84 | - public function retrieve_calculated_fields_for_model( \EEM_Base $model ) { |
|
84 | + public function retrieve_calculated_fields_for_model(\EEM_Base $model) { |
|
85 | 85 | $mapping = $this->mapping(); |
86 | - if( isset( $mapping[ $model->get_this_model_name() ] ) ) { |
|
87 | - return array_keys( $mapping[ $model->get_this_model_name() ] ); |
|
86 | + if (isset($mapping[$model->get_this_model_name()])) { |
|
87 | + return array_keys($mapping[$model->get_this_model_name()]); |
|
88 | 88 | } else { |
89 | 89 | return array(); |
90 | 90 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @return mixed|null |
104 | 104 | * @throws \EE_Error |
105 | 105 | */ |
106 | - public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) { |
|
106 | + public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) { |
|
107 | 107 | $mapping = $this->mapping(); |
108 | - if( isset( $mapping[ $model->get_this_model_name() ] ) |
|
109 | - && isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) { |
|
110 | - $classname = $mapping[ $model->get_this_model_name() ][ $field_name ]; |
|
111 | - return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller ); |
|
108 | + if (isset($mapping[$model->get_this_model_name()]) |
|
109 | + && isset($mapping[$model->get_this_model_name()][$field_name])) { |
|
110 | + $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
111 | + return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller); |
|
112 | 112 | } |
113 | 113 | throw new Rest_Exception( |
114 | 114 | 'calculated_field_does_not_exist', |
115 | 115 | sprintf( |
116 | - __( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), |
|
116 | + __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
117 | 117 | $field_name, |
118 | 118 | $model->get_this_model_name() |
119 | 119 | ) |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Rest_Exception extends \EE_Error { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $_wp_error_data = array(); |
26 | 26 | protected $_wp_error_code = ''; |
27 | - public function __construct( $string_code, $message, $wp_error_data = array(), $previous = null ) { |
|
27 | + public function __construct($string_code, $message, $wp_error_data = array(), $previous = null) { |
|
28 | 28 | parent::__construct( |
29 | 29 | $message, |
30 | 30 | 500, |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\helpers; |
3 | 3 | /** |
4 | - * |
|
5 | - * Class Exception |
|
6 | - * |
|
7 | - * similar to EE's EE_Error, except has space to hold the "data" we |
|
8 | - * want to eventually pass to WP_Error |
|
9 | - * |
|
10 | - * @package Event Espresso |
|
11 | - * @subpackage |
|
12 | - * @author Mike Nelson |
|
13 | - * @since $VID:$ |
|
14 | - * |
|
15 | - */ |
|
4 | + * |
|
5 | + * Class Exception |
|
6 | + * |
|
7 | + * similar to EE's EE_Error, except has space to hold the "data" we |
|
8 | + * want to eventually pass to WP_Error |
|
9 | + * |
|
10 | + * @package Event Espresso |
|
11 | + * @subpackage |
|
12 | + * @author Mike Nelson |
|
13 | + * @since $VID:$ |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
17 | 17 | exit( 'No direct script access allowed' ); |
18 | 18 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function __construct() { |
44 | 44 | // construct request stack and run middleware apps as soon as all WP plugins are loaded |
45 | - add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 ); |
|
45 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
46 | 46 | // set framework for the rest of EE to hook into when loading |
47 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 ); |
|
48 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 ); |
|
49 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 ); |
|
50 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
51 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 ); |
|
47 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
48 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
49 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
50 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
51 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | new EE_Load_Espresso_Core() |
66 | 66 | ); |
67 | 67 | $this->_request_stack->handle_request( |
68 | - new EE_Request( $_GET, $_POST, $_COOKIE ), |
|
68 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
69 | 69 | new EE_Response() |
70 | 70 | ); |
71 | 71 | $this->_request_stack->handle_response(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function load_autoloader() { |
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' ); |
|
81 | + espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php'); |
|
82 | 82 | EEH_Autoloader::instance(); |
83 | 83 | } |
84 | 84 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function set_autoloaders_for_required_files() { |
91 | 91 | // load interfaces |
92 | - espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' ); |
|
92 | + espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php'); |
|
93 | 93 | // load helpers |
94 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
94 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
95 | 95 | // load request stack |
96 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS ); |
|
96 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
97 | 97 | // load middleware |
98 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS ); |
|
98 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | // load middleware onto stack : FILO (First In Last Out) |
121 | - foreach ( (array)$stack_apps as $stack_app ) { |
|
121 | + foreach ((array) $stack_apps as $stack_app) { |
|
122 | 122 | //$request_stack_builder->push( $stack_app ); |
123 | - $request_stack_builder->unshift( $stack_app ); |
|
123 | + $request_stack_builder->unshift($stack_app); |
|
124 | 124 | } |
125 | 125 | return apply_filters( |
126 | 126 | 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * no other logic should be performed at this point |
138 | 138 | */ |
139 | 139 | public static function load_espresso_addons() { |
140 | - do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' ); |
|
140 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * we can determine if anything needs activating or upgrading |
150 | 150 | */ |
151 | 151 | public static function detect_activations_or_upgrades() { |
152 | - do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' ); |
|
152 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * we can load and set all of the system configurations |
162 | 162 | */ |
163 | 163 | public static function load_core_configuration() { |
164 | - do_action( 'AHEE__EE_Bootstrap__load_core_configuration' ); |
|
164 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * so that they are ready to be used throughout the system |
174 | 174 | */ |
175 | 175 | public static function register_shortcodes_modules_and_widgets() { |
176 | - do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' ); |
|
176 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * so let the fun begin... |
186 | 186 | */ |
187 | 187 | public static function brew_espresso() { |
188 | - do_action( 'AHEE__EE_Bootstrap__brew_espresso' ); |
|
188 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | * @param array $post |
61 | 61 | * @param array $cookie |
62 | 62 | */ |
63 | - public function __construct( $get, $post, $cookie ) { |
|
63 | + public function __construct($get, $post, $cookie) { |
|
64 | 64 | // grab request vars |
65 | 65 | $this->_get = $get; |
66 | 66 | $this->_post = $post; |
67 | 67 | $this->_cookie = $cookie; |
68 | - $this->_params = array_merge( $get, $post ); |
|
68 | + $this->_params = array_merge($get, $post); |
|
69 | 69 | // AJAX ??? |
70 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
71 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
70 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
71 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | * @param bool $override_ee |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function set( $key, $value, $override_ee = FALSE ) { |
|
122 | + public function set($key, $value, $override_ee = FALSE) { |
|
123 | 123 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
124 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
125 | - $this->_params[ $key ] = $value; |
|
124 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
125 | + $this->_params[$key] = $value; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param null $default |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get( $key, $default = NULL ) { |
|
140 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
139 | + public function get($key, $default = NULL) { |
|
140 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param $key |
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | - public function is_set( $key ) { |
|
153 | - return isset( $this->_params[ $key ] ) ? TRUE : FALSE; |
|
152 | + public function is_set($key) { |
|
153 | + return isset($this->_params[$key]) ? TRUE : FALSE; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @param $key |
163 | 163 | * @param bool $unset_from_global_too |
164 | 164 | */ |
165 | - public function un_set( $key, $unset_from_global_too = false ) { |
|
166 | - unset( $this->_params[ $key ] ); |
|
167 | - if ( $unset_from_global_too ) { |
|
168 | - unset( $_REQUEST[ $key ] ); |
|
165 | + public function un_set($key, $unset_from_global_too = false) { |
|
166 | + unset($this->_params[$key]); |
|
167 | + if ($unset_from_global_too) { |
|
168 | + unset($_REQUEST[$key]); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param WP $wp |
66 | 66 | * @return \EE_Request_Handler |
67 | 67 | */ |
68 | - public function __construct( $wp = null ) { |
|
68 | + public function __construct($wp = null) { |
|
69 | 69 | // grab request vars |
70 | 70 | // NOTE: WHEN MERGING TO 4.9 PLZ FAVOUR THE CHANGES IN 4.9 OVER THE FOLLOWING LINE |
71 | - $this->_params = array_merge( $_GET, $_POST ); |
|
71 | + $this->_params = array_merge($_GET, $_POST); |
|
72 | 72 | // AJAX ??? |
73 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
74 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
75 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
73 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
74 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
75 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @param WP $wp |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function parse_request( $wp = null ) { |
|
87 | + public function parse_request($wp = null) { |
|
88 | 88 | //if somebody forgot to provide us with WP, that's ok because its global |
89 | - if ( ! $wp instanceof WP ) { |
|
89 | + if ( ! $wp instanceof WP) { |
|
90 | 90 | global $wp; |
91 | 91 | } |
92 | - $this->set_request_vars( $wp ); |
|
92 | + $this->set_request_vars($wp); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * @param WP $wp |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function set_request_vars( $wp = null ) { |
|
105 | - if ( ! is_admin() ) { |
|
104 | + public function set_request_vars($wp = null) { |
|
105 | + if ( ! is_admin()) { |
|
106 | 106 | // set request post_id |
107 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
107 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
108 | 108 | // set request post name |
109 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
109 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
110 | 110 | // set request post_type |
111 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
111 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
112 | 112 | // true or false ? is this page being used by EE ? |
113 | 113 | $this->set_espresso_page(); |
114 | 114 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | * @param WP $wp |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function get_post_id_from_request( $wp = null ) { |
|
127 | - if ( ! $wp instanceof WP ){ |
|
126 | + public function get_post_id_from_request($wp = null) { |
|
127 | + if ( ! $wp instanceof WP) { |
|
128 | 128 | global $wp; |
129 | 129 | } |
130 | 130 | $post_id = null; |
131 | - if ( isset( $wp->query_vars['p'] )) { |
|
131 | + if (isset($wp->query_vars['p'])) { |
|
132 | 132 | $post_id = $wp->query_vars['p']; |
133 | 133 | } |
134 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
134 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
135 | 135 | $post_id = $wp->query_vars['page_id']; |
136 | 136 | } |
137 | - if ( ! $post_id && isset( $wp->request )) { |
|
138 | - if ( is_numeric( basename( $wp->request ))) { |
|
139 | - $post_id = basename( $wp->request ); |
|
137 | + if ( ! $post_id && isset($wp->request)) { |
|
138 | + if (is_numeric(basename($wp->request))) { |
|
139 | + $post_id = basename($wp->request); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | return $post_id; |
@@ -151,35 +151,35 @@ discard block |
||
151 | 151 | * @param WP $wp |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function get_post_name_from_request( $wp = null ) { |
|
155 | - if ( ! $wp instanceof WP ){ |
|
154 | + public function get_post_name_from_request($wp = null) { |
|
155 | + if ( ! $wp instanceof WP) { |
|
156 | 156 | global $wp; |
157 | 157 | } |
158 | 158 | $post_name = null; |
159 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
159 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
160 | 160 | $post_name = $wp->query_vars['name']; |
161 | 161 | } |
162 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
162 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
163 | 163 | $post_name = $wp->query_vars['pagename']; |
164 | 164 | } |
165 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
166 | - $possible_post_name = basename( $wp->request ); |
|
167 | - if ( ! is_numeric( $possible_post_name )) { |
|
165 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
166 | + $possible_post_name = basename($wp->request); |
|
167 | + if ( ! is_numeric($possible_post_name)) { |
|
168 | 168 | /** @type WPDB $wpdb */ |
169 | 169 | global $wpdb; |
170 | 170 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
171 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
172 | - if ( $possible_post_name ) { |
|
171 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
172 | + if ($possible_post_name) { |
|
173 | 173 | $post_name = $possible_post_name; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
177 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
177 | + if ( ! $post_name && $this->get('post_id')) { |
|
178 | 178 | /** @type WPDB $wpdb */ |
179 | 179 | global $wpdb; |
180 | 180 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
181 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
182 | - if( $possible_post_name ) { |
|
181 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
182 | + if ($possible_post_name) { |
|
183 | 183 | $post_name = $possible_post_name; |
184 | 184 | } |
185 | 185 | } |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @param WP $wp |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - public function get_post_type_from_request( $wp = null ) { |
|
199 | - if ( ! $wp instanceof WP ){ |
|
198 | + public function get_post_type_from_request($wp = null) { |
|
199 | + if ( ! $wp instanceof WP) { |
|
200 | 200 | global $wp; |
201 | 201 | } |
202 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
202 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param WP $wp |
210 | 210 | * @return bool|string|void |
211 | 211 | */ |
212 | - public function get_current_page_permalink( $wp = null ) { |
|
213 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
214 | - if ( $post_id ) { |
|
215 | - $current_page_permalink = get_permalink( $post_id ); |
|
212 | + public function get_current_page_permalink($wp = null) { |
|
213 | + $post_id = $this->get_post_id_from_request($wp); |
|
214 | + if ($post_id) { |
|
215 | + $current_page_permalink = get_permalink($post_id); |
|
216 | 216 | } else { |
217 | - if ( ! $wp instanceof WP ) { |
|
217 | + if ( ! $wp instanceof WP) { |
|
218 | 218 | global $wp; |
219 | 219 | } |
220 | - if ( $wp->request ) { |
|
221 | - $current_page_permalink = site_url( $wp->request ); |
|
220 | + if ($wp->request) { |
|
221 | + $current_page_permalink = site_url($wp->request); |
|
222 | 222 | } else { |
223 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
223 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | return $current_page_permalink; |
@@ -237,41 +237,41 @@ discard block |
||
237 | 237 | public function test_for_espresso_page() { |
238 | 238 | global $wp; |
239 | 239 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
240 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
240 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
241 | 241 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
242 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
243 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
244 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
242 | + if (is_array($espresso_CPT_taxonomies)) { |
|
243 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
244 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | 249 | // load espresso CPT endpoints |
250 | 250 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
251 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
252 | - $post_types = (array)$this->get( 'post_type' ); |
|
253 | - foreach ( $post_types as $post_type ) { |
|
251 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
252 | + $post_types = (array) $this->get('post_type'); |
|
253 | + foreach ($post_types as $post_type) { |
|
254 | 254 | // was a post name passed ? |
255 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
255 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
256 | 256 | // kk we know this is an espresso page, but is it a specific post ? |
257 | - if ( ! $this->get( 'post_name' ) ) { |
|
257 | + if ( ! $this->get('post_name')) { |
|
258 | 258 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
259 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
259 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
260 | 260 | // if the post type matches on of our then set the endpoint |
261 | - if ( $post_name ) { |
|
262 | - $this->set( 'post_name', $post_name ); |
|
261 | + if ($post_name) { |
|
262 | + $this->set('post_name', $post_name); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | } |
268 | - if ( $this->get( 'post_name' )) { |
|
268 | + if ($this->get('post_name')) { |
|
269 | 269 | // load all pages using espresso shortcodes |
270 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
270 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
271 | 271 | // make sure core pages are included |
272 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
272 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
273 | 273 | // was a post name passed ? |
274 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
274 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param null $value |
288 | 288 | * @return mixed |
289 | 289 | */ |
290 | - public function set_espresso_page( $value = null ) { |
|
290 | + public function set_espresso_page($value = null) { |
|
291 | 291 | $value = $value ? $value : $this->test_for_espresso_page(); |
292 | 292 | $this->_params['is_espresso_page'] = $value; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return mixed |
302 | 302 | */ |
303 | 303 | public function is_espresso_page() { |
304 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
304 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | * @param bool $override_ee |
326 | 326 | * @return void |
327 | 327 | */ |
328 | - public function set( $key, $value, $override_ee = false ) { |
|
328 | + public function set($key, $value, $override_ee = false) { |
|
329 | 329 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
330 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
331 | - $this->_params[ $key ] = $value; |
|
330 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
331 | + $this->_params[$key] = $value; |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param null $default |
343 | 343 | * @return mixed |
344 | 344 | */ |
345 | - public function get( $key, $default = null ) { |
|
346 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
345 | + public function get($key, $default = null) { |
|
346 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param $key |
356 | 356 | * @return boolean |
357 | 357 | */ |
358 | - public function is_set( $key ) { |
|
359 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
358 | + public function is_set($key) { |
|
359 | + return isset($this->_params[$key]) ? true : false; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param $key |
369 | 369 | * @return void |
370 | 370 | */ |
371 | - public function un_set( $key ) { |
|
372 | - unset( $this->_params[ $key ] ); |
|
371 | + public function un_set($key) { |
|
372 | + unset($this->_params[$key]); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param $value |
383 | 383 | * @return void |
384 | 384 | */ |
385 | - public function set_notice( $key, $value ) { |
|
386 | - $this->_notice[ $key ] = $value; |
|
385 | + public function set_notice($key, $value) { |
|
386 | + $this->_notice[$key] = $value; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param $key |
396 | 396 | * @return mixed |
397 | 397 | */ |
398 | - public function get_notice( $key ) { |
|
399 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
398 | + public function get_notice($key) { |
|
399 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param $string |
409 | 409 | * @return void |
410 | 410 | */ |
411 | - public function add_output( $string ) { |
|
411 | + public function add_output($string) { |
|
412 | 412 | $this->_output .= $string; |
413 | 413 | } |
414 | 414 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param $item |
431 | 431 | * @param $key |
432 | 432 | */ |
433 | - function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
434 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
433 | + function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
434 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param $b |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public function __set($a,$b) { return false; } |
|
444 | + public function __set($a, $b) { return false; } |
|
445 | 445 | |
446 | 446 | |
447 | 447 |