Completed
Push — master ( a97d75...975fd1 )
by J.D.
03:39
created
src/includes/classes/hook/extension/miss/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 fire that was a miss.
23 23
 	 */
24
-	public function after_miss( WordPoints_Hook_Fire $fire );
24
+	public function after_miss(WordPoints_Hook_Fire $fire);
25 25
 }
26 26
 
27 27
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/reversals/legacy/points.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @since 1.0.0
25 25
 	 */
26
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
26
+	public function should_hit(WordPoints_Hook_Fire $fire) {
27 27
 
28
-		if ( ! parent::should_hit( $fire ) ) {
28
+		if ( ! parent::should_hit($fire)) {
29 29
 
30
-			$logs = $this->get_points_logs_to_be_reversed( $fire );
30
+			$logs = $this->get_points_logs_to_be_reversed($fire);
31 31
 
32
-			return count( $logs ) > 0;
32
+			return count($logs) > 0;
33 33
 		}
34 34
 
35 35
 		return true;
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	/**
39 39
 	 * @since 1.0.0
40 40
 	 */
41
-	public function after_miss( WordPoints_Hook_Fire $fire ) {
41
+	public function after_miss(WordPoints_Hook_Fire $fire) {
42 42
 
43
-		parent::after_miss( $fire );
43
+		parent::after_miss($fire);
44 44
 
45
-		if ( ! $this->get_settings_from_fire( $fire ) ) {
45
+		if ( ! $this->get_settings_from_fire($fire)) {
46 46
 			return;
47 47
 		}
48 48
 
49
-		foreach ( $this->get_points_logs_to_be_reversed( $fire ) as $log ) {
50
-			wordpoints_add_points_log_meta( $log->id, 'auto_reversed', 0 );
49
+		foreach ($this->get_points_logs_to_be_reversed($fire) as $log) {
50
+			wordpoints_add_points_log_meta($log->id, 'auto_reversed', 0);
51 51
 		}
52 52
 	}
53 53
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return array The points logs to be reversed.
62 62
 	 */
63
-	protected function get_points_logs_to_be_reversed( WordPoints_Hook_Fire $fire ) {
63
+	protected function get_points_logs_to_be_reversed(WordPoints_Hook_Fire $fire) {
64 64
 
65
-		if ( isset( $fire->data[ $this->slug ]['points_logs'] ) ) {
66
-			return $fire->data[ $this->slug ]['points_logs'];
65
+		if (isset($fire->data[$this->slug]['points_logs'])) {
66
+			return $fire->data[$this->slug]['points_logs'];
67 67
 		}
68 68
 
69 69
 		$entity = $fire->event_args->get_primary_arg();
70 70
 
71
-		if ( ! $entity ) {
72
-			$fire->data[ $this->slug ]['points_logs'] = array();
71
+		if ( ! $entity) {
72
+			$fire->data[$this->slug]['points_logs'] = array();
73 73
 			return array();
74 74
 		}
75 75
 
76 76
 		$slug = $entity->get_slug();
77 77
 
78
-		if ( ( $pos = strpos( $slug, '\\' ) ) ) {
79
-			$slug = substr( $slug, 0, $pos );
78
+		if (($pos = strpos($slug, '\\'))) {
79
+			$slug = substr($slug, 0, $pos);
80 80
 		}
81 81
 
82 82
 		$meta_queries = array(
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 			)
93 93
 		);
94 94
 
95
-		$log_type = $fire->reaction->get_meta( 'legacy_log_type' );
95
+		$log_type = $fire->reaction->get_meta('legacy_log_type');
96 96
 
97
-		if ( ! $log_type ) {
97
+		if ( ! $log_type) {
98 98
 			$log_type = $fire->reaction->get_event_slug();
99 99
 		}
100 100
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$logs = $query->get();
109 109
 
110
-		if ( ! $logs ) {
110
+		if ( ! $logs) {
111 111
 			$logs = array();
112 112
 		}
113 113
 
114
-		$fire->data[ $this->slug ]['points_logs'] = $logs;
114
+		$fire->data[$this->slug]['points_logs'] = $logs;
115 115
 
116 116
 		return $logs;
117 117
 	}
Please login to merge, or discard this patch.
src/admin/includes/functions.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 		, 'WordPointsPointsTypesL10n'
107 107
 		, array(
108 108
 			'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints' )
109
-			                   . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ),
109
+							   . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ),
110 110
 			'confirmTitle'  => esc_html__( 'Are you sure?', 'wordpoints' ),
111 111
 			'deleteText'    => esc_html__( 'Delete', 'wordpoints' ),
112 112
 			'cancelText'    => esc_html__( 'Cancel', 'wordpoints' ),
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 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,22 +82,22 @@  discard block
 block discarded – undo
82 82
 
83 83
 	wp_register_script(
84 84
 		'wordpoints-admin-points-types'
85
-		, $assets_url . '/js/points-types.js'
86
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
85
+		, $assets_url.'/js/points-types.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-models'
92
-		, $assets_url . '/js/hooks/models.js'
93
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
92
+		, $assets_url.'/js/hooks/models.js'
93
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
94 94
 		, WORDPOINTS_VERSION
95 95
 	);
96 96
 
97 97
 	wp_register_script(
98 98
 		'wordpoints-hooks-views'
99
-		, $assets_url . '/js/hooks/views.js'
100
-		, array( 'wordpoints-hooks-models' )
99
+		, $assets_url.'/js/hooks/views.js'
100
+		, array('wordpoints-hooks-models')
101 101
 		, WORDPOINTS_VERSION
102 102
 	);
103 103
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 		'wordpoints-admin-points-types'
106 106
 		, 'WordPointsPointsTypesL10n'
107 107
 		, array(
108
-			'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints' )
109
-			                   . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ),
110
-			'confirmTitle'  => esc_html__( 'Are you sure?', 'wordpoints' ),
111
-			'deleteText'    => esc_html__( 'Delete', 'wordpoints' ),
112
-			'cancelText'    => esc_html__( 'Cancel', 'wordpoints' ),
108
+			'confirmDelete' => esc_html__('Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints')
109
+			                   . ' '.esc_html__('Once a points type has been deleted, you cannot bring it back.', 'wordpoints'),
110
+			'confirmTitle'  => esc_html__('Are you sure?', 'wordpoints'),
111
+			'deleteText'    => esc_html__('Delete', 'wordpoints'),
112
+			'cancelText'    => esc_html__('Cancel', 'wordpoints'),
113 113
 		)
114 114
 	);
115 115
 
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 		'wordpoints-hooks-views'
118 118
 		, 'WordPointsHooksAdminL10n'
119 119
 		, array(
120
-			'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
121
-			'changesSaved'    => __( 'Your changes have been saved.', 'wordpoints' ),
120
+			'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
121
+			'changesSaved'    => __('Your changes have been saved.', 'wordpoints'),
122 122
 			/* translators: the name of the field that cannot be empty */
123
-			'emptyField'      => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ),
124
-			'confirmDelete'   => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ),
125
-			'confirmTitle'    => __( 'Are you sure?', 'wordpoints' ),
126
-			'deleteText'      => __( 'Delete', 'wordpoints' ),
127
-			'cancelText'      => __( 'Cancel', 'wordpoints' ),
128
-			'separator'       => __( ' » ', 'wordpoints' ),
129
-			'target_label'    => __( 'Target', 'wordpoints' ),
123
+			'emptyField'      => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'),
124
+			'confirmDelete'   => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'),
125
+			'confirmTitle'    => __('Are you sure?', 'wordpoints'),
126
+			'deleteText'      => __('Delete', 'wordpoints'),
127
+			'cancelText'      => __('Cancel', 'wordpoints'),
128
+			'separator'       => __(' » ', 'wordpoints'),
129
+			'target_label'    => __('Target', 'wordpoints'),
130 130
 			// translators: form field
131
-			'cannotBeChanged' => __( '(cannot be changed)', 'wordpoints' ),
132
-			'fieldsInvalid'   => __( 'Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints' ),
131
+			'cannotBeChanged' => __('(cannot be changed)', 'wordpoints'),
132
+			'fieldsInvalid'   => __('Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints'),
133 133
 		)
134 134
 	);
135 135
 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 			<div class="view">
142 142
 				<div class="title"></div>
143 143
 				<button type="button" class="edit button-secondary">
144
-					' . esc_html__( 'Edit', 'wordpoints' ) . '
144
+					' . esc_html__('Edit', 'wordpoints').'
145 145
 				</button>
146 146
 				<button type="button" class="close button-secondary">
147
-					' . esc_html__( 'Close', 'wordpoints' ) . '
147
+					' . esc_html__('Close', 'wordpoints').'
148 148
 				</button>
149 149
 			</div>
150 150
 			<div class="form">
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 						</div>
164 164
 						<div class="action-buttons">
165 165
 							<button type="button" class="save button-primary" disabled>
166
-								' . esc_html__( 'Save', 'wordpoints' ) . '
166
+								' . esc_html__('Save', 'wordpoints').'
167 167
 							</button>
168 168
 							<button type="button" class="cancel button-secondary">
169
-								' . esc_html__( 'Cancel', 'wordpoints' ) . '
169
+								' . esc_html__('Cancel', 'wordpoints').'
170 170
 							</button>
171 171
 							<button type="button" class="close button-secondary">
172
-								' . esc_html__( 'Close', 'wordpoints' ) . '
172
+								' . esc_html__('Close', 'wordpoints').'
173 173
 							</button>
174 174
 							<button type="button" class="delete button-secondary">
175
-								' . esc_html__( 'Delete', 'wordpoints' ) . '
175
+								' . esc_html__('Delete', 'wordpoints').'
176 176
 							</button>
177 177
 						</div>
178 178
 					</div>
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
 
221 221
 	wp_register_script(
222 222
 		'wordpoints-hooks-reactor-points'
223
-		, $assets_url . '/js/hooks/reactors/points.js'
224
-		, array( 'wordpoints-hooks-views' )
223
+		, $assets_url.'/js/hooks/reactors/points.js'
224
+		, array('wordpoints-hooks-views')
225 225
 		, WORDPOINTS_VERSION
226 226
 	);
227 227
 
228 228
 	wp_register_script(
229 229
 		'wordpoints-hooks-extension-conditions'
230
-		, $assets_url . '/js/hooks/extensions/conditions.js'
231
-		, array( 'wordpoints-hooks-views' )
230
+		, $assets_url.'/js/hooks/extensions/conditions.js'
231
+		, array('wordpoints-hooks-views')
232 232
 		, WORDPOINTS_VERSION
233 233
 	);
234 234
 
@@ -238,25 +238,25 @@  discard block
 block discarded – undo
238 238
 		, '
239 239
 			<script type="text/template" id="tmpl-wordpoints-hook-condition-groups">
240 240
 				<div class="conditions-title section-title">
241
-					<h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4>
241
+					<h4>' . esc_html__('Conditions', 'wordpoints').'</h4>
242 242
 					<button type="button" class="add-new button-secondary button-link">
243
-						<span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span>
243
+						<span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span>
244 244
 						<span class="dashicons dashicons-plus"></span>
245 245
 					</button>
246 246
 				</div>
247 247
 				<div class="add-condition-form hidden">
248 248
 					<div class="no-conditions hidden">
249
-						' . esc_html__( 'No conditions available.', 'wordpoints' ) . '
249
+						' . esc_html__('No conditions available.', 'wordpoints').'
250 250
 					</div>
251 251
 					<div class="condition-selectors">
252 252
 						<div class="arg-selectors"></div>
253 253
 						<div class="condition-selector"></div>
254 254
 					</div>
255
-					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '">
256
-						' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . '
255
+					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'">
256
+						' . esc_html_x('Add', 'reaction condition', 'wordpoints').'
257 257
 					</button>
258
-					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '">
259
-						' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . '
258
+					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'">
259
+						' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').'
260 260
 					</button>
261 261
 				</div>
262 262
 				<div class="condition-groups section-content"></div>
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 				<div class="condition-controls">
271 271
 					<div class="condition-title"></div>
272 272
 					<button type="button" class="delete button-secondary button-link">
273
-						<span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span>
273
+						<span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span>
274 274
 						<span class="dashicons dashicons-no"></span>
275 275
 					</button>
276 276
 				</div>
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 
289 289
 	wp_register_script(
290 290
 		'wordpoints-hooks-extension-periods'
291
-		, $assets_url . '/js/hooks/extensions/periods.js'
292
-		, array( 'wordpoints-hooks-views' )
291
+		, $assets_url.'/js/hooks/extensions/periods.js'
292
+		, array('wordpoints-hooks-views')
293 293
 		, WORDPOINTS_VERSION
294 294
 	);
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		, '
300 300
 			<script type="text/template" id="tmpl-wordpoints-hook-periods">
301 301
 				<div class="periods-title section-title">
302
-					<h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4>
302
+					<h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4>
303 303
 				</div>
304 304
 				<div class="periods section-content"></div>
305 305
 			</script>
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 *
349 349
 	 * @param array $data The data.
350 350
 	 */
351
-	$data = apply_filters( 'wordpoints_hooks_ui_data', $data );
351
+	$data = apply_filters('wordpoints_hooks_ui_data', $data);
352 352
 
353 353
 	wp_localize_script(
354 354
 		'wordpoints-hooks-models'
@@ -368,18 +368,18 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return array The data extracted from the objects.
370 370
  */
371
-function wordpoints_hooks_ui_get_script_data_from_objects( $objects, $type ) {
371
+function wordpoints_hooks_ui_get_script_data_from_objects($objects, $type) {
372 372
 
373 373
 	$data = array();
374 374
 
375
-	foreach ( $objects as $slug => $object ) {
375
+	foreach ($objects as $slug => $object) {
376 376
 
377
-		if ( $object instanceof WordPoints_Hook_UI_Script_Data_ProviderI ) {
378
-			$data[ $slug ] = $object->get_ui_script_data();
377
+		if ($object instanceof WordPoints_Hook_UI_Script_Data_ProviderI) {
378
+			$data[$slug] = $object->get_ui_script_data();
379 379
 		}
380 380
 
381
-		if ( wp_script_is( "wordpoints-hooks-{$type}-{$slug}", 'registered' ) ) {
382
-			wp_enqueue_script( "wordpoints-hooks-{$type}-{$slug}" );
381
+		if (wp_script_is("wordpoints-hooks-{$type}-{$slug}", 'registered')) {
382
+			wp_enqueue_script("wordpoints-hooks-{$type}-{$slug}");
383 383
 		}
384 384
 	}
385 385
 
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
 	$entity_children = $entities->children;
404 404
 
405 405
 	/** @var WordPoints_Entity $entity */
406
-	foreach ( $entities->get_all() as $slug => $entity ) {
406
+	foreach ($entities->get_all() as $slug => $entity) {
407 407
 
408 408
 		$child_data = array();
409 409
 
410 410
 		/** @var WordPoints_EntityishI $child */
411
-		foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) {
411
+		foreach ($entity_children->get_children($slug) as $child_slug => $child) {
412 412
 
413
-			$child_data[ $child_slug ] = array(
413
+			$child_data[$child_slug] = array(
414 414
 				'slug'  => $child_slug,
415 415
 				'title' => $child->get_title(),
416 416
 			);
417 417
 
418
-			if ( $child instanceof WordPoints_Entity_Attr ) {
418
+			if ($child instanceof WordPoints_Entity_Attr) {
419 419
 
420
-				$child_data[ $child_slug ]['_type']     = 'attr';
421
-				$child_data[ $child_slug ]['data_type'] = $child->get_data_type();
420
+				$child_data[$child_slug]['_type']     = 'attr';
421
+				$child_data[$child_slug]['data_type'] = $child->get_data_type();
422 422
 
423
-			} elseif ( $child instanceof WordPoints_Entity_Relationship ) {
423
+			} elseif ($child instanceof WordPoints_Entity_Relationship) {
424 424
 
425
-				$child_data[ $child_slug ]['_type']     = 'relationship';
426
-				$child_data[ $child_slug ]['primary']   = $child->get_primary_entity_slug();
427
-				$child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug();
425
+				$child_data[$child_slug]['_type']     = 'relationship';
426
+				$child_data[$child_slug]['primary']   = $child->get_primary_entity_slug();
427
+				$child_data[$child_slug]['secondary'] = $child->get_related_entity_slug();
428 428
 			}
429 429
 
430 430
 			/**
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
 			 * @param array                $data  The data for the entity child.
436 436
 			 * @param WordPoints_Entityish $child The child's object.
437 437
 			 */
438
-			$child_data[ $child_slug ] = apply_filters(
438
+			$child_data[$child_slug] = apply_filters(
439 439
 				'wordpoints_hooks_ui_data_entity_child'
440
-				, $child_data[ $child_slug ]
440
+				, $child_data[$child_slug]
441 441
 				, $child
442 442
 			);
443 443
 		}
444 444
 
445
-		$entities_data[ $slug ] = array(
445
+		$entities_data[$slug] = array(
446 446
 			'slug'     => $slug,
447 447
 			'title'    => $entity->get_title(),
448 448
 			'children' => $child_data,
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 			'_type'    => 'entity',
451 451
 		);
452 452
 
453
-		if ( $entity instanceof WordPoints_Entity_EnumerableI ) {
453
+		if ($entity instanceof WordPoints_Entity_EnumerableI) {
454 454
 
455 455
 			$values = array();
456 456
 
457
-			foreach ( $entity->get_enumerated_values() as $value ) {
458
-				if ( $entity->set_the_value( $value ) ) {
457
+			foreach ($entity->get_enumerated_values() as $value) {
458
+				if ($entity->set_the_value($value)) {
459 459
 					$values[] = array(
460 460
 						'value' => $entity->get_the_id(),
461 461
 						'label' => $entity->get_the_human_id(),
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 				}
464 464
 			}
465 465
 
466
-			$entities_data[ $slug ]['values'] = $values;
466
+			$entities_data[$slug]['values'] = $values;
467 467
 		}
468 468
 
469 469
 		/**
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 		 * @param array             $data   The data for the entity.
473 473
 		 * @param WordPoints_Entity $entity The entity object.
474 474
 		 */
475
-		$entities_data[ $slug ] = apply_filters(
475
+		$entities_data[$slug] = apply_filters(
476 476
 			'wordpoints_hooks_ui_data_entity'
477
-			, $entities_data[ $slug ]
477
+			, $entities_data[$slug]
478 478
 			, $entity
479 479
 		);
480 480
 	}
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 
499 499
 	// We don't care about the action slugs, so first we get rid of that bottom level
500 500
 	// of the array.
501
-	$event_index = call_user_func_array( 'array_merge_recursive', $event_index );
501
+	$event_index = call_user_func_array('array_merge_recursive', $event_index);
502 502
 
503 503
 	$event_action_types = array();
504 504
 
505 505
 	// This leaves us the event indexed by action type. But we actually need to flip
506 506
 	// this, so that we have the action types indexed by event slug.
507
-	foreach ( $event_index as $action_type => $events ) {
508
-		foreach ( $events as $event => $unused ) {
509
-			$event_action_types[ $event ][ $action_type ] = true;
507
+	foreach ($event_index as $action_type => $events) {
508
+		foreach ($events as $event => $unused) {
509
+			$event_action_types[$event][$action_type] = true;
510 510
 		}
511 511
 	}
512 512
 
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
  *
530 530
  * @return string The HTML with templates appended.
531 531
  */
532
-function wordpoints_script_templates_filter( $html, $handle ) {
532
+function wordpoints_script_templates_filter($html, $handle) {
533 533
 
534 534
 	global $wp_scripts;
535 535
 
536
-	$templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' );
536
+	$templates = $wp_scripts->get_data($handle, 'wordpoints-templates');
537 537
 
538
-	if ( $templates ) {
538
+	if ($templates) {
539 539
 		$html .= $templates;
540 540
 	}
541 541
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function wordpoints_hooks_admin_ajax() {
553 553
 
554
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
554
+	if (defined('DOING_AJAX') && DOING_AJAX) {
555 555
 		new WordPoints_Admin_Ajax_Hooks;
556 556
 	}
557 557
 }
Please login to merge, or discard this patch.
src/includes/functions.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
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' );
39
-	$reactors->register( 'points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy' );
38
+	$reactors->register('points', 'WordPoints_Hook_Reactor_Points');
39
+	$reactors->register('points_legacy', 'WordPoints_Hook_Reactor_Points_Legacy');
40 40
 }
41 41
 
42 42
 /**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @param WordPoints_Class_Registry_Children $reaction_stores The store registry.
50 50
  */
51
-function wordpoints_hook_reaction_stores_init( $reaction_stores ) {
51
+function wordpoints_hook_reaction_stores_init($reaction_stores) {
52 52
 
53 53
 	$reaction_stores->register(
54 54
 		'standard'
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		, 'WordPoints_Hook_Reaction_Store_Options'
57 57
 	);
58 58
 
59
-	if ( is_wordpoints_network_active() ) {
59
+	if (is_wordpoints_network_active()) {
60 60
 		$reaction_stores->register(
61 61
 			'network'
62 62
 			, 'points'
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
  *
75 75
  * @param WordPoints_Class_Registry_Persistent $extensions The extension registry.
76 76
  */
77
-function wordpoints_hook_extension_init( $extensions ) {
78
-
79
-	$extensions->register( 'blocker', 'WordPoints_Hook_Extension_Blocker' );
80
-	$extensions->register( 'repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker' );
81
-	$extensions->register( 'reversals', 'WordPoints_Hook_Extension_Reversals' );
82
-	$extensions->register( 'reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points' );
83
-	$extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' );
84
-	$extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' );
77
+function wordpoints_hook_extension_init($extensions) {
78
+
79
+	$extensions->register('blocker', 'WordPoints_Hook_Extension_Blocker');
80
+	$extensions->register('repeat_blocker', 'WordPoints_Hook_Extension_Repeat_Blocker');
81
+	$extensions->register('reversals', 'WordPoints_Hook_Extension_Reversals');
82
+	$extensions->register('reversals_legacy_points', 'WordPoints_Hook_Extension_Reversals_Legacy_Points');
83
+	$extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions');
84
+	$extensions->register('periods', 'WordPoints_Hook_Extension_Periods');
85 85
 }
86 86
 
87 87
 /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @param WordPoints_Class_Registry_Children $conditions The conditions registry.
95 95
  */
96
-function wordpoints_hook_conditions_init( $conditions ) {
96
+function wordpoints_hook_conditions_init($conditions) {
97 97
 
98 98
 	$conditions->register(
99 99
 		'text'
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  *
130 130
  * @param WordPoints_Hook_Actions $actions The action registry.
131 131
  */
132
-function wordpoints_hook_actions_init( $actions ) {
132
+function wordpoints_hook_actions_init($actions) {
133 133
 
134 134
 	$actions->register(
135 135
 		'comment_approve'
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 		, array(
138 138
 			'action' => 'transition_comment_status',
139 139
 			'data'   => array(
140
-				'arg_index'    => array( 'comment' => 2 ),
141
-				'requirements' => array( 0 => 'approved' ),
140
+				'arg_index'    => array('comment' => 2),
141
+				'requirements' => array(0 => 'approved'),
142 142
 			),
143 143
 		)
144 144
 	);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		, array(
150 150
 			'action' => 'wp_insert_comment',
151 151
 			'data'   => array(
152
-				'arg_index' => array( 'comment' => 1 ),
152
+				'arg_index' => array('comment' => 1),
153 153
 			),
154 154
 		)
155 155
 	);
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 		, array(
161 161
 			'action' => 'transition_comment_status',
162 162
 			'data'   => array(
163
-				'arg_index' => array( 'comment' => 2 ),
164
-				'requirements' => array( 1 => 'approved' ),
163
+				'arg_index' => array('comment' => 2),
164
+				'requirements' => array(1 => 'approved'),
165 165
 			),
166 166
 		)
167 167
 	);
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 		, array(
174 174
 			'action' => 'transition_post_status',
175 175
 			'data'   => array(
176
-				'arg_index' => array( 'post' => 2 ),
177
-				'requirements' => array( 0 => 'publish' ),
176
+				'arg_index' => array('post' => 2),
177
+				'requirements' => array(0 => 'publish'),
178 178
 			),
179 179
 		)
180 180
 	);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 		, array(
186 186
 			'action' => 'transition_post_status',
187 187
 			'data'   => array(
188
-				'arg_index' => array( 'post' => 2 ),
189
-				'requirements' => array( 1 => 'publish' ),
188
+				'arg_index' => array('post' => 2),
189
+				'requirements' => array(1 => 'publish'),
190 190
 			),
191 191
 		)
192 192
 	);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		, array(
198 198
 			'action' => 'delete_post',
199 199
 			'data'   => array(
200
-				'arg_index' => array( 'post' => 0 ),
200
+				'arg_index' => array('post' => 0),
201 201
 			),
202 202
 		)
203 203
 	);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		, array(
209 209
 			'action' => 'add_attachment',
210 210
 			'data'   => array(
211
-				'arg_index' => array( 'post\attachment' => 0 ),
211
+				'arg_index' => array('post\attachment' => 0),
212 212
 			),
213 213
 		)
214 214
 	);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		, array(
220 220
 			'action' => 'delete_post',
221 221
 			'data'   => array(
222
-				'arg_index' => array( 'post' => 0 ),
222
+				'arg_index' => array('post' => 0),
223 223
 			),
224 224
 		)
225 225
 	);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		, array(
231 231
 			'action' => 'user_register',
232 232
 			'data'   => array(
233
-				'arg_index' => array( 'user' => 0 ),
233
+				'arg_index' => array('user' => 0),
234 234
 			),
235 235
 		)
236 236
 	);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		, array(
242 242
 			'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user',
243 243
 			'data'   => array(
244
-				'arg_index' => array( 'user' => 0 ),
244
+				'arg_index' => array('user' => 0),
245 245
 			),
246 246
 		)
247 247
 	);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @param WordPoints_Hook_Events $events The event registry.
266 266
  */
267
-function wordpoints_hook_events_init( $events ) {
267
+function wordpoints_hook_events_init($events) {
268 268
 
269 269
 	$events->register(
270 270
 		'user_register'
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	);
295 295
 
296 296
 	// Register events for all of the public post types.
297
-	$post_types = get_post_types( array( 'public' => true ) );
297
+	$post_types = get_post_types(array('public' => true));
298 298
 
299 299
 	/**
300 300
 	 * Filter which post types to register hook events for.
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @param string[] The post type slugs ("names").
305 305
 	 */
306
-	$post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types );
306
+	$post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types);
307 307
 
308
-	foreach ( $post_types as $slug ) {
309
-		wordpoints_register_post_type_hook_events( $slug );
308
+	foreach ($post_types as $slug) {
309
+		wordpoints_register_post_type_hook_events($slug);
310 310
 	}
311 311
 }
312 312
 
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
  *
320 320
  * @param WordPoints_App_Registry $entities The entities app.
321 321
  */
322
-function wordpoints_entities_app_init( $entities ) {
322
+function wordpoints_entities_app_init($entities) {
323 323
 
324
-	$entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' );
325
-	$entities->sub_apps->register( 'contexts', 'WordPoints_Class_Registry' );
324
+	$entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children');
325
+	$entities->sub_apps->register('contexts', 'WordPoints_Class_Registry');
326 326
 }
327 327
 
328 328
 /**
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
  *
335 335
  * @param WordPoints_Class_Registry $contexts The entity context registry.
336 336
  */
337
-function wordpoints_entity_contexts_init( $contexts ) {
337
+function wordpoints_entity_contexts_init($contexts) {
338 338
 
339
-	$contexts->register( 'network', 'WordPoints_Entity_Context_Network' );
340
-	$contexts->register( 'site', 'WordPoints_Entity_Context_Site' );
339
+	$contexts->register('network', 'WordPoints_Entity_Context_Network');
340
+	$contexts->register('site', 'WordPoints_Entity_Context_Site');
341 341
 }
342 342
 
343 343
 /**
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
  *
350 350
  * @param WordPoints_App_Registry $entities The entities app.
351 351
  */
352
-function wordpoints_entities_init( $entities ) {
352
+function wordpoints_entities_init($entities) {
353 353
 
354 354
 	$children = $entities->children;
355 355
 
356
-	$entities->register( 'user', 'WordPoints_Entity_User' );
357
-	$children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' );
356
+	$entities->register('user', 'WordPoints_Entity_User');
357
+	$children->register('user', 'roles', 'WordPoints_Entity_User_Roles');
358 358
 
359
-	$entities->register( 'user_role', 'WordPoints_Entity_User_Role' );
359
+	$entities->register('user_role', 'WordPoints_Entity_User_Role');
360 360
 
361 361
 	// Register entities for all of the public post types.
362
-	$post_types = get_post_types( array( 'public' => true ) );
362
+	$post_types = get_post_types(array('public' => true));
363 363
 
364 364
 	/**
365 365
 	 * Filter which post types to register entities for.
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @param string[] The post type slugs ("names").
370 370
 	 */
371
-	$post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types );
371
+	$post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types);
372 372
 
373
-	foreach ( $post_types as $slug ) {
374
-		wordpoints_register_post_type_entities( $slug );
373
+	foreach ($post_types as $slug) {
374
+		wordpoints_register_post_type_entities($slug);
375 375
 	}
376 376
 
377 377
 	// Register entities for all of the public taxonomies.
378
-	$taxonomies = get_taxonomies( array( 'public' => true ) );
378
+	$taxonomies = get_taxonomies(array('public' => true));
379 379
 
380 380
 	/**
381 381
 	 * Filter which taxonomies to register entities for.
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @param string[] The taxonomy slugs.
386 386
 	 */
387
-	$taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies );
387
+	$taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies);
388 388
 
389
-	foreach ( $taxonomies as $slug ) {
390
-		wordpoints_register_taxonomy_entities( $slug );
389
+	foreach ($taxonomies as $slug) {
390
+		wordpoints_register_taxonomy_entities($slug);
391 391
 	}
392 392
 }
393 393
 
@@ -398,28 +398,28 @@  discard block
 block discarded – undo
398 398
  *
399 399
  * @param string $slug The slug of the post type.
400 400
  */
401
-function wordpoints_register_post_type_entities( $slug ) {
401
+function wordpoints_register_post_type_entities($slug) {
402 402
 
403 403
 	$entities = wordpoints_entities();
404 404
 	$children = $entities->children;
405 405
 
406
-	$entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' );
407
-	$children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' );
406
+	$entities->register("post\\{$slug}", 'WordPoints_Entity_Post');
407
+	$children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author');
408 408
 
409
-	$supports = get_all_post_type_supports( $slug );
409
+	$supports = get_all_post_type_supports($slug);
410 410
 
411
-	if ( isset( $supports['editor'] ) ) {
412
-		$children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' );
411
+	if (isset($supports['editor'])) {
412
+		$children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content');
413 413
 	}
414 414
 
415
-	if ( isset( $supports['comments'] ) ) {
416
-		$entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' );
417
-		$children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' );
418
-		$children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' );
415
+	if (isset($supports['comments'])) {
416
+		$entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment');
417
+		$children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post');
418
+		$children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author');
419 419
 	}
420 420
 
421
-	foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) {
422
-		$children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' );
421
+	foreach (get_object_taxonomies($slug) as $taxonomy_slug) {
422
+		$children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms');
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 *
430 430
 	 * @param string $slug The slug ("name") of the post type.
431 431
 	 */
432
-	do_action( 'wordpoints_register_post_type_entities', $slug );
432
+	do_action('wordpoints_register_post_type_entities', $slug);
433 433
 }
434 434
 
435 435
 /**
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
  *
440 440
  * @param string $slug The slug of the post type.
441 441
  */
442
-function wordpoints_register_post_type_hook_events( $slug ) {
442
+function wordpoints_register_post_type_hook_events($slug) {
443 443
 
444 444
 	$events = wordpoints_hooks()->events;
445 445
 
446
-	if ( 'attachment' === $slug ) {
446
+	if ('attachment' === $slug) {
447 447
 
448 448
 		$events->register(
449 449
 			'media_upload'
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			, array(
468 468
 				'actions' => array(
469 469
 					'toggle_on'  => 'post_publish',
470
-					'toggle_off' => array( 'post_depublish', 'post_depublish_delete' ),
470
+					'toggle_off' => array('post_depublish', 'post_depublish_delete'),
471 471
 				),
472 472
 				'args'    => array(
473 473
 					"post\\{$slug}" => 'WordPoints_Hook_Arg_Dynamic',
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 		);
477 477
 	}
478 478
 
479
-	if ( post_type_supports( $slug, 'comments' ) ) {
479
+	if (post_type_supports($slug, 'comments')) {
480 480
 
481 481
 		$events->register(
482 482
 			"comment_leave\\{$slug}"
483 483
 			, 'WordPoints_Hook_Event_Comment_Leave'
484 484
 			, array(
485 485
 				'actions' => array(
486
-					'toggle_on'  => array( 'comment_approve', 'comment_new' ),
486
+					'toggle_on'  => array('comment_approve', 'comment_new'),
487 487
 					'toggle_off' => 'comment_deapprove',
488 488
 				),
489 489
 				'args' => array(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 *
501 501
 	 * @param string $slug The slug ("name") of the post type.
502 502
 	 */
503
-	do_action( 'wordpoints_register_post_type_hook_events', $slug );
503
+	do_action('wordpoints_register_post_type_hook_events', $slug);
504 504
 }
505 505
 
506 506
 /**
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
  *
511 511
  * @param string $slug The slug of the taxonomy.
512 512
  */
513
-function wordpoints_register_taxonomy_entities( $slug ) {
513
+function wordpoints_register_taxonomy_entities($slug) {
514 514
 
515 515
 	$entities = wordpoints_entities();
516 516
 	$children = $entities->children;
517 517
 
518
-	$entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' );
519
-	$children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' );
518
+	$entities->register("term\\{$slug}", 'WordPoints_Entity_Term');
519
+	$children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id');
520 520
 
521 521
 	/**
522 522
 	 * Fired when registering the entities for a taxonomy.
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @param string $slug The taxonomy's slug.
527 527
 	 */
528
-	do_action( 'wordpoints_register_taxonomy_entities', $slug );
528
+	do_action('wordpoints_register_taxonomy_entities', $slug);
529 529
 }
530 530
 
531 531
 /**
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
  *
538 538
  * @param WordPoints_Class_RegistryI $data_types The data types registry.
539 539
  */
540
-function wordpoints_data_types_init( $data_types ) {
540
+function wordpoints_data_types_init($data_types) {
541 541
 
542
-	$data_types->register( 'integer', 'WordPoints_Data_Type_Integer' );
543
-	$data_types->register( 'text', 'WordPoints_Data_Type_Text' );
542
+	$data_types->register('integer', 'WordPoints_Data_Type_Integer');
543
+	$data_types->register('text', 'WordPoints_Data_Type_Text');
544 544
 }
545 545
 
546 546
 /**
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
  *
556 556
  * @return bool Whether the user can view the points log.
557 557
  */
558
-function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) {
558
+function wordpoints_hooks_user_can_view_points_log($can_view, $log) {
559 559
 
560
-	if ( ! $can_view ) {
560
+	if ( ! $can_view) {
561 561
 		return $can_view;
562 562
 	}
563 563
 
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 	$event_slug = $log->log_type;
567 567
 
568 568
 	/** @var WordPoints_Hook_Arg $arg */
569
-	foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) {
569
+	foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) {
570 570
 
571
-		$value = wordpoints_get_points_log_meta( $log->id, $slug, true );
571
+		$value = wordpoints_get_points_log_meta($log->id, $slug, true);
572 572
 
573
-		if ( ! $value ) {
573
+		if ( ! $value) {
574 574
 			continue;
575 575
 		}
576 576
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			, $value
581 581
 		);
582 582
 
583
-		if ( ! $can_view ) {
583
+		if ( ! $can_view) {
584 584
 			break;
585 585
 		}
586 586
 	}
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
  *
600 600
  * @return bool Whether the user can view this entity.
601 601
  */
602
-function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) {
602
+function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) {
603 603
 
604
-	$entity = wordpoints_entities()->get( $entity_slug );
604
+	$entity = wordpoints_entities()->get($entity_slug);
605 605
 
606 606
 	// If this entity type is not found, we have no way of determining whether it is
607 607
 	// safe for the user to view it.
608
-	if ( ! ( $entity instanceof WordPoints_Entity ) ) {
608
+	if ( ! ($entity instanceof WordPoints_Entity)) {
609 609
 		return false;
610 610
 	}
611 611
 
612 612
 	$can_view = true;
613 613
 
614
-	if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) {
615
-		$can_view = $entity->user_can_view( $user_id, $entity_id );
614
+	if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) {
615
+		$can_view = $entity->user_can_view($user_id, $entity_id);
616 616
 	}
617 617
 
618 618
 	/**
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function wordpoints_apps() {
645 645
 
646
-	if ( ! isset( WordPoints_App::$main ) ) {
647
-		WordPoints_App::$main = new WordPoints_App( 'apps' );
646
+	if ( ! isset(WordPoints_App::$main)) {
647
+		WordPoints_App::$main = new WordPoints_App('apps');
648 648
 	}
649 649
 
650 650
 	return WordPoints_App::$main;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
  */
660 660
 function wordpoints_hooks() {
661 661
 
662
-	if ( ! isset( WordPoints_App::$main ) ) {
662
+	if ( ! isset(WordPoints_App::$main)) {
663 663
 		wordpoints_apps();
664 664
 	}
665 665
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
  */
676 676
 function wordpoints_entities() {
677 677
 
678
-	if ( ! isset( WordPoints_App::$main ) ) {
678
+	if ( ! isset(WordPoints_App::$main)) {
679 679
 		wordpoints_apps();
680 680
 	}
681 681
 
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
  *
692 692
  * @param WordPoints_App $app The main apps app.
693 693
  */
694
-function wordpoints_apps_init( $app ) {
694
+function wordpoints_apps_init($app) {
695 695
 
696 696
 	$apps = $app->sub_apps;
697 697
 
698
-	$apps->register( 'hooks', 'WordPoints_Hooks' );
699
-	$apps->register( 'entities', 'WordPoints_App_Registry' );
700
-	$apps->register( 'data_types', 'WordPoints_Class_Registry' );
698
+	$apps->register('hooks', 'WordPoints_Hooks');
699
+	$apps->register('entities', 'WordPoints_App_Registry');
700
+	$apps->register('data_types', 'WordPoints_Class_Registry');
701 701
 }
702 702
 
703 703
 /**
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
  *
711 711
  * @return object|false The constructed object, or false if to many args were passed.
712 712
  */
713
-function wordpoints_construct_class_with_args( $class_name, array $args ) {
713
+function wordpoints_construct_class_with_args($class_name, array $args) {
714 714
 
715
-	switch ( count( $args ) ) {
715
+	switch (count($args)) {
716 716
 		case 0:
717 717
 			return new $class_name();
718 718
 		case 1:
719
-			return new $class_name( $args[0] );
719
+			return new $class_name($args[0]);
720 720
 		case 2:
721
-			return new $class_name( $args[0], $args[1] );
721
+			return new $class_name($args[0], $args[1]);
722 722
 		case 3:
723
-			return new $class_name( $args[0], $args[1], $args[2] );
723
+			return new $class_name($args[0], $args[1], $args[2]);
724 724
 		case 4:
725
-			return new $class_name( $args[0], $args[1], $args[2], $args[3] );
725
+			return new $class_name($args[0], $args[1], $args[2], $args[3]);
726 726
 		default:
727 727
 			return false;
728 728
 	}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
  * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the
745 745
  *               slug is not dynamic, the value of each of those keys will be false.
746 746
  */
747
-function wordpoints_parse_dynamic_slug( $slug ) {
747
+function wordpoints_parse_dynamic_slug($slug) {
748 748
 
749
-	$parsed = array( 'dynamic' => false, 'generic' => false );
749
+	$parsed = array('dynamic' => false, 'generic' => false);
750 750
 
751
-	$parts = explode( '\\', $slug, 2 );
751
+	$parts = explode('\\', $slug, 2);
752 752
 
753
-	if ( isset( $parts[1] ) ) {
753
+	if (isset($parts[1])) {
754 754
 		$parsed['dynamic'] = $parts[1];
755 755
 		$parsed['generic'] = $parts[0];
756 756
 	}
@@ -789,28 +789,28 @@  discard block
 block discarded – undo
789 789
  *                     contexts, indexed by context slug, or false if any of the
790 790
  *                     contexts isn't current.
791 791
  */
792
-function wordpoints_entities_get_current_context_id( $slug ) {
792
+function wordpoints_entities_get_current_context_id($slug) {
793 793
 
794 794
 	$current_context = array();
795 795
 
796 796
 	/** @var WordPoints_Class_Registry $contexts */
797 797
 	$contexts = wordpoints_entities()->contexts;
798 798
 
799
-	while ( $slug ) {
799
+	while ($slug) {
800 800
 
801
-		$context = $contexts->get( $slug );
801
+		$context = $contexts->get($slug);
802 802
 
803
-		if ( ! $context instanceof WordPoints_Entity_Context ) {
803
+		if ( ! $context instanceof WordPoints_Entity_Context) {
804 804
 			return false;
805 805
 		}
806 806
 
807 807
 		$id = $context->get_current_id();
808 808
 
809
-		if ( false === $id ) {
809
+		if (false === $id) {
810 810
 			return false;
811 811
 		}
812 812
 
813
-		$current_context[ $slug ] = $id;
813
+		$current_context[$slug] = $id;
814 814
 
815 815
 		$slug = $context->get_parent_slug();
816 816
 	}
@@ -831,22 +831,22 @@  discard block
 block discarded – undo
831 831
  */
832 832
 function wordpoints_is_network_context() {
833 833
 
834
-	if ( ! is_multisite() ) {
834
+	if ( ! is_multisite()) {
835 835
 		return false;
836 836
 	}
837 837
 
838
-	if ( is_network_admin() ) {
838
+	if (is_network_admin()) {
839 839
 		return true;
840 840
 	}
841 841
 
842 842
 	// See https://core.trac.wordpress.org/ticket/22589
843 843
 	if (
844
-		defined( 'DOING_AJAX' )
844
+		defined('DOING_AJAX')
845 845
 		&& DOING_AJAX
846
-		&& isset( $_SERVER['HTTP_REFERER'] )
846
+		&& isset($_SERVER['HTTP_REFERER'])
847 847
 		&& preg_match(
848
-			'#^' . preg_quote( network_admin_url(), '#' ) . '#i'
849
-			, esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) )
848
+			'#^'.preg_quote(network_admin_url(), '#').'#i'
849
+			, esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))
850 850
 		)
851 851
 	) {
852 852
 		return true;
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 	 *
860 860
 	 * @param bool $in_network_context Whether we are in network context.
861 861
 	 */
862
-	return apply_filters( 'wordpoints_is_network_context', false );
862
+	return apply_filters('wordpoints_is_network_context', false);
863 863
 }
864 864
 
865 865
 /**
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
  *
874 874
  * @return string The primary arg's GUID, JSON encoded.
875 875
  */
876
-function wordpoints_hooks_get_event_primary_arg_guid_json( WordPoints_Hook_Event_Args $event_args ) {
876
+function wordpoints_hooks_get_event_primary_arg_guid_json(WordPoints_Hook_Event_Args $event_args) {
877 877
 
878 878
 	$entity = $event_args->get_primary_arg();
879 879
 
880
-	if ( ! $entity ) {
880
+	if ( ! $entity) {
881 881
 		return '';
882 882
 	}
883 883
 
884 884
 	$the_guid = $entity->get_the_guid();
885 885
 
886
-	if ( ! $the_guid ) {
886
+	if ( ! $the_guid) {
887 887
 		return '';
888 888
 	}
889 889
 
890
-	return wp_json_encode( $the_guid );
890
+	return wp_json_encode($the_guid);
891 891
 }
892 892
 
893 893
 /**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
  */
901 901
 function wordpoints_hooks_api_add_global_cache_groups() {
902 902
 
903
-	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
903
+	if (function_exists('wp_cache_add_global_groups')) {
904 904
 
905 905
 		wp_cache_add_global_groups(
906 906
 			array(
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
  * @return string The escaped identifier. Already quoted, do not place within
927 927
  *                backticks.
928 928
  */
929
-function wordpoints_escape_mysql_identifier( $identifier ) {
930
-	return '`' . str_replace( '`', '``', $identifier ) . '`';
929
+function wordpoints_escape_mysql_identifier($identifier) {
930
+	return '`'.str_replace('`', '``', $identifier).'`';
931 931
 }
932 932
 
933 933
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/action/post/depublish/delete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@
 block discarded – undo
19 19
 	 */
20 20
 	public function should_fire() {
21 21
 
22
-		$post = $this->get_arg_value( 'post' );
22
+		$post = $this->get_arg_value('post');
23 23
 
24
-		if ( ! $post ) {
24
+		if ( ! $post) {
25 25
 			return false;
26 26
 		}
27 27
 
28
-		if ( 'publish' !== get_post_status( $post ) ) {
28
+		if ('publish' !== get_post_status($post)) {
29 29
 			return false;
30 30
 		}
31 31
 
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' );
72
+		return $this->get_meta('reactor');
73 73
 	}
74 74
 
75 75
 	/**
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
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	public function get_ui_script_data() {
39 39
 
40 40
 		$periods = array(
41
-			MINUTE_IN_SECONDS   => __( 'Minute', 'wordpoints' ),
42
-			HOUR_IN_SECONDS     => __( 'Hour',   'wordpoints' ),
43
-			DAY_IN_SECONDS      => __( 'Day',    'wordpoints' ),
44
-			WEEK_IN_SECONDS     => __( 'Week',   'wordpoints' ),
45
-			30 * DAY_IN_SECONDS => __( 'Month',  'wordpoints' ),
41
+			MINUTE_IN_SECONDS   => __('Minute', 'wordpoints'),
42
+			HOUR_IN_SECONDS     => __('Hour', 'wordpoints'),
43
+			DAY_IN_SECONDS      => __('Day', 'wordpoints'),
44
+			WEEK_IN_SECONDS     => __('Week', 'wordpoints'),
45
+			30 * DAY_IN_SECONDS => __('Month', 'wordpoints'),
46 46
 		);
47 47
 
48 48
 		/**
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 		 *
53 53
 		 * @param string[] $periods The period titles, indexed by length in seconds.
54 54
 		 */
55
-		$periods = apply_filters( 'wordpoints_hooks_ui_data_periods', $periods );
55
+		$periods = apply_filters('wordpoints_hooks_ui_data_periods', $periods);
56 56
 
57 57
 		return array(
58 58
 			'periods' => $periods,
59 59
 			'l10n' => array(
60
-				'label' => __( 'Trigger reaction no more than once per:', 'wordpoints' ),
60
+				'label' => __('Trigger reaction no more than once per:', 'wordpoints'),
61 61
 			),
62 62
 		);
63 63
 	}
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return array The validated periods.
73 73
 	 */
74
-	protected function validate_action_type_settings( $periods ) {
74
+	protected function validate_action_type_settings($periods) {
75 75
 
76
-		if ( ! is_array( $periods ) ) {
76
+		if ( ! is_array($periods)) {
77 77
 
78 78
 			$this->validator->add_error(
79
-				__( 'Periods do not match expected format.', 'wordpoints' )
79
+				__('Periods do not match expected format.', 'wordpoints')
80 80
 			);
81 81
 
82 82
 			return array();
83 83
 		}
84 84
 
85
-		foreach ( $periods as $index => $period ) {
85
+		foreach ($periods as $index => $period) {
86 86
 
87
-			$this->validator->push_field( $index );
87
+			$this->validator->push_field($index);
88 88
 
89
-			$period = $this->validate_period( $period );
89
+			$period = $this->validate_period($period);
90 90
 
91
-			if ( $period ) {
92
-				$periods[ $index ] = $period;
91
+			if ($period) {
92
+				$periods[$index] = $period;
93 93
 			}
94 94
 
95 95
 			$this->validator->pop_field();
@@ -107,30 +107,30 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return array|false The validated period, or false if invalid.
109 109
 	 */
110
-	protected function validate_period( $period ) {
110
+	protected function validate_period($period) {
111 111
 
112
-		if ( ! is_array( $period ) ) {
112
+		if ( ! is_array($period)) {
113 113
 			$this->validator->add_error(
114
-				__( 'Period does not match expected format.', 'wordpoints' )
114
+				__('Period does not match expected format.', 'wordpoints')
115 115
 			);
116 116
 
117 117
 			return false;
118 118
 		}
119 119
 
120
-		if ( isset( $period['args'] ) ) {
121
-			$this->validate_period_args( $period['args'] );
120
+		if (isset($period['args'])) {
121
+			$this->validate_period_args($period['args']);
122 122
 		}
123 123
 
124
-		if ( ! isset( $period['length'] ) ) {
124
+		if ( ! isset($period['length'])) {
125 125
 
126 126
 			$this->validator->add_error(
127
-				__( 'Period length setting is missing.', 'wordpoints' )
127
+				__('Period length setting is missing.', 'wordpoints')
128 128
 			);
129 129
 
130
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
130
+		} elseif (false === wordpoints_posint($period['length'])) {
131 131
 
132 132
 			$this->validator->add_error(
133
-				__( 'Period length must be a positive integer.', 'wordpoints' )
133
+				__('Period length must be a positive integer.', 'wordpoints')
134 134
 				, 'length'
135 135
 			);
136 136
 
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param mixed $args The args the period is related to.
149 149
 	 */
150
-	protected function validate_period_args( $args ) {
150
+	protected function validate_period_args($args) {
151 151
 
152
-		if ( ! is_array( $args ) ) {
152
+		if ( ! is_array($args)) {
153 153
 
154 154
 			$this->validator->add_error(
155
-				__( 'Period does not match expected format.', 'wordpoints' )
155
+				__('Period does not match expected format.', 'wordpoints')
156 156
 				, 'args'
157 157
 			);
158 158
 
159 159
 			return;
160 160
 		}
161 161
 
162
-		$this->validator->push_field( 'args' );
162
+		$this->validator->push_field('args');
163 163
 
164
-		foreach ( $args as $index => $hierarchy ) {
164
+		foreach ($args as $index => $hierarchy) {
165 165
 
166
-			$this->validator->push_field( $index );
166
+			$this->validator->push_field($index);
167 167
 
168
-			if ( ! is_array( $hierarchy ) ) {
168
+			if ( ! is_array($hierarchy)) {
169 169
 
170 170
 				$this->validator->add_error(
171
-					__( 'Period does not match expected format.', 'wordpoints' )
171
+					__('Period does not match expected format.', 'wordpoints')
172 172
 				);
173 173
 
174
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
174
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
175 175
 
176 176
 				$this->validator->add_error(
177
-					__( 'Invalid arg hierarchy for period.', 'wordpoints' )
177
+					__('Invalid arg hierarchy for period.', 'wordpoints')
178 178
 				);
179 179
 			}
180 180
 
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	/**
188 188
 	 * @since 1.0.0
189 189
 	 */
190
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
190
+	public function should_hit(WordPoints_Hook_Fire $fire) {
191 191
 
192
-		$periods = $this->get_settings_from_fire( $fire );
192
+		$periods = $this->get_settings_from_fire($fire);
193 193
 
194
-		if ( empty( $periods ) ) {
194
+		if (empty($periods)) {
195 195
 			return true;
196 196
 		}
197 197
 
198 198
 		$this->event_args = $fire->event_args;
199 199
 		$this->action_type = $fire->action_type;
200 200
 
201
-		foreach ( $periods as $period ) {
202
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
201
+		foreach ($periods as $period) {
202
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
203 203
 				return false;
204 204
 			}
205 205
 		}
@@ -223,24 +223,24 @@  discard block
 block discarded – undo
223 223
 	) {
224 224
 
225 225
 		$period = $this->get_period_by_reaction(
226
-			$this->get_period_signature( $settings, $reaction )
226
+			$this->get_period_signature($settings, $reaction)
227 227
 			, $reaction
228 228
 		);
229 229
 
230 230
 		// If the period isn't found, we know that we can still fire.
231
-		if ( ! $period ) {
231
+		if ( ! $period) {
232 232
 			return true;
233 233
 		}
234 234
 
235
-		$now = current_time( 'timestamp' );
236
-		$hit_time = strtotime( $period->date, $now );
235
+		$now = current_time('timestamp');
236
+		$hit_time = strtotime($period->date, $now);
237 237
 
238
-		if ( ! empty( $settings['relative'] ) ) {
239
-			return ( $hit_time < $now - $settings['length'] );
238
+		if ( ! empty($settings['relative'])) {
239
+			return ($hit_time < $now - $settings['length']);
240 240
 		} else {
241 241
 			return (
242
-				(int) ( $hit_time / $settings['length'] )
243
-				< (int) ( $now / $settings['length'] )
242
+				(int) ($hit_time / $settings['length'])
243
+				< (int) ($now / $settings['length'])
244 244
 			);
245 245
 		}
246 246
 	}
@@ -254,24 +254,24 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return array The arg values.
256 256
 	 */
257
-	protected function get_arg_values( array $period_args ) {
257
+	protected function get_arg_values(array $period_args) {
258 258
 
259 259
 		$values = array();
260 260
 
261
-		foreach ( $period_args as $arg_hierarchy ) {
261
+		foreach ($period_args as $arg_hierarchy) {
262 262
 
263 263
 			$arg = $this->event_args->get_from_hierarchy(
264 264
 				$arg_hierarchy
265 265
 			);
266 266
 
267
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
267
+			if ( ! $arg instanceof WordPoints_EntityishI) {
268 268
 				continue;
269 269
 			}
270 270
 
271
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
271
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
272 272
 		}
273 273
 
274
-		ksort( $values );
274
+		ksort($values);
275 275
 
276 276
 		return $values;
277 277
 	}
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return object|false The period data, or false if not found.
287 287
 	 */
288
-	protected function get_period( $period_id ) {
288
+	protected function get_period($period_id) {
289 289
 
290
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_periods' );
290
+		$period = wp_cache_get($period_id, 'wordpoints_hook_periods');
291 291
 
292
-		if ( ! $period ) {
292
+		if ( ! $period) {
293 293
 
294 294
 			global $wpdb;
295 295
 
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 				)
307 307
 			);
308 308
 
309
-			if ( ! $period ) {
309
+			if ( ! $period) {
310 310
 				return false;
311 311
 			}
312 312
 
313
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
313
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
314 314
 		}
315 315
 
316 316
 		return $period;
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 
335 335
 		$reaction_guid = $reaction->get_guid();
336 336
 
337
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}-{$this->action_type}";
337
+		$cache_key = wp_json_encode($reaction_guid)."-{$signature}-{$this->action_type}";
338 338
 
339 339
 		// Before we run the query, we try to lookup the ID in the cache.
340
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' );
340
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction');
341 341
 
342 342
 		// If we found it, we can retrieve the period by ID instead.
343
-		if ( $period_id ) {
344
-			return $this->get_period( $period_id );
343
+		if ($period_id) {
344
+			return $this->get_period($period_id);
345 345
 		}
346 346
 
347 347
 		global $wpdb;
@@ -364,18 +364,18 @@  discard block
 block discarded – undo
364 364
 				"
365 365
 				, $signature
366 366
 				, $reaction_guid['store']
367
-				, wp_json_encode( $reaction_guid['context_id'] )
367
+				, wp_json_encode($reaction_guid['context_id'])
368 368
 				, $reaction_guid['id']
369 369
 				, $this->action_type
370 370
 			)
371 371
 		);
372 372
 
373
-		if ( ! $period ) {
373
+		if ( ! $period) {
374 374
 			return false;
375 375
 		}
376 376
 
377
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' );
378
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
377
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction');
378
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
379 379
 
380 380
 		return $period;
381 381
 	}
@@ -383,21 +383,21 @@  discard block
 block discarded – undo
383 383
 	/**
384 384
 	 * @since 1.0.0
385 385
 	 */
386
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
386
+	public function after_hit(WordPoints_Hook_Fire $fire) {
387 387
 
388
-		$periods = $this->get_settings_from_fire( $fire );
388
+		$periods = $this->get_settings_from_fire($fire);
389 389
 
390
-		if ( empty( $periods ) ) {
390
+		if (empty($periods)) {
391 391
 			return;
392 392
 		}
393 393
 
394 394
 		$this->event_args = $fire->event_args;
395 395
 		$this->action_type = $fire->action_type;
396 396
 
397
-		foreach ( $periods as $settings ) {
397
+		foreach ($periods as $settings) {
398 398
 
399 399
 			$this->add_period(
400
-				$this->get_period_signature( $settings, $fire->reaction )
400
+				$this->get_period_signature($settings, $fire->reaction)
401 401
 				, $fire
402 402
 			);
403 403
 		}
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 		WordPoints_Hook_ReactionI $reaction
423 423
 	) {
424 424
 
425
-		if ( isset( $settings['args'] ) ) {
425
+		if (isset($settings['args'])) {
426 426
 			$period_args = $settings['args'];
427 427
 		} else {
428
-			$period_args = array( $reaction->get_meta( 'target' ) );
428
+			$period_args = array($reaction->get_meta('target'));
429 429
 		}
430 430
 
431 431
 		return wordpoints_hash(
432
-			wp_json_encode( $this->get_arg_values( $period_args ) )
432
+			wp_json_encode($this->get_arg_values($period_args))
433 433
 		);
434 434
 	}
435 435
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return false|object The period data, or false if not found.
445 445
 	 */
446
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
446
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
447 447
 
448 448
 		global $wpdb;
449 449
 
@@ -453,17 +453,17 @@  discard block
 block discarded – undo
453 453
 				'hit_id' => $fire->hit_id,
454 454
 				'signature' => $signature,
455 455
 			)
456
-			, array( '%d', '%s' )
456
+			, array('%d', '%s')
457 457
 		);
458 458
 
459
-		if ( ! $inserted ) {
459
+		if ( ! $inserted) {
460 460
 			return false;
461 461
 		}
462 462
 
463 463
 		$period_id = $wpdb->insert_id;
464 464
 
465 465
 		wp_cache_set(
466
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}-{$this->action_type}"
466
+			wp_json_encode($fire->reaction->get_guid())."-{$signature}-{$this->action_type}"
467 467
 			, $period_id
468 468
 			, 'wordpoints_hook_period_ids_by_reaction'
469 469
 		);
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/store/options.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @since 1.0.0
24 24
 	 */
25
-	public function reaction_exists( $id ) {
26
-		return (bool) $this->get_option( $this->get_settings_option_name( $id ) );
25
+	public function reaction_exists($id) {
26
+		return (bool) $this->get_option($this->get_settings_option_name($id));
27 27
 	}
28 28
 
29 29
 	/**
30 30
 	 * @since 1.0.0
31 31
 	 */
32 32
 	public function get_reactions() {
33
-		return $this->create_reaction_objects( $this->get_reaction_index() );
33
+		return $this->create_reaction_objects($this->get_reaction_index());
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @since 1.0.0
38 38
 	 */
39
-	public function get_reactions_to_event( $event_slug ) {
39
+	public function get_reactions_to_event($event_slug) {
40 40
 
41 41
 		$index = $this->get_reaction_index();
42
-		$index = wp_list_filter( $index, array( 'event' => $event_slug ) );
43
-		return $this->create_reaction_objects( $index );
42
+		$index = wp_list_filter($index, array('event' => $event_slug));
43
+		return $this->create_reaction_objects($index);
44 44
 	}
45 45
 
46 46
 	/**
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	protected function get_reaction_index() {
61 61
 
62
-		$index = $this->get_option( $this->get_reaction_index_option_name() );
62
+		$index = $this->get_option($this->get_reaction_index_option_name());
63 63
 
64
-		if ( ! is_array( $index ) ) {
64
+		if ( ! is_array($index)) {
65 65
 			$index = array();
66 66
 		}
67 67
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return bool Whether the index was updated successfully.
79 79
 	 */
80
-	protected function update_reaction_index( $index ) {
80
+	protected function update_reaction_index($index) {
81 81
 
82 82
 		return $this->update_option(
83 83
 			$this->get_reaction_index_option_name()
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return string|false The event slug, or false if not found.
98 98
 	 */
99
-	public function get_reaction_event_from_index( $id ) {
99
+	public function get_reaction_event_from_index($id) {
100 100
 
101 101
 		$index = $this->get_reaction_index();
102 102
 
103
-		if ( ! isset( $index[ $id ]['event'] ) ) {
103
+		if ( ! isset($index[$id]['event'])) {
104 104
 			return false;
105 105
 		}
106 106
 
107
-		return $index[ $id ]['event'];
107
+		return $index[$id]['event'];
108 108
 	}
109 109
 
110 110
 	/**
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return bool Whether the event was updated successfully.
121 121
 	 */
122
-	public function update_reaction_event_in_index( $id, $event ) {
122
+	public function update_reaction_event_in_index($id, $event) {
123 123
 
124 124
 		$index = $this->get_reaction_index();
125 125
 
126
-		if ( ! isset( $index[ $id ] ) ) {
126
+		if ( ! isset($index[$id])) {
127 127
 			return false;
128 128
 		}
129 129
 
130
-		$index[ $id ]['event'] = $event;
130
+		$index[$id]['event'] = $event;
131 131
 
132
-		return $this->update_reaction_index( $index );
132
+		return $this->update_reaction_index($index);
133 133
 	}
134 134
 
135 135
 	/**
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return WordPoints_Hook_Reaction_Options[] The objects for the reactions.
143 143
 	 */
144
-	protected function create_reaction_objects( $index ) {
144
+	protected function create_reaction_objects($index) {
145 145
 
146 146
 		$reactions = array();
147 147
 
148
-		foreach ( $index as $reaction ) {
148
+		foreach ($index as $reaction) {
149 149
 
150
-			$object = $this->get_reaction( $reaction['id'] );
150
+			$object = $this->get_reaction($reaction['id']);
151 151
 
152
-			if ( ! $object ) {
152
+			if ( ! $object) {
153 153
 				continue;
154 154
 			}
155 155
 
@@ -162,52 +162,52 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * @since 1.0.0
164 164
 	 */
165
-	public function delete_reaction( $id ) {
165
+	public function delete_reaction($id) {
166 166
 
167
-		if ( ! $this->reaction_exists( $id ) ) {
167
+		if ( ! $this->reaction_exists($id)) {
168 168
 			return false;
169 169
 		}
170 170
 
171
-		$result = $this->delete_option( $this->get_settings_option_name( $id ) );
171
+		$result = $this->delete_option($this->get_settings_option_name($id));
172 172
 
173
-		if ( ! $result ) {
173
+		if ( ! $result) {
174 174
 			return false;
175 175
 		}
176 176
 
177 177
 		$index = $this->get_reaction_index();
178 178
 
179
-		unset( $index[ $id ] );
179
+		unset($index[$id]);
180 180
 
181
-		return $this->update_reaction_index( $index );
181
+		return $this->update_reaction_index($index);
182 182
 	}
183 183
 
184 184
 	/**
185 185
 	 * @since 1.0.0
186 186
 	 */
187
-	protected function _create_reaction( $event_slug ) {
187
+	protected function _create_reaction($event_slug) {
188 188
 
189 189
 		$index = $this->get_reaction_index();
190 190
 
191
-		$id = $this->get_next_id( $index );
191
+		$id = $this->get_next_id($index);
192 192
 
193
-		$settings = array( 'event' => $event_slug );
193
+		$settings = array('event' => $event_slug);
194 194
 
195 195
 		$result = $this->add_option(
196
-			$this->get_settings_option_name( $id )
196
+			$this->get_settings_option_name($id)
197 197
 			, $settings
198 198
 		);
199 199
 
200
-		if ( ! $result ) {
200
+		if ( ! $result) {
201 201
 			return false;
202 202
 		}
203 203
 
204
-		$index[ $id ] = array( 'event' => $event_slug, 'id' => $id );
204
+		$index[$id] = array('event' => $event_slug, 'id' => $id);
205 205
 
206
-		if ( ! $this->update_reaction_index( $index ) ) {
206
+		if ( ! $this->update_reaction_index($index)) {
207 207
 			return false;
208 208
 		}
209 209
 
210
-		$this->update_option( $this->get_last_reaction_id_option_name(), $id );
210
+		$this->update_option($this->get_last_reaction_id_option_name(), $id);
211 211
 
212 212
 		return $id;
213 213
 	}
@@ -221,23 +221,23 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return int The ID to use for the next reaction.
223 223
 	 */
224
-	protected function get_next_id( $index ) {
224
+	protected function get_next_id($index) {
225 225
 
226 226
 		$id = 1;
227 227
 
228
-		$last_id = $this->get_option( $this->get_last_reaction_id_option_name() );
228
+		$last_id = $this->get_option($this->get_last_reaction_id_option_name());
229 229
 
230
-		if ( wordpoints_posint( $last_id ) ) {
230
+		if (wordpoints_posint($last_id)) {
231 231
 			$id = $last_id + 1;
232 232
 		}
233 233
 
234 234
 		// Double-check this against the index. This should avoid some issues from
235 235
 		// race conditions.
236
-		if ( ! empty( $index ) ) {
236
+		if ( ! empty($index)) {
237 237
 
238
-			$max = max( array_keys( $index ) );
238
+			$max = max(array_keys($index));
239 239
 
240
-			if ( $max >= $id ) {
240
+			if ($max >= $id) {
241 241
 				$id = $max + 1;
242 242
 			}
243 243
 		}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return mixed The option value, or false.
258 258
 	 */
259
-	public function get_option( $name ) {
260
-		return get_option( $name );
259
+	public function get_option($name) {
260
+		return get_option($name);
261 261
 	}
262 262
 
263 263
 	/**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return bool Whether the option was added successfully.
272 272
 	 */
273
-	protected function add_option( $name, $value ) {
274
-		return add_option( $name, $value );
273
+	protected function add_option($name, $value) {
274
+		return add_option($name, $value);
275 275
 	}
276 276
 
277 277
 	/**
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return bool Whether the option was updated successfully.
288 288
 	 */
289
-	public function update_option( $name, $value ) {
290
-		return update_option( $name, $value );
289
+	public function update_option($name, $value) {
290
+		return update_option($name, $value);
291 291
 	}
292 292
 
293 293
 	/**
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return bool Whether the option was deleted successfully.
301 301
 	 */
302
-	protected function delete_option( $name ) {
303
-		return delete_option( $name );
302
+	protected function delete_option($name) {
303
+		return delete_option($name);
304 304
 	}
305 305
 
306 306
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return string The name of the option where the settings are stored.
316 316
 	 */
317
-	public function get_settings_option_name( $id ) {
317
+	public function get_settings_option_name($id) {
318 318
 
319 319
 		$current_mode = wordpoints_hooks()->get_current_mode();
320 320
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/string/contains.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @since 1.0.0
19 19
 	 */
20 20
 	public function get_title() {
21
-		return __( 'Contains', 'wordpoints' );
21
+		return __('Contains', 'wordpoints');
22 22
 	}
23 23
 
24 24
 	/**
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return array(
29 29
 			'value' => array(
30 30
 				'type'     => 'text',
31
-				'label'    => __( 'Word or phrase (case sensitive)', 'wordpoints' ),
31
+				'label'    => __('Word or phrase (case sensitive)', 'wordpoints'),
32 32
 				'required' => true,
33 33
 			),
34 34
 		);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
40
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
41 41
 
42 42
 		return false !== strpos(
43 43
 			$args->get_current()->get_the_value()
Please login to merge, or discard this patch.