Completed
Push — master ( 10c93c...9e33f9 )
by J.D.
03:00
created
src/includes/classes/entity/attr.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return mixed The attribute value.
41 41
 	 */
42
-	abstract protected function get_attr_value_from_entity( WordPoints_Entity $entity );
42
+	abstract protected function get_attr_value_from_entity(WordPoints_Entity $entity);
43 43
 
44 44
 	/**
45 45
 	 * Get the data type of this attribute's values.
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return bool Whether the value was set correctly.
68 68
 	 */
69
-	public function set_the_value_from_entity( WordPoints_Entity $entity ) {
69
+	public function set_the_value_from_entity(WordPoints_Entity $entity) {
70 70
 
71
-		$this->the_value = $this->get_attr_value_from_entity( $entity );
71
+		$this->the_value = $this->get_attr_value_from_entity($entity);
72 72
 
73 73
 		return true;
74 74
 	}
Please login to merge, or discard this patch.
src/includes/classes/entity/user/roles.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @since 1.0.0
36 36
 	 */
37
-	protected function get_related_entity_ids( WordPoints_Entity $entity ) {
38
-		return $entity->get_the_attr_value( $this->related_ids_field );
37
+	protected function get_related_entity_ids(WordPoints_Entity $entity) {
38
+		return $entity->get_the_attr_value($this->related_ids_field);
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @since 1.0.0
43 43
 	 */
44 44
 	public function get_title() {
45
-		return __( 'Roles', 'wordpoints' );
45
+		return __('Roles', 'wordpoints');
46 46
 	}
47 47
 
48 48
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 				'conditions'       => array(
63 63
 					array(
64 64
 						'field' => 'meta_key',
65
-						'value' => $GLOBALS['wpdb']->get_blog_prefix() . 'capabilities',
65
+						'value' => $GLOBALS['wpdb']->get_blog_prefix().'capabilities',
66 66
 					),
67 67
 				),
68 68
 			),
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38
-	public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ) {
38
+	public function __construct($id, WordPoints_Hook_Reaction_StoreI $store) {
39 39
 
40
-		$this->ID    = wordpoints_int( $id );
40
+		$this->ID    = wordpoints_int($id);
41 41
 		$this->store = $store;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @since 1.0.0
46 46
 	 */
47
-	public function __get( $var ) {
47
+	public function __get($var) {
48 48
 
49
-		if ( 'ID' === $var ) {
49
+		if ('ID' === $var) {
50 50
 			return $this->ID;
51 51
 		}
52 52
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @since 1.0.0
70 70
 	 */
71 71
 	public function get_reactor_slug() {
72
-		return $this->get_meta( 'reactor' ); // TODO remove this method?
72
+		return $this->get_meta('reactor'); // TODO remove this method?
73 73
 	}
74 74
 
75 75
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/validator.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 	 * @param bool                            $fail_fast Whether to fail as soon as
104 104
 	 *                                                   the first error is found.
105 105
 	 */
106
-	public function __construct( $settings, $fail_fast = false ) {
106
+	public function __construct($settings, $fail_fast = false) {
107 107
 
108 108
 		$this->fail_fast = $fail_fast;
109 109
 		$this->hooks = wordpoints_hooks();
110 110
 
111
-		if ( $settings instanceof WordPoints_Hook_ReactionI ) {
111
+		if ($settings instanceof WordPoints_Hook_ReactionI) {
112 112
 
113 113
 			$this->reaction     = $settings;
114 114
 			$this->settings     = $this->reaction->get_all_meta();
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
 			$this->settings = $settings;
121 121
 
122
-			if ( isset( $this->settings['event'] ) ) {
122
+			if (isset($this->settings['event'])) {
123 123
 				$this->event_slug = $this->settings['event'];
124 124
 			}
125 125
 
126
-			if ( isset( $this->settings['reactor'] ) ) {
126
+			if (isset($this->settings['reactor'])) {
127 127
 				$this->reactor_slug = $this->settings['reactor'];
128 128
 			}
129 129
 		}
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 			$fail_fast = $this->fail_fast;
147 147
 			$this->fail_fast = true;
148 148
 
149
-			if ( ! isset( $this->event_slug ) ) {
150
-				$this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' );
151
-			} elseif ( ! $this->hooks->events->is_registered( $this->event_slug ) ) {
152
-				$this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' );
149
+			if ( ! isset($this->event_slug)) {
150
+				$this->add_error(__('Event is missing.', 'wordpoints'), 'event');
151
+			} elseif ( ! $this->hooks->events->is_registered($this->event_slug)) {
152
+				$this->add_error(__('Event is invalid.', 'wordpoints'), 'event');
153 153
 			}
154 154
 
155
-			if ( ! isset( $this->reactor_slug ) ) {
156
-				$this->add_error( __( 'Reactor is missing.', 'wordpoints' ), 'reactor' );
157
-			} elseif ( ! $this->hooks->reactors->is_registered( $this->reactor_slug ) ) {
158
-				$this->add_error( __( 'Reactor is invalid.', 'wordpoints' ), 'reactor' );
155
+			if ( ! isset($this->reactor_slug)) {
156
+				$this->add_error(__('Reactor is missing.', 'wordpoints'), 'reactor');
157
+			} elseif ( ! $this->hooks->reactors->is_registered($this->reactor_slug)) {
158
+				$this->add_error(__('Reactor is invalid.', 'wordpoints'), 'reactor');
159 159
 			}
160 160
 
161 161
 			// From here on out we can collect errors as they come (unless we are
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 				$this->event_slug
167 167
 			);
168 168
 
169
-			$this->event_args = new WordPoints_Hook_Event_Args( $event_args );
170
-			$this->event_args->set_validator( $this );
169
+			$this->event_args = new WordPoints_Hook_Event_Args($event_args);
170
+			$this->event_args->set_validator($this);
171 171
 
172
-			$reactor = $this->hooks->reactors->get( $this->reactor_slug );
172
+			$reactor = $this->hooks->reactors->get($this->reactor_slug);
173 173
 
174
-			$this->settings = $reactor->validate_settings( $this->settings, $this, $this->event_args );
174
+			$this->settings = $reactor->validate_settings($this->settings, $this, $this->event_args);
175 175
 
176 176
 			/** @var WordPoints_Hook_Extension $extension */
177
-			foreach ( $this->hooks->extensions->get_all() as $extension ) {
178
-				$this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args );
177
+			foreach ($this->hooks->extensions->get_all() as $extension) {
178
+				$this->settings = $extension->validate_settings($this->settings, $this, $this->event_args);
179 179
 			}
180 180
 
181 181
 			/**
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 			 * @param WordPoints_Hook_Reaction_Validator $validator The validator object.
186 186
 			 * @param WordPoints_Hook_Event_Args         $args      The event args object.
187 187
 			 */
188
-			$this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args );
188
+			$this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args);
189 189
 
190
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
190
+		} catch (WordPoints_Hook_Validator_Exception $e) {
191 191
 
192 192
 			// Do nothing.
193
-			unset( $e );
193
+			unset($e);
194 194
 		}
195 195
 
196 196
 		return $this->settings;
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	 * @throws WordPoints_Hook_Validator_Exception If the validator is configured to
219 219
 	 *                                             fail as soon as an error is found.
220 220
 	 */
221
-	public function add_error( $message, $field = null ) {
221
+	public function add_error($message, $field = null) {
222 222
 
223 223
 		$field_stack = $this->field_stack;
224 224
 
225
-		if ( null !== $field ) {
225
+		if (null !== $field) {
226 226
 			$field_stack[] = $field;
227 227
 		}
228 228
 
229
-		$this->errors[] = array( 'message' => $message, 'field' => $field_stack );
229
+		$this->errors[] = array('message' => $message, 'field' => $field_stack);
230 230
 
231
-		if ( $this->fail_fast ) {
231
+		if ($this->fail_fast) {
232 232
 			throw new WordPoints_Hook_Validator_Exception;
233 233
 		}
234 234
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @return bool Whether the validator found any errors.
242 242
 	 */
243 243
 	public function had_errors() {
244
-		return ! empty( $this->errors );
244
+		return ! empty($this->errors);
245 245
 	}
246 246
 
247 247
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @param string $field The field.
264 264
 	 */
265
-	public function push_field( $field ) {
265
+	public function push_field($field) {
266 266
 		$this->field_stack[] = $field;
267 267
 	}
268 268
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @since 1.0.0
273 273
 	 */
274 274
 	public function pop_field() {
275
-		array_pop( $this->field_stack );
275
+		array_pop($this->field_stack);
276 276
 	}
277 277
 
278 278
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function get_id() {
319 319
 
320
-		if ( ! $this->reaction ) {
320
+		if ( ! $this->reaction) {
321 321
 			return false;
322 322
 		}
323 323
 
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return mixed The meta value.
357 357
 	 */
358
-	public function get_meta( $key ) {
358
+	public function get_meta($key) {
359 359
 
360
-		if ( ! isset( $this->settings[ $key ] ) ) {
360
+		if ( ! isset($this->settings[$key])) {
361 361
 			return null;
362 362
 		}
363 363
 
364
-		return $this->settings[ $key ];
364
+		return $this->settings[$key];
365 365
 	}
366 366
 
367 367
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/storei.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param string $slug The slug of this store.
26 26
 	 */
27
-	public function __construct( $slug );
27
+	public function __construct($slug);
28 28
 
29 29
 	/**
30 30
 	 * Get the slug of this reaction store.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return bool Whether the reaction exists.
61 61
 	 */
62
-	public function reaction_exists( $id );
62
+	public function reaction_exists($id);
63 63
 
64 64
 	/**
65 65
 	 * Get an reaction object.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return WordPoints_Hook_ReactionI|false The reaction, or false if nonexistent.
72 72
 	 */
73
-	public function get_reaction( $id );
73
+	public function get_reaction($id);
74 74
 
75 75
 	/**
76 76
 	 * Create an reaction.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *         The reaction object if created successfully. False or a validator
84 84
 	 *         instance if not.
85 85
 	 */
86
-	public function create_reaction( array $settings );
86
+	public function create_reaction(array $settings);
87 87
 
88 88
 	/**
89 89
 	 * Update an reaction.
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *         The reaction object if updated successfully. False or a validator
98 98
 	 *         instance if not.
99 99
 	 */
100
-	public function update_reaction( $id, array $settings );
100
+	public function update_reaction($id, array $settings);
101 101
 
102 102
 	/**
103 103
 	 * Delete an reaction.
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool Whether the reaction was deleted successfully.
110 110
 	 */
111
-	public function delete_reaction( $id );
111
+	public function delete_reaction($id);
112 112
 
113 113
 	/**
114 114
 	 * Get all hook reactions for the reactor.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return WordPoints_Hook_ReactionI[]
133 133
 	 */
134
-	public function get_reactions_to_event( $event_slug );
134
+	public function get_reactions_to_event($event_slug);
135 135
 }
136 136
 
137 137
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/entity/comment/post.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	protected function get_related_entity_ids( WordPoints_Entity $entity ) {
41
-		return $entity->get_the_attr_value( $this->related_ids_field );
40
+	protected function get_related_entity_ids(WordPoints_Entity $entity) {
41
+		return $entity->get_the_attr_value($this->related_ids_field);
42 42
 	}
43 43
 	
44 44
 	/**
Please login to merge, or discard this patch.
src/admin/includes/functions.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @param WordPoints_App $app The main WordPoints app.
18 18
  */
19
-function wordpoints_hooks_register_admin_apps( $app ) {
19
+function wordpoints_hooks_register_admin_apps($app) {
20 20
 
21 21
 	$apps = $app->sub_apps;
22 22
 
23
-	$apps->register( 'admin', 'WordPoints_App' );
23
+	$apps->register('admin', 'WordPoints_App');
24 24
 
25 25
 	/** @var WordPoints_App $admin */
26
-	$admin = $apps->get( 'admin' );
26
+	$admin = $apps->get('admin');
27 27
 
28
-	$admin->sub_apps->register( 'screen', 'WordPoints_Admin_Screens' );
28
+	$admin->sub_apps->register('screen', 'WordPoints_Admin_Screens');
29 29
 }
30 30
 
31 31
 /**
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	// Hooks page.
47 47
 	$id = add_submenu_page(
48 48
 		$wordpoints_menu
49
-		, __( 'WordPoints — Points Types', 'wordpoints' )
50
-		, __( 'Points Types', 'wordpoints' )
49
+		, __('WordPoints — Points Types', 'wordpoints')
50
+		, __('Points Types', 'wordpoints')
51 51
 		, 'manage_options'
52 52
 		, 'wordpoints_points_types'
53
-		, array( $admin_screens, 'display' )
53
+		, array($admin_screens, 'display')
54 54
 	);
55 55
 
56
-	if ( $id ) {
57
-		$admin_screens->register( $id, 'WordPoints_Admin_Screen_Points_Types' );
56
+	if ($id) {
57
+		$admin_screens->register($id, 'WordPoints_Admin_Screen_Points_Types');
58 58
 	}
59 59
 }
60 60
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function wordpoints_hooks_admin_register_scripts() {
69 69
 
70
-	$assets_url = wordpoints_modules_url( '/assets', dirname( __FILE__ ) );
70
+	$assets_url = wordpoints_modules_url('/assets', dirname(__FILE__));
71 71
 
72 72
 	// CSS
73 73
 
74 74
 	wp_register_style(
75 75
 		'wordpoints-hooks-admin'
76
-		, $assets_url . '/css/hooks.css'
77
-		, array( 'dashicons', 'wp-jquery-ui-dialog' )
76
+		, $assets_url.'/css/hooks.css'
77
+		, array('dashicons', 'wp-jquery-ui-dialog')
78 78
 		, WORDPOINTS_VERSION
79 79
 	);
80 80
 
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 
83 83
 	wp_register_script(
84 84
 		'wordpoints-hooks-models'
85
-		, $assets_url . '/js/hooks/models.js'
86
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
85
+		, $assets_url.'/js/hooks/models.js'
86
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
87 87
 		, WORDPOINTS_VERSION
88 88
 	);
89 89
 
90 90
 	wp_register_script(
91 91
 		'wordpoints-hooks-views'
92
-		, $assets_url . '/js/hooks/views.js'
93
-		, array( 'wordpoints-hooks-models' )
92
+		, $assets_url.'/js/hooks/views.js'
93
+		, array('wordpoints-hooks-models')
94 94
 		, WORDPOINTS_VERSION
95 95
 	);
96 96
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 		'wordpoints-hooks-views'
99 99
 		, 'WordPointsHooksAdminL10n'
100 100
 		, array(
101
-			'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
102
-			'changesSaved'    => __( 'Your changes have been saved.', 'wordpoints' ),
101
+			'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
102
+			'changesSaved'    => __('Your changes have been saved.', 'wordpoints'),
103 103
 			/* translators: the name of the field that cannot be empty */
104
-			'emptyField'      => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ),
105
-			'confirmDelete'   => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ),
106
-			'confirmTitle'    => __( 'Are you sure?', 'wordpoints' ),
107
-			'deleteText'      => __( 'Delete', 'wordpoints' ),
108
-			'cancelText'      => __( 'Cancel', 'wordpoints' ),
109
-			'separator'       => __( ' » ', 'wordpoints' ),
110
-			'target_label'    => __( 'Target', 'wordpoints' ),
104
+			'emptyField'      => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'),
105
+			'confirmDelete'   => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'),
106
+			'confirmTitle'    => __('Are you sure?', 'wordpoints'),
107
+			'deleteText'      => __('Delete', 'wordpoints'),
108
+			'cancelText'      => __('Cancel', 'wordpoints'),
109
+			'separator'       => __(' » ', 'wordpoints'),
110
+			'target_label'    => __('Target', 'wordpoints'),
111 111
 		)
112 112
 	);
113 113
 
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 			<div class="view">
120 120
 				<div class="title"></div>
121 121
 				<button type="button" class="edit button-secondary">
122
-					' . esc_html__( 'Edit', 'wordpoints' ) . '
122
+					' . esc_html__('Edit', 'wordpoints').'
123 123
 				</button>
124 124
 				<button type="button" class="close button-secondary">
125
-					' . esc_html__( 'Close', 'wordpoints' ) . '
125
+					' . esc_html__('Close', 'wordpoints').'
126 126
 				</button>
127 127
 			</div>
128 128
 			<div class="form">
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 						</div>
142 142
 						<div class="action-buttons">
143 143
 							<button type="button" class="save button-primary" disabled>
144
-								' . esc_html__( 'Save', 'wordpoints' ) . '
144
+								' . esc_html__('Save', 'wordpoints').'
145 145
 							</button>
146 146
 							<button type="button" class="cancel button-secondary">
147
-								' . esc_html__( 'Cancel', 'wordpoints' ) . '
147
+								' . esc_html__('Cancel', 'wordpoints').'
148 148
 							</button>
149 149
 							<button type="button" class="close button-secondary">
150
-								' . esc_html__( 'Close', 'wordpoints' ) . '
150
+								' . esc_html__('Close', 'wordpoints').'
151 151
 							</button>
152 152
 							<button type="button" class="delete button-secondary">
153
-								' . esc_html__( 'Delete', 'wordpoints' ) . '
153
+								' . esc_html__('Delete', 'wordpoints').'
154 154
 							</button>
155 155
 						</div>
156 156
 					</div>
@@ -198,15 +198,15 @@  discard block
 block discarded – undo
198 198
 
199 199
 	wp_register_script(
200 200
 		'wordpoints-hooks-reactor-points'
201
-		, $assets_url . '/js/hooks/reactors/points.js'
202
-		, array( 'wordpoints-hooks-views' )
201
+		, $assets_url.'/js/hooks/reactors/points.js'
202
+		, array('wordpoints-hooks-views')
203 203
 		, WORDPOINTS_VERSION
204 204
 	);
205 205
 
206 206
 	wp_register_script(
207 207
 		'wordpoints-hooks-extension-conditions'
208
-		, $assets_url . '/js/hooks/extensions/conditions.js'
209
-		, array( 'wordpoints-hooks-views' )
208
+		, $assets_url.'/js/hooks/extensions/conditions.js'
209
+		, array('wordpoints-hooks-views')
210 210
 		, WORDPOINTS_VERSION
211 211
 	);
212 212
 
@@ -216,25 +216,25 @@  discard block
 block discarded – undo
216 216
 		, '
217 217
 			<script type="text/template" id="tmpl-wordpoints-hook-condition-groups">
218 218
 				<div class="conditions-title section-title">
219
-					<h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4>
219
+					<h4>' . esc_html__('Conditions', 'wordpoints').'</h4>
220 220
 					<button type="button" class="add-new button-secondary button-link">
221
-						<span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span>
221
+						<span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span>
222 222
 						<span class="dashicons dashicons-plus"></span>
223 223
 					</button>
224 224
 				</div>
225 225
 				<div class="add-condition-form hidden">
226 226
 					<div class="no-conditions hidden">
227
-						' . esc_html__( 'No conditions available.', 'wordpoints' ) . '
227
+						' . esc_html__('No conditions available.', 'wordpoints').'
228 228
 					</div>
229 229
 					<div class="condition-selectors">
230 230
 						<div class="arg-selectors"></div>
231 231
 						<div class="condition-selector"></div>
232 232
 					</div>
233
-					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '">
234
-						' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . '
233
+					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'">
234
+						' . esc_html_x('Add', 'reaction condition', 'wordpoints').'
235 235
 					</button>
236
-					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '">
237
-						' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . '
236
+					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'">
237
+						' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').'
238 238
 					</button>
239 239
 				</div>
240 240
 				<div class="condition-groups section-content"></div>
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 				<div class="condition-controls">
249 249
 					<div class="condition-title"></div>
250 250
 					<button type="button" class="delete button-secondary button-link">
251
-						<span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span>
251
+						<span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span>
252 252
 						<span class="dashicons dashicons-no"></span>
253 253
 					</button>
254 254
 				</div>
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 
267 267
 	wp_register_script(
268 268
 		'wordpoints-hooks-extension-periods'
269
-		, $assets_url . '/js/hooks/extensions/periods.js'
270
-		, array( 'wordpoints-hooks-views' )
269
+		, $assets_url.'/js/hooks/extensions/periods.js'
270
+		, array('wordpoints-hooks-views')
271 271
 		, WORDPOINTS_VERSION
272 272
 	);
273 273
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		, '
278 278
 			<script type="text/template" id="tmpl-wordpoints-hook-periods">
279 279
 				<div class="periods-title section-title">
280
-					<h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4>
280
+					<h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4>
281 281
 				</div>
282 282
 				<div class="periods section-content"></div>
283 283
 			</script>
@@ -296,33 +296,33 @@  discard block
 block discarded – undo
296 296
 
297 297
 	$extensions_data = array();
298 298
 
299
-	foreach ( $hooks->extensions->get_all() as $slug => $extension ) {
299
+	foreach ($hooks->extensions->get_all() as $slug => $extension) {
300 300
 
301
-		if ( $extension instanceof WordPoints_Hook_Extension ) {
302
-			$extensions_data[ $slug ] = $extension->get_ui_script_data();
301
+		if ($extension instanceof WordPoints_Hook_Extension) {
302
+			$extensions_data[$slug] = $extension->get_ui_script_data();
303 303
 		}
304 304
 
305
-		if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) {
306
-			wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" );
305
+		if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) {
306
+			wp_enqueue_script("wordpoints-hooks-extension-{$slug}");
307 307
 		}
308 308
 	}
309 309
 
310
-	unset( $extension, $slug );
310
+	unset($extension, $slug);
311 311
 
312 312
 	$reactor_data = array();
313 313
 
314
-	foreach ( $hooks->reactors->get_all() as $slug => $reactor ) {
314
+	foreach ($hooks->reactors->get_all() as $slug => $reactor) {
315 315
 
316
-		if ( $reactor instanceof WordPoints_Hook_Reactor ) {
317
-			$reactor_data[ $slug ] = $reactor->get_ui_script_data();
316
+		if ($reactor instanceof WordPoints_Hook_Reactor) {
317
+			$reactor_data[$slug] = $reactor->get_ui_script_data();
318 318
 		}
319 319
 
320
-		if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) {
321
-			wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" );
320
+		if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) {
321
+			wp_enqueue_script("wordpoints-hooks-reactor-{$slug}");
322 322
 		}
323 323
 	}
324 324
 
325
-	unset( $reactor, $slug );
325
+	unset($reactor, $slug);
326 326
 
327 327
 	$event_action_types = wordpoints_hooks_ui_get_script_data_event_action_types();
328 328
 	$entities_data = wordpoints_hooks_ui_get_script_data_entities();
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @param array $data The data.
348 348
 	 */
349
-	$data = apply_filters( 'wordpoints_hooks_ui_data', $data );
349
+	$data = apply_filters('wordpoints_hooks_ui_data', $data);
350 350
 
351 351
 	wp_localize_script(
352 352
 		'wordpoints-hooks-models'
@@ -372,28 +372,28 @@  discard block
 block discarded – undo
372 372
 	$entity_children = $entities->children;
373 373
 
374 374
 	/** @var WordPoints_Entity $entity */
375
-	foreach ( $entities->get_all() as $slug => $entity ) {
375
+	foreach ($entities->get_all() as $slug => $entity) {
376 376
 
377 377
 		$child_data = array();
378 378
 
379 379
 		/** @var WordPoints_EntityishI $child */
380
-		foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) {
380
+		foreach ($entity_children->get_children($slug) as $child_slug => $child) {
381 381
 
382
-			$child_data[ $child_slug ] = array(
382
+			$child_data[$child_slug] = array(
383 383
 				'slug'  => $child_slug,
384 384
 				'title' => $child->get_title(),
385 385
 			);
386 386
 
387
-			if ( $child instanceof WordPoints_Entity_Attr ) {
387
+			if ($child instanceof WordPoints_Entity_Attr) {
388 388
 
389
-				$child_data[ $child_slug ]['_type']     = 'attr';
390
-				$child_data[ $child_slug ]['data_type'] = $child->get_data_type();
389
+				$child_data[$child_slug]['_type']     = 'attr';
390
+				$child_data[$child_slug]['data_type'] = $child->get_data_type();
391 391
 
392
-			} elseif ( $child instanceof WordPoints_Entity_Relationship ) {
392
+			} elseif ($child instanceof WordPoints_Entity_Relationship) {
393 393
 
394
-				$child_data[ $child_slug ]['_type']     = 'relationship';
395
-				$child_data[ $child_slug ]['primary']   = $child->get_primary_entity_slug();
396
-				$child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug();
394
+				$child_data[$child_slug]['_type']     = 'relationship';
395
+				$child_data[$child_slug]['primary']   = $child->get_primary_entity_slug();
396
+				$child_data[$child_slug]['secondary'] = $child->get_related_entity_slug();
397 397
 			}
398 398
 
399 399
 			/**
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
 			 * @param array                $data  The data for the entity child.
405 405
 			 * @param WordPoints_Entityish $child The child's object.
406 406
 			 */
407
-			$child_data[ $child_slug ] = apply_filters(
407
+			$child_data[$child_slug] = apply_filters(
408 408
 				'wordpoints_hooks_ui_data_entity_child'
409
-				, $child_data[ $child_slug ]
409
+				, $child_data[$child_slug]
410 410
 				, $child
411 411
 			);
412 412
 		}
413 413
 
414
-		$entities_data[ $slug ] = array(
414
+		$entities_data[$slug] = array(
415 415
 			'slug'     => $slug,
416 416
 			'title'    => $entity->get_title(),
417 417
 			'children' => $child_data,
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
 			'_type'    => 'entity',
420 420
 		);
421 421
 
422
-		if ( $entity instanceof WordPoints_Entity_EnumerableI ) {
422
+		if ($entity instanceof WordPoints_Entity_EnumerableI) {
423 423
 
424 424
 			$values = array();
425 425
 
426
-			foreach ( $entity->get_enumerated_values() as $value ) {
427
-				if ( $entity->set_the_value( $value ) ) {
426
+			foreach ($entity->get_enumerated_values() as $value) {
427
+				if ($entity->set_the_value($value)) {
428 428
 					$values[] = array(
429 429
 						'value' => $entity->get_the_id(),
430 430
 						'label' => $entity->get_the_human_id(),
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 				}
433 433
 			}
434 434
 
435
-			$entities_data[ $slug ]['values'] = $values;
435
+			$entities_data[$slug]['values'] = $values;
436 436
 		}
437 437
 
438 438
 		/**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 		 * @param array             $data   The data for the entity.
442 442
 		 * @param WordPoints_Entity $entity The entity object.
443 443
 		 */
444
-		$entities_data[ $slug ] = apply_filters(
444
+		$entities_data[$slug] = apply_filters(
445 445
 			'wordpoints_hooks_ui_data_entity'
446
-			, $entities_data[ $slug ]
446
+			, $entities_data[$slug]
447 447
 			, $entity
448 448
 		);
449 449
 	}
@@ -467,15 +467,15 @@  discard block
 block discarded – undo
467 467
 
468 468
 	// We don't care about the action slugs, so first we get rid of that bottom level
469 469
 	// of the array.
470
-	$event_index = call_user_func_array( 'array_merge_recursive', $event_index );
470
+	$event_index = call_user_func_array('array_merge_recursive', $event_index);
471 471
 
472 472
 	$event_action_types = array();
473 473
 
474 474
 	// This leaves us the event indexed by action type. But we actually need to flip
475 475
 	// this, so that we have the action types indexed by event slug.
476
-	foreach ( $event_index as $action_type => $events ) {
477
-		foreach ( $events as $event => $unused ) {
478
-			$event_action_types[ $event ][ $action_type ] = true;
476
+	foreach ($event_index as $action_type => $events) {
477
+		foreach ($events as $event => $unused) {
478
+			$event_action_types[$event][$action_type] = true;
479 479
 		}
480 480
 	}
481 481
 
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
  *
499 499
  * @return string The HTML with templates appended.
500 500
  */
501
-function wordpoints_script_templates_filter( $html, $handle ) {
501
+function wordpoints_script_templates_filter($html, $handle) {
502 502
 
503 503
 	global $wp_scripts;
504 504
 
505
-	$templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' );
505
+	$templates = $wp_scripts->get_data($handle, 'wordpoints-templates');
506 506
 
507
-	if ( $templates ) {
507
+	if ($templates) {
508 508
 		$html .= $templates;
509 509
 	}
510 510
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
  */
521 521
 function wordpoints_hooks_admin_ajax() {
522 522
 
523
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
523
+	if (defined('DOING_AJAX') && DOING_AJAX) {
524 524
 		new WordPoints_Admin_Ajax_Hooks;
525 525
 	}
526 526
 }
Please login to merge, or discard this patch.
src/includes/classes/hook/events.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function __construct( $slug ) {
40
+	public function __construct($slug) {
41 41
 
42 42
 		$hooks = wordpoints_hooks();
43 43
 
44 44
 		$this->router = $hooks->router;
45 45
 
46
-		parent::__construct( $slug );
46
+		parent::__construct($slug);
47 47
 	}
48 48
 
49 49
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function init() {
53 53
 
54
-		$this->sub_apps->register( 'args', 'WordPoints_Class_Registry_Children' );
54
+		$this->sub_apps->register('args', 'WordPoints_Class_Registry_Children');
55 55
 
56 56
 		parent::init();
57 57
 	}
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return bool Whether the event was registered.
77 77
 	 */
78
-	public function register( $slug, $class, array $args = array() ) {
78
+	public function register($slug, $class, array $args = array()) {
79 79
 
80
-		parent::register( $slug, $class, $args );
80
+		parent::register($slug, $class, $args);
81 81
 
82
-		if ( isset( $args['actions'] ) ) {
83
-			foreach ( $args['actions'] as $type => $actions ) {
84
-				foreach ( (array) $actions as $action_slug ) {
85
-					$this->router->add_event_to_action( $slug, $action_slug, $type );
82
+		if (isset($args['actions'])) {
83
+			foreach ($args['actions'] as $type => $actions) {
84
+				foreach ((array) $actions as $action_slug) {
85
+					$this->router->add_event_to_action($slug, $action_slug, $type);
86 86
 				}
87 87
 			}
88 88
 		}
89 89
 
90
-		if ( isset( $args['args'] ) ) {
91
-			foreach ( $args['args'] as $arg_slug => $class ) {
92
-				$this->args->register( $slug, $arg_slug, $class );
90
+		if (isset($args['args'])) {
91
+			foreach ($args['args'] as $arg_slug => $class) {
92
+				$this->args->register($slug, $arg_slug, $class);
93 93
 			}
94 94
 		}
95 95
 
96
-		$this->event_data[ $slug ] = $args;
96
+		$this->event_data[$slug] = $args;
97 97
 
98 98
 		return true;
99 99
 	}
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @since 1.0.0
103 103
 	 */
104
-	public function deregister( $slug ) {
104
+	public function deregister($slug) {
105 105
 
106
-		if ( ! $this->is_registered( $slug ) ) {
106
+		if ( ! $this->is_registered($slug)) {
107 107
 			return;
108 108
 		}
109 109
 
110
-		parent::deregister( $slug );
110
+		parent::deregister($slug);
111 111
 
112
-		foreach ( (array) $this->event_data[ $slug ]['actions'] as $type => $actions ) {
113
-			foreach ( (array) $actions as $action_slug ) {
114
-				$this->router->remove_event_from_action( $slug, $action_slug, $type );
112
+		foreach ((array) $this->event_data[$slug]['actions'] as $type => $actions) {
113
+			foreach ((array) $actions as $action_slug) {
114
+				$this->router->remove_event_from_action($slug, $action_slug, $type);
115 115
 			}
116 116
 		}
117 117
 
118
-		$this->args->deregister_children( $slug );
118
+		$this->args->deregister_children($slug);
119 119
 
120
-		unset( $this->event_data[ $slug ] );
120
+		unset($this->event_data[$slug]);
121 121
 	}
122 122
 }
123 123
 
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/periods.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	public function get_ui_script_data() {
37 37
 
38 38
 		$periods = array(
39
-			MINUTE_IN_SECONDS   => __( 'Minute', 'wordpoints' ),
40
-			HOUR_IN_SECONDS     => __( 'Hour',   'wordpoints' ),
41
-			DAY_IN_SECONDS      => __( 'Day',    'wordpoints' ),
42
-			WEEK_IN_SECONDS     => __( 'Week',   'wordpoints' ),
43
-			30 * DAY_IN_SECONDS => __( 'Month',  'wordpoints' ),
39
+			MINUTE_IN_SECONDS   => __('Minute', 'wordpoints'),
40
+			HOUR_IN_SECONDS     => __('Hour', 'wordpoints'),
41
+			DAY_IN_SECONDS      => __('Day', 'wordpoints'),
42
+			WEEK_IN_SECONDS     => __('Week', 'wordpoints'),
43
+			30 * DAY_IN_SECONDS => __('Month', 'wordpoints'),
44 44
 		);
45 45
 
46 46
 		/**
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		 *
51 51
 		 * @param string[] $periods The period titles, indexed by length in seconds.
52 52
 		 */
53
-		$periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods );
53
+		$periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods);
54 54
 
55 55
 		return array(
56 56
 			'periods' => $periods,
57 57
 			'l10n' => array(
58
-				'label' => __( 'Trigger reaction no more than once per:', 'wordpoints' ),
58
+				'label' => __('Trigger reaction no more than once per:', 'wordpoints'),
59 59
 			),
60 60
 		);
61 61
 	}
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return array The validated periods.
71 71
 	 */
72
-	protected function validate_action_type_settings( $periods ) {
72
+	protected function validate_action_type_settings($periods) {
73 73
 
74
-		if ( ! is_array( $periods ) ) {
74
+		if ( ! is_array($periods)) {
75 75
 
76 76
 			$this->validator->add_error(
77
-				__( 'Periods do not match expected format.', 'wordpoints' )
77
+				__('Periods do not match expected format.', 'wordpoints')
78 78
 			);
79 79
 
80 80
 			return array();
81 81
 		}
82 82
 
83
-		foreach ( $periods as $index => $period ) {
83
+		foreach ($periods as $index => $period) {
84 84
 
85
-			$this->validator->push_field( $index );
85
+			$this->validator->push_field($index);
86 86
 
87
-			$period = $this->validate_period( $period );
87
+			$period = $this->validate_period($period);
88 88
 
89
-			if ( $period ) {
90
-				$periods[ $index ] = $period;
89
+			if ($period) {
90
+				$periods[$index] = $period;
91 91
 			}
92 92
 
93 93
 			$this->validator->pop_field();
@@ -105,30 +105,30 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return array|false The validated period, or false if invalid.
107 107
 	 */
108
-	protected function validate_period( $period ) {
108
+	protected function validate_period($period) {
109 109
 
110
-		if ( ! is_array( $period ) ) {
110
+		if ( ! is_array($period)) {
111 111
 			$this->validator->add_error(
112
-				__( 'Period does not match expected format.', 'wordpoints' )
112
+				__('Period does not match expected format.', 'wordpoints')
113 113
 			);
114 114
 
115 115
 			return false;
116 116
 		}
117 117
 
118
-		if ( isset( $period['args'] ) ) {
119
-			$this->validate_period_args( $period['args'] );
118
+		if (isset($period['args'])) {
119
+			$this->validate_period_args($period['args']);
120 120
 		}
121 121
 
122
-		if ( ! isset( $period['length'] ) ) {
122
+		if ( ! isset($period['length'])) {
123 123
 
124 124
 			$this->validator->add_error(
125
-				__( 'Period length setting is missing.', 'wordpoints' )
125
+				__('Period length setting is missing.', 'wordpoints')
126 126
 			);
127 127
 
128
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
128
+		} elseif (false === wordpoints_posint($period['length'])) {
129 129
 
130 130
 			$this->validator->add_error(
131
-				__( 'Period length must be a positive integer.', 'wordpoints' )
131
+				__('Period length must be a positive integer.', 'wordpoints')
132 132
 				, 'length'
133 133
 			);
134 134
 
@@ -145,34 +145,34 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param mixed $args The args the period is related to.
147 147
 	 */
148
-	protected function validate_period_args( $args ) {
148
+	protected function validate_period_args($args) {
149 149
 
150
-		if ( ! is_array( $args ) ) {
150
+		if ( ! is_array($args)) {
151 151
 
152 152
 			$this->validator->add_error(
153
-				__( 'Period does not match expected format.', 'wordpoints' )
153
+				__('Period does not match expected format.', 'wordpoints')
154 154
 				, 'args'
155 155
 			);
156 156
 
157 157
 			return;
158 158
 		}
159 159
 
160
-		$this->validator->push_field( 'args' );
160
+		$this->validator->push_field('args');
161 161
 
162
-		foreach ( $args as $index => $hierarchy ) {
162
+		foreach ($args as $index => $hierarchy) {
163 163
 
164
-			$this->validator->push_field( $index );
164
+			$this->validator->push_field($index);
165 165
 
166
-			if ( ! is_array( $hierarchy ) ) {
166
+			if ( ! is_array($hierarchy)) {
167 167
 
168 168
 				$this->validator->add_error(
169
-					__( 'Period does not match expected format.', 'wordpoints' )
169
+					__('Period does not match expected format.', 'wordpoints')
170 170
 				);
171 171
 
172
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
172
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
173 173
 
174 174
 				$this->validator->add_error(
175
-					__( 'Invalid period.', 'wordpoints' ) // TODO better error message
175
+					__('Invalid period.', 'wordpoints') // TODO better error message
176 176
 				);
177 177
 			}
178 178
 
@@ -185,19 +185,19 @@  discard block
 block discarded – undo
185 185
 	/**
186 186
 	 * @since 1.0.0
187 187
 	 */
188
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
188
+	public function should_hit(WordPoints_Hook_Fire $fire) {
189 189
 
190
-		$periods = $this->get_settings_from_fire( $fire );
190
+		$periods = $this->get_settings_from_fire($fire);
191 191
 
192
-		if ( empty( $periods ) ) {
192
+		if (empty($periods)) {
193 193
 			return true;
194 194
 		}
195 195
 
196 196
 		$this->event_args = $fire->event_args;
197 197
 		$this->action_type = $fire->action_type;
198 198
 
199
-		foreach ( $periods as $period ) {
200
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
199
+		foreach ($periods as $period) {
200
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
201 201
 				return false;
202 202
 			}
203 203
 		}
@@ -221,24 +221,24 @@  discard block
 block discarded – undo
221 221
 	) {
222 222
 
223 223
 		$period = $this->get_period_by_reaction(
224
-			$this->get_period_signature( $settings, $reaction )
224
+			$this->get_period_signature($settings, $reaction)
225 225
 			, $reaction
226 226
 		);
227 227
 
228 228
 		// If the period isn't found, we know that we can still fire.
229
-		if ( ! $period ) {
229
+		if ( ! $period) {
230 230
 			return true;
231 231
 		}
232 232
 
233
-		$now = current_time( 'timestamp' );
234
-		$hit_time = strtotime( $period->date, $now );
233
+		$now = current_time('timestamp');
234
+		$hit_time = strtotime($period->date, $now);
235 235
 
236
-		if ( ! empty( $settings['relative'] ) ) {
237
-			return ( $hit_time < $now - $settings['length'] );
236
+		if ( ! empty($settings['relative'])) {
237
+			return ($hit_time < $now - $settings['length']);
238 238
 		} else {
239 239
 			return (
240
-				(int) ( $hit_time / $settings['length'] )
241
-				< (int) ( $now / $settings['length'] )
240
+				(int) ($hit_time / $settings['length'])
241
+				< (int) ($now / $settings['length'])
242 242
 			);
243 243
 		}
244 244
 	}
@@ -252,24 +252,24 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return array The arg values.
254 254
 	 */
255
-	protected function get_arg_values( array $period_args ) {
255
+	protected function get_arg_values(array $period_args) {
256 256
 
257 257
 		$values = array();
258 258
 
259
-		foreach ( $period_args as $arg_hierarchy ) {
259
+		foreach ($period_args as $arg_hierarchy) {
260 260
 
261 261
 			$arg = $this->event_args->get_from_hierarchy(
262 262
 				$arg_hierarchy
263 263
 			);
264 264
 
265
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
265
+			if ( ! $arg instanceof WordPoints_EntityishI) {
266 266
 				continue;
267 267
 			}
268 268
 
269
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
269
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
270 270
 		}
271 271
 
272
-		ksort( $values );
272
+		ksort($values);
273 273
 
274 274
 		return $values;
275 275
 	}
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @return object|false The period data, or false if not found.
285 285
 	 */
286
-	protected function get_period( $period_id ) {
286
+	protected function get_period($period_id) {
287 287
 
288
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_periods' );
288
+		$period = wp_cache_get($period_id, 'wordpoints_hook_periods');
289 289
 
290
-		if ( ! $period ) {
290
+		if ( ! $period) {
291 291
 
292 292
 			global $wpdb;
293 293
 
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 				)
305 305
 			);
306 306
 
307
-			if ( ! $period ) {
307
+			if ( ! $period) {
308 308
 				return false;
309 309
 			}
310 310
 
311
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
311
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
312 312
 		}
313 313
 
314 314
 		return $period;
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 
333 333
 		$reaction_guid = $reaction->get_guid();
334 334
 
335
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}-{$this->action_type}";
335
+		$cache_key = wp_json_encode($reaction_guid)."-{$signature}-{$this->action_type}";
336 336
 
337 337
 		// Before we run the query, we try to lookup the ID in the cache.
338
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' );
338
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction');
339 339
 
340 340
 		// If we found it, we can retrieve the period by ID instead.
341
-		if ( $period_id ) {
342
-			return $this->get_period( $period_id );
341
+		if ($period_id) {
342
+			return $this->get_period($period_id);
343 343
 		}
344 344
 
345 345
 		global $wpdb;
@@ -362,18 +362,18 @@  discard block
 block discarded – undo
362 362
 				"
363 363
 				, $signature
364 364
 				, $reaction_guid['store']
365
-				, wp_json_encode( $reaction_guid['context_id'] )
365
+				, wp_json_encode($reaction_guid['context_id'])
366 366
 				, $reaction_guid['id']
367 367
 				, $this->action_type
368 368
 			)
369 369
 		);
370 370
 
371
-		if ( ! $period ) {
371
+		if ( ! $period) {
372 372
 			return false;
373 373
 		}
374 374
 
375
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' );
376
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
375
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction');
376
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
377 377
 
378 378
 		return $period;
379 379
 	}
@@ -381,21 +381,21 @@  discard block
 block discarded – undo
381 381
 	/**
382 382
 	 * @since 1.0.0
383 383
 	 */
384
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
384
+	public function after_hit(WordPoints_Hook_Fire $fire) {
385 385
 
386
-		$periods = $this->get_settings_from_fire( $fire );
386
+		$periods = $this->get_settings_from_fire($fire);
387 387
 
388
-		if ( empty( $periods ) ) {
388
+		if (empty($periods)) {
389 389
 			return;
390 390
 		}
391 391
 
392 392
 		$this->event_args = $fire->event_args;
393 393
 		$this->action_type = $fire->action_type;
394 394
 
395
-		foreach ( $periods as $settings ) {
395
+		foreach ($periods as $settings) {
396 396
 
397 397
 			$this->add_period(
398
-				$this->get_period_signature( $settings, $fire->reaction )
398
+				$this->get_period_signature($settings, $fire->reaction)
399 399
 				, $fire
400 400
 			);
401 401
 		}
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 		WordPoints_Hook_ReactionI $reaction
421 421
 	) {
422 422
 
423
-		if ( isset( $settings['args'] ) ) {
423
+		if (isset($settings['args'])) {
424 424
 			$period_args = $settings['args'];
425 425
 		} else {
426
-			$period_args = array( $reaction->get_meta( 'target' ) );
426
+			$period_args = array($reaction->get_meta('target'));
427 427
 		}
428 428
 
429 429
 		return wordpoints_hash(
430
-			wp_json_encode( $this->get_arg_values( $period_args ) )
430
+			wp_json_encode($this->get_arg_values($period_args))
431 431
 		);
432 432
 	}
433 433
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @return false|object The period data, or false if not found.
443 443
 	 */
444
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
444
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
445 445
 
446 446
 		global $wpdb;
447 447
 
@@ -451,17 +451,17 @@  discard block
 block discarded – undo
451 451
 				'hit_id' => $fire->hit_id,
452 452
 				'signature' => $signature,
453 453
 			)
454
-			, array( '%d', '%s' )
454
+			, array('%d', '%s')
455 455
 		);
456 456
 
457
-		if ( ! $inserted ) {
457
+		if ( ! $inserted) {
458 458
 			return false;
459 459
 		}
460 460
 
461 461
 		$period_id = $wpdb->insert_id;
462 462
 
463 463
 		wp_cache_set(
464
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}-{$this->action_type}"
464
+			wp_json_encode($fire->reaction->get_guid())."-{$signature}-{$this->action_type}"
465 465
 			, $period_id
466 466
 			, 'wordpoints_hook_period_ids_by_reaction'
467 467
 		);
Please login to merge, or discard this patch.