| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace WP_Stream; |
| 3 | 4 | |
| 4 | 5 | class List_Table extends \WP_List_Table { |
| 6 | + | |
| 5 | 7 | /** |
| 6 | 8 | * Hold Plugin class |
| 7 | 9 | * |
| 8 | 10 | * @var Plugin |
| @@ -14,9 +16,9 @@ | ||
| 14 | 16 | * |
| 15 | 17 | * @param Plugin $plugin The main Plugin class. |
| 16 | 18 | * @param array $args |
| 17 | 19 | */ |
| 18 | - function __construct( $plugin, $args = array() ) { | |
| 20 | + public function __construct( $plugin, $args = array() ) { | |
| 19 | 21 | $this->plugin = $plugin; |
| 20 | 22 | |
| 21 | 23 | $screen_id = isset( $args['screen'] ) ? $args['screen'] : null; |
| 22 | 24 | |
| @@ -46,21 +48,37 @@ | ||
| 46 | 48 | |
| 47 | 49 | // Check for default hidden columns |
| 48 | 50 | $this->get_hidden_columns(); |
| 49 | 51 | |
| 50 | - add_filter( 'screen_settings', array( $this, 'screen_controls' ), 10, 2 ); | |
| 51 | - add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 ); | |
| 52 | + add_filter( | |
| 53 | + 'screen_settings', | |
| 54 | + array( | |
| 55 | + $this, | |
| 56 | + 'screen_controls', | |
| 57 | + ), | |
| 58 | + 10, | |
| 59 | + 2 | |
| 60 | + ); | |
| 61 | + add_filter( | |
| 62 | + 'set-screen-option', | |
| 63 | + array( | |
| 64 | + $this, | |
| 65 | + 'set_screen_option', | |
| 66 | + ), | |
| 67 | + 10, | |
| 68 | + 3 | |
| 69 | + ); | |
| 52 | 70 | |
| 53 | 71 | set_screen_options(); |
| 54 | 72 | } |
| 55 | 73 | |
| 56 | - function extra_tablenav( $which ) { | |
| 74 | + public function extra_tablenav( $which ) { | |
| 57 | 75 | if ( 'top' === $which ) { |
| 58 | 76 | echo $this->filters_form(); // xss ok |
| 59 | 77 | } |
| 60 | 78 | } |
| 61 | 79 | |
| 62 | - function no_items() { | |
| 80 | + public function no_items() { | |
| 63 | 81 | ?> |
| 64 | 82 | <div class="stream-list-table-no-items"> |
| 65 | 83 | <p><?php esc_html_e( 'Sorry, no activity records were found.', 'stream' ); ?></p> |
| 66 | 84 | </div> |
| @@ -66,9 +84,9 @@ | ||
| 66 | 84 | </div> |
| 67 | 85 | <?php |
| 68 | 86 | } |
| 69 | 87 | |
| 70 | - function get_columns() { | |
| 88 | + public function get_columns() { | |
| 71 | 89 | /** |
| 72 | 90 | * Allows devs to add new columns to table |
| 73 | 91 | * |
| 74 | 92 | * @return array |
| @@ -85,16 +103,17 @@ | ||
| 85 | 103 | ) |
| 86 | 104 | ); |
| 87 | 105 | } |
| 88 | 106 | |
| 89 | - function get_sortable_columns() { | |
| 107 | + public function get_sortable_columns() { | |
| 90 | 108 | return array( |
| 91 | 109 | 'date' => array( 'date', false ), |
| 92 | 110 | ); |
| 93 | 111 | } |
| 94 | 112 | |
| 95 | - function get_hidden_columns() { | |
| 96 | - if ( ! $user = wp_get_current_user() ) { | |
| 113 | + public function get_hidden_columns() { | |
| 114 | + $user = wp_get_current_user(); | |
| 115 | + if ( ! $user ) { | |
| 97 | 116 | return array(); |
| 98 | 117 | } |
| 99 | 118 | |
| 100 | 119 | // Directly checking the user meta; to check whether user has changed screen option or not |
| @@ -108,15 +127,20 @@ | ||
| 108 | 127 | |
| 109 | 128 | return $hidden; |
| 110 | 129 | } |
| 111 | 130 | |
| 112 | - function prepare_items() { | |
| 131 | + public function prepare_items() { | |
| 113 | 132 | $columns = $this->get_columns(); |
| 114 | 133 | $sortable = $this->get_sortable_columns(); |
| 115 | 134 | $hidden = $this->get_hidden_columns(); |
| 116 | 135 | $primary = $columns['summary']; |
| 117 | 136 | |
| 118 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); | |
| 137 | + $this->_column_headers = array( | |
| 138 | + $columns, | |
| 139 | + $hidden, | |
| 140 | + $sortable, | |
| 141 | + $primary, | |
| 142 | + ); | |
| 119 | 143 | |
| 120 | 144 | $this->items = $this->get_records(); |
| 121 | 145 | |
| 122 | 146 | $total_items = $this->get_total_found_rows(); |
| @@ -128,17 +152,19 @@ | ||
| 128 | 152 | ) |
| 129 | 153 | ); |
| 130 | 154 | } |
| 131 | 155 | |
| 132 | - function get_records() { | |
| 156 | + public function get_records() { | |
| 133 | 157 | $args = array(); |
| 134 | 158 | |
| 135 | 159 | // Parse sorting params |
| 136 | - if ( $order = wp_stream_filter_input( INPUT_GET, 'order' ) ) { | |
| 160 | + $order = wp_stream_filter_input( INPUT_GET, 'order' ); | |
| 161 | + if ( $order ) { | |
| 137 | 162 | $args['order'] = $order; |
| 138 | 163 | } |
| 139 | 164 | |
| 140 | - if ( $orderby = wp_stream_filter_input( INPUT_GET, 'orderby' ) ) { | |
| 165 | + $orderby = wp_stream_filter_input( INPUT_GET, 'orderby' ); | |
| 166 | + if ( $orderby ) { | |
| 141 | 167 | $args['orderby'] = $orderby; |
| 142 | 168 | } |
| 143 | 169 | |
| 144 | 170 | $params = array( |
| @@ -206,8 +232,9 @@ | ||
| 206 | 232 | } |
| 207 | 233 | $args['records_per_page'] = apply_filters( 'stream_records_per_page', $args['records_per_page'] ); |
| 208 | 234 | |
| 209 | 235 | $items = $this->plugin->db->get_records( $args ); |
| 236 | + | |
| 210 | 237 | return $items; |
| 211 | 238 | } |
| 212 | 239 | |
| 213 | 240 | /** |
| @@ -218,14 +245,14 @@ | ||
| 218 | 245 | public function get_total_found_rows() { |
| 219 | 246 | return $this->plugin->db->get_found_records_count(); |
| 220 | 247 | } |
| 221 | 248 | |
| 222 | - function column_default( $item, $column_name ) { | |
| 223 | - $out = ''; | |
| 249 | + public function column_default( $item, $column_name ) { | |
| 250 | + $out = ''; | |
| 224 | 251 | $record = new Record( $item ); |
| 225 | 252 | |
| 226 | 253 | switch ( $column_name ) { |
| 227 | - case 'date' : | |
| 254 | + case 'date': | |
| 228 | 255 | $created = date( 'Y-m-d H:i:s', strtotime( $record->created ) ); |
| 229 | 256 | $date_string = sprintf( |
| 230 | 257 | '<time datetime="%s" class="relative-time record-created">%s</time>', |
| 231 | 258 | wp_stream_get_iso_8601_extended_date( strtotime( $record->created ) ), |
| @@ -230,16 +257,17 @@ | ||
| 230 | 257 | '<time datetime="%s" class="relative-time record-created">%s</time>', |
| 231 | 258 | wp_stream_get_iso_8601_extended_date( strtotime( $record->created ) ), |
| 232 | 259 | get_date_from_gmt( $created, 'Y/m/d' ) |
| 233 | 260 | ); |
| 234 | - $out = $this->column_link( $date_string, 'date', get_date_from_gmt( $created, 'Y/m/d' ) ); | |
| 235 | - $out .= '<br />'; | |
| 236 | - $out .= get_date_from_gmt( $created, 'h:i:s A' ); | |
| 261 | + $out = $this->column_link( $date_string, 'date', get_date_from_gmt( $created, 'Y/m/d' ) ); | |
| 262 | + $out .= '<br />'; | |
| 263 | + $out .= get_date_from_gmt( $created, 'h:i:s A' ); | |
| 237 | 264 | break; |
| 238 | 265 | |
| 239 | - case 'summary' : | |
| 240 | - $out = $record->summary; | |
| 241 | - $object_title = $record->get_object_title(); | |
| 266 | + case 'summary': | |
| 267 | + $out = $record->summary; | |
| 268 | + $object_title = $record->get_object_title(); | |
| 269 | + // translators: Placeholder refers to the title of any object, like a Post (e.g. "Hello World") | |
| 242 | 270 | $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' ); |
| 243 | 271 | |
| 244 | 272 | if ( $record->object_id ) { |
| 245 | 273 | $out .= $this->column_link( |
| @@ -254,9 +282,9 @@ | ||
| 254 | 282 | } |
| 255 | 283 | $out .= $this->get_action_links( $record ); |
| 256 | 284 | break; |
| 257 | 285 | |
| 258 | - case 'user_id' : | |
| 286 | + case 'user_id': | |
| 259 | 287 | $user = new Author( (int) $record->user_id, (array) $record->user_meta ); |
| 260 | 288 | |
| 261 | 289 | $filtered_records_url = add_query_arg( |
| 262 | 290 | array( |
| @@ -300,13 +328,13 @@ | ||
| 300 | 328 | $blog = ( $record->blog_id && is_multisite() ) ? get_blog_details( $record->blog_id ) : $this->plugin->admin->network->get_network_blog(); |
| 301 | 329 | $out = $this->column_link( $blog->blogname, 'blog_id', $blog->blog_id ); |
| 302 | 330 | break; |
| 303 | 331 | |
| 304 | - case 'ip' : | |
| 332 | + case 'ip': | |
| 305 | 333 | $out = $this->column_link( $record->{$column_name}, 'ip', $record->{$column_name} ); |
| 306 | 334 | break; |
| 307 | 335 | |
| 308 | - default : | |
| 336 | + default: | |
| 309 | 337 | /** |
| 310 | 338 | * Registers new Columns to be inserted into the table. The cell contents of this column is set |
| 311 | 339 | * below with 'wp_stream_insert_column_default_' |
| 312 | 340 | * |
| @@ -311,9 +339,10 @@ | ||
| 311 | 339 | * below with 'wp_stream_insert_column_default_' |
| 312 | 340 | * |
| 313 | 341 | * @return array |
| 314 | 342 | */ |
| 315 | - $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns = array() ); | |
| 343 | + $new_columns = array(); | |
| 344 | + $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns ); | |
| 316 | 345 | |
| 317 | 346 | if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) { |
| 318 | 347 | foreach ( $inserted_columns as $column_title ) { |
| 319 | 348 | /** |
| @@ -327,9 +356,9 @@ | ||
| 327 | 356 | if ( $column_title === $column_name && has_filter( "wp_stream_insert_column_default_{$column_title}" ) ) { |
| 328 | 357 | /** |
| 329 | 358 | * Allows for the addition of content under a specified column. |
| 330 | 359 | * |
| 331 | - * @param object $record Contents of the row | |
| 360 | + * @param object $record Contents of the row | |
| 332 | 361 | * |
| 333 | 362 | * @return string |
| 334 | 363 | */ |
| 335 | 364 | $out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $column_name, $record ); |
| @@ -341,10 +370,13 @@ | ||
| 341 | 370 | $out = $column_name; |
| 342 | 371 | } |
| 343 | 372 | } |
| 344 | 373 | |
| 345 | - $allowed_tags = wp_kses_allowed_html( 'post' ); | |
| 346 | - $allowed_tags['time'] = array( 'datetime' => true, 'class' => true ); | |
| 374 | + $allowed_tags = wp_kses_allowed_html( 'post' ); | |
| 375 | + $allowed_tags['time'] = array( | |
| 376 | + 'datetime' => true, | |
| 377 | + 'class' => true, | |
| 378 | + ); | |
| 347 | 379 | $allowed_tags['img']['srcset'] = true; |
| 348 | 380 | |
| 349 | 381 | echo wp_kses( $out, $allowed_tags ); |
| 350 | 382 | } |
| @@ -401,9 +433,9 @@ | ||
| 401 | 433 | |
| 402 | 434 | return $out; |
| 403 | 435 | } |
| 404 | 436 | |
| 405 | - function column_link( $display, $key, $value = null, $title = null ) { | |
| 437 | + public function column_link( $display, $key, $value = null, $title = null ) { | |
| 406 | 438 | $url = add_query_arg( |
| 407 | 439 | array( |
| 408 | 440 | 'page' => $this->plugin->admin->records_page_slug, |
| 409 | 441 | ), |
| @@ -409,9 +441,11 @@ | ||
| 409 | 441 | ), |
| 410 | 442 | self_admin_url( $this->plugin->admin->admin_parent_page ) |
| 411 | 443 | ); |
| 412 | 444 | |
| 413 | - $args = ! is_array( $key ) ? array( $key => $value ) : $key; | |
| 445 | + $args = ! is_array( $key ) ? array( | |
| 446 | + $key => $value, | |
| 447 | + ) : $key; | |
| 414 | 448 | |
| 415 | 449 | foreach ( $args as $k => $v ) { |
| 416 | 450 | $url = add_query_arg( $k, $v, $url ); |
| 417 | 451 | } |
| @@ -424,13 +458,13 @@ | ||
| 424 | 458 | ); |
| 425 | 459 | } |
| 426 | 460 | |
| 427 | 461 | public function get_term_title( $term, $type ) { |
| 428 | - if ( ! isset( $this->plugin->connectors->term_labels[ "stream_$type" ][ $term ] ) ) { | |
| 462 | + if ( ! isset( $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ] ) ) { | |
| 429 | 463 | return $term; |
| 430 | 464 | } |
| 431 | 465 | |
| 432 | - return $this->plugin->connectors->term_labels[ "stream_$type" ][ $term ]; | |
| 466 | + return $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ]; | |
| 433 | 467 | } |
| 434 | 468 | |
| 435 | 469 | /** |
| 436 | 470 | * Assembles records for display in search filters |
| @@ -442,9 +476,9 @@ | ||
| 442 | 476 | * @param string $column List table column name |
| 443 | 477 | * |
| 444 | 478 | * @return array Options to be displayed in search filters |
| 445 | 479 | */ |
| 446 | - function assemble_records( $column ) { | |
| 480 | + public function assemble_records( $column ) { | |
| 447 | 481 | // @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object |
| 448 | 482 | if ( 'user_id' === $column ) { |
| 449 | 483 | $all_records = array(); |
| 450 | 484 | |
| @@ -455,9 +489,12 @@ | ||
| 455 | 489 | if ( $total_users > $this->plugin->admin->preload_users_max ) { |
| 456 | 490 | $selected_user = wp_stream_filter_input( INPUT_GET, 'user_id' ); |
| 457 | 491 | if ( $selected_user ) { |
| 458 | 492 | $user = new Author( $selected_user ); |
| 459 | - return array( $selected_user => $user->get_display_name() ); | |
| 493 | + | |
| 494 | + return array( | |
| 495 | + $selected_user => $user->get_display_name(), | |
| 496 | + ); | |
| 460 | 497 | } else { |
| 461 | 498 | return array(); |
| 462 | 499 | } |
| 463 | 500 | } |
| @@ -462,26 +499,36 @@ | ||
| 462 | 499 | } |
| 463 | 500 | } |
| 464 | 501 | |
| 465 | 502 | $users = array_map( |
| 466 | - function( $user_id ) { | |
| 503 | + function ( $user_id ) { | |
| 467 | 504 | return new Author( $user_id ); |
| 468 | 505 | }, |
| 469 | - get_users( array( 'fields' => 'ID' ) ) | |
| 506 | + get_users( | |
| 507 | + array( | |
| 508 | + 'fields' => 'ID', | |
| 509 | + ) | |
| 510 | + ) | |
| 470 | 511 | ); |
| 471 | 512 | |
| 472 | 513 | if ( is_multisite() && is_super_admin() ) { |
| 473 | 514 | $super_admins = array_map( |
| 474 | - function( $login ) { | |
| 515 | + function ( $login ) { | |
| 475 | 516 | $user = get_user_by( 'login', $login ); |
| 517 | + | |
| 476 | 518 | return new Author( $user->ID ); |
| 477 | 519 | }, |
| 478 | 520 | get_super_admins() |
| 479 | 521 | ); |
| 480 | - $users = array_unique( array_merge( $users, $super_admins ) ); | |
| 522 | + $users = array_unique( array_merge( $users, $super_admins ) ); | |
| 481 | 523 | } |
| 482 | 524 | |
| 483 | - $users[] = new Author( 0, array( 'is_wp_cli' => true ) ); | |
| 525 | + $users[] = new Author( | |
| 526 | + 0, | |
| 527 | + array( | |
| 528 | + 'is_wp_cli' => true, | |
| 529 | + ) | |
| 530 | + ); | |
| 484 | 531 | |
| 485 | 532 | foreach ( $users as $user ) { |
| 486 | 533 | $all_records[ $user->id ] = $user->get_display_name(); |
| 487 | 534 | } |
| @@ -495,11 +542,17 @@ | ||
| 495 | 542 | $disabled_records = array(); |
| 496 | 543 | |
| 497 | 544 | foreach ( $all_records as $record => $label ) { |
| 498 | 545 | if ( array_key_exists( $record, $existing_records ) ) { |
| 499 | - $active_records[ $record ] = array( 'label' => $label, 'disabled' => '' ); | |
| 546 | + $active_records[ $record ] = array( | |
| 547 | + 'label' => $label, | |
| 548 | + 'disabled' => '', | |
| 549 | + ); | |
| 500 | 550 | } else { |
| 501 | - $disabled_records[ $record ] = array( 'label' => $label, 'disabled' => 'disabled="disabled"' ); | |
| 551 | + $disabled_records[ $record ] = array( | |
| 552 | + 'label' => $label, | |
| 553 | + 'disabled' => 'disabled="disabled"', | |
| 554 | + ); | |
| 502 | 555 | } |
| 503 | 556 | } |
| 504 | 557 | |
| 505 | 558 | // Remove WP-CLI pseudo user if no records with user=0 exist |
| @@ -506,9 +559,9 @@ | ||
| 506 | 559 | if ( isset( $disabled_records[0] ) ) { |
| 507 | 560 | unset( $disabled_records[0] ); |
| 508 | 561 | } |
| 509 | 562 | |
| 510 | - $sort = function( $a, $b ) use ( $column ) { | |
| 563 | + $sort = function ( $a, $b ) use ( $column ) { | |
| 511 | 564 | $label_a = (string) $a['label']; |
| 512 | 565 | $label_b = (string) $b['label']; |
| 513 | 566 | |
| 514 | 567 | if ( $label_a === $label_b ) { |
| @@ -514,9 +567,9 @@ | ||
| 514 | 567 | if ( $label_a === $label_b ) { |
| 515 | 568 | return 0; |
| 516 | 569 | } |
| 517 | 570 | |
| 518 | - return ( strtolower( $label_a ) < strtolower( $label_b ) ) ? -1 : 1; | |
| 571 | + return ( strtolower( $label_a ) < strtolower( $label_b ) ) ? - 1 : 1; | |
| 519 | 572 | }; |
| 520 | 573 | |
| 521 | 574 | uasort( $active_records, $sort ); |
| 522 | 575 | uasort( $disabled_records, $sort ); |
| @@ -566,9 +619,9 @@ | ||
| 566 | 619 | */ |
| 567 | 620 | return apply_filters( 'wp_stream_list_table_filters', $filters ); |
| 568 | 621 | } |
| 569 | 622 | |
| 570 | - function filters_form() { | |
| 623 | + public function filters_form() { | |
| 571 | 624 | $filters = $this->get_filters(); |
| 572 | 625 | |
| 573 | 626 | $filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' ); |
| 574 | 627 | $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) ); |
| @@ -574,13 +627,16 @@ | ||
| 574 | 627 | $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) ); |
| 575 | 628 | |
| 576 | 629 | foreach ( $filters as $name => $data ) { |
| 577 | 630 | |
| 578 | - $data = wp_parse_args( $data, array( | |
| 579 | - 'title' => '', | |
| 580 | - 'items' => array(), | |
| 581 | - 'ajax' => false, | |
| 582 | - ) ); | |
| 631 | + $data = wp_parse_args( | |
| 632 | + $data, | |
| 633 | + array( | |
| 634 | + 'title' => '', | |
| 635 | + 'items' => array(), | |
| 636 | + 'ajax' => false, | |
| 637 | + ) | |
| 638 | + ); | |
| 583 | 639 | |
| 584 | 640 | if ( 'date' === $name ) { |
| 585 | 641 | $filters_string .= $this->filter_date( $data['items'] ); |
| 586 | 642 | } else { |
| @@ -660,9 +716,9 @@ | ||
| 660 | 716 | |
| 661 | 717 | return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok |
| 662 | 718 | } |
| 663 | 719 | |
| 664 | - function filter_select( $name, $title, $items, $ajax = false ) { | |
| 720 | + public function filter_select( $name, $title, $items, $ajax = false ) { | |
| 665 | 721 | if ( $ajax ) { |
| 666 | 722 | $out = sprintf( |
| 667 | 723 | '<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />', |
| 668 | 724 | esc_attr( $name ), |
| @@ -684,13 +740,13 @@ | ||
| 684 | 740 | 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null, |
| 685 | 741 | 'class' => isset( $item['children'] ) ? 'level-1' : null, |
| 686 | 742 | 'label' => isset( $item['label'] ) ? $item['label'] : null, |
| 687 | 743 | ); |
| 688 | - $options[] = $this->filter_option( $option_args ); | |
| 744 | + $options[] = $this->filter_option( $option_args ); | |
| 689 | 745 | |
| 690 | 746 | if ( isset( $item['children'] ) ) { |
| 691 | 747 | foreach ( $item['children'] as $child_value => $child_item ) { |
| 692 | - $option_args = array( | |
| 748 | + $option_args = array( | |
| 693 | 749 | 'value' => $child_value, |
| 694 | 750 | 'selected' => selected( $child_value, $selected, false ), |
| 695 | 751 | 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null, |
| 696 | 752 | 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null, |
| @@ -698,9 +754,9 @@ | ||
| 698 | 754 | 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null, |
| 699 | 755 | 'class' => 'level-2', |
| 700 | 756 | 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null, |
| 701 | 757 | ); |
| 702 | - $options[] = $this->filter_option( $option_args ); | |
| 758 | + $options[] = $this->filter_option( $option_args ); | |
| 703 | 759 | } |
| 704 | 760 | } |
| 705 | 761 | } |
| 706 | 762 | $out = sprintf( |
| @@ -705,8 +761,9 @@ | ||
| 705 | 761 | } |
| 706 | 762 | $out = sprintf( |
| 707 | 763 | '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>', |
| 708 | 764 | esc_attr( $name ), |
| 765 | + // translators: Placeholder refers to the title of the dropdown menu (e.g. "users") | |
| 709 | 766 | sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ), |
| 710 | 767 | implode( '', $options ) |
| 711 | 768 | ); |
| 712 | 769 | } |
| @@ -713,9 +770,9 @@ | ||
| 713 | 770 | |
| 714 | 771 | return $out; |
| 715 | 772 | } |
| 716 | 773 | |
| 717 | - function filter_option( $args ) { | |
| 774 | + public function filter_option( $args ) { | |
| 718 | 775 | $defaults = array( |
| 719 | 776 | 'value' => null, |
| 720 | 777 | 'selected' => null, |
| 721 | 778 | 'disabled' => null, |
| @@ -739,13 +796,12 @@ | ||
| 739 | 796 | esc_html( $args['label'] ) |
| 740 | 797 | ); |
| 741 | 798 | } |
| 742 | 799 | |
| 743 | - function filter_search() { | |
| 800 | + public function filter_search() { | |
| 744 | 801 | $search = null; |
| 745 | - if ( isset( $_GET['search'] ) ) { | |
| 746 | - // @TODO: Make this pass phpcs | |
| 747 | - $search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay | |
| 802 | + if ( isset( $_GET['search'] ) ) { // CSRF okay | |
| 803 | + $search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay, CSRF okay | |
| 748 | 804 | } |
| 749 | 805 | $out = sprintf( |
| 750 | 806 | '<p class="search-box"> |
| 751 | 807 | <label class="screen-reader-text" for="record-search-input">%1$s:</label> |
| @@ -758,9 +814,9 @@ | ||
| 758 | 814 | |
| 759 | 815 | return $out; |
| 760 | 816 | } |
| 761 | 817 | |
| 762 | - function filter_date( $items ) { | |
| 818 | + public function filter_date( $items ) { | |
| 763 | 819 | wp_enqueue_style( 'jquery-ui' ); |
| 764 | 820 | wp_enqueue_style( 'wp-stream-datepicker' ); |
| 765 | 821 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 766 | 822 | |
| @@ -793,15 +849,15 @@ | ||
| 793 | 849 | |
| 794 | 850 | <div class="date-inputs"> |
| 795 | 851 | <div class="box"> |
| 796 | 852 | <i class="date-remove dashicons"></i> |
| 797 | - <input type="text" name="date_from" class="date-picker field-from" placeholder="<?php esc_attr_e( 'Start Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_from ); ?>" /> | |
| 853 | + <input type="text" name="date_from" class="date-picker field-from" placeholder="<?php esc_attr_e( 'Start Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_from ); ?>"/> | |
| 798 | 854 | </div> |
| 799 | 855 | <span class="connector dashicons"></span> |
| 800 | 856 | |
| 801 | 857 | <div class="box"> |
| 802 | 858 | <i class="date-remove dashicons"></i> |
| 803 | - <input type="text" name="date_to" class="date-picker field-to" placeholder="<?php esc_attr_e( 'End Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_to ); ?>" /> | |
| 859 | + <input type="text" name="date_to" class="date-picker field-to" placeholder="<?php esc_attr_e( 'End Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_to ); ?>"/> | |
| 804 | 860 | </div> |
| 805 | 861 | </div> |
| 806 | 862 | |
| 807 | 863 | </div> |
| @@ -814,9 +870,9 @@ | ||
| 814 | 870 | * Output a Select dropdown of actions relating to the Stream records |
| 815 | 871 | * |
| 816 | 872 | * @return string |
| 817 | 873 | */ |
| 818 | - function record_actions_form() { | |
| 874 | + public function record_actions_form() { | |
| 819 | 875 | /** |
| 820 | 876 | * Filter the records screen actions dropdown menu |
| 821 | 877 | * |
| 822 | 878 | * @return array Should be in the format of action_slug => 'Action Name' |
| @@ -854,9 +910,9 @@ | ||
| 854 | 910 | |
| 855 | 911 | return ob_get_clean(); |
| 856 | 912 | } |
| 857 | 913 | |
| 858 | - function display() { | |
| 914 | + public function display() { | |
| 859 | 915 | $url = self_admin_url( $this->plugin->admin->admin_parent_page ); |
| 860 | 916 | |
| 861 | 917 | echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">'; |
| 862 | 918 | echo $this->filter_search(); // xss ok |
| @@ -867,9 +923,9 @@ | ||
| 867 | 923 | echo $this->record_actions_form(); // xss ok |
| 868 | 924 | echo '</form>'; |
| 869 | 925 | } |
| 870 | 926 | |
| 871 | - function single_row( $item ) { | |
| 927 | + public function single_row( $item ) { | |
| 872 | 928 | $classes = apply_filters( 'wp_stream_record_classes', array(), $item ); |
| 873 | 929 | $class_string = ''; |
| 874 | 930 | if ( ! empty( $classes ) ) { |
| 875 | 931 | $class_string = ' class="' . esc_attr( join( ' ', $classes ) ) . '"'; |
| @@ -879,10 +935,11 @@ | ||
| 879 | 935 | $this->single_row_columns( $item ); |
| 880 | 936 | echo '</tr>'; |
| 881 | 937 | } |
| 882 | 938 | |
| 883 | - function display_tablenav( $which ) { | |
| 884 | - if ( 'top' === $which ) : ?> | |
| 939 | + public function display_tablenav( $which ) { | |
| 940 | + if ( 'top' === $which ) : | |
| 941 | + ?> | |
| 885 | 942 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
| 886 | 943 | <?php |
| 887 | 944 | $this->pagination( $which ); |
| 888 | 945 | $this->extra_tablenav( $which ); |
| @@ -887,9 +944,9 @@ | ||
| 887 | 944 | $this->pagination( $which ); |
| 888 | 945 | $this->extra_tablenav( $which ); |
| 889 | 946 | ?> |
| 890 | 947 | |
| 891 | - <br class="clear" /> | |
| 948 | + <br class="clear"/> | |
| 892 | 949 | </div> |
| 893 | 950 | <?php else : ?> |
| 894 | 951 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
| 895 | 952 | <?php |
| @@ -900,15 +957,15 @@ | ||
| 900 | 957 | $this->pagination( $which ); |
| 901 | 958 | $this->extra_tablenav( $which ); |
| 902 | 959 | ?> |
| 903 | 960 | |
| 904 | - <br class="clear" /> | |
| 961 | + <br class="clear"/> | |
| 905 | 962 | </div> |
| 906 | - <?php | |
| 963 | + <?php | |
| 907 | 964 | endif; |
| 908 | 965 | } |
| 909 | 966 | |
| 910 | - function set_screen_option( $dummy, $option, $value ) { | |
| 967 | + public function set_screen_option( $dummy, $option, $value ) { | |
| 911 | 968 | if ( 'edit_stream_per_page' === $option ) { |
| 912 | 969 | return $value; |
| 913 | 970 | } else { |
| 914 | 971 | return $dummy; |
| @@ -914,9 +971,9 @@ | ||
| 914 | 971 | return $dummy; |
| 915 | 972 | } |
| 916 | 973 | } |
| 917 | 974 | |
| 918 | - function set_live_update_option( $dummy, $option, $value ) { | |
| 975 | + public function set_live_update_option( $dummy, $option, $value ) { | |
| 919 | 976 | unset( $value ); |
| 920 | 977 | |
| 921 | 978 | // @codingStandardsIgnoreStart |
| 922 | 979 | if ( |
| @@ -927,8 +984,9 @@ | ||
| 927 | 984 | $value = esc_attr( $_POST[ $this->plugin->admin->live_update->user_meta_key ] ); //input var okay |
| 928 | 985 | |
| 929 | 986 | return $value; |
| 930 | 987 | } |
| 988 | + | |
| 931 | 989 | // @codingStandardsIgnoreEnd |
| 932 | 990 | |
| 933 | 991 | return $dummy; |
| 934 | 992 | } |
| @@ -954,17 +1012,18 @@ | ||
| 954 | 1012 | <fieldset> |
| 955 | 1013 | <h5><?php esc_html_e( 'Live updates', 'stream' ); ?></h5> |
| 956 | 1014 | |
| 957 | 1015 | <div> |
| 958 | - <input type="hidden" name="stream_live_update_nonce" id="stream_live_update_nonce" value="<?php echo esc_attr( $nonce ); ?>" /> | |
| 1016 | + <input type="hidden" name="stream_live_update_nonce" id="stream_live_update_nonce" value="<?php echo esc_attr( $nonce ); ?>"/> | |
| 959 | 1017 | </div> |
| 960 | 1018 | <div> |
| 961 | - <input type="hidden" name="enable_live_update_user" id="enable_live_update_user" value="<?php echo absint( $user_id ); ?>" /> | |
| 1019 | + <input type="hidden" name="enable_live_update_user" id="enable_live_update_user" value="<?php echo absint( $user_id ); ?>"/> | |
| 962 | 1020 | </div> |
| 963 | 1021 | <div class="metabox-prefs stream-live-update-checkbox"> |
| 964 | 1022 | <label for="enable_live_update"> |
| 965 | 1023 | <input type="checkbox" value="on" name="enable_live_update" id="enable_live_update" data-heartbeat="<?php echo esc_attr( $heartbeat ); ?>" <?php checked( $option, 'on' ); ?> /> |
| 966 | - <?php esc_html_e( 'Enabled', 'stream' ); ?><span class="spinner"></span> | |
| 1024 | + <?php esc_html_e( 'Enabled', 'stream' ); ?> | |
| 1025 | + <span class="spinner"></span> | |
| 967 | 1026 | </label> |
| 968 | 1027 | </div> |
| 969 | 1028 | </fieldset> |
| 970 | 1029 | <?php |
| @@ -977,9 +1036,9 @@ | ||
| 977 | 1036 | * @param string $column List table column name |
| 978 | 1037 | * |
| 979 | 1038 | * @return string setting name for that column |
| 980 | 1039 | */ |
| 981 | - function get_column_excluded_setting_key( $column ) { | |
| 1040 | + public function get_column_excluded_setting_key( $column ) { | |
| 982 | 1041 | switch ( $column ) { |
| 983 | 1042 | case 'connector': |
| 984 | 1043 | $output = 'connectors'; |
| 985 | 1044 | break; |