Completed
Push — master ( 4e24b6...14289c )
by Jamie
03:44
created
classes/helpers/FrmListHelper.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@
 block discarded – undo
179 179
 	 * @access public
180 180
 	 *
181 181
 	 * @param string $name Property to check if set.
182
-	 * @return bool Whether the property is set.
182
+	 * @return boolean|null Whether the property is set.
183 183
 	 */
184 184
 	public function __isset( $name ) {
185 185
 		if ( in_array( $name, $this->compat_fields ) ) {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 	protected $modes = array();
68 68
 
69 69
 	/**
70
-	*
71
-	* @var array
72
-	*/
73
-    protected $params;
70
+	 *
71
+	 * @var array
72
+	 */
73
+	protected $params;
74 74
 
75 75
 	/**
76 76
 	 * Stores the value returned by ->get_column_info()
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 		'single_row_columns' );
88 88
 
89 89
 	/**
90
-	* Construct the table object
91
-	*/
90
+	 * Construct the table object
91
+	 */
92 92
 	public function __construct( $args ) {
93
-	    $args = wp_parse_args( $args, array(
93
+		$args = wp_parse_args( $args, array(
94 94
 			'params' => array(),
95 95
 			'plural' => '',
96 96
 			'singular' => '',
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 		add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
106 106
 
107
-		if ( !$args['plural'] )
107
+		if ( ! $args['plural'] )
108 108
 			$args['plural'] = $this->screen->base;
109 109
 
110 110
 		$args['plural'] = sanitize_key( $args['plural'] );
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 			'per_page' => 0,
246 246
 		) );
247 247
 
248
-		if ( !$args['total_pages'] && $args['per_page'] > 0 )
248
+		if ( ! $args['total_pages'] && $args['per_page'] > 0 )
249 249
 			$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
250 250
 
251 251
 		// Redirect if page number is invalid and headers are not already sent.
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @return bool
285 285
 	 */
286 286
 	public function has_items() {
287
-		return !empty( $this->items );
287
+		return ! empty( $this->items );
288 288
 	}
289 289
 
290 290
 	/**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @param string $input_id The search input id
308 308
 	 */
309 309
 	public function search_box( $text, $input_id ) {
310
-		if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
310
+		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() )
311 311
 			return;
312 312
 
313 313
 		$input_id = $input_id . '-search-input';
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 <p class="search-box">
325 325
 	<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
326 326
 	<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
327
-	<?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?>
327
+	<?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?>
328 328
 </p>
329 329
 <?php
330 330
 	}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 		echo "<ul class='subsubsub'>\n";
369 369
 		foreach ( $views as $class => $view ) {
370
-			$views[ $class ] = "\t<li class='$class'>$view";
370
+			$views[$class] = "\t<li class='$class'>$view";
371 371
 		}
372 372
 		echo implode( " |</li>\n", $views ) . "</li>\n";
373 373
 		echo "</ul>";
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 		$action_count = count( $actions );
472 472
 		$i = 0;
473 473
 
474
-		if ( !$action_count )
474
+		if ( ! $action_count )
475 475
 			return '';
476 476
 
477 477
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
478 478
 		foreach ( $actions as $action => $link ) {
479
-			++$i;
479
+			++ $i;
480 480
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
481 481
 			$out .= "<span class='$action'>$link$sep</span>";
482 482
 		}
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
 		$month_count = count( $months );
534 534
 
535
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
535
+		if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
536 536
 			return;
537 537
 
538 538
 		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
749 749
 		} else {
750 750
 			$page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
751
-				esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
751
+				esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
752 752
 				__( 'Previous page' ),
753 753
 				'&lsaquo;'
754 754
 			);
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
772 772
 		} else {
773 773
 			$page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
774
-				esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
774
+				esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
775 775
 				__( 'Next page' ),
776 776
 				'&rsaquo;'
777 777
 			);
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 		// We need a primary defined so responsive views show something,
836 836
 		// so let's fall back to the first non-checkbox column.
837
-		foreach( $columns as $col => $column_name ) {
837
+		foreach ( $columns as $col => $column_name ) {
838 838
 			if ( 'cb' === $col ) {
839 839
 				continue;
840 840
 			}
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 
861 861
 		// If the primary column doesn't exist fall back to the
862 862
 		// first non-checkbox column.
863
-		if ( ! isset( $columns[ $default ] ) ) {
863
+		if ( ! isset( $columns[$default] ) ) {
864 864
 			$default = FrmListHelper::get_default_primary_column_name();
865 865
 		}
866 866
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		 */
875 875
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
876 876
 
877
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
877
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
878 878
 			$column = $default;
879 879
 		}
880 880
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 			// In 4.3, we added a fourth argument for primary column.
897 897
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
898 898
 			foreach ( $this->_column_headers as $key => $value ) {
899
-				$column_headers[ $key ] = $value;
899
+				$column_headers[$key] = $value;
900 900
 			}
901 901
 
902 902
 			return $column_headers;
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 				continue;
925 925
 
926 926
 			$data = (array) $data;
927
-			if ( !isset( $data[1] ) )
927
+			if ( ! isset( $data[1] ) )
928 928
 				$data[1] = false;
929 929
 
930 930
 			$sortable[$id] = $data;
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 			static $cb_counter = 1;
981 981
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
982 982
 				. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
983
-			$cb_counter++;
983
+			$cb_counter ++;
984 984
 		}
985 985
 
986 986
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1020 1020
 			$id = $with_id ? "id='$column_key'" : '';
1021 1021
 
1022
-			if ( !empty( $class ) )
1022
+			if ( ! empty( $class ) )
1023 1023
 				$class = "class='" . join( ' ', $class ) . "'";
1024 1024
 
1025 1025
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
Please login to merge, or discard this patch.
Braces   +89 added lines, -62 removed lines patch added patch discarded remove patch
@@ -104,8 +104,9 @@  discard block
 block discarded – undo
104 104
 
105 105
 		add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
106 106
 
107
-		if ( !$args['plural'] )
108
-			$args['plural'] = $this->screen->base;
107
+		if ( !$args['plural'] ) {
108
+					$args['plural'] = $this->screen->base;
109
+		}
109 110
 
110 111
 		$args['plural'] = sanitize_key( $args['plural'] );
111 112
 		$args['singular'] = sanitize_key( $args['singular'] );
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 			'per_page' => 0,
246 247
 		) );
247 248
 
248
-		if ( !$args['total_pages'] && $args['per_page'] > 0 )
249
-			$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
249
+		if ( !$args['total_pages'] && $args['per_page'] > 0 ) {
250
+					$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
251
+		}
250 252
 
251 253
 		// Redirect if page number is invalid and headers are not already sent.
252 254
 		if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
@@ -268,11 +270,13 @@  discard block
 block discarded – undo
268 270
 	 * @return int Number of items that correspond to the given pagination argument.
269 271
 	 */
270 272
 	public function get_pagination_arg( $key ) {
271
-		if ( 'page' == $key )
272
-			return $this->get_pagenum();
273
+		if ( 'page' == $key ) {
274
+					return $this->get_pagenum();
275
+		}
273 276
 
274
-		if ( isset( $this->_pagination_args[$key] ) )
275
-			return $this->_pagination_args[$key];
277
+		if ( isset( $this->_pagination_args[$key] ) ) {
278
+					return $this->_pagination_args[$key];
279
+		}
276 280
 	}
277 281
 
278 282
 	/**
@@ -307,20 +311,25 @@  discard block
 block discarded – undo
307 311
 	 * @param string $input_id The search input id
308 312
 	 */
309 313
 	public function search_box( $text, $input_id ) {
310
-		if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
311
-			return;
314
+		if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) {
315
+					return;
316
+		}
312 317
 
313 318
 		$input_id = $input_id . '-search-input';
314 319
 
315
-		if ( ! empty( $_REQUEST['orderby'] ) )
316
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
317
-		if ( ! empty( $_REQUEST['order'] ) )
318
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
319
-		if ( ! empty( $_REQUEST['post_mime_type'] ) )
320
-			echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
321
-		if ( ! empty( $_REQUEST['detached'] ) )
322
-			echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
323
-?>
320
+		if ( ! empty( $_REQUEST['orderby'] ) ) {
321
+					echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
322
+		}
323
+		if ( ! empty( $_REQUEST['order'] ) ) {
324
+					echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
325
+		}
326
+		if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
327
+					echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
328
+		}
329
+		if ( ! empty( $_REQUEST['detached'] ) ) {
330
+					echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
331
+		}
332
+		?>
324 333
 <p class="search-box">
325 334
 	<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
326 335
 	<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
@@ -362,8 +371,9 @@  discard block
 block discarded – undo
362 371
 		 */
363 372
 		$views = apply_filters( "views_{$this->screen->id}", $views );
364 373
 
365
-		if ( empty( $views ) )
366
-			return;
374
+		if ( empty( $views ) ) {
375
+					return;
376
+		}
367 377
 
368 378
 		echo "<ul class='subsubsub'>\n";
369 379
 		foreach ( $views as $class => $view ) {
@@ -417,8 +427,9 @@  discard block
 block discarded – undo
417 427
 			$two = '2';
418 428
 		}
419 429
 
420
-		if ( empty( $this->_actions ) )
421
-			return;
430
+		if ( empty( $this->_actions ) ) {
431
+					return;
432
+		}
422 433
 
423 434
 		echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action' ) . "</label>";
424 435
 		echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
@@ -445,14 +456,17 @@  discard block
 block discarded – undo
445 456
 	 * @return string|false The action name or False if no action was selected
446 457
 	 */
447 458
 	public function current_action() {
448
-		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
449
-			return false;
459
+		if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
460
+					return false;
461
+		}
450 462
 
451
-		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
452
-			return $_REQUEST['action'];
463
+		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
464
+					return $_REQUEST['action'];
465
+		}
453 466
 
454
-		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
455
-			return $_REQUEST['action2'];
467
+		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
468
+					return $_REQUEST['action2'];
469
+		}
456 470
 
457 471
 		return false;
458 472
 	}
@@ -471,8 +485,9 @@  discard block
 block discarded – undo
471 485
 		$action_count = count( $actions );
472 486
 		$i = 0;
473 487
 
474
-		if ( !$action_count )
475
-			return '';
488
+		if ( !$action_count ) {
489
+					return '';
490
+		}
476 491
 
477 492
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
478 493
 		foreach ( $actions as $action => $link ) {
@@ -532,8 +547,9 @@  discard block
 block discarded – undo
532 547
 
533 548
 		$month_count = count( $months );
534 549
 
535
-		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
536
-			return;
550
+		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
551
+					return;
552
+		}
537 553
 
538 554
 		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
539 555
 ?>
@@ -542,8 +558,9 @@  discard block
 block discarded – undo
542 558
 			<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
543 559
 <?php
544 560
 		foreach ( $months as $arc_row ) {
545
-			if ( 0 == $arc_row->year )
546
-				continue;
561
+			if ( 0 == $arc_row->year ) {
562
+							continue;
563
+			}
547 564
 
548 565
 			$month = zeroise( $arc_row->month, 2 );
549 566
 			$year = $arc_row->year;
@@ -575,8 +592,9 @@  discard block
 block discarded – undo
575 592
 <?php
576 593
 			foreach ( $this->modes as $mode => $title ) {
577 594
 				$classes = array( 'view-' . $mode );
578
-				if ( $current_mode == $mode )
579
-					$classes[] = 'current';
595
+				if ( $current_mode == $mode ) {
596
+									$classes[] = 'current';
597
+				}
580 598
 				printf(
581 599
 					"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
582 600
 					esc_url( add_query_arg( 'mode', $mode ) ),
@@ -647,8 +665,9 @@  discard block
 block discarded – undo
647 665
 	public function get_pagenum() {
648 666
 		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
649 667
 
650
-		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
651
-			$pagenum = $this->_pagination_args['total_pages'];
668
+		if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
669
+					$pagenum = $this->_pagination_args['total_pages'];
670
+		}
652 671
 
653 672
 		return max( 1, $pagenum );
654 673
 	}
@@ -665,8 +684,9 @@  discard block
 block discarded – undo
665 684
 	 */
666 685
 	protected function get_items_per_page( $option, $default = 20 ) {
667 686
 		$per_page = (int) get_user_option( $option );
668
-		if ( empty( $per_page ) || $per_page < 1 )
669
-			$per_page = $default;
687
+		if ( empty( $per_page ) || $per_page < 1 ) {
688
+					$per_page = $default;
689
+		}
670 690
 
671 691
 		/**
672 692
 		 * Filter the number of items to be displayed on each page of the list table.
@@ -920,12 +940,14 @@  discard block
 block discarded – undo
920 940
 
921 941
 		$sortable = array();
922 942
 		foreach ( $_sortable as $id => $data ) {
923
-			if ( empty( $data ) )
924
-				continue;
943
+			if ( empty( $data ) ) {
944
+							continue;
945
+			}
925 946
 
926 947
 			$data = (array) $data;
927
-			if ( !isset( $data[1] ) )
928
-				$data[1] = false;
948
+			if ( !isset( $data[1] ) ) {
949
+							$data[1] = false;
950
+			}
929 951
 
930 952
 			$sortable[$id] = $data;
931 953
 		}
@@ -966,15 +988,17 @@  discard block
 block discarded – undo
966 988
 		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
967 989
 		$current_url = remove_query_arg( 'paged', $current_url );
968 990
 
969
-		if ( isset( $_GET['orderby'] ) )
970
-			$current_orderby = $_GET['orderby'];
971
-		else
972
-			$current_orderby = '';
991
+		if ( isset( $_GET['orderby'] ) ) {
992
+					$current_orderby = $_GET['orderby'];
993
+		} else {
994
+					$current_orderby = '';
995
+		}
973 996
 
974
-		if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
975
-			$current_order = 'desc';
976
-		else
977
-			$current_order = 'asc';
997
+		if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
998
+					$current_order = 'desc';
999
+		} else {
1000
+					$current_order = 'asc';
1001
+		}
978 1002
 
979 1003
 		if ( ! empty( $columns['cb'] ) ) {
980 1004
 			static $cb_counter = 1;
@@ -990,10 +1014,11 @@  discard block
 block discarded – undo
990 1014
 				$class[] = 'hidden';
991 1015
 			}
992 1016
 
993
-			if ( 'cb' == $column_key )
994
-				$class[] = 'check-column';
995
-			elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
996
-				$class[] = 'num';
1017
+			if ( 'cb' == $column_key ) {
1018
+							$class[] = 'check-column';
1019
+			} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
1020
+							$class[] = 'num';
1021
+			}
997 1022
 
998 1023
 			if ( $column_key === $primary ) {
999 1024
 				$class[] = 'column-primary';
@@ -1019,8 +1044,9 @@  discard block
 block discarded – undo
1019 1044
 			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1020 1045
 			$id = $with_id ? "id='$column_key'" : '';
1021 1046
 
1022
-			if ( !empty( $class ) )
1023
-				$class = "class='" . join( ' ', $class ) . "'";
1047
+			if ( !empty( $class ) ) {
1048
+							$class = "class='" . join( ' ', $class ) . "'";
1049
+			}
1024 1050
 
1025 1051
 			echo "<$tag $scope $id $class>$column_display_name</$tag>";
1026 1052
 		}
@@ -1082,9 +1108,10 @@  discard block
 block discarded – undo
1082 1108
 	 * @param string $which
1083 1109
 	 */
1084 1110
 	protected function display_tablenav( $which ) {
1085
-		if ( 'top' == $which )
1086
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1087
-?>
1111
+		if ( 'top' == $which ) {
1112
+					wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1113
+		}
1114
+		?>
1088 1115
 	<div class="tablenav <?php echo esc_attr( $which ); ?>">
1089 1116
 
1090 1117
 		<div class="alignleft actions bulkactions">
Please login to merge, or discard this patch.