@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return object[] The child objects, indexed by slug. |
48 | 48 | */ |
49 | - public function get_children( $parent_slug ); |
|
49 | + public function get_children($parent_slug); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Get the slugs of all of the classes that are children of a certain parent. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string[] The child slugs. |
59 | 59 | */ |
60 | - public function get_children_slugs( $parent_slug ); |
|
60 | + public function get_children_slugs($parent_slug); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get an object by its slug. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return object|false The object or false on failure. |
71 | 71 | */ |
72 | - public function get( $parent_slug, $slug ); |
|
72 | + public function get($parent_slug, $slug); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Register a type of object. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool Whether the class was registered successfully. |
85 | 85 | */ |
86 | - public function register( $parent_slug, $slug, $class, array $args = array() ); |
|
86 | + public function register($parent_slug, $slug, $class, array $args = array()); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Deregister a type of object. |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $parent_slug The group slug. |
94 | 94 | * @param string $slug The slug of the class to deregister. |
95 | 95 | */ |
96 | - public function deregister( $parent_slug, $slug ); |
|
96 | + public function deregister($parent_slug, $slug); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Deregister all children of a particular parent. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param string $parent_slug The group slug. |
104 | 104 | */ |
105 | - public function deregister_children( $parent_slug ); |
|
105 | + public function deregister_children($parent_slug); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Check if a type of object is registered by its slug. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether the class is registered. |
119 | 119 | */ |
120 | - public function is_registered( $parent_slug, $slug = null ); |
|
120 | + public function is_registered($parent_slug, $slug = null); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // EOF |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @since 1.0.0 |
35 | 35 | */ |
36 | - public function get_all( array $args = array() ) { |
|
36 | + public function get_all(array $args = array()) { |
|
37 | 37 | |
38 | 38 | $items = array(); |
39 | 39 | |
40 | - foreach ( $this->classes as $parent_slug => $classes ) { |
|
41 | - $items[ $parent_slug ] = WordPoints_Class_Registry::construct_with_args( |
|
40 | + foreach ($this->classes as $parent_slug => $classes) { |
|
41 | + $items[$parent_slug] = WordPoints_Class_Registry::construct_with_args( |
|
42 | 42 | $classes |
43 | 43 | , $args |
44 | 44 | ); |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | * @since 1.0.0 |
52 | 52 | */ |
53 | 53 | public function get_all_slugs() { |
54 | - return array_map( 'array_keys', $this->classes ); |
|
54 | + return array_map('array_keys', $this->classes); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @since 1.0.0 |
59 | 59 | */ |
60 | - public function get_children( $parent_slug, array $args = array() ) { |
|
60 | + public function get_children($parent_slug, array $args = array()) { |
|
61 | 61 | |
62 | 62 | $items = array(); |
63 | 63 | |
64 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
64 | + if (isset($this->classes[$parent_slug])) { |
|
65 | 65 | |
66 | 66 | $items = WordPoints_Class_Registry::construct_with_args( |
67 | - $this->classes[ $parent_slug ] |
|
67 | + $this->classes[$parent_slug] |
|
68 | 68 | , $args |
69 | 69 | ); |
70 | 70 | } |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @since 1.0.0 |
77 | 77 | */ |
78 | - public function get_children_slugs( $parent_slug ) { |
|
78 | + public function get_children_slugs($parent_slug) { |
|
79 | 79 | |
80 | 80 | $slugs = array(); |
81 | 81 | |
82 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
83 | - $slugs = array_keys( $this->classes[ $parent_slug ] ); |
|
82 | + if (isset($this->classes[$parent_slug])) { |
|
83 | + $slugs = array_keys($this->classes[$parent_slug]); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $slugs; |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @since 1.0.0 |
91 | 91 | */ |
92 | - public function get( $parent_slug, $slug, array $args = array() ) { |
|
92 | + public function get($parent_slug, $slug, array $args = array()) { |
|
93 | 93 | |
94 | - if ( ! isset( $this->classes[ $parent_slug ][ $slug ] ) ) { |
|
94 | + if ( ! isset($this->classes[$parent_slug][$slug])) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - $class = $this->classes[ $parent_slug ][ $slug ]; |
|
98 | + $class = $this->classes[$parent_slug][$slug]; |
|
99 | 99 | |
100 | - if ( empty( $args ) ) { |
|
101 | - return new $class( $slug ); |
|
100 | + if (empty($args)) { |
|
101 | + return new $class($slug); |
|
102 | 102 | } else { |
103 | - array_unshift( $args, $slug ); |
|
103 | + array_unshift($args, $slug); |
|
104 | 104 | |
105 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
105 | + return wordpoints_construct_class_with_args($class, $args); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @since 1.0.0 |
111 | 111 | */ |
112 | - public function register( $parent_slug, $slug, $class, array $args = array() ) { |
|
112 | + public function register($parent_slug, $slug, $class, array $args = array()) { |
|
113 | 113 | |
114 | - $this->classes[ $parent_slug ][ $slug ] = $class; |
|
114 | + $this->classes[$parent_slug][$slug] = $class; |
|
115 | 115 | |
116 | 116 | return true; |
117 | 117 | } |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @since 1.0.0 |
121 | 121 | */ |
122 | - public function deregister( $parent_slug, $slug ) { |
|
123 | - unset( $this->classes[ $parent_slug ][ $slug ] ); |
|
122 | + public function deregister($parent_slug, $slug) { |
|
123 | + unset($this->classes[$parent_slug][$slug]); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @since 1.0.0 |
128 | 128 | */ |
129 | - public function deregister_children( $parent_slug ) { |
|
130 | - unset( $this->classes[ $parent_slug ] ); |
|
129 | + public function deregister_children($parent_slug) { |
|
130 | + unset($this->classes[$parent_slug]); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @since 1.0.0 |
135 | 135 | */ |
136 | - public function is_registered( $parent_slug, $slug = null ) { |
|
136 | + public function is_registered($parent_slug, $slug = null) { |
|
137 | 137 | |
138 | - if ( isset( $slug ) ) { |
|
139 | - return isset( $this->classes[ $parent_slug ][ $slug ] ); |
|
138 | + if (isset($slug)) { |
|
139 | + return isset($this->classes[$parent_slug][$slug]); |
|
140 | 140 | } else { |
141 | - return isset( $this->classes[ $parent_slug ] ); |
|
141 | + return isset($this->classes[$parent_slug]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -30,46 +30,46 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @since 1.0.0 |
32 | 32 | */ |
33 | - public function get_all( array $args = array() ) { |
|
34 | - return self::construct_with_args( $this->classes, $args ); |
|
33 | + public function get_all(array $args = array()) { |
|
34 | + return self::construct_with_args($this->classes, $args); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @since 1.0.0 |
39 | 39 | */ |
40 | 40 | public function get_all_slugs() { |
41 | - return array_keys( $this->classes ); |
|
41 | + return array_keys($this->classes); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | - public function get( $slug, array $args = array() ) { |
|
47 | + public function get($slug, array $args = array()) { |
|
48 | 48 | |
49 | - if ( ! isset( $this->classes[ $slug ] ) ) { |
|
49 | + if ( ! isset($this->classes[$slug])) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - if ( ! empty( $args ) ) { |
|
53 | + if ( ! empty($args)) { |
|
54 | 54 | |
55 | - array_unshift( $args, $slug ); |
|
55 | + array_unshift($args, $slug); |
|
56 | 56 | |
57 | 57 | return wordpoints_construct_class_with_args( |
58 | - $this->classes[ $slug ] |
|
58 | + $this->classes[$slug] |
|
59 | 59 | , $args |
60 | 60 | ); |
61 | 61 | |
62 | 62 | } else { |
63 | - return new $this->classes[ $slug ]( $slug ); |
|
63 | + return new $this->classes[$slug]($slug); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @since 1.0.0 |
69 | 69 | */ |
70 | - public function register( $slug, $class, array $args = array() ) { |
|
70 | + public function register($slug, $class, array $args = array()) { |
|
71 | 71 | |
72 | - $this->classes[ $slug ] = $class; |
|
72 | + $this->classes[$slug] = $class; |
|
73 | 73 | |
74 | 74 | return true; |
75 | 75 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @since 1.0.0 |
79 | 79 | */ |
80 | - public function deregister( $slug ) { |
|
80 | + public function deregister($slug) { |
|
81 | 81 | |
82 | - unset( $this->classes[ $slug ] ); |
|
82 | + unset($this->classes[$slug]); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @since 1.0.0 |
87 | 87 | */ |
88 | - public function is_registered( $slug ) { |
|
88 | + public function is_registered($slug) { |
|
89 | 89 | |
90 | - return isset( $this->classes[ $slug ] ); |
|
90 | + return isset($this->classes[$slug]); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return object[] An array of the constructed objects. |
103 | 103 | */ |
104 | - public static function construct_with_args( array $classes, array $args ) { |
|
104 | + public static function construct_with_args(array $classes, array $args) { |
|
105 | 105 | |
106 | 106 | $objects = array(); |
107 | 107 | |
108 | - if ( empty( $args ) ) { |
|
108 | + if (empty($args)) { |
|
109 | 109 | |
110 | - foreach ( $classes as $slug => $class ) { |
|
111 | - $objects[ $slug ] = new $class( $slug ); |
|
110 | + foreach ($classes as $slug => $class) { |
|
111 | + $objects[$slug] = new $class($slug); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | } else { |
115 | 115 | |
116 | - array_unshift( $args, null ); |
|
116 | + array_unshift($args, null); |
|
117 | 117 | |
118 | - foreach ( $classes as $slug => $class ) { |
|
119 | - $objects[ $slug ] = wordpoints_construct_class_with_args( |
|
118 | + foreach ($classes as $slug => $class) { |
|
119 | + $objects[$slug] = wordpoints_construct_class_with_args( |
|
120 | 120 | $class |
121 | - , array( $slug ) + $args |
|
121 | + , array($slug) + $args |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | } |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param string $slug The arg slug. |
71 | 71 | * @param WordPoints_Hook_ActionI $action The calling action's object. |
72 | 72 | */ |
73 | - public function __construct( $slug, WordPoints_Hook_ActionI $action = null ) { |
|
73 | + public function __construct($slug, WordPoints_Hook_ActionI $action = null) { |
|
74 | 74 | |
75 | 75 | $this->slug = $slug; |
76 | 76 | $this->action = $action; |
77 | 77 | |
78 | - $parts = explode( ':', $slug, 2 ); |
|
78 | + $parts = explode(':', $slug, 2); |
|
79 | 79 | |
80 | - if ( isset( $parts[1] ) ) { |
|
80 | + if (isset($parts[1])) { |
|
81 | 81 | $this->entity_slug = $parts[1]; |
82 | 82 | } else { |
83 | 83 | $this->entity_slug = $slug; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | $this->get_entity_slug() |
120 | 120 | ); |
121 | 121 | |
122 | - if ( $entity instanceof WordPoints_Entity ) { |
|
122 | + if ($entity instanceof WordPoints_Entity) { |
|
123 | 123 | $value = $this->get_value(); |
124 | 124 | |
125 | - if ( $value ) { |
|
126 | - $entity->set_the_value( $value ); |
|
125 | + if ($value) { |
|
126 | + $entity->set_the_value($value); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_value() { |
141 | 141 | |
142 | - if ( $this->action instanceof WordPoints_Hook_ActionI ) { |
|
143 | - return $this->action->get_arg_value( $this->slug ); |
|
142 | + if ($this->action instanceof WordPoints_Hook_ActionI) { |
|
143 | + return $this->action->get_arg_value($this->slug); |
|
144 | 144 | } else { |
145 | 145 | return null; |
146 | 146 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $entity = $this->get_entity(); |
159 | 159 | |
160 | - if ( ! $entity ) { |
|
160 | + if ( ! $entity) { |
|
161 | 161 | return $this->slug; |
162 | 162 | } |
163 | 163 |
@@ -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 |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @since 1.0.0 |
55 | 55 | */ |
56 | - public function __get( $var ) { |
|
56 | + public function __get($var) { |
|
57 | 57 | |
58 | - if ( 'reactions' !== $var ) { |
|
58 | + if ('reactions' !== $var) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | wordpoints_hooks()->get_current_mode() |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! $reaction_group ) { |
|
66 | + if ( ! $reaction_group) { |
|
67 | 67 | return null; |
68 | 68 | } |
69 | 69 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return WordPoints_Hook_Reaction_StorageI|false The reaction storage object. |
81 | 81 | */ |
82 | - public function get_reaction_group( $slug ) { |
|
82 | + public function get_reaction_group($slug) { |
|
83 | 83 | |
84 | 84 | $reaction_group = wordpoints_hooks()->reaction_groups->get( |
85 | 85 | $this->slug |
86 | 86 | , $slug |
87 | - , array( $this ) |
|
87 | + , array($this) |
|
88 | 88 | ); |
89 | 89 | |
90 | - if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI ) { |
|
90 | + if ( ! $reaction_group instanceof WordPoints_Hook_Reaction_StorageI) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Allowing access to groups out-of-context would lead to strange behavior. |
95 | - if ( false === $reaction_group->get_context_id() ) { |
|
95 | + if (false === $reaction_group->get_context_id()) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | public function get_context() { |
149 | 149 | |
150 | 150 | return is_wordpoints_network_active() |
151 | - ? array( 'network' ) |
|
152 | - : array( 'network', 'site' ); |
|
151 | + ? array('network') |
|
152 | + : array('network', 'site'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return WordPoints_Hook_ReactionI[] All of the reaction objects. |
170 | 170 | */ |
171 | - public function get_all_reactions_to_event( $event_slug ) { |
|
171 | + public function get_all_reactions_to_event($event_slug) { |
|
172 | 172 | |
173 | 173 | $reactions = array(); |
174 | 174 | |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | $this->slug |
177 | 177 | ); |
178 | 178 | |
179 | - foreach ( $slugs as $slug ) { |
|
179 | + foreach ($slugs as $slug) { |
|
180 | 180 | |
181 | - $storage = $this->get_reaction_group( $slug ); |
|
181 | + $storage = $this->get_reaction_group($slug); |
|
182 | 182 | |
183 | - if ( ! $storage ) { |
|
183 | + if ( ! $storage) { |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | |
187 | 187 | $reactions = array_merge( |
188 | 188 | $reactions |
189 | - , $storage->get_reactions_to_event( $event_slug ) |
|
189 | + , $storage->get_reactions_to_event($event_slug) |
|
190 | 190 | ); |
191 | 191 | } |
192 | 192 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | $this->slug |
216 | 216 | ); |
217 | 217 | |
218 | - foreach ( $slugs as $slug ) { |
|
218 | + foreach ($slugs as $slug) { |
|
219 | 219 | |
220 | - $storage = $this->get_reaction_group( $slug ); |
|
220 | + $storage = $this->get_reaction_group($slug); |
|
221 | 221 | |
222 | - if ( ! $storage ) { |
|
222 | + if ( ! $storage) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | |
226 | - $reactions = array_merge( $reactions, $storage->get_reactions() ); |
|
226 | + $reactions = array_merge($reactions, $storage->get_reactions()); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $reactions; |
@@ -239,21 +239,21 @@ discard block |
||
239 | 239 | ) { |
240 | 240 | |
241 | 241 | if ( |
242 | - empty( $settings['target'] ) |
|
243 | - || ! is_array( $settings['target'] ) |
|
242 | + empty($settings['target']) |
|
243 | + || ! is_array($settings['target']) |
|
244 | 244 | ) { |
245 | 245 | |
246 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
246 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
250 | - $target = $event_args->get_from_hierarchy( $settings['target'] ); |
|
250 | + $target = $event_args->get_from_hierarchy($settings['target']); |
|
251 | 251 | |
252 | 252 | if ( |
253 | 253 | ! $target instanceof WordPoints_Entity |
254 | - || ! in_array( $target->get_slug(), (array) $this->arg_types ) |
|
254 | + || ! in_array($target->get_slug(), (array) $this->arg_types) |
|
255 | 255 | ) { |
256 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
256 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | /** |
264 | 264 | * @since 1.0.0 |
265 | 265 | */ |
266 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
267 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
266 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
267 | + $reaction->update_meta('target', $settings['target']); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | protected function init() { |
48 | 48 | |
49 | 49 | $sub_apps = $this->sub_apps; |
50 | - $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
|
51 | - $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
|
52 | - $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
|
53 | - $sub_apps->register( 'firers', 'WordPoints_Class_Registry_Persistent' ); |
|
54 | - $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
|
55 | - $sub_apps->register( 'reaction_groups', 'WordPoints_Class_Registry_Children' ); |
|
56 | - $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
|
57 | - $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
|
50 | + $sub_apps->register('router', 'WordPoints_Hook_Router'); |
|
51 | + $sub_apps->register('actions', 'WordPoints_Hook_Actions'); |
|
52 | + $sub_apps->register('events', 'WordPoints_Hook_Events'); |
|
53 | + $sub_apps->register('firers', 'WordPoints_Class_Registry_Persistent'); |
|
54 | + $sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent'); |
|
55 | + $sub_apps->register('reaction_groups', 'WordPoints_Class_Registry_Children'); |
|
56 | + $sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent'); |
|
57 | + $sub_apps->register('conditions', 'WordPoints_Class_Registry_Children'); |
|
58 | 58 | |
59 | 59 | parent::init(); |
60 | 60 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function get_current_mode() { |
79 | 79 | |
80 | - if ( ! isset( $this->current_mode ) ) { |
|
81 | - $this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' ); |
|
80 | + if ( ! isset($this->current_mode)) { |
|
81 | + $this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $this->current_mode; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param string $mode The slug of the mode to set as the current mode. |
98 | 98 | */ |
99 | - public function set_current_mode( $mode ) { |
|
99 | + public function set_current_mode($mode) { |
|
100 | 100 | $this->current_mode = $mode; |
101 | 101 | } |
102 | 102 | } |
@@ -7,24 +7,24 @@ |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_init_app-apps', 'wordpoints_apps_init' ); |
|
11 | -add_action( 'wordpoints_init_app-entities', 'wordpoints_entities_app_init' ); |
|
10 | +add_action('wordpoints_init_app-apps', 'wordpoints_apps_init'); |
|
11 | +add_action('wordpoints_init_app-entities', 'wordpoints_entities_app_init'); |
|
12 | 12 | |
13 | -add_action( 'wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init' ); |
|
14 | -add_action( 'wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init' ); |
|
13 | +add_action('wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init'); |
|
14 | +add_action('wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init'); |
|
15 | 15 | |
16 | -add_action( 'wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init' ); |
|
16 | +add_action('wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init'); |
|
17 | 17 | |
18 | -add_action( 'wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init' ); |
|
19 | -add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' ); |
|
20 | -add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' ); |
|
21 | -add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' ); |
|
22 | -add_action( 'wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init' ); |
|
23 | -add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' ); |
|
24 | -add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' ); |
|
18 | +add_action('wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init'); |
|
19 | +add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init'); |
|
20 | +add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init'); |
|
21 | +add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init'); |
|
22 | +add_action('wordpoints_init_app_registry-hooks-reaction_groups', 'wordpoints_hook_reaction_groups_init'); |
|
23 | +add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init'); |
|
24 | +add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init'); |
|
25 | 25 | |
26 | -add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' ); |
|
26 | +add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks'); |
|
27 | 27 | |
28 | -add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' ); |
|
28 | +add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log'); |
|
29 | 29 | |
30 | 30 | // EOF |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
35 | 35 | */ |
36 | -function wordpoints_hook_reactors_init( $reactors ) { |
|
36 | +function wordpoints_hook_reactors_init($reactors) { |
|
37 | 37 | |
38 | - $reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param WordPoints_Class_Registry_Children $reaction_groups The group registry. |
49 | 49 | */ |
50 | -function wordpoints_hook_reaction_groups_init( $reaction_groups ) { |
|
50 | +function wordpoints_hook_reaction_groups_init($reaction_groups) { |
|
51 | 51 | |
52 | 52 | $reaction_groups->register( |
53 | 53 | 'points' |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | , 'WordPoints_Hook_Reaction_Storage_Options' |
56 | 56 | ); |
57 | 57 | |
58 | - if ( is_wordpoints_network_active() ) { |
|
58 | + if (is_wordpoints_network_active()) { |
|
59 | 59 | $reaction_groups->register( |
60 | 60 | 'points' |
61 | 61 | , 'network' |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
75 | 75 | */ |
76 | -function wordpoints_hook_extension_init( $extensions ) { |
|
76 | +function wordpoints_hook_extension_init($extensions) { |
|
77 | 77 | |
78 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
79 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
78 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
79 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
90 | 90 | */ |
91 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
91 | +function wordpoints_hook_conditions_init($conditions) { |
|
92 | 92 | |
93 | 93 | $conditions->register( |
94 | 94 | 'text' |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param WordPoints_Hook_Actions $actions The action registry. |
126 | 126 | */ |
127 | -function wordpoints_hook_actions_init( $actions ) { |
|
127 | +function wordpoints_hook_actions_init($actions) { |
|
128 | 128 | |
129 | 129 | $actions->register( |
130 | 130 | 'comment_approve' |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | , array( |
133 | 133 | 'action' => 'transition_comment_status', |
134 | 134 | 'data' => array( |
135 | - 'arg_index' => array( 'comment' => 2 ), |
|
136 | - 'requirements' => array( 0 => 'approved' ), |
|
135 | + 'arg_index' => array('comment' => 2), |
|
136 | + 'requirements' => array(0 => 'approved'), |
|
137 | 137 | ), |
138 | 138 | ) |
139 | 139 | ); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | , array( |
145 | 145 | 'action' => 'wp_insert_comment', |
146 | 146 | 'data' => array( |
147 | - 'arg_index' => array( 'comment' => 1 ), |
|
147 | + 'arg_index' => array('comment' => 1), |
|
148 | 148 | ), |
149 | 149 | ) |
150 | 150 | ); |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | , array( |
156 | 156 | 'action' => 'transition_comment_status', |
157 | 157 | 'data' => array( |
158 | - 'arg_index' => array( 'comment' => 2 ), |
|
159 | - 'requirements' => array( 1 => 'approved' ), |
|
158 | + 'arg_index' => array('comment' => 2), |
|
159 | + 'requirements' => array(1 => 'approved'), |
|
160 | 160 | ), |
161 | 161 | ) |
162 | 162 | ); |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | , array( |
169 | 169 | 'action' => 'transition_post_status', |
170 | 170 | 'data' => array( |
171 | - 'arg_index' => array( 'post' => 2 ), |
|
172 | - 'requirements' => array( 0 => 'publish' ), |
|
171 | + 'arg_index' => array('post' => 2), |
|
172 | + 'requirements' => array(0 => 'publish'), |
|
173 | 173 | ), |
174 | 174 | ) |
175 | 175 | ); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | , array( |
181 | 181 | 'action' => 'add_attachment', |
182 | 182 | 'data' => array( |
183 | - 'arg_index' => array( 'post\attachment' => 0 ), |
|
183 | + 'arg_index' => array('post\attachment' => 0), |
|
184 | 184 | ), |
185 | 185 | ) |
186 | 186 | ); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | , array( |
192 | 192 | 'action' => 'post_delete', |
193 | 193 | 'data' => array( |
194 | - 'arg_index' => array( 'post' => 0 ), |
|
194 | + 'arg_index' => array('post' => 0), |
|
195 | 195 | ), |
196 | 196 | ) |
197 | 197 | ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | , array( |
203 | 203 | 'action' => 'user_register', |
204 | 204 | 'data' => array( |
205 | - 'arg_index' => array( 'user' => 0 ), |
|
205 | + 'arg_index' => array('user' => 0), |
|
206 | 206 | ), |
207 | 207 | ) |
208 | 208 | ); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | , array( |
214 | 214 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
215 | 215 | 'data' => array( |
216 | - 'arg_index' => array( 'user' => 0 ), |
|
216 | + 'arg_index' => array('user' => 0), |
|
217 | 217 | ), |
218 | 218 | ) |
219 | 219 | ); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param WordPoints_Hook_Events $events The event registry. |
238 | 238 | */ |
239 | -function wordpoints_hook_events_init( $events ) { |
|
239 | +function wordpoints_hook_events_init($events) { |
|
240 | 240 | |
241 | 241 | $events->register( |
242 | 242 | 'user_register' |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Register events for all of the public post types. |
269 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
269 | + $post_types = get_post_types(array('public' => true)); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Filter which post types to register hook events for. |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param string[] The post type slugs ("names"). |
277 | 277 | */ |
278 | - $post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types ); |
|
278 | + $post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types); |
|
279 | 279 | |
280 | - foreach ( $post_types as $slug ) { |
|
281 | - wordpoints_register_post_type_hook_events( $slug ); |
|
280 | + foreach ($post_types as $slug) { |
|
281 | + wordpoints_register_post_type_hook_events($slug); |
|
282 | 282 | } |
283 | 283 | |
284 | - if ( is_multisite() ) { |
|
284 | + if (is_multisite()) { |
|
285 | 285 | |
286 | 286 | $event_slugs = array( |
287 | 287 | 'user_visit', |
288 | 288 | 'user_register', |
289 | 289 | ); |
290 | 290 | |
291 | - foreach ( $event_slugs as $event_slug ) { |
|
291 | + foreach ($event_slugs as $event_slug) { |
|
292 | 292 | // TODO network hooks |
293 | 293 | $events->args->register( |
294 | 294 | $event_slug |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param WordPoints_Class_Registry_Persistent $firers The firer registry. |
310 | 310 | */ |
311 | -function wordpoints_hook_firers_init( $firers ) { |
|
311 | +function wordpoints_hook_firers_init($firers) { |
|
312 | 312 | |
313 | - $firers->register( 'fire', 'WordPoints_Hook_Firer' ); |
|
314 | - $firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' ); |
|
315 | - $firers->register( 'spam', 'WordPoints_Hook_Firer_Spam' ); |
|
313 | + $firers->register('fire', 'WordPoints_Hook_Firer'); |
|
314 | + $firers->register('reverse', 'WordPoints_Hook_Firer_Reverse'); |
|
315 | + $firers->register('spam', 'WordPoints_Hook_Firer_Spam'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @param WordPoints_App_Registry $entities The entities app. |
326 | 326 | */ |
327 | -function wordpoints_entities_app_init( $entities ) { |
|
327 | +function wordpoints_entities_app_init($entities) { |
|
328 | 328 | |
329 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
330 | - $entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' ); |
|
329 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
330 | + $entities->sub_apps->register('contexts', 'WordPoints_Class_Registry'); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @param WordPoints_Class_Registry $contexts The entity context registry. |
341 | 341 | */ |
342 | -function wordpoints_entity_contexts_init( $contexts ) { |
|
342 | +function wordpoints_entity_contexts_init($contexts) { |
|
343 | 343 | |
344 | - $contexts->register( 'network', 'WordPoints_Entity_Context_Network' ); |
|
345 | - $contexts->register( 'site', 'WordPoints_Entity_Context_Site' ); |
|
344 | + $contexts->register('network', 'WordPoints_Entity_Context_Network'); |
|
345 | + $contexts->register('site', 'WordPoints_Entity_Context_Site'); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -354,18 +354,18 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @param WordPoints_App_Registry $entities The entities app. |
356 | 356 | */ |
357 | -function wordpoints_entities_init( $entities ) { |
|
357 | +function wordpoints_entities_init($entities) { |
|
358 | 358 | |
359 | 359 | $children = $entities->children; |
360 | 360 | |
361 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
362 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
361 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
362 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
363 | 363 | |
364 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
365 | - $children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
364 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
365 | + $children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
366 | 366 | |
367 | 367 | // Register entities for all of the public post types. |
368 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
368 | + $post_types = get_post_types(array('public' => true)); |
|
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Filter which post types to register entities for. |
@@ -374,14 +374,14 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @param string[] The post type slugs ("names"). |
376 | 376 | */ |
377 | - $post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types ); |
|
377 | + $post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types); |
|
378 | 378 | |
379 | - foreach ( $post_types as $slug ) { |
|
380 | - wordpoints_register_post_type_entities( $slug ); |
|
379 | + foreach ($post_types as $slug) { |
|
380 | + wordpoints_register_post_type_entities($slug); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // Register entities for all of the public taxonomies. |
384 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
384 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Filter which taxonomies to register entities for. |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param string[] The taxonomy slugs. |
392 | 392 | */ |
393 | - $taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies ); |
|
393 | + $taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies); |
|
394 | 394 | |
395 | - foreach ( $taxonomies as $slug ) { |
|
396 | - wordpoints_register_taxonomy_entities( $slug ); |
|
395 | + foreach ($taxonomies as $slug) { |
|
396 | + wordpoints_register_taxonomy_entities($slug); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -404,28 +404,28 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @param string $slug The slug of the post type. |
406 | 406 | */ |
407 | -function wordpoints_register_post_type_entities( $slug ) { |
|
407 | +function wordpoints_register_post_type_entities($slug) { |
|
408 | 408 | |
409 | 409 | $entities = wordpoints_entities(); |
410 | 410 | $children = $entities->children; |
411 | 411 | |
412 | - $entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' ); |
|
413 | - $children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' ); |
|
412 | + $entities->register("post\\{$slug}", 'WordPoints_Entity_Post'); |
|
413 | + $children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author'); |
|
414 | 414 | |
415 | - $supports = get_all_post_type_supports( $slug ); |
|
415 | + $supports = get_all_post_type_supports($slug); |
|
416 | 416 | |
417 | - if ( isset( $supports['editor'] ) ) { |
|
418 | - $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
|
417 | + if (isset($supports['editor'])) { |
|
418 | + $children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content'); |
|
419 | 419 | } |
420 | 420 | |
421 | - if ( isset( $supports['comments'] ) ) { |
|
422 | - $entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' ); |
|
423 | - $children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' ); |
|
424 | - $children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' ); |
|
421 | + if (isset($supports['comments'])) { |
|
422 | + $entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment'); |
|
423 | + $children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post'); |
|
424 | + $children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author'); |
|
425 | 425 | } |
426 | 426 | |
427 | - foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) { |
|
428 | - $children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' ); |
|
427 | + foreach (get_object_taxonomies($slug) as $taxonomy_slug) { |
|
428 | + $children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms'); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @param string $slug The slug ("name") of the post type. |
437 | 437 | */ |
438 | - do_action( 'wordpoints_register_post_type_entities', $slug ); |
|
438 | + do_action('wordpoints_register_post_type_entities', $slug); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $slug The slug of the post type. |
447 | 447 | */ |
448 | -function wordpoints_register_post_type_hook_events( $slug ) { |
|
448 | +function wordpoints_register_post_type_hook_events($slug) { |
|
449 | 449 | |
450 | 450 | $event_slugs = array(); |
451 | 451 | |
452 | 452 | $events = wordpoints_hooks()->events; |
453 | 453 | |
454 | - if ( 'attachment' === $slug ) { |
|
454 | + if ('attachment' === $slug) { |
|
455 | 455 | |
456 | 456 | $event_slugs[] = 'media_upload'; |
457 | 457 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | - if ( post_type_supports( $slug, 'comments' ) ) { |
|
491 | + if (post_type_supports($slug, 'comments')) { |
|
492 | 492 | |
493 | 493 | $event_slugs[] = "comment_leave\\{$slug}"; |
494 | 494 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | , 'WordPoints_Hook_Event_Comment_Leave' |
498 | 498 | , array( |
499 | 499 | 'actions' => array( |
500 | - 'fire' => array( 'comment_approve', 'comment_new' ), |
|
500 | + 'fire' => array('comment_approve', 'comment_new'), |
|
501 | 501 | 'reverse' => 'comment_deapprove', |
502 | 502 | 'spam' => 'comment_spam', |
503 | 503 | ), |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | ); |
509 | 509 | } |
510 | 510 | |
511 | - if ( is_multisite() ) { |
|
512 | - foreach ( $event_slugs as $event_slug ) { |
|
511 | + if (is_multisite()) { |
|
512 | + foreach ($event_slugs as $event_slug) { |
|
513 | 513 | $events->args->register( |
514 | 514 | $event_slug |
515 | 515 | , 'current:site' |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @param string $slug The slug ("name") of the post type. |
527 | 527 | */ |
528 | - do_action( 'wordpoints_register_post_type_hook_events', $slug ); |
|
528 | + do_action('wordpoints_register_post_type_hook_events', $slug); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @param string $slug The slug of the taxonomy. |
537 | 537 | */ |
538 | -function wordpoints_register_taxonomy_entities( $slug ) { |
|
538 | +function wordpoints_register_taxonomy_entities($slug) { |
|
539 | 539 | |
540 | 540 | $entities = wordpoints_entities(); |
541 | 541 | $children = $entities->children; |
542 | 542 | |
543 | - $entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' ); |
|
544 | - $children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' ); |
|
543 | + $entities->register("term\\{$slug}", 'WordPoints_Entity_Term'); |
|
544 | + $children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id'); |
|
545 | 545 | |
546 | 546 | /** |
547 | 547 | * Fired when registering the entities for a taxonomy. |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * |
551 | 551 | * @param string $slug The taxonomy's slug. |
552 | 552 | */ |
553 | - do_action( 'wordpoints_register_taxonomy_entities', $slug ); |
|
553 | + do_action('wordpoints_register_taxonomy_entities', $slug); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
564 | 564 | */ |
565 | -function wordpoints_data_types_init( $data_types ) { |
|
565 | +function wordpoints_data_types_init($data_types) { |
|
566 | 566 | |
567 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
568 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
567 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
568 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return bool Whether the user can view the points log. |
582 | 582 | */ |
583 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
583 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
584 | 584 | |
585 | - if ( ! $can_view ) { |
|
585 | + if ( ! $can_view) { |
|
586 | 586 | return $can_view; |
587 | 587 | } |
588 | 588 | |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | $event_slug = $log->log_type; |
592 | 592 | |
593 | 593 | /** @var WordPoints_Hook_Arg $arg */ |
594 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
594 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
595 | 595 | |
596 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
596 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
597 | 597 | |
598 | - if ( ! $value ) { |
|
598 | + if ( ! $value) { |
|
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | , $value |
606 | 606 | ); |
607 | 607 | |
608 | - if ( ! $can_view ) { |
|
608 | + if ( ! $can_view) { |
|
609 | 609 | break; |
610 | 610 | } |
611 | 611 | } |
@@ -624,20 +624,20 @@ discard block |
||
624 | 624 | * |
625 | 625 | * @return bool Whether the user can view this entity. |
626 | 626 | */ |
627 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
627 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
628 | 628 | |
629 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
629 | + $entity = wordpoints_entities()->get($entity_slug); |
|
630 | 630 | |
631 | 631 | // If this entity type is not found, we have no way of determining whether it is |
632 | 632 | // safe for the user to view it. |
633 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
633 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
634 | 634 | return false; |
635 | 635 | } |
636 | 636 | |
637 | 637 | $can_view = true; |
638 | 638 | |
639 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
640 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
639 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
640 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | */ |
669 | 669 | function wordpoints_apps() { |
670 | 670 | |
671 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
672 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
671 | + if ( ! isset(WordPoints_App::$main)) { |
|
672 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | return WordPoints_App::$main; |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function wordpoints_hooks() { |
686 | 686 | |
687 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
687 | + if ( ! isset(WordPoints_App::$main)) { |
|
688 | 688 | wordpoints_apps(); |
689 | 689 | } |
690 | 690 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | function wordpoints_entities() { |
702 | 702 | |
703 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
703 | + if ( ! isset(WordPoints_App::$main)) { |
|
704 | 704 | wordpoints_apps(); |
705 | 705 | } |
706 | 706 | |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | * |
717 | 717 | * @param WordPoints_App $app The main apps app. |
718 | 718 | */ |
719 | -function wordpoints_apps_init( $app ) { |
|
719 | +function wordpoints_apps_init($app) { |
|
720 | 720 | |
721 | 721 | $apps = $app->sub_apps; |
722 | 722 | |
723 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
724 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
725 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
723 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
724 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
725 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -735,19 +735,19 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return object|false The constructed object, or false if to many args were passed. |
737 | 737 | */ |
738 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
738 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
739 | 739 | |
740 | - switch ( count( $args ) ) { |
|
740 | + switch (count($args)) { |
|
741 | 741 | case 0: |
742 | 742 | return new $class_name(); |
743 | 743 | case 1: |
744 | - return new $class_name( $args[0] ); |
|
744 | + return new $class_name($args[0]); |
|
745 | 745 | case 2: |
746 | - return new $class_name( $args[0], $args[1] ); |
|
746 | + return new $class_name($args[0], $args[1]); |
|
747 | 747 | case 3: |
748 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
748 | + return new $class_name($args[0], $args[1], $args[2]); |
|
749 | 749 | case 4: |
750 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
750 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
751 | 751 | default: |
752 | 752 | return false; |
753 | 753 | } |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the |
770 | 770 | * slug is not dynamic, the value of each of those keys will be false. |
771 | 771 | */ |
772 | -function wordpoints_parse_dynamic_slug( $slug ) { |
|
772 | +function wordpoints_parse_dynamic_slug($slug) { |
|
773 | 773 | |
774 | - $parsed = array( 'dynamic' => false, 'generic' => false ); |
|
774 | + $parsed = array('dynamic' => false, 'generic' => false); |
|
775 | 775 | |
776 | - $parts = explode( '\\', $slug, 2 ); |
|
776 | + $parts = explode('\\', $slug, 2); |
|
777 | 777 | |
778 | - if ( isset( $parts[1] ) ) { |
|
778 | + if (isset($parts[1])) { |
|
779 | 779 | $parsed['dynamic'] = $parts[1]; |
780 | 780 | $parsed['generic'] = $parts[0]; |
781 | 781 | } |
@@ -812,28 +812,28 @@ discard block |
||
812 | 812 | * @return array|false The IDs of the context(s) you passed in, indexed by context |
813 | 813 | * slug, or false if any of the contexts isn't current. |
814 | 814 | */ |
815 | -function wordpoints_entities_get_current_context_id( array $slugs ) { |
|
815 | +function wordpoints_entities_get_current_context_id(array $slugs) { |
|
816 | 816 | |
817 | 817 | $current_context = array(); |
818 | 818 | |
819 | 819 | /** @var WordPoints_Class_Registry $contexts */ |
820 | 820 | $contexts = wordpoints_entities()->contexts; |
821 | 821 | |
822 | - foreach ( $slugs as $slug ) { |
|
822 | + foreach ($slugs as $slug) { |
|
823 | 823 | |
824 | - $context = $contexts->get( $slug ); |
|
824 | + $context = $contexts->get($slug); |
|
825 | 825 | |
826 | - if ( ! $context instanceof WordPoints_Entity_Context ) { |
|
826 | + if ( ! $context instanceof WordPoints_Entity_Context) { |
|
827 | 827 | return false; |
828 | 828 | } |
829 | 829 | |
830 | 830 | $id = $context->get_current_id(); |
831 | 831 | |
832 | - if ( false === $id ) { |
|
832 | + if (false === $id) { |
|
833 | 833 | return false; |
834 | 834 | } |
835 | 835 | |
836 | - $current_context[ $slug ] = $id; |
|
836 | + $current_context[$slug] = $id; |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | return $current_context; |
@@ -852,18 +852,18 @@ discard block |
||
852 | 852 | */ |
853 | 853 | function wordpoints_is_network_context() { |
854 | 854 | |
855 | - if ( is_network_admin() ) { |
|
855 | + if (is_network_admin()) { |
|
856 | 856 | return true; |
857 | 857 | } |
858 | 858 | |
859 | 859 | // See https://core.trac.wordpress.org/ticket/22589 |
860 | 860 | if ( |
861 | - defined( 'DOING_AJAX' ) |
|
861 | + defined('DOING_AJAX') |
|
862 | 862 | && DOING_AJAX |
863 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
863 | + && isset($_SERVER['HTTP_REFERER']) |
|
864 | 864 | && preg_match( |
865 | - '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
|
866 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
865 | + '#^'.preg_quote(network_admin_url(), '#').'#i' |
|
866 | + , esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) |
|
867 | 867 | ) |
868 | 868 | ) { |
869 | 869 | return true; |
@@ -876,19 +876,19 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @param bool $in_network_context Whether we are in network context. |
878 | 878 | */ |
879 | - return apply_filters( 'wordpoints_is_network_context', false ); |
|
879 | + return apply_filters('wordpoints_is_network_context', false); |
|
880 | 880 | } |
881 | 881 | |
882 | -function wordpoints_hooks_get_event_signature( WordPoints_Hook_Event_Args $event_args ) { |
|
882 | +function wordpoints_hooks_get_event_signature(WordPoints_Hook_Event_Args $event_args) { |
|
883 | 883 | |
884 | 884 | $entity = $event_args->get_primary_arg(); |
885 | 885 | |
886 | 886 | // TODO what if GUID isn't set? |
887 | - if ( ! $entity ) { |
|
888 | - return str_repeat( '-', 64 ); |
|
887 | + if ( ! $entity) { |
|
888 | + return str_repeat('-', 64); |
|
889 | 889 | } |
890 | 890 | |
891 | - return wordpoints_hash( wp_json_encode( $entity->get_the_guid() ) ); |
|
891 | + return wordpoints_hash(wp_json_encode($entity->get_the_guid())); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | // EOF |