Completed
Push — master ( 975fd1...3e68e7 )
by J.D.
03:16
created
src/admin/includes/classes/screen/points/types.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	protected function get_title() {
59
-		return _x( 'Points Types', 'page title', 'wordpoints' );
59
+		return _x('Points Types', 'page title', 'wordpoints');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 
67 67
 		parent::hooks();
68 68
 
69
-		add_action( 'add_meta_boxes', array( $this, 'add_points_settings_meta_box' ) );
70
-		add_action( 'add_meta_boxes', array( $this, 'add_event_meta_boxes' ) );
69
+		add_action('add_meta_boxes', array($this, 'add_points_settings_meta_box'));
70
+		add_action('add_meta_boxes', array($this, 'add_event_meta_boxes'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function enqueue_scripts() {
77 77
 
78
-		wp_enqueue_style( 'wordpoints-hooks-admin' );
78
+		wp_enqueue_style('wordpoints-hooks-admin');
79 79
 
80
-		wp_enqueue_script( 'postbox' );
81
-		wp_enqueue_script( 'wordpoints-admin-points-types' );
80
+		wp_enqueue_script('postbox');
81
+		wp_enqueue_script('wordpoints-admin-points-types');
82 82
 
83 83
 		wordpoints_hooks_ui_setup_script_data();
84 84
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 					.addClass( 'closed' );
99 99
 
100 100
 				postboxes.add_postbox_toggles(
101
-					<?php echo wp_json_encode( $this->id ); ?>
101
+					<?php echo wp_json_encode($this->id); ?>
102 102
 				);
103 103
 			} );
104 104
 		</script>
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function add_points_settings_meta_box() {
115 115
 
116
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
116
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
117 117
 			return;
118 118
 		}
119 119
 
120 120
 		add_meta_box(
121 121
 			'settings'
122
-			, __( 'Settings', 'wordpoints' )
123
-			, array( $this, 'display_points_settings_meta_box' )
122
+			, __('Settings', 'wordpoints')
123
+			, array($this, 'display_points_settings_meta_box')
124 124
 			, $this->id
125 125
 			, 'side'
126 126
 			, 'default'
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function display_points_settings_meta_box() {
136 136
 
137
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
137
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
138 138
 			return;
139 139
 		}
140 140
 
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$add_new = 0;
144 144
 
145
-		$points_type = wordpoints_get_points_type( $slug );
145
+		$points_type = wordpoints_get_points_type($slug);
146 146
 
147
-		if ( ! $points_type ) {
147
+		if ( ! $points_type) {
148 148
 
149 149
 			$points_type = array();
150
-			$add_new     = wp_create_nonce( 'wordpoints_add_new_points_type' );
150
+			$add_new     = wp_create_nonce('wordpoints_add_new_points_type');
151 151
 		}
152 152
 
153 153
 		$points_type = array_merge(
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 		?>
163 163
 
164 164
 		<form method="post">
165
-			<?php if ( $slug ) : ?>
165
+			<?php if ($slug) : ?>
166 166
 				<p>
167 167
 					<span class="wordpoints-points-slug">
168 168
 						<em>
169
-							<?php echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) ); ?>
169
+							<?php echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug)); ?>
170 170
 						</em>
171 171
 					</span>
172 172
 				</p>
173
-				<?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?>
173
+				<?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?>
174 174
 			<?php endif; ?>
175 175
 
176 176
 			<?php
@@ -184,45 +184,45 @@  discard block
 block discarded – undo
184 184
 			 *
185 185
 			 * @param string $points_type The slug of the points type.
186 186
 			 */
187
-			do_action( 'wordpoints_points_type_form_top', $slug );
187
+			do_action('wordpoints_points_type_form_top', $slug);
188 188
 
189
-			if ( $add_new ) {
189
+			if ($add_new) {
190 190
 
191 191
 				// Mark the prefix and suffix optional on the add new form.
192
-				$prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' );
193
-				$suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' );
192
+				$prefix = _x('Prefix (optional):', 'points type', 'wordpoints');
193
+				$suffix = _x('Suffix (optional):', 'points type', 'wordpoints');
194 194
 
195 195
 			} else {
196 196
 
197
-				$prefix = _x( 'Prefix:', 'points type', 'wordpoints' );
198
-				$suffix = _x( 'Suffix:', 'points type', 'wordpoints' );
197
+				$prefix = _x('Prefix:', 'points type', 'wordpoints');
198
+				$suffix = _x('Suffix:', 'points type', 'wordpoints');
199 199
 			}
200 200
 
201 201
 			?>
202 202
 
203 203
 			<p>
204 204
 				<label
205
-					for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label>
205
+					for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label>
206 206
 				<input class="widefat" type="text"
207
-				       id="points-name-<?php echo esc_attr( $slug ); ?>"
207
+				       id="points-name-<?php echo esc_attr($slug); ?>"
208 208
 				       name="points-name"
209
-				       value="<?php echo esc_attr( $points_type['name'] ); ?>"/>
209
+				       value="<?php echo esc_attr($points_type['name']); ?>"/>
210 210
 			</p>
211 211
 			<p>
212 212
 				<label
213
-					for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label>
213
+					for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label>
214 214
 				<input class="widefat" type="text"
215
-				       id="points-prefix-<?php echo esc_attr( $slug ); ?>"
215
+				       id="points-prefix-<?php echo esc_attr($slug); ?>"
216 216
 				       name="points-prefix"
217
-				       value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/>
217
+				       value="<?php echo esc_attr($points_type['prefix']); ?>"/>
218 218
 			</p>
219 219
 			<p>
220 220
 				<label
221
-					for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label>
221
+					for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label>
222 222
 				<input class="widefat" type="text"
223
-				       id="points-suffix-<?php echo esc_attr( $slug ); ?>"
223
+				       id="points-suffix-<?php echo esc_attr($slug); ?>"
224 224
 				       name="points-suffix"
225
-				       value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/>
225
+				       value="<?php echo esc_attr($points_type['suffix']); ?>"/>
226 226
 			</p>
227 227
 
228 228
 			<?php
@@ -236,28 +236,28 @@  discard block
 block discarded – undo
236 236
 			 *
237 237
 			 * @param string $points_type The slug of the points type.
238 238
 			 */
239
-			do_action( 'wordpoints_points_type_form_bottom', $slug );
239
+			do_action('wordpoints_points_type_form_bottom', $slug);
240 240
 
241 241
 			?>
242 242
 
243 243
 			<input type="hidden" name="points-slug"
244
-			       value="<?php echo esc_attr( $slug ); ?>"/>
244
+			       value="<?php echo esc_attr($slug); ?>"/>
245 245
 			<input type="hidden" name="add_new" class="add_new"
246
-			       value="<?php echo esc_attr( $add_new ); ?>"/>
246
+			       value="<?php echo esc_attr($add_new); ?>"/>
247 247
 
248 248
 			<div class="hook-control-actions">
249 249
 				<div class="alignleft">
250 250
 					<?php
251 251
 
252
-					if ( ! $add_new ) {
253
-						wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' );
254
-						submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) );
252
+					if ( ! $add_new) {
253
+						wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce');
254
+						submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}"));
255 255
 					}
256 256
 
257 257
 					?>
258 258
 				</div>
259 259
 				<div class="alignright">
260
-					<?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?>
260
+					<?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?>
261 261
 					<span class="spinner"></span>
262 262
 				</div>
263 263
 				<br class="clear"/>
@@ -274,18 +274,18 @@  discard block
 block discarded – undo
274 274
 	 */
275 275
 	public function add_event_meta_boxes() {
276 276
 
277
-		if ( ! $this->current_points_type ) {
277
+		if ( ! $this->current_points_type) {
278 278
 			return;
279 279
 		}
280 280
 
281 281
 		/** @var WordPoints_Hook_ReactorI $reactor */
282
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( 'points' );
283
-		$reactor_action_types = array_fill_keys( $reactor->get_action_types(), true );
282
+		$reactor = $this->hooks->get_sub_app('reactors')->get('points');
283
+		$reactor_action_types = array_fill_keys($reactor->get_action_types(), true);
284 284
 
285 285
 		$event_action_types = wordpoints_hooks_ui_get_script_data_event_action_types();
286 286
 
287 287
 		/** @var WordPoints_Hook_EventI[] $events */
288
-		$events = $this->hooks->get_sub_app( 'events' )->get_all();
288
+		$events = $this->hooks->get_sub_app('events')->get_all();
289 289
 
290 290
 		/**
291 291
 		 * Filter the events to show meta boxes for on the Points Types admin screen.
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 			, $this->current_points_type
306 306
 		);
307 307
 
308
-		foreach ( $events as $slug => $event ) {
308
+		foreach ($events as $slug => $event) {
309 309
 
310 310
 			if (
311 311
 				! array_intersect_key(
312
-					$event_action_types[ $slug ]
312
+					$event_action_types[$slug]
313 313
 					, $reactor_action_types
314 314
 				)
315 315
 			) {
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			add_meta_box(
320 320
 				"{$this->current_points_type}-{$slug}"
321 321
 				, $event->get_title()
322
-				, array( $this, 'display_event_meta_box' )
322
+				, array($this, 'display_event_meta_box')
323 323
 				, $this->id
324 324
 				, 'events'
325 325
 				, 'default'
@@ -340,54 +340,54 @@  discard block
 block discarded – undo
340 340
 	 * @param array $points_type The points type this meta-box relates to.
341 341
 	 * @param array $meta_box    The data the meta-box was created with.
342 342
 	 */
343
-	public function display_event_meta_box( $points_type, $meta_box ) {
343
+	public function display_event_meta_box($points_type, $meta_box) {
344 344
 
345 345
 		$event_slug = $meta_box['args']['slug'];
346 346
 
347 347
 		$data = array();
348 348
 
349
-		$reaction_store = wordpoints_hooks()->get_reaction_store( 'points' );
349
+		$reaction_store = wordpoints_hooks()->get_reaction_store('points');
350 350
 
351
-		foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $id => $reaction ) {
352
-			if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) {
351
+		foreach ($reaction_store->get_reactions_to_event($event_slug) as $id => $reaction) {
352
+			if ($reaction->get_meta('points_type') === $this->current_points_type) {
353 353
 				$data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction(
354 354
 					$reaction
355 355
 				);
356 356
 			}
357 357
 		}
358 358
 
359
-		$args = $this->hooks->get_sub_app( 'events' )->get_sub_app( 'args' )->get_children( $event_slug );
359
+		$args = $this->hooks->get_sub_app('events')->get_sub_app('args')->get_children($event_slug);
360 360
 
361
-		$event_data = array( 'args' => array() );
361
+		$event_data = array('args' => array());
362 362
 
363
-		foreach ( $args as $slug => $arg ) {
363
+		foreach ($args as $slug => $arg) {
364 364
 
365
-			$event_data['args'][ $slug ] = array(
365
+			$event_data['args'][$slug] = array(
366 366
 				'slug' => $slug,
367 367
 			);
368 368
 
369
-			if ( $arg instanceof WordPoints_Hook_ArgI ) {
370
-				$event_data['args'][ $slug ]['title'] = $arg->get_title();
371
-				$event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful();
369
+			if ($arg instanceof WordPoints_Hook_ArgI) {
370
+				$event_data['args'][$slug]['title'] = $arg->get_title();
371
+				$event_data['args'][$slug]['is_stateful'] = $arg->is_stateful();
372 372
 			}
373 373
 		}
374 374
 
375 375
 		?>
376 376
 
377 377
 		<script>
378
-			WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>;
379
-			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>;
378
+			WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>;
379
+			WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>;
380 380
 		</script>
381 381
 
382 382
 		<div class="wordpoints-hook-reaction-group-container">
383 383
 			<p class="description wordpoints-hook-reaction-group-description">
384
-				<?php echo esc_html( $meta_box['args']['event']->get_description() ); ?>
384
+				<?php echo esc_html($meta_box['args']['event']->get_description()); ?>
385 385
 			</p>
386 386
 
387 387
 			<div class="wordpoints-hook-reaction-group"
388
-				data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>"
389
-				data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>"
390
-				data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $reaction_store ) ); ?>"
388
+				data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>"
389
+				data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>"
390
+				data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($reaction_store)); ?>"
391 391
 				data-wordpoints-hooks-reaction-store="points"
392 392
 				data-wordpoints-hooks-reactor="points">
393 393
 			</div>
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
 			<div class="controls">
404 404
 				<button type="button" class="button-primary add-reaction">
405
-					<?php esc_html_e( 'Add New', 'wordpoints' ); ?>
405
+					<?php esc_html_e('Add New', 'wordpoints'); ?>
406 406
 				</button>
407 407
 			</div>
408 408
 		</div>
@@ -422,19 +422,19 @@  discard block
 block discarded – undo
422 422
 		// Show a tab for each points type.
423 423
 		$tabs = array();
424 424
 
425
-		foreach ( $points_types as $slug => $settings ) {
426
-			$tabs[ $slug ] = $settings['name'];
425
+		foreach ($points_types as $slug => $settings) {
426
+			$tabs[$slug] = $settings['name'];
427 427
 		}
428 428
 
429
-		$tabs['add-new'] = __( 'Add New', 'wordpoints' );
429
+		$tabs['add-new'] = __('Add New', 'wordpoints');
430 430
 
431
-		$tab = wordpoints_admin_get_current_tab( $tabs );
431
+		$tab = wordpoints_admin_get_current_tab($tabs);
432 432
 
433
-		if ( 'add-new' !== $tab ) {
433
+		if ('add-new' !== $tab) {
434 434
 			$this->current_points_type = $tab;
435 435
 		}
436 436
 
437
-		do_action( 'add_meta_boxes', $this->id );
437
+		do_action('add_meta_boxes', $this->id);
438 438
 
439 439
 		$this->tabs = $tabs;
440 440
 	}
@@ -446,19 +446,19 @@  discard block
 block discarded – undo
446 446
 	 */
447 447
 	public function save_points_type() {
448 448
 
449
-		if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) {
449
+		if ( ! current_user_can('manage_wordpoints_points_types')) {
450 450
 			return;
451 451
 		}
452 452
 
453
-		if ( isset( $_POST['save-points-type'] ) ) { // WPCS: CSRF OK
453
+		if (isset($_POST['save-points-type'])) { // WPCS: CSRF OK
454 454
 
455
-			if ( isset( $_POST['points-slug'] ) ) { // WPCS: CSRF OK
455
+			if (isset($_POST['points-slug'])) { // WPCS: CSRF OK
456 456
 				$this->update_points_type();
457 457
 			} else {
458 458
 				$this->add_points_type();
459 459
 			}
460 460
 
461
-		} elseif ( ! empty( $_POST['delete-points-type'] ) ) { // WPCS: CSRF OK
461
+		} elseif ( ! empty($_POST['delete-points-type'])) { // WPCS: CSRF OK
462 462
 
463 463
 			$this->delete_points_type();
464 464
 		}
@@ -475,21 +475,21 @@  discard block
 block discarded – undo
475 475
 
476 476
 		$settings = array();
477 477
 
478
-		if ( isset( $_POST['points-name'] ) ) { // WPCS: CSRF OK
478
+		if (isset($_POST['points-name'])) { // WPCS: CSRF OK
479 479
 			$settings['name'] = trim(
480
-				sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) // WPCS: CSRF OK
480
+				sanitize_text_field(wp_unslash($_POST['points-name'])) // WPCS: CSRF OK
481 481
 			);
482 482
 		}
483 483
 
484
-		if ( isset( $_POST['points-prefix'] ) ) { // WPCS: CSRF OK
484
+		if (isset($_POST['points-prefix'])) { // WPCS: CSRF OK
485 485
 			$settings['prefix'] = ltrim(
486
-				sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) // WPCS: CSRF OK
486
+				sanitize_text_field(wp_unslash($_POST['points-prefix'])) // WPCS: CSRF OK
487 487
 			);
488 488
 		}
489 489
 
490
-		if ( isset( $_POST['points-suffix'] ) ) { // WPCS: CSRF OK
490
+		if (isset($_POST['points-suffix'])) { // WPCS: CSRF OK
491 491
 			$settings['suffix'] = rtrim(
492
-				sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) // WPCS: CSRF OK
492
+				sanitize_text_field(wp_unslash($_POST['points-suffix'])) // WPCS: CSRF OK
493 493
 			);
494 494
 		}
495 495
 
@@ -507,52 +507,52 @@  discard block
 block discarded – undo
507 507
 			! wordpoints_verify_nonce(
508 508
 				'update_points_type'
509 509
 				, 'wordpoints_update_points_type-%s'
510
-				, array( 'points-slug' )
510
+				, array('points-slug')
511 511
 				, 'post'
512 512
 			)
513
-			|| ! isset( $_POST['points-slug'] )
513
+			|| ! isset($_POST['points-slug'])
514 514
 		) {
515 515
 			return;
516 516
 		}
517 517
 
518 518
 		$settings = $this->get_points_type_settings();
519 519
 
520
-		if ( empty( $settings['name'] ) ) {
520
+		if (empty($settings['name'])) {
521 521
 
522 522
 			add_settings_error(
523 523
 				'points-name'
524 524
 				, 'wordpoints_points_type_update'
525
-				, __( 'Error: points type name cannot be empty.', 'wordpoints' )
525
+				, __('Error: points type name cannot be empty.', 'wordpoints')
526 526
 			);
527 527
 
528 528
 			return;
529 529
 		}
530 530
 
531
-		$points_type = sanitize_key( $_POST['points-slug'] );
531
+		$points_type = sanitize_key($_POST['points-slug']);
532 532
 
533
-		$old_settings = wordpoints_get_points_type( $points_type );
533
+		$old_settings = wordpoints_get_points_type($points_type);
534 534
 
535
-		if ( false === $old_settings ) {
535
+		if (false === $old_settings) {
536 536
 
537 537
 			add_settings_error(
538 538
 				''
539 539
 				, 'wordpoints_points_type_update'
540
-				, __( 'Error: failed updating points type.', 'wordpoints' )
540
+				, __('Error: failed updating points type.', 'wordpoints')
541 541
 			);
542 542
 
543 543
 			return;
544 544
 		}
545 545
 
546
-		if ( is_array( $old_settings ) ) {
547
-			$settings = array_merge( $old_settings, $settings );
546
+		if (is_array($old_settings)) {
547
+			$settings = array_merge($old_settings, $settings);
548 548
 		}
549 549
 
550
-		if ( ! wordpoints_update_points_type( $points_type, $settings ) ) {
550
+		if ( ! wordpoints_update_points_type($points_type, $settings)) {
551 551
 
552 552
 			add_settings_error(
553 553
 				''
554 554
 				, 'wordpoints_points_type_update'
555
-				, __( 'Error: failed updating points type.', 'wordpoints' )
555
+				, __('Error: failed updating points type.', 'wordpoints')
556 556
 			);
557 557
 
558 558
 		} else {
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 			add_settings_error(
561 561
 				''
562 562
 				, 'wordpoints_points_type_update'
563
-				, __( 'Points type updated.', 'wordpoints' )
563
+				, __('Points type updated.', 'wordpoints')
564 564
 				, 'updated'
565 565
 			);
566 566
 		}
@@ -586,14 +586,14 @@  discard block
 block discarded – undo
586 586
 
587 587
 		$settings = $this->get_points_type_settings();
588 588
 
589
-		$slug = wordpoints_add_points_type( $settings );
589
+		$slug = wordpoints_add_points_type($settings);
590 590
 
591
-		if ( ! $slug ) {
591
+		if ( ! $slug) {
592 592
 
593 593
 			add_settings_error(
594 594
 				''
595 595
 				, 'wordpoints_points_type_create'
596
-				, __( 'Please choose a unique name for this points type.', 'wordpoints' )
596
+				, __('Please choose a unique name for this points type.', 'wordpoints')
597 597
 			);
598 598
 
599 599
 		} else {
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 			add_settings_error(
604 604
 				''
605 605
 				, 'wordpoints_points_type_create'
606
-				, __( 'Points type created.', 'wordpoints' )
606
+				, __('Points type created.', 'wordpoints')
607 607
 				, 'updated'
608 608
 			);
609 609
 		}
@@ -620,22 +620,22 @@  discard block
 block discarded – undo
620 620
 			wordpoints_verify_nonce(
621 621
 				'delete-points-type-nonce'
622 622
 				, 'wordpoints_delete_points_type-%s'
623
-				, array( 'points-slug' )
623
+				, array('points-slug')
624 624
 				, 'post'
625 625
 			)
626
-			&& isset( $_POST['points-slug'] )
626
+			&& isset($_POST['points-slug'])
627 627
 		) {
628 628
 
629 629
 			if (
630 630
 				wordpoints_delete_points_type(
631
-					sanitize_key( $_POST['points-slug'] )
631
+					sanitize_key($_POST['points-slug'])
632 632
 				)
633 633
 			) {
634 634
 
635 635
 				add_settings_error(
636 636
 					''
637 637
 					, 'wordpoints_points_type_delete'
638
-					, __( 'Points type deleted.', 'wordpoints' )
638
+					, __('Points type deleted.', 'wordpoints')
639 639
 					, 'updated'
640 640
 				);
641 641
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 				add_settings_error(
645 645
 					''
646 646
 					, 'wordpoints_points_type_delete'
647
-					, __( 'Error while deleting.', 'wordpoints' )
647
+					, __('Error while deleting.', 'wordpoints')
648 648
 				);
649 649
 			}
650 650
 		}
@@ -660,25 +660,25 @@  discard block
 block discarded – undo
660 660
 		 *
661 661
 		 * @since 1.0.0
662 662
 		 */
663
-		do_action( 'wordpoints_admin_points_events_head' );
663
+		do_action('wordpoints_admin_points_events_head');
664 664
 
665
-		if ( is_network_admin() ) {
666
-			$title = __( 'Network Events', 'wordpoints' );
667
-			$description = __( 'Award points when various events happen on this network.', 'wordpoints' );
665
+		if (is_network_admin()) {
666
+			$title = __('Network Events', 'wordpoints');
667
+			$description = __('Award points when various events happen on this network.', 'wordpoints');
668 668
 		} else {
669
-			$title = __( 'Events', 'wordpoints' );
670
-			$description = __( 'Award points when various events happen on this site.', 'wordpoints' );
669
+			$title = __('Events', 'wordpoints');
670
+			$description = __('Award points when various events happen on this site.', 'wordpoints');
671 671
 		}
672 672
 
673
-		$points_type = wordpoints_get_points_type( $this->current_points_type );
673
+		$points_type = wordpoints_get_points_type($this->current_points_type);
674 674
 
675 675
 		?>
676 676
 
677 677
 		<div class="wordpoints-points-type-meta-box-wrap">
678 678
 
679 679
 				<form>
680
-					<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
681
-					<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
680
+					<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
681
+					<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
682 682
 				</form>
683 683
 
684 684
 				<div id="poststuff">
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 					<div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>">
687 687
 
688 688
 						<div id="postbox-container-1" class="postbox-container">
689
-							<?php do_meta_boxes( $this->id, 'side', $points_type ); ?>
689
+							<?php do_meta_boxes($this->id, 'side', $points_type); ?>
690 690
 						</div>
691 691
 
692
-						<?php if ( isset( $this->current_points_type ) ) : ?>
692
+						<?php if (isset($this->current_points_type)) : ?>
693 693
 							<div class="wordpoints-hook-events-heading">
694
-								<h2><?php echo esc_html( $title ); ?></h2>
695
-								<p class="description"><?php echo esc_html( $description ); ?></p>
694
+								<h2><?php echo esc_html($title); ?></h2>
695
+								<p class="description"><?php echo esc_html($description); ?></p>
696 696
 							</div>
697 697
 
698 698
 							<div id="postbox-container-2" class="postbox-container">
699
-								<?php do_meta_boxes( $this->id, 'events', $points_type ); ?>
699
+								<?php do_meta_boxes($this->id, 'events', $points_type); ?>
700 700
 							</div>
701 701
 						<?php endif; ?>
702 702
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 		 *
716 716
 		 * @since 1.0.0
717 717
 		 */
718
-		do_action( 'wordpoints_admin_points_events_foot' );
718
+		do_action('wordpoints_admin_points_events_foot');
719 719
 	}
720 720
 }
721 721
 
Please login to merge, or discard this patch.
src/admin/includes/functions.php 1 patch
Spacing   +94 added lines, -94 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
 /**
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
 	$wordpoints_menu = wordpoints_get_main_admin_menu();
42 42
 
43 43
 	/** @var WordPoints_Admin_Screens $admin_screens */
44
-	$admin_screens = wordpoints_apps()->get_sub_app( 'admin' )->get_sub_app(
44
+	$admin_screens = wordpoints_apps()->get_sub_app('admin')->get_sub_app(
45 45
 		'screen'
46 46
 	);
47 47
 
48 48
 	// Hooks page.
49 49
 	$id = add_submenu_page(
50 50
 		$wordpoints_menu
51
-		, __( 'WordPoints — Points Types', 'wordpoints' )
52
-		, __( 'Points Types', 'wordpoints' )
51
+		, __('WordPoints — Points Types', 'wordpoints')
52
+		, __('Points Types', 'wordpoints')
53 53
 		, 'manage_options'
54 54
 		, 'wordpoints_points_types'
55
-		, array( $admin_screens, 'display' )
55
+		, array($admin_screens, 'display')
56 56
 	);
57 57
 
58
-	if ( $id ) {
59
-		$admin_screens->register( $id, 'WordPoints_Admin_Screen_Points_Types' );
58
+	if ($id) {
59
+		$admin_screens->register($id, 'WordPoints_Admin_Screen_Points_Types');
60 60
 	}
61 61
 }
62 62
 
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function wordpoints_hooks_admin_register_scripts() {
71 71
 
72
-	$assets_url = wordpoints_modules_url( '/assets', dirname( __FILE__ ) );
72
+	$assets_url = wordpoints_modules_url('/assets', dirname(__FILE__));
73 73
 
74 74
 	// CSS
75 75
 
76 76
 	wp_register_style(
77 77
 		'wordpoints-hooks-admin'
78
-		, $assets_url . '/css/hooks.css'
79
-		, array( 'dashicons', 'wp-jquery-ui-dialog' )
78
+		, $assets_url.'/css/hooks.css'
79
+		, array('dashicons', 'wp-jquery-ui-dialog')
80 80
 		, WORDPOINTS_VERSION
81 81
 	);
82 82
 
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 
85 85
 	wp_register_script(
86 86
 		'wordpoints-admin-points-types'
87
-		, $assets_url . '/js/points-types.js'
88
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
87
+		, $assets_url.'/js/points-types.js'
88
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
89 89
 		, WORDPOINTS_VERSION
90 90
 	);
91 91
 
92 92
 	wp_register_script(
93 93
 		'wordpoints-hooks-models'
94
-		, $assets_url . '/js/hooks/models.js'
95
-		, array( 'backbone', 'jquery-ui-dialog', 'wp-util' )
94
+		, $assets_url.'/js/hooks/models.js'
95
+		, array('backbone', 'jquery-ui-dialog', 'wp-util')
96 96
 		, WORDPOINTS_VERSION
97 97
 	);
98 98
 
99 99
 	wp_register_script(
100 100
 		'wordpoints-hooks-views'
101
-		, $assets_url . '/js/hooks/views.js'
102
-		, array( 'wordpoints-hooks-models' )
101
+		, $assets_url.'/js/hooks/views.js'
102
+		, array('wordpoints-hooks-models')
103 103
 		, WORDPOINTS_VERSION
104 104
 	);
105 105
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		'wordpoints-admin-points-types'
108 108
 		, 'WordPointsPointsTypesL10n'
109 109
 		, array(
110
-			'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints' )
111
-			                   . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ),
112
-			'confirmTitle'  => esc_html__( 'Are you sure?', 'wordpoints' ),
113
-			'deleteText'    => esc_html__( 'Delete', 'wordpoints' ),
114
-			'cancelText'    => esc_html__( 'Cancel', 'wordpoints' ),
110
+			'confirmDelete' => esc_html__('Are you sure that you want to delete this points type? This will delete all related logs and event hooks.', 'wordpoints')
111
+			                   . ' '.esc_html__('Once a points type has been deleted, you cannot bring it back.', 'wordpoints'),
112
+			'confirmTitle'  => esc_html__('Are you sure?', 'wordpoints'),
113
+			'deleteText'    => esc_html__('Delete', 'wordpoints'),
114
+			'cancelText'    => esc_html__('Cancel', 'wordpoints'),
115 115
 		)
116 116
 	);
117 117
 
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 		'wordpoints-hooks-views'
120 120
 		, 'WordPointsHooksAdminL10n'
121 121
 		, array(
122
-			'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ),
123
-			'changesSaved'    => __( 'Your changes have been saved.', 'wordpoints' ),
122
+			'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'),
123
+			'changesSaved'    => __('Your changes have been saved.', 'wordpoints'),
124 124
 			/* translators: the name of the field that cannot be empty */
125
-			'emptyField'      => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ),
126
-			'confirmDelete'   => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ),
127
-			'confirmTitle'    => __( 'Are you sure?', 'wordpoints' ),
128
-			'deleteText'      => __( 'Delete', 'wordpoints' ),
129
-			'cancelText'      => __( 'Cancel', 'wordpoints' ),
130
-			'separator'       => __( ' » ', 'wordpoints' ),
131
-			'target_label'    => __( 'Target', 'wordpoints' ),
125
+			'emptyField'      => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'),
126
+			'confirmDelete'   => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'),
127
+			'confirmTitle'    => __('Are you sure?', 'wordpoints'),
128
+			'deleteText'      => __('Delete', 'wordpoints'),
129
+			'cancelText'      => __('Cancel', 'wordpoints'),
130
+			'separator'       => __(' » ', 'wordpoints'),
131
+			'target_label'    => __('Target', 'wordpoints'),
132 132
 			// translators: form field
133
-			'cannotBeChanged' => __( '(cannot be changed)', 'wordpoints' ),
134
-			'fieldsInvalid'   => __( 'Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints' ),
133
+			'cannotBeChanged' => __('(cannot be changed)', 'wordpoints'),
134
+			'fieldsInvalid'   => __('Error: the values of some fields are invalid. Please correct these and then try again.', 'wordpoints'),
135 135
 		)
136 136
 	);
137 137
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 			<div class="view">
144 144
 				<div class="title"></div>
145 145
 				<button type="button" class="edit button-secondary">
146
-					' . esc_html__( 'Edit', 'wordpoints' ) . '
146
+					' . esc_html__('Edit', 'wordpoints').'
147 147
 				</button>
148 148
 				<button type="button" class="close button-secondary">
149
-					' . esc_html__( 'Close', 'wordpoints' ) . '
149
+					' . esc_html__('Close', 'wordpoints').'
150 150
 				</button>
151 151
 			</div>
152 152
 			<div class="form">
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 						</div>
166 166
 						<div class="action-buttons">
167 167
 							<button type="button" class="save button-primary" disabled>
168
-								' . esc_html__( 'Save', 'wordpoints' ) . '
168
+								' . esc_html__('Save', 'wordpoints').'
169 169
 							</button>
170 170
 							<button type="button" class="cancel button-secondary">
171
-								' . esc_html__( 'Cancel', 'wordpoints' ) . '
171
+								' . esc_html__('Cancel', 'wordpoints').'
172 172
 							</button>
173 173
 							<button type="button" class="close button-secondary">
174
-								' . esc_html__( 'Close', 'wordpoints' ) . '
174
+								' . esc_html__('Close', 'wordpoints').'
175 175
 							</button>
176 176
 							<button type="button" class="delete button-secondary">
177
-								' . esc_html__( 'Delete', 'wordpoints' ) . '
177
+								' . esc_html__('Delete', 'wordpoints').'
178 178
 							</button>
179 179
 						</div>
180 180
 					</div>
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 
223 223
 	wp_register_script(
224 224
 		'wordpoints-hooks-reactor-points'
225
-		, $assets_url . '/js/hooks/reactors/points.js'
226
-		, array( 'wordpoints-hooks-views' )
225
+		, $assets_url.'/js/hooks/reactors/points.js'
226
+		, array('wordpoints-hooks-views')
227 227
 		, WORDPOINTS_VERSION
228 228
 	);
229 229
 
230 230
 	wp_register_script(
231 231
 		'wordpoints-hooks-extension-conditions'
232
-		, $assets_url . '/js/hooks/extensions/conditions.js'
233
-		, array( 'wordpoints-hooks-views' )
232
+		, $assets_url.'/js/hooks/extensions/conditions.js'
233
+		, array('wordpoints-hooks-views')
234 234
 		, WORDPOINTS_VERSION
235 235
 	);
236 236
 
@@ -240,25 +240,25 @@  discard block
 block discarded – undo
240 240
 		, '
241 241
 			<script type="text/template" id="tmpl-wordpoints-hook-condition-groups">
242 242
 				<div class="conditions-title section-title">
243
-					<h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4>
243
+					<h4>' . esc_html__('Conditions', 'wordpoints').'</h4>
244 244
 					<button type="button" class="add-new button-secondary button-link">
245
-						<span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span>
245
+						<span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span>
246 246
 						<span class="dashicons dashicons-plus"></span>
247 247
 					</button>
248 248
 				</div>
249 249
 				<div class="add-condition-form hidden">
250 250
 					<div class="no-conditions hidden">
251
-						' . esc_html__( 'No conditions available.', 'wordpoints' ) . '
251
+						' . esc_html__('No conditions available.', 'wordpoints').'
252 252
 					</div>
253 253
 					<div class="condition-selectors">
254 254
 						<div class="arg-selectors"></div>
255 255
 						<div class="condition-selector"></div>
256 256
 					</div>
257
-					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '">
258
-						' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . '
257
+					<button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'">
258
+						' . esc_html_x('Add', 'reaction condition', 'wordpoints').'
259 259
 					</button>
260
-					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '">
261
-						' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . '
260
+					<button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'">
261
+						' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').'
262 262
 					</button>
263 263
 				</div>
264 264
 				<div class="condition-groups section-content"></div>
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				<div class="condition-controls">
273 273
 					<div class="condition-title"></div>
274 274
 					<button type="button" class="delete button-secondary button-link">
275
-						<span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span>
275
+						<span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span>
276 276
 						<span class="dashicons dashicons-no"></span>
277 277
 					</button>
278 278
 				</div>
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 
291 291
 	wp_register_script(
292 292
 		'wordpoints-hooks-extension-periods'
293
-		, $assets_url . '/js/hooks/extensions/periods.js'
294
-		, array( 'wordpoints-hooks-views' )
293
+		, $assets_url.'/js/hooks/extensions/periods.js'
294
+		, array('wordpoints-hooks-views')
295 295
 		, WORDPOINTS_VERSION
296 296
 	);
297 297
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		, '
302 302
 			<script type="text/template" id="tmpl-wordpoints-hook-periods">
303 303
 				<div class="periods-title section-title">
304
-					<h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4>
304
+					<h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4>
305 305
 				</div>
306 306
 				<div class="periods section-content"></div>
307 307
 			</script>
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 	$hooks = wordpoints_hooks();
320 320
 
321 321
 	$extensions_data = wordpoints_hooks_ui_get_script_data_from_objects(
322
-		$hooks->get_sub_app( 'extensions' )->get_all()
322
+		$hooks->get_sub_app('extensions')->get_all()
323 323
 		, 'extension'
324 324
 	);
325 325
 
326 326
 	$reactor_data = wordpoints_hooks_ui_get_script_data_from_objects(
327
-		$hooks->get_sub_app( 'reactors' )->get_all()
327
+		$hooks->get_sub_app('reactors')->get_all()
328 328
 		, 'reactor'
329 329
 	);
330 330
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param array $data The data.
352 352
 	 */
353
-	$data = apply_filters( 'wordpoints_hooks_ui_data', $data );
353
+	$data = apply_filters('wordpoints_hooks_ui_data', $data);
354 354
 
355 355
 	wp_localize_script(
356 356
 		'wordpoints-hooks-models'
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @return array The data extracted from the objects.
372 372
  */
373
-function wordpoints_hooks_ui_get_script_data_from_objects( $objects, $type ) {
373
+function wordpoints_hooks_ui_get_script_data_from_objects($objects, $type) {
374 374
 
375 375
 	$data = array();
376 376
 
377
-	foreach ( $objects as $slug => $object ) {
377
+	foreach ($objects as $slug => $object) {
378 378
 
379
-		if ( $object instanceof WordPoints_Hook_UI_Script_Data_ProviderI ) {
380
-			$data[ $slug ] = $object->get_ui_script_data();
379
+		if ($object instanceof WordPoints_Hook_UI_Script_Data_ProviderI) {
380
+			$data[$slug] = $object->get_ui_script_data();
381 381
 		}
382 382
 
383
-		if ( wp_script_is( "wordpoints-hooks-{$type}-{$slug}", 'registered' ) ) {
384
-			wp_enqueue_script( "wordpoints-hooks-{$type}-{$slug}" );
383
+		if (wp_script_is("wordpoints-hooks-{$type}-{$slug}", 'registered')) {
384
+			wp_enqueue_script("wordpoints-hooks-{$type}-{$slug}");
385 385
 		}
386 386
 	}
387 387
 
@@ -402,31 +402,31 @@  discard block
 block discarded – undo
402 402
 	$entities_data = array();
403 403
 
404 404
 	/** @var WordPoints_Class_Registry_Children $entity_children */
405
-	$entity_children = $entities->get_sub_app( 'children' );
405
+	$entity_children = $entities->get_sub_app('children');
406 406
 
407 407
 	/** @var WordPoints_Entity $entity */
408
-	foreach ( $entities->get_all() as $slug => $entity ) {
408
+	foreach ($entities->get_all() as $slug => $entity) {
409 409
 
410 410
 		$child_data = array();
411 411
 
412 412
 		/** @var WordPoints_EntityishI $child */
413
-		foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) {
413
+		foreach ($entity_children->get_children($slug) as $child_slug => $child) {
414 414
 
415
-			$child_data[ $child_slug ] = array(
415
+			$child_data[$child_slug] = array(
416 416
 				'slug'  => $child_slug,
417 417
 				'title' => $child->get_title(),
418 418
 			);
419 419
 
420
-			if ( $child instanceof WordPoints_Entity_Attr ) {
420
+			if ($child instanceof WordPoints_Entity_Attr) {
421 421
 
422
-				$child_data[ $child_slug ]['_type']     = 'attr';
423
-				$child_data[ $child_slug ]['data_type'] = $child->get_data_type();
422
+				$child_data[$child_slug]['_type']     = 'attr';
423
+				$child_data[$child_slug]['data_type'] = $child->get_data_type();
424 424
 
425
-			} elseif ( $child instanceof WordPoints_Entity_Relationship ) {
425
+			} elseif ($child instanceof WordPoints_Entity_Relationship) {
426 426
 
427
-				$child_data[ $child_slug ]['_type']     = 'relationship';
428
-				$child_data[ $child_slug ]['primary']   = $child->get_primary_entity_slug();
429
-				$child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug();
427
+				$child_data[$child_slug]['_type']     = 'relationship';
428
+				$child_data[$child_slug]['primary']   = $child->get_primary_entity_slug();
429
+				$child_data[$child_slug]['secondary'] = $child->get_related_entity_slug();
430 430
 			}
431 431
 
432 432
 			/**
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
 			 * @param array                $data  The data for the entity child.
438 438
 			 * @param WordPoints_Entityish $child The child's object.
439 439
 			 */
440
-			$child_data[ $child_slug ] = apply_filters(
440
+			$child_data[$child_slug] = apply_filters(
441 441
 				'wordpoints_hooks_ui_data_entity_child'
442
-				, $child_data[ $child_slug ]
442
+				, $child_data[$child_slug]
443 443
 				, $child
444 444
 			);
445 445
 		}
446 446
 
447
-		$entities_data[ $slug ] = array(
447
+		$entities_data[$slug] = array(
448 448
 			'slug'     => $slug,
449 449
 			'title'    => $entity->get_title(),
450 450
 			'children' => $child_data,
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 			'_type'    => 'entity',
453 453
 		);
454 454
 
455
-		if ( $entity instanceof WordPoints_Entity_EnumerableI ) {
455
+		if ($entity instanceof WordPoints_Entity_EnumerableI) {
456 456
 
457 457
 			$values = array();
458 458
 
459
-			foreach ( $entity->get_enumerated_values() as $value ) {
460
-				if ( $entity->set_the_value( $value ) ) {
459
+			foreach ($entity->get_enumerated_values() as $value) {
460
+				if ($entity->set_the_value($value)) {
461 461
 					$values[] = array(
462 462
 						'value' => $entity->get_the_id(),
463 463
 						'label' => $entity->get_the_human_id(),
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 			}
467 467
 
468
-			$entities_data[ $slug ]['values'] = $values;
468
+			$entities_data[$slug]['values'] = $values;
469 469
 		}
470 470
 
471 471
 		/**
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 		 * @param array             $data   The data for the entity.
475 475
 		 * @param WordPoints_Entity $entity The entity object.
476 476
 		 */
477
-		$entities_data[ $slug ] = apply_filters(
477
+		$entities_data[$slug] = apply_filters(
478 478
 			'wordpoints_hooks_ui_data_entity'
479
-			, $entities_data[ $slug ]
479
+			, $entities_data[$slug]
480 480
 			, $entity
481 481
 		);
482 482
 	}
@@ -496,19 +496,19 @@  discard block
 block discarded – undo
496 496
 	// We want a list of the action types for each event. We can start with this list
497 497
 	// but it is indexed by action slug and then action type and then event slug, so
498 498
 	// we ned to do some processing.
499
-	$event_index = wordpoints_hooks()->get_sub_app( 'router' )->get_event_index();
499
+	$event_index = wordpoints_hooks()->get_sub_app('router')->get_event_index();
500 500
 
501 501
 	// We don't care about the action slugs, so first we get rid of that bottom level
502 502
 	// of the array.
503
-	$event_index = call_user_func_array( 'array_merge_recursive', $event_index );
503
+	$event_index = call_user_func_array('array_merge_recursive', $event_index);
504 504
 
505 505
 	$event_action_types = array();
506 506
 
507 507
 	// This leaves us the event indexed by action type. But we actually need to flip
508 508
 	// this, so that we have the action types indexed by event slug.
509
-	foreach ( $event_index as $action_type => $events ) {
510
-		foreach ( $events as $event => $unused ) {
511
-			$event_action_types[ $event ][ $action_type ] = true;
509
+	foreach ($event_index as $action_type => $events) {
510
+		foreach ($events as $event => $unused) {
511
+			$event_action_types[$event][$action_type] = true;
512 512
 		}
513 513
 	}
514 514
 
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
  *
532 532
  * @return string The HTML with templates appended.
533 533
  */
534
-function wordpoints_script_templates_filter( $html, $handle ) {
534
+function wordpoints_script_templates_filter($html, $handle) {
535 535
 
536 536
 	global $wp_scripts;
537 537
 
538
-	$templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' );
538
+	$templates = $wp_scripts->get_data($handle, 'wordpoints-templates');
539 539
 
540
-	if ( $templates ) {
540
+	if ($templates) {
541 541
 		$html .= $templates;
542 542
 	}
543 543
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
  */
554 554
 function wordpoints_hooks_admin_ajax() {
555 555
 
556
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
556
+	if (defined('DOING_AJAX') && DOING_AJAX) {
557 557
 		new WordPoints_Admin_Ajax_Hooks;
558 558
 	}
559 559
 }
Please login to merge, or discard this patch.