PluginProbe
Stream – Activity Log & Audit Trail / 3.8.2
Stream – Activity Log & Audit Trail v3.8.2
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-list-table.php +245 -96 3.2.33.8.2 View file →
@@ -1,12 +1,20 @@
1 1 <?php
2 +/**
3 + * Generates a filterable list of provided records to be displayed HTML Table.
4 + *
5 + * @package WP_Stream
6 + */
2 7
3 8 namespace WP_Stream;
4 9
10 +/**
11 + * Class - List_Table
12 + */
5 13 class List_Table extends \WP_List_Table {
6 14
7 15 /**
8 - * Hold Plugin class
16 + * Holds Instance of plugin object
9 17 *
10 18 * @var Plugin
11 19 */
12 20 public $plugin;
@@ -13,10 +21,10 @@
13 21
14 22 /**
15 23 * Class constructor.
16 24 *
17 - * @param Plugin $plugin The main Plugin class.
18 - * @param array $args
25 + * @param Plugin $plugin Instance of plugin object.
26 + * @param array $args Argument to filter rows by.
19 27 */
20 28 public function __construct( $plugin, $args = array() ) {
21 29 $this->plugin = $plugin;
22 30
@@ -45,37 +53,63 @@
45 53 'option' => 'edit_stream_per_page',
46 54 )
47 55 );
48 56
49 - // Check for default hidden columns
57 + // Check for default hidden columns.
50 58 $this->get_hidden_columns();
51 59
52 - add_filter( 'screen_settings', array(
53 - $this,
54 - 'screen_controls',
55 - ), 10, 2 );
56 - add_filter( 'set-screen-option', array(
57 - $this,
58 - 'set_screen_option',
59 - ), 10, 3 );
60 + add_filter(
61 + 'screen_settings',
62 + array(
63 + $this,
64 + 'screen_controls',
65 + ),
66 + 10,
67 + 2
68 + );
69 + add_filter(
70 + 'set-screen-option',
71 + array(
72 + $this,
73 + 'set_screen_option',
74 + ),
75 + 10,
76 + 3
77 + );
60 78
61 79 set_screen_options();
62 80 }
63 81
82 + /**
83 + * Renders extra from navigation options.
84 + *
85 + * @param string $which Page location.
86 + * @return void
87 + */
64 88 public function extra_tablenav( $which ) {
65 89 if ( 'top' === $which ) {
66 - echo $this->filters_form(); // xss ok
90 + echo $this->filters_form(); // xss ok.
67 91 }
68 92 }
69 93
94 + /**
95 + * Renders "No items found" message.
96 + *
97 + * @return void
98 + */
70 99 public function no_items() {
71 100 ?>
72 101 <div class="stream-list-table-no-items">
73 - <p><?php esc_html_e( 'Sorry, no activity records were found.', 'stream' ); ?></p>
102 + <p><?php esc_html_e( 'No activity records were found.', 'stream' ); ?></p>
74 103 </div>
75 104 <?php
76 105 }
77 106
107 + /**
108 + * Returns the table columns to be rendered.
109 + *
110 + * @return array
111 + */
78 112 public function get_columns() {
79 113 /**
80 114 * Allows devs to add new columns to table
81 115 *
@@ -93,8 +127,13 @@
93 127 )
94 128 );
95 129 }
96 130
131 + /**
132 + * Returns the columns the items can be sort by.
133 + *
134 + * @return array
135 + */
97 136 public function get_sortable_columns() {
98 137 return array(
99 138 'date' => array( 'date', false ),
100 139 );
@@ -99,8 +138,13 @@
99 138 'date' => array( 'date', false ),
100 139 );
101 140 }
102 141
142 + /**
143 + * Returns columns hidden from all except specific users.
144 + *
145 + * @return array|bool
146 + */
103 147 public function get_hidden_columns() {
104 148 $user = wp_get_current_user();
105 149 if ( ! $user ) {
106 150 return array();
@@ -105,12 +149,12 @@
105 149 if ( ! $user ) {
106 150 return array();
107 151 }
108 152
109 - // Directly checking the user meta; to check whether user has changed screen option or not
153 + // Directly checking the user meta; to check whether user has changed screen option or not.
110 154 $hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
111 155
112 - // If user meta is not found; add the default hidden column 'id'
156 + // If user meta is not found; add the default hidden column 'id'.
113 157 if ( ! $hidden ) {
114 158 $hidden = array( 'id' );
115 159 $this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
116 160 }
@@ -117,8 +161,13 @@
117 161
118 162 return $hidden;
119 163 }
120 164
165 + /**
166 + * Prepares table columns and data for render
167 + *
168 + * @return void
169 + */
121 170 public function prepare_items() {
122 171 $columns = $this->get_columns();
123 172 $sortable = $this->get_sortable_columns();
124 173 $hidden = $this->get_hidden_columns();
@@ -142,12 +191,17 @@
142 191 )
143 192 );
144 193 }
145 194
195 + /**
196 + * Returns records to be displayed
197 + *
198 + * @return array
199 + */
146 200 public function get_records() {
147 201 $args = array();
148 202
149 - // Parse sorting params
203 + // Parse sorting params.
150 204 $order = wp_stream_filter_input( INPUT_GET, 'order' );
151 205 if ( $order ) {
152 206 $args['order'] = $order;
153 207 }
@@ -173,9 +227,9 @@
173 227 $args[ $param ] = $value;
174 228 }
175 229 }
176 230
177 - // Additional filter properties
231 + // Additional filter properties.
178 232 $properties = array(
179 233 'record',
180 234 'site_id',
181 235 'blog_id',
@@ -187,13 +241,13 @@
187 241 'context',
188 242 'action',
189 243 );
190 244
191 - // Add property fields to defaults, including their __in/__not_in variations
245 + // Add property fields to defaults, including their __in/__not_in variations.
192 246 foreach ( $properties as $property ) {
193 247 $value = wp_stream_filter_input( INPUT_GET, $property );
194 248
195 - // Allow 0 values
249 + // Allow 0 values.
196 250 if ( isset( $value ) && '' !== $value && false !== $value ) {
197 251 $args[ $property ] = $value;
198 252 }
199 253
@@ -235,8 +289,15 @@
235 289 public function get_total_found_rows() {
236 290 return $this->plugin->db->get_found_records_count();
237 291 }
238 292
293 + /**
294 + * Returns the column content for the provided item and column.
295 + *
296 + * @param array $item Record data.
297 + * @param string $column_name Column name.
298 + * @return void
299 + */
239 300 public function column_default( $item, $column_name ) {
240 301 $out = '';
241 302 $record = new Record( $item );
242 303
@@ -241,9 +302,9 @@
241 302 $record = new Record( $item );
242 303
243 304 switch ( $column_name ) {
244 305 case 'date':
245 - $created = date( 'Y-m-d H:i:s', strtotime( $record->created ) );
306 + $created = gmdate( 'Y-m-d H:i:s', strtotime( $record->created ) );
246 307 $date_string = sprintf(
247 308 '<time datetime="%s" class="relative-time record-created">%s</time>',
248 309 wp_stream_get_iso_8601_extended_date( strtotime( $record->created ) ),
249 310 get_date_from_gmt( $created, 'Y/m/d' )
@@ -255,9 +316,9 @@
255 316
256 317 case 'summary':
257 318 $out = $record->summary;
258 319 $object_title = $record->get_object_title();
259 - // translators: Placeholder refers to the title of any object, like a Post (e.g. "Hello World")
320 + /* translators: %s: the title of any object, like a Post (e.g. "Hello World") */
260 321 $view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'stream' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'stream' );
261 322
262 323 if ( $record->object_id ) {
263 324 $out .= $this->column_link(
@@ -327,12 +388,13 @@
327 388 /**
328 389 * Registers new Columns to be inserted into the table. The cell contents of this column is set
329 390 * below with 'wp_stream_insert_column_default_'
330 391 *
392 + * @param array $new_columns Columns injected in the table.
393 + *
331 394 * @return array
332 395 */
333 - $new_columns = array();
334 - $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns );
396 + $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() );
335 397
336 398 if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
337 399 foreach ( $inserted_columns as $column_title ) {
338 400 /**
@@ -342,23 +404,22 @@
342 404 *
343 405 * Also, note that the action name must include the $column_title registered
344 406 * with wp_stream_register_column_defaults
345 407 */
346 - if ( $column_title === $column_name && has_filter( "wp_stream_insert_column_default_{$column_title}" ) ) {
408 + if ( $column_title === $column_name ) {
347 409 /**
348 410 * Allows for the addition of content under a specified column.
349 411 *
350 - * @param object $record Contents of the row
412 + * @param string $out Column content.
413 + * @param object $record Record with row content.
414 + * @param string $column_name Column name.
351 415 *
352 416 * @return string
353 417 */
354 - $out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $column_name, $record );
355 - } else {
356 - $out = $column_name;
418 + $out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name );
419 + break;
357 420 }
358 421 }
359 - } else {
360 - $out = $column_name;
361 422 }
362 423 }
363 424
364 425 $allowed_tags = wp_kses_allowed_html( 'post' );
@@ -370,8 +431,14 @@
370 431
371 432 echo wp_kses( $out, $allowed_tags );
372 433 }
373 434
435 + /**
436 + * Returns the actions links for the provided record. (Eg. Edit, View)
437 + *
438 + * @param Record $record Record.
439 + * @return string
440 + */
374 441 public function get_action_links( $record ) {
375 442 $out = '';
376 443
377 444 /**
@@ -423,8 +490,17 @@
423 490
424 491 return $out;
425 492 }
426 493
494 + /**
495 + * Returns a link to be display in the table.
496 + *
497 + * @param string $display Text to be displayed in link.
498 + * @param string|array $key Query string variable(s).
499 + * @param string $value Single query string value.
500 + * @param string $title Tooltip value.
501 + * @return string
502 + */
427 503 public function column_link( $display, $key, $value = null, $title = null ) {
428 504 $url = add_query_arg(
429 505 array(
430 506 'page' => $this->plugin->admin->records_page_slug,
@@ -447,8 +523,15 @@
447 523 $display
448 524 );
449 525 }
450 526
527 + /**
528 + * Returns the label for a connector term.
529 + *
530 + * @param string $term Connector label type.
531 + * @param string $type Connector term.
532 + * @return string
533 + */
451 534 public function get_term_title( $term, $type ) {
452 535 if ( ! isset( $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ] ) ) {
453 536 return $term;
454 537 }
@@ -462,9 +545,9 @@
462 545 * Gathers list of all users/connectors, then compares it to
463 546 * results of existing records. All items that do not exist in records
464 547 * get assigned a disabled value of "true".
465 548 *
466 - * @param string $column List table column name
549 + * @param string $column List table column name.
467 550 *
468 551 * @return array Options to be displayed in search filters
469 552 */
470 553 public function assemble_records( $column ) {
@@ -471,9 +554,9 @@
471 554 // @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
472 555 if ( 'user_id' === $column ) {
473 556 $all_records = array();
474 557
475 - // If the number of users exceeds the max users constant value then return an empty array and use AJAX instead
558 + // If the number of users exceeds the max users constant value then return an empty array and use AJAX instead.
476 559 $user_count = count_users();
477 560 $total_users = $user_count['total_users'];
478 561
479 562 if ( $total_users > $this->plugin->admin->preload_users_max ) {
@@ -512,9 +595,10 @@
512 595 $users = array_unique( array_merge( $users, $super_admins ) );
513 596 }
514 597
515 598 $users[] = new Author(
516 - 0, array(
599 + 0,
600 + array(
517 601 'is_wp_cli' => true,
518 602 )
519 603 );
520 604
@@ -543,9 +627,9 @@
543 627 );
544 628 }
545 629 }
546 630
547 - // Remove WP-CLI pseudo user if no records with user=0 exist
631 + // Remove WP-CLI pseudo user if no records with user=0 exist.
548 632 if ( isset( $disabled_records[0] ) ) {
549 633 unset( $disabled_records[0] );
550 634 }
551 635
@@ -562,14 +646,19 @@
562 646
563 647 uasort( $active_records, $sort );
564 648 uasort( $disabled_records, $sort );
565 649
566 - // Not using array_merge() in order to preserve the array index for the users dropdown which uses the user_id as the key
650 + // Not using array_merge() in order to preserve the array index for the users dropdown which uses the user_id as the key.
567 651 $all_records = $active_records + $disabled_records;
568 652
569 653 return $all_records;
570 654 }
571 655
656 + /**
657 + * Returns list filters.
658 + *
659 + * @return array
660 + */
572 661 public function get_filters() {
573 662 $filters = array();
574 663
575 664 $date_interval = new Date_Interval();
@@ -608,8 +697,13 @@
608 697 */
609 698 return apply_filters( 'wp_stream_list_table_filters', $filters );
610 699 }
611 700
701 + /**
702 + * Returns table filters form.
703 + *
704 + * @return string
705 + */
612 706 public function filters_form() {
613 707 $filters = $this->get_filters();
614 708
615 709 $filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
@@ -617,9 +711,10 @@
617 711
618 712 foreach ( $filters as $name => $data ) {
619 713
620 714 $data = wp_parse_args(
621 - $data, array(
715 + $data,
716 + array(
622 717 'title' => '',
623 718 'items' => array(),
624 719 'ajax' => false,
625 720 )
@@ -628,9 +723,9 @@
628 723 if ( 'date' === $name ) {
629 724 $filters_string .= $this->filter_date( $data['items'] );
630 725 } else {
631 726 if ( 'context' === $name ) {
632 - // Add Connectors as parents, and apply the Contexts as children
727 + // Add Connectors as parents, and apply the Contexts as children.
633 728 $connectors = $this->assemble_records( 'connector' );
634 729 $context_items = array();
635 730
636 731 foreach ( $connectors as $connector => $item ) {
@@ -644,9 +739,9 @@
644 739
645 740 if ( isset( $context_items[ $connector ]['children'] ) ) {
646 741 $labels = wp_list_pluck( $context_items[ $connector ]['children'], 'label' );
647 742
648 - // Sort child items by label
743 + // Sort child items by label.
649 744 array_multisort( $labels, SORT_ASC, $context_items[ $connector ]['children'] );
650 745 }
651 746 }
652 747
@@ -659,12 +754,12 @@
659 754 $data['items'] = $context_items;
660 755
661 756 $labels = wp_list_pluck( $data['items'], 'label' );
662 757
663 - // Sort top-level items by label
758 + // Sort top-level items by label.
664 759 array_multisort( $labels, SORT_ASC, $data['items'] );
665 760
666 - // Output a hidden input to handle the connector value
761 + // Output a hidden input to handle the connector value.
667 762 $filters_string .= sprintf(
668 763 '<input type="hidden" name="connector" class="record-filter-connector" value="%s" />',
669 764 esc_attr( wp_stream_filter_input( INPUT_GET, 'connector' ) )
670 765 );
@@ -675,9 +770,9 @@
675 770 }
676 771
677 772 $filters_string .= sprintf( '<input type="submit" id="record-query-submit" class="button" value="%s" />', __( 'Filter', 'stream' ) );
678 773
679 - // Parse all query vars into an array
774 + // Parse all query vars into an array.
680 775 $query_vars = array();
681 776
682 777 if ( isset( $_SERVER['QUERY_STRING'] ) ) {
683 778 parse_str( urldecode( $_SERVER['QUERY_STRING'] ), $query_vars );
@@ -682,9 +777,9 @@
682 777 if ( isset( $_SERVER['QUERY_STRING'] ) ) {
683 778 parse_str( urldecode( $_SERVER['QUERY_STRING'] ), $query_vars );
684 779 }
685 780
686 - // Ignore certain query vars and query vars that are empty
781 + // Ignore certain query vars and query vars that are empty.
687 782 foreach ( $query_vars as $query_var => $value ) {
688 783 if ( '' === $value || 'page' === $query_var || 'paged' === $query_var ) {
689 784 unset( $query_vars[ $query_var ] );
690 785 }
@@ -696,70 +791,76 @@
696 791 ),
697 792 self_admin_url( $this->plugin->admin->admin_parent_page )
698 793 );
699 794
700 - // Display reset action if records are being filtered
795 + // Display reset action if records are being filtered.
701 796 if ( ! empty( $query_vars ) ) {
702 797 $filters_string .= sprintf( '<a href="%s" id="record-query-reset"><span class="dashicons dashicons-dismiss"></span> <span class="record-query-reset-text">%s</span></a>', esc_url( $url ), __( 'Reset filters', 'stream' ) );
703 798 }
704 799
705 - return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok
800 + return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok.
706 801 }
707 802
803 + /**
804 + * Returns HTML string of filterable select control with filtered items.
805 + *
806 + * @param string $name Search input.
807 + * @param string $title Name of the control.
808 + * @param array $items Items to be filtered.
809 + * @param boolean $ajax Whether is an ajax request or not.
810 + * @return string
811 + */
708 812 public function filter_select( $name, $title, $items, $ajax = false ) {
709 - if ( $ajax ) {
710 - $out = sprintf(
711 - '<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
712 - esc_attr( $name ),
713 - esc_attr( wp_stream_filter_input( INPUT_GET, $name ) ),
714 - esc_attr( $title )
813 + $options = array( '<option value=""></option>' );
814 + $selected = wp_stream_filter_input( INPUT_GET, $name );
815 +
816 + foreach ( $items as $key => $item ) {
817 + $value = isset( $item['children'] ) ? 'group-' . $key : $key;
818 + $option_args = array(
819 + 'value' => $value,
820 + 'selected' => selected( $value, $selected, false ),
821 + 'disabled' => isset( $item['disabled'] ) ? $item['disabled'] : null,
822 + 'icon' => isset( $item['icon'] ) ? $item['icon'] : null,
823 + 'group' => isset( $item['children'] ) ? $key : null,
824 + 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
825 + 'class' => isset( $item['children'] ) ? 'level-1' : null,
826 + 'label' => isset( $item['label'] ) ? $item['label'] : null,
715 827 );
716 - } else {
717 - $options = array( '<option value=""></option>' );
718 - $selected = wp_stream_filter_input( INPUT_GET, $name );
828 + $options[] = $this->filter_option( $option_args );
719 829
720 - foreach ( $items as $key => $item ) {
721 - $value = isset( $item['children'] ) ? 'group-' . $key : $key;
722 - $option_args = array(
723 - 'value' => $value,
724 - 'selected' => selected( $value, $selected, false ),
725 - 'disabled' => isset( $item['disabled'] ) ? $item['disabled'] : null,
726 - 'icon' => isset( $item['icon'] ) ? $item['icon'] : null,
727 - 'group' => isset( $item['children'] ) ? $key : null,
728 - 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
729 - 'class' => isset( $item['children'] ) ? 'level-1' : null,
730 - 'label' => isset( $item['label'] ) ? $item['label'] : null,
731 - );
732 - $options[] = $this->filter_option( $option_args );
733 -
734 - if ( isset( $item['children'] ) ) {
735 - foreach ( $item['children'] as $child_value => $child_item ) {
736 - $option_args = array(
737 - 'value' => $child_value,
738 - 'selected' => selected( $child_value, $selected, false ),
739 - 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
740 - 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null,
741 - 'group' => $key,
742 - 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
743 - 'class' => 'level-2',
744 - 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
745 - );
746 - $options[] = $this->filter_option( $option_args );
747 - }
830 + if ( isset( $item['children'] ) ) {
831 + foreach ( $item['children'] as $child_value => $child_item ) {
832 + $option_args = array(
833 + 'value' => $child_value,
834 + 'selected' => selected( $child_value, $selected, false ),
835 + 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
836 + 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null,
837 + 'group' => $key,
838 + 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
839 + 'class' => 'level-2',
840 + 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
841 + );
842 + $options[] = $this->filter_option( $option_args );
748 843 }
749 844 }
750 - $out = sprintf(
751 - '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
752 - esc_attr( $name ),
753 - // translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
754 - sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
755 - implode( '', $options )
756 - );
757 845 }
846 + $out = sprintf(
847 + '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
848 + esc_attr( $name ),
849 + /* translators: %s: the title of the dropdown menu (e.g. "users") */
850 + sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
851 + implode( '', $options )
852 + );
758 853
759 854 return $out;
760 855 }
761 856
857 + /**
858 + * Return HTML string of a filterable select option.
859 + *
860 + * @param array $args Option attributes.
861 + * @return string
862 + */
762 863 public function filter_option( $args ) {
763 864 $defaults = array(
764 865 'value' => null,
765 866 'selected' => null,
@@ -784,12 +885,17 @@
784 885 esc_html( $args['label'] )
785 886 );
786 887 }
787 888
889 + /**
890 + * Return HTML string of a filter search box.
891 + *
892 + * @return string
893 + */
788 894 public function filter_search() {
789 895 $search = null;
790 - if ( isset( $_GET['search'] ) ) { // CSRF okay
791 - $search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay, CSRF okay
896 + if ( isset( $_GET['search'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
897 + $search = sanitize_key( wp_unslash( $_GET['search'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
792 898 }
793 899 $out = sprintf(
794 900 '<p class="search-box">
795 901 <label class="screen-reader-text" for="record-search-input">%1$s:</label>
@@ -802,8 +908,14 @@
802 908
803 909 return $out;
804 910 }
805 911
912 + /**
913 + * Return HTML string of a filter select box based upon date.
914 + *
915 + * @param array $items Records.
916 + * @return string
917 + */
806 918 public function filter_date( $items ) {
807 919 wp_enqueue_style( 'jquery-ui' );
808 920 wp_enqueue_style( 'wp-stream-datepicker' );
809 921 wp_enqueue_script( 'jquery-ui-datepicker' );
@@ -882,8 +994,9 @@
882 994 );
883 995 }
884 996 echo '</select></div>';
885 997 wp_nonce_field( 'stream_record_actions_nonce', 'stream_record_actions_nonce' );
998 + wp_nonce_field( 'stream_filters_user_search_nonce', 'stream_filters_user_search_nonce' );
886 999
887 1000 printf( '<input type="hidden" name="page" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'page' ) ) );
888 1001 printf( '<input type="hidden" name="date_predefined" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'date_predefined' ) ) );
889 1002 printf( '<input type="hidden" name="date_from" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'date_from' ) ) );
@@ -898,21 +1011,29 @@
898 1011
899 1012 return ob_get_clean();
900 1013 }
901 1014
1015 + /**
1016 + * Renders record filter forms.
1017 + */
902 1018 public function display() {
903 1019 $url = self_admin_url( $this->plugin->admin->admin_parent_page );
904 1020
905 1021 echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
906 - echo $this->filter_search(); // xss ok
1022 + echo $this->filter_search(); // xss ok.
907 1023 parent::display();
908 1024 echo '</form>';
909 1025
910 1026 echo '<form method="get" action="' . esc_url( $url ) . '" id="record-actions-form">';
911 - echo $this->record_actions_form(); // xss ok
1027 + echo $this->record_actions_form(); // xss ok.
912 1028 echo '</form>';
913 1029 }
914 1030
1031 + /**
1032 + * Renders a single record
1033 + *
1034 + * @param array $item Record data.
1035 + */
915 1036 public function single_row( $item ) {
916 1037 $classes = apply_filters( 'wp_stream_record_classes', array(), $item );
917 1038 $class_string = '';
918 1039 if ( ! empty( $classes ) ) {
@@ -918,13 +1039,18 @@
918 1039 if ( ! empty( $classes ) ) {
919 1040 $class_string = ' class="' . esc_attr( join( ' ', $classes ) ) . '"';
920 1041 }
921 1042
922 - echo sprintf( '<tr%s>', $class_string ); // xss ok
1043 + echo sprintf( '<tr%s>', $class_string ); // xss ok.
923 1044 $this->single_row_columns( $item );
924 1045 echo '</tr>';
925 1046 }
926 1047
1048 + /**
1049 + * Renders table navigation controls
1050 + *
1051 + * @param string $which Location controls.
1052 + */
927 1053 public function display_tablenav( $which ) {
928 1054 if ( 'top' === $which ) :
929 1055 ?>
930 1056 <div class="tablenav <?php echo esc_attr( $which ); ?>">
@@ -951,8 +1077,16 @@
951 1077 <?php
952 1078 endif;
953 1079 }
954 1080
1081 + /**
1082 + * Sets the screen options.
1083 + *
1084 + * @param string $dummy Unused.
1085 + * @param string $option Screen option name.
1086 + * @param string $value Screen option value.
1087 + * @return string
1088 + */
955 1089 public function set_screen_option( $dummy, $option, $value ) {
956 1090 if ( 'edit_stream_per_page' === $option ) {
957 1091 return $value;
958 1092 } else {
@@ -959,8 +1093,16 @@
959 1093 return $dummy;
960 1094 }
961 1095 }
962 1096
1097 + /**
1098 + * Sets the live update options.
1099 + *
1100 + * @param string $dummy Unused.
1101 + * @param string $option Screen option name.
1102 + * @param string $value Screen option value.
1103 + * @return string
1104 + */
963 1105 public function set_live_update_option( $dummy, $option, $value ) {
964 1106 unset( $value );
965 1107
966 1108 // @codingStandardsIgnoreStart
@@ -978,8 +1120,15 @@
978 1120
979 1121 return $dummy;
980 1122 }
981 1123
1124 + /**
1125 + * Return HTML string of the "Live updates" screen option.
1126 + *
1127 + * @param string $status Unused.
1128 + * @param array $args Unused.
1129 + * @return string
1130 + */
982 1131 public function screen_controls( $status, $args ) {
983 1132 unset( $status );
984 1133 unset( $args );
985 1134
@@ -1020,9 +1169,9 @@
1020 1169
1021 1170 /**
1022 1171 * This function is use to map List table column name with excluded setting keys
1023 1172 *
1024 - * @param string $column List table column name
1173 + * @param string $column List table column name.
1025 1174 *
1026 1175 * @return string setting name for that column
1027 1176 */
1028 1177 public function get_column_excluded_setting_key( $column ) {
@@ -1051,9 +1200,9 @@
1051 1200
1052 1201 /**
1053 1202 * Get users as dropdown items
1054 1203 *
1055 - * @param array $users
1204 + * @param array $users Users.
1056 1205 *
1057 1206 * @return array
1058 1207 */
1059 1208 public function get_users_dropdown_items( $users ) {