@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get_value() { |
26 | 26 | |
27 | - if ( wordpoints_is_network_context() ) { |
|
27 | + if (wordpoints_is_network_context()) { |
|
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | - return __( 'Site', 'wordpoints' ); |
|
38 | + return __('Site', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -58,8 +58,20 @@ discard block |
||
58 | 58 | |
59 | 59 | // this is basically a reactor |
60 | 60 | interface WordPoints_Entity_Change_ListenerI { |
61 | + |
|
62 | + /** |
|
63 | + * @return void |
|
64 | + */ |
|
61 | 65 | public function created( WordPoints_Entity $entity ); |
66 | + |
|
67 | + /** |
|
68 | + * @return void |
|
69 | + */ |
|
62 | 70 | public function updated( WordPoints_Entity $before, WordPoints_Entity $after ); |
71 | + |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + */ |
|
63 | 75 | public function deleted( WordPoints_Entity $entity ); |
64 | 76 | } |
65 | 77 | |
@@ -129,6 +141,9 @@ discard block |
||
129 | 141 | return true; |
130 | 142 | } |
131 | 143 | |
144 | + /** |
|
145 | + * @param string $type |
|
146 | + */ |
|
132 | 147 | protected function fire_event( $type, WordPoints_Entity $entity ) { |
133 | 148 | |
134 | 149 | $args = new WordPoints_Hook_Event_Args( array() ); |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | // this is basicaly a router. |
11 | 11 | class WordPoints_Entity_chang_trigger implements WordPoints_Entity_Change_ListenerI { |
12 | 12 | |
13 | - public function created( WordPoints_Entity $entity ) { |
|
13 | + public function created(WordPoints_Entity $entity) { |
|
14 | 14 | // can multiple entities be created at once? not using insert() but via query() |
15 | 15 | // maybe? and how shoudl we handle that, all at once or one by one? |
16 | 16 | |
17 | 17 | /** @var WordPoints_Entity_Change_ListenerI[] $listeners */ |
18 | - $listeners = wordpoints_apps()->get_sub_app( 'entity_change_listeners' ); |
|
19 | - foreach ( $listeners as $listener ) { |
|
20 | - $listener->created( $entity ); |
|
18 | + $listeners = wordpoints_apps()->get_sub_app('entity_change_listeners'); |
|
19 | + foreach ($listeners as $listener) { |
|
20 | + $listener->created($entity); |
|
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | - public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) { |
|
25 | + public function updated(WordPoints_Entity $before, WordPoints_Entity $after) { |
|
26 | 26 | |
27 | 27 | // what if multiple entities are updated at once? do we run each one separatately? |
28 | 28 | // mayb ethat should be left up to the listenter. |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | - public function deleted( WordPoints_Entity $entity ) { |
|
33 | + public function deleted(WordPoints_Entity $entity) { |
|
34 | 34 | |
35 | 35 | // what if we need information about this entitie's relationships, etc., that |
36 | 36 | // isn't included inthe entity object? |
@@ -58,41 +58,41 @@ discard block |
||
58 | 58 | |
59 | 59 | // this is basically a reactor |
60 | 60 | interface WordPoints_Entity_Change_ListenerI { |
61 | - public function created( WordPoints_Entity $entity ); |
|
62 | - public function updated( WordPoints_Entity $before, WordPoints_Entity $after ); |
|
63 | - public function deleted( WordPoints_Entity $entity ); |
|
61 | + public function created(WordPoints_Entity $entity); |
|
62 | + public function updated(WordPoints_Entity $before, WordPoints_Entity $after); |
|
63 | + public function deleted(WordPoints_Entity $entity); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | class WordPoints_Entity_Change_Listener_Hooks implements WordPoints_Entity_Change_ListenerI { |
67 | 67 | |
68 | - public function created( WordPoints_Entity $entity ) { |
|
68 | + public function created(WordPoints_Entity $entity) { |
|
69 | 69 | |
70 | 70 | // maybe we would have multuiple events with requirements for a single entity? |
71 | 71 | // like comment author and post commentn author targets for the same hook. |
72 | 72 | // but I guess taht is just one event. |
73 | 73 | // what about user register vs user create on MS? |
74 | - if ( $this->matches_requirements( $entity ) ) { |
|
75 | - $this->fire_event( 'add', $entity ); |
|
74 | + if ($this->matches_requirements($entity)) { |
|
75 | + $this->fire_event('add', $entity); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) { |
|
79 | + public function updated(WordPoints_Entity $before, WordPoints_Entity $after) { |
|
80 | 80 | |
81 | - if ( $this->matches_requirements( $after ) ) { |
|
82 | - if ( ! $this->matches_requirements( $before ) ) { |
|
83 | - $this->fire_event( 'add', $after ); |
|
81 | + if ($this->matches_requirements($after)) { |
|
82 | + if ( ! $this->matches_requirements($before)) { |
|
83 | + $this->fire_event('add', $after); |
|
84 | 84 | } |
85 | 85 | } else { |
86 | - if ( $this->matches_requirements( $before ) ) { |
|
87 | - $this->fire_event( 'remove', $after ); |
|
86 | + if ($this->matches_requirements($before)) { |
|
87 | + $this->fire_event('remove', $after); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - public function deleted( WordPoints_Entity $entity ) { |
|
92 | + public function deleted(WordPoints_Entity $entity) { |
|
93 | 93 | |
94 | - if ( $this->matches_requirements( $entity ) ) { |
|
95 | - $this->fire_event( 'remove', $entity ); |
|
94 | + if ($this->matches_requirements($entity)) { |
|
95 | + $this->fire_event('remove', $entity); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | // called into play when the entity itself is deleted is moot, because the |
109 | 109 | // reltionships, etc., aren't even taken into account when toggle-off is called, |
110 | 110 | // in the points reactor. other reators might, i guess. |
111 | - protected function matches_requirements( WordPoints_Entity $entity ) { |
|
111 | + protected function matches_requirements(WordPoints_Entity $entity) { |
|
112 | 112 | |
113 | 113 | /** @var WordPoints_Class_Registry $defaults */ |
114 | - $defaults = wordpoints_apps()->get_sub_app( 'entity_possession_defaults' ); |
|
114 | + $defaults = wordpoints_apps()->get_sub_app('entity_possession_defaults'); |
|
115 | 115 | |
116 | - $defaults = $defaults->get( $entity->get_slug() ); |
|
116 | + $defaults = $defaults->get($entity->get_slug()); |
|
117 | 117 | |
118 | - if ( ! $defaults ) { |
|
118 | + if ( ! $defaults) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // use conditions here? |
123 | - foreach ( $defaults as $child => $value ) { |
|
124 | - if ( $entity->get_child( $child ) !== $value ) { |
|
123 | + foreach ($defaults as $child => $value) { |
|
124 | + if ($entity->get_child($child) !== $value) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | |
132 | - protected function fire_event( $type, WordPoints_Entity $entity ) { |
|
132 | + protected function fire_event($type, WordPoints_Entity $entity) { |
|
133 | 133 | |
134 | - $args = new WordPoints_Hook_Event_Args( array() ); |
|
135 | - $args->add_entity( $entity ); |
|
134 | + $args = new WordPoints_Hook_Event_Args(array()); |
|
135 | + $args->add_entity($entity); |
|
136 | 136 | |
137 | 137 | wordpoints_hooks()->fire( |
138 | - $type . '_entity_' . $entity->get_slug(), |
|
138 | + $type.'_entity_'.$entity->get_slug(), |
|
139 | 139 | $args, |
140 | 140 | 'toggle_on' |
141 | 141 | ); |
@@ -144,31 +144,31 @@ discard block |
||
144 | 144 | |
145 | 145 | class WordPoints_Entity_Change_Listener_Points implements WordPoints_Entity_Change_ListenerI { |
146 | 146 | |
147 | - public function created( WordPoints_Entity $entity ) { |
|
147 | + public function created(WordPoints_Entity $entity) { |
|
148 | 148 | |
149 | 149 | $this->process_entityish( |
150 | 150 | $entity |
151 | - , $this->get_settings_for_entity( $entity ) |
|
151 | + , $this->get_settings_for_entity($entity) |
|
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
155 | - protected function process_entityish( WordPoints_EntityishI $entity, $settings ) { |
|
155 | + protected function process_entityish(WordPoints_EntityishI $entity, $settings) { |
|
156 | 156 | |
157 | 157 | // possibly make this more like extension handling |
158 | - if ( ! $this->meets_conditions( $entity, $settings['conditions'] ) ) { |
|
158 | + if ( ! $this->meets_conditions($entity, $settings['conditions'])) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | 162 | // possibly make this more like reactor handling. |
163 | - $this->award_points( $settings ); |
|
163 | + $this->award_points($settings); |
|
164 | 164 | |
165 | 165 | // only proces the attributes taht have changed. |
166 | 166 | // acutally, in this case, the entity was just created. |
167 | - if ( $entity instanceof WordPoints_Entity_ParentI ) { |
|
167 | + if ($entity instanceof WordPoints_Entity_ParentI) { |
|
168 | 168 | |
169 | 169 | // this check runs on attributes only. |
170 | - foreach ( $settings['children'] as $child_slug => $child_settings ) { |
|
171 | - $this->process_entityish( $entity->get_child( $child_slug ), $child_settings ); |
|
170 | + foreach ($settings['children'] as $child_slug => $child_settings) { |
|
171 | + $this->process_entityish($entity->get_child($child_slug), $child_settings); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // we also need to check for any children, like relationships, that have |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // for this we need a list of relationships. |
177 | 177 | // if we do two-way relationships, we may need to have infinite-loop |
178 | 178 | // halding here, depending. |
179 | - foreach ( $this->get_related_entities( $entity ) as $child_entity ) { |
|
179 | + foreach ($this->get_related_entities($entity) as $child_entity) { |
|
180 | 180 | // If a comment was just created, for example, and we have conditions |
181 | 181 | // on the post entity, that affect the comment author, this allows |
182 | 182 | // us to handle those by pulling up the settings for the post entity |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | // as we've proposed... |
196 | 196 | $this->process_entityish( |
197 | 197 | $child_entity |
198 | - , $this->get_entity_settings( $child_entity ) |
|
198 | + , $this->get_entity_settings($child_entity) |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | // doesn't really make sense. |
210 | 210 | // I think relationships can be created and deleted, but not really updated. |
211 | 211 | // so maybe what we need is a separate api? |
212 | - public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) { |
|
212 | + public function updated(WordPoints_Entity $before, WordPoints_Entity $after) { |
|
213 | 213 | |
214 | - $settings = $this->get_settings_for_entity( $before ); |
|
214 | + $settings = $this->get_settings_for_entity($before); |
|
215 | 215 | |
216 | 216 | /** @var WordPoints_Class_Registry_ChildrenI $children */ |
217 | - $children = wordpoints_entities()->get_sub_app( 'children' ); |
|
218 | - foreach ( $children->get_children_slugs( $before->get_slug() ) as $child_slug ) { |
|
217 | + $children = wordpoints_entities()->get_sub_app('children'); |
|
218 | + foreach ($children->get_children_slugs($before->get_slug()) as $child_slug) { |
|
219 | 219 | |
220 | - if ( ! isset( $settings['children'][ $child_slug ] ) ) { |
|
220 | + if ( ! isset($settings['children'][$child_slug])) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
@@ -232,23 +232,23 @@ discard block |
||
232 | 232 | // but then we'll not be checking even the relationships taht are defined |
233 | 233 | // on the atts. so we have to decide whether those should be handled by |
234 | 234 | // a separate api or not. |
235 | - if ( $before->get_the_attr_value( $child_slug ) === $after->get_the_attr_value( $child_slug ) ) { |
|
235 | + if ($before->get_the_attr_value($child_slug) === $after->get_the_attr_value($child_slug)) { |
|
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | |
239 | 239 | $this->process_modified_entityish( |
240 | - $before->get_child( $child_slug ) |
|
241 | - , $after->get_child( $child_slug ) |
|
242 | - , $settings['children'][ $child_slug ] |
|
240 | + $before->get_child($child_slug) |
|
241 | + , $after->get_child($child_slug) |
|
242 | + , $settings['children'][$child_slug] |
|
243 | 243 | ); |
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - protected function process_modified_entityish( WordPoints_EntityishI $before, WordPoints_EntityishI $after, $settings ) { |
|
247 | + protected function process_modified_entityish(WordPoints_EntityishI $before, WordPoints_EntityishI $after, $settings) { |
|
248 | 248 | |
249 | - if ( ! $this->meets_conditions( $before, $settings['conditions'] ) ) { |
|
250 | - if ( $this->meets_conditions( $after, $settings['conditions'] ) ) { |
|
251 | - $this->award_points( $settings ); |
|
249 | + if ( ! $this->meets_conditions($before, $settings['conditions'])) { |
|
250 | + if ($this->meets_conditions($after, $settings['conditions'])) { |
|
251 | + $this->award_points($settings); |
|
252 | 252 | |
253 | 253 | // also need to process other eneities that are affected by this |
254 | 254 | // change, which may have conditions on this, i.e., that could be |
@@ -265,38 +265,38 @@ discard block |
||
265 | 265 | // then we do indeed need to run through the children/parents. |
266 | 266 | } |
267 | 267 | } else { |
268 | - if ( ! $this->meets_conditions( $after, $settings['conditions'] ) ) { |
|
269 | - $this->remove_points( $settings ); |
|
268 | + if ( ! $this->meets_conditions($after, $settings['conditions'])) { |
|
269 | + $this->remove_points($settings); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - public function deleted( WordPoints_Entity $entity ) { |
|
274 | + public function deleted(WordPoints_Entity $entity) { |
|
275 | 275 | // basically the opposite of created(). |
276 | - $this->process_entityish_reverse( $entity ); |
|
276 | + $this->process_entityish_reverse($entity); |
|
277 | 277 | } |
278 | 278 | |
279 | - protected function meets_conditions( WordPoints_EntityishI $entityish, $conditions ) { |
|
279 | + protected function meets_conditions(WordPoints_EntityishI $entityish, $conditions) { |
|
280 | 280 | // use conditions api |
281 | 281 | |
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | - private function award_points( $settings ) { |
|
285 | + private function award_points($settings) { |
|
286 | 286 | |
287 | - $hierarchy = new WordPoints_Entity_Hierarchy( $this->eitnty ); |
|
287 | + $hierarchy = new WordPoints_Entity_Hierarchy($this->eitnty); |
|
288 | 288 | // todo we'll need to introudce entity array targets, possibly. |
289 | 289 | // how will we know how to reverse the target reltinoship chains in the UI |
290 | 290 | // before saving? i guess we'll need to either have a dedicated index fo taht |
291 | 291 | // or else juust look it up by looping through the relationships (though we'd |
292 | 292 | // have to remove the entity array {} part from any one-to-many relationships |
293 | 293 | // and maybe we'd have to add it to others?) |
294 | - $targets = $hierarchy->get_from_hierarchy( $settings['target'] ); |
|
294 | + $targets = $hierarchy->get_from_hierarchy($settings['target']); |
|
295 | 295 | |
296 | 296 | // maybe just one target, maybe several, depending. |
297 | 297 | } |
298 | 298 | |
299 | - private function get_related_entities( WordPoints_Entity $entity ) { |
|
299 | + private function get_related_entities(WordPoints_Entity $entity) { |
|
300 | 300 | |
301 | 301 | // what we need is parental conditions. Conditions that go up the chain, |
302 | 302 | // and look back at parent entities. This way we can handle the info about |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @since 1.0.0 |
34 | 34 | */ |
35 | 35 | public function get_title() { |
36 | - return _x( 'Name', 'user role', 'wordpoints' ); |
|
36 | + return _x('Name', 'user role', 'wordpoints'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @since 1.0.0 |
34 | 34 | */ |
35 | 35 | public function get_title() { |
36 | - return _x( 'ID', 'taxonomy term', 'wordpoints' ); |
|
36 | + return _x('ID', 'taxonomy term', 'wordpoints'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | // EOF |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | |
12 | 12 | protected $wpdb; |
13 | 13 | |
14 | - public function __construct( $wpdb ) { |
|
14 | + public function __construct($wpdb) { |
|
15 | 15 | $this->wpdb = $wpdb; |
16 | 16 | } |
17 | 17 | |
18 | - public function __get( $name ) { |
|
18 | + public function __get($name) { |
|
19 | 19 | return $this->wpdb->$name; |
20 | 20 | } |
21 | 21 | |
22 | - public function __set( $name, $value ) { |
|
22 | + public function __set($name, $value) { |
|
23 | 23 | $this->wpdb->$name = $value; |
24 | 24 | } |
25 | 25 | |
26 | - public function __isset( $name ) { |
|
27 | - return isset( $this->wpdb->$name ); |
|
26 | + public function __isset($name) { |
|
27 | + return isset($this->wpdb->$name); |
|
28 | 28 | } |
29 | 29 | |
30 | - public function __unset( $name ) { |
|
31 | - unset( $this->wpdb->$name ); |
|
30 | + public function __unset($name) { |
|
31 | + unset($this->wpdb->$name); |
|
32 | 32 | } |
33 | 33 | |
34 | - public function __call( $name, $arguments ) { |
|
34 | + public function __call($name, $arguments) { |
|
35 | 35 | |
36 | - $wrappers = wordpoints_apps()->get_sub_app( 'wpdb_wrappers' ); |
|
37 | - $slugs = $wrappers->get_child_slugs( $name ); |
|
36 | + $wrappers = wordpoints_apps()->get_sub_app('wpdb_wrappers'); |
|
37 | + $slugs = $wrappers->get_child_slugs($name); |
|
38 | 38 | $should_listen = $query = false; |
39 | 39 | |
40 | 40 | |
41 | - switch ( $name ) { |
|
41 | + switch ($name) { |
|
42 | 42 | |
43 | 43 | case 'insert': |
44 | 44 | // case 'replace': |
45 | - $query = new WordPoints_WPDB_Query_Data_Array( $this->args[0] ); |
|
45 | + $query = new WordPoints_WPDB_Query_Data_Array($this->args[0]); |
|
46 | 46 | break; |
47 | 47 | |
48 | 48 | case 'update': |
49 | - $query = new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[2] ); |
|
49 | + $query = new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[2]); |
|
50 | 50 | break; |
51 | 51 | |
52 | 52 | case 'delete': |
53 | - $query = new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[1] ); |
|
53 | + $query = new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[1]); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case 'query': |
57 | - $query = new WordPoints_WPDB_Query_Data_SQL( $this->args[0] ); |
|
57 | + $query = new WordPoints_WPDB_Query_Data_SQL($this->args[0]); |
|
58 | 58 | break; |
59 | 59 | } |
60 | 60 | |
61 | - if ( $query ) { |
|
61 | + if ($query) { |
|
62 | 62 | /** @var WordPoints_WPDB_Query_WrapperI $wrapper */ |
63 | - $wrapper = $wrappers->get( $name, $query ); |
|
63 | + $wrapper = $wrappers->get($name, $query); |
|
64 | 64 | |
65 | 65 | $result = $wrapper->execute(); |
66 | 66 | } else { |
67 | - $result = call_user_func_array( array( $this->wpdb, $name ), $arguments ); |
|
67 | + $result = call_user_func_array(array($this->wpdb, $name), $arguments); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $result; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | class WordPoints_MySQL_Query_Parser_Simple_Insert implements WordPoints_MySQL_Query_Parser_SimpleI { |
86 | 86 | |
87 | - public function __construct( $sql ) { |
|
87 | + public function __construct($sql) { |
|
88 | 88 | $this->sql = $sql; |
89 | 89 | } |
90 | 90 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // columns will not be needed. then the other code can decide what to do. |
100 | 100 | // although I guess sense we have the tablel name we could reun the query |
101 | 101 | // ourselves if we need/want to. |
102 | - if ( stripos( $this->sql, 'ON DUPLICATE KEY UPDATE' ) ) { |
|
102 | + if (stripos($this->sql, 'ON DUPLICATE KEY UPDATE')) { |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected $parser; |
121 | 121 | |
122 | - public function __construct( $sql ) { |
|
122 | + public function __construct($sql) { |
|
123 | 123 | $this->sql = $sql; |
124 | 124 | $this->parser = $this->get_parser(); |
125 | 125 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // of query it is. |
131 | 131 | // maybe the parser will actually be passed in, and the query type deterimed |
132 | 132 | // by teh method wrapper. |
133 | - $parser = new WordPoints_MySQL_Query_Parser_Simple_Insert( $this->sql ); |
|
133 | + $parser = new WordPoints_MySQL_Query_Parser_Simple_Insert($this->sql); |
|
134 | 134 | // maybe we don't even need to parse. |
135 | 135 | return $parser; |
136 | 136 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | protected $table_name; |
150 | 150 | protected $where_data; |
151 | 151 | |
152 | - public function __construct( $table_name, $where_data = array() ) { |
|
152 | + public function __construct($table_name, $where_data = array()) { |
|
153 | 153 | $this->table_name = $table_name; |
154 | 154 | $this->where_data = $where_data; |
155 | 155 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | interface WordPoints_WPDB_Query_WrapperI { |
167 | - public function __construct( $slug, $args, $wpdb ); |
|
167 | + public function __construct($slug, $args, $wpdb); |
|
168 | 168 | public function execute(); |
169 | 169 | |
170 | 170 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | protected $result; |
186 | 186 | protected $backed_up_wpdb_vars; |
187 | 187 | |
188 | - public function __construct( $slug, $args, $wpdb ) { |
|
188 | + public function __construct($slug, $args, $wpdb) { |
|
189 | 189 | $this->slug = $slug; |
190 | 190 | $this->args = $args; |
191 | 191 | $this->wpdb = $wpdb; |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | |
195 | 195 | protected function get_query_data() { |
196 | 196 | |
197 | - switch ( $this->slug ) { |
|
197 | + switch ($this->slug) { |
|
198 | 198 | |
199 | 199 | case 'insert': |
200 | 200 | // case 'replace': |
201 | - return new WordPoints_WPDB_Query_Data_Array( $this->args[0] ); |
|
201 | + return new WordPoints_WPDB_Query_Data_Array($this->args[0]); |
|
202 | 202 | |
203 | 203 | case 'update': |
204 | - return new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[2] ); |
|
204 | + return new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[2]); |
|
205 | 205 | |
206 | 206 | case 'delete': |
207 | - return new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[1] ); |
|
207 | + return new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[1]); |
|
208 | 208 | |
209 | 209 | case 'query': |
210 | - return new WordPoints_WPDB_Query_Data_SQL( $this->args[0] ); |
|
210 | + return new WordPoints_WPDB_Query_Data_SQL($this->args[0]); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return false; |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | |
218 | 218 | $should_listen = $this->should_listen(); |
219 | 219 | |
220 | - if ( $should_listen ) { |
|
220 | + if ($should_listen) { |
|
221 | 221 | $this->before_query(); |
222 | 222 | } |
223 | 223 | |
224 | - $this->result = call_user_func_array( array( $this->wpdb, $this->slug ), $this->args ); |
|
224 | + $this->result = call_user_func_array(array($this->wpdb, $this->slug), $this->args); |
|
225 | 225 | |
226 | - if ( $should_listen && $this->was_successful_query() ) { |
|
226 | + if ($should_listen && $this->was_successful_query()) { |
|
227 | 227 | $this->backup_wpdb_vars(); |
228 | 228 | $this->after_query(); |
229 | 229 | $this->restore_wpdb_vars(); |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | |
253 | 253 | // we could check for the availableility of eahc valu here in case of dropins |
254 | 254 | // or they become not available in the future. |
255 | - foreach ( $to_backup as $property ) { |
|
256 | - $this->backed_up_wpdb_vars[ $property ] = $this->wpdb->$property; |
|
255 | + foreach ($to_backup as $property) { |
|
256 | + $this->backed_up_wpdb_vars[$property] = $this->wpdb->$property; |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | // with the backed up result. |
264 | 264 | $this->wpdb->flush(); |
265 | 265 | |
266 | - foreach ( $this->backed_up_wpdb_vars as $property => $value ) { |
|
266 | + foreach ($this->backed_up_wpdb_vars as $property => $value) { |
|
267 | 267 | $this->wpdb->$property = $value; |
268 | 268 | } |
269 | 269 | } |
@@ -301,18 +301,18 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function is_entity_table() { |
303 | 303 | |
304 | - $this->entity = 'new entity object' . $this->data->get_table_name(); |
|
304 | + $this->entity = 'new entity object'.$this->data->get_table_name(); |
|
305 | 305 | |
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | |
309 | 309 | public function should_listen() { |
310 | 310 | |
311 | - if ( ! $this->data ) { |
|
311 | + if ( ! $this->data) { |
|
312 | 312 | return false; |
313 | 313 | } |
314 | 314 | |
315 | - if ( $this->is_entity_table() ) { |
|
315 | + if ($this->is_entity_table()) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | protected function was_successful_query() { |
323 | - return (bool) wordpoints_posint( $not_by_ref = $this->wpdb->num_rows ); |
|
323 | + return (bool) wordpoints_posint($not_by_ref = $this->wpdb->num_rows); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | protected $args; |
331 | 331 | protected $wpdb; |
332 | 332 | |
333 | - public function __construct( $slug, $args, $wpdb ) { |
|
333 | + public function __construct($slug, $args, $wpdb) { |
|
334 | 334 | $this->slug = $slug; |
335 | 335 | $this->args = $args; |
336 | 336 | $this->wpdb = $wpdb; |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | // check if this is a query that we want to listen to. |
342 | 342 | // if so, call execute on a particular child. |
343 | 343 | // otherwise, just call execute. |
344 | - if ( $this->get_query_type() ) { |
|
344 | + if ($this->get_query_type()) { |
|
345 | 345 | |
346 | 346 | } else { |
347 | - $result = call_user_func_array( array( $this->wpdb, $this->slug ), $this->args ); |
|
347 | + $result = call_user_func_array(array($this->wpdb, $this->slug), $this->args); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return $result; |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | |
370 | 370 | $ids = $this->get_entity_ids(); |
371 | 371 | |
372 | - $this->entities = new WordPoints_Entity_Array( $this->entity->get_slug() ); |
|
373 | - $this->entities->set_the_value( $ids ); |
|
372 | + $this->entities = new WordPoints_Entity_Array($this->entity->get_slug()); |
|
373 | + $this->entities->set_the_value($ids); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | protected function get_entity_ids() { |
377 | 377 | $where = $this->data->get_where_clause(); |
378 | - $id_field = wordpoints_escape_mysql_identifier( $this->entity->get_id_field() ); |
|
379 | - $table_name = wordpoints_escape_mysql_identifier( $this->data->get_table_name() ); |
|
380 | - return $this->wpdb->get_col( "SELECT {$id_field} FROM {$table_name} {$where}" ); |
|
378 | + $id_field = wordpoints_escape_mysql_identifier($this->entity->get_id_field()); |
|
379 | + $table_name = wordpoints_escape_mysql_identifier($this->data->get_table_name()); |
|
380 | + return $this->wpdb->get_col("SELECT {$id_field} FROM {$table_name} {$where}"); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | protected function after_query() { |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | $where_clause = $this->data->get_where_clause(); |
397 | 397 | |
398 | 398 | // get a before snapshot, if any matching are found. |
399 | - if ( $where_clause ) { |
|
399 | + if ($where_clause) { |
|
400 | 400 | |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | protected function after_query() { |
405 | - $this->entity->set_the_value( $this->wpdb->insert_id ); |
|
405 | + $this->entity->set_the_value($this->wpdb->insert_id); |
|
406 | 406 | // I guess we invoke the api to run the action now? |
407 | 407 | $this->trigger_entity_create_actions(); |
408 | 408 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | protected function after_query() { |
415 | 415 | // I guess we invoke the api to run the action now? |
416 | - $this->trigger_entity_delete_actions( $this->entities ); |
|
416 | + $this->trigger_entity_delete_actions($this->entities); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 |
@@ -74,11 +74,23 @@ discard block |
||
74 | 74 | |
75 | 75 | interface WordPoints_WPDB_Query_Data { |
76 | 76 | public function get_table_name(); |
77 | + |
|
78 | + /** |
|
79 | + * @return void |
|
80 | + */ |
|
77 | 81 | public function get_where_clause(); |
78 | 82 | } |
79 | 83 | |
80 | 84 | interface WordPoints_MySQL_Query_Parser_SimpleI { |
85 | + |
|
86 | + /** |
|
87 | + * @return void |
|
88 | + */ |
|
81 | 89 | public function get_table_name(); |
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
82 | 94 | public function get_where_clause(); |
83 | 95 | } |
84 | 96 | |
@@ -164,6 +176,10 @@ discard block |
||
164 | 176 | } |
165 | 177 | |
166 | 178 | interface WordPoints_WPDB_Query_WrapperI { |
179 | + |
|
180 | + /** |
|
181 | + * @return void |
|
182 | + */ |
|
167 | 183 | public function __construct( $slug, $args, $wpdb ); |
168 | 184 | public function execute(); |
169 | 185 |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | interface WordPoints_Hook_Reaction_SettingI { |
11 | - public function __construct( $slug ); |
|
11 | + public function __construct($slug); |
|
12 | 12 | public function get_type(); |
13 | 13 | public function get_label(); |
14 | 14 | public function is_required(); |
15 | - public function get( WordPoints_Hook_ReactionI $reaction ); |
|
16 | - public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ); |
|
17 | - public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ); |
|
15 | + public function get(WordPoints_Hook_ReactionI $reaction); |
|
16 | + public function validate($value, WordPoints_Hook_Reaction_Validator $validator); |
|
17 | + public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class WordPoints_Hook_Reaction_Setting implements WordPoints_Hook_Reaction_SettingI { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | protected $type = 'hidden'; |
24 | 24 | protected $required = true; |
25 | 25 | |
26 | - public function __construct( $slug ) { |
|
26 | + public function __construct($slug) { |
|
27 | 27 | $this->slug = $slug; |
28 | 28 | } |
29 | 29 | |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | return $this->required; |
40 | 40 | } |
41 | 41 | |
42 | - public function get( WordPoints_Hook_ReactionI $reaction ) { |
|
43 | - return $reaction->get_meta( $this->slug ); |
|
42 | + public function get(WordPoints_Hook_ReactionI $reaction) { |
|
43 | + return $reaction->get_meta($this->slug); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ) { |
|
46 | + public function validate($value, WordPoints_Hook_Reaction_Validator $validator) { |
|
47 | 47 | |
48 | - if ( $this->is_required() && '' === trim( $value ) ) { |
|
48 | + if ($this->is_required() && '' === trim($value)) { |
|
49 | 49 | |
50 | 50 | $validator->add_error( |
51 | 51 | sprintf( |
52 | - __( '%s cannot be empty.', 'wordpoints' ) |
|
52 | + __('%s cannot be empty.', 'wordpoints') |
|
53 | 53 | , $this->get_label() |
54 | 54 | ) |
55 | 55 | , $this->slug |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | return $value; |
60 | 60 | } |
61 | 61 | |
62 | - public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ) { |
|
63 | - $reaction->update_meta( $this->slug, $value ); |
|
62 | + public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new) { |
|
63 | + $reaction->update_meta($this->slug, $value); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | // |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | |
83 | 83 | $fields = array(); |
84 | 84 | |
85 | - foreach ( $this->settings as $slug => $class ) { |
|
85 | + foreach ($this->settings as $slug => $class) { |
|
86 | 86 | |
87 | 87 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
88 | - $setting = new $class( $slug ); |
|
88 | + $setting = new $class($slug); |
|
89 | 89 | |
90 | - $fields[ $slug ] = array( |
|
90 | + $fields[$slug] = array( |
|
91 | 91 | 'type' => $setting->get_type(), |
92 | 92 | 'label' => $setting->get_label(), |
93 | 93 | 'required' => $setting->is_required(), |
@@ -97,29 +97,29 @@ discard block |
||
97 | 97 | return $fields; |
98 | 98 | } |
99 | 99 | |
100 | - public function save_settings( $reaction, $settings, $is_new ) { |
|
100 | + public function save_settings($reaction, $settings, $is_new) { |
|
101 | 101 | |
102 | - foreach ( $this->settings as $slug => $class ) { |
|
102 | + foreach ($this->settings as $slug => $class) { |
|
103 | 103 | |
104 | 104 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
105 | - $setting = new $class( $slug ); |
|
105 | + $setting = new $class($slug); |
|
106 | 106 | |
107 | - $value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null; |
|
107 | + $value = isset($settings[$slug]) ? $settings[$slug] : null; |
|
108 | 108 | |
109 | - $setting->save( $value, $reaction, $is_new ); |
|
109 | + $setting->save($value, $reaction, $is_new); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - public function validate_settings( $settings, $validator ) { |
|
113 | + public function validate_settings($settings, $validator) { |
|
114 | 114 | |
115 | - foreach ( $this->settings as $slug => $class ) { |
|
115 | + foreach ($this->settings as $slug => $class) { |
|
116 | 116 | |
117 | 117 | /** @var WordPoints_Hook_Reaction_SettingI $setting */ |
118 | - $setting = new $class( $slug ); |
|
118 | + $setting = new $class($slug); |
|
119 | 119 | |
120 | - $value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null; |
|
120 | + $value = isset($settings[$slug]) ? $settings[$slug] : null; |
|
121 | 121 | |
122 | - $settings[ $slug ] = $setting->validate( $value, $validator ); |
|
122 | + $settings[$slug] = $setting->validate($value, $validator); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $settings; |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param WordPoints_Hooks $hooks |
135 | 135 | */ |
136 | -function wordpoints_hook_settings_app( $hooks ) { |
|
137 | - $hooks->sub_apps()->register( 'settings', 'WordPoints_Hook_Settings' ); |
|
136 | +function wordpoints_hook_settings_app($hooks) { |
|
137 | + $hooks->sub_apps()->register('settings', 'WordPoints_Hook_Settings'); |
|
138 | 138 | } |
139 | 139 | //add_action( 'wordpoints_hooks_init', 'wordpoints_hook_settings_app' ); |
140 | 140 | |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param WordPoints_Hook_Settings $settings |
147 | 147 | */ |
148 | -function wordpoints_register_hook_settings( $settings ) { |
|
148 | +function wordpoints_register_hook_settings($settings) { |
|
149 | 149 | |
150 | - add_action( 'wordpoints_hook_reaction_save', array( $settings, 'save_settings' ), 10, 3 ); |
|
151 | - add_filter( 'wordpoints_hook_reaction_validate', array( $settings, 'validate_settings' ), 10, 2 ); |
|
150 | + add_action('wordpoints_hook_reaction_save', array($settings, 'save_settings'), 10, 3); |
|
151 | + add_filter('wordpoints_hook_reaction_validate', array($settings, 'validate_settings'), 10, 2); |
|
152 | 152 | |
153 | - $settings->register( 'description', 'WordPoints_Hook_Reaction_Setting_Description' ); |
|
153 | + $settings->register('description', 'WordPoints_Hook_Reaction_Setting_Description'); |
|
154 | 154 | } |
155 | 155 | //add_action( 'wordpoints_hook_settings_init', 'wordpoints_register_hook_settings' ); |
156 | 156 |
@@ -44,18 +44,18 @@ |
||
44 | 44 | * |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | -require_once( dirname( __FILE__ ) . '/includes/functions.php' ); |
|
47 | +require_once(dirname(__FILE__).'/includes/functions.php'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * The module's actions and filters. |
51 | 51 | * |
52 | 52 | * @since 1.0.0 |
53 | 53 | */ |
54 | -require_once( dirname( __FILE__ ) . '/includes/actions.php' ); |
|
54 | +require_once(dirname(__FILE__).'/includes/actions.php'); |
|
55 | 55 | |
56 | 56 | // Register the classes to autoload. |
57 | 57 | WordPoints_Class_Autoloader::register_dir( |
58 | - dirname( __FILE__ ) . '/includes/classes' |
|
58 | + dirname(__FILE__).'/includes/classes' |
|
59 | 59 | , 'WordPoints_' |
60 | 60 | ); |
61 | 61 |
@@ -10,29 +10,29 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // auto-generated { |
13 | -$dir = dirname( __FILE__ ); |
|
14 | -require_once( $dir . '/specedi.php' ); |
|
15 | -require_once( $dir . '/hook/retroactive/queryi.php' ); |
|
16 | -require_once( $dir . '/hook/retroactive/query/modifieri.php' ); |
|
17 | -require_once( $dir . '/spec.php' ); |
|
18 | -require_once( $dir . '/entity/change.php' ); |
|
19 | -require_once( $dir . '/entity/post/terms.php' ); |
|
20 | -require_once( $dir . '/entity/post/type.php' ); |
|
21 | -require_once( $dir . '/entity/post/type/name.php' ); |
|
22 | -require_once( $dir . '/entity/post/type/relationship.php' ); |
|
23 | -require_once( $dir . '/entity/site.php' ); |
|
24 | -require_once( $dir . '/entity/term.php' ); |
|
25 | -require_once( $dir . '/entity/term/id.php' ); |
|
26 | -require_once( $dir . '/entity/user/role/name.php' ); |
|
27 | -require_once( $dir . '/hierarchy.php' ); |
|
28 | -require_once( $dir . '/hook/arg/current/post.php' ); |
|
29 | -require_once( $dir . '/hook/arg/current/site.php' ); |
|
30 | -require_once( $dir . '/hook/retroactive/conditions.php' ); |
|
31 | -require_once( $dir . '/hook/retroactive/query.php' ); |
|
32 | -require_once( $dir . '/hook/retroactive/queryable.php' ); |
|
33 | -require_once( $dir . '/hook/settings.php' ); |
|
34 | -require_once( $dir . '/query/builder/db/mysql.php' ); |
|
35 | -require_once( $dir . '/wpdb/wrapper.php' ); |
|
13 | +$dir = dirname(__FILE__); |
|
14 | +require_once($dir.'/specedi.php'); |
|
15 | +require_once($dir.'/hook/retroactive/queryi.php'); |
|
16 | +require_once($dir.'/hook/retroactive/query/modifieri.php'); |
|
17 | +require_once($dir.'/spec.php'); |
|
18 | +require_once($dir.'/entity/change.php'); |
|
19 | +require_once($dir.'/entity/post/terms.php'); |
|
20 | +require_once($dir.'/entity/post/type.php'); |
|
21 | +require_once($dir.'/entity/post/type/name.php'); |
|
22 | +require_once($dir.'/entity/post/type/relationship.php'); |
|
23 | +require_once($dir.'/entity/site.php'); |
|
24 | +require_once($dir.'/entity/term.php'); |
|
25 | +require_once($dir.'/entity/term/id.php'); |
|
26 | +require_once($dir.'/entity/user/role/name.php'); |
|
27 | +require_once($dir.'/hierarchy.php'); |
|
28 | +require_once($dir.'/hook/arg/current/post.php'); |
|
29 | +require_once($dir.'/hook/arg/current/site.php'); |
|
30 | +require_once($dir.'/hook/retroactive/conditions.php'); |
|
31 | +require_once($dir.'/hook/retroactive/query.php'); |
|
32 | +require_once($dir.'/hook/retroactive/queryable.php'); |
|
33 | +require_once($dir.'/hook/settings.php'); |
|
34 | +require_once($dir.'/query/builder/db/mysql.php'); |
|
35 | +require_once($dir.'/wpdb/wrapper.php'); |
|
36 | 36 | // } |
37 | 37 | |
38 | 38 | // EOF |
@@ -33,14 +33,14 @@ |
||
33 | 33 | * @since 1.0.0 |
34 | 34 | */ |
35 | 35 | public function get_title() { |
36 | - return __( 'Content Type', 'wordpoints' ); |
|
36 | + return __('Content Type', 'wordpoints'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @since 1.0.0 |
41 | 41 | */ |
42 | 42 | public function get_storage_array() { |
43 | - return get_post_types( array( 'public' => true ), 'labels' ); |
|
43 | + return get_post_types(array('public' => true), 'labels'); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 |