@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * this model. IE, there can be many other model objects related to one of this model's objects (but NOT through a JOIN table, |
33 | 33 | * which is the case for EE_HABTM_Relations). This knows how to join the models, |
34 | 34 | * get related models across the relation, and add-and-remove the relationships. |
35 | - * @param string $primary_pk_field See property description for details |
|
36 | - * @param string $parent_cpt_field This is the field that is "connected" to the $primary_cpt_field. See property desc for details. |
|
35 | + * @param string $primary_cpt_field See property description for details |
|
36 | + * @param string $primary_cpt_field This is the field that is "connected" to the $primary_cpt_field. See property desc for details. |
|
37 | 37 | * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model |
38 | 38 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
39 | 39 | */ |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * Basically this method gets called to verify if the incoming object needs to be manipulated somewhat because it is a revision save. If so, then we change things before sending back. We also do verifications when this IS NOT an revision because we always need to make sure that the autosave/revision has parent recorded (which is sometime delayed if the object is created/saved first by the autosave) |
192 | 192 | * |
193 | - * @param EE_Base_Class $this_model_obj |
|
193 | + * @param EE_Base_Class $this_obj |
|
194 | 194 | * @param EE_Base_Class $other_obj |
195 | 195 | * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
196 | 196 | * @return EE_Base_Class. ($other_obj); |
@@ -188,13 +188,13 @@ |
||
188 | 188 | |
189 | 189 | |
190 | 190 | /** |
191 | - * Basically this method gets called to verify if the incoming object needs to be manipulated somewhat because it is a revision save. If so, then we change things before sending back. We also do verifications when this IS NOT an revision because we always need to make sure that the autosave/revision has parent recorded (which is sometime delayed if the object is created/saved first by the autosave) |
|
192 | - * |
|
193 | - * @param EE_Base_Class $this_model_obj |
|
194 | - * @param EE_Base_Class $other_obj |
|
195 | - * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
|
196 | - * @return EE_Base_Class. ($other_obj); |
|
197 | - */ |
|
191 | + * Basically this method gets called to verify if the incoming object needs to be manipulated somewhat because it is a revision save. If so, then we change things before sending back. We also do verifications when this IS NOT an revision because we always need to make sure that the autosave/revision has parent recorded (which is sometime delayed if the object is created/saved first by the autosave) |
|
192 | + * |
|
193 | + * @param EE_Base_Class $this_model_obj |
|
194 | + * @param EE_Base_Class $other_obj |
|
195 | + * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
|
196 | + * @return EE_Base_Class. ($other_obj); |
|
197 | + */ |
|
198 | 198 | protected function _check_for_revision( $this_obj, $other_obj, $remove_relation = FALSE ) { |
199 | 199 | $pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name(); |
200 | 200 | //now we need to determine if we're in a WP revision save cause if we are we need to do some special handling |
@@ -60,8 +60,9 @@ discard block |
||
60 | 60 | $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj); |
61 | 61 | |
62 | 62 | //if is array, then we've already done the add_relation so let's get out |
63 | - if ( is_array( $other_model_obj ) ) |
|
64 | - return $other_model_obj[0]; |
|
63 | + if ( is_array( $other_model_obj ) ) { |
|
64 | + return $other_model_obj[0]; |
|
65 | + } |
|
65 | 66 | |
66 | 67 | //find the field on th eother model which is a foreign key to this model |
67 | 68 | $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | |
89 | 90 | |
90 | 91 | //if is array, then we've already done the add_relation so let's get out |
91 | - if ( is_array( $other_model_obj ) ) |
|
92 | - return $other_model_obj[0]; |
|
92 | + if ( is_array( $other_model_obj ) ) { |
|
93 | + return $other_model_obj[0]; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | |
95 | 97 | //find the field on th eother model which is a foreign key to this model |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * In this relation, the OTHER model ahs the foreign key pointing to this model |
6 | 6 | */ |
7 | -require_once( EE_MODELS . 'relations/EE_Has_Many_Relation.php'); |
|
8 | -class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation{ |
|
7 | +require_once(EE_MODELS.'relations/EE_Has_Many_Relation.php'); |
|
8 | +class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation { |
|
9 | 9 | |
10 | 10 | |
11 | 11 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model |
38 | 38 | * @param type $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
39 | 39 | */ |
40 | - function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null){ |
|
40 | + function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null) { |
|
41 | 41 | $this->_primary_cpt_field = $primary_cpt_field; |
42 | 42 | $this->_parent_pk_relation_field = $parent_pk_relation_field; |
43 | 43 | parent::__construct($block_deletes, $blocking_delete_error_message); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param EE_Base_Class/int $other_obj_or_id |
53 | 53 | * @return EE_Base_Class |
54 | 54 | */ |
55 | - function add_relation_to($this_obj_or_id, $other_obj_or_id ){ |
|
55 | + function add_relation_to($this_obj_or_id, $other_obj_or_id) { |
|
56 | 56 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
57 | 57 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj); |
61 | 61 | |
62 | 62 | //if is array, then we've already done the add_relation so let's get out |
63 | - if ( is_array( $other_model_obj ) ) |
|
63 | + if (is_array($other_model_obj)) |
|
64 | 64 | return $other_model_obj[0]; |
65 | 65 | |
66 | 66 | //find the field on th eother model which is a foreign key to this model |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param EE_Base_Class/int $other_obj_or_id |
81 | 81 | * @return EE_Base_Class |
82 | 82 | */ |
83 | - function remove_relation_to($this_obj_or_id, $other_obj_or_id){ |
|
83 | + function remove_relation_to($this_obj_or_id, $other_obj_or_id) { |
|
84 | 84 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id); |
85 | 85 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
86 | 86 | //handle possible revisions |
87 | - $other_model_obj = $this->_check_for_revision( $this_model_obj, $other_model_obj, TRUE ); |
|
87 | + $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, TRUE); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | //if is array, then we've already done the add_relation so let's get out |
91 | - if ( is_array( $other_model_obj ) ) |
|
91 | + if (is_array($other_model_obj)) |
|
92 | 92 | return $other_model_obj[0]; |
93 | 93 | |
94 | 94 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | //set that field on the other model to this model's ID |
100 | - if ( $this->_blocking_delete ) { |
|
101 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null,true); |
|
100 | + if ($this->_blocking_delete) { |
|
101 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
102 | 102 | $other_model_obj->save(); |
103 | 103 | } else { |
104 | 104 | $other_model_obj->delete(); |
105 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null,true); |
|
105 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
106 | 106 | return $other_model_obj; |
107 | 107 | } |
108 | 108 | return $other_model_obj; |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | * @param boolean $values_already_prepared_by_model_object @deprecated since 4.8.1 |
119 | 119 | * @return EE_Base_Class[] |
120 | 120 | */ |
121 | - public function get_all_related( $model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ) { |
|
122 | - if( $values_already_prepared_by_model_object !== false ) { |
|
123 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
121 | + public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
|
122 | + if ($values_already_prepared_by_model_object !== false) { |
|
123 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //if this is an autosave then we're going to get things differently |
127 | - if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { |
|
128 | - return $this->_do_autosave_get_all($model_object_or_id, $query_params ); |
|
127 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
128 | + return $this->_do_autosave_get_all($model_object_or_id, $query_params); |
|
129 | 129 | } |
130 | 130 | |
131 | - return parent::get_all_related( $model_object_or_id, $query_params ); |
|
131 | + return parent::get_all_related($model_object_or_id, $query_params); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -141,22 +141,22 @@ discard block |
||
141 | 141 | * @access protected |
142 | 142 | * @return EE_Base_Class[] |
143 | 143 | */ |
144 | - protected function _do_autosave_get_all( $model_object_or_id, $query_params, $deprecated = false ) { |
|
144 | + protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) { |
|
145 | 145 | |
146 | 146 | //first we check if the post_id for the incoming query is for an autosave. If it isn't that's what we want! |
147 | - $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
|
147 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
148 | 148 | |
149 | - $autosave = wp_get_post_autosave( $model_object_id ); |
|
149 | + $autosave = wp_get_post_autosave($model_object_id); |
|
150 | 150 | $id_to_use = $autosave ? $autosave->ID : $model_object_id; |
151 | 151 | |
152 | - $autosave_relations = parent::get_all_related( $id_to_use, $query_params ); |
|
152 | + $autosave_relations = parent::get_all_related($id_to_use, $query_params); |
|
153 | 153 | $parent_ids = $parents = array(); |
154 | 154 | $return_objs = array(); |
155 | 155 | |
156 | 156 | //k this is where things differ because NOW what we're going to do is get the PARENTS for the get all related (and we'll also start setting up the return_objs array containing related that DON'T have parent ids, for those that DON'T have parents to merge with our returned objects); |
157 | - foreach ( $autosave_relations as $a_r ) { |
|
157 | + foreach ($autosave_relations as $a_r) { |
|
158 | 158 | $pid = $a_r->parent(); |
159 | - if ( !empty( $pid ) ) { |
|
159 | + if ( ! empty($pid)) { |
|
160 | 160 | $parent_ids[] = $pid; |
161 | 161 | } else { |
162 | 162 | $return_objs[] = $a_r; |
@@ -164,17 +164,17 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | //we have to make sure we also include the ORIGINAL values |
167 | - $originals = parent::get_all_related($model_object_or_id, $query_params ); |
|
167 | + $originals = parent::get_all_related($model_object_or_id, $query_params); |
|
168 | 168 | |
169 | 169 | //merge $originals with $return_objs |
170 | - if ( $originals ) { |
|
170 | + if ($originals) { |
|
171 | 171 | $return_objs = array_merge($originals, $return_objs); |
172 | 172 | } |
173 | 173 | |
174 | 174 | //now we setup the query to get all the parents |
175 | - if ( !empty( $parent_ids ) ) { |
|
175 | + if ( ! empty($parent_ids)) { |
|
176 | 176 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name(); |
177 | - $query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids ); |
|
177 | + $query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids); |
|
178 | 178 | $parents = $this->get_other_model()->get_all($query_params); |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | //now merge parents with our current $return_objs and send back |
185 | - return array_merge( $parents, $return_objs ); |
|
185 | + return array_merge($parents, $return_objs); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -195,42 +195,42 @@ discard block |
||
195 | 195 | * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
196 | 196 | * @return EE_Base_Class. ($other_obj); |
197 | 197 | */ |
198 | - protected function _check_for_revision( $this_obj, $other_obj, $remove_relation = FALSE ) { |
|
198 | + protected function _check_for_revision($this_obj, $other_obj, $remove_relation = FALSE) { |
|
199 | 199 | $pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name(); |
200 | 200 | //now we need to determine if we're in a WP revision save cause if we are we need to do some special handling |
201 | - if ( $this_obj->post_type() == 'revision' ) { |
|
201 | + if ($this_obj->post_type() == 'revision') { |
|
202 | 202 | //first if $other_obj fk = this_obj pk then we know that this is a pk object, let's make sure there is a matching set for the autosave if there is then we save over it, if there isn't then we need to create a new one. |
203 | 203 | $parent_evt_id = $this_obj->parent(); |
204 | 204 | /*var_dump($parent_evt_id); |
205 | 205 | var_dump($this_obj); |
206 | 206 | var_dump($other_obj);/**/ |
207 | 207 | |
208 | - if ( !empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field) ) { |
|
208 | + if ( ! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
209 | 209 | //let's do query on this objects model to see if the incoming pk value on the obj matches any parents in this objects table. |
210 | - $has_parent_obj = $this->get_other_model()->get_one( array( array( $this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID() ) ) ); |
|
210 | + $has_parent_obj = $this->get_other_model()->get_one(array(array($this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID()))); |
|
211 | 211 | |
212 | - if ( $has_parent_obj ) { |
|
212 | + if ($has_parent_obj) { |
|
213 | 213 | //this makes sure the update on the current obj happens to the revision's row NOT the parent row. |
214 | 214 | |
215 | - $other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID()); |
|
216 | - $other_obj->set($pk_on_related_model, $has_parent_obj->ID() ); |
|
215 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
216 | + $other_obj->set($pk_on_related_model, $has_parent_obj->ID()); |
|
217 | 217 | $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
218 | 218 | |
219 | - if ( !$remove_relation ) { |
|
219 | + if ( ! $remove_relation) { |
|
220 | 220 | $other_obj->save(); |
221 | - return array( $other_obj ); |
|
222 | - } elseif ( $remove_relation && !$this->_blocking_delete) { |
|
221 | + return array($other_obj); |
|
222 | + } elseif ($remove_relation && ! $this->_blocking_delete) { |
|
223 | 223 | $other_obj->delete(); |
224 | 224 | $other_obj->set($this->_parent_pk_relation_field, NULL, true); |
225 | 225 | return array($other_obj); |
226 | 226 | } |
227 | 227 | |
228 | 228 | } else { |
229 | - $other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() ); |
|
230 | - $other_obj->set( $this->_primary_cpt_field, $this_obj->ID() ); |
|
229 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
230 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
231 | 231 | $other_obj->set($pk_on_related_model, NULL, true); //ensure we create a new row for the autosave with parent id the same as the incoming ID. |
232 | 232 | $other_obj->save(); //make sure we insert. |
233 | - return array( $other_obj ); |
|
233 | + return array($other_obj); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -243,24 +243,24 @@ discard block |
||
243 | 243 | } else { |
244 | 244 | |
245 | 245 | //we only need to do the below IF this is not a remove relation |
246 | - if ( !$remove_relation ) { |
|
246 | + if ( ! $remove_relation) { |
|
247 | 247 | //okay this is is a normal update/save/remove so, let's make sure the other object is not a revision of the current object. |
248 | 248 | //the other object will likely NOT have the correct fk on it (which is the primary_cpt_field_mame) so we must retrieve from the db to get that first. |
249 | 249 | $existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID()); |
250 | 250 | $potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : NULL; |
251 | 251 | |
252 | - if ( $parent_this_obj_id = wp_is_post_revision($potential_revision_id) ) { |
|
252 | + if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) { |
|
253 | 253 | //yes the OTHER object is linked to the revision of the parent, not the parent itself. That means we need to make the other_object an attachment of this_obj and then duplicate other_obj for the revision. |
254 | - $other_obj->set($this->_primary_cpt_field, $this_obj->ID() ); |
|
254 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
255 | 255 | $other_obj->save(); |
256 | 256 | |
257 | 257 | //now create a new other_obj and fill with details from existing object |
258 | 258 | $new_obj = $other_obj; |
259 | - $new_obj->set( $this->_primary_cpt_field, $potential_revision_id ); |
|
260 | - $new_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() ); |
|
261 | - $new_obj->set( $pk_on_related_model, NULL ); |
|
259 | + $new_obj->set($this->_primary_cpt_field, $potential_revision_id); |
|
260 | + $new_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
261 | + $new_obj->set($pk_on_related_model, NULL); |
|
262 | 262 | $new_obj->save(); |
263 | - return array( $new_obj ); |
|
263 | + return array($new_obj); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @since 4.5.0 |
558 | 558 | * |
559 | 559 | * @param string $meta_cap What meta capability is this mapping. |
560 | - * @param array $map_values array { |
|
560 | + * @param string[] $map_values array { |
|
561 | 561 | * //array of values that MUST match a count of 4. It's okay to send an empty string for capabilities that don't get mapped to. |
562 | 562 | * @type $map_values[0] string A string representing the model name. Required. String's |
563 | 563 | * should always be used when Menu Maps are registered via the |
@@ -625,8 +625,8 @@ discard block |
||
625 | 625 | * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
626 | 626 | * @since 4.6.x |
627 | 627 | * @param $caps |
628 | - * @param $cap |
|
629 | - * @param $user_id |
|
628 | + * @param string $cap |
|
629 | + * @param integer $user_id |
|
630 | 630 | * @param $args |
631 | 631 | * |
632 | 632 | * @return array |
@@ -111,7 +111,6 @@ discard block |
||
111 | 111 | |
112 | 112 | /** |
113 | 113 | * This sets the meta caps property. |
114 | - |
|
115 | 114 | * @since 4.5.0 |
116 | 115 | * |
117 | 116 | * @return void |
@@ -209,7 +208,7 @@ discard block |
||
209 | 208 | * capability mapping which will be used for accessing payment methods owned by |
210 | 209 | * other users. This is not fully implemented yet in the payment method ui. |
211 | 210 | * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well). |
212 | - **/ |
|
211 | + **/ |
|
213 | 212 | 'ee_manage_gateways', |
214 | 213 | 'ee_read_payment_method', |
215 | 214 | 'ee_read_payment_methods', |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * @package Event Espresso |
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
11 | - exit( 'No direct script access allowed' ); |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | //check if instantiated, and if not do so. |
72 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
72 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @since 4.5.0 |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function init_caps( $reset = false ) { |
|
102 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
101 | + public function init_caps($reset = false) { |
|
102 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
103 | 103 | $this->_caps_map = $this->_init_caps_map(); |
104 | - $this->init_role_caps( $reset ); |
|
104 | + $this->init_role_caps($reset); |
|
105 | 105 | $this->_set_meta_caps(); |
106 | 106 | } |
107 | 107 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
121 | 121 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
122 | 122 | |
123 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
123 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
124 | 124 | |
125 | 125 | //add filter for map_meta_caps but only if models can query. |
126 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
127 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
126 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
127 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function _get_default_meta_caps_array() { |
139 | 139 | static $default_meta_caps = array(); |
140 | - if ( empty( $default_meta_caps ) ) { |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | 141 | $default_meta_caps = array( |
142 | 142 | //edits |
143 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
144 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
147 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
149 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
150 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
151 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
143 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
144 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
145 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
146 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
147 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
148 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
149 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
150 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
151 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
152 | 152 | //reads |
153 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
154 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
155 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
156 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
157 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
158 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
159 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
153 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
154 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
155 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
156 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
157 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
158 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
159 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
160 | 160 | |
161 | 161 | //deletes |
162 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
163 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
166 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
168 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
169 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
170 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
162 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
163 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
164 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
165 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
166 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
167 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
168 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
169 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
170 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | return $default_meta_caps; |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array actual users capabilities |
193 | 193 | */ |
194 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
194 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
195 | 195 | //loop through our _meta_caps array |
196 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
197 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
196 | + foreach ($this->_meta_caps as $meta_map) { |
|
197 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | $meta_map->ensure_is_model(); |
201 | 201 | |
202 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
202 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
203 | 203 | } |
204 | 204 | return $caps; |
205 | 205 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
367 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
368 | 368 | return $caps; |
369 | 369 | } |
370 | 370 | |
@@ -381,26 +381,26 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
384 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
385 | 385 | |
386 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
386 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
387 | 387 | |
388 | 388 | //first let's determine if these caps have already been set. |
389 | - $caps_set_before = get_option( self::option_name, array() ); |
|
389 | + $caps_set_before = get_option(self::option_name, array()); |
|
390 | 390 | //if not reset, see what caps are new for each role. if they're new, add them. |
391 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
392 | - foreach ( $caps_for_role as $cap ) { |
|
391 | + foreach ($caps_map as $role => $caps_for_role) { |
|
392 | + foreach ($caps_for_role as $cap) { |
|
393 | 393 | //first check we haven't already added this cap before, or it's a reset |
394 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
395 | - $this->add_cap_to_role( $role, $cap ); |
|
396 | - $caps_set_before[ $role ][] = $cap; |
|
394 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
395 | + $this->add_cap_to_role($role, $cap); |
|
396 | + $caps_set_before[$role][] = $cap; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | 401 | //now let's just save the cap that has been set. |
402 | - update_option( self::option_name, $caps_set_before ); |
|
403 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
402 | + update_option(self::option_name, $caps_set_before); |
|
403 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | * @param bool $grant Whether to grant access to this cap on this role. |
420 | 420 | * @return void |
421 | 421 | */ |
422 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
423 | - $role = get_role( $role ); |
|
424 | - if ( $role instanceof WP_Role ) { |
|
425 | - $role->add_cap( $cap, $grant ); |
|
422 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
423 | + $role = get_role($role); |
|
424 | + if ($role instanceof WP_Role) { |
|
425 | + $role->add_cap($cap, $grant); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public function remove_cap_from_role( $role, $cap ) { |
|
446 | - $role = get_role( $role ); |
|
447 | - if ( $role instanceof WP_Role ) { |
|
448 | - $role->remove_cap( $cap ); |
|
445 | + public function remove_cap_from_role($role, $cap) { |
|
446 | + $role = get_role($role); |
|
447 | + if ($role instanceof WP_Role) { |
|
448 | + $role->remove_cap($cap); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return bool Whether user can or not. |
468 | 468 | */ |
469 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
469 | + public function current_user_can($cap, $context, $id = 0) { |
|
470 | 470 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
471 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
472 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
473 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
471 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
472 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
473 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return bool Whether user can or not. |
489 | 489 | */ |
490 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
490 | + public function user_can($user, $cap, $context, $id = 0) { |
|
491 | 491 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
492 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
493 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
494 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
492 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
493 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
494 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return bool Whether user can or not. |
513 | 513 | */ |
514 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
515 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
514 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
515 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
516 | 516 | |
517 | 517 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
518 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
519 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
518 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
519 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
520 | 520 | return $user_can; |
521 | 521 | } |
522 | 522 | |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return array |
534 | 534 | */ |
535 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
535 | + public function get_ee_capabilities($role = 'administrator') { |
|
536 | 536 | $capabilities = $this->_init_caps_map(); |
537 | - if ( empty( $role ) ) { |
|
537 | + if (empty($role)) { |
|
538 | 538 | return $capabilities; |
539 | 539 | } |
540 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
540 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * } |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function __construct( $meta_cap, $map_values ) { |
|
588 | + public function __construct($meta_cap, $map_values) { |
|
589 | 589 | $this->meta_cap = $meta_cap; |
590 | 590 | //verify there are four args in the $map_values array; |
591 | - if ( count( $map_values ) !== 4 ) { |
|
592 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
591 | + if (count($map_values) !== 4) { |
|
592 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | //set properties |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Makes it so this object stops filtering caps |
605 | 605 | */ |
606 | - public function remove_filters(){ |
|
607 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
606 | + public function remove_filters() { |
|
607 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | */ |
620 | 620 | public function ensure_is_model() { |
621 | 621 | //is it already instantiated? |
622 | - if ( $this->_model instanceof EEM_Base ) { |
|
622 | + if ($this->_model instanceof EEM_Base) { |
|
623 | 623 | return; |
624 | 624 | } |
625 | 625 | |
626 | 626 | //ensure model name is string |
627 | 627 | $this->_model_name = (string) $this->_model_name; |
628 | 628 | //error proof if the name has EEM in it |
629 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
629 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
630 | 630 | |
631 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
631 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
632 | 632 | |
633 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
634 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
633 | + if ( ! $this->_model instanceof EEM_Base) { |
|
634 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
651 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
650 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
651 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return array actual users capabilities |
668 | 668 | */ |
669 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
669 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -698,28 +698,28 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array actual users capabilities |
700 | 700 | */ |
701 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
701 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
702 | 702 | //only process if we're checking our mapped_cap |
703 | - if ( $cap !== $this->meta_cap ) { |
|
703 | + if ($cap !== $this->meta_cap) { |
|
704 | 704 | return $caps; |
705 | 705 | } |
706 | 706 | |
707 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
707 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
708 | 708 | |
709 | 709 | //if no obj then let's just do cap |
710 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
710 | + if ( ! $obj instanceof EE_Base_Class) { |
|
711 | 711 | $caps[] = $cap; |
712 | 712 | return $caps; |
713 | 713 | } |
714 | 714 | |
715 | - if ( $obj instanceof EE_CPT_Base ) { |
|
715 | + if ($obj instanceof EE_CPT_Base) { |
|
716 | 716 | //if the item author is set and the user is the author... |
717 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
718 | - if ( empty( $this->published_cap ) ) { |
|
717 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
718 | + if (empty($this->published_cap)) { |
|
719 | 719 | $caps[] = $cap; |
720 | 720 | } else { |
721 | 721 | //if obj is published... |
722 | - if ( $obj->status() == 'publish' ) { |
|
722 | + if ($obj->status() == 'publish') { |
|
723 | 723 | $caps[] = $this->published_cap; |
724 | 724 | } else { |
725 | 725 | $caps[] = $cap; |
@@ -727,21 +727,21 @@ discard block |
||
727 | 727 | } |
728 | 728 | } else { |
729 | 729 | //the user is trying to edit someone else's obj |
730 | - if ( ! empty( $this->others_cap ) ) { |
|
730 | + if ( ! empty($this->others_cap)) { |
|
731 | 731 | $caps[] = $this->others_cap; |
732 | 732 | } |
733 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
733 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
734 | 734 | $caps[] = $this->published_cap; |
735 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
735 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
736 | 736 | $caps[] = $this->private_cap; |
737 | 737 | } |
738 | 738 | } |
739 | 739 | } else { |
740 | 740 | //not a cpt object so handled differently |
741 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
741 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
742 | 742 | $caps[] = $cap; |
743 | 743 | } else { |
744 | - if ( ! empty( $this->others_cap ) ) { |
|
744 | + if ( ! empty($this->others_cap)) { |
|
745 | 745 | $caps[] = $this->others_cap; |
746 | 746 | } |
747 | 747 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | * |
779 | 779 | * @return array actual users capabilities |
780 | 780 | */ |
781 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
782 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
781 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
782 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -811,45 +811,45 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return array actual users capabilities |
813 | 813 | */ |
814 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
814 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
815 | 815 | //only process if we're checking our mapped cap; |
816 | - if ( $cap !== $this->meta_cap ) { |
|
816 | + if ($cap !== $this->meta_cap) { |
|
817 | 817 | return $caps; |
818 | 818 | } |
819 | 819 | |
820 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
820 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
821 | 821 | |
822 | 822 | //if no obj then let's just do cap |
823 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
823 | + if ( ! $obj instanceof EE_Base_Class) { |
|
824 | 824 | $caps[] = $cap; |
825 | 825 | return $caps; |
826 | 826 | } |
827 | 827 | |
828 | - if ( $obj instanceof EE_CPT_Base ) { |
|
829 | - $status_obj = get_post_status_object( $obj->status() ); |
|
830 | - if ( $status_obj->public ) { |
|
828 | + if ($obj instanceof EE_CPT_Base) { |
|
829 | + $status_obj = get_post_status_object($obj->status()); |
|
830 | + if ($status_obj->public) { |
|
831 | 831 | $caps[] = $cap; |
832 | 832 | return $caps; |
833 | 833 | } |
834 | 834 | |
835 | 835 | //if the item author is set and the user is the author... |
836 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
836 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
837 | 837 | $caps[] = $cap; |
838 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
838 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
839 | 839 | //the user is trying to view someone else's obj |
840 | 840 | $caps[] = $this->private_cap; |
841 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
841 | + } elseif ( ! empty($this->others_cap)) { |
|
842 | 842 | $caps[] = $this->others_cap; |
843 | 843 | } else { |
844 | 844 | $caps[] = $cap; |
845 | 845 | } |
846 | 846 | } else { |
847 | 847 | //not a cpt object so handled differently |
848 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
848 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
849 | 849 | $caps[] = $cap; |
850 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
850 | + } elseif ( ! empty($this->private_cap)) { |
|
851 | 851 | $caps[] = $this->private_cap; |
852 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
852 | + } elseif ( ! empty($this->others_cap)) { |
|
853 | 853 | $caps[] = $this->others_cap; |
854 | 854 | } else { |
855 | 855 | $caps[] = $cap; |
@@ -886,30 +886,30 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array actual users capabilities |
888 | 888 | */ |
889 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
889 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
890 | 890 | //only process if we're checking our mapped_cap |
891 | - if ( $cap !== $this->meta_cap ) { |
|
891 | + if ($cap !== $this->meta_cap) { |
|
892 | 892 | return $caps; |
893 | 893 | } |
894 | 894 | |
895 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
895 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
896 | 896 | |
897 | 897 | //if no obj then let's just do cap |
898 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
898 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
899 | 899 | $caps[] = $cap; |
900 | 900 | return $caps; |
901 | 901 | } |
902 | 902 | |
903 | 903 | $is_global = $obj->is_global(); |
904 | 904 | |
905 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
906 | - if ( $is_global ) { |
|
907 | - $caps[] = $this->private_cap; |
|
905 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
906 | + if ($is_global) { |
|
907 | + $caps[] = $this->private_cap; |
|
908 | 908 | } else { |
909 | 909 | $caps[] = $cap; |
910 | 910 | } |
911 | 911 | } else { |
912 | - if ( $is_global ) { |
|
912 | + if ($is_global) { |
|
913 | 913 | $caps[] = $this->private_cap; |
914 | 914 | } else { |
915 | 915 | $caps[] = $this->others_cap; |
@@ -947,16 +947,16 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return array actual users capabilities |
949 | 949 | */ |
950 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
950 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
951 | 951 | //only process if we're checking our mapped_cap |
952 | - if ( $cap !== $this->meta_cap ) { |
|
952 | + if ($cap !== $this->meta_cap) { |
|
953 | 953 | return $caps; |
954 | 954 | } |
955 | 955 | |
956 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
956 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
957 | 957 | |
958 | 958 | //if no obj then let's just do cap |
959 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
959 | + if ( ! $obj instanceof EE_Base_Class) { |
|
960 | 960 | $caps[] = $cap; |
961 | 961 | return $caps; |
962 | 962 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
965 | 965 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
966 | 966 | |
967 | - if ( $is_system ) { |
|
967 | + if ($is_system) { |
|
968 | 968 | $caps[] = $this->private_cap; |
969 | 969 | } else { |
970 | 970 | $caps[] = $cap; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * update_espresso_config |
314 | 314 | * |
315 | 315 | * @access public |
316 | - * @return bool |
|
316 | + * @return boolean|null |
|
317 | 317 | */ |
318 | 318 | protected function _reset_espresso_addon_config() { |
319 | 319 | $this->_config_option_names = array(); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @param string $name |
382 | 382 | * @param string $config_class |
383 | 383 | * @param EE_Config_Base $config_obj |
384 | - * @param array $tests_to_run |
|
384 | + * @param integer[] $tests_to_run |
|
385 | 385 | * @param bool $display_errors |
386 | 386 | * @return bool TRUE on success, FALSE on fail |
387 | 387 | */ |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | |
1443 | 1443 | |
1444 | 1444 | /** |
1445 | - * @return array |
|
1445 | + * @return integer[] |
|
1446 | 1446 | */ |
1447 | 1447 | public function get_critical_pages_array() { |
1448 | 1448 | return array( |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | |
1456 | 1456 | |
1457 | 1457 | /** |
1458 | - * @return array |
|
1458 | + * @return string[] |
|
1459 | 1459 | */ |
1460 | 1460 | public function get_critical_pages_shortcodes_array() { |
1461 | 1461 | return array( |
@@ -1778,7 +1778,7 @@ discard block |
||
1778 | 1778 | * class constructor |
1779 | 1779 | * |
1780 | 1780 | * @access public |
1781 | - * @param null $CNT_ISO |
|
1781 | + * @param string $CNT_ISO |
|
1782 | 1782 | * @return \EE_Currency_Config |
1783 | 1783 | */ |
1784 | 1784 | public function __construct( $CNT_ISO = NULL ) { |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * |
4 | 6 | * Class EE_Payment_Method_Manager |
@@ -139,7 +141,7 @@ discard block |
||
139 | 141 | if(isset($this->_payment_method_types[$payment_method_name])){ |
140 | 142 | require_once($this->_payment_method_types[$payment_method_name]); |
141 | 143 | return true; |
142 | - }else{ |
|
144 | + } else{ |
|
143 | 145 | return false; |
144 | 146 | } |
145 | 147 | } |
@@ -159,7 +161,7 @@ discard block |
||
159 | 161 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
160 | 162 | } |
161 | 163 | return $payment_methods; |
162 | - }else{ |
|
164 | + } else{ |
|
163 | 165 | return array_keys($this->_payment_method_types); |
164 | 166 | } |
165 | 167 | } |
@@ -242,7 +244,7 @@ discard block |
||
242 | 244 | } |
243 | 245 | } |
244 | 246 | |
245 | - }else{ |
|
247 | + } else{ |
|
246 | 248 | $payment_method->set_active(); |
247 | 249 | $payment_method->save(); |
248 | 250 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | public $map_settings = null; |
90 | 90 | |
91 | 91 | /** |
92 | - * |
|
93 | - * @deprecated |
|
94 | - * @var EE_Gateway_Config |
|
95 | - */ |
|
92 | + * |
|
93 | + * @deprecated |
|
94 | + * @var EE_Gateway_Config |
|
95 | + */ |
|
96 | 96 | public $gateway = null; |
97 | 97 | |
98 | 98 | /** |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | |
583 | 583 | /** |
584 | 584 | * update_config |
585 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
585 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
586 | 586 | * |
587 | 587 | * @access public |
588 | 588 | * @param string $section |
@@ -1606,51 +1606,51 @@ discard block |
||
1606 | 1606 | class EE_Organization_Config extends EE_Config_Base { |
1607 | 1607 | |
1608 | 1608 | /** |
1609 | - * @var string $name |
|
1610 | - * eg EE4.1 |
|
1611 | - */ |
|
1609 | + * @var string $name |
|
1610 | + * eg EE4.1 |
|
1611 | + */ |
|
1612 | 1612 | public $name; |
1613 | 1613 | |
1614 | 1614 | /** |
1615 | - * @var string $address_1 |
|
1616 | - * eg 123 Onna Road |
|
1617 | - */ |
|
1615 | + * @var string $address_1 |
|
1616 | + * eg 123 Onna Road |
|
1617 | + */ |
|
1618 | 1618 | public $address_1; |
1619 | 1619 | |
1620 | 1620 | /** |
1621 | - * @var string $address_2 |
|
1622 | - * eg PO Box 123 |
|
1623 | - */ |
|
1621 | + * @var string $address_2 |
|
1622 | + * eg PO Box 123 |
|
1623 | + */ |
|
1624 | 1624 | public $address_2; |
1625 | 1625 | |
1626 | 1626 | /** |
1627 | - * @var string $city |
|
1628 | - * eg Inna City |
|
1629 | - */ |
|
1627 | + * @var string $city |
|
1628 | + * eg Inna City |
|
1629 | + */ |
|
1630 | 1630 | public $city; |
1631 | 1631 | |
1632 | 1632 | /** |
1633 | - * @var int $STA_ID |
|
1634 | - * eg 4 |
|
1635 | - */ |
|
1633 | + * @var int $STA_ID |
|
1634 | + * eg 4 |
|
1635 | + */ |
|
1636 | 1636 | public $STA_ID; |
1637 | 1637 | |
1638 | 1638 | /** |
1639 | - * @var string $CNT_ISO |
|
1640 | - * eg US |
|
1641 | - */ |
|
1639 | + * @var string $CNT_ISO |
|
1640 | + * eg US |
|
1641 | + */ |
|
1642 | 1642 | public $CNT_ISO; |
1643 | 1643 | |
1644 | 1644 | /** |
1645 | - * @var string $zip |
|
1646 | - * eg 12345 or V1A 2B3 |
|
1647 | - */ |
|
1645 | + * @var string $zip |
|
1646 | + * eg 12345 or V1A 2B3 |
|
1647 | + */ |
|
1648 | 1648 | public $zip; |
1649 | 1649 | |
1650 | 1650 | /** |
1651 | - * @var string $email |
|
1652 | - * eg [email protected] |
|
1653 | - */ |
|
1651 | + * @var string $email |
|
1652 | + * eg [email protected] |
|
1653 | + */ |
|
1654 | 1654 | public $email; |
1655 | 1655 | |
1656 | 1656 | |
@@ -1669,9 +1669,9 @@ discard block |
||
1669 | 1669 | public $vat; |
1670 | 1670 | |
1671 | 1671 | /** |
1672 | - * @var string $logo_url |
|
1673 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1674 | - */ |
|
1672 | + * @var string $logo_url |
|
1673 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1674 | + */ |
|
1675 | 1675 | public $logo_url; |
1676 | 1676 | |
1677 | 1677 | |
@@ -1765,55 +1765,55 @@ discard block |
||
1765 | 1765 | class EE_Currency_Config extends EE_Config_Base { |
1766 | 1766 | |
1767 | 1767 | /** |
1768 | - * @var string $code |
|
1769 | - * eg 'US' |
|
1770 | - */ |
|
1768 | + * @var string $code |
|
1769 | + * eg 'US' |
|
1770 | + */ |
|
1771 | 1771 | public $code; |
1772 | 1772 | |
1773 | 1773 | /** |
1774 | - * @var string $name |
|
1775 | - * eg 'Dollar' |
|
1776 | - */ |
|
1774 | + * @var string $name |
|
1775 | + * eg 'Dollar' |
|
1776 | + */ |
|
1777 | 1777 | public $name; |
1778 | 1778 | |
1779 | 1779 | /** |
1780 | - * plural name |
|
1781 | - * @var string $plural |
|
1782 | - * eg 'Dollars' |
|
1783 | - */ |
|
1780 | + * plural name |
|
1781 | + * @var string $plural |
|
1782 | + * eg 'Dollars' |
|
1783 | + */ |
|
1784 | 1784 | public $plural; |
1785 | 1785 | |
1786 | 1786 | /** |
1787 | - * currency sign |
|
1788 | - * @var string $sign |
|
1789 | - * eg '$' |
|
1790 | - */ |
|
1787 | + * currency sign |
|
1788 | + * @var string $sign |
|
1789 | + * eg '$' |
|
1790 | + */ |
|
1791 | 1791 | public $sign; |
1792 | 1792 | |
1793 | 1793 | /** |
1794 | - * Whether the currency sign should come before the number or not |
|
1795 | - * @var boolean $sign_b4 |
|
1796 | - */ |
|
1794 | + * Whether the currency sign should come before the number or not |
|
1795 | + * @var boolean $sign_b4 |
|
1796 | + */ |
|
1797 | 1797 | public $sign_b4; |
1798 | 1798 | |
1799 | 1799 | /** |
1800 | - * How many digits should come after the decimal place |
|
1801 | - * @var int $dec_plc |
|
1802 | - */ |
|
1800 | + * How many digits should come after the decimal place |
|
1801 | + * @var int $dec_plc |
|
1802 | + */ |
|
1803 | 1803 | public $dec_plc; |
1804 | 1804 | |
1805 | 1805 | /** |
1806 | - * Symbol to use for decimal mark |
|
1807 | - * @var string $dec_mrk |
|
1808 | - * eg '.' |
|
1809 | - */ |
|
1806 | + * Symbol to use for decimal mark |
|
1807 | + * @var string $dec_mrk |
|
1808 | + * eg '.' |
|
1809 | + */ |
|
1810 | 1810 | public $dec_mrk; |
1811 | 1811 | |
1812 | 1812 | /** |
1813 | - * Symbol to use for thousands |
|
1814 | - * @var string $thsnds |
|
1815 | - * eg ',' |
|
1816 | - */ |
|
1813 | + * Symbol to use for thousands |
|
1814 | + * @var string $thsnds |
|
1815 | + * eg ',' |
|
1816 | + */ |
|
1817 | 1817 | public $thsnds; |
1818 | 1818 | |
1819 | 1819 | |
@@ -1881,13 +1881,13 @@ discard block |
||
1881 | 1881 | * whether or not to show alternate payment options during the reg process if payment status is pending |
1882 | 1882 | * @var boolean $show_pending_payment_options |
1883 | 1883 | */ |
1884 | - public $show_pending_payment_options; |
|
1884 | + public $show_pending_payment_options; |
|
1885 | 1885 | |
1886 | 1886 | /** |
1887 | 1887 | * Whether to skip the registration confirmation page |
1888 | 1888 | * @var boolean $skip_reg_confirmation |
1889 | 1889 | */ |
1890 | - public $skip_reg_confirmation; |
|
1890 | + public $skip_reg_confirmation; |
|
1891 | 1891 | |
1892 | 1892 | /** |
1893 | 1893 | * an array of SPCO reg steps where: |
@@ -1898,64 +1898,64 @@ discard block |
||
1898 | 1898 | * "slug" => the URL param used to trigger the reg step |
1899 | 1899 | * @var array $reg_steps |
1900 | 1900 | */ |
1901 | - public $reg_steps; |
|
1901 | + public $reg_steps; |
|
1902 | 1902 | |
1903 | 1903 | /** |
1904 | 1904 | * Whether registration confirmation should be the last page of SPCO |
1905 | 1905 | * @var boolean $reg_confirmation_last |
1906 | 1906 | */ |
1907 | - public $reg_confirmation_last; |
|
1907 | + public $reg_confirmation_last; |
|
1908 | 1908 | |
1909 | 1909 | /** |
1910 | 1910 | * Whether or not to enable the EE Bot Trap |
1911 | 1911 | * @var boolean $use_bot_trap |
1912 | 1912 | */ |
1913 | - public $use_bot_trap; |
|
1913 | + public $use_bot_trap; |
|
1914 | 1914 | |
1915 | 1915 | /** |
1916 | 1916 | * Whether or not to encrypt some data sent by the EE Bot Trap |
1917 | 1917 | * @var boolean $use_encryption |
1918 | 1918 | */ |
1919 | - public $use_encryption; |
|
1919 | + public $use_encryption; |
|
1920 | 1920 | |
1921 | 1921 | /** |
1922 | 1922 | * Whether or not to use ReCaptcha |
1923 | 1923 | * @var boolean $use_captcha |
1924 | 1924 | */ |
1925 | - public $use_captcha; |
|
1925 | + public $use_captcha; |
|
1926 | 1926 | |
1927 | 1927 | /** |
1928 | 1928 | * ReCaptcha Theme |
1929 | 1929 | * @var string $recaptcha_theme |
1930 | 1930 | * options: 'dark ', 'light' |
1931 | 1931 | */ |
1932 | - public $recaptcha_theme; |
|
1932 | + public $recaptcha_theme; |
|
1933 | 1933 | |
1934 | 1934 | /** |
1935 | 1935 | * ReCaptcha Type |
1936 | 1936 | * @var string $recaptcha_type |
1937 | 1937 | * options: 'audio', 'image' |
1938 | 1938 | */ |
1939 | - public $recaptcha_type; |
|
1939 | + public $recaptcha_type; |
|
1940 | 1940 | |
1941 | 1941 | /** |
1942 | 1942 | * ReCaptcha language |
1943 | 1943 | * @var string $recaptcha_language |
1944 | 1944 | * eg 'en' |
1945 | 1945 | */ |
1946 | - public $recaptcha_language; |
|
1946 | + public $recaptcha_language; |
|
1947 | 1947 | |
1948 | 1948 | /** |
1949 | 1949 | * ReCaptcha public key |
1950 | 1950 | * @var string $recaptcha_publickey |
1951 | 1951 | */ |
1952 | - public $recaptcha_publickey; |
|
1952 | + public $recaptcha_publickey; |
|
1953 | 1953 | |
1954 | 1954 | /** |
1955 | 1955 | * ReCaptcha private key |
1956 | 1956 | * @var string $recaptcha_privatekey |
1957 | 1957 | */ |
1958 | - public $recaptcha_privatekey; |
|
1958 | + public $recaptcha_privatekey; |
|
1959 | 1959 | |
1960 | 1960 | /** |
1961 | 1961 | * ReCaptcha width |
@@ -2021,58 +2021,58 @@ discard block |
||
2021 | 2021 | class EE_Admin_Config extends EE_Config_Base { |
2022 | 2022 | |
2023 | 2023 | /** |
2024 | - * @var boolean $use_personnel_manager |
|
2025 | - */ |
|
2024 | + * @var boolean $use_personnel_manager |
|
2025 | + */ |
|
2026 | 2026 | public $use_personnel_manager; |
2027 | 2027 | |
2028 | 2028 | /** |
2029 | - * @var boolean $use_dashboard_widget |
|
2030 | - */ |
|
2029 | + * @var boolean $use_dashboard_widget |
|
2030 | + */ |
|
2031 | 2031 | public $use_dashboard_widget; |
2032 | 2032 | |
2033 | 2033 | /** |
2034 | - * @var int $events_in_dashboard |
|
2035 | - */ |
|
2034 | + * @var int $events_in_dashboard |
|
2035 | + */ |
|
2036 | 2036 | public $events_in_dashboard; |
2037 | 2037 | |
2038 | 2038 | /** |
2039 | - * @var boolean $use_event_timezones |
|
2040 | - */ |
|
2039 | + * @var boolean $use_event_timezones |
|
2040 | + */ |
|
2041 | 2041 | public $use_event_timezones; |
2042 | 2042 | |
2043 | 2043 | /** |
2044 | - * @var boolean $use_full_logging |
|
2045 | - */ |
|
2044 | + * @var boolean $use_full_logging |
|
2045 | + */ |
|
2046 | 2046 | public $use_full_logging; |
2047 | 2047 | |
2048 | 2048 | /** |
2049 | - * @var string $log_file_name |
|
2050 | - */ |
|
2049 | + * @var string $log_file_name |
|
2050 | + */ |
|
2051 | 2051 | public $log_file_name; |
2052 | 2052 | |
2053 | 2053 | /** |
2054 | - * @var string $debug_file_name |
|
2055 | - */ |
|
2054 | + * @var string $debug_file_name |
|
2055 | + */ |
|
2056 | 2056 | public $debug_file_name; |
2057 | 2057 | |
2058 | 2058 | /** |
2059 | - * @var boolean $use_remote_logging |
|
2060 | - */ |
|
2059 | + * @var boolean $use_remote_logging |
|
2060 | + */ |
|
2061 | 2061 | public $use_remote_logging; |
2062 | 2062 | |
2063 | 2063 | /** |
2064 | - * @var string $remote_logging_url |
|
2065 | - */ |
|
2064 | + * @var string $remote_logging_url |
|
2065 | + */ |
|
2066 | 2066 | public $remote_logging_url; |
2067 | 2067 | |
2068 | 2068 | /** |
2069 | - * @var boolean $show_reg_footer |
|
2070 | - */ |
|
2069 | + * @var boolean $show_reg_footer |
|
2070 | + */ |
|
2071 | 2071 | public $show_reg_footer; |
2072 | 2072 | |
2073 | 2073 | /** |
2074 | - * @var string $affiliate_id |
|
2075 | - */ |
|
2074 | + * @var string $affiliate_id |
|
2075 | + */ |
|
2076 | 2076 | public $affiliate_id; |
2077 | 2077 | |
2078 | 2078 | |
@@ -2146,43 +2146,43 @@ discard block |
||
2146 | 2146 | class EE_Template_Config extends EE_Config_Base { |
2147 | 2147 | |
2148 | 2148 | /** |
2149 | - * @var boolean $enable_default_style |
|
2150 | - */ |
|
2149 | + * @var boolean $enable_default_style |
|
2150 | + */ |
|
2151 | 2151 | public $enable_default_style; |
2152 | 2152 | |
2153 | 2153 | /** |
2154 | - * @var string $custom_style_sheet |
|
2155 | - */ |
|
2154 | + * @var string $custom_style_sheet |
|
2155 | + */ |
|
2156 | 2156 | public $custom_style_sheet; |
2157 | 2157 | |
2158 | 2158 | /** |
2159 | - * @var boolean $display_address_in_regform |
|
2160 | - */ |
|
2159 | + * @var boolean $display_address_in_regform |
|
2160 | + */ |
|
2161 | 2161 | public $display_address_in_regform; |
2162 | 2162 | |
2163 | 2163 | /** |
2164 | - * @var int $display_description_on_multi_reg_page |
|
2165 | - */ |
|
2164 | + * @var int $display_description_on_multi_reg_page |
|
2165 | + */ |
|
2166 | 2166 | public $display_description_on_multi_reg_page; |
2167 | 2167 | |
2168 | 2168 | /** |
2169 | - * @var boolean $use_custom_templates |
|
2170 | - */ |
|
2169 | + * @var boolean $use_custom_templates |
|
2170 | + */ |
|
2171 | 2171 | public $use_custom_templates; |
2172 | 2172 | |
2173 | 2173 | /** |
2174 | - * @var string $current_espresso_theme |
|
2175 | - */ |
|
2174 | + * @var string $current_espresso_theme |
|
2175 | + */ |
|
2176 | 2176 | public $current_espresso_theme; |
2177 | 2177 | |
2178 | 2178 | /** |
2179 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2180 | - */ |
|
2179 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2180 | + */ |
|
2181 | 2181 | public $EED_Event_Single; |
2182 | 2182 | |
2183 | 2183 | /** |
2184 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2185 | - */ |
|
2184 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2185 | + */ |
|
2186 | 2186 | public $EED_Events_Archive; |
2187 | 2187 | |
2188 | 2188 | |
@@ -2215,78 +2215,78 @@ discard block |
||
2215 | 2215 | class EE_Map_Config extends EE_Config_Base { |
2216 | 2216 | |
2217 | 2217 | /** |
2218 | - * @var boolean $use_google_maps |
|
2219 | - */ |
|
2218 | + * @var boolean $use_google_maps |
|
2219 | + */ |
|
2220 | 2220 | public $use_google_maps; |
2221 | 2221 | |
2222 | 2222 | /** |
2223 | - * @var int $event_details_map_width |
|
2224 | - */ |
|
2223 | + * @var int $event_details_map_width |
|
2224 | + */ |
|
2225 | 2225 | public $event_details_map_width; |
2226 | 2226 | |
2227 | 2227 | /** |
2228 | - * @var int $event_details_map_height |
|
2229 | - */ |
|
2228 | + * @var int $event_details_map_height |
|
2229 | + */ |
|
2230 | 2230 | public $event_details_map_height; |
2231 | 2231 | |
2232 | 2232 | /** |
2233 | - * @var int $event_details_map_zoom |
|
2234 | - */ |
|
2233 | + * @var int $event_details_map_zoom |
|
2234 | + */ |
|
2235 | 2235 | public $event_details_map_zoom; |
2236 | 2236 | |
2237 | 2237 | /** |
2238 | - * @var boolean $event_details_display_nav |
|
2239 | - */ |
|
2238 | + * @var boolean $event_details_display_nav |
|
2239 | + */ |
|
2240 | 2240 | public $event_details_display_nav; |
2241 | 2241 | |
2242 | 2242 | /** |
2243 | - * @var boolean $event_details_nav_size |
|
2244 | - */ |
|
2243 | + * @var boolean $event_details_nav_size |
|
2244 | + */ |
|
2245 | 2245 | public $event_details_nav_size; |
2246 | 2246 | |
2247 | 2247 | /** |
2248 | - * @var string $event_details_control_type |
|
2249 | - */ |
|
2248 | + * @var string $event_details_control_type |
|
2249 | + */ |
|
2250 | 2250 | public $event_details_control_type; |
2251 | 2251 | |
2252 | 2252 | /** |
2253 | - * @var string $event_details_map_align |
|
2254 | - */ |
|
2253 | + * @var string $event_details_map_align |
|
2254 | + */ |
|
2255 | 2255 | public $event_details_map_align; |
2256 | 2256 | |
2257 | 2257 | /** |
2258 | - * @var int $event_list_map_width |
|
2259 | - */ |
|
2258 | + * @var int $event_list_map_width |
|
2259 | + */ |
|
2260 | 2260 | public $event_list_map_width; |
2261 | 2261 | |
2262 | 2262 | /** |
2263 | - * @var int $event_list_map_height |
|
2264 | - */ |
|
2263 | + * @var int $event_list_map_height |
|
2264 | + */ |
|
2265 | 2265 | public $event_list_map_height; |
2266 | 2266 | |
2267 | 2267 | /** |
2268 | - * @var int $event_list_map_zoom |
|
2269 | - */ |
|
2268 | + * @var int $event_list_map_zoom |
|
2269 | + */ |
|
2270 | 2270 | public $event_list_map_zoom; |
2271 | 2271 | |
2272 | 2272 | /** |
2273 | - * @var boolean $event_list_display_nav |
|
2274 | - */ |
|
2273 | + * @var boolean $event_list_display_nav |
|
2274 | + */ |
|
2275 | 2275 | public $event_list_display_nav; |
2276 | 2276 | |
2277 | 2277 | /** |
2278 | - * @var boolean $event_list_nav_size |
|
2279 | - */ |
|
2278 | + * @var boolean $event_list_nav_size |
|
2279 | + */ |
|
2280 | 2280 | public $event_list_nav_size; |
2281 | 2281 | |
2282 | 2282 | /** |
2283 | - * @var string $event_list_control_type |
|
2284 | - */ |
|
2283 | + * @var string $event_list_control_type |
|
2284 | + */ |
|
2285 | 2285 | public $event_list_control_type; |
2286 | 2286 | |
2287 | 2287 | /** |
2288 | - * @var string $event_list_map_align |
|
2289 | - */ |
|
2288 | + * @var string $event_list_map_align |
|
2289 | + */ |
|
2290 | 2290 | public $event_list_map_align; |
2291 | 2291 | |
2292 | 2292 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function instance() { |
130 | 130 | // check if class object is instantiated, and instantiated properly |
131 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Config) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode) |
146 | 146 | * @return EE_Config |
147 | 147 | */ |
148 | - public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){ |
|
149 | - if ( $hard_reset ) { |
|
148 | + public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) { |
|
149 | + if ($hard_reset) { |
|
150 | 150 | self::$_instance->_config_option_names = array(); |
151 | 151 | self::$_instance->_initialize_config(); |
152 | 152 | self::$_instance->update_espresso_config(); |
153 | 153 | } |
154 | - if( self::$_instance instanceof EE_Config ){ |
|
154 | + if (self::$_instance instanceof EE_Config) { |
|
155 | 155 | self::$_instance->shutdown(); |
156 | 156 | } |
157 | 157 | self::$_instance = NULL; |
158 | 158 | //we don't need to reset the static properties imo because those should |
159 | 159 | //only change when a module is added or removed. Currently we don't |
160 | 160 | //support removing a module during a request when it previously existed |
161 | - if( $reinstantiate ){ |
|
161 | + if ($reinstantiate) { |
|
162 | 162 | return self::instance(); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | return NULL; |
165 | 165 | } |
166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return \EE_Config |
175 | 175 | */ |
176 | 176 | private function __construct() { |
177 | - do_action( 'AHEE__EE_Config__construct__begin',$this ); |
|
178 | - $this->_config_option_names = get_option( 'ee_config_option_names', array() ); |
|
177 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
178 | + $this->_config_option_names = get_option('ee_config_option_names', array()); |
|
179 | 179 | // setup empty config classes |
180 | 180 | $this->_initialize_config(); |
181 | 181 | // load existing EE site settings |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | // confirm everything loaded correctly and set filtered defaults if not |
184 | 184 | $this->_verify_config(); |
185 | 185 | // register shortcodes and modules |
186 | - add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 ); |
|
186 | + add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999); |
|
187 | 187 | // initialize shortcodes and modules |
188 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' )); |
|
188 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
189 | 189 | // register widgets |
190 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
190 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
191 | 191 | // shutdown |
192 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
192 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
193 | 193 | // construct__end hook |
194 | - do_action( 'AHEE__EE_Config__construct__end',$this ); |
|
194 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
195 | 195 | // hardcoded hack |
196 | 196 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return string current theme set. |
205 | 205 | */ |
206 | 206 | public static function get_current_theme() { |
207 | - return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
207 | + return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -238,27 +238,27 @@ discard block |
||
238 | 238 | */ |
239 | 239 | private function _load_core_config() { |
240 | 240 | // load_core_config__start hook |
241 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
241 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
242 | 242 | $espresso_config = $this->get_espresso_config(); |
243 | - foreach ( $espresso_config as $config => $settings ) { |
|
243 | + foreach ($espresso_config as $config => $settings) { |
|
244 | 244 | // load_core_config__start hook |
245 | - $settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this ); |
|
246 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
247 | - $this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
245 | + $settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this); |
|
246 | + if (is_object($settings) && property_exists($this, $config)) { |
|
247 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
248 | 248 | //call configs populate method to ensure any defaults are set for empty values. |
249 | - if ( method_exists( $settings, 'populate' ) ) { |
|
249 | + if (method_exists($settings, 'populate')) { |
|
250 | 250 | $this->{$config}->populate(); |
251 | 251 | } |
252 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
252 | + if (method_exists($settings, 'do_hooks')) { |
|
253 | 253 | $this->{$config}->do_hooks(); |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) { |
|
257 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) { |
|
258 | 258 | $this->update_espresso_config(); |
259 | 259 | } |
260 | 260 | // load_core_config__end hook |
261 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
261 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -272,40 +272,40 @@ discard block |
||
272 | 272 | protected function _verify_config() { |
273 | 273 | |
274 | 274 | $this->core = $this->core instanceof EE_Core_Config |
275 | - ? $this->core : new EE_Core_Config(); |
|
276 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
275 | + ? $this->core : new EE_Core_Config(); |
|
276 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
277 | 277 | |
278 | 278 | $this->organization = $this->organization instanceof EE_Organization_Config |
279 | - ? $this->organization : new EE_Organization_Config(); |
|
280 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
279 | + ? $this->organization : new EE_Organization_Config(); |
|
280 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
281 | 281 | |
282 | 282 | $this->currency = $this->currency instanceof EE_Currency_Config |
283 | 283 | ? $this->currency : new EE_Currency_Config(); |
284 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
284 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
285 | 285 | |
286 | 286 | $this->registration = $this->registration instanceof EE_Registration_Config |
287 | 287 | ? $this->registration : new EE_Registration_Config(); |
288 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
288 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
289 | 289 | |
290 | 290 | $this->admin = $this->admin instanceof EE_Admin_Config |
291 | 291 | ? $this->admin : new EE_Admin_Config(); |
292 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
292 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
293 | 293 | |
294 | 294 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
295 | 295 | ? $this->template_settings : new EE_Template_Config(); |
296 | - $this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings ); |
|
296 | + $this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings); |
|
297 | 297 | |
298 | 298 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
299 | 299 | ? $this->map_settings : new EE_Map_Config(); |
300 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
300 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
301 | 301 | |
302 | 302 | $this->environment = $this->environment instanceof EE_Environment_Config |
303 | 303 | ? $this->environment : new EE_Environment_Config(); |
304 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
304 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
305 | 305 | |
306 | 306 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
307 | 307 | ? $this->gateway : new EE_Gateway_Config(); |
308 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
308 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
309 | 309 | |
310 | 310 | } |
311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function get_espresso_config() { |
321 | 321 | // grab espresso configuration |
322 | - return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() )); |
|
322 | + return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array())); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * @param $old_value |
333 | 333 | * @param $value |
334 | 334 | */ |
335 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
335 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
336 | 336 | // make sure we're checking the ee config |
337 | - if ( $option == 'ee_config' ) { |
|
337 | + if ($option == 'ee_config') { |
|
338 | 338 | // run a loose comparison of the old value against the new value for type and properties, |
339 | 339 | // but NOT exact instance like WP update_option does |
340 | - if ( $value != $old_value ) { |
|
340 | + if ($value != $old_value) { |
|
341 | 341 | // if they are NOT the same, then remove the hook, |
342 | 342 | // which means the subsequent update results will be based solely on the update query results |
343 | 343 | // the reason we do this is because, as stated above, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | // the string it sees in the db looks the same as the new one it has been passed!!! |
353 | 353 | // This results in the query returning an "affected rows" value of ZERO, |
354 | 354 | // which gets returned immediately by WP update_option and looks like an error. |
355 | - remove_action( 'update_option', array( $this, 'check_config_updated' )); |
|
355 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | */ |
368 | 368 | protected function _reset_espresso_addon_config() { |
369 | 369 | $this->_config_option_names = array(); |
370 | - foreach( $this->addons as $addon_name => $addon_config_obj ) { |
|
371 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
372 | - $config_class = get_class( $addon_config_obj ); |
|
373 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
374 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE ); |
|
370 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
371 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
372 | + $config_class = get_class($addon_config_obj); |
|
373 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
374 | + $this->update_config('addons', $addon_name, $addon_config_obj, FALSE); |
|
375 | 375 | } |
376 | 376 | $this->addons->{$addon_name} = NULL; |
377 | 377 | } |
@@ -387,17 +387,17 @@ discard block |
||
387 | 387 | * @param bool $add_error |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | - public function update_espresso_config( $add_success = FALSE, $add_error = TRUE ) { |
|
390 | + public function update_espresso_config($add_success = FALSE, $add_error = TRUE) { |
|
391 | 391 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
392 | 392 | //$clone = clone( self::$_instance ); |
393 | 393 | //self::$_instance = NULL; |
394 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this ); |
|
394 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
395 | 395 | $this->_reset_espresso_addon_config(); |
396 | 396 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
397 | 397 | // but BEFORE the actual update occurs |
398 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
398 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
399 | 399 | // now update "ee_config" |
400 | - $saved = update_option( 'ee_config', $this ); |
|
400 | + $saved = update_option('ee_config', $this); |
|
401 | 401 | // if not saved... check if the hook we just added still exists; |
402 | 402 | // if it does, it means one of two things: |
403 | 403 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -408,25 +408,25 @@ discard block |
||
408 | 408 | // but just means no update occurred, so don't display an error to the user. |
409 | 409 | // BUT... if update_option returns FALSE, AND the hook is missing, |
410 | 410 | // then it means that something truly went wrong |
411 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved; |
|
411 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
412 | 412 | // remove our action since we don't want it in the system anymore |
413 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
414 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
413 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
414 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
415 | 415 | //self::$_instance = $clone; |
416 | 416 | //unset( $clone ); |
417 | 417 | // if config remains the same or was updated successfully |
418 | - if ( $saved ) { |
|
419 | - if ( $add_success ) { |
|
418 | + if ($saved) { |
|
419 | + if ($add_success) { |
|
420 | 420 | EE_Error::add_success( |
421 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
421 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
422 | 422 | __FILE__, __FUNCTION__, __LINE__ |
423 | 423 | ); |
424 | 424 | } |
425 | 425 | return TRUE; |
426 | 426 | } else { |
427 | - if ( $add_error ) { |
|
427 | + if ($add_error) { |
|
428 | 428 | EE_Error::add_error( |
429 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
429 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
430 | 430 | __FILE__, __FUNCTION__, __LINE__ |
431 | 431 | ); |
432 | 432 | } |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | $name = '', |
453 | 453 | $config_class = '', |
454 | 454 | $config_obj = NULL, |
455 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
455 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
456 | 456 | $display_errors = TRUE |
457 | 457 | ) { |
458 | 458 | try { |
459 | - foreach ( $tests_to_run as $test ) { |
|
460 | - switch ( $test ) { |
|
459 | + foreach ($tests_to_run as $test) { |
|
460 | + switch ($test) { |
|
461 | 461 | |
462 | 462 | // TEST #1 : check that section was set |
463 | 463 | case 1 : |
464 | - if ( empty( $section ) ) { |
|
465 | - if ( $display_errors ) { |
|
464 | + if (empty($section)) { |
|
465 | + if ($display_errors) { |
|
466 | 466 | throw new EE_Error( |
467 | 467 | sprintf( |
468 | - __( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ), |
|
468 | + __('No configuration section has been provided while attempting to save "%s".', 'event_espresso'), |
|
469 | 469 | $config_class |
470 | 470 | ) |
471 | 471 | ); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | // TEST #2 : check that settings section exists |
478 | 478 | case 2 : |
479 | - if ( ! isset( $this->{$section} ) ) { |
|
480 | - if ( $display_errors ) { |
|
479 | + if ( ! isset($this->{$section} )) { |
|
480 | + if ($display_errors) { |
|
481 | 481 | throw new EE_Error( |
482 | - sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
483 | - $section ) |
|
482 | + sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'), |
|
483 | + $section) |
|
484 | 484 | ); |
485 | 485 | } |
486 | 486 | return false; |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | // TEST #3 : check that section is the proper format |
491 | 491 | case 3 : |
492 | 492 | if ( |
493 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
493 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
494 | 494 | ) { |
495 | - if ( $display_errors ) { |
|
495 | + if ($display_errors) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | - __( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ), |
|
498 | + __('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'), |
|
499 | 499 | $section |
500 | 500 | ) |
501 | 501 | ); |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | |
507 | 507 | // TEST #4 : check that config section name has been set |
508 | 508 | case 4 : |
509 | - if ( empty( $name ) ) { |
|
510 | - if ( $display_errors ) { |
|
509 | + if (empty($name)) { |
|
510 | + if ($display_errors) { |
|
511 | 511 | throw new EE_Error( |
512 | - __( 'No name has been provided for the specific configuration section.', 'event_espresso' ) |
|
512 | + __('No name has been provided for the specific configuration section.', 'event_espresso') |
|
513 | 513 | ); |
514 | 514 | } |
515 | 515 | return false; |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | |
519 | 519 | // TEST #5 : check that a config class name has been set |
520 | 520 | case 5 : |
521 | - if ( empty( $config_class ) ) { |
|
522 | - if ( $display_errors ) { |
|
521 | + if (empty($config_class)) { |
|
522 | + if ($display_errors) { |
|
523 | 523 | throw new EE_Error( |
524 | - __( 'No class name has been provided for the specific configuration section.', 'event_espresso' ) |
|
524 | + __('No class name has been provided for the specific configuration section.', 'event_espresso') |
|
525 | 525 | ); |
526 | 526 | } |
527 | 527 | return false; |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | |
531 | 531 | // TEST #6 : verify config class is accessible |
532 | 532 | case 6 : |
533 | - if ( ! class_exists( $config_class ) ) { |
|
534 | - if ( $display_errors ) { |
|
533 | + if ( ! class_exists($config_class)) { |
|
534 | + if ($display_errors) { |
|
535 | 535 | throw new EE_Error( |
536 | 536 | sprintf( |
537 | - __( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ), |
|
537 | + __('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'), |
|
538 | 538 | $config_class |
539 | 539 | ) |
540 | 540 | ); |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | |
546 | 546 | // TEST #7 : check that config has even been set |
547 | 547 | case 7 : |
548 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
549 | - if ( $display_errors ) { |
|
548 | + if ( ! isset($this->{$section}->{$name} )) { |
|
549 | + if ($display_errors) { |
|
550 | 550 | throw new EE_Error( |
551 | 551 | sprintf( |
552 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
552 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
553 | 553 | $section, |
554 | 554 | $name |
555 | 555 | ) |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | return false; |
559 | 559 | } else { |
560 | 560 | // and make sure it's not serialized |
561 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
561 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
562 | 562 | } |
563 | 563 | break; |
564 | 564 | |
565 | 565 | // TEST #8 : check that config is the requested type |
566 | 566 | case 8 : |
567 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
568 | - if ( $display_errors ) { |
|
567 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
568 | + if ($display_errors) { |
|
569 | 569 | throw new EE_Error( |
570 | 570 | sprintf( |
571 | - __( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ), |
|
571 | + __('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'), |
|
572 | 572 | $section, |
573 | 573 | $name, |
574 | 574 | $config_class |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | |
582 | 582 | // TEST #9 : verify config object |
583 | 583 | case 9 : |
584 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
585 | - if ( $display_errors ) { |
|
584 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
585 | + if ($display_errors) { |
|
586 | 586 | throw new EE_Error( |
587 | 587 | sprintf( |
588 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
589 | - print_r( $config_obj, true ) |
|
588 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
589 | + print_r($config_obj, true) |
|
590 | 590 | ) |
591 | 591 | ); |
592 | 592 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | - } catch( EE_Error $e ) { |
|
600 | + } catch (EE_Error $e) { |
|
601 | 601 | $e->get_error(); |
602 | 602 | } |
603 | 603 | // you have successfully run the gauntlet |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * @param string $name |
615 | 615 | * @return string |
616 | 616 | */ |
617 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
618 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
617 | + private function _generate_config_option_name($section = '', $name = '') { |
|
618 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param string $name |
630 | 630 | * @return string |
631 | 631 | */ |
632 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
633 | - return ! empty( $config_class ) |
|
632 | + private function _set_config_class($config_class = '', $name = '') { |
|
633 | + return ! empty($config_class) |
|
634 | 634 | ? $config_class |
635 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
635 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -646,34 +646,34 @@ discard block |
||
646 | 646 | * @param EE_Config_Base $config_obj |
647 | 647 | * @return EE_Config_Base |
648 | 648 | */ |
649 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
649 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
650 | 650 | // ensure config class is set to something |
651 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
651 | + $config_class = $this->_set_config_class($config_class, $name); |
|
652 | 652 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
653 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) { |
|
653 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
654 | 654 | return null; |
655 | 655 | } |
656 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
656 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
657 | 657 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
658 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
659 | - $this->_config_option_names[ $config_option_name ] = $config_class; |
|
658 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
659 | + $this->_config_option_names[$config_option_name] = $config_class; |
|
660 | 660 | } |
661 | 661 | // verify the incoming config object but suppress errors |
662 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) { |
|
662 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
663 | 663 | $config_obj = new $config_class(); |
664 | 664 | } |
665 | - if ( get_option( $config_option_name ) ) { |
|
666 | - update_option( $config_option_name, $config_obj ); |
|
665 | + if (get_option($config_option_name)) { |
|
666 | + update_option($config_option_name, $config_obj); |
|
667 | 667 | $this->{$section}->{$name} = $config_obj; |
668 | 668 | return $this->{$section}->{$name}; |
669 | 669 | } else { |
670 | 670 | // create a wp-option for this config |
671 | - if ( add_option( $config_option_name, $config_obj, '', 'no' )) { |
|
672 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
671 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
672 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
673 | 673 | return $this->{$section}->{$name}; |
674 | 674 | } else { |
675 | 675 | EE_Error::add_error( |
676 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
676 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
677 | 677 | __FILE__, __FUNCTION__, __LINE__ |
678 | 678 | ); |
679 | 679 | return null; |
@@ -694,37 +694,37 @@ discard block |
||
694 | 694 | * @param bool $throw_errors |
695 | 695 | * @return bool |
696 | 696 | */ |
697 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
698 | - $config_obj = maybe_unserialize( $config_obj ); |
|
697 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
698 | + $config_obj = maybe_unserialize($config_obj); |
|
699 | 699 | // get class name of the incoming object |
700 | - $config_class = get_class( $config_obj ); |
|
700 | + $config_class = get_class($config_obj); |
|
701 | 701 | // run tests 1-5 and 9 to verify config |
702 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) { |
|
702 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) { |
|
703 | 703 | return false; |
704 | 704 | } |
705 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
705 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
706 | 706 | // check if config object has been added to db by seeing if config option name is in $this->_config_option_names array |
707 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
707 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
708 | 708 | // save new config to db |
709 | - return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
709 | + return $this->set_config($section, $name, $config_class, $config_obj); |
|
710 | 710 | } else { |
711 | 711 | // first check if the record already exists |
712 | - $existing_config = get_option( $config_option_name ); |
|
713 | - $config_obj = serialize( $config_obj ); |
|
712 | + $existing_config = get_option($config_option_name); |
|
713 | + $config_obj = serialize($config_obj); |
|
714 | 714 | // just return if db record is already up to date |
715 | - if ( $existing_config == $config_obj ) { |
|
715 | + if ($existing_config == $config_obj) { |
|
716 | 716 | $this->{$section}->{$name} = $config_obj; |
717 | 717 | return true; |
718 | - } else if ( update_option( $config_option_name, $config_obj )) { |
|
718 | + } else if (update_option($config_option_name, $config_obj)) { |
|
719 | 719 | // update wp-option for this config class |
720 | 720 | $this->{$section}->{$name} = $config_obj; |
721 | 721 | return true; |
722 | - } elseif ( $throw_errors ) { |
|
722 | + } elseif ($throw_errors) { |
|
723 | 723 | EE_Error::add_error( |
724 | 724 | sprintf( |
725 | - __( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ), |
|
725 | + __('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'), |
|
726 | 726 | $config_class, |
727 | - 'EE_Config->' . $section . '->' . $name |
|
727 | + 'EE_Config->'.$section.'->'.$name |
|
728 | 728 | ), |
729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
730 | 730 | ); |
@@ -744,34 +744,34 @@ discard block |
||
744 | 744 | * @param string $config_class |
745 | 745 | * @return mixed EE_Config_Base | NULL |
746 | 746 | */ |
747 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
747 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
748 | 748 | // ensure config class is set to something |
749 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
749 | + $config_class = $this->_set_config_class($config_class, $name); |
|
750 | 750 | // run tests 1-4, 6 and 7 to verify that all params have been set |
751 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) { |
|
751 | + if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) { |
|
752 | 752 | return NULL; |
753 | 753 | } |
754 | 754 | // now test if the requested config object exists, but suppress errors |
755 | - if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) { |
|
755 | + if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) { |
|
756 | 756 | // config already exists, so pass it back |
757 | 757 | return $this->{$section}->{$name}; |
758 | 758 | } |
759 | 759 | // load config option from db if it exists |
760 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name )); |
|
760 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
761 | 761 | // verify the newly retrieved config object, but suppress errors |
762 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) { |
|
762 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) { |
|
763 | 763 | // config is good, so set it and pass it back |
764 | 764 | $this->{$section}->{$name} = $config_obj; |
765 | 765 | return $this->{$section}->{$name}; |
766 | 766 | } |
767 | 767 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
768 | - $config_obj =$this->set_config( $section, $name, $config_class ); |
|
768 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
769 | 769 | // verify the newly created config object |
770 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) { |
|
770 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
771 | 771 | return $this->{$section}->{$name}; |
772 | 772 | } else { |
773 | 773 | EE_Error::add_error( |
774 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
774 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
775 | 775 | __FILE__, __FUNCTION__, __LINE__ |
776 | 776 | ); |
777 | 777 | } |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | * @param string $config_option_name |
787 | 787 | * @return mixed EE_Config_Base | FALSE |
788 | 788 | */ |
789 | - public function get_config_option( $config_option_name = '' ) { |
|
789 | + public function get_config_option($config_option_name = '') { |
|
790 | 790 | // retrieve the wp-option for this config class. |
791 | - return maybe_unserialize( get_option( $config_option_name )); |
|
791 | + return maybe_unserialize(get_option($config_option_name)); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -801,45 +801,45 @@ discard block |
||
801 | 801 | * @param $page_for_posts |
802 | 802 | * @return void |
803 | 803 | */ |
804 | - public function update_post_shortcodes( $page_for_posts = '' ) { |
|
804 | + public function update_post_shortcodes($page_for_posts = '') { |
|
805 | 805 | // make sure page_for_posts is set |
806 | - $page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
806 | + $page_for_posts = ! empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
807 | 807 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
808 | 808 | $critical_shortcodes = $this->core->get_critical_pages_shortcodes_array(); |
809 | 809 | // allow others to mess stuff up :D |
810 | - do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts ); |
|
810 | + do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts); |
|
811 | 811 | // verify that post_shortcodes is set |
812 | - $this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array(); |
|
812 | + $this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array(); |
|
813 | 813 | // cycle thru post_shortcodes |
814 | - foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){ |
|
814 | + foreach ($this->core->post_shortcodes as $post_name => $shortcodes) { |
|
815 | 815 | // are there any shortcodes to track ? |
816 | - if ( ! empty( $shortcodes )) { |
|
816 | + if ( ! empty($shortcodes)) { |
|
817 | 817 | // loop thru list of tracked shortcodes |
818 | - foreach( $shortcodes as $shortcode => $post_id ) { |
|
818 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
819 | 819 | // if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode |
820 | - if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) { |
|
820 | + if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) { |
|
821 | 821 | // then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog) |
822 | - unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] ); |
|
822 | + unset($this->core->post_shortcodes[$post_name][$shortcode]); |
|
823 | 823 | } |
824 | 824 | // skip the posts page, because we want all shortcodes registered for it |
825 | - if ( $post_name == $page_for_posts ) { |
|
825 | + if ($post_name == $page_for_posts) { |
|
826 | 826 | continue; |
827 | 827 | } |
828 | 828 | // make sure post still exists |
829 | - $post = get_post( $post_id ); |
|
830 | - if ( $post ) { |
|
829 | + $post = get_post($post_id); |
|
830 | + if ($post) { |
|
831 | 831 | // check that the post name matches what we have saved |
832 | - if ( $post->post_name == $post_name ) { |
|
832 | + if ($post->post_name == $post_name) { |
|
833 | 833 | // if so, then break before hitting the unset below |
834 | 834 | continue; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | // we don't like missing posts around here >:( |
838 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
838 | + unset($this->core->post_shortcodes[$post_name]); |
|
839 | 839 | } |
840 | 840 | } else { |
841 | 841 | // you got no shortcodes to keep track of ! |
842 | - unset( $this->core->post_shortcodes[ $post_name ] ); |
|
842 | + unset($this->core->post_shortcodes[$post_name]); |
|
843 | 843 | } |
844 | 844 | } |
845 | 845 | //only show errors |
@@ -858,14 +858,14 @@ discard block |
||
858 | 858 | * @return string |
859 | 859 | */ |
860 | 860 | public static function get_page_for_posts() { |
861 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
862 | - if ( ! $page_for_posts ) { |
|
861 | + $page_for_posts = get_option('page_for_posts'); |
|
862 | + if ( ! $page_for_posts) { |
|
863 | 863 | return 'posts'; |
864 | 864 | } |
865 | 865 | /** @type WPDB $wpdb */ |
866 | 866 | global $wpdb; |
867 | 867 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
868 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts )); |
|
868 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | |
@@ -881,11 +881,11 @@ discard block |
||
881 | 881 | * @return void |
882 | 882 | */ |
883 | 883 | public function register_shortcodes_and_modules() { |
884 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
884 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
885 | 885 | return; |
886 | 886 | } |
887 | 887 | // allow shortcodes to register with WP and to set hooks for the rest of the system |
888 | - EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
|
888 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
889 | 889 | // allow modules to set hooks for the rest of the system |
890 | 890 | EE_Registry::instance()->modules = $this->_register_modules(); |
891 | 891 | } |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | * @return void |
900 | 900 | */ |
901 | 901 | public function initialize_shortcodes_and_modules() { |
902 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
902 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
903 | 903 | return; |
904 | 904 | } |
905 | 905 | // allow shortcodes to set hooks for the rest of the system |
@@ -918,26 +918,26 @@ discard block |
||
918 | 918 | * @return void |
919 | 919 | */ |
920 | 920 | public function widgets_init() { |
921 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
921 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
922 | 922 | return; |
923 | 923 | } |
924 | 924 | //only init widgets on admin pages when not in complete maintenance, and |
925 | 925 | //on frontend when not in any maintenance mode |
926 | - if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
|
926 | + if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) { |
|
927 | 927 | // grab list of installed widgets |
928 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
928 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
929 | 929 | // filter list of modules to register |
930 | - $widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
|
930 | + $widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register); |
|
931 | 931 | |
932 | - if ( ! empty( $widgets_to_register ) ) { |
|
932 | + if ( ! empty($widgets_to_register)) { |
|
933 | 933 | // cycle thru widget folders |
934 | - foreach ( $widgets_to_register as $widget_path ) { |
|
934 | + foreach ($widgets_to_register as $widget_path) { |
|
935 | 935 | // add to list of installed widget modules |
936 | - EE_Config::register_ee_widget( $widget_path ); |
|
936 | + EE_Config::register_ee_widget($widget_path); |
|
937 | 937 | } |
938 | 938 | } |
939 | 939 | // filter list of installed modules |
940 | - EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
|
940 | + EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets); |
|
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
@@ -950,54 +950,54 @@ discard block |
||
950 | 950 | * @param string $widget_path - full path up to and including widget folder |
951 | 951 | * @return void |
952 | 952 | */ |
953 | - public static function register_ee_widget( $widget_path = NULL ) { |
|
954 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
953 | + public static function register_ee_widget($widget_path = NULL) { |
|
954 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
955 | 955 | $widget_ext = '.widget.php'; |
956 | 956 | // make all separators match |
957 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
957 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
958 | 958 | // does the file path INCLUDE the actual file name as part of the path ? |
959 | - if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
|
959 | + if (strpos($widget_path, $widget_ext) !== FALSE) { |
|
960 | 960 | // grab and shortcode file name from directory name and break apart at dots |
961 | - $file_name = explode( '.', basename( $widget_path )); |
|
961 | + $file_name = explode('.', basename($widget_path)); |
|
962 | 962 | // take first segment from file name pieces and remove class prefix if it exists |
963 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
963 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
964 | 964 | // sanitize shortcode directory name |
965 | - $widget = sanitize_key( $widget ); |
|
965 | + $widget = sanitize_key($widget); |
|
966 | 966 | // now we need to rebuild the shortcode path |
967 | - $widget_path = explode( DS, $widget_path ); |
|
967 | + $widget_path = explode(DS, $widget_path); |
|
968 | 968 | // remove last segment |
969 | - array_pop( $widget_path ); |
|
969 | + array_pop($widget_path); |
|
970 | 970 | // glue it back together |
971 | - $widget_path = implode( DS, $widget_path ); |
|
971 | + $widget_path = implode(DS, $widget_path); |
|
972 | 972 | } else { |
973 | 973 | // grab and sanitize widget directory name |
974 | - $widget = sanitize_key( basename( $widget_path )); |
|
974 | + $widget = sanitize_key(basename($widget_path)); |
|
975 | 975 | } |
976 | 976 | // create classname from widget directory name |
977 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
|
977 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
978 | 978 | // add class prefix |
979 | - $widget_class = 'EEW_' . $widget; |
|
979 | + $widget_class = 'EEW_'.$widget; |
|
980 | 980 | // does the widget exist ? |
981 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
981 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
982 | 982 | $msg = sprintf( |
983 | - __( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ), |
|
983 | + __('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), |
|
984 | 984 | $widget_class, |
985 | - $widget_path . DS . $widget_class . $widget_ext |
|
985 | + $widget_path.DS.$widget_class.$widget_ext |
|
986 | 986 | ); |
987 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
987 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
988 | 988 | return; |
989 | 989 | } |
990 | 990 | // load the widget class file |
991 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
991 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
992 | 992 | // verify that class exists |
993 | - if ( ! class_exists( $widget_class )) { |
|
994 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
995 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
993 | + if ( ! class_exists($widget_class)) { |
|
994 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
995 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
996 | 996 | return; |
997 | 997 | } |
998 | - register_widget( $widget_class ); |
|
998 | + register_widget($widget_class); |
|
999 | 999 | // add to array of registered widgets |
1000 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1000 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1010,18 +1010,18 @@ discard block |
||
1010 | 1010 | */ |
1011 | 1011 | private function _register_shortcodes() { |
1012 | 1012 | // grab list of installed shortcodes |
1013 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
1013 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
1014 | 1014 | // filter list of modules to register |
1015 | - $shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
|
1016 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
1015 | + $shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register); |
|
1016 | + if ( ! empty($shortcodes_to_register)) { |
|
1017 | 1017 | // cycle thru shortcode folders |
1018 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
1018 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
1019 | 1019 | // add to list of installed shortcode modules |
1020 | - EE_Config::register_shortcode( $shortcode_path ); |
|
1020 | + EE_Config::register_shortcode($shortcode_path); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | // filter list of installed modules |
1024 | - return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
|
1024 | + return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
@@ -1033,56 +1033,56 @@ discard block |
||
1033 | 1033 | * @param string $shortcode_path - full path up to and including shortcode folder |
1034 | 1034 | * @return bool |
1035 | 1035 | */ |
1036 | - public static function register_shortcode( $shortcode_path = NULL ) { |
|
1037 | - do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
|
1036 | + public static function register_shortcode($shortcode_path = NULL) { |
|
1037 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1038 | 1038 | $shortcode_ext = '.shortcode.php'; |
1039 | 1039 | // make all separators match |
1040 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
1040 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1041 | 1041 | // does the file path INCLUDE the actual file name as part of the path ? |
1042 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
|
1042 | + if (strpos($shortcode_path, $shortcode_ext) !== FALSE) { |
|
1043 | 1043 | // grab shortcode file name from directory name and break apart at dots |
1044 | - $shortcode_file = explode( '.', basename( $shortcode_path )); |
|
1044 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
1045 | 1045 | // take first segment from file name pieces and remove class prefix if it exists |
1046 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
|
1046 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0]; |
|
1047 | 1047 | // sanitize shortcode directory name |
1048 | - $shortcode = sanitize_key( $shortcode ); |
|
1048 | + $shortcode = sanitize_key($shortcode); |
|
1049 | 1049 | // now we need to rebuild the shortcode path |
1050 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
1050 | + $shortcode_path = explode(DS, $shortcode_path); |
|
1051 | 1051 | // remove last segment |
1052 | - array_pop( $shortcode_path ); |
|
1052 | + array_pop($shortcode_path); |
|
1053 | 1053 | // glue it back together |
1054 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
1054 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
1055 | 1055 | } else { |
1056 | 1056 | // we need to generate the filename based off of the folder name |
1057 | 1057 | // grab and sanitize shortcode directory name |
1058 | - $shortcode = sanitize_key( basename( $shortcode_path )); |
|
1059 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
1058 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
1059 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
1060 | 1060 | } |
1061 | 1061 | // create classname from shortcode directory or file name |
1062 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
|
1062 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1063 | 1063 | // add class prefix |
1064 | - $shortcode_class = 'EES_' . $shortcode; |
|
1064 | + $shortcode_class = 'EES_'.$shortcode; |
|
1065 | 1065 | // does the shortcode exist ? |
1066 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
1066 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1067 | 1067 | $msg = sprintf( |
1068 | - __( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
|
1068 | + __('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'), |
|
1069 | 1069 | $shortcode_class, |
1070 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1070 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1071 | 1071 | ); |
1072 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1072 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | return FALSE; |
1074 | 1074 | } |
1075 | 1075 | // load the shortcode class file |
1076 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1076 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1077 | 1077 | // verify that class exists |
1078 | - if ( ! class_exists( $shortcode_class )) { |
|
1079 | - $msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
|
1080 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1078 | + if ( ! class_exists($shortcode_class)) { |
|
1079 | + $msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class); |
|
1080 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1081 | 1081 | return FALSE; |
1082 | 1082 | } |
1083 | - $shortcode = strtoupper( $shortcode ); |
|
1083 | + $shortcode = strtoupper($shortcode); |
|
1084 | 1084 | // add to array of registered shortcodes |
1085 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1085 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1086 | 1086 | return TRUE; |
1087 | 1087 | } |
1088 | 1088 | |
@@ -1097,23 +1097,23 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | private function _register_modules() { |
1099 | 1099 | // grab list of installed modules |
1100 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1100 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1101 | 1101 | // filter list of modules to register |
1102 | - $modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
|
1102 | + $modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register); |
|
1103 | 1103 | |
1104 | 1104 | |
1105 | - if ( ! empty( $modules_to_register ) ) { |
|
1105 | + if ( ! empty($modules_to_register)) { |
|
1106 | 1106 | // loop through folders |
1107 | - foreach ( $modules_to_register as $module_path ) { |
|
1107 | + foreach ($modules_to_register as $module_path) { |
|
1108 | 1108 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1109 | - if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
|
1109 | + if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') { |
|
1110 | 1110 | // add to list of installed modules |
1111 | - EE_Config::register_module( $module_path ); |
|
1111 | + EE_Config::register_module($module_path); |
|
1112 | 1112 | } |
1113 | 1113 | } |
1114 | 1114 | } |
1115 | 1115 | // filter list of installed modules |
1116 | - return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
|
1116 | + return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | |
@@ -1126,54 +1126,54 @@ discard block |
||
1126 | 1126 | * @param string $module_path - full path up to and including module folder |
1127 | 1127 | * @return bool |
1128 | 1128 | */ |
1129 | - public static function register_module( $module_path = NULL ) { |
|
1130 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1129 | + public static function register_module($module_path = NULL) { |
|
1130 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1131 | 1131 | $module_ext = '.module.php'; |
1132 | 1132 | // make all separators match |
1133 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1133 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1134 | 1134 | // does the file path INCLUDE the actual file name as part of the path ? |
1135 | - if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
|
1135 | + if (strpos($module_path, $module_ext) !== FALSE) { |
|
1136 | 1136 | // grab and shortcode file name from directory name and break apart at dots |
1137 | - $module_file = explode( '.', basename( $module_path )); |
|
1137 | + $module_file = explode('.', basename($module_path)); |
|
1138 | 1138 | // now we need to rebuild the shortcode path |
1139 | - $module_path = explode( DS, $module_path ); |
|
1139 | + $module_path = explode(DS, $module_path); |
|
1140 | 1140 | // remove last segment |
1141 | - array_pop( $module_path ); |
|
1141 | + array_pop($module_path); |
|
1142 | 1142 | // glue it back together |
1143 | - $module_path = implode( DS, $module_path ) . DS; |
|
1143 | + $module_path = implode(DS, $module_path).DS; |
|
1144 | 1144 | // take first segment from file name pieces and sanitize it |
1145 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1145 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1146 | 1146 | // ensure class prefix is added |
1147 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1147 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1148 | 1148 | } else { |
1149 | 1149 | // we need to generate the filename based off of the folder name |
1150 | 1150 | // grab and sanitize module name |
1151 | - $module = strtolower( basename( $module_path )); |
|
1152 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
|
1151 | + $module = strtolower(basename($module_path)); |
|
1152 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1153 | 1153 | // like trailingslashit() |
1154 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
1154 | + $module_path = rtrim($module_path, DS).DS; |
|
1155 | 1155 | // create classname from module directory name |
1156 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
|
1156 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1157 | 1157 | // add class prefix |
1158 | - $module_class = 'EED_' . $module; |
|
1158 | + $module_class = 'EED_'.$module; |
|
1159 | 1159 | } |
1160 | 1160 | // does the module exist ? |
1161 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
1162 | - $msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
1163 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1161 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1162 | + $msg = sprintf(__('The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
1163 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1164 | 1164 | return FALSE; |
1165 | 1165 | } |
1166 | 1166 | // load the module class file |
1167 | - require_once( $module_path . $module_class . $module_ext ); |
|
1167 | + require_once($module_path.$module_class.$module_ext); |
|
1168 | 1168 | // verify that class exists |
1169 | - if ( ! class_exists( $module_class )) { |
|
1170 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1171 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1169 | + if ( ! class_exists($module_class)) { |
|
1170 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1171 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1172 | 1172 | return FALSE; |
1173 | 1173 | } |
1174 | 1174 | // add to array of registered modules |
1175 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1176 | - do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
1175 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1176 | + do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
1177 | 1177 | return TRUE; |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1187,23 +1187,23 @@ discard block |
||
1187 | 1187 | */ |
1188 | 1188 | private function _initialize_shortcodes() { |
1189 | 1189 | // cycle thru shortcode folders |
1190 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1190 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1191 | 1191 | // add class prefix |
1192 | - $shortcode_class = 'EES_' . $shortcode; |
|
1192 | + $shortcode_class = 'EES_'.$shortcode; |
|
1193 | 1193 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1194 | 1194 | // which set hooks ? |
1195 | - if ( is_admin() ) { |
|
1195 | + if (is_admin()) { |
|
1196 | 1196 | // fire immediately |
1197 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
|
1197 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1198 | 1198 | } else { |
1199 | 1199 | // delay until other systems are online |
1200 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
|
1200 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks')); |
|
1201 | 1201 | // convert classname to UPPERCASE and create WP shortcode. |
1202 | - $shortcode_tag = strtoupper( $shortcode ); |
|
1202 | + $shortcode_tag = strtoupper($shortcode); |
|
1203 | 1203 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1204 | - if ( ! shortcode_exists( $shortcode_tag )) { |
|
1204 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1205 | 1205 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1206 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
|
1206 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1207 | 1207 | } |
1208 | 1208 | } |
1209 | 1209 | } |
@@ -1220,15 +1220,15 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | private function _initialize_modules() { |
1222 | 1222 | // cycle thru shortcode folders |
1223 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1223 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1224 | 1224 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1225 | 1225 | // which set hooks ? |
1226 | - if ( is_admin() ) { |
|
1226 | + if (is_admin()) { |
|
1227 | 1227 | // fire immediately |
1228 | - call_user_func( array( $module_class, 'set_hooks_admin' )); |
|
1228 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1229 | 1229 | } else { |
1230 | 1230 | // delay until other systems are online |
1231 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
|
1231 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks')); |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | } |
@@ -1246,26 +1246,26 @@ discard block |
||
1246 | 1246 | * @param string $key - url param key indicating a route is being called |
1247 | 1247 | * @return bool |
1248 | 1248 | */ |
1249 | - public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
|
1250 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1251 | - $module = str_replace( 'EED_', '', $module ); |
|
1252 | - $module_class = 'EED_' . $module; |
|
1253 | - if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) { |
|
1254 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1255 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1249 | + public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') { |
|
1250 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | + $module = str_replace('EED_', '', $module); |
|
1252 | + $module_class = 'EED_'.$module; |
|
1253 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) { |
|
1254 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | 1256 | return FALSE; |
1257 | 1257 | } |
1258 | - if ( empty( $route )) { |
|
1259 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1260 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1258 | + if (empty($route)) { |
|
1259 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
1263 | - if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
1264 | - $msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
|
1265 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1263 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1264 | + $msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route); |
|
1265 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1266 | 1266 | return FALSE; |
1267 | 1267 | } |
1268 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1268 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1269 | 1269 | return TRUE; |
1270 | 1270 | } |
1271 | 1271 | |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | * @param string $key - url param key indicating a route is being called |
1280 | 1280 | * @return string |
1281 | 1281 | */ |
1282 | - public static function get_route( $route = NULL, $key = 'ee' ) { |
|
1283 | - do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
|
1284 | - $route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
|
1285 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
|
1286 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1282 | + public static function get_route($route = NULL, $key = 'ee') { |
|
1283 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1284 | + $route = apply_filters('FHEE__EE_Config__get_route', $route); |
|
1285 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1286 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1287 | 1287 | } |
1288 | 1288 | return NULL; |
1289 | 1289 | } |
@@ -1312,35 +1312,35 @@ discard block |
||
1312 | 1312 | * @param string $key - url param key indicating a route is being called |
1313 | 1313 | * @return bool |
1314 | 1314 | */ |
1315 | - public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
|
1316 | - do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
|
1317 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1318 | - $msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
|
1319 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1315 | + public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') { |
|
1316 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1317 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1318 | + $msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route); |
|
1319 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1320 | 1320 | return FALSE; |
1321 | 1321 | } |
1322 | - if ( empty( $forward )) { |
|
1323 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1324 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1322 | + if (empty($forward)) { |
|
1323 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1324 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1325 | 1325 | return FALSE; |
1326 | 1326 | } |
1327 | - if ( is_array( $forward )) { |
|
1328 | - if ( ! isset( $forward[1] )) { |
|
1329 | - $msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
|
1330 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1327 | + if (is_array($forward)) { |
|
1328 | + if ( ! isset($forward[1])) { |
|
1329 | + $msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route); |
|
1330 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1331 | 1331 | return FALSE; |
1332 | 1332 | } |
1333 | - if ( ! method_exists( $forward[0], $forward[1] )) { |
|
1334 | - $msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
|
1335 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1333 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1334 | + $msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route); |
|
1335 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1336 | 1336 | return FALSE; |
1337 | 1337 | } |
1338 | - } else if ( ! function_exists( $forward )) { |
|
1339 | - $msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
|
1340 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1338 | + } else if ( ! function_exists($forward)) { |
|
1339 | + $msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route); |
|
1340 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | 1341 | return FALSE; |
1342 | 1342 | } |
1343 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1343 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1344 | 1344 | return TRUE; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1355,10 +1355,10 @@ discard block |
||
1355 | 1355 | * @param string $key - url param key indicating a route is being called |
1356 | 1356 | * @return string |
1357 | 1357 | */ |
1358 | - public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1359 | - do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
|
1360 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
|
1361 | - return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1358 | + public static function get_forward($route = NULL, $status = 0, $key = 'ee') { |
|
1359 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1360 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1361 | + return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status); |
|
1362 | 1362 | } |
1363 | 1363 | return NULL; |
1364 | 1364 | } |
@@ -1375,19 +1375,19 @@ discard block |
||
1375 | 1375 | * @param string $key - url param key indicating a route is being called |
1376 | 1376 | * @return bool |
1377 | 1377 | */ |
1378 | - public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
|
1379 | - do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
|
1380 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1381 | - $msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
|
1382 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1378 | + public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') { |
|
1379 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1380 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1381 | + $msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route); |
|
1382 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1383 | 1383 | return FALSE; |
1384 | 1384 | } |
1385 | - if ( ! is_readable( $view )) { |
|
1386 | - $msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
|
1387 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1385 | + if ( ! is_readable($view)) { |
|
1386 | + $msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view); |
|
1387 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1388 | 1388 | return FALSE; |
1389 | 1389 | } |
1390 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1390 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1391 | 1391 | return TRUE; |
1392 | 1392 | } |
1393 | 1393 | |
@@ -1404,10 +1404,10 @@ discard block |
||
1404 | 1404 | * @param string $key - url param key indicating a route is being called |
1405 | 1405 | * @return string |
1406 | 1406 | */ |
1407 | - public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1408 | - do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
|
1409 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
|
1410 | - return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1407 | + public static function get_view($route = NULL, $status = 0, $key = 'ee') { |
|
1408 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1409 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1410 | + return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status); |
|
1411 | 1411 | } |
1412 | 1412 | return NULL; |
1413 | 1413 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | |
1417 | 1417 | public function shutdown() { |
1418 | - update_option( 'ee_config_option_names', $this->_config_option_names ); |
|
1418 | + update_option('ee_config_option_names', $this->_config_option_names); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | * magic functions in use, except we'll allow them to magically set and get stuff... |
1432 | 1432 | * basically, they should just be well-defined stdClasses |
1433 | 1433 | */ |
1434 | -class EE_Config_Base{ |
|
1434 | +class EE_Config_Base { |
|
1435 | 1435 | |
1436 | 1436 | /** |
1437 | 1437 | * Utility function for escaping the value of a property and returning. |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1441 | 1441 | * @throws \EE_Error |
1442 | 1442 | */ |
1443 | - public function get_pretty( $property ) { |
|
1444 | - if ( ! property_exists( $this, $property ) ) { |
|
1445 | - throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) ); |
|
1443 | + public function get_pretty($property) { |
|
1444 | + if ( ! property_exists($this, $property)) { |
|
1445 | + throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property)); |
|
1446 | 1446 | } |
1447 | 1447 | //just handling escaping of strings for now. |
1448 | - if ( is_string( $this->{$property} ) ) { |
|
1449 | - return stripslashes( $this->{$property} ); |
|
1448 | + if (is_string($this->{$property} )) { |
|
1449 | + return stripslashes($this->{$property} ); |
|
1450 | 1450 | } |
1451 | 1451 | return $this->{$property}; |
1452 | 1452 | } |
@@ -1455,19 +1455,19 @@ discard block |
||
1455 | 1455 | |
1456 | 1456 | public function populate() { |
1457 | 1457 | //grab defaults via a new instance of this class. |
1458 | - $class_name = get_class( $this ); |
|
1458 | + $class_name = get_class($this); |
|
1459 | 1459 | $defaults = new $class_name; |
1460 | 1460 | |
1461 | 1461 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1462 | 1462 | //default from our $defaults object. |
1463 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1464 | - if ( is_null( $this->{$property} ) ) { |
|
1463 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1464 | + if (is_null($this->{$property} )) { |
|
1465 | 1465 | $this->{$property} = $value; |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | //cleanup |
1470 | - unset( $defaults ); |
|
1470 | + unset($defaults); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | |
@@ -1559,12 +1559,12 @@ discard block |
||
1559 | 1559 | */ |
1560 | 1560 | public function __construct() { |
1561 | 1561 | $current_network_main_site = is_multisite() ? get_current_site() : NULL; |
1562 | - $current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1562 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1563 | 1563 | // set default organization settings |
1564 | 1564 | $this->current_blog_id = get_current_blog_id(); |
1565 | 1565 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1566 | - $this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
|
1567 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
|
1566 | + $this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE); |
|
1567 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE; |
|
1568 | 1568 | $this->post_shortcodes = array(); |
1569 | 1569 | $this->module_route_map = array(); |
1570 | 1570 | $this->module_forward_map = array(); |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | $this->event_cpt_slug = __('events', 'event_espresso'); |
1584 | 1584 | |
1585 | 1585 | //ueip constant check |
1586 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1586 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1587 | 1587 | $this->ee_ueip_optin = FALSE; |
1588 | 1588 | $this->ee_ueip_has_notified = TRUE; |
1589 | 1589 | } |
@@ -1623,8 +1623,8 @@ discard block |
||
1623 | 1623 | * @return string |
1624 | 1624 | */ |
1625 | 1625 | public function reg_page_url() { |
1626 | - if ( ! $this->reg_page_url ) { |
|
1627 | - $this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
1626 | + if ( ! $this->reg_page_url) { |
|
1627 | + $this->reg_page_url = get_permalink($this->reg_page_id).'#checkout'; |
|
1628 | 1628 | } |
1629 | 1629 | return $this->reg_page_url; |
1630 | 1630 | } |
@@ -1637,12 +1637,12 @@ discard block |
||
1637 | 1637 | * @return string |
1638 | 1638 | */ |
1639 | 1639 | public function txn_page_url($query_args = array()) { |
1640 | - if ( ! $this->txn_page_url ) { |
|
1641 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1640 | + if ( ! $this->txn_page_url) { |
|
1641 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1642 | 1642 | } |
1643 | - if($query_args){ |
|
1644 | - return add_query_arg($query_args,$this->txn_page_url); |
|
1645 | - }else{ |
|
1643 | + if ($query_args) { |
|
1644 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1645 | + } else { |
|
1646 | 1646 | return $this->txn_page_url; |
1647 | 1647 | } |
1648 | 1648 | } |
@@ -1654,12 +1654,12 @@ discard block |
||
1654 | 1654 | * @return string |
1655 | 1655 | */ |
1656 | 1656 | public function thank_you_page_url($query_args = array()) { |
1657 | - if ( ! $this->thank_you_page_url ) { |
|
1658 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1657 | + if ( ! $this->thank_you_page_url) { |
|
1658 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1659 | 1659 | } |
1660 | - if($query_args){ |
|
1661 | - return add_query_arg($query_args,$this->thank_you_page_url); |
|
1662 | - }else{ |
|
1660 | + if ($query_args) { |
|
1661 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1662 | + } else { |
|
1663 | 1663 | return $this->thank_you_page_url; |
1664 | 1664 | } |
1665 | 1665 | } |
@@ -1670,8 +1670,8 @@ discard block |
||
1670 | 1670 | * @return string |
1671 | 1671 | */ |
1672 | 1672 | public function cancel_page_url() { |
1673 | - if ( ! $this->cancel_page_url ) { |
|
1674 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1673 | + if ( ! $this->cancel_page_url) { |
|
1674 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1675 | 1675 | } |
1676 | 1676 | return $this->cancel_page_url; |
1677 | 1677 | } |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | //reset all url properties |
1700 | 1700 | $this->_reset_urls(); |
1701 | 1701 | //return what to save to db |
1702 | - return array_keys( get_object_vars( $this ) ); |
|
1702 | + return array_keys(get_object_vars($this)); |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | } |
@@ -1931,39 +1931,39 @@ discard block |
||
1931 | 1931 | * @param null $CNT_ISO |
1932 | 1932 | * @return \EE_Currency_Config |
1933 | 1933 | */ |
1934 | - public function __construct( $CNT_ISO = NULL ) { |
|
1934 | + public function __construct($CNT_ISO = NULL) { |
|
1935 | 1935 | |
1936 | 1936 | // get country code from organization settings or use default |
1937 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1937 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1938 | 1938 | // but override if requested |
1939 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
1940 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
1939 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
1940 | + EE_Registry::instance()->load_helper('Activation'); |
|
1941 | 1941 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
1942 | - if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
1942 | + if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) { |
|
1943 | 1943 | // retrieve the country settings from the db, just in case they have been customized |
1944 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
1945 | - if ( $country instanceof EE_Country ) { |
|
1946 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1947 | - $this->name = $country->currency_name_single(); // Dollar |
|
1948 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
1949 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
1950 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1951 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1952 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1953 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1944 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
1945 | + if ($country instanceof EE_Country) { |
|
1946 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1947 | + $this->name = $country->currency_name_single(); // Dollar |
|
1948 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
1949 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
1950 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1951 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1952 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1953 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1954 | 1954 | } |
1955 | 1955 | } |
1956 | 1956 | // fallback to hardcoded defaults, in case the above failed |
1957 | - if ( empty( $this->code )) { |
|
1957 | + if (empty($this->code)) { |
|
1958 | 1958 | // set default currency settings |
1959 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1960 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
1961 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
1962 | - $this->sign = '$'; // currency sign: $ |
|
1963 | - $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1964 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1965 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1966 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1959 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1960 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
1961 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
1962 | + $this->sign = '$'; // currency sign: $ |
|
1963 | + $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1964 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1965 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1966 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1967 | 1967 | } |
1968 | 1968 | } |
1969 | 1969 | } |
@@ -2103,7 +2103,7 @@ discard block |
||
2103 | 2103 | * @since 4.8.8.rc.019 |
2104 | 2104 | */ |
2105 | 2105 | public function do_hooks() { |
2106 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
|
2106 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2107 | 2107 | } |
2108 | 2108 | |
2109 | 2109 | |
@@ -2111,7 +2111,7 @@ discard block |
||
2111 | 2111 | * @return void |
2112 | 2112 | */ |
2113 | 2113 | public function set_default_reg_status_on_EEM_Event() { |
2114 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2114 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | |
@@ -2216,10 +2216,10 @@ discard block |
||
2216 | 2216 | * @param bool $reset |
2217 | 2217 | * @return string |
2218 | 2218 | */ |
2219 | - public function log_file_name( $reset = FALSE ) { |
|
2220 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
2221 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2222 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2219 | + public function log_file_name($reset = FALSE) { |
|
2220 | + if (empty($this->log_file_name) || $reset) { |
|
2221 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt'; |
|
2222 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2223 | 2223 | } |
2224 | 2224 | return $this->log_file_name; |
2225 | 2225 | } |
@@ -2231,10 +2231,10 @@ discard block |
||
2231 | 2231 | * @param bool $reset |
2232 | 2232 | * @return string |
2233 | 2233 | */ |
2234 | - public function debug_file_name( $reset = FALSE ) { |
|
2235 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
2236 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2237 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2234 | + public function debug_file_name($reset = FALSE) { |
|
2235 | + if (empty($this->debug_file_name) || $reset) { |
|
2236 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt'; |
|
2237 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2238 | 2238 | } |
2239 | 2239 | return $this->debug_file_name; |
2240 | 2240 | } |
@@ -2407,21 +2407,21 @@ discard block |
||
2407 | 2407 | // set default map settings |
2408 | 2408 | $this->use_google_maps = TRUE; |
2409 | 2409 | // for event details pages (reg page) |
2410 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2411 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2412 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2413 | - $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2414 | - $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2415 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2416 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2410 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2411 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2412 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2413 | + $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2414 | + $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2415 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2416 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2417 | 2417 | // for event list pages |
2418 | - $this->event_list_map_width = 300; // ee_map_width |
|
2419 | - $this->event_list_map_height = 185; // ee_map_height |
|
2420 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2421 | - $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2422 | - $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2423 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2424 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2418 | + $this->event_list_map_width = 300; // ee_map_width |
|
2419 | + $this->event_list_map_height = 185; // ee_map_height |
|
2420 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2421 | + $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2422 | + $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2423 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2424 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2425 | 2425 | } |
2426 | 2426 | |
2427 | 2427 | } |
@@ -2432,7 +2432,7 @@ discard block |
||
2432 | 2432 | /** |
2433 | 2433 | * stores Events_Archive settings |
2434 | 2434 | */ |
2435 | -class EE_Events_Archive_Config extends EE_Config_Base{ |
|
2435 | +class EE_Events_Archive_Config extends EE_Config_Base { |
|
2436 | 2436 | |
2437 | 2437 | public $display_status_banner; |
2438 | 2438 | public $display_description; |
@@ -2451,7 +2451,7 @@ discard block |
||
2451 | 2451 | /** |
2452 | 2452 | * class constructor |
2453 | 2453 | */ |
2454 | - public function __construct(){ |
|
2454 | + public function __construct() { |
|
2455 | 2455 | $this->display_status_banner = 0; |
2456 | 2456 | $this->display_description = 1; |
2457 | 2457 | $this->display_ticket_selector = 0; |
@@ -2471,7 +2471,7 @@ discard block |
||
2471 | 2471 | /** |
2472 | 2472 | * Stores Event_Single_Config settings |
2473 | 2473 | */ |
2474 | -class EE_Event_Single_Config extends EE_Config_Base{ |
|
2474 | +class EE_Event_Single_Config extends EE_Config_Base { |
|
2475 | 2475 | |
2476 | 2476 | public $display_status_banner_single; |
2477 | 2477 | public $display_venue; |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | /** |
2501 | 2501 | * Stores Ticket_Selector_Config settings |
2502 | 2502 | */ |
2503 | -class EE_Ticket_Selector_Config extends EE_Config_Base{ |
|
2503 | +class EE_Ticket_Selector_Config extends EE_Config_Base { |
|
2504 | 2504 | public $show_ticket_sale_columns; |
2505 | 2505 | public $show_ticket_details; |
2506 | 2506 | public $show_expired_tickets; |
@@ -2554,7 +2554,7 @@ discard block |
||
2554 | 2554 | * @return void |
2555 | 2555 | */ |
2556 | 2556 | protected function _set_php_values() { |
2557 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2557 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
2558 | 2558 | $this->php->version = phpversion(); |
2559 | 2559 | } |
2560 | 2560 | |
@@ -2573,8 +2573,8 @@ discard block |
||
2573 | 2573 | * @type string $msg Any message to be displayed. |
2574 | 2574 | * } |
2575 | 2575 | */ |
2576 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2577 | - if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
|
2576 | + public function max_input_vars_limit_check($input_count = 0) { |
|
2577 | + if (($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) { |
|
2578 | 2578 | return __('The number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.', 'event_espresso'); |
2579 | 2579 | } else { |
2580 | 2580 | return ''; |
@@ -2610,7 +2610,7 @@ discard block |
||
2610 | 2610 | * stores payment gateway info |
2611 | 2611 | * @deprecated |
2612 | 2612 | */ |
2613 | -class EE_Gateway_Config extends EE_Config_Base{ |
|
2613 | +class EE_Gateway_Config extends EE_Config_Base { |
|
2614 | 2614 | |
2615 | 2615 | /** |
2616 | 2616 | * Array with keys that are payment gateways slugs, and values are arrays |
@@ -2632,9 +2632,9 @@ discard block |
||
2632 | 2632 | * class constructor |
2633 | 2633 | * @deprecated |
2634 | 2634 | */ |
2635 | - public function __construct(){ |
|
2635 | + public function __construct() { |
|
2636 | 2636 | $this->payment_settings = array(); |
2637 | - $this->active_gateways = array( 'Invoice' => FALSE ); |
|
2637 | + $this->active_gateways = array('Invoice' => FALSE); |
|
2638 | 2638 | } |
2639 | 2639 | } |
2640 | 2640 |
@@ -184,7 +184,7 @@ |
||
184 | 184 | * returns TRUE if M-Mode is engaged and the current request is not for the admin |
185 | 185 | * |
186 | 186 | * @access public |
187 | - * @return string |
|
187 | + * @return boolean |
|
188 | 188 | */ |
189 | 189 | public static function disable_frontend_for_maintenance() { |
190 | 190 | return ! is_admin() && EE_Maintenance_Mode::instance()->level() ? TRUE : FALSE; |
@@ -48,10 +48,10 @@ |
||
48 | 48 | */ |
49 | 49 | const option_name_maintenance_mode = 'ee_maintenance_mode'; |
50 | 50 | /** |
51 | - * EE_Maintenance_Mode Object |
|
52 | - * @var EE_Maintenance_Mode $_instance |
|
53 | - * @access private |
|
54 | - */ |
|
51 | + * EE_Maintenance_Mode Object |
|
52 | + * @var EE_Maintenance_Mode $_instance |
|
53 | + * @access private |
|
54 | + */ |
|
55 | 55 | private static $_instance = NULL; |
56 | 56 | |
57 | 57 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | 142 | $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else{ |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + } elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | 162 | update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else{ |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function instance() { |
75 | 75 | // check if class object is instantiated |
76 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) { |
|
76 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) { |
|
77 | 77 | self::$_instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$_instance; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
84 | 84 | * @return EE_Maintenance_Mode |
85 | 85 | */ |
86 | - public static function reset(){ |
|
86 | + public static function reset() { |
|
87 | 87 | self::instance()->set_maintenance_mode_if_db_old(); |
88 | 88 | return self::instance(); |
89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function __construct() { |
100 | 100 | // if M-Mode level 2 is engaged, we still need basic assets loaded |
101 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' )); |
|
101 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
102 | 102 | // shut 'er down down for maintenance ? |
103 | - add_filter( 'the_content', array( $this, 'the_content' ), 999 ); |
|
103 | + add_filter('the_content', array($this, 'the_content'), 999); |
|
104 | 104 | // add powered by EE msg |
105 | - add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 ); |
|
105 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * retrieves the maintenance mode option value from the db |
113 | 113 | * @return int |
114 | 114 | */ |
115 | - public function real_level(){ |
|
116 | - return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
115 | + public function real_level() { |
|
116 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * thinks their tables are present and up-to-date). |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function models_can_query(){ |
|
124 | + public function models_can_query() { |
|
125 | 125 | return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance; |
126 | 126 | } |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function level(){ |
|
137 | + public function level() { |
|
138 | 138 | $real_maintenance_mode_level = $this->real_level(); |
139 | 139 | //if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
140 | - if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
140 | + if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | - $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
|
142 | + $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1 |
|
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else { |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * Determines if we need to put EE in maintenance mode because the database needs updating |
152 | 152 | * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
153 | 153 | */ |
154 | - public function set_maintenance_mode_if_db_old(){ |
|
155 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
156 | - if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
154 | + public function set_maintenance_mode_if_db_old() { |
|
155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + }elseif ($this->level() == self::level_2_complete_maintenance) { |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | - update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
|
162 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param int $level |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - public function set_maintenance_level($level){ |
|
175 | - do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level ); |
|
174 | + public function set_maintenance_level($level) { |
|
175 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
176 | 176 | update_option(self::option_name_maintenance_mode, intval($level)); |
177 | 177 | } |
178 | 178 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function load_assets_required_for_m_mode() { |
202 | - if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) { |
|
203 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
202 | + if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) { |
|
203 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
204 | 204 | wp_enqueue_style('espresso_default'); |
205 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
206 | - wp_enqueue_script( 'espresso_core' ); |
|
205 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
206 | + wp_enqueue_script('espresso_core'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @param string $template_path |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function template_include( $template_path ) { |
|
222 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
223 | - $template_located = EEH_Template::locate_template( EE_TEMPLATES . 'maintenance_mode.template.php', FALSE, FALSE ); |
|
221 | + public static function template_include($template_path) { |
|
222 | + EE_Registry::instance()->load_helper('Template'); |
|
223 | + $template_located = EEH_Template::locate_template(EE_TEMPLATES.'maintenance_mode.template.php', FALSE, FALSE); |
|
224 | 224 | return $template_located ? $template_located : $template_path; |
225 | 225 | } |
226 | 226 | |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $the_content |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function the_content( $the_content ) { |
|
238 | + public function the_content($the_content) { |
|
239 | 239 | // check if M-mode is engaged and for EE shortcode |
240 | - if ( $this->level() && strpos( $the_content, '[ESPRESSO_' )) { |
|
240 | + if ($this->level() && strpos($the_content, '[ESPRESSO_')) { |
|
241 | 241 | // this can eventually be moved to a template, or edited via admin. But for now... |
242 | 242 | $the_content = sprintf( |
243 | - __( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ), |
|
243 | + __('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'), |
|
244 | 244 | '<h2>', |
245 | 245 | '</h2><p>', |
246 | 246 | '</p>' |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | // check if M-mode is engaged and for EE shortcode |
265 | 265 | if ( |
266 | 266 | $this->real_level() && |
267 | - current_user_can( 'administrator' ) && |
|
267 | + current_user_can('administrator') && |
|
268 | 268 | ! is_admin() && |
269 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
269 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
270 | 270 | && EE_Registry::instance()->REQ->is_espresso_page() |
271 | 271 | ) { |
272 | 272 | printf( |
273 | - __( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ), |
|
273 | + __('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'), |
|
274 | 274 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
275 | 275 | '">×</a><p>', |
276 | - ' » <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">', |
|
276 | + ' » <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">', |
|
277 | 277 | '</a></p></div>' |
278 | 278 | ); |
279 | 279 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @ return void |
292 | 292 | */ |
293 | 293 | final function __destruct() {} |
294 | - final function __call($a,$b) {} |
|
294 | + final function __call($a, $b) {} |
|
295 | 295 | final function __get($a) {} |
296 | - final function __set($a,$b) {} |
|
296 | + final function __set($a, $b) {} |
|
297 | 297 | final function __isset($a) {} |
298 | 298 | final function __unset($a) {} |
299 | 299 | final function __sleep() { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | final function __invoke() {} |
305 | 305 | final function __set_state() {} |
306 | 306 | final function __clone() {} |
307 | - final static function __callStatic($a,$b) {} |
|
307 | + final static function __callStatic($a, $b) {} |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | // End of file EE_Maintenance_Mode.core.php |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * is_espresso_page |
272 | 272 | * |
273 | 273 | * @access public |
274 | - * @param null $value |
|
274 | + * @param boolean $value |
|
275 | 275 | * @return mixed |
276 | 276 | */ |
277 | 277 | public function set_espresso_page( $value = null ) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * setter |
308 | 308 | * |
309 | 309 | * @access public |
310 | - * @param $key |
|
310 | + * @param string $key |
|
311 | 311 | * @param $value |
312 | 312 | * @param bool $override_ee |
313 | 313 | * @return void |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * remove param |
353 | 353 | * |
354 | 354 | * @access public |
355 | - * @param $key |
|
355 | + * @param string $key |
|
356 | 356 | * @return void |
357 | 357 | */ |
358 | 358 | public function un_set( $key ) { |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * add_output |
393 | 393 | * |
394 | 394 | * @access public |
395 | - * @param $string |
|
395 | + * @param string $string |
|
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | public function add_output( $string ) { |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Event Espresso |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * class EE_Request_Handler |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage /core/ |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Event Espresso |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * class EE_Request_Handler |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage /core/ |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | final class EE_Request_Handler { |
25 | 25 | |
26 | 26 | /** |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @param EE_Request $request |
66 | 66 | * @return \EE_Request_Handler |
67 | 67 | */ |
68 | - public function __construct( EE_Request $request ) { |
|
68 | + public function __construct(EE_Request $request) { |
|
69 | 69 | // grab request vars |
70 | 70 | $this->_params = $request->params(); |
71 | 71 | // AJAX ??? |
72 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
73 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
74 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
72 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
73 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
74 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * @param WP $wp |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public function parse_request( $wp = null ) { |
|
86 | + public function parse_request($wp = null) { |
|
87 | 87 | //if somebody forgot to provide us with WP, that's ok because its global |
88 | - if ( ! $wp instanceof WP ) { |
|
88 | + if ( ! $wp instanceof WP) { |
|
89 | 89 | global $wp; |
90 | 90 | } |
91 | - $this->set_request_vars( $wp ); |
|
91 | + $this->set_request_vars($wp); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @param WP $wp |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function set_request_vars( $wp = null ) { |
|
104 | - if ( ! is_admin() ) { |
|
103 | + public function set_request_vars($wp = null) { |
|
104 | + if ( ! is_admin()) { |
|
105 | 105 | // set request post_id |
106 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
106 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
107 | 107 | // set request post name |
108 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
108 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
109 | 109 | // set request post_type |
110 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
110 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
111 | 111 | // true or false ? is this page being used by EE ? |
112 | 112 | $this->set_espresso_page(); |
113 | 113 | } |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | * @param WP $wp |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function get_post_id_from_request( $wp = null ) { |
|
126 | - if ( ! $wp instanceof WP ){ |
|
125 | + public function get_post_id_from_request($wp = null) { |
|
126 | + if ( ! $wp instanceof WP) { |
|
127 | 127 | global $wp; |
128 | 128 | } |
129 | 129 | $post_id = null; |
130 | - if ( isset( $wp->query_vars['p'] )) { |
|
130 | + if (isset($wp->query_vars['p'])) { |
|
131 | 131 | $post_id = $wp->query_vars['p']; |
132 | 132 | } |
133 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
133 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
134 | 134 | $post_id = $wp->query_vars['page_id']; |
135 | 135 | } |
136 | - if ( ! $post_id && isset( $wp->request )) { |
|
137 | - if ( is_numeric( basename( $wp->request ))) { |
|
138 | - $post_id = basename( $wp->request ); |
|
136 | + if ( ! $post_id && isset($wp->request)) { |
|
137 | + if (is_numeric(basename($wp->request))) { |
|
138 | + $post_id = basename($wp->request); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | return $post_id; |
@@ -150,35 +150,35 @@ discard block |
||
150 | 150 | * @param WP $wp |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_post_name_from_request( $wp = null ) { |
|
154 | - if ( ! $wp instanceof WP ){ |
|
153 | + public function get_post_name_from_request($wp = null) { |
|
154 | + if ( ! $wp instanceof WP) { |
|
155 | 155 | global $wp; |
156 | 156 | } |
157 | 157 | $post_name = null; |
158 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
158 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
159 | 159 | $post_name = $wp->query_vars['name']; |
160 | 160 | } |
161 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
161 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
162 | 162 | $post_name = $wp->query_vars['pagename']; |
163 | 163 | } |
164 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
165 | - $possible_post_name = basename( $wp->request ); |
|
166 | - if ( ! is_numeric( $possible_post_name )) { |
|
164 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
165 | + $possible_post_name = basename($wp->request); |
|
166 | + if ( ! is_numeric($possible_post_name)) { |
|
167 | 167 | /** @type WPDB $wpdb */ |
168 | 168 | global $wpdb; |
169 | 169 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
170 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
171 | - if ( $possible_post_name ) { |
|
170 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
171 | + if ($possible_post_name) { |
|
172 | 172 | $post_name = $possible_post_name; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
176 | + if ( ! $post_name && $this->get('post_id')) { |
|
177 | 177 | /** @type WPDB $wpdb */ |
178 | 178 | global $wpdb; |
179 | 179 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
180 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
181 | - if( $possible_post_name ) { |
|
180 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
181 | + if ($possible_post_name) { |
|
182 | 182 | $post_name = $possible_post_name; |
183 | 183 | } |
184 | 184 | } |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | * @param WP $wp |
195 | 195 | * @return mixed |
196 | 196 | */ |
197 | - public function get_post_type_from_request( $wp = null ) { |
|
198 | - if ( ! $wp instanceof WP ){ |
|
197 | + public function get_post_type_from_request($wp = null) { |
|
198 | + if ( ! $wp instanceof WP) { |
|
199 | 199 | global $wp; |
200 | 200 | } |
201 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
201 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | * @param WP $wp |
209 | 209 | * @return bool|string|void |
210 | 210 | */ |
211 | - public function get_current_page_permalink( $wp = null ) { |
|
212 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
213 | - if ( $post_id ) { |
|
214 | - $current_page_permalink = get_permalink( $post_id ); |
|
211 | + public function get_current_page_permalink($wp = null) { |
|
212 | + $post_id = $this->get_post_id_from_request($wp); |
|
213 | + if ($post_id) { |
|
214 | + $current_page_permalink = get_permalink($post_id); |
|
215 | 215 | } else { |
216 | - if ( ! $wp instanceof WP ) { |
|
216 | + if ( ! $wp instanceof WP) { |
|
217 | 217 | global $wp; |
218 | 218 | } |
219 | - if ( $wp->request ) { |
|
220 | - $current_page_permalink = site_url( $wp->request ); |
|
219 | + if ($wp->request) { |
|
220 | + $current_page_permalink = site_url($wp->request); |
|
221 | 221 | } else { |
222 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
222 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | return $current_page_permalink; |
@@ -236,41 +236,41 @@ discard block |
||
236 | 236 | public function test_for_espresso_page() { |
237 | 237 | global $wp; |
238 | 238 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
239 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
239 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
240 | 240 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
241 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
242 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
243 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
241 | + if (is_array($espresso_CPT_taxonomies)) { |
|
242 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
243 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
244 | 244 | return true; |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | // load espresso CPT endpoints |
249 | 249 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
250 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
251 | - $post_types = (array)$this->get( 'post_type' ); |
|
252 | - foreach ( $post_types as $post_type ) { |
|
250 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
251 | + $post_types = (array) $this->get('post_type'); |
|
252 | + foreach ($post_types as $post_type) { |
|
253 | 253 | // was a post name passed ? |
254 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
254 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
255 | 255 | // kk we know this is an espresso page, but is it a specific post ? |
256 | - if ( ! $this->get( 'post_name' ) ) { |
|
256 | + if ( ! $this->get('post_name')) { |
|
257 | 257 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
258 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
258 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
259 | 259 | // if the post type matches on of our then set the endpoint |
260 | - if ( $post_name ) { |
|
261 | - $this->set( 'post_name', $post_name ); |
|
260 | + if ($post_name) { |
|
261 | + $this->set('post_name', $post_name); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | return true; |
265 | 265 | } |
266 | 266 | } |
267 | - if ( $this->get( 'post_name' )) { |
|
267 | + if ($this->get('post_name')) { |
|
268 | 268 | // load all pages using espresso shortcodes |
269 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
269 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
270 | 270 | // make sure core pages are included |
271 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
271 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
272 | 272 | // was a post name passed ? |
273 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
273 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
274 | 274 | return true; |
275 | 275 | } |
276 | 276 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param null $value |
287 | 287 | * @return mixed |
288 | 288 | */ |
289 | - public function set_espresso_page( $value = null ) { |
|
289 | + public function set_espresso_page($value = null) { |
|
290 | 290 | $value = $value ? $value : $this->test_for_espresso_page(); |
291 | 291 | $this->_params['is_espresso_page'] = $value; |
292 | 292 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return mixed |
301 | 301 | */ |
302 | 302 | public function is_espresso_page() { |
303 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
303 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * @param bool $override_ee |
325 | 325 | * @return void |
326 | 326 | */ |
327 | - public function set( $key, $value, $override_ee = false ) { |
|
327 | + public function set($key, $value, $override_ee = false) { |
|
328 | 328 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
329 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
330 | - $this->_params[ $key ] = $value; |
|
329 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
330 | + $this->_params[$key] = $value; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param null $default |
342 | 342 | * @return mixed |
343 | 343 | */ |
344 | - public function get( $key, $default = null ) { |
|
345 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
344 | + public function get($key, $default = null) { |
|
345 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param $key |
355 | 355 | * @return boolean |
356 | 356 | */ |
357 | - public function is_set( $key ) { |
|
358 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
357 | + public function is_set($key) { |
|
358 | + return isset($this->_params[$key]) ? true : false; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param $key |
368 | 368 | * @return void |
369 | 369 | */ |
370 | - public function un_set( $key ) { |
|
371 | - unset( $this->_params[ $key ] ); |
|
370 | + public function un_set($key) { |
|
371 | + unset($this->_params[$key]); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | * @param $value |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public function set_notice( $key, $value ) { |
|
385 | - $this->_notice[ $key ] = $value; |
|
384 | + public function set_notice($key, $value) { |
|
385 | + $this->_notice[$key] = $value; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @param $key |
395 | 395 | * @return mixed |
396 | 396 | */ |
397 | - public function get_notice( $key ) { |
|
398 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
397 | + public function get_notice($key) { |
|
398 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param $string |
408 | 408 | * @return void |
409 | 409 | */ |
410 | - public function add_output( $string ) { |
|
410 | + public function add_output($string) { |
|
411 | 411 | $this->_output .= $string; |
412 | 412 | } |
413 | 413 | |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param $item |
430 | 430 | * @param $key |
431 | 431 | */ |
432 | - function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
433 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
432 | + function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
433 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param $b |
441 | 441 | * @return bool |
442 | 442 | */ |
443 | - public function __set($a,$b) { return false; } |
|
443 | + public function __set($a, $b) { return false; } |
|
444 | 444 | |
445 | 445 | |
446 | 446 |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * retrieve session data |
338 | 338 | * @access public |
339 | - * @param null $key |
|
339 | + * @param string|null $key |
|
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * set session data |
361 | 361 | * @access public |
362 | 362 | * @param array $data |
363 | - * @return TRUE on success, FALSE on fail |
|
363 | + * @return boolean on success, FALSE on fail |
|
364 | 364 | */ |
365 | 365 | public function set_session_data( $data ) { |
366 | 366 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @initiate session |
392 | 392 | * @access private |
393 | - * @return TRUE on success, FALSE on fail |
|
393 | + * @return boolean on success, FALSE on fail |
|
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | 396 | private function _espresso_session() { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @update session data prior to saving to the db |
522 | 522 | * @access public |
523 | 523 | * @param bool $new_session |
524 | - * @return TRUE on success, FALSE on fail |
|
524 | + * @return boolean on success, FALSE on fail |
|
525 | 525 | */ |
526 | 526 | public function update( $new_session = FALSE ) { |
527 | 527 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @access public |
792 | 792 | * @param array $data_to_reset |
793 | 793 | * @param bool $show_all_notices |
794 | - * @return TRUE on success, FALSE on fail |
|
794 | + * @return boolean on success, FALSE on fail |
|
795 | 795 | */ |
796 | 796 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
797 | 797 | // if $data_to_reset is not in an array, then put it in one |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
3 | 5 | * |
4 | 6 | * Event Espresso |
@@ -349,7 +351,7 @@ discard block |
||
349 | 351 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
350 | 352 | if ( ! empty( $key )) { |
351 | 353 | return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
352 | - } else { |
|
354 | + } else { |
|
353 | 355 | return $this->_session_data; |
354 | 356 | } |
355 | 357 | } |
@@ -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 | * |
4 | 4 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @param \EE_Encryption $encryption |
128 | 128 | * @return EE_Session |
129 | 129 | */ |
130 | - public static function instance( EE_Encryption $encryption = null ) { |
|
130 | + public static function instance(EE_Encryption $encryption = null) { |
|
131 | 131 | // check if class object is instantiated |
132 | 132 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
133 | 133 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
134 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
135 | - self::$_instance = new self( $encryption ); |
|
134 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
135 | + self::$_instance = new self($encryption); |
|
136 | 136 | } |
137 | 137 | return self::$_instance; |
138 | 138 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @access protected |
146 | 146 | * @param \EE_Encryption $encryption |
147 | 147 | */ |
148 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
148 | + protected function __construct(EE_Encryption $encryption = null) { |
|
149 | 149 | |
150 | 150 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
151 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
151 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
152 | 152 | return NULL; |
153 | 153 | } |
154 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
155 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
156 | - define( 'ESPRESSO_SESSION', true ); |
|
154 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
155 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
156 | + define('ESPRESSO_SESSION', true); |
|
157 | 157 | } |
158 | 158 | // default session lifespan in seconds |
159 | 159 | $this->_lifespan = apply_filters( |
@@ -167,35 +167,35 @@ discard block |
||
167 | 167 | * } |
168 | 168 | */ |
169 | 169 | // retrieve session options from db |
170 | - $session_settings = get_option( 'ee_session_settings' ); |
|
171 | - if ( $session_settings !== FALSE ) { |
|
170 | + $session_settings = get_option('ee_session_settings'); |
|
171 | + if ($session_settings !== FALSE) { |
|
172 | 172 | // cycle though existing session options |
173 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
173 | + foreach ($session_settings as $var_name => $session_setting) { |
|
174 | 174 | // set values for class properties |
175 | - $var_name = '_' . $var_name; |
|
175 | + $var_name = '_'.$var_name; |
|
176 | 176 | $this->{$var_name} = $session_setting; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | // are we using encryption? |
180 | - if ( $this->_use_encryption && $encryption instanceof EE_Encryption ) { |
|
180 | + if ($this->_use_encryption && $encryption instanceof EE_Encryption) { |
|
181 | 181 | // encrypt data via: $this->encryption->encrypt(); |
182 | 182 | $this->encryption = $encryption; |
183 | 183 | } |
184 | 184 | // filter hook allows outside functions/classes/plugins to change default empty cart |
185 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
186 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
185 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
186 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
187 | 187 | // apply default session vars |
188 | 188 | $this->_set_defaults(); |
189 | 189 | // check for existing session and retrieve it from db |
190 | - if ( ! $this->_espresso_session() ) { |
|
190 | + if ( ! $this->_espresso_session()) { |
|
191 | 191 | // or just start a new one |
192 | 192 | $this->_create_espresso_session(); |
193 | 193 | } |
194 | 194 | // check request for 'clear_session' param |
195 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
195 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
196 | 196 | // once everything is all said and done, |
197 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
198 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
197 | + add_action('shutdown', array($this, 'update'), 100); |
|
198 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function _set_defaults() { |
229 | 229 | // set some defaults |
230 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
231 | - if ( is_array( $default_var )) { |
|
232 | - $this->_session_data[ $key ] = array(); |
|
230 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
231 | + if (is_array($default_var)) { |
|
232 | + $this->_session_data[$key] = array(); |
|
233 | 233 | } else { |
234 | - $this->_session_data[ $key ] = ''; |
|
234 | + $this->_session_data[$key] = ''; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param \EE_Cart $cart |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function set_cart( EE_Cart $cart ) { |
|
256 | + public function set_cart(EE_Cart $cart) { |
|
257 | 257 | $this->_session_data['cart'] = $cart; |
258 | 258 | return TRUE; |
259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return \EE_Cart |
274 | 274 | */ |
275 | 275 | public function cart() { |
276 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
276 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param \EE_Checkout $checkout |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public function set_checkout( EE_Checkout $checkout ) { |
|
285 | + public function set_checkout(EE_Checkout $checkout) { |
|
286 | 286 | $this->_session_data['checkout'] = $checkout; |
287 | 287 | return TRUE; |
288 | 288 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return \EE_Checkout |
303 | 303 | */ |
304 | 304 | public function checkout() { |
305 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
305 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param \EE_Transaction $transaction |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | - public function set_transaction( EE_Transaction $transaction ) { |
|
314 | + public function set_transaction(EE_Transaction $transaction) { |
|
315 | 315 | // first remove the session from the transaction before we save the transaction in the session |
316 | - $transaction->set_txn_session_data( NULL ); |
|
316 | + $transaction->set_txn_session_data(NULL); |
|
317 | 317 | $this->_session_data['transaction'] = $transaction; |
318 | 318 | return TRUE; |
319 | 319 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return \EE_Transaction |
334 | 334 | */ |
335 | 335 | public function transaction() { |
336 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
336 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | * @param bool $reset_cache |
346 | 346 | * @return array |
347 | 347 | */ |
348 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
349 | - if ( $reset_cache ) { |
|
348 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
349 | + if ($reset_cache) { |
|
350 | 350 | $this->reset_cart(); |
351 | 351 | $this->reset_checkout(); |
352 | 352 | $this->reset_transaction(); |
353 | 353 | } |
354 | - if ( ! empty( $key )) { |
|
355 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
356 | - } else { |
|
354 | + if ( ! empty($key)) { |
|
355 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
356 | + } else { |
|
357 | 357 | return $this->_session_data; |
358 | 358 | } |
359 | 359 | } |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | * @param array $data |
367 | 367 | * @return TRUE on success, FALSE on fail |
368 | 368 | */ |
369 | - public function set_session_data( $data ) { |
|
369 | + public function set_session_data($data) { |
|
370 | 370 | |
371 | 371 | // nothing ??? bad data ??? go home! |
372 | - if ( empty( $data ) || ! is_array( $data )) { |
|
373 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + if (empty($data) || ! is_array($data)) { |
|
373 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
374 | 374 | return FALSE; |
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $data as $key =>$value ) { |
|
378 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
379 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
377 | + foreach ($data as $key =>$value) { |
|
378 | + if (isset($this->_default_session_vars[$key])) { |
|
379 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
380 | 380 | return FALSE; |
381 | 381 | } else { |
382 | - $this->_session_data[ $key ] = $value; |
|
382 | + $this->_session_data[$key] = $value; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
399 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
399 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
400 | 400 | // check that session has started |
401 | - if ( session_id() === '' ) { |
|
401 | + if (session_id() === '') { |
|
402 | 402 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
403 | 403 | session_start(); |
404 | 404 | } |
@@ -407,57 +407,57 @@ discard block |
||
407 | 407 | // and the visitors IP |
408 | 408 | $this->_ip_address = $this->_visitor_ip(); |
409 | 409 | // set the "user agent" |
410 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
410 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
411 | 411 | // now let's retrieve what's in the db |
412 | 412 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
413 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
414 | - if ( $session_data ) { |
|
415 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
416 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
417 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
413 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
414 | + if ($session_data) { |
|
415 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
416 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
417 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
418 | 418 | EE_Error::add_error( |
419 | 419 | sprintf( |
420 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
421 | - EE_Session::session_id_prefix . $this->_sid |
|
420 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
421 | + EE_Session::session_id_prefix.$this->_sid |
|
422 | 422 | ), |
423 | 423 | __FILE__, __FUNCTION__, __LINE__ |
424 | 424 | ); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | // un-encrypt the data |
428 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
428 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
429 | 429 | // unserialize |
430 | - $session_data = maybe_unserialize( $session_data ); |
|
430 | + $session_data = maybe_unserialize($session_data); |
|
431 | 431 | // just a check to make sure the session array is indeed an array |
432 | - if ( ! is_array( $session_data ) ) { |
|
432 | + if ( ! is_array($session_data)) { |
|
433 | 433 | // no?!?! then something is wrong |
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | // get the current time in UTC |
437 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
437 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
438 | 438 | // and reset the session expiration |
439 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
439 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
440 | 440 | |
441 | 441 | } else { |
442 | 442 | // set initial site access time and the session expiration |
443 | 443 | $this->_set_init_access_and_expiration(); |
444 | 444 | // set referer |
445 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
445 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
446 | 446 | // no previous session = go back and create one (on top of the data above) |
447 | 447 | return FALSE; |
448 | 448 | } |
449 | 449 | // now the user agent |
450 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
450 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
451 | 451 | return FALSE; |
452 | 452 | } |
453 | 453 | // wait a minute... how old are you? |
454 | - if ( $this->_time > $this->_expiration ) { |
|
454 | + if ($this->_time > $this->_expiration) { |
|
455 | 455 | // yer too old fer me! |
456 | 456 | // wipe out everything that isn't a default session datum |
457 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
457 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
458 | 458 | } |
459 | 459 | // make event espresso session data available to plugin |
460 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
460 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
461 | 461 | return TRUE; |
462 | 462 | |
463 | 463 | } |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | */ |
476 | 476 | protected function _generate_session_id() { |
477 | 477 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
478 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
479 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
478 | + if (isset($_REQUEST['EESID'])) { |
|
479 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
480 | 480 | } else { |
481 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
481 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
482 | 482 | } |
483 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
483 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -492,20 +492,20 @@ discard block |
||
492 | 492 | */ |
493 | 493 | protected function _get_sid_salt() { |
494 | 494 | // was session id salt already saved to db ? |
495 | - if ( empty( $this->_sid_salt ) ) { |
|
495 | + if (empty($this->_sid_salt)) { |
|
496 | 496 | // no? then maybe use WP defined constant |
497 | - if ( defined( 'AUTH_SALT' ) ) { |
|
497 | + if (defined('AUTH_SALT')) { |
|
498 | 498 | $this->_sid_salt = AUTH_SALT; |
499 | 499 | } |
500 | 500 | // if salt doesn't exist or is too short |
501 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
501 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
502 | 502 | // create a new one |
503 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
503 | + $this->_sid_salt = wp_generate_password(64); |
|
504 | 504 | } |
505 | 505 | // and save it as a permanent session setting |
506 | - $session_settings = get_option( 'ee_session_settings' ); |
|
507 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
508 | - update_option( 'ee_session_settings', $session_settings ); |
|
506 | + $session_settings = get_option('ee_session_settings'); |
|
507 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
508 | + update_option('ee_session_settings', $session_settings); |
|
509 | 509 | } |
510 | 510 | return $this->_sid_salt; |
511 | 511 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param bool $new_session |
534 | 534 | * @return TRUE on success, FALSE on fail |
535 | 535 | */ |
536 | - public function update( $new_session = FALSE ) { |
|
537 | - $this->_session_data = isset( $this->_session_data ) |
|
538 | - && is_array( $this->_session_data ) |
|
539 | - && isset( $this->_session_data['id']) |
|
536 | + public function update($new_session = FALSE) { |
|
537 | + $this->_session_data = isset($this->_session_data) |
|
538 | + && is_array($this->_session_data) |
|
539 | + && isset($this->_session_data['id']) |
|
540 | 540 | ? $this->_session_data |
541 | 541 | : NULL; |
542 | - if ( empty( $this->_session_data )) { |
|
542 | + if (empty($this->_session_data)) { |
|
543 | 543 | $this->_set_defaults(); |
544 | 544 | } |
545 | 545 | $session_data = array(); |
546 | - foreach ( $this->_session_data as $key => $value ) { |
|
546 | + foreach ($this->_session_data as $key => $value) { |
|
547 | 547 | |
548 | - switch( $key ) { |
|
548 | + switch ($key) { |
|
549 | 549 | |
550 | 550 | case 'id' : |
551 | 551 | // session ID |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | break; |
564 | 564 | |
565 | 565 | case 'init_access' : |
566 | - $session_data['init_access'] = absint( $value ); |
|
566 | + $session_data['init_access'] = absint($value); |
|
567 | 567 | break; |
568 | 568 | |
569 | 569 | case 'last_access' : |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'expiration' : |
575 | 575 | // when the session expires |
576 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
576 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
577 | 577 | ? $this->_expiration |
578 | 578 | : $session_data['init_access'] + $this->_lifespan; |
579 | 579 | break; |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | |
586 | 586 | case 'pages_visited' : |
587 | 587 | $page_visit = $this->_get_page_visit(); |
588 | - if ( $page_visit ) { |
|
588 | + if ($page_visit) { |
|
589 | 589 | // set pages visited where the first will be the http referrer |
590 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
590 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
591 | 591 | // we'll only save the last 10 page visits. |
592 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
592 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | |
604 | 604 | $this->_session_data = $session_data; |
605 | 605 | // creating a new session does not require saving to the db just yet |
606 | - if ( ! $new_session ) { |
|
606 | + if ( ! $new_session) { |
|
607 | 607 | // ready? let's save |
608 | - if ( $this->_save_session_to_db() ) { |
|
608 | + if ($this->_save_session_to_db()) { |
|
609 | 609 | return TRUE; |
610 | 610 | } else { |
611 | 611 | return FALSE; |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * @return bool |
627 | 627 | */ |
628 | 628 | private function _create_espresso_session( ) { |
629 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
629 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
630 | 630 | // use the update function for now with $new_session arg set to TRUE |
631 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
631 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | return FALSE; |
653 | 653 | } |
654 | 654 | // first serialize all of our session data |
655 | - $session_data = serialize( $this->_session_data ); |
|
655 | + $session_data = serialize($this->_session_data); |
|
656 | 656 | // encrypt it if we are using encryption |
657 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
657 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
658 | 658 | // maybe save hash check |
659 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
660 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
659 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
660 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
661 | 661 | } |
662 | 662 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
663 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
663 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | 'HTTP_FORWARDED', |
687 | 687 | 'REMOTE_ADDR' |
688 | 688 | ); |
689 | - foreach ( $server_keys as $key ){ |
|
690 | - if ( isset( $_SERVER[ $key ] )) { |
|
691 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
692 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
689 | + foreach ($server_keys as $key) { |
|
690 | + if (isset($_SERVER[$key])) { |
|
691 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
692 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
693 | 693 | $visitor_ip = $ip; |
694 | 694 | } |
695 | 695 | } |
@@ -710,45 +710,45 @@ discard block |
||
710 | 710 | public function _get_page_visit() { |
711 | 711 | |
712 | 712 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
713 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
713 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
714 | 714 | |
715 | 715 | // check for request url |
716 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
716 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
717 | 717 | |
718 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
718 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
719 | 719 | |
720 | - $ru_bits = explode( '?', $request_uri ); |
|
720 | + $ru_bits = explode('?', $request_uri); |
|
721 | 721 | $request_uri = $ru_bits[0]; |
722 | 722 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
723 | 723 | |
724 | 724 | // check for and grab host as well |
725 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
726 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
725 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
726 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
727 | 727 | } else { |
728 | 728 | $http_host = ''; |
729 | 729 | } |
730 | 730 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
731 | 731 | |
732 | 732 | // check for page_id in SERVER REQUEST |
733 | - if ( isset( $_REQUEST['page_id'] )) { |
|
733 | + if (isset($_REQUEST['page_id'])) { |
|
734 | 734 | // rebuild $e_reg without any of the extra parameters |
735 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
735 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
736 | 736 | } else { |
737 | 737 | $page_id = '?'; |
738 | 738 | } |
739 | 739 | // check for $e_reg in SERVER REQUEST |
740 | - if ( isset( $_REQUEST['ee'] )) { |
|
740 | + if (isset($_REQUEST['ee'])) { |
|
741 | 741 | // rebuild $e_reg without any of the extra parameters |
742 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
742 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
743 | 743 | } else { |
744 | 744 | $e_reg = ''; |
745 | 745 | } |
746 | 746 | |
747 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
747 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
751 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
@@ -777,14 +777,14 @@ discard block |
||
777 | 777 | * @param string $function |
778 | 778 | * @return void |
779 | 779 | */ |
780 | - public function clear_session( $class = '', $function = '' ) { |
|
780 | + public function clear_session($class = '', $function = '') { |
|
781 | 781 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
782 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
782 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
783 | 783 | $this->reset_cart(); |
784 | 784 | $this->reset_checkout(); |
785 | 785 | $this->reset_transaction(); |
786 | 786 | // wipe out everything that isn't a default session datum |
787 | - $this->reset_data( array_keys( $this->_session_data )); |
|
787 | + $this->reset_data(array_keys($this->_session_data)); |
|
788 | 788 | // reset initial site access time and the session expiration |
789 | 789 | $this->_set_init_access_and_expiration(); |
790 | 790 | $this->_save_session_to_db(); |
@@ -799,42 +799,42 @@ discard block |
||
799 | 799 | * @param bool $show_all_notices |
800 | 800 | * @return TRUE on success, FALSE on fail |
801 | 801 | */ |
802 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
802 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
803 | 803 | // if $data_to_reset is not in an array, then put it in one |
804 | - if ( ! is_array( $data_to_reset ) ) { |
|
805 | - $data_to_reset = array ( $data_to_reset ); |
|
804 | + if ( ! is_array($data_to_reset)) { |
|
805 | + $data_to_reset = array($data_to_reset); |
|
806 | 806 | } |
807 | 807 | // nothing ??? go home! |
808 | - if ( empty( $data_to_reset )) { |
|
809 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
808 | + if (empty($data_to_reset)) { |
|
809 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
810 | 810 | return FALSE; |
811 | 811 | } |
812 | 812 | $return_value = TRUE; |
813 | 813 | // since $data_to_reset is an array, cycle through the values |
814 | - foreach ( $data_to_reset as $reset ) { |
|
814 | + foreach ($data_to_reset as $reset) { |
|
815 | 815 | |
816 | 816 | // first check to make sure it is a valid session var |
817 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
817 | + if (isset($this->_session_data[$reset])) { |
|
818 | 818 | // then check to make sure it is not a default var |
819 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
819 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
820 | 820 | // remove session var |
821 | - unset( $this->_session_data[ $reset ] ); |
|
822 | - if ( $show_all_notices ) { |
|
823 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
821 | + unset($this->_session_data[$reset]); |
|
822 | + if ($show_all_notices) { |
|
823 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
824 | 824 | } |
825 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
825 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
826 | 826 | |
827 | 827 | } else { |
828 | 828 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
829 | - if ( $show_all_notices ) { |
|
830 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
829 | + if ($show_all_notices) { |
|
830 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } |
832 | 832 | $return_value = FALSE; |
833 | 833 | } |
834 | 834 | |
835 | - } else if ( $show_all_notices ) { |
|
835 | + } else if ($show_all_notices) { |
|
836 | 836 | // oops! that session var does not exist! |
837 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
837 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
838 | 838 | $return_value = FALSE; |
839 | 839 | } |
840 | 840 | |
@@ -855,8 +855,8 @@ discard block |
||
855 | 855 | * @return string |
856 | 856 | */ |
857 | 857 | public function wp_loaded() { |
858 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
859 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
858 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
859 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -881,24 +881,24 @@ discard block |
||
881 | 881 | */ |
882 | 882 | public function garbage_collection() { |
883 | 883 | // only perform during regular requests |
884 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
884 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
885 | 885 | /** @type WPDB $wpdb */ |
886 | 886 | global $wpdb; |
887 | 887 | // since transient expiration timestamps are set in the future, we can compare against NOW |
888 | 888 | $expiration = time(); |
889 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
889 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
890 | 890 | // filter the query limit. Set to 0 to turn off garbage collection |
891 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
891 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
892 | 892 | // non-zero LIMIT means take out the trash |
893 | - if ( $expired_session_transient_delete_query_limit ) { |
|
893 | + if ($expired_session_transient_delete_query_limit) { |
|
894 | 894 | //array of transient keys that require garbage collection |
895 | 895 | $session_keys = array( |
896 | 896 | EE_Session::session_id_prefix, |
897 | 897 | EE_Session::hash_check_prefix, |
898 | 898 | ); |
899 | - foreach ( $session_keys as $session_key ) { |
|
900 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
901 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
899 | + foreach ($session_keys as $session_key) { |
|
900 | + $session_key = str_replace('_', '\_', $session_key); |
|
901 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
902 | 902 | $SQL = " |
903 | 903 | SELECT option_name |
904 | 904 | FROM {$wpdb->options} |
@@ -908,28 +908,28 @@ discard block |
||
908 | 908 | OR option_value > {$too_far_in_the_the_future} ) |
909 | 909 | LIMIT {$expired_session_transient_delete_query_limit} |
910 | 910 | "; |
911 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
911 | + $expired_sessions = $wpdb->get_col($SQL); |
|
912 | 912 | // valid results? |
913 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
913 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
914 | 914 | // format array of results into something usable within the actual DELETE query's IN clause |
915 | 915 | $expired = array(); |
916 | - foreach ( $expired_sessions as $expired_session ) { |
|
917 | - $expired[ ] = "'" . $expired_session . "'"; |
|
918 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
916 | + foreach ($expired_sessions as $expired_session) { |
|
917 | + $expired[] = "'".$expired_session."'"; |
|
918 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
919 | 919 | } |
920 | - $expired = implode( ', ', $expired ); |
|
920 | + $expired = implode(', ', $expired); |
|
921 | 921 | $SQL = " |
922 | 922 | DELETE FROM {$wpdb->options} |
923 | 923 | WHERE option_name |
924 | 924 | IN ( $expired ); |
925 | 925 | "; |
926 | - $results = $wpdb->query( $SQL ); |
|
926 | + $results = $wpdb->query($SQL); |
|
927 | 927 | // if something went wrong, then notify the admin |
928 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
929 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
928 | + if ($results instanceof WP_Error && is_admin()) { |
|
929 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
930 | 930 | } |
931 | 931 | } |
932 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
932 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
933 | 933 | } |
934 | 934 | } |
935 | 935 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param mixed $opt_group |
776 | 776 | * @param mixed $QSOs |
777 | - * @param mixed $answer |
|
777 | + * @param string $answer |
|
778 | 778 | * @return string |
779 | 779 | */ |
780 | 780 | private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * prep_required |
1124 | 1124 | * @param string|array $required |
1125 | - * @return array |
|
1125 | + * @return string |
|
1126 | 1126 | */ |
1127 | 1127 | static function prep_required( $required = array() ){ |
1128 | 1128 | // make sure required is an array |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * _load_system_dropdowns |
1176 | - * @param array $QFI |
|
1177 | - * @return array |
|
1176 | + * @param EE_Question_Form_Input $QFI |
|
1177 | + * @return EE_Question_Form_Input |
|
1178 | 1178 | */ |
1179 | 1179 | private static function _load_system_dropdowns( $QFI ){ |
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | * @param string $nonce_action - if using nonces |
1464 | 1464 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | - * @return void |
|
1466 | + * @return string |
|
1467 | 1467 | */ |
1468 | 1468 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1469 | 1469 | $btn = ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,22 +363,22 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | //load formatter helper |
374 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
374 | + EE_Registry::instance()->load_helper('Formatter'); |
|
375 | 375 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
376 | 376 | |
377 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
377 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
378 | 378 | //Debug |
379 | 379 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
380 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | - $field .= ' ' . $parameters; |
|
380 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | + $field .= ' '.$parameters; |
|
382 | 382 | if ($autosize) { |
383 | 383 | $size = 'med'; |
384 | 384 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | $size = ''; |
392 | 392 | } |
393 | 393 | |
394 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
394 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
395 | 395 | |
396 | 396 | if (empty($default) && isset($GLOBALS[$name])) |
397 | 397 | $default = stripslashes($GLOBALS[$name]); |
398 | 398 | |
399 | 399 | |
400 | 400 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
401 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
401 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
402 | 402 | if ($default == $values[$i]['id']) { |
403 | 403 | $field .= ' selected = "selected"'; |
404 | 404 | } |
405 | - if ( isset( $values[$i]['class'] ) ) { |
|
406 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
405 | + if (isset($values[$i]['class'])) { |
|
406 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
407 | 407 | } |
408 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
408 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
409 | 409 | } |
410 | 410 | $field .= '</select>'; |
411 | 411 | |
@@ -423,38 +423,38 @@ discard block |
||
423 | 423 | * @param string $question_groups |
424 | 424 | * @return string HTML |
425 | 425 | */ |
426 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
426 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
427 | 427 | |
428 | 428 | $html = ''; |
429 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
430 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
429 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
430 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
431 | 431 | |
432 | - if ( ! empty( $question_groups )) { |
|
432 | + if ( ! empty($question_groups)) { |
|
433 | 433 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
434 | 434 | // loop thru question groups |
435 | - foreach ( $question_groups as $QSG ) { |
|
435 | + foreach ($question_groups as $QSG) { |
|
436 | 436 | // check that questions exist |
437 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
437 | + if ( ! empty($QSG['QSG_questions'])) { |
|
438 | 438 | // use fieldsets |
439 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
439 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
440 | 440 | // group_name |
441 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
441 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
442 | 442 | // group_desc |
443 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
443 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
444 | 444 | |
445 | 445 | $html .= $before_question_group_questions; |
446 | 446 | // loop thru questions |
447 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
447 | + foreach ($QSG['QSG_questions'] as $question) { |
|
448 | 448 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
449 | 449 | $QFI = new EE_Question_Form_Input( |
450 | 450 | $question['qst_obj'], |
451 | 451 | $question['ans_obj'], |
452 | 452 | $question |
453 | 453 | ); |
454 | - $html .= self::generate_form_input( $QFI ); |
|
454 | + $html .= self::generate_form_input($QFI); |
|
455 | 455 | } |
456 | 456 | $html .= $after_question_group_questions; |
457 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
457 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $group_wrapper |
475 | 475 | * @return string HTML |
476 | 476 | */ |
477 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
477 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
478 | 478 | |
479 | 479 | $html = ''; |
480 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
481 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
480 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
481 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
482 | 482 | |
483 | 483 | $default_q_meta = array( |
484 | 484 | 'att_nmbr' => 1, |
@@ -487,55 +487,55 @@ discard block |
||
487 | 487 | 'input_id' => '', |
488 | 488 | 'input_class' => '' |
489 | 489 | ); |
490 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
490 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
491 | 491 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | |
493 | - if ( ! empty( $question_groups )) { |
|
493 | + if ( ! empty($question_groups)) { |
|
494 | 494 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
495 | 495 | // loop thru question groups |
496 | - foreach ( $question_groups as $QSG ) { |
|
497 | - if ( $QSG instanceof EE_Question_Group ) { |
|
496 | + foreach ($question_groups as $QSG) { |
|
497 | + if ($QSG instanceof EE_Question_Group) { |
|
498 | 498 | // check that questions exist |
499 | 499 | |
500 | - $where = array( 'QST_deleted' => 0 ); |
|
501 | - if ( ! $from_admin ) { |
|
500 | + $where = array('QST_deleted' => 0); |
|
501 | + if ( ! $from_admin) { |
|
502 | 502 | $where['QST_admin_only'] = 0; |
503 | 503 | } |
504 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
505 | - if ( ! empty( $questions )) { |
|
504 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
505 | + if ( ! empty($questions)) { |
|
506 | 506 | // use fieldsets |
507 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
507 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
508 | 508 | // group_name |
509 | - if ( $QSG->show_group_name() ) { |
|
510 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
509 | + if ($QSG->show_group_name()) { |
|
510 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
511 | 511 | } |
512 | 512 | // group_desc |
513 | - if ( $QSG->show_group_desc() ) { |
|
514 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
513 | + if ($QSG->show_group_desc()) { |
|
514 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $html .= $before_question_group_questions; |
518 | 518 | // loop thru questions |
519 | - foreach ( $questions as $QST ) { |
|
519 | + foreach ($questions as $QST) { |
|
520 | 520 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
521 | 521 | |
522 | 522 | $answer = NULL; |
523 | 523 | |
524 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
524 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
525 | 525 | // check for answer in $_GET in case we are reprocessing a form after an error |
526 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
527 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
526 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
527 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
528 | 528 | } |
529 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
529 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
530 | 530 | //attendee data from the session |
531 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
531 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | |
536 | 536 | $QFI = new EE_Question_Form_Input( |
537 | 537 | $QST, |
538 | - EE_Answer::new_instance ( array( |
|
538 | + EE_Answer::new_instance(array( |
|
539 | 539 | 'ANS_ID'=> 0, |
540 | 540 | 'QST_ID'=> 0, |
541 | 541 | 'REG_ID'=> 0, |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | $q_meta |
545 | 545 | ); |
546 | 546 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
547 | - $html .= self::generate_form_input( $QFI ); |
|
547 | + $html .= self::generate_form_input($QFI); |
|
548 | 548 | } |
549 | 549 | $html .= $after_question_group_questions; |
550 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
550 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -567,63 +567,63 @@ discard block |
||
567 | 567 | * @param EE_Question_Form_Input $QFI |
568 | 568 | * @return string HTML |
569 | 569 | */ |
570 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
571 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
570 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
571 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
576 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
575 | + $QFI = self::_load_system_dropdowns($QFI); |
|
576 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
577 | 577 | |
578 | 578 | //we also need to verify |
579 | 579 | |
580 | 580 | $display_text = $QFI->get('QST_display_text'); |
581 | 581 | $input_name = $QFI->get('QST_input_name'); |
582 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
582 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
583 | 583 | $input_id = $QFI->get('QST_input_id'); |
584 | 584 | $input_class = $QFI->get('QST_input_class'); |
585 | 585 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
586 | 586 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
587 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
587 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
588 | 588 | $QST_required = $QFI->get('QST_required'); |
589 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
590 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
591 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
592 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
589 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
590 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
591 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
592 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
593 | 593 | $label_class = 'espresso-form-input-lbl'; |
594 | - $QST_options = $QFI->options(true,$answer); |
|
595 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
594 | + $QST_options = $QFI->options(true, $answer); |
|
595 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
596 | 596 | $system_ID = $QFI->get('QST_system'); |
597 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
598 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
597 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
598 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
599 | 599 | |
600 | 600 | |
601 | - switch ( $QFI->get('QST_type') ){ |
|
601 | + switch ($QFI->get('QST_type')) { |
|
602 | 602 | |
603 | 603 | case 'TEXTAREA' : |
604 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
604 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
605 | 605 | break; |
606 | 606 | |
607 | 607 | case 'DROPDOWN' : |
608 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
608 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
609 | 609 | break; |
610 | 610 | |
611 | 611 | |
612 | 612 | case 'RADIO_BTN' : |
613 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
613 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
614 | 614 | break; |
615 | 615 | |
616 | 616 | case 'CHECKBOX' : |
617 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
617 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
618 | 618 | break; |
619 | 619 | |
620 | 620 | case 'DATE' : |
621 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
621 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
622 | 622 | break; |
623 | 623 | |
624 | 624 | case 'TEXT' : |
625 | 625 | default: |
626 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
626 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
627 | 627 | break; |
628 | 628 | |
629 | 629 | } |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string $disabled disabled="disabled" or null |
650 | 650 | * @return string HTML |
651 | 651 | */ |
652 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
652 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
653 | 653 | // need these |
654 | - if ( ! $question || ! $name ) { |
|
654 | + if ( ! $question || ! $name) { |
|
655 | 655 | return NULL; |
656 | 656 | } |
657 | 657 | // prep the answer |
658 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
658 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
659 | 659 | // prep the required array |
660 | - $required = self::prep_required( $required ); |
|
660 | + $required = self::prep_required($required); |
|
661 | 661 | // set disabled tag |
662 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
662 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
663 | 663 | // ya gots ta have style man!!! |
664 | 664 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
665 | - $class = empty( $class ) ? $txt_class : $class; |
|
666 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
667 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
665 | + $class = empty($class) ? $txt_class : $class; |
|
666 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
667 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
668 | 668 | |
669 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
669 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
670 | 670 | // filter label but ensure required text comes before it |
671 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
671 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
672 | 672 | |
673 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
673 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
674 | 674 | |
675 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
676 | - return $label_html . $input_html; |
|
675 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
676 | + return $label_html.$input_html; |
|
677 | 677 | |
678 | 678 | } |
679 | 679 | |
@@ -695,35 +695,35 @@ discard block |
||
695 | 695 | * @param string $disabled disabled="disabled" or null |
696 | 696 | * @return string HTML |
697 | 697 | */ |
698 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
698 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
699 | 699 | // need these |
700 | - if ( ! $question || ! $name ) { |
|
700 | + if ( ! $question || ! $name) { |
|
701 | 701 | return NULL; |
702 | 702 | } |
703 | 703 | // prep the answer |
704 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
704 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
705 | 705 | // prep the required array |
706 | - $required = self::prep_required( $required ); |
|
706 | + $required = self::prep_required($required); |
|
707 | 707 | // make sure $dimensions is an array |
708 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
708 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
709 | 709 | // and set some defaults |
710 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
710 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
711 | 711 | // set disabled tag |
712 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
712 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
713 | 713 | // ya gots ta have style man!!! |
714 | 714 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
715 | - $class = empty( $class ) ? $txt_class : $class; |
|
716 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
717 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
715 | + $class = empty($class) ? $txt_class : $class; |
|
716 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
717 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
718 | 718 | |
719 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
719 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
720 | 720 | // filter label but ensure required text comes before it |
721 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
721 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
722 | 722 | |
723 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
723 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
724 | 724 | |
725 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
726 | - return $label_html . $input_html; |
|
725 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
726 | + return $label_html.$input_html; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | |
@@ -746,47 +746,47 @@ discard block |
||
746 | 746 | * @param string $disabled disabled="disabled" or null |
747 | 747 | * @return string HTML |
748 | 748 | */ |
749 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
749 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
750 | 750 | |
751 | 751 | // need these |
752 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
752 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
753 | 753 | return NULL; |
754 | 754 | } |
755 | 755 | // prep the answer |
756 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
756 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
757 | 757 | // prep the required array |
758 | - $required = self::prep_required( $required ); |
|
758 | + $required = self::prep_required($required); |
|
759 | 759 | // set disabled tag |
760 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
760 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
761 | 761 | // ya gots ta have style man!!! |
762 | 762 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
763 | - $class = empty( $class ) ? $txt_class : $class; |
|
764 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
765 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
763 | + $class = empty($class) ? $txt_class : $class; |
|
764 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
765 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
766 | 766 | |
767 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
767 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
768 | 768 | // filter label but ensure required text comes before it |
769 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
769 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
770 | 770 | |
771 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
771 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
772 | 772 | // recursively count array elements, to determine total number of options |
773 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
774 | - if ( ! $only_option ) { |
|
773 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
774 | + if ( ! $only_option) { |
|
775 | 775 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
776 | 776 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
777 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
777 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
778 | 778 | } |
779 | - foreach ( $options as $key => $value ) { |
|
779 | + foreach ($options as $key => $value) { |
|
780 | 780 | // if value is an array, then create option groups, else create regular ol' options |
781 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
781 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
782 | 782 | } |
783 | 783 | |
784 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
784 | + $input_html .= "\n\t\t\t".'</select>'; |
|
785 | 785 | |
786 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
786 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
787 | 787 | |
788 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
789 | - return $label_html . $input_html; |
|
788 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
789 | + return $label_html.$input_html; |
|
790 | 790 | |
791 | 791 | } |
792 | 792 | |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | * @param boolean $use_html_entities |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
808 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
809 | - foreach ( $QSOs as $QSO ) { |
|
810 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
807 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
808 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
809 | + foreach ($QSOs as $QSO) { |
|
810 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
811 | 811 | } |
812 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
812 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
813 | 813 | return $html; |
814 | 814 | } |
815 | 815 | |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | * @param boolean $use_html_entities |
825 | 825 | * @return string |
826 | 826 | */ |
827 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
828 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
829 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
830 | - $value = ! empty( $value ) ? $value : $key; |
|
831 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
832 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
827 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
828 | + $key = self::prep_answer($key, $use_html_entities); |
|
829 | + $value = self::prep_answer($value, $use_html_entities); |
|
830 | + $value = ! empty($value) ? $value : $key; |
|
831 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
832 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -853,56 +853,56 @@ discard block |
||
853 | 853 | * @param bool $use_desc_4_label |
854 | 854 | * @return string HTML |
855 | 855 | */ |
856 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
856 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
857 | 857 | // need these |
858 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
858 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
859 | 859 | return NULL; |
860 | 860 | } |
861 | 861 | // prep the answer |
862 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
862 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
863 | 863 | // prep the required array |
864 | - $required = self::prep_required( $required ); |
|
864 | + $required = self::prep_required($required); |
|
865 | 865 | // set disabled tag |
866 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
866 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
867 | 867 | // ya gots ta have style man!!! |
868 | 868 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
869 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
870 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
869 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
870 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
871 | 871 | |
872 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
872 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
873 | 873 | // filter label but ensure required text comes before it |
874 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
874 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
875 | 875 | |
876 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
876 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
877 | 877 | |
878 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
879 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
878 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
879 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
880 | 880 | |
881 | - foreach ( $options as $OPT ) { |
|
882 | - if ( $OPT instanceof EE_Question_Option ) { |
|
883 | - $value = self::prep_option_value( $OPT->value() ); |
|
881 | + foreach ($options as $OPT) { |
|
882 | + if ($OPT instanceof EE_Question_Option) { |
|
883 | + $value = self::prep_option_value($OPT->value()); |
|
884 | 884 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
885 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
886 | - $desc = $OPT->desc();//no self::prep_answer |
|
887 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
888 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
889 | - $opt = '-' . sanitize_key( $value ); |
|
890 | - |
|
891 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
892 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
893 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
894 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
895 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
896 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
897 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
898 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
885 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
886 | + $desc = $OPT->desc(); //no self::prep_answer |
|
887 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
888 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
889 | + $opt = '-'.sanitize_key($value); |
|
890 | + |
|
891 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
892 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
893 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
894 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
895 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
896 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
897 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
898 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
902 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
903 | 903 | |
904 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
905 | - return $label_html . $input_html; |
|
904 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
905 | + return $label_html.$input_html; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -925,65 +925,65 @@ discard block |
||
925 | 925 | * @param string $disabled disabled="disabled" or null |
926 | 926 | * @return string HTML |
927 | 927 | */ |
928 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
928 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
929 | 929 | // need these |
930 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
930 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
931 | 931 | return NULL; |
932 | 932 | } |
933 | - $answer = maybe_unserialize( $answer ); |
|
933 | + $answer = maybe_unserialize($answer); |
|
934 | 934 | |
935 | 935 | // prep the answer(s) |
936 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
936 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
937 | 937 | |
938 | - foreach ( $answer as $key => $value ) { |
|
939 | - $key = self::prep_option_value( $key ); |
|
940 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
938 | + foreach ($answer as $key => $value) { |
|
939 | + $key = self::prep_option_value($key); |
|
940 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | // prep the required array |
944 | - $required = self::prep_required( $required ); |
|
944 | + $required = self::prep_required($required); |
|
945 | 945 | // set disabled tag |
946 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
946 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
947 | 947 | // ya gots ta have style man!!! |
948 | 948 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
949 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
950 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
949 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
950 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
951 | 951 | |
952 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
952 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
953 | 953 | // filter label but ensure required text comes before it |
954 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
955 | - |
|
956 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
957 | - |
|
958 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
959 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
960 | - |
|
961 | - foreach ( $options as $OPT ) { |
|
962 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
963 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
964 | - $text = self::prep_answer( $OPT->value() ); |
|
965 | - $desc = $OPT->desc() ; |
|
966 | - $opt = '-' . sanitize_key( $value ); |
|
967 | - |
|
968 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
969 | - |
|
970 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
971 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
972 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
973 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
974 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
975 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
976 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
977 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
954 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
955 | + |
|
956 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
957 | + |
|
958 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
959 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
960 | + |
|
961 | + foreach ($options as $OPT) { |
|
962 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
963 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
964 | + $text = self::prep_answer($OPT->value()); |
|
965 | + $desc = $OPT->desc(); |
|
966 | + $opt = '-'.sanitize_key($value); |
|
967 | + |
|
968 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
969 | + |
|
970 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
971 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
972 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
973 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
974 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
975 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
976 | + if ( ! empty($desc) && $desc != $text) { |
|
977 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
978 | 978 | } |
979 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
979 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
980 | 980 | |
981 | 981 | } |
982 | 982 | |
983 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
983 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
984 | 984 | |
985 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
986 | - return $label_html . $input_html; |
|
985 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
986 | + return $label_html.$input_html; |
|
987 | 987 | |
988 | 988 | } |
989 | 989 | |
@@ -1005,36 +1005,36 @@ discard block |
||
1005 | 1005 | * @param string $disabled disabled="disabled" or null |
1006 | 1006 | * @return string HTML |
1007 | 1007 | */ |
1008 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1008 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1009 | 1009 | // need these |
1010 | - if ( ! $question || ! $name ) { |
|
1010 | + if ( ! $question || ! $name) { |
|
1011 | 1011 | return NULL; |
1012 | 1012 | } |
1013 | 1013 | // prep the answer |
1014 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1014 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1015 | 1015 | // prep the required array |
1016 | - $required = self::prep_required( $required ); |
|
1016 | + $required = self::prep_required($required); |
|
1017 | 1017 | // set disabled tag |
1018 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1018 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1019 | 1019 | // ya gots ta have style man!!! |
1020 | 1020 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1021 | - $class = empty( $class ) ? $txt_class : $class; |
|
1022 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1023 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1021 | + $class = empty($class) ? $txt_class : $class; |
|
1022 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1023 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1024 | 1024 | |
1025 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1025 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1026 | 1026 | // filter label but ensure required text comes before it |
1027 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1027 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1028 | 1028 | |
1029 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1029 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1030 | 1030 | |
1031 | 1031 | // enqueue scripts |
1032 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1033 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1034 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1032 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1033 | + wp_enqueue_style('espresso-ui-theme'); |
|
1034 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1035 | 1035 | |
1036 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1037 | - return $label_html . $input_html; |
|
1036 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1037 | + return $label_html.$input_html; |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @access public |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1049 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1050 | 1050 | return $required_text; |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param string $value |
1061 | 1061 | * @return string HTML |
1062 | 1062 | */ |
1063 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1064 | - $id = ! empty( $id ) ? $id : $name; |
|
1065 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1063 | + static function hidden_input($name, $value, $id = '') { |
|
1064 | + $id = ! empty($id) ? $id : $name; |
|
1065 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @param string $question |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | - static function prep_question( $question ){ |
|
1077 | + static function prep_question($question) { |
|
1078 | 1078 | return $question; |
1079 | 1079 | // $link = ''; |
1080 | 1080 | // // does this label have a help link attached ? |
@@ -1097,13 +1097,13 @@ discard block |
||
1097 | 1097 | * @param mixed $answer |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1100 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1101 | 1101 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1102 | - if ( is_bool( $answer ) ) { |
|
1102 | + if (is_bool($answer)) { |
|
1103 | 1103 | $answer = $answer ? 1 : 0; |
1104 | 1104 | } |
1105 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1106 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1105 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1106 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
@@ -1113,18 +1113,18 @@ discard block |
||
1113 | 1113 | * @param array $QSOs array of EE_Question_Option objects |
1114 | 1114 | * @return array |
1115 | 1115 | */ |
1116 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1116 | + public static function prep_answer_options($QSOs = array()) { |
|
1117 | 1117 | $prepped_answer_options = array(); |
1118 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1119 | - foreach( $QSOs as $key => $QSO ) { |
|
1120 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1121 | - $QSO = EE_Question_Option::new_instance( array( |
|
1122 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1123 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1118 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1119 | + foreach ($QSOs as $key => $QSO) { |
|
1120 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1121 | + $QSO = EE_Question_Option::new_instance(array( |
|
1122 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1123 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1124 | 1124 | )); |
1125 | 1125 | } |
1126 | - if ( $QSO->opt_group() ) { |
|
1127 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1126 | + if ($QSO->opt_group()) { |
|
1127 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1128 | 1128 | } else { |
1129 | 1129 | $prepped_answer_options[] = $QSO; |
1130 | 1130 | } |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | * @param string $option_value |
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | - static function prep_option_value( $option_value ){ |
|
1144 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1143 | + static function prep_option_value($option_value) { |
|
1144 | + return esc_attr(trim(stripslashes($option_value))); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | * @param string|array $required |
1153 | 1153 | * @return array |
1154 | 1154 | */ |
1155 | - static function prep_required( $required = array() ){ |
|
1155 | + static function prep_required($required = array()) { |
|
1156 | 1156 | // make sure required is an array |
1157 | - $required = is_array( $required ) ? $required : array(); |
|
1157 | + $required = is_array($required) ? $required : array(); |
|
1158 | 1158 | // and set some defaults |
1159 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1159 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1160 | 1160 | return $required; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1167,30 +1167,30 @@ discard block |
||
1167 | 1167 | * @param string $value |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - static function get_label_size_class( $value = FALSE ){ |
|
1171 | - if ( $value === FALSE || $value == '' ) { |
|
1170 | + static function get_label_size_class($value = FALSE) { |
|
1171 | + if ($value === FALSE || $value == '') { |
|
1172 | 1172 | return ' class="medium-lbl"'; |
1173 | 1173 | } |
1174 | 1174 | // determine length of option value |
1175 | - $val_size = strlen( $value ); |
|
1176 | - switch( $val_size ){ |
|
1175 | + $val_size = strlen($value); |
|
1176 | + switch ($val_size) { |
|
1177 | 1177 | case $val_size < 3 : |
1178 | - $size = ' class="nano-lbl"'; |
|
1178 | + $size = ' class="nano-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 6 : |
1181 | - $size = ' class="micro-lbl"'; |
|
1181 | + $size = ' class="micro-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 12 : |
1184 | - $size = ' class="tiny-lbl"'; |
|
1184 | + $size = ' class="tiny-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size < 25 : |
1187 | - $size = ' class="small-lbl"'; |
|
1187 | + $size = ' class="small-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | case $val_size > 100 : |
1190 | - $size = ' class="big-lbl"'; |
|
1190 | + $size = ' class="big-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | default: |
1193 | - $size = ' class="medium-lbl"'; |
|
1193 | + $size = ' class="medium-lbl"'; |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | return $size; |
@@ -1204,20 +1204,20 @@ discard block |
||
1204 | 1204 | * @param array $QFI |
1205 | 1205 | * @return array |
1206 | 1206 | */ |
1207 | - private static function _load_system_dropdowns( $QFI ){ |
|
1207 | + private static function _load_system_dropdowns($QFI) { |
|
1208 | 1208 | $QST_system = $QFI->get('QST_system'); |
1209 | - switch ( $QST_system ) { |
|
1209 | + switch ($QST_system) { |
|
1210 | 1210 | case 'state' : |
1211 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_state_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'country' : |
1214 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1214 | + $QFI = self::generate_country_dropdown($QFI); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-state' : |
1217 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | case 'admin-country' : |
1220 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1220 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1221 | 1221 | break; |
1222 | 1222 | } |
1223 | 1223 | return $QFI; |
@@ -1234,13 +1234,13 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @return EE_Question_Form_Input |
1236 | 1236 | */ |
1237 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1238 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1237 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1238 | + switch ($QFI->get('QST_type')) { |
|
1239 | 1239 | case 'STATE' : |
1240 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_state_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | case 'COUNTRY' : |
1243 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1243 | + $QFI = self::generate_country_dropdown($QFI); |
|
1244 | 1244 | break; |
1245 | 1245 | } |
1246 | 1246 | return $QFI; |
@@ -1254,23 +1254,23 @@ discard block |
||
1254 | 1254 | * @param bool $get_all |
1255 | 1255 | * @return array |
1256 | 1256 | */ |
1257 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1257 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1258 | 1258 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1259 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1260 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1259 | + if ($states && count($states) != count($QST->options())) { |
|
1260 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1261 | 1261 | // if multiple countries, we'll create option groups within the dropdown |
1262 | - foreach ( $states as $state ) { |
|
1263 | - if ( $state instanceof EE_State ) { |
|
1264 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1262 | + foreach ($states as $state) { |
|
1263 | + if ($state instanceof EE_State) { |
|
1264 | + $QSO = EE_Question_Option::new_instance(array( |
|
1265 | 1265 | 'QSO_value' => $state->ID(), |
1266 | 1266 | 'QSO_desc' => $state->name(), |
1267 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1267 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1268 | 1268 | 'QSO_deleted' => FALSE |
1269 | 1269 | )); |
1270 | 1270 | // set option group |
1271 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1271 | + $QSO->set_opt_group($state->country()->name()); |
|
1272 | 1272 | // add option to question |
1273 | - $QST->add_temp_option( $QSO ); |
|
1273 | + $QST->add_temp_option($QSO); |
|
1274 | 1274 | } |
1275 | 1275 | } |
1276 | 1276 | } |
@@ -1286,20 +1286,20 @@ discard block |
||
1286 | 1286 | * @internal param array $question |
1287 | 1287 | * @return array |
1288 | 1288 | */ |
1289 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1289 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1290 | 1290 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1291 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1292 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1291 | + if ($countries && count($countries) != count($QST->options())) { |
|
1292 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1293 | 1293 | // now add countries |
1294 | - foreach ( $countries as $country ) { |
|
1295 | - if ( $country instanceof EE_Country ) { |
|
1296 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1294 | + foreach ($countries as $country) { |
|
1295 | + if ($country instanceof EE_Country) { |
|
1296 | + $QSO = EE_Question_Option::new_instance(array( |
|
1297 | 1297 | 'QSO_value' => $country->ID(), |
1298 | 1298 | 'QSO_desc' => $country->name(), |
1299 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1299 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1300 | 1300 | 'QSO_deleted' => FALSE |
1301 | 1301 | )); |
1302 | - $QST->add_temp_option( $QSO ); |
|
1302 | + $QST->add_temp_option($QSO); |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1316,11 +1316,11 @@ discard block |
||
1316 | 1316 | */ |
1317 | 1317 | public static function two_digit_months_dropdown_options() { |
1318 | 1318 | $options = array(); |
1319 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1320 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1321 | - $options[ (string)$mm ] = (string)$mm; |
|
1319 | + for ($x = 1; $x <= 12; $x++) { |
|
1320 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1321 | + $options[(string) $mm] = (string) $mm; |
|
1322 | 1322 | } |
1323 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1323 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | $options = array(); |
1336 | 1336 | $current_year = date('y'); |
1337 | 1337 | $next_decade = $current_year + 10; |
1338 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1339 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1340 | - $options[ (string)$yy ] = (string)$yy; |
|
1338 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1339 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1340 | + $options[(string) $yy] = (string) $yy; |
|
1341 | 1341 | } |
1342 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1342 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | |
@@ -1353,17 +1353,17 @@ discard block |
||
1353 | 1353 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1354 | 1354 | * @return string html |
1355 | 1355 | */ |
1356 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1356 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1357 | 1357 | $_where = array(); |
1358 | - if ( !empty( $status ) ) { |
|
1358 | + if ( ! empty($status)) { |
|
1359 | 1359 | $_where['STS_ID'] = $status; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( $evt_category > 0 ) { |
|
1362 | + if ($evt_category > 0) { |
|
1363 | 1363 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1366 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1367 | 1367 | |
1368 | 1368 | //setup vals for select input helper |
1369 | 1369 | $options = array( |
@@ -1373,15 +1373,15 @@ discard block |
||
1373 | 1373 | ) |
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - foreach ( $regdtts as $regdtt ) { |
|
1377 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1376 | + foreach ($regdtts as $regdtt) { |
|
1377 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1378 | 1378 | $options[] = array( |
1379 | 1379 | 'text' => $date, |
1380 | 1380 | 'id' => $date |
1381 | 1381 | ); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1384 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | |
@@ -1395,18 +1395,18 @@ discard block |
||
1395 | 1395 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1396 | 1396 | * @return string html |
1397 | 1397 | */ |
1398 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1398 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1399 | 1399 | //determine what post_status our condition will have for the query. |
1400 | - switch ( $status ) { |
|
1400 | + switch ($status) { |
|
1401 | 1401 | case 'month' : |
1402 | 1402 | case 'today' : |
1403 | 1403 | case NULL : |
1404 | 1404 | case 'all' : |
1405 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1405 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1406 | 1406 | break; |
1407 | 1407 | |
1408 | 1408 | case 'draft' : |
1409 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1409 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1410 | 1410 | |
1411 | 1411 | default : |
1412 | 1412 | $where['Event.status'] = $status; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | //categories? |
1416 | 1416 | |
1417 | 1417 | |
1418 | - if ( !empty ( $evt_category ) ) { |
|
1418 | + if ( ! empty ($evt_category)) { |
|
1419 | 1419 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1420 | 1420 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1421 | 1421 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | |
1424 | 1424 | // $where['DTT_is_primary'] = 1; |
1425 | 1425 | |
1426 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1426 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1427 | 1427 | |
1428 | 1428 | //let's setup vals for select input helper |
1429 | 1429 | $options = array( |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | //translate month and date |
1439 | 1439 | global $wp_locale; |
1440 | 1440 | |
1441 | - foreach ( $DTTS as $DTT ) { |
|
1442 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1443 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1441 | + foreach ($DTTS as $DTT) { |
|
1442 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1443 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1444 | 1444 | $options[] = array( |
1445 | 1445 | 'text' => $localized_date, |
1446 | 1446 | 'id' => $id |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | |
1451 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1451 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | * @param integer $current_cat currently selected category |
1460 | 1460 | * @return string html for dropdown |
1461 | 1461 | */ |
1462 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1462 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1463 | 1463 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1464 | 1464 | $options = array( |
1465 | 1465 | '0' => array( |
@@ -1469,14 +1469,14 @@ discard block |
||
1469 | 1469 | ); |
1470 | 1470 | |
1471 | 1471 | //setup categories for dropdown |
1472 | - foreach ( $categories as $category ) { |
|
1472 | + foreach ($categories as $category) { |
|
1473 | 1473 | $options[] = array( |
1474 | 1474 | 'text' => $category->get('name'), |
1475 | 1475 | 'id' => $category->ID() |
1476 | 1476 | ); |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1479 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | |
@@ -1495,20 +1495,20 @@ discard block |
||
1495 | 1495 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1496 | 1496 | * @return void |
1497 | 1497 | */ |
1498 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1498 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1499 | 1499 | $btn = ''; |
1500 | - if ( empty( $url ) || empty( $ID )) { |
|
1500 | + if (empty($url) || empty($ID)) { |
|
1501 | 1501 | return $btn; |
1502 | 1502 | } |
1503 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1504 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1505 | - if ( ! $input_only ) { |
|
1506 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1507 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1503 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1504 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1505 | + if ( ! $input_only) { |
|
1506 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1507 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1508 | 1508 | $btn_frm .= $btn; |
1509 | 1509 | $btn_frm .= '</form>'; |
1510 | 1510 | $btn = $btn_frm; |
1511 | - unset ( $btn_frm ); |
|
1511 | + unset ($btn_frm); |
|
1512 | 1512 | } |
1513 | 1513 | return $btn; |
1514 | 1514 | } |
@@ -31,7 +31,6 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * google_map - creates a Google Map Link |
34 | - * @param array $atts aray of attributes required for the map link generation |
|
35 | 34 | * @return string (link to map!) |
36 | 35 | */ |
37 | 36 | public static function google_map( $ee_gmaps_opts ){ |
@@ -116,7 +115,6 @@ discard block |
||
116 | 115 | |
117 | 116 | /** |
118 | 117 | * creates a Google Map Link |
119 | - * @param array $atts aray of attributes required for the map link generation |
|
120 | 118 | * @return string (link to map!) |
121 | 119 | */ |
122 | 120 | public static function espresso_google_map_js() { |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @param array $atts aray of attributes required for the map link generation |
35 | 35 | * @return string (link to map!) |
36 | 36 | */ |
37 | - public static function google_map( $ee_gmaps_opts ){ |
|
37 | + public static function google_map($ee_gmaps_opts) { |
|
38 | 38 | |
39 | 39 | //d( $ee_gmaps_opts ); |
40 | 40 | |
41 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
45 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
41 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
45 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
48 | 48 | |
49 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
50 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
49 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
50 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
51 | 51 | case "left": |
52 | 52 | $map_align = 'ee-gmap-align-left left'; |
53 | 53 | break; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | // Determine whether user has set a hardoded url to use and |
70 | 70 | // if so display a Google static iframe map else run V3 api |
71 | - if( $static_url ) { |
|
71 | + if ($static_url) { |
|
72 | 72 | |
73 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
74 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
73 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
74 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
75 | 75 | $html .= '</iframe>'; |
76 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
76 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
77 | 77 | $html .= '</div>'; |
78 | 78 | return $html; |
79 | 79 | |
80 | 80 | } else { |
81 | 81 | |
82 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
82 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
83 | 83 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
84 | 84 | 'ee_map_zoom' => $ee_map_zoom, |
85 | 85 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
92 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
92 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
93 | 93 | $html .= '</div>'; |
94 | 94 | |
95 | - wp_enqueue_script( 'gmap_api' ); |
|
96 | - wp_enqueue_script( 'ee_gmap' ); |
|
97 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
95 | + wp_enqueue_script('gmap_api'); |
|
96 | + wp_enqueue_script('ee_gmap'); |
|
97 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
98 | 98 | |
99 | 99 | return $html; |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return void |
110 | 110 | */ |
111 | 111 | public static function footer_enqueue_script() { |
112 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
112 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function espresso_google_map_js() { |
123 | 123 | $scheme = is_ssl() ? 'https://' : 'http://'; |
124 | - wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE ); |
|
125 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
124 | + wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE); |
|
125 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string (link to map!) |
132 | 132 | */ |
133 | 133 | public static function google_map_link($atts) { |
134 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | 135 | extract($atts); |
136 | 136 | |
137 | 137 | $address = "{$address}"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | $id = isset($id) ? $id : 'not_set'; |
147 | 147 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
148 | 148 | |
149 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
149 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
150 | 150 | |
151 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
151 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
152 | 152 | |
153 | 153 | switch ($type) { |
154 | 154 | case 'text': |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | case 'map': |
164 | 164 | $scheme = is_ssl() ? 'https://' : 'http://'; |
165 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false' ) . '" /></a>'; |
|
165 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false').'" /></a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
168 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 |
@@ -1,28 +1,28 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for Wordpress |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @author Seth Shoultes |
|
9 | - * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
10 | - * @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
|
11 | - * @link http://www.eventespresso.com |
|
12 | - * @version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EEH_Maps |
|
17 | - * |
|
18 | - * This is a helper utility class that provides different helpers related to mapping and displaying location related data. |
|
19 | - * |
|
20 | - * @package Event Espresso |
|
21 | - * @subpackage /helpers/EEH_Maps.helper.php |
|
22 | - * @author Hugo Ashmore, Brent Christensen, Darren Ethier |
|
23 | - * |
|
24 | - * ------------------------------------------------------------------------ |
|
25 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for Wordpress |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @author Seth Shoultes |
|
9 | + * @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
|
10 | + * @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
|
11 | + * @link http://www.eventespresso.com |
|
12 | + * @version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EEH_Maps |
|
17 | + * |
|
18 | + * This is a helper utility class that provides different helpers related to mapping and displaying location related data. |
|
19 | + * |
|
20 | + * @package Event Espresso |
|
21 | + * @subpackage /helpers/EEH_Maps.helper.php |
|
22 | + * @author Hugo Ashmore, Brent Christensen, Darren Ethier |
|
23 | + * |
|
24 | + * ------------------------------------------------------------------------ |
|
25 | + */ |
|
26 | 26 | class EEH_Maps { |
27 | 27 | |
28 | 28 | // array of map settings |
@@ -109,7 +109,7 @@ |
||
109 | 109 | * - registers and enqueues the qtip scripts and styles. |
110 | 110 | * |
111 | 111 | * @access public |
112 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
112 | + * @param string[] $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function instance() { |
34 | 34 | // check if class object is instantiated |
35 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
35 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
36 | 36 | self::$_instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$_instance; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function __construct() { |
50 | 50 | //let's just make sure this is instantiated in the right place. |
51 | - if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) { |
|
52 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' ); |
|
51 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
52 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,27 +61,27 @@ discard block |
||
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function register_and_enqueue() { |
64 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
65 | - $qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js'; |
|
66 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
67 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
64 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
65 | + $qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js'; |
|
66 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
67 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
68 | 68 | |
69 | - wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE ); |
|
70 | - wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE ); |
|
71 | - wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE ); |
|
72 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
69 | + wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE); |
|
70 | + wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE); |
|
71 | + wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE); |
|
72 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE); |
|
73 | 73 | |
74 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2' ); |
|
74 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
75 | 75 | |
76 | 76 | //k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
77 | - if ( !empty( $this->_qtips ) ) { |
|
77 | + if ( ! empty($this->_qtips)) { |
|
78 | 78 | wp_enqueue_script('ee-qtip-helper'); |
79 | 79 | wp_enqueue_style('qtip-css'); |
80 | 80 | $qtips = array(); |
81 | - foreach ( $this->_qtips as $qtip ) { |
|
81 | + foreach ($this->_qtips as $qtip) { |
|
82 | 82 | $qts = $qtip->get_tips(); |
83 | - foreach ( $qts as $qt ) { |
|
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
83 | + foreach ($qts as $qt) { |
|
84 | + if ( ! $qt instanceof EE_Qtip) |
|
85 | 85 | continue; |
86 | 86 | $qtips[] = array( |
87 | 87 | 'content_id' => $qt->content_id, |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
93 | + if ( ! empty($qtips)) |
|
94 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
95 | 95 | |
96 | 96 | } else { |
97 | 97 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function register( $configname, $paths = array() ) { |
|
116 | + public function register($configname, $paths = array()) { |
|
117 | 117 | |
118 | 118 | //let's just make sure this is instantiated in the right place. |
119 | - if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) { |
|
120 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' ); |
|
119 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
120 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $configname = (array) $configname; //typecast to array |
124 | - foreach ( $configname as $config ) { |
|
125 | - $this->_register( $config, $paths ); |
|
124 | + foreach ($configname as $config) { |
|
125 | + $this->_register($config, $paths); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | //hook into appropriate footer |
129 | 129 | $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
130 | - add_action($footer_action, array($this, 'setup_qtip'), 10 ); |
|
130 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
131 | 131 | |
132 | 132 | //make sure we "turn on" qtip js. |
133 | - add_filter('FHEE_load_qtip', '__return_true' ); |
|
133 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | * @throws EE_Error |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - private function _register( $config, $paths ) { |
|
147 | + private function _register($config, $paths) { |
|
148 | 148 | //before doing anything we have to make sure that EE_Qtip_Config parent is required. |
149 | - EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE ); |
|
149 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE); |
|
150 | 150 | |
151 | - if ( !empty( $paths ) ) { |
|
151 | + if ( ! empty($paths)) { |
|
152 | 152 | $paths = (array) $paths; |
153 | - foreach ( $paths as $path ) { |
|
154 | - $path = $path . $config . '.lib.php'; |
|
155 | - if ( !is_readable($path ) ) { |
|
153 | + foreach ($paths as $path) { |
|
154 | + $path = $path.$config.'.lib.php'; |
|
155 | + if ( ! is_readable($path)) { |
|
156 | 156 | continue; |
157 | 157 | } else { |
158 | 158 | require_once $path; |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | //does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
164 | - if ( !class_exists($config) ) { |
|
165 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
166 | - if ( !is_readable($path ) ) { |
|
167 | - throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) ); |
|
164 | + if ( ! class_exists($config)) { |
|
165 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
166 | + if ( ! is_readable($path)) { |
|
167 | + throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
168 | 168 | } else { |
169 | 169 | require_once $path; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
174 | + if ( ! class_exists($config)) |
|
175 | + throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
176 | 176 | |
177 | 177 | //made it HERE? FINALLY, let's get things setup. |
178 | 178 | $a = new ReflectionClass($config); |
179 | 179 | $qtip = $a->newInstance(); |
180 | 180 | |
181 | 181 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
182 | + if ( ! $qtip instanceof EE_Qtip_Config) |
|
183 | + throw new EE_Error(sprintf(__('The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config)); |
|
184 | 184 | |
185 | 185 | $this->_qtips[] = $a->newInstance(); |
186 | 186 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @return void |
197 | 197 | */ |
198 | 198 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
199 | + if (empty($this->_qtips)) |
|
200 | 200 | return; //no qtips! |
201 | 201 | |
202 | 202 | $content = array(); |
203 | 203 | |
204 | - foreach ( $this->_qtips as $qtip ) { |
|
204 | + foreach ($this->_qtips as $qtip) { |
|
205 | 205 | $content[] = $this->_generate_content_container($qtip); |
206 | 206 | } |
207 | 207 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | private function _generate_content_container($qtip) { |
219 | 219 | $qts = $qtip->get_tips(); |
220 | 220 | $content = array(); |
221 | - foreach ( $qts as $qt ) { |
|
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
221 | + foreach ($qts as $qt) { |
|
222 | + if ( ! $qt instanceof EE_Qtip) |
|
223 | 223 | continue; |
224 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
|
224 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return implode('<br />', $content); |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | foreach ( $this->_qtips as $qtip ) { |
82 | 82 | $qts = $qtip->get_tips(); |
83 | 83 | foreach ( $qts as $qt ) { |
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
85 | - continue; |
|
84 | + if ( ! $qt instanceof EE_Qtip ) { |
|
85 | + continue; |
|
86 | + } |
|
86 | 87 | $qtips[] = array( |
87 | 88 | 'content_id' => $qt->content_id, |
88 | 89 | 'options' => $qt->options, |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | ); |
91 | 92 | } |
92 | 93 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
94 | + if ( !empty($qtips) ) { |
|
95 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | } else { |
97 | 99 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -171,16 +173,18 @@ discard block |
||
171 | 173 | } |
172 | 174 | |
173 | 175 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
176 | + if ( !class_exists( $config ) ) { |
|
177 | + throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
178 | + } |
|
176 | 179 | |
177 | 180 | //made it HERE? FINALLY, let's get things setup. |
178 | 181 | $a = new ReflectionClass($config); |
179 | 182 | $qtip = $a->newInstance(); |
180 | 183 | |
181 | 184 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
185 | + if ( ! $qtip instanceof EE_Qtip_Config ) { |
|
186 | + throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
187 | + } |
|
184 | 188 | |
185 | 189 | $this->_qtips[] = $a->newInstance(); |
186 | 190 | |
@@ -196,8 +200,10 @@ discard block |
||
196 | 200 | * @return void |
197 | 201 | */ |
198 | 202 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
200 | - return; //no qtips! |
|
203 | + if ( empty( $this->_qtips ) ) { |
|
204 | + return; |
|
205 | + } |
|
206 | + //no qtips! |
|
201 | 207 | |
202 | 208 | $content = array(); |
203 | 209 | |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | $qts = $qtip->get_tips(); |
220 | 226 | $content = array(); |
221 | 227 | foreach ( $qts as $qt ) { |
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
223 | - continue; |
|
228 | + if ( ! $qt instanceof EE_Qtip ) { |
|
229 | + continue; |
|
230 | + } |
|
224 | 231 | $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
225 | 232 | } |
226 | 233 |