PluginProbe
Stream – Activity Log & Audit Trail / 3.9.2
Stream – Activity Log & Audit Trail v3.9.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 +113 -113 trunk3.9.2 View file →
@@ -86,11 +86,9 @@
86 86 * @return void
87 87 */
88 88 public function extra_tablenav( $which ) {
89 89 if ( 'top' === $which ) {
90 - echo '<div class="alignleft actions">';
91 - $this->render_filters_form();
92 - echo '</div>';
90 + echo $this->filters_form(); // xss ok.
93 91 }
94 92 }
95 93
96 94 /**
@@ -152,14 +150,14 @@
152 150 return array();
153 151 }
154 152
155 153 // Directly checking the user meta; to check whether user has changed screen option or not.
156 - $hidden = get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
154 + $hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
157 155
158 156 // If user meta is not found; add the default hidden column 'id'.
159 157 if ( ! $hidden ) {
160 158 $hidden = array( 'id' );
161 - update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
159 + $this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
162 160 }
163 161
164 162 return $hidden;
165 163 }
@@ -312,9 +310,9 @@
312 310 get_date_from_gmt( $created, 'Y/m/d' )
313 311 );
314 312 $out = $this->column_link( $date_string, 'date', get_date_from_gmt( $created, 'Y/m/d' ) );
315 313 $out .= '<br />';
316 - $out .= get_date_from_gmt( $created, 'h:i:s A T' );
314 + $out .= get_date_from_gmt( $created, 'h:i:s A' );
317 315 break;
318 316
319 317 case 'summary':
320 318 $out = $record->summary;
@@ -390,35 +388,39 @@
390 388 /**
391 389 * Registers new Columns to be inserted into the table. The cell contents of this column is set
392 390 * below with 'wp_stream_insert_column_default_'
393 391 *
394 - * @since 3.5.1
395 - * @deprecated 4.0.1 Use the {@see 'wp_stream_list_table_columns'} filter instead.
392 + * @param array $new_columns Columns injected in the table.
396 393 *
397 - * @param array $new_columns Columns injected in the table.
398 - *
399 394 * @return array
400 395 */
401 - apply_filters_deprecated(
402 - 'wp_stream_register_column_defaults',
403 - array( array() ),
404 - /* translators: %s is the Stream version number. It is part of a filter deprecation notice and is preceded by: "{hook_name} is deprecated since version %s of Stream". */
405 - sprintf( __( '%s of Stream', 'stream' ), '4.0.1' ),
406 - 'wp_stream_list_table_columns',
407 - __( 'This filter is being deprecated as it is redundant. You can define custom column names and titles using the `wp_stream_list_table_columns` filter then provide the value for the custom columns using the `wp_stream_insert_column_default_{$column_name}` filter.', 'stream' )
408 - );
396 + $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() );
409 397
410 - /**
411 - * Allows for the addition of content under a specified column.
412 - *
413 - * @param string $out Column content.
414 - * @param object $record Record with row content.
415 - * @param string $column_name Column name.
416 - *
417 - * @return string
418 - */
419 - $out = (string) apply_filters( "wp_stream_insert_column_default_{$column_name}", $out, $record, $column_name );
420 - break;
398 + if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
399 + foreach ( $inserted_columns as $column_title ) {
400 + /**
401 + * If column title inserted via wp_stream_register_column_defaults ($column_title) exists
402 + * among columns registered with get_columns ($column_name) and there is an action associated
403 + * with this column, do the action
404 + *
405 + * Also, note that the action name must include the $column_title registered
406 + * with wp_stream_register_column_defaults
407 + */
408 + if ( $column_title === $column_name ) {
409 + /**
410 + * Allows for the addition of content under a specified column.
411 + *
412 + * @param string $out Column content.
413 + * @param object $record Record with row content.
414 + * @param string $column_name Column name.
415 + *
416 + * @return string
417 + */
418 + $out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name );
419 + break;
420 + }
421 + }
422 + }
421 423 }
422 424
423 425 $allowed_tags = wp_kses_allowed_html( 'post' );
424 426 $allowed_tags['time'] = array(
@@ -615,14 +617,14 @@
615 617 foreach ( $all_records as $record => $label ) {
616 618 if ( array_key_exists( $record, $existing_records ) ) {
617 619 $active_records[ $record ] = array(
618 620 'label' => $label,
619 - 'disabled' => false,
621 + 'disabled' => '',
620 622 );
621 623 } else {
622 624 $disabled_records[ $record ] = array(
623 625 'label' => $label,
624 - 'disabled' => true,
626 + 'disabled' => 'disabled="disabled"',
625 627 );
626 628 }
627 629 }
628 630
@@ -696,17 +698,17 @@
696 698 return apply_filters( 'wp_stream_list_table_filters', $filters );
697 699 }
698 700
699 701 /**
700 - * Renders table filters form.
702 + * Returns table filters form.
701 703 *
702 - * @return void
704 + * @return string
703 705 */
704 - public function render_filters_form() {
706 + public function filters_form() {
705 707 $filters = $this->get_filters();
706 708
707 - printf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
708 - printf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) );
709 + $filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
710 + $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) );
709 711
710 712 foreach ( $filters as $name => $data ) {
711 713
712 714 $data = wp_parse_args(
@@ -718,9 +720,9 @@
718 720 )
719 721 );
720 722
721 723 if ( 'date' === $name ) {
722 - $this->filter_date( $data['items'] );
724 + $filters_string .= $this->filter_date( $data['items'] );
723 725 } else {
724 726 if ( 'context' === $name ) {
725 727 // Add Connectors as parents, and apply the Contexts as children.
726 728 $connectors = $this->assemble_records( 'connector' );
@@ -756,29 +758,25 @@
756 758 // Sort top-level items by label.
757 759 array_multisort( $labels, SORT_ASC, $data['items'] );
758 760
759 761 // Output a hidden input to handle the connector value.
760 - printf(
762 + $filters_string .= sprintf(
761 763 '<input type="hidden" name="connector" class="record-filter-connector" value="%s" />',
762 764 esc_attr( wp_stream_filter_input( INPUT_GET, 'connector' ) )
763 765 );
764 766 }
765 767
766 - $this->filter_select( $name, $data['title'], $data['items'], $data['ajax'] );
768 + $filters_string .= $this->filter_select( $name, $data['title'], $data['items'], $data['ajax'] );
767 769 }
768 770 }
769 771
770 - printf(
771 - '<input type="submit" id="record-query-submit" class="button" value="%s" />',
772 - esc_attr__( 'Filter', 'stream' )
773 - );
772 + $filters_string .= sprintf( '<input type="submit" id="record-query-submit" class="button" value="%s" />', __( 'Filter', 'stream' ) );
774 773
775 774 // Parse all query vars into an array.
776 775 $query_vars = array();
777 776
778 777 if ( isset( $_SERVER['QUERY_STRING'] ) ) {
779 - parse_str( wp_unslash( $_SERVER['QUERY_STRING'] ), $query_vars );
780 - $query_vars = map_deep( $query_vars, 'sanitize_text_field' );
778 + parse_str( urldecode( $_SERVER['QUERY_STRING'] ), $query_vars );
781 779 }
782 780
783 781 // Ignore certain query vars and query vars that are empty.
784 782 foreach ( $query_vars as $query_var => $value ) {
@@ -795,50 +793,33 @@
795 793 );
796 794
797 795 // Display reset action if records are being filtered.
798 796 if ( ! empty( $query_vars ) ) {
799 - printf(
800 - '<a href="%1$s" id="record-query-reset"><span class="dashicons dashicons-dismiss"></span> <span class="record-query-reset-text">%2$s</span></a>',
801 - esc_url( $url ),
802 - esc_html__( 'Reset filters', 'stream' )
803 - );
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' ) );
804 798 }
799 +
800 + return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok.
805 801 }
806 802
807 803 /**
808 - * Renders a filterable select control with filtered items.
804 + * Returns HTML string of filterable select control with filtered items.
809 805 *
810 - * @param string $name Search input.
811 - * @param string $title Name of the control.
812 - * @param array $items Items to be filtered.
813 - * @param boolean $ajax Whether is an ajax request or not.
814 - *
815 - * @return void
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
816 811 */
817 812 public function filter_select( $name, $title, $items, $ajax = false ) {
813 + $options = array( '<option value=""></option>' );
818 814 $selected = wp_stream_filter_input( INPUT_GET, $name );
819 815
820 - printf(
821 - '<select name="%1$s" class="chosen-select" data-placeholder="%2$s">',
822 - esc_attr( $name ),
823 - esc_attr(
824 - sprintf(
825 - /* translators: %s: the title of the dropdown menu (e.g. "users") */
826 - __( 'Show all %s', 'stream' ),
827 - $title
828 - )
829 - )
830 - );
831 -
832 - // First option should be empty.
833 - echo '<option value=""></option>';
834 -
835 816 foreach ( $items as $key => $item ) {
836 817 $value = isset( $item['children'] ) ? 'group-' . $key : $key;
837 818 $option_args = array(
838 819 'value' => $value,
839 - 'selected' => (string) $value === (string) $selected,
840 - 'disabled' => ! empty( $item['disabled'] ),
820 + 'selected' => selected( $value, $selected, false ),
821 + 'disabled' => isset( $item['disabled'] ) ? $item['disabled'] : null,
841 822 'icon' => isset( $item['icon'] ) ? $item['icon'] : null,
842 823 'group' => isset( $item['children'] ) ? $key : null,
843 824 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
844 825 'class' => isset( $item['children'] ) ? 'level-1' : null,
@@ -843,16 +824,16 @@
843 824 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
844 825 'class' => isset( $item['children'] ) ? 'level-1' : null,
845 826 'label' => isset( $item['label'] ) ? $item['label'] : null,
846 827 );
847 - $this->filter_option( $option_args );
828 + $options[] = $this->filter_option( $option_args );
848 829
849 830 if ( isset( $item['children'] ) ) {
850 831 foreach ( $item['children'] as $child_value => $child_item ) {
851 832 $option_args = array(
852 833 'value' => $child_value,
853 - 'selected' => (string) $child_value === (string) $selected,
854 - 'disabled' => ! empty( $child_item['disabled'] ),
834 + 'selected' => selected( $child_value, $selected, false ),
835 + 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
855 836 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null,
856 837 'group' => $key,
857 838 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
858 839 'class' => 'level-2',
@@ -857,28 +838,34 @@
857 838 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
858 839 'class' => 'level-2',
859 840 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
860 841 );
861 - $this->filter_option( $option_args );
842 + $options[] = $this->filter_option( $option_args );
862 843 }
863 844 }
864 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 + );
865 853
866 - echo '</select>';
854 + return $out;
867 855 }
868 856
869 857 /**
870 - * Render a filterable select option.
858 + * Return HTML string of a filterable select option.
871 859 *
872 - * @param array $args Option attributes.
873 - *
874 - * @return void
860 + * @param array $args Option attributes.
861 + * @return string
875 862 */
876 863 public function filter_option( $args ) {
877 864 $defaults = array(
878 865 'value' => null,
879 - 'selected' => false,
880 - 'disabled' => false,
866 + 'selected' => null,
867 + 'disabled' => null,
881 868 'icon' => null,
882 869 'group' => null,
883 870 'tooltip' => null,
884 871 'class' => null,
@@ -885,13 +872,13 @@
885 872 'label' => null,
886 873 );
887 874 wp_parse_args( $args, $defaults );
888 875
889 - printf(
876 + return sprintf(
890 877 '<option value="%s" %s %s %s %s %s class="%s">%s</option>',
891 878 esc_attr( $args['value'] ),
892 - selected( $args['selected'], true, false ),
893 - disabled( $args['disabled'], true, false ),
879 + $args['selected'],
880 + $args['disabled'],
894 881 $args['icon'] ? sprintf( 'data-icon="%s"', esc_attr( $args['icon'] ) ) : null,
895 882 $args['group'] ? sprintf( 'data-group="%s"', esc_attr( $args['group'] ) ) : null,
896 883 $args['tooltip'] ? sprintf( 'title="%s"', esc_attr( $args['tooltip'] ) ) : null,
897 884 $args['class'] ? esc_attr( $args['class'] ) : null,
@@ -899,31 +886,35 @@
899 886 );
900 887 }
901 888
902 889 /**
903 - * Render filter search box.
890 + * Return HTML string of a filter search box.
904 891 *
905 - * @return void
892 + * @return string
906 893 */
907 894 public function filter_search() {
908 - printf(
895 + $search = null;
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
898 + }
899 + $out = sprintf(
909 900 '<p class="search-box">
910 901 <label class="screen-reader-text" for="record-search-input">%1$s:</label>
911 902 <input type="search" id="record-search-input" name="search" value="%2$s" />
912 - <input type="submit" name="" id="search-submit" class="button" value="%3$s" />
903 + <input type="submit" name="" id="search-submit" class="button" value="%1$s" />
913 904 </p>',
914 - esc_html__( 'Search Records', 'stream' ),
915 - esc_attr( ! empty( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '' ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
916 - esc_attr__( 'Search Records', 'stream' )
905 + esc_attr__( 'Search Records', 'stream' ),
906 + $search
917 907 );
908 +
909 + return $out;
918 910 }
919 911
920 912 /**
921 - * Renders a filter select box based upon date.
913 + * Return HTML string of a filter select box based upon date.
922 914 *
923 - * @param array $items Records.
924 - *
925 - * @return void
915 + * @param array $items Records.
916 + * @return string
926 917 */
927 918 public function filter_date( $items ) {
928 919 wp_enqueue_style( 'jquery-ui' );
929 920 wp_enqueue_style( 'wp-stream-datepicker' );
@@ -932,8 +923,9 @@
932 923 $date_predefined = wp_stream_filter_input( INPUT_GET, 'date_predefined' );
933 924 $date_from = wp_stream_filter_input( INPUT_GET, 'date_from' );
934 925 $date_to = wp_stream_filter_input( INPUT_GET, 'date_to' );
935 926
927 + ob_start();
936 928 ?>
937 929 <div class="date-interval">
938 930
939 931 <select class="field-predefined hide-if-no-js chosen-select" name="date_predefined" data-placeholder="<?php esc_attr_e( 'All Time', 'stream' ); ?>">
@@ -969,14 +961,16 @@
969 961 </div>
970 962
971 963 </div>
972 964 <?php
965 +
966 + return ob_get_clean();
973 967 }
974 968
975 969 /**
976 - * Render a Select dropdown of actions relating to the Stream records
970 + * Output a Select dropdown of actions relating to the Stream records
977 971 *
978 - * @return void
972 + * @return string
979 973 */
980 974 public function record_actions_form() {
981 975 /**
982 976 * Filter the records screen actions dropdown menu
@@ -985,11 +979,12 @@
985 979 */
986 980 $actions = apply_filters( 'wp_stream_record_actions_menu', array() );
987 981
988 982 if ( empty( $actions ) ) {
989 - return;
983 + return '';
990 984 }
991 985
986 + ob_start();
992 987 printf( '<div class="alignleft actions recordactions"><select name="%s">', esc_attr( 'record-actions' ) );
993 988 printf( '<option value="">%s</option>', esc_attr__( 'Record Actions', 'stream' ) );
994 989 foreach ( $actions as $value => $name ) {
995 990 printf(
@@ -1012,8 +1007,10 @@
1012 1007 printf( '<input type="hidden" name="action" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'action' ) ) );
1013 1008
1014 1009 printf( '<input type="submit" name="" id="record-actions-submit" class="button" value="%s">', esc_attr__( 'Apply', 'stream' ) );
1015 1010 echo '<div class="clear"></div>';
1011 +
1012 + return ob_get_clean();
1016 1013 }
1017 1014
1018 1015 /**
1019 1016 * Renders record filter forms.
@@ -1021,14 +1018,14 @@
1021 1018 public function display() {
1022 1019 $url = self_admin_url( $this->plugin->admin->admin_parent_page );
1023 1020
1024 1021 echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
1025 - $this->filter_search();
1022 + echo $this->filter_search(); // xss ok.
1026 1023 parent::display();
1027 1024 echo '</form>';
1028 1025
1029 1026 echo '<form method="get" action="' . esc_url( $url ) . '" id="record-actions-form">';
1030 - $this->record_actions_form();
1027 + echo $this->record_actions_form(); // xss ok.
1031 1028 echo '</form>';
1032 1029 }
1033 1030
1034 1031 /**
@@ -1036,16 +1033,15 @@
1036 1033 *
1037 1034 * @param array $item Record data.
1038 1035 */
1039 1036 public function single_row( $item ) {
1040 - $classes = apply_filters( 'wp_stream_record_classes', array(), $item );
1041 -
1042 - if ( empty( $classes ) ) {
1043 - echo '<tr>';
1044 - } else {
1045 - printf( '<tr class="%s">', esc_attr( join( ' ', $classes ) ) );
1037 + $classes = apply_filters( 'wp_stream_record_classes', array(), $item );
1038 + $class_string = '';
1039 + if ( ! empty( $classes ) ) {
1040 + $class_string = ' class="' . esc_attr( join( ' ', $classes ) ) . '"';
1046 1041 }
1047 1042
1043 + echo sprintf( '<tr%s>', $class_string ); // xss ok.
1048 1044 $this->single_row_columns( $item );
1049 1045 echo '</tr>';
1050 1046 }
1051 1047
@@ -1142,9 +1138,9 @@
1142 1138
1143 1139 if ( 'on' === $option && 'false' === $heartbeat ) {
1144 1140 $option = 'off';
1145 1141
1146 - update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' );
1142 + $this->plugin->admin->update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' );
1147 1143 }
1148 1144
1149 1145 $nonce = wp_create_nonce( $this->plugin->admin->live_update->user_meta_key . '_nonce' );
1150 1146
@@ -1155,8 +1151,11 @@
1155 1151
1156 1152 <div>
1157 1153 <input type="hidden" name="stream_live_update_nonce" id="stream_live_update_nonce" value="<?php echo esc_attr( $nonce ); ?>"/>
1158 1154 </div>
1155 + <div>
1156 + <input type="hidden" name="enable_live_update_user" id="enable_live_update_user" value="<?php echo absint( $user_id ); ?>"/>
1157 + </div>
1159 1158 <div class="metabox-prefs stream-live-update-checkbox">
1160 1159 <label for="enable_live_update">
1161 1160 <input type="checkbox" value="on" name="enable_live_update" id="enable_live_update" data-heartbeat="<?php echo esc_attr( $heartbeat ); ?>" <?php checked( $option, 'on' ); ?> />
1162 1161 <?php esc_html_e( 'Enabled', 'stream' ); ?>
@@ -1209,9 +1208,10 @@
1209 1208 public function get_users_dropdown_items( $users ) {
1210 1209 $record_meta = array();
1211 1210
1212 1211 foreach ( $users as $user_id => $args ) {
1213 - $user = new Author( $user_id );
1212 + $user = new Author( $user_id );
1213 + $disabled = isset( $args['disabled'] ) ? $args['disabled'] : null;
1214 1214
1215 1215 $record_meta[ $user_id ] = array(
1216 1216 'text' => $user->get_display_name(),
1217 1217 'id' => $user_id,
@@ -1217,9 +1217,9 @@
1217 1217 'id' => $user_id,
1218 1218 'label' => $user->get_display_name(),
1219 1219 'icon' => $user->get_avatar_src( 32 ),
1220 1220 'title' => '',
1221 - 'disabled' => ! empty( $args['disabled'] ),
1221 + 'disabled' => $disabled,
1222 1222 );
1223 1223 }
1224 1224
1225 1225 return $record_meta;