@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | // 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); |
191 | 191 | foreach ($autosave_relations as $a_r) { |
192 | 192 | $pid = $a_r->parent(); |
193 | - if (! empty($pid)) { |
|
193 | + if ( ! empty($pid)) { |
|
194 | 194 | $parent_ids[] = $pid; |
195 | 195 | } else { |
196 | 196 | $return_objs[] = $a_r; |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | // now we setup the query to get all the parents |
209 | - if (! empty($parent_ids)) { |
|
210 | - $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() . "." . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
211 | - $query_param[0][ $query_param_where_this_model_pk ] = array('IN', $parent_ids); |
|
209 | + if ( ! empty($parent_ids)) { |
|
210 | + $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name(); |
|
211 | + $query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids); |
|
212 | 212 | $parents = $this->get_other_model()->get_all($query_params); |
213 | 213 | } |
214 | 214 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | var_dump($this_obj); |
244 | 244 | var_dump($other_obj);/**/ |
245 | 245 | |
246 | - if (! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
246 | + if ( ! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
247 | 247 | // 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. |
248 | 248 | $has_parent_obj = $this->get_other_model()->get_one(array( |
249 | 249 | array( |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $other_obj->set($pk_on_related_model, $has_parent_obj->ID()); |
260 | 260 | $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
261 | 261 | |
262 | - if (! $remove_relation) { |
|
262 | + if ( ! $remove_relation) { |
|
263 | 263 | $other_obj->save(); |
264 | 264 | return array($other_obj); |
265 | 265 | } elseif ($remove_relation && ! $this->_blocking_delete) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | // the last possible condition on a revision is that the incoming other_model object has a fk that == $this_obj pk which means we just return the $other obj and let it save as normal so we see the return at the bottom of this method. |
288 | 288 | } else { |
289 | 289 | // we only need to do the below IF this is not a remove relation |
290 | - if (! $remove_relation) { |
|
290 | + if ( ! $remove_relation) { |
|
291 | 291 | // 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. |
292 | 292 | // 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. |
293 | 293 | $existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID()); |
@@ -10,303 +10,303 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation |
12 | 12 | { |
13 | - /** |
|
14 | - * The Foreign key on the model that acts as the PRIMARY KEY used in special autosave handling where we query for |
|
15 | - * autosaves (or the Foreign key on other models in relations pointing to this models primary key which is this |
|
16 | - * value). The _primary_cpt_field is what is equivalent to the post_id field on a cpt join. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private $_primary_cpt_field; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * This is what field serves as the "parent" column that is linked with whatever the main model's calling this |
|
25 | - * relation has as a primary key. In other words EEM_Event has 'Datetime' => new |
|
26 | - * EE_Has_Many_Revision_Relation('EVT_ID', 'DTT_parent'). That means that in the EEM_Datetime model the |
|
27 | - * 'DTT_Parent' field is related to the 'DTT_ID' primary key field (in the same model) because 'DTT_ID' is the |
|
28 | - * primary key in the other model (EEM_Datetime). |
|
29 | - * |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - private $_parent_pk_relation_field; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
37 | - * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
38 | - * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
39 | - * related models across the relation, and add-and-remove the relationships. |
|
40 | - * |
|
41 | - * @param string $primary_cpt_field See property description for details |
|
42 | - * @param string $parent_pk_relation_field This is the field that is "connected" to the $primary_cpt_field. |
|
43 | - * See property desc for details. |
|
44 | - * @param boolean $block_deletes For this type of relation, we block by default. If there are |
|
45 | - * related models across this relation, block (prevent and add an |
|
46 | - * error) the deletion of this model |
|
47 | - * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
48 | - * default |
|
49 | - */ |
|
50 | - public function __construct( |
|
51 | - $primary_cpt_field, |
|
52 | - $parent_pk_relation_field, |
|
53 | - $block_deletes = true, |
|
54 | - $blocking_delete_error_message = null |
|
55 | - ) { |
|
56 | - $this->_primary_cpt_field = $primary_cpt_field; |
|
57 | - $this->_parent_pk_relation_field = $parent_pk_relation_field; |
|
58 | - parent::__construct($block_deletes, $blocking_delete_error_message); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
64 | - * you like. |
|
65 | - * |
|
66 | - * @param EE_Base_Class|int $this_obj_or_id |
|
67 | - * @param EE_Base_Class|int $other_obj_or_id |
|
68 | - * @param array $extra_join_model_fields_n_values |
|
69 | - * @return \EE_Base_Class |
|
70 | - * @throws \EE_Error |
|
71 | - */ |
|
72 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
73 | - { |
|
74 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
75 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
76 | - |
|
77 | - // handle possible revisions |
|
78 | - $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj); |
|
79 | - |
|
80 | - // if is array, then we've already done the add_relation so let's get out |
|
81 | - if (is_array($other_model_obj)) { |
|
82 | - return $other_model_obj[0]; |
|
83 | - } |
|
84 | - // find the field on the other model which is a foreign key to this model |
|
85 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
86 | - // set that field on the other model to this model's ID |
|
87 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
88 | - $other_model_obj->save(); |
|
89 | - return $other_model_obj; |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object |
|
95 | - * |
|
96 | - * @param EE_Base_Class|int $this_obj_or_id |
|
97 | - * @param EE_Base_Class|int $other_obj_or_id |
|
98 | - * @param array $where_query |
|
99 | - * @return \EE_Base_Class |
|
100 | - * @throws \EE_Error |
|
101 | - */ |
|
102 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
103 | - { |
|
104 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id); |
|
105 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
106 | - // handle possible revisions |
|
107 | - $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, true); |
|
108 | - |
|
109 | - |
|
110 | - // if is array, then we've already done the add_relation so let's get out |
|
111 | - if (is_array($other_model_obj)) { |
|
112 | - return $other_model_obj[0]; |
|
113 | - } |
|
114 | - |
|
115 | - // find the field on the other model which is a foreign key to this model |
|
116 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
117 | - |
|
118 | - |
|
119 | - // set that field on the other model to this model's ID |
|
120 | - if ($this->_blocking_delete) { |
|
121 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
122 | - $other_model_obj->save(); |
|
123 | - } else { |
|
124 | - $other_model_obj->delete(); |
|
125 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
126 | - return $other_model_obj; |
|
127 | - } |
|
128 | - return $other_model_obj; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * This is identical to EE_Model_Relation->get_all_related() except we're going handle special autosave conditions |
|
134 | - * in here. |
|
135 | - * |
|
136 | - * @param EE_Base_Class|int $model_object_or_id |
|
137 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
138 | - * @param boolean $values_already_prepared_by_model_object @deprecated since 4.8.1 |
|
139 | - * @return EE_Base_Class[] |
|
140 | - * @throws \EE_Error |
|
141 | - */ |
|
142 | - public function get_all_related( |
|
143 | - $model_object_or_id, |
|
144 | - $query_params = array(), |
|
145 | - $values_already_prepared_by_model_object = false |
|
146 | - ) { |
|
147 | - if ($values_already_prepared_by_model_object !== false) { |
|
148 | - EE_Error::doing_it_wrong( |
|
149 | - 'EE_Model_Relation_Base::get_all_related', |
|
150 | - esc_html__('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), |
|
151 | - '4.8.1' |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - // if this is an autosave then we're going to get things differently |
|
156 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
157 | - return $this->_do_autosave_get_all($model_object_or_id, $query_params); |
|
158 | - } |
|
159 | - |
|
160 | - return parent::get_all_related($model_object_or_id, $query_params); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * If we're in the midst of an autosave then we're going to do things a bit differently than the usual |
|
166 | - * get_all_related (commenting within). For description of params see the get_all_related() comments |
|
167 | - * |
|
168 | - * @access protected |
|
169 | - * @param $model_object_or_id |
|
170 | - * @param $query_params |
|
171 | - * @param bool $deprecated |
|
172 | - * @return \EE_Base_Class[] |
|
173 | - * @throws \EE_Error |
|
174 | - */ |
|
175 | - protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) |
|
176 | - { |
|
177 | - |
|
178 | - // first we check if the post_id for the incoming query is for an autosave. If it isn't that's what we want! |
|
179 | - $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
180 | - |
|
181 | - $autosave = wp_get_post_autosave($model_object_id); |
|
182 | - $id_to_use = $autosave ? $autosave->ID : $model_object_id; |
|
183 | - |
|
184 | - $autosave_relations = parent::get_all_related($id_to_use, $query_params); |
|
185 | - $parent_ids = $parents = array(); |
|
186 | - $return_objs = array(); |
|
187 | - |
|
188 | - // 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); |
|
189 | - foreach ($autosave_relations as $a_r) { |
|
190 | - $pid = $a_r->parent(); |
|
191 | - if (! empty($pid)) { |
|
192 | - $parent_ids[] = $pid; |
|
193 | - } else { |
|
194 | - $return_objs[] = $a_r; |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - // we have to make sure we also include the ORIGINAL values |
|
199 | - $originals = parent::get_all_related($model_object_or_id, $query_params); |
|
200 | - |
|
201 | - // merge $originals with $return_objs |
|
202 | - if ($originals) { |
|
203 | - $return_objs = array_merge($originals, $return_objs); |
|
204 | - } |
|
205 | - |
|
206 | - // now we setup the query to get all the parents |
|
207 | - if (! empty($parent_ids)) { |
|
208 | - $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() . "." . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
209 | - $query_param[0][ $query_param_where_this_model_pk ] = array('IN', $parent_ids); |
|
210 | - $parents = $this->get_other_model()->get_all($query_params); |
|
211 | - } |
|
212 | - |
|
213 | - // var_dump($parents); |
|
214 | - |
|
215 | - |
|
216 | - // now merge parents with our current $return_objs and send back |
|
217 | - return array_merge($parents, $return_objs); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * Basically this method gets called to verify if the incoming object needs to be manipulated somewhat because it |
|
223 | - * is a revision save. If so, then we change things before sending back. We also do verifications when this IS |
|
224 | - * NOT an revision because we always need to make sure that the autosave/revision has parent recorded (which is |
|
225 | - * sometime delayed if the object is created/saved first by the autosave) |
|
226 | - * |
|
227 | - * @param EE_Base_Class $this_obj |
|
228 | - * @param EE_Base_Class $other_obj |
|
229 | - * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
|
230 | - * @return EE_Base_Class. ($other_obj); |
|
231 | - * @throws \EE_Error |
|
232 | - */ |
|
233 | - protected function _check_for_revision($this_obj, $other_obj, $remove_relation = false) |
|
234 | - { |
|
235 | - $pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name(); |
|
236 | - // now we need to determine if we're in a WP revision save cause if we are we need to do some special handling |
|
237 | - if ($this_obj->post_type() === 'revision') { |
|
238 | - // 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. |
|
239 | - $parent_evt_id = $this_obj->parent(); |
|
240 | - /*var_dump($parent_evt_id); |
|
13 | + /** |
|
14 | + * The Foreign key on the model that acts as the PRIMARY KEY used in special autosave handling where we query for |
|
15 | + * autosaves (or the Foreign key on other models in relations pointing to this models primary key which is this |
|
16 | + * value). The _primary_cpt_field is what is equivalent to the post_id field on a cpt join. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private $_primary_cpt_field; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * This is what field serves as the "parent" column that is linked with whatever the main model's calling this |
|
25 | + * relation has as a primary key. In other words EEM_Event has 'Datetime' => new |
|
26 | + * EE_Has_Many_Revision_Relation('EVT_ID', 'DTT_parent'). That means that in the EEM_Datetime model the |
|
27 | + * 'DTT_Parent' field is related to the 'DTT_ID' primary key field (in the same model) because 'DTT_ID' is the |
|
28 | + * primary key in the other model (EEM_Datetime). |
|
29 | + * |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + private $_parent_pk_relation_field; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
37 | + * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
38 | + * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
39 | + * related models across the relation, and add-and-remove the relationships. |
|
40 | + * |
|
41 | + * @param string $primary_cpt_field See property description for details |
|
42 | + * @param string $parent_pk_relation_field This is the field that is "connected" to the $primary_cpt_field. |
|
43 | + * See property desc for details. |
|
44 | + * @param boolean $block_deletes For this type of relation, we block by default. If there are |
|
45 | + * related models across this relation, block (prevent and add an |
|
46 | + * error) the deletion of this model |
|
47 | + * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
48 | + * default |
|
49 | + */ |
|
50 | + public function __construct( |
|
51 | + $primary_cpt_field, |
|
52 | + $parent_pk_relation_field, |
|
53 | + $block_deletes = true, |
|
54 | + $blocking_delete_error_message = null |
|
55 | + ) { |
|
56 | + $this->_primary_cpt_field = $primary_cpt_field; |
|
57 | + $this->_parent_pk_relation_field = $parent_pk_relation_field; |
|
58 | + parent::__construct($block_deletes, $blocking_delete_error_message); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
64 | + * you like. |
|
65 | + * |
|
66 | + * @param EE_Base_Class|int $this_obj_or_id |
|
67 | + * @param EE_Base_Class|int $other_obj_or_id |
|
68 | + * @param array $extra_join_model_fields_n_values |
|
69 | + * @return \EE_Base_Class |
|
70 | + * @throws \EE_Error |
|
71 | + */ |
|
72 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
73 | + { |
|
74 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
75 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
76 | + |
|
77 | + // handle possible revisions |
|
78 | + $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj); |
|
79 | + |
|
80 | + // if is array, then we've already done the add_relation so let's get out |
|
81 | + if (is_array($other_model_obj)) { |
|
82 | + return $other_model_obj[0]; |
|
83 | + } |
|
84 | + // find the field on the other model which is a foreign key to this model |
|
85 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
86 | + // set that field on the other model to this model's ID |
|
87 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
88 | + $other_model_obj->save(); |
|
89 | + return $other_model_obj; |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object |
|
95 | + * |
|
96 | + * @param EE_Base_Class|int $this_obj_or_id |
|
97 | + * @param EE_Base_Class|int $other_obj_or_id |
|
98 | + * @param array $where_query |
|
99 | + * @return \EE_Base_Class |
|
100 | + * @throws \EE_Error |
|
101 | + */ |
|
102 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
103 | + { |
|
104 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id); |
|
105 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
106 | + // handle possible revisions |
|
107 | + $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, true); |
|
108 | + |
|
109 | + |
|
110 | + // if is array, then we've already done the add_relation so let's get out |
|
111 | + if (is_array($other_model_obj)) { |
|
112 | + return $other_model_obj[0]; |
|
113 | + } |
|
114 | + |
|
115 | + // find the field on the other model which is a foreign key to this model |
|
116 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
117 | + |
|
118 | + |
|
119 | + // set that field on the other model to this model's ID |
|
120 | + if ($this->_blocking_delete) { |
|
121 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
122 | + $other_model_obj->save(); |
|
123 | + } else { |
|
124 | + $other_model_obj->delete(); |
|
125 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
126 | + return $other_model_obj; |
|
127 | + } |
|
128 | + return $other_model_obj; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * This is identical to EE_Model_Relation->get_all_related() except we're going handle special autosave conditions |
|
134 | + * in here. |
|
135 | + * |
|
136 | + * @param EE_Base_Class|int $model_object_or_id |
|
137 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
138 | + * @param boolean $values_already_prepared_by_model_object @deprecated since 4.8.1 |
|
139 | + * @return EE_Base_Class[] |
|
140 | + * @throws \EE_Error |
|
141 | + */ |
|
142 | + public function get_all_related( |
|
143 | + $model_object_or_id, |
|
144 | + $query_params = array(), |
|
145 | + $values_already_prepared_by_model_object = false |
|
146 | + ) { |
|
147 | + if ($values_already_prepared_by_model_object !== false) { |
|
148 | + EE_Error::doing_it_wrong( |
|
149 | + 'EE_Model_Relation_Base::get_all_related', |
|
150 | + esc_html__('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), |
|
151 | + '4.8.1' |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + // if this is an autosave then we're going to get things differently |
|
156 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
157 | + return $this->_do_autosave_get_all($model_object_or_id, $query_params); |
|
158 | + } |
|
159 | + |
|
160 | + return parent::get_all_related($model_object_or_id, $query_params); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * If we're in the midst of an autosave then we're going to do things a bit differently than the usual |
|
166 | + * get_all_related (commenting within). For description of params see the get_all_related() comments |
|
167 | + * |
|
168 | + * @access protected |
|
169 | + * @param $model_object_or_id |
|
170 | + * @param $query_params |
|
171 | + * @param bool $deprecated |
|
172 | + * @return \EE_Base_Class[] |
|
173 | + * @throws \EE_Error |
|
174 | + */ |
|
175 | + protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) |
|
176 | + { |
|
177 | + |
|
178 | + // first we check if the post_id for the incoming query is for an autosave. If it isn't that's what we want! |
|
179 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
180 | + |
|
181 | + $autosave = wp_get_post_autosave($model_object_id); |
|
182 | + $id_to_use = $autosave ? $autosave->ID : $model_object_id; |
|
183 | + |
|
184 | + $autosave_relations = parent::get_all_related($id_to_use, $query_params); |
|
185 | + $parent_ids = $parents = array(); |
|
186 | + $return_objs = array(); |
|
187 | + |
|
188 | + // 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); |
|
189 | + foreach ($autosave_relations as $a_r) { |
|
190 | + $pid = $a_r->parent(); |
|
191 | + if (! empty($pid)) { |
|
192 | + $parent_ids[] = $pid; |
|
193 | + } else { |
|
194 | + $return_objs[] = $a_r; |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + // we have to make sure we also include the ORIGINAL values |
|
199 | + $originals = parent::get_all_related($model_object_or_id, $query_params); |
|
200 | + |
|
201 | + // merge $originals with $return_objs |
|
202 | + if ($originals) { |
|
203 | + $return_objs = array_merge($originals, $return_objs); |
|
204 | + } |
|
205 | + |
|
206 | + // now we setup the query to get all the parents |
|
207 | + if (! empty($parent_ids)) { |
|
208 | + $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() . "." . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
209 | + $query_param[0][ $query_param_where_this_model_pk ] = array('IN', $parent_ids); |
|
210 | + $parents = $this->get_other_model()->get_all($query_params); |
|
211 | + } |
|
212 | + |
|
213 | + // var_dump($parents); |
|
214 | + |
|
215 | + |
|
216 | + // now merge parents with our current $return_objs and send back |
|
217 | + return array_merge($parents, $return_objs); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * Basically this method gets called to verify if the incoming object needs to be manipulated somewhat because it |
|
223 | + * is a revision save. If so, then we change things before sending back. We also do verifications when this IS |
|
224 | + * NOT an revision because we always need to make sure that the autosave/revision has parent recorded (which is |
|
225 | + * sometime delayed if the object is created/saved first by the autosave) |
|
226 | + * |
|
227 | + * @param EE_Base_Class $this_obj |
|
228 | + * @param EE_Base_Class $other_obj |
|
229 | + * @param boolean $remove_relation Indicates whether we're doing a remove_relation or add_relation. |
|
230 | + * @return EE_Base_Class. ($other_obj); |
|
231 | + * @throws \EE_Error |
|
232 | + */ |
|
233 | + protected function _check_for_revision($this_obj, $other_obj, $remove_relation = false) |
|
234 | + { |
|
235 | + $pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name(); |
|
236 | + // now we need to determine if we're in a WP revision save cause if we are we need to do some special handling |
|
237 | + if ($this_obj->post_type() === 'revision') { |
|
238 | + // 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. |
|
239 | + $parent_evt_id = $this_obj->parent(); |
|
240 | + /*var_dump($parent_evt_id); |
|
241 | 241 | var_dump($this_obj); |
242 | 242 | var_dump($other_obj);/**/ |
243 | 243 | |
244 | - if (! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
245 | - // 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. |
|
246 | - $has_parent_obj = $this->get_other_model()->get_one(array( |
|
247 | - array( |
|
248 | - $this->_parent_pk_relation_field => $other_obj->ID(), |
|
249 | - $this->_primary_cpt_field => $this_obj->ID(), |
|
250 | - ), |
|
251 | - )); |
|
252 | - |
|
253 | - if ($has_parent_obj) { |
|
254 | - // this makes sure the update on the current obj happens to the revision's row NOT the parent row. |
|
255 | - |
|
256 | - $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
257 | - $other_obj->set($pk_on_related_model, $has_parent_obj->ID()); |
|
258 | - $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
259 | - |
|
260 | - if (! $remove_relation) { |
|
261 | - $other_obj->save(); |
|
262 | - return array($other_obj); |
|
263 | - } elseif ($remove_relation && ! $this->_blocking_delete) { |
|
264 | - $other_obj->delete(); |
|
265 | - $other_obj->set($this->_parent_pk_relation_field, null, true); |
|
266 | - return array($other_obj); |
|
267 | - } |
|
268 | - } else { |
|
269 | - $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
270 | - $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
271 | - $other_obj->set( |
|
272 | - $pk_on_related_model, |
|
273 | - null, |
|
274 | - true |
|
275 | - ); // ensure we create a new row for the autosave with parent id the same as the incoming ID. |
|
276 | - $other_obj->save(); // make sure we insert. |
|
277 | - return array($other_obj); |
|
278 | - } |
|
279 | - } |
|
280 | - |
|
281 | - // var_dump('what makes it here'); |
|
282 | - // var_dump($other_obj); |
|
283 | - // the next possible condition is that the incoming other_model obj has a NULL pk which means it just gets saved (which in turn creates it) |
|
284 | - |
|
285 | - // the last possible condition on a revision is that the incoming other_model object has a fk that == $this_obj pk which means we just return the $other obj and let it save as normal so we see the return at the bottom of this method. |
|
286 | - } else { |
|
287 | - // we only need to do the below IF this is not a remove relation |
|
288 | - if (! $remove_relation) { |
|
289 | - // 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. |
|
290 | - // 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. |
|
291 | - $existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID()); |
|
292 | - $potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : null; |
|
293 | - |
|
294 | - if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) { |
|
295 | - // 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. |
|
296 | - $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
297 | - $other_obj->save(); |
|
298 | - |
|
299 | - // now create a new other_obj and fill with details from existing object |
|
300 | - $new_obj = $other_obj; |
|
301 | - $new_obj->set($this->_primary_cpt_field, $potential_revision_id); |
|
302 | - $new_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
303 | - $new_obj->set($pk_on_related_model, null); |
|
304 | - $new_obj->save(); |
|
305 | - return array($new_obj); |
|
306 | - } |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - return $other_obj; |
|
311 | - } |
|
244 | + if (! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
245 | + // 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. |
|
246 | + $has_parent_obj = $this->get_other_model()->get_one(array( |
|
247 | + array( |
|
248 | + $this->_parent_pk_relation_field => $other_obj->ID(), |
|
249 | + $this->_primary_cpt_field => $this_obj->ID(), |
|
250 | + ), |
|
251 | + )); |
|
252 | + |
|
253 | + if ($has_parent_obj) { |
|
254 | + // this makes sure the update on the current obj happens to the revision's row NOT the parent row. |
|
255 | + |
|
256 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
257 | + $other_obj->set($pk_on_related_model, $has_parent_obj->ID()); |
|
258 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
259 | + |
|
260 | + if (! $remove_relation) { |
|
261 | + $other_obj->save(); |
|
262 | + return array($other_obj); |
|
263 | + } elseif ($remove_relation && ! $this->_blocking_delete) { |
|
264 | + $other_obj->delete(); |
|
265 | + $other_obj->set($this->_parent_pk_relation_field, null, true); |
|
266 | + return array($other_obj); |
|
267 | + } |
|
268 | + } else { |
|
269 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
270 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
271 | + $other_obj->set( |
|
272 | + $pk_on_related_model, |
|
273 | + null, |
|
274 | + true |
|
275 | + ); // ensure we create a new row for the autosave with parent id the same as the incoming ID. |
|
276 | + $other_obj->save(); // make sure we insert. |
|
277 | + return array($other_obj); |
|
278 | + } |
|
279 | + } |
|
280 | + |
|
281 | + // var_dump('what makes it here'); |
|
282 | + // var_dump($other_obj); |
|
283 | + // the next possible condition is that the incoming other_model obj has a NULL pk which means it just gets saved (which in turn creates it) |
|
284 | + |
|
285 | + // the last possible condition on a revision is that the incoming other_model object has a fk that == $this_obj pk which means we just return the $other obj and let it save as normal so we see the return at the bottom of this method. |
|
286 | + } else { |
|
287 | + // we only need to do the below IF this is not a remove relation |
|
288 | + if (! $remove_relation) { |
|
289 | + // 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. |
|
290 | + // 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. |
|
291 | + $existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID()); |
|
292 | + $potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : null; |
|
293 | + |
|
294 | + if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) { |
|
295 | + // 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. |
|
296 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
297 | + $other_obj->save(); |
|
298 | + |
|
299 | + // now create a new other_obj and fill with details from existing object |
|
300 | + $new_obj = $other_obj; |
|
301 | + $new_obj->set($this->_primary_cpt_field, $potential_revision_id); |
|
302 | + $new_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
303 | + $new_obj->set($pk_on_related_model, null); |
|
304 | + $new_obj->save(); |
|
305 | + return array($new_obj); |
|
306 | + } |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + return $other_obj; |
|
311 | + } |
|
312 | 312 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
33 | 33 | $model_relation_chain, |
34 | 34 | $this->get_this_model()->get_this_model_name() |
35 | - ) . $this_table_pk_field->get_table_alias(); |
|
36 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
35 | + ).$this_table_pk_field->get_table_alias(); |
|
36 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
37 | 37 | $model_relation_chain, |
38 | 38 | $this->get_other_model()->get_this_model_name() |
39 | - ) . $other_table_fk_field->get_table_alias(); |
|
39 | + ).$other_table_fk_field->get_table_alias(); |
|
40 | 40 | $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
41 | 41 | $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
42 | 42 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $other_table_fk_field->get_table_column(), |
47 | 47 | $pk_table_alias, |
48 | 48 | $this_table_pk_field->get_table_column(), |
49 | - $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
49 | + $fk_table_alias.'.'.$field_with_model_name->get_table_column()."='".$this->get_this_model()->get_this_model_name()."'" |
|
50 | 50 | ) |
51 | 51 | . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
52 | 52 | } |
@@ -14,94 +14,94 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation |
16 | 16 | { |
17 | - /** |
|
18 | - * Gets the SQL string for performing the join between this model and the other model. |
|
19 | - * |
|
20 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
21 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
22 | - * other_model_primary_table.fk" etc |
|
23 | - * @throws \EE_Error |
|
24 | - */ |
|
25 | - public function get_join_statement($model_relation_chain) |
|
26 | - { |
|
27 | - // create the sql string like |
|
28 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
29 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
30 | - $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
31 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
32 | - $model_relation_chain, |
|
33 | - $this->get_this_model()->get_this_model_name() |
|
34 | - ) . $this_table_pk_field->get_table_alias(); |
|
35 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
36 | - $model_relation_chain, |
|
37 | - $this->get_other_model()->get_this_model_name() |
|
38 | - ) . $other_table_fk_field->get_table_alias(); |
|
39 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
40 | - $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
|
17 | + /** |
|
18 | + * Gets the SQL string for performing the join between this model and the other model. |
|
19 | + * |
|
20 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
21 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
22 | + * other_model_primary_table.fk" etc |
|
23 | + * @throws \EE_Error |
|
24 | + */ |
|
25 | + public function get_join_statement($model_relation_chain) |
|
26 | + { |
|
27 | + // create the sql string like |
|
28 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
29 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
30 | + $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
31 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
32 | + $model_relation_chain, |
|
33 | + $this->get_this_model()->get_this_model_name() |
|
34 | + ) . $this_table_pk_field->get_table_alias(); |
|
35 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
36 | + $model_relation_chain, |
|
37 | + $this->get_other_model()->get_this_model_name() |
|
38 | + ) . $other_table_fk_field->get_table_alias(); |
|
39 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
40 | + $field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name(); |
|
41 | 41 | |
42 | - return $this->_left_join( |
|
43 | - $fk_table, |
|
44 | - $fk_table_alias, |
|
45 | - $other_table_fk_field->get_table_column(), |
|
46 | - $pk_table_alias, |
|
47 | - $this_table_pk_field->get_table_column(), |
|
48 | - $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
49 | - ) |
|
50 | - . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
51 | - } |
|
42 | + return $this->_left_join( |
|
43 | + $fk_table, |
|
44 | + $fk_table_alias, |
|
45 | + $other_table_fk_field->get_table_column(), |
|
46 | + $pk_table_alias, |
|
47 | + $this_table_pk_field->get_table_column(), |
|
48 | + $fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" |
|
49 | + ) |
|
50 | + . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
56 | - * you like. |
|
57 | - * |
|
58 | - * @param EE_Base_Class|int $this_obj_or_id |
|
59 | - * @param EE_Base_Class|int $other_obj_or_id |
|
60 | - * @param array $extra_join_model_fields_n_values |
|
61 | - * @return \EE_Base_Class |
|
62 | - * @throws \EE_Error |
|
63 | - */ |
|
64 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
65 | - { |
|
66 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
67 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
54 | + /** |
|
55 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
56 | + * you like. |
|
57 | + * |
|
58 | + * @param EE_Base_Class|int $this_obj_or_id |
|
59 | + * @param EE_Base_Class|int $other_obj_or_id |
|
60 | + * @param array $extra_join_model_fields_n_values |
|
61 | + * @return \EE_Base_Class |
|
62 | + * @throws \EE_Error |
|
63 | + */ |
|
64 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
65 | + { |
|
66 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
67 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
68 | 68 | |
69 | - // find the field on the other model which is a foreign key to this model |
|
70 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
71 | - // set that field on the other model to this model's ID |
|
72 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
73 | - $other_model_obj->set( |
|
74 | - $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
75 | - $this->get_this_model()->get_this_model_name() |
|
76 | - ); |
|
77 | - $other_model_obj->save(); |
|
78 | - return $other_model_obj; |
|
79 | - } |
|
69 | + // find the field on the other model which is a foreign key to this model |
|
70 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
71 | + // set that field on the other model to this model's ID |
|
72 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
73 | + $other_model_obj->set( |
|
74 | + $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
75 | + $this->get_this_model()->get_this_model_name() |
|
76 | + ); |
|
77 | + $other_model_obj->save(); |
|
78 | + return $other_model_obj; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
84 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
85 | - * |
|
86 | - * @param EE_Base_Class|int $this_obj_or_id |
|
87 | - * @param EE_Base_Class|int $other_obj_or_id |
|
88 | - * @param array $where_query |
|
89 | - * @return \EE_Base_Class |
|
90 | - * @throws \EE_Error |
|
91 | - */ |
|
92 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
93 | - { |
|
94 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
95 | - // find the field on the other model which is a foreign key to this model |
|
96 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
97 | - // set that field on the other model to this model's ID |
|
98 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
99 | - $other_model_obj->set( |
|
100 | - $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
101 | - null, |
|
102 | - true |
|
103 | - ); |
|
104 | - $other_model_obj->save(); |
|
105 | - return $other_model_obj; |
|
106 | - } |
|
82 | + /** |
|
83 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
84 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
85 | + * |
|
86 | + * @param EE_Base_Class|int $this_obj_or_id |
|
87 | + * @param EE_Base_Class|int $other_obj_or_id |
|
88 | + * @param array $where_query |
|
89 | + * @return \EE_Base_Class |
|
90 | + * @throws \EE_Error |
|
91 | + */ |
|
92 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
93 | + { |
|
94 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
95 | + // find the field on the other model which is a foreign key to this model |
|
96 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
97 | + // set that field on the other model to this model's ID |
|
98 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
99 | + $other_model_obj->set( |
|
100 | + $this->get_other_model()->get_field_containing_related_model_name()->get_name(), |
|
101 | + null, |
|
102 | + true |
|
103 | + ); |
|
104 | + $other_model_obj->save(); |
|
105 | + return $other_model_obj; |
|
106 | + } |
|
107 | 107 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Unique_Index extends EE_Index |
8 | 8 | { |
9 | - // yep, actually the same as index right now |
|
9 | + // yep, actually the same as index right now |
|
10 | 10 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Primary_Key_Index extends EE_Unique_Index |
8 | 8 | { |
9 | - // yep, actually the same as unique index right now |
|
9 | + // yep, actually the same as unique index right now |
|
10 | 10 | } |
@@ -14,141 +14,141 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
16 | 16 | */ |
17 | - private $_join_sql; |
|
17 | + private $_join_sql; |
|
18 | 18 | /** |
19 | 19 | * |
20 | 20 | * @var array stating all the models that have been included thus far,so we don't get duplicates. |
21 | 21 | * Keys are the model relation chains to them from the queried model |
22 | 22 | * (eg, "Registration.Transaction.Payment"), and valuesare model names (eg "Payment") |
23 | 23 | */ |
24 | - private $_models_included; |
|
24 | + private $_models_included; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * After we've acquired all the data types, we can create this sql. |
28 | 28 | * @var string |
29 | 29 | */ |
30 | - private $_where_sql; |
|
30 | + private $_where_sql; |
|
31 | 31 | /** |
32 | 32 | * Full join sql. Eg, in a select query, that's everything after the "FROM", and before the "WHERE", so it includes |
33 | 33 | * the declaration of the main model's tables, and then appends all the joining sql to other models |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_main_join_sql; |
|
36 | + private $_main_join_sql; |
|
37 | 37 | |
38 | 38 | |
39 | - private $_limit_sql; |
|
39 | + private $_limit_sql; |
|
40 | 40 | |
41 | - private $_order_by_sql; |
|
41 | + private $_order_by_sql; |
|
42 | 42 | |
43 | - private $_having_sql; |
|
43 | + private $_having_sql; |
|
44 | 44 | |
45 | - private $_group_by_sql; |
|
45 | + private $_group_by_sql; |
|
46 | 46 | |
47 | - public function set_limit_sql($limit_sql) |
|
48 | - { |
|
49 | - $this->_limit_sql = $limit_sql; |
|
50 | - } |
|
47 | + public function set_limit_sql($limit_sql) |
|
48 | + { |
|
49 | + $this->_limit_sql = $limit_sql; |
|
50 | + } |
|
51 | 51 | |
52 | - public function set_order_by_sql($order_by_sql) |
|
53 | - { |
|
54 | - $this->_order_by_sql = $order_by_sql; |
|
55 | - } |
|
56 | - public function set_group_by_sql($group_by_sql) |
|
57 | - { |
|
58 | - $this->_group_by_sql = $group_by_sql; |
|
59 | - } |
|
60 | - public function set_having_sql($having_sql) |
|
61 | - { |
|
62 | - $this->_having_sql = $having_sql; |
|
63 | - } |
|
64 | - public function get_limit_sql() |
|
65 | - { |
|
66 | - return $this->_limit_sql; |
|
67 | - } |
|
68 | - public function get_order_by_sql() |
|
69 | - { |
|
70 | - return $this->_order_by_sql; |
|
71 | - } |
|
72 | - public function get_group_by_sql() |
|
73 | - { |
|
74 | - return $this->_group_by_sql; |
|
75 | - } |
|
76 | - public function get_having_sql() |
|
77 | - { |
|
78 | - return $this->_having_sql; |
|
79 | - } |
|
52 | + public function set_order_by_sql($order_by_sql) |
|
53 | + { |
|
54 | + $this->_order_by_sql = $order_by_sql; |
|
55 | + } |
|
56 | + public function set_group_by_sql($group_by_sql) |
|
57 | + { |
|
58 | + $this->_group_by_sql = $group_by_sql; |
|
59 | + } |
|
60 | + public function set_having_sql($having_sql) |
|
61 | + { |
|
62 | + $this->_having_sql = $having_sql; |
|
63 | + } |
|
64 | + public function get_limit_sql() |
|
65 | + { |
|
66 | + return $this->_limit_sql; |
|
67 | + } |
|
68 | + public function get_order_by_sql() |
|
69 | + { |
|
70 | + return $this->_order_by_sql; |
|
71 | + } |
|
72 | + public function get_group_by_sql() |
|
73 | + { |
|
74 | + return $this->_group_by_sql; |
|
75 | + } |
|
76 | + public function get_having_sql() |
|
77 | + { |
|
78 | + return $this->_having_sql; |
|
79 | + } |
|
80 | 80 | /** |
81 | 81 | * |
82 | 82 | * @param type $model_included_name |
83 | 83 | * @param type $join_sql |
84 | 84 | * @param type $data_types |
85 | 85 | */ |
86 | - public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | - { |
|
88 | - $this->_models_included = $model_included_name; |
|
89 | - $this->_join_sql = $join_sql; |
|
90 | - } |
|
86 | + public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | + { |
|
88 | + $this->_models_included = $model_included_name; |
|
89 | + $this->_join_sql = $join_sql; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
94 | 94 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
95 | 95 | */ |
96 | - public function merge($other_model_query_info_carrier) |
|
97 | - { |
|
98 | - if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | - $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | - $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | - } |
|
103 | - // otherwise don't merge our data. |
|
104 | - // yes, this means that we must immediately merge any model data into our grand list |
|
105 | - // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | - // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | - } |
|
96 | + public function merge($other_model_query_info_carrier) |
|
97 | + { |
|
98 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | + $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | + } |
|
103 | + // otherwise don't merge our data. |
|
104 | + // yes, this means that we must immediately merge any model data into our grand list |
|
105 | + // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | + // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | + } |
|
108 | 108 | /** |
109 | 109 | * Checks whether or not we have already included all the models mentione din $model_names on the query info varrier |
110 | 110 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
111 | 111 | * @return boolean |
112 | 112 | */ |
113 | - protected function _have_already_included_one_of_these_models($model_names) |
|
114 | - { |
|
115 | - foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | - if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | - return true; |
|
118 | - } |
|
119 | - } |
|
120 | - return false; |
|
121 | - } |
|
113 | + protected function _have_already_included_one_of_these_models($model_names) |
|
114 | + { |
|
115 | + foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | + return true; |
|
118 | + } |
|
119 | + } |
|
120 | + return false; |
|
121 | + } |
|
122 | 122 | /** |
123 | 123 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
124 | 124 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
125 | 125 | */ |
126 | - public function get_model_names_included() |
|
127 | - { |
|
128 | - return $this->_models_included; |
|
129 | - } |
|
126 | + public function get_model_names_included() |
|
127 | + { |
|
128 | + return $this->_models_included; |
|
129 | + } |
|
130 | 130 | /** |
131 | 131 | * sets the $where_sql for later use from client code |
132 | 132 | * @param string $where_sql |
133 | 133 | */ |
134 | - public function set_where_sql($where_sql) |
|
135 | - { |
|
136 | - $this->_where_sql = $where_sql; |
|
137 | - } |
|
138 | - public function get_where_sql() |
|
139 | - { |
|
140 | - return $this->_where_sql; |
|
141 | - } |
|
134 | + public function set_where_sql($where_sql) |
|
135 | + { |
|
136 | + $this->_where_sql = $where_sql; |
|
137 | + } |
|
138 | + public function get_where_sql() |
|
139 | + { |
|
140 | + return $this->_where_sql; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Gets the SQL for joining the main model to other models involves in the query, which was set earlier on |
145 | 145 | * the EE_Model_Query_info_Carrier by calling set_main_model_join_sql() |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function get_main_model_join_sql() |
|
149 | - { |
|
150 | - return $this->_main_join_sql; |
|
151 | - } |
|
148 | + public function get_main_model_join_sql() |
|
149 | + { |
|
150 | + return $this->_main_join_sql; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | /** |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * after the FROM and before the WHERE.) |
159 | 159 | * @param string $join_sql |
160 | 160 | */ |
161 | - public function set_main_model_join_sql($join_sql) |
|
162 | - { |
|
163 | - $this->_main_join_sql = $join_sql; |
|
164 | - } |
|
165 | - public function get_full_join_sql() |
|
166 | - { |
|
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
168 | - } |
|
161 | + public function set_main_model_join_sql($join_sql) |
|
162 | + { |
|
163 | + $this->_main_join_sql = $join_sql; |
|
164 | + } |
|
165 | + public function get_full_join_sql() |
|
166 | + { |
|
167 | + return $this->_main_join_sql . $this->_join_sql; |
|
168 | + } |
|
169 | 169 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function merge($other_model_query_info_carrier) |
97 | 97 | { |
98 | 98 | if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | 100 | $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
101 | 101 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
102 | 102 | } |
@@ -164,6 +164,6 @@ discard block |
||
164 | 164 | } |
165 | 165 | public function get_full_join_sql() |
166 | 166 | { |
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
167 | + return $this->_main_join_sql.$this->_join_sql; |
|
168 | 168 | } |
169 | 169 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return htmlspecialchars($string); |
47 | 47 | } else { |
48 | 48 | if ($translate === false) { |
49 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
49 | + return self::ee_tep_parse_input_field_data($string, array('"' => '"')); |
|
50 | 50 | } else { |
51 | 51 | return self::ee_tep_parse_input_field_data($string, $translate); |
52 | 52 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | } else { |
87 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
87 | + if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) { |
|
88 | 88 | return true; |
89 | 89 | } else { |
90 | 90 | return false; |
@@ -10,108 +10,108 @@ |
||
10 | 10 | */ |
11 | 11 | class EEH_Formatter |
12 | 12 | { |
13 | - /** |
|
14 | - * _admin_format_content |
|
15 | - * Text formatting function for wp_editor. |
|
16 | - * This should fix all of the formatting issues of text output from the database. |
|
17 | - * |
|
18 | - * @static |
|
19 | - * @access public |
|
20 | - * @param string $content content to format |
|
21 | - * @return string formatted content |
|
22 | - */ |
|
23 | - public static function admin_format_content($content = '') |
|
24 | - { |
|
25 | - return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
26 | - } |
|
13 | + /** |
|
14 | + * _admin_format_content |
|
15 | + * Text formatting function for wp_editor. |
|
16 | + * This should fix all of the formatting issues of text output from the database. |
|
17 | + * |
|
18 | + * @static |
|
19 | + * @access public |
|
20 | + * @param string $content content to format |
|
21 | + * @return string formatted content |
|
22 | + */ |
|
23 | + public static function admin_format_content($content = '') |
|
24 | + { |
|
25 | + return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * ee_tep_output_string |
|
32 | - * todo: we need a description for this. |
|
33 | - * |
|
34 | - * @static |
|
35 | - * @access public |
|
36 | - * @param string $string string to handle |
|
37 | - * @param boolean $translate //todo what is this for? |
|
38 | - * @param boolean $protected true then we run htmlspecialchars and return |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
42 | - { |
|
43 | - if ($protected === true) { |
|
44 | - return htmlspecialchars($string); |
|
45 | - } else { |
|
46 | - if ($translate === false) { |
|
47 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
48 | - } else { |
|
49 | - return self::ee_tep_parse_input_field_data($string, $translate); |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
30 | + /** |
|
31 | + * ee_tep_output_string |
|
32 | + * todo: we need a description for this. |
|
33 | + * |
|
34 | + * @static |
|
35 | + * @access public |
|
36 | + * @param string $string string to handle |
|
37 | + * @param boolean $translate //todo what is this for? |
|
38 | + * @param boolean $protected true then we run htmlspecialchars and return |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
42 | + { |
|
43 | + if ($protected === true) { |
|
44 | + return htmlspecialchars($string); |
|
45 | + } else { |
|
46 | + if ($translate === false) { |
|
47 | + return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
48 | + } else { |
|
49 | + return self::ee_tep_parse_input_field_data($string, $translate); |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * ee_tep_parse_input_field_data |
|
58 | - * |
|
59 | - * @param string $data string to be "translated" |
|
60 | - * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public static function ee_tep_parse_input_field_data($data, $parse) |
|
64 | - { |
|
65 | - return strtr(trim($data), $parse); |
|
66 | - } |
|
56 | + /** |
|
57 | + * ee_tep_parse_input_field_data |
|
58 | + * |
|
59 | + * @param string $data string to be "translated" |
|
60 | + * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public static function ee_tep_parse_input_field_data($data, $parse) |
|
64 | + { |
|
65 | + return strtr(trim($data), $parse); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * [ee_tep_not_null description] |
|
72 | - * |
|
73 | - * @param string | array $value [description] |
|
74 | - * @return bool [description] |
|
75 | - */ |
|
76 | - public static function ee_tep_not_null($value) |
|
77 | - { |
|
78 | - if (is_array($value)) { |
|
79 | - if (count($value) > 0) { |
|
80 | - return true; |
|
81 | - } else { |
|
82 | - return false; |
|
83 | - } |
|
84 | - } else { |
|
85 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
86 | - return true; |
|
87 | - } else { |
|
88 | - return false; |
|
89 | - } |
|
90 | - } |
|
91 | - } |
|
70 | + /** |
|
71 | + * [ee_tep_not_null description] |
|
72 | + * |
|
73 | + * @param string | array $value [description] |
|
74 | + * @return bool [description] |
|
75 | + */ |
|
76 | + public static function ee_tep_not_null($value) |
|
77 | + { |
|
78 | + if (is_array($value)) { |
|
79 | + if (count($value) > 0) { |
|
80 | + return true; |
|
81 | + } else { |
|
82 | + return false; |
|
83 | + } |
|
84 | + } else { |
|
85 | + if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
86 | + return true; |
|
87 | + } else { |
|
88 | + return false; |
|
89 | + } |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * Formats a date |
|
97 | - * |
|
98 | - * @param string $date |
|
99 | - * @param string $format - format for the date |
|
100 | - * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
101 | - * addons at time of writing this. So just deprecated in case of third party use. |
|
102 | - * @return string |
|
103 | - * @deprecated v4.6.21 |
|
104 | - */ |
|
105 | - public static function event_date_display($date, $format = '') |
|
106 | - { |
|
107 | - EE_Error::doing_it_wrong( |
|
108 | - __METHOD__, |
|
109 | - esc_html__( |
|
110 | - 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
111 | - 'event_espresso' |
|
112 | - ), |
|
113 | - '4.6.21' |
|
114 | - ); |
|
115 | - return $date; |
|
116 | - } |
|
95 | + /** |
|
96 | + * Formats a date |
|
97 | + * |
|
98 | + * @param string $date |
|
99 | + * @param string $format - format for the date |
|
100 | + * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
101 | + * addons at time of writing this. So just deprecated in case of third party use. |
|
102 | + * @return string |
|
103 | + * @deprecated v4.6.21 |
|
104 | + */ |
|
105 | + public static function event_date_display($date, $format = '') |
|
106 | + { |
|
107 | + EE_Error::doing_it_wrong( |
|
108 | + __METHOD__, |
|
109 | + esc_html__( |
|
110 | + 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
111 | + 'event_espresso' |
|
112 | + ), |
|
113 | + '4.6.21' |
|
114 | + ); |
|
115 | + return $date; |
|
116 | + } |
|
117 | 117 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | */ |
45 | 45 | public function pre_get_posts(WP_Query $WP_Query) |
46 | 46 | { |
47 | - if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
47 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
48 | 48 | return $WP_Query; |
49 | 49 | } |
50 | 50 | return $WP_Query; |
@@ -11,70 +11,70 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_CPT_Default_Strategy |
13 | 13 | { |
14 | - /** |
|
15 | - * $CPT - the current page, if it utilizes CPTs |
|
16 | - * |
|
17 | - * @var object |
|
18 | - * @access protected |
|
19 | - */ |
|
20 | - protected $CPT = null; |
|
14 | + /** |
|
15 | + * $CPT - the current page, if it utilizes CPTs |
|
16 | + * |
|
17 | + * @var object |
|
18 | + * @access protected |
|
19 | + */ |
|
20 | + protected $CPT = null; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * class constructor |
|
25 | - * |
|
26 | - * @access private |
|
27 | - * @param array $arguments |
|
28 | - * @return \EE_CPT_Default_Strategy |
|
29 | - */ |
|
30 | - public function __construct($arguments = array()) |
|
31 | - { |
|
32 | - $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
33 | - } |
|
23 | + /** |
|
24 | + * class constructor |
|
25 | + * |
|
26 | + * @access private |
|
27 | + * @param array $arguments |
|
28 | + * @return \EE_CPT_Default_Strategy |
|
29 | + */ |
|
30 | + public function __construct($arguments = array()) |
|
31 | + { |
|
32 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * pre_get_posts |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param \WP_Query $WP_Query |
|
41 | - * @return \WP_Query |
|
42 | - */ |
|
43 | - public function pre_get_posts(WP_Query $WP_Query) |
|
44 | - { |
|
45 | - if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
46 | - return $WP_Query; |
|
47 | - } |
|
48 | - return $WP_Query; |
|
49 | - } |
|
36 | + /** |
|
37 | + * pre_get_posts |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param \WP_Query $WP_Query |
|
41 | + * @return \WP_Query |
|
42 | + */ |
|
43 | + public function pre_get_posts(WP_Query $WP_Query) |
|
44 | + { |
|
45 | + if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
46 | + return $WP_Query; |
|
47 | + } |
|
48 | + return $WP_Query; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * wp |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @param \WP_Post[] $posts |
|
57 | - * @param \WP_Query $WP_Query |
|
58 | - * @return \WP_Post[] |
|
59 | - */ |
|
60 | - public function the_posts($posts, WP_Query $WP_Query) |
|
61 | - { |
|
62 | - return $posts; |
|
63 | - } |
|
52 | + /** |
|
53 | + * wp |
|
54 | + * |
|
55 | + * @access public |
|
56 | + * @param \WP_Post[] $posts |
|
57 | + * @param \WP_Query $WP_Query |
|
58 | + * @return \WP_Post[] |
|
59 | + */ |
|
60 | + public function the_posts($posts, WP_Query $WP_Query) |
|
61 | + { |
|
62 | + return $posts; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * get_EE_post_type_metadata |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @param mixed $meta_value |
|
71 | - * @param int $post_id |
|
72 | - * @param string $meta_key |
|
73 | - * @param string $single |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - public function get_EE_post_type_metadata($meta_value = null, $post_id, $meta_key, $single) |
|
77 | - { |
|
78 | - return $meta_value; |
|
79 | - } |
|
66 | + /** |
|
67 | + * get_EE_post_type_metadata |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @param mixed $meta_value |
|
71 | + * @param int $post_id |
|
72 | + * @param string $meta_key |
|
73 | + * @param string $single |
|
74 | + * @return mixed |
|
75 | + */ |
|
76 | + public function get_EE_post_type_metadata($meta_value = null, $post_id, $meta_key, $single) |
|
77 | + { |
|
78 | + return $meta_value; |
|
79 | + } |
|
80 | 80 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public static function getInvalidCheckoutAccess() |
62 | 62 | { |
63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
63 | + if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | 64 | self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
65 | 65 | } |
66 | 66 | return self::$invalid_checkout_access_form; |
@@ -13,84 +13,84 @@ |
||
13 | 13 | */ |
14 | 14 | class EED_Invalid_Checkout_Access extends EED_Module |
15 | 15 | { |
16 | - /** |
|
17 | - * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
18 | - */ |
|
19 | - private static $invalid_checkout_access_form; |
|
16 | + /** |
|
17 | + * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
18 | + */ |
|
19 | + private static $invalid_checkout_access_form; |
|
20 | 20 | |
21 | - /** |
|
22 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | - */ |
|
24 | - public static function set_hooks() |
|
25 | - { |
|
26 | - } |
|
21 | + /** |
|
22 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | + */ |
|
24 | + public static function set_hooks() |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
31 | - */ |
|
32 | - public static function set_hooks_admin() |
|
33 | - { |
|
34 | - add_action( |
|
35 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
36 | - array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
37 | - 15 |
|
38 | - ); |
|
39 | - add_filter( |
|
40 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
41 | - array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
42 | - ); |
|
43 | - } |
|
29 | + /** |
|
30 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
31 | + */ |
|
32 | + public static function set_hooks_admin() |
|
33 | + { |
|
34 | + add_action( |
|
35 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
36 | + array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
37 | + 15 |
|
38 | + ); |
|
39 | + add_filter( |
|
40 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
41 | + array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * run - initial module setup |
|
48 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
49 | - * |
|
50 | - * @var WP $WP |
|
51 | - */ |
|
52 | - public function run($WP) |
|
53 | - { |
|
54 | - // TODO: Implement run() method. |
|
55 | - } |
|
46 | + /** |
|
47 | + * run - initial module setup |
|
48 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
49 | + * |
|
50 | + * @var WP $WP |
|
51 | + */ |
|
52 | + public function run($WP) |
|
53 | + { |
|
54 | + // TODO: Implement run() method. |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @return InvalidCheckoutAccess |
|
60 | - */ |
|
61 | - public static function getInvalidCheckoutAccess() |
|
62 | - { |
|
63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | - self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
65 | - } |
|
66 | - return self::$invalid_checkout_access_form; |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return InvalidCheckoutAccess |
|
60 | + */ |
|
61 | + public static function getInvalidCheckoutAccess() |
|
62 | + { |
|
63 | + if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
64 | + self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
65 | + } |
|
66 | + return self::$invalid_checkout_access_form; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * email_validation_settings_form |
|
72 | - * |
|
73 | - * @return void |
|
74 | - * @throws EE_Error |
|
75 | - */ |
|
76 | - public static function display_invalid_checkout_access_form() |
|
77 | - { |
|
78 | - $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
79 | - echo wp_kses($invalid_checkout_access_form->getForm()->get_html(), AllowedTags::getWithFormTags()); |
|
80 | - } |
|
70 | + /** |
|
71 | + * email_validation_settings_form |
|
72 | + * |
|
73 | + * @return void |
|
74 | + * @throws EE_Error |
|
75 | + */ |
|
76 | + public static function display_invalid_checkout_access_form() |
|
77 | + { |
|
78 | + $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
79 | + echo wp_kses($invalid_checkout_access_form->getForm()->get_html(), AllowedTags::getWithFormTags()); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * email_validation_settings_form |
|
85 | - * |
|
86 | - * @param EE_Registration_Config $EE_Registration_Config |
|
87 | - * @return EE_Registration_Config |
|
88 | - * @throws EE_Error |
|
89 | - * @throws ReflectionException |
|
90 | - */ |
|
91 | - public static function process_invalid_checkout_access_form(EE_Registration_Config $EE_Registration_Config) |
|
92 | - { |
|
93 | - $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
94 | - return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
95 | - } |
|
83 | + /** |
|
84 | + * email_validation_settings_form |
|
85 | + * |
|
86 | + * @param EE_Registration_Config $EE_Registration_Config |
|
87 | + * @return EE_Registration_Config |
|
88 | + * @throws EE_Error |
|
89 | + * @throws ReflectionException |
|
90 | + */ |
|
91 | + public static function process_invalid_checkout_access_form(EE_Registration_Config $EE_Registration_Config) |
|
92 | + { |
|
93 | + $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
94 | + return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
95 | + } |
|
96 | 96 | } |
@@ -3,13 +3,13 @@ |
||
3 | 3 | // if this is decaf, which is put on WordPress.org, we need to inform users that |
4 | 4 | // we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12 |
5 | 5 | if (apply_filters('FHEE__ee_show_affiliate_links', true)) { |
6 | - $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso'); |
|
6 | + $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso'); |
|
7 | 7 | } |
8 | 8 | printf( |
9 | - esc_html__( |
|
10 | - 'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
11 | - 'event_espresso' |
|
12 | - ), |
|
13 | - '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', |
|
14 | - $closing_tag |
|
9 | + esc_html__( |
|
10 | + 'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
11 | + 'event_espresso' |
|
12 | + ), |
|
13 | + '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', |
|
14 | + $closing_tag |
|
15 | 15 | ); |