Completed
Push — master ( 274f34...8ff377 )
by J.D.
04:05
created
src/includes/classes/hooks.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	protected function init() {
47 47
 
48 48
 		$sub_apps = $this->sub_apps;
49
-		$sub_apps->register( 'router', 'WordPoints_Hook_Router' );
50
-		$sub_apps->register( 'actions', 'WordPoints_Hook_Actions' );
51
-		$sub_apps->register( 'events', 'WordPoints_Hook_Events' );
52
-		$sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' );
53
-		$sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' );
54
-		$sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' );
55
-		$sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' );
49
+		$sub_apps->register('router', 'WordPoints_Hook_Router');
50
+		$sub_apps->register('actions', 'WordPoints_Hook_Actions');
51
+		$sub_apps->register('events', 'WordPoints_Hook_Events');
52
+		$sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent');
53
+		$sub_apps->register('reaction_stores', 'WordPoints_Class_Registry_Children');
54
+		$sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent');
55
+		$sub_apps->register('conditions', 'WordPoints_Class_Registry_Children');
56 56
 
57 57
 		parent::init();
58 58
 	}
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function get_current_mode() {
77 77
 
78
-		if ( ! isset( $this->current_mode ) ) {
79
-			$this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' );
78
+		if ( ! isset($this->current_mode)) {
79
+			$this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard');
80 80
 		}
81 81
 
82 82
 		return $this->current_mode;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @param string $mode The slug of the mode to set as the current mode.
96 96
 	 */
97
-	public function set_current_mode( $mode ) {
97
+	public function set_current_mode($mode) {
98 98
 		$this->current_mode = $mode;
99 99
 	}
100 100
 
@@ -107,19 +107,19 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object.
109 109
 	 */
110
-	public function get_reaction_store( $slug ) {
110
+	public function get_reaction_store($slug) {
111 111
 
112 112
 		$reaction_store = $this->reaction_stores->get(
113 113
 			$this->get_current_mode()
114 114
 			, $slug
115 115
 		);
116 116
 
117
-		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
117
+		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
118 118
 			return false;
119 119
 		}
120 120
 
121 121
 		// Allowing access to stores out-of-context would lead to strange behavior.
122
-		if ( false === $reaction_store->get_context_id() ) {
122
+		if (false === $reaction_store->get_context_id()) {
123 123
 			return false;
124 124
 		}
125 125
 
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 		$action_type
143 143
 	) {
144 144
 
145
-		foreach ( $this->reaction_stores->get_all() as $reaction_stores ) {
146
-			foreach ( $reaction_stores as $reaction_store ) {
145
+		foreach ($this->reaction_stores->get_all() as $reaction_stores) {
146
+			foreach ($reaction_stores as $reaction_store) {
147 147
 
148
-				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
148
+				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
149 149
 					continue;
150 150
 				}
151 151
 
152 152
 				// Allowing access to stores out-of-context would lead to strange behavior.
153
-				if ( false === $reaction_store->get_context_id() ) {
153
+				if (false === $reaction_store->get_context_id()) {
154 154
 					continue;
155 155
 				}
156 156
 
157
-				foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) {
157
+				foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) {
158 158
 
159 159
 					$fire = new WordPoints_Hook_Fire(
160 160
 						$event_args
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 						, $action_type
163 163
 					);
164 164
 
165
-					$this->fire_reaction( $fire );
165
+					$this->fire_reaction($fire);
166 166
 				}
167 167
 			}
168 168
 		}
@@ -175,32 +175,32 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
177 177
 	 */
178
-	protected function fire_reaction( $fire ) {
178
+	protected function fire_reaction($fire) {
179 179
 
180 180
 		/** @var WordPoints_Hook_Reactor $reactor */
181
-		$reactor = $this->reactors->get( $fire->reaction->get_reactor_slug() );
181
+		$reactor = $this->reactors->get($fire->reaction->get_reactor_slug());
182 182
 
183
-		if ( ! in_array( $fire->action_type, $reactor->get_action_types(), true ) ) {
183
+		if ( ! in_array($fire->action_type, $reactor->get_action_types(), true)) {
184 184
 			return;
185 185
 		}
186 186
 
187
-		$validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true );
187
+		$validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true);
188 188
 		$validator->validate();
189 189
 
190
-		if ( $validator->had_errors() ) {
190
+		if ($validator->had_errors()) {
191 191
 			return;
192 192
 		}
193 193
 
194
-		unset( $validator );
194
+		unset($validator);
195 195
 
196 196
 		/** @var WordPoints_Hook_Extension[] $extensions */
197 197
 		$extensions = $this->extensions->get_all();
198 198
 
199
-		foreach ( $extensions as $extension ) {
200
-			if ( ! $extension->should_hit( $fire ) ) {
201
-				foreach ( $extensions as $ext ) {
202
-					if ( $ext instanceof WordPoints_Hook_Extension_Miss_ListenerI ) {
203
-						$ext->after_miss( $fire );
199
+		foreach ($extensions as $extension) {
200
+			if ( ! $extension->should_hit($fire)) {
201
+				foreach ($extensions as $ext) {
202
+					if ($ext instanceof WordPoints_Hook_Extension_Miss_ListenerI) {
203
+						$ext->after_miss($fire);
204 204
 					}
205 205
 				}
206 206
 
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$fire->hit();
212 212
 
213
-		$reactor->hit( $fire );
213
+		$reactor->hit($fire);
214 214
 
215
-		foreach ( $extensions as $extension ) {
216
-			if ( $extension instanceof WordPoints_Hook_Extension_Hit_ListenerI ) {
217
-				$extension->after_hit( $fire );
215
+		foreach ($extensions as $extension) {
216
+			if ($extension instanceof WordPoints_Hook_Extension_Hit_ListenerI) {
217
+				$extension->after_hit($fire);
218 218
 			}
219 219
 		}
220 220
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/extension.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 		WordPoints_Hook_Event_Args $event_args
66 66
 	) {
67 67
 
68
-		if ( ! isset( $settings[ $this->slug ] ) ) {
68
+		if ( ! isset($settings[$this->slug])) {
69 69
 			return $settings;
70 70
 		}
71 71
 
72
-		if ( ! is_array( $settings[ $this->slug ] ) ) {
72
+		if ( ! is_array($settings[$this->slug])) {
73 73
 
74 74
 			$validator->add_error(
75
-				__( 'Invalid settings format.', 'wordpoints' )
75
+				__('Invalid settings format.', 'wordpoints')
76 76
 				, $this->slug
77 77
 			);
78 78
 
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 		$this->validator = $validator;
83 83
 		$this->event_args = $event_args;
84 84
 
85
-		$this->validator->push_field( $this->slug );
85
+		$this->validator->push_field($this->slug);
86 86
 
87
-		foreach ( $settings[ $this->slug ] as $action_type => $action_type_settings ) {
87
+		foreach ($settings[$this->slug] as $action_type => $action_type_settings) {
88 88
 
89
-			$this->validator->push_field( $action_type );
89
+			$this->validator->push_field($action_type);
90 90
 
91
-			$settings[ $this->slug ][ $action_type ] = $this->validate_action_type_settings(
91
+			$settings[$this->slug][$action_type] = $this->validate_action_type_settings(
92 92
 				$action_type_settings
93 93
 			);
94 94
 
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * @since 1.0.0
105 105
 	 */
106
-	public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) {
106
+	public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) {
107 107
 
108
-		if ( isset( $settings[ $this->slug ] ) ) {
109
-			$reaction->update_meta( $this->slug, $settings[ $this->slug ] );
108
+		if (isset($settings[$this->slug])) {
109
+			$reaction->update_meta($this->slug, $settings[$this->slug]);
110 110
 		} else {
111
-			$reaction->delete_meta( $this->slug );
111
+			$reaction->delete_meta($this->slug);
112 112
 		}
113 113
 	}
114 114
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return mixed The validated settings.
123 123
 	 */
124
-	protected function validate_action_type_settings( $settings ) {
124
+	protected function validate_action_type_settings($settings) {
125 125
 		return $settings;
126 126
 	}
127 127
 
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return mixed The settings for the extension, or false if none.
140 140
 	 */
141
-	protected function get_settings_from_fire( WordPoints_Hook_Fire $fire ) {
141
+	protected function get_settings_from_fire(WordPoints_Hook_Fire $fire) {
142 142
 
143
-		$settings = $fire->reaction->get_meta( $this->slug );
143
+		$settings = $fire->reaction->get_meta($this->slug);
144 144
 
145
-		if ( ! is_array( $settings ) ) {
145
+		if ( ! is_array($settings)) {
146 146
 			return $settings;
147 147
 		}
148 148
 
149
-		if ( isset( $settings[ $fire->action_type ] ) ) {
150
-			return $settings[ $fire->action_type ];
149
+		if (isset($settings[$fire->action_type])) {
150
+			return $settings[$fire->action_type];
151 151
 		} else {
152 152
 			return false;
153 153
 		}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return bool Whether the target should be hit by this hook firing.
164 164
 	 */
165
-	abstract public function should_hit( WordPoints_Hook_Fire $fire );
165
+	abstract public function should_hit(WordPoints_Hook_Fire $fire);
166 166
 
167 167
 	/**
168 168
 	 * Get the data the scripts need for the UI.
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/repeat/blocker.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,22 +22,22 @@
 block discarded – undo
22 22
 	/**
23 23
 	 * @since 1.0.0
24 24
 	 */
25
-	protected function validate_action_type_settings( $settings ) {
25
+	protected function validate_action_type_settings($settings) {
26 26
 		return (bool) $settings;
27 27
 	}
28 28
 
29 29
 	/**
30 30
 	 * @since 1.0.0
31 31
 	 */
32
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
32
+	public function should_hit(WordPoints_Hook_Fire $fire) {
33 33
 
34
-		$block_repeats = (bool) $this->get_settings_from_fire( $fire );
34
+		$block_repeats = (bool) $this->get_settings_from_fire($fire);
35 35
 
36
-		if ( ! $block_repeats ) {
36
+		if ( ! $block_repeats) {
37 37
 			return true;
38 38
 		}
39 39
 
40
-		if ( $fire->get_matching_hits_query()->count() > 0 ) {
40
+		if ($fire->get_matching_hits_query()->count() > 0) {
41 41
 			return false;
42 42
 		}
43 43
 
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/reversals.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,36 +32,36 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @since 1.0.0
34 34
 	 */
35
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
35
+	public function should_hit(WordPoints_Hook_Fire $fire) {
36 36
 
37
-		if ( ! $this->get_settings_from_fire( $fire ) ) {
37
+		if ( ! $this->get_settings_from_fire($fire)) {
38 38
 			return true;
39 39
 		}
40 40
 
41
-		$ids = $this->get_hits_to_be_reversed( $fire );
41
+		$ids = $this->get_hits_to_be_reversed($fire);
42 42
 
43
-		return count( $ids ) > 0;
43
+		return count($ids) > 0;
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @since 1.0.0
48 48
 	 */
49
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
49
+	public function after_hit(WordPoints_Hook_Fire $fire) {
50 50
 
51
-		if ( ! $this->get_settings_from_fire( $fire ) ) {
51
+		if ( ! $this->get_settings_from_fire($fire)) {
52 52
 			return;
53 53
 		}
54 54
 
55
-		foreach ( $this->get_hits_to_be_reversed( $fire ) as $id ) {
56
-			add_metadata( 'wordpoints_hook_hit', $id, 'reverse_fired', true );
55
+		foreach ($this->get_hits_to_be_reversed($fire) as $id) {
56
+			add_metadata('wordpoints_hook_hit', $id, 'reverse_fired', true);
57 57
 		}
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * @since 1.0.0
62 62
 	 */
63
-	public function after_miss( WordPoints_Hook_Fire $fire ) {
64
-		$this->after_hit( $fire );
63
+	public function after_miss(WordPoints_Hook_Fire $fire) {
64
+		$this->after_hit($fire);
65 65
 	}
66 66
 
67 67
 	/**
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return array The ids the hits to be reversed.
75 75
 	 */
76
-	protected function get_hits_to_be_reversed( WordPoints_Hook_Fire $fire ) {
76
+	protected function get_hits_to_be_reversed(WordPoints_Hook_Fire $fire) {
77 77
 
78 78
 		// We cache these so that we don't run the query both before and after the
79 79
 		// fire.
80
-		if ( isset( $fire->data[ $this->slug ]['hit_ids'] ) ) {
81
-			return $fire->data[ $this->slug ]['hit_ids'];
80
+		if (isset($fire->data[$this->slug]['hit_ids'])) {
81
+			return $fire->data[$this->slug]['hit_ids'];
82 82
 		}
83 83
 
84 84
 		$query = $fire->get_matching_hits_query();
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
 		$query->set_args(
87 87
 			array(
88 88
 				'fields'       => 'id',
89
-				'action_type'  => $this->get_settings_from_fire( $fire ),
89
+				'action_type'  => $this->get_settings_from_fire($fire),
90 90
 				'meta_key'     => 'reverse_fired',
91 91
 				'meta_compare' => 'NOT EXISTS',
92 92
 			)
93 93
 		);
94 94
 
95
-		$ids = $query->get( 'col' );
95
+		$ids = $query->get('col');
96 96
 
97
-		if ( ! $ids ) {
97
+		if ( ! $ids) {
98 98
 			$ids = array();
99 99
 		}
100 100
 
101
-		$fire->data[ $this->slug ]['hit_ids'] = $ids;
101
+		$fire->data[$this->slug]['hit_ids'] = $ids;
102 102
 
103 103
 		return $ids;
104 104
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/hit/listeneri.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
23 23
 	 */
24
-	public function after_hit( WordPoints_Hook_Fire $fire );
24
+	public function after_hit(WordPoints_Hook_Fire $fire);
25 25
 }
26 26
 
27 27
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/router.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	/**
81 81
 	 * @since 1.0.0
82 82
 	 */
83
-	public function __call( $name, $args ) {
83
+	public function __call($name, $args) {
84 84
 
85
-		$this->route_action( $name, $args );
85
+		$this->route_action($name, $args);
86 86
 
87 87
 		// Return the first value, in case it is hooked to a filter.
88 88
 		$return = null;
89
-		if ( isset( $args[0] ) ) {
89
+		if (isset($args[0])) {
90 90
 			$return = $args[0];
91 91
 		}
92 92
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	 *                     action name and the priority.
104 104
 	 * @param array  $args The args the action was fired with.
105 105
 	 */
106
-	protected function route_action( $name, $args ) {
106
+	protected function route_action($name, $args) {
107 107
 
108
-		if ( ! isset( $this->action_index[ $name ] ) ) {
108
+		if ( ! isset($this->action_index[$name])) {
109 109
 			return;
110 110
 		}
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		// registry attempts to access the router in its own constructor. The result
114 114
 		// of attempting to do this before the router itself has been fully
115 115
 		// constructed is that the events registry gets null instead of the router.
116
-		if ( ! isset( $this->hooks ) ) {
116
+		if ( ! isset($this->hooks)) {
117 117
 
118 118
 			$hooks = wordpoints_hooks();
119 119
 
@@ -122,38 +122,38 @@  discard block
 block discarded – undo
122 122
 			$this->actions = $hooks->actions;
123 123
 		}
124 124
 
125
-		foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) {
125
+		foreach ($this->action_index[$name]['actions'] as $slug => $data) {
126 126
 
127
-			if ( ! isset( $this->event_index[ $slug ] ) ) {
127
+			if ( ! isset($this->event_index[$slug])) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$action_object = $this->actions->get( $slug, $args, $data );
131
+			$action_object = $this->actions->get($slug, $args, $data);
132 132
 
133
-			if ( ! ( $action_object instanceof WordPoints_Hook_ActionI ) ) {
133
+			if ( ! ($action_object instanceof WordPoints_Hook_ActionI)) {
134 134
 				continue;
135 135
 			}
136 136
 
137
-			if ( ! $action_object->should_fire() ) {
137
+			if ( ! $action_object->should_fire()) {
138 138
 				continue;
139 139
 			}
140 140
 
141
-			foreach ( $this->event_index[ $slug ] as $type => $events ) {
142
-				foreach ( $events as $event_slug => $unused ) {
141
+			foreach ($this->event_index[$slug] as $type => $events) {
142
+				foreach ($events as $event_slug => $unused) {
143 143
 
144
-					if ( ! $this->events->is_registered( $event_slug ) ) {
144
+					if ( ! $this->events->is_registered($event_slug)) {
145 145
 						continue;
146 146
 					}
147 147
 
148
-					$event_args = $this->events->args->get_children( $event_slug, array( $action_object ) );
148
+					$event_args = $this->events->args->get_children($event_slug, array($action_object));
149 149
 
150
-					if ( empty( $event_args ) ) {
150
+					if (empty($event_args)) {
151 151
 						continue;
152 152
 					}
153 153
 
154
-					$event_args = new WordPoints_Hook_Event_Args( $event_args );
154
+					$event_args = new WordPoints_Hook_Event_Args($event_args);
155 155
 
156
-					$this->hooks->fire( $event_slug, $event_args, $type );
156
+					$this->hooks->fire($event_slug, $event_args, $type);
157 157
 				}
158 158
 			}
159 159
 		}
@@ -182,56 +182,56 @@  discard block
 block discarded – undo
182 182
 	 *        }
183 183
 	 * }
184 184
 	 */
185
-	public function add_action( $slug, array $args ) {
185
+	public function add_action($slug, array $args) {
186 186
 
187 187
 		$priority = 10;
188
-		if ( isset( $args['priority'] ) ) {
188
+		if (isset($args['priority'])) {
189 189
 			$priority = $args['priority'];
190 190
 		}
191 191
 
192
-		if ( ! isset( $args['action'] ) ) {
192
+		if ( ! isset($args['action'])) {
193 193
 			return;
194 194
 		}
195 195
 
196 196
 		$method = "{$args['action']},{$priority}";
197 197
 
198
-		$this->action_index[ $method ]['actions'][ $slug ] = array();
198
+		$this->action_index[$method]['actions'][$slug] = array();
199 199
 
200 200
 		$arg_number = 1;
201 201
 
202
-		if ( isset( $args['data'] ) ) {
202
+		if (isset($args['data'])) {
203 203
 
204
-			if ( isset( $args['data']['arg_index'] ) ) {
205
-				$arg_number = 1 + max( $args['data']['arg_index'] );
204
+			if (isset($args['data']['arg_index'])) {
205
+				$arg_number = 1 + max($args['data']['arg_index']);
206 206
 			}
207 207
 
208
-			if ( isset( $args['data']['requirements'] ) ) {
209
-				$requirements = 1 + max( array_keys( $args['data']['requirements'] ) );
208
+			if (isset($args['data']['requirements'])) {
209
+				$requirements = 1 + max(array_keys($args['data']['requirements']));
210 210
 
211
-				if ( $requirements > $arg_number ) {
211
+				if ($requirements > $arg_number) {
212 212
 					$arg_number = $requirements;
213 213
 				}
214 214
 			}
215 215
 
216
-			$this->action_index[ $method ]['actions'][ $slug ] = $args['data'];
216
+			$this->action_index[$method]['actions'][$slug] = $args['data'];
217 217
 		}
218 218
 
219
-		if ( isset( $args['arg_number'] ) ) {
219
+		if (isset($args['arg_number'])) {
220 220
 			$arg_number = $args['arg_number'];
221 221
 		}
222 222
 
223 223
 		// If this action is already being routed, and will have enough args, we
224 224
 		// don't need to hook to it again.
225 225
 		if (
226
-			isset( $this->action_index[ $method ]['arg_number'] )
227
-			&& $this->action_index[ $method ]['arg_number'] >= $arg_number
226
+			isset($this->action_index[$method]['arg_number'])
227
+			&& $this->action_index[$method]['arg_number'] >= $arg_number
228 228
 		) {
229 229
 			return;
230 230
 		}
231 231
 
232
-		$this->action_index[ $method ]['arg_number'] = $arg_number;
232
+		$this->action_index[$method]['arg_number'] = $arg_number;
233 233
 
234
-		add_action( $args['action'], array( $this, $method ), $priority, $arg_number );
234
+		add_action($args['action'], array($this, $method), $priority, $arg_number);
235 235
 	}
236 236
 
237 237
 	/**
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @param string $slug The action slug.
243 243
 	 */
244
-	public function remove_action( $slug ) {
244
+	public function remove_action($slug) {
245 245
 
246
-		foreach ( $this->action_index as $method => $data ) {
247
-			if ( isset( $data['actions'][ $slug ] ) ) {
246
+		foreach ($this->action_index as $method => $data) {
247
+			if (isset($data['actions'][$slug])) {
248 248
 
249
-				unset( $this->action_index[ $method ]['actions'][ $slug ] );
249
+				unset($this->action_index[$method]['actions'][$slug]);
250 250
 
251
-				if ( empty( $this->action_index[ $method ]['actions'] ) ) {
251
+				if (empty($this->action_index[$method]['actions'])) {
252 252
 
253
-					unset( $this->action_index[ $method ] );
253
+					unset($this->action_index[$method]);
254 254
 
255
-					list( $action, $priority ) = explode( ',', $method );
255
+					list($action, $priority) = explode(',', $method);
256 256
 
257
-					remove_action( $action, array( $this, $method ), $priority );
257
+					remove_action($action, array($this, $method), $priority);
258 258
 				}
259 259
 			}
260 260
 		}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param string $action_slug The slug of the action.
270 270
 	 * @param string $action_type The type of action. Default is 'fire'.
271 271
 	 */
272
-	public function add_event_to_action( $event_slug, $action_slug, $action_type = 'fire' ) {
273
-		$this->event_index[ $action_slug ][ $action_type ][ $event_slug ] = true;
272
+	public function add_event_to_action($event_slug, $action_slug, $action_type = 'fire') {
273
+		$this->event_index[$action_slug][$action_type][$event_slug] = true;
274 274
 	}
275 275
 
276 276
 	/**
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param string $action_slug The slug of the action.
283 283
 	 * @param string $action_type The type of action. Default is 'fire'.
284 284
 	 */
285
-	public function remove_event_from_action( $event_slug, $action_slug, $action_type = 'fire' ) {
286
-		unset( $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] );
285
+	public function remove_event_from_action($event_slug, $action_slug, $action_type = 'fire') {
286
+		unset($this->event_index[$action_slug][$action_type][$event_slug]);
287 287
 	}
288 288
 
289 289
 	/**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public function get_event_index() {
297 297
 
298
-		if ( empty( $this->event_index ) ) {
298
+		if (empty($this->event_index)) {
299 299
 			wordpoints_hooks()->events;
300 300
 		}
301 301
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor/points.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @since 1.0.0
29 29
 	 */
30
-	protected $action_types = array( 'fire', 'toggle_on', 'toggle_off' );
30
+	protected $action_types = array('fire', 'toggle_on', 'toggle_off');
31 31
 
32 32
 	/**
33 33
 	 * @since 1.0.0
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function get_settings_fields() {
60 60
 
61
-		$this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' );
62
-		$this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' );
63
-		$this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' );
61
+		$this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints');
62
+		$this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints');
63
+		$this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints');
64 64
 
65 65
 		return parent::get_settings_fields();
66 66
 	}
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$data = parent::get_ui_script_data();
74 74
 
75
-		$data['target_label'] = __( 'Award To', 'wordpoints' );
76
-		$data['periods_label'] = __( 'Award each user no more than once per:', 'wordpoints' );
75
+		$data['target_label'] = __('Award To', 'wordpoints');
76
+		$data['periods_label'] = __('Award each user no more than once per:', 'wordpoints');
77 77
 
78 78
 		return $data;
79 79
 	}
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
 		WordPoints_Hook_Event_Args $event_args
88 88
 	) {
89 89
 
90
-		if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) {
91
-			$validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' );
90
+		if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) {
91
+			$validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points');
92 92
 		}
93 93
 
94
-		if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) {
95
-			$validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' );
94
+		if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) {
95
+			$validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type');
96 96
 		}
97 97
 
98
-		if ( ! isset( $settings['description'] ) ) {
99
-			$validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' );
98
+		if ( ! isset($settings['description'])) {
99
+			$validator->add_error(__('Description is required.', 'wordpoints'), 'description');
100 100
 		}
101 101
 
102
-		if ( ! isset( $settings['log_text'] ) ) {
103
-			$validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' );
102
+		if ( ! isset($settings['log_text'])) {
103
+			$validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text');
104 104
 		}
105 105
 
106
-		return parent::validate_settings( $settings, $validator, $event_args );
106
+		return parent::validate_settings($settings, $validator, $event_args);
107 107
 	}
108 108
 
109 109
 	/**
@@ -114,58 +114,58 @@  discard block
 block discarded – undo
114 114
 		array $settings
115 115
 	) {
116 116
 
117
-		parent::update_settings( $reaction, $settings );
117
+		parent::update_settings($reaction, $settings);
118 118
 
119
-		$reaction->update_meta( 'points', $settings['points'] );
120
-		$reaction->update_meta( 'points_type', $settings['points_type'] );
121
-		$reaction->update_meta( 'description', $settings['description'] );
122
-		$reaction->update_meta( 'log_text', $settings['log_text'] );
119
+		$reaction->update_meta('points', $settings['points']);
120
+		$reaction->update_meta('points_type', $settings['points_type']);
121
+		$reaction->update_meta('description', $settings['description']);
122
+		$reaction->update_meta('log_text', $settings['log_text']);
123 123
 	}
124 124
 
125 125
 	/**
126 126
 	 * @since 1.0.0
127 127
 	 */
128
-	public function hit( WordPoints_Hook_Fire $fire ) {
128
+	public function hit(WordPoints_Hook_Fire $fire) {
129 129
 
130
-		if ( 'toggle_off' === $fire->action_type ) {
131
-			$this->reverse_hit( $fire );
130
+		if ('toggle_off' === $fire->action_type) {
131
+			$this->reverse_hit($fire);
132 132
 			return;
133 133
 		}
134 134
 
135 135
 		$reaction = $fire->reaction;
136 136
 
137 137
 		$target = $fire->event_args->get_from_hierarchy(
138
-			$reaction->get_meta( 'target' )
138
+			$reaction->get_meta('target')
139 139
 		);
140 140
 
141
-		if ( ! $target instanceof WordPoints_Entity ) {
141
+		if ( ! $target instanceof WordPoints_Entity) {
142 142
 			return;
143 143
 		}
144 144
 
145
-		$meta = array( 'hook_hit_id' => $fire->hit_id );
145
+		$meta = array('hook_hit_id' => $fire->hit_id);
146 146
 
147
-		foreach ( $fire->event_args->get_entities() as $entity ) {
148
-			$meta[ $entity->get_slug() ] = $entity->get_the_id();
147
+		foreach ($fire->event_args->get_entities() as $entity) {
148
+			$meta[$entity->get_slug()] = $entity->get_the_id();
149 149
 		}
150 150
 
151 151
 		wordpoints_alter_points(
152 152
 			$target->get_the_id()
153
-			, $reaction->get_meta( 'points' )
154
-			, $reaction->get_meta( 'points_type' )
153
+			, $reaction->get_meta('points')
154
+			, $reaction->get_meta('points_type')
155 155
 			, $reaction->get_event_slug()
156 156
 			, $meta
157
-			, $reaction->get_meta( 'log_text' )
157
+			, $reaction->get_meta('log_text')
158 158
 		);
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * @since 1.0.0
163 163
 	 */
164
-	public function reverse_hit( WordPoints_Hook_Fire $fire ) {
164
+	public function reverse_hit(WordPoints_Hook_Fire $fire) {
165 165
 
166
-		$hit_ids = $this->get_hit_ids_to_be_reversed( $fire );
166
+		$hit_ids = $this->get_hit_ids_to_be_reversed($fire);
167 167
 
168
-		if ( empty( $hit_ids ) ) {
168
+		if (empty($hit_ids)) {
169 169
 			return;
170 170
 		}
171 171
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$logs = $query->get();
185 185
 
186
-		if ( ! $logs ) {
186
+		if ( ! $logs) {
187 187
 			return;
188 188
 		}
189 189
 
190
-		$this->reverse_logs( $logs, $fire );
190
+		$this->reverse_logs($logs, $fire);
191 191
 	}
192 192
 
193 193
 	/**
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return array The IDs of the hits to be reversed.
201 201
 	 */
202
-	protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) {
202
+	protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) {
203 203
 
204 204
 		// We closely integrate with the reversals extension to get the hit IDs.
205
-		if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) {
205
+		if ( ! isset($fire->data['reversals']['hit_ids'])) {
206 206
 			return array();
207 207
 		}
208 208
 
@@ -217,28 +217,28 @@  discard block
 block discarded – undo
217 217
 	 * @param object[]             $logs The logs to reverse.
218 218
 	 * @param WordPoints_Hook_Fire $fire The fire object.
219 219
 	 */
220
-	protected function reverse_logs( $logs, WordPoints_Hook_Fire $fire ) {
220
+	protected function reverse_logs($logs, WordPoints_Hook_Fire $fire) {
221 221
 
222 222
 		$event = wordpoints_hooks()->events->get(
223 223
 			$fire->reaction->get_event_slug()
224 224
 		);
225 225
 
226
-		if ( $event instanceof WordPoints_Hook_Event_ReversingI ) {
226
+		if ($event instanceof WordPoints_Hook_Event_ReversingI) {
227 227
 
228 228
 			/* translators: 1: log text for transaction that is being reversed, 2: the reason that this is being reversed. */
229
-			$template = __( 'Reversed “%1$s” (%2$s)', 'wordpoints' );
229
+			$template = __('Reversed “%1$s” (%2$s)', 'wordpoints');
230 230
 
231 231
 			$event_description = $event->get_reversal_text();
232 232
 
233 233
 		} else {
234 234
 
235 235
 			/* translators: 1: log text for transaction that is being reversed. */
236
-			$template = __( 'Reversed “%1$s”', 'wordpoints' );
236
+			$template = __('Reversed “%1$s”', 'wordpoints');
237 237
 
238 238
 			$event_description = '';
239 239
 		}
240 240
 
241
-		foreach ( $logs as $log ) {
241
+		foreach ($logs as $log) {
242 242
 
243 243
 			$log_id = wordpoints_alter_points(
244 244
 				$log->user_id
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 					'original_log_id' => $log->id,
250 250
 					'hook_hit_id'     => $fire->hit_id,
251 251
 				)
252
-				, sprintf( $template, $log->text, $event_description )
252
+				, sprintf($template, $log->text, $event_description)
253 253
 			);
254 254
 
255 255
 			// Mark the old log as reversed by this one.
256
-			wordpoints_update_points_log_meta( $log->id, 'auto_reversed', $log_id );
256
+			wordpoints_update_points_log_meta($log->id, 'auto_reversed', $log_id);
257 257
 		}
258 258
 	}
259 259
 }
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor/points/legacy.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 		array $settings
28 28
 	) {
29 29
 
30
-		if ( isset( $settings['legacy_log_type'] ) ) {
30
+		if (isset($settings['legacy_log_type'])) {
31 31
 			$reaction->update_meta(
32 32
 				'legacy_log_type',
33 33
 				$settings['legacy_log_type']
34 34
 			);
35 35
 		}
36 36
 
37
-		parent::update_settings( $reaction, $settings );
37
+		parent::update_settings($reaction, $settings);
38 38
 	}
39 39
 
40 40
 	/**
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @since 1.0.0
54 54
 	 */
55
-	public function reverse_hit( WordPoints_Hook_Fire $fire ) {
55
+	public function reverse_hit(WordPoints_Hook_Fire $fire) {
56 56
 
57
-		if ( isset( $fire->data['reversals_legacy_points']['points_logs'] ) ) {
57
+		if (isset($fire->data['reversals_legacy_points']['points_logs'])) {
58 58
 
59 59
 			$this->reverse_logs(
60 60
 				$fire->data['reversals_legacy_points']['points_logs']
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 			);
63 63
 
64 64
 		} else {
65
-			parent::reverse_hit( $fire );
65
+			parent::reverse_hit($fire);
66 66
 		}
67 67
 	}
68 68
 
69 69
 	/**
70 70
 	 * @since 1.0.0
71 71
 	 */
72
-	protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) {
72
+	protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) {
73 73
 
74 74
 		// We closely integrate with the legacy reversals extension to get the IDs.
75
-		if ( ! isset( $fire->data['reversals_legacy_points']['hit_ids'] ) ) {
75
+		if ( ! isset($fire->data['reversals_legacy_points']['hit_ids'])) {
76 76
 			return array();
77 77
 		}
78 78
 
Please login to merge, or discard this patch.
src/includes/classes/hook/event/media/upload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function get_title() {
23 23
 
24
-		return __( 'Upload Media', 'wordpoints' );
24
+		return __('Upload Media', 'wordpoints');
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function get_description() {
31 31
 
32
-		return __( 'When a file is uploaded to the Media Library.', 'wordpoints' );
32
+		return __('When a file is uploaded to the Media Library.', 'wordpoints');
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38 38
 	public function get_reversal_text() {
39
-		return __( 'Media file deleted.', 'wordpoints' );
39
+		return __('Media file deleted.', 'wordpoints');
40 40
 	}
41 41
 }
42 42
 
Please login to merge, or discard this patch.