Completed
Push — master ( a97d75...975fd1 )
by J.D.
03:39
created
src/admin/includes/functions.php 1 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.