PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.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-admin.php +191 -91 3.13.4.2 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace WP_Stream;
3 4
4 5 use DateTime;
5 6 use DateTimeZone;
@@ -7,8 +8,9 @@
7 8 use \WP_CLI;
8 9 use \WP_Roles;
9 10
10 11 class Admin {
12 +
11 13 /**
12 14 * Hold Plugin class
13 15 *
14 16 * @var Plugin
@@ -124,9 +126,9 @@
124 126 add_action( 'init', array( $this, 'init' ) );
125 127
126 128 // Ensure function used in various methods is pre-loaded.
127 129 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
128 - require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
130 + require_once ABSPATH . '/wp-admin/includes/plugin.php';
129 131 }
130 132
131 133 // User and role caps.
132 134 add_filter( 'user_has_cap', array( $this, 'filter_user_caps' ), 10, 4 );
@@ -131,9 +133,9 @@
131 133 // User and role caps.
132 134 add_filter( 'user_has_cap', array( $this, 'filter_user_caps' ), 10, 4 );
133 135 add_filter( 'role_has_cap', array( $this, 'filter_role_caps' ), 10, 3 );
134 136
135 - if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && ! is_network_admin() ) {
137 + if ( is_multisite() && $plugin->is_network_activated() && ! is_network_admin() ) {
136 138 $options = (array) get_site_option( 'wp_stream_network', array() );
137 139 $option = isset( $options['general_site_access'] ) ? absint( $options['general_site_access'] ) : 1;
138 140
139 141 $this->disable_access = ( $option ) ? false : true;
@@ -151,27 +153,58 @@
151 153 // Add admin body class.
152 154 add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
153 155
154 156 // Plugin action links.
155 - add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
157 + add_filter(
158 + 'plugin_action_links',
159 + array(
160 + $this,
161 + 'plugin_action_links',
162 + ),
163 + 10,
164 + 2
165 + );
156 166
157 167 // Load admin scripts and styles.
158 - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
168 + add_action(
169 + 'admin_enqueue_scripts',
170 + array(
171 + $this,
172 + 'admin_enqueue_scripts',
173 + )
174 + );
159 175 add_action( 'admin_enqueue_scripts', array( $this, 'admin_menu_css' ) );
160 176
161 177 // Reset Streams database.
162 - add_action( 'wp_ajax_wp_stream_reset', array( $this, 'wp_ajax_reset' ) );
178 + add_action(
179 + 'wp_ajax_wp_stream_reset',
180 + array(
181 + $this,
182 + 'wp_ajax_reset',
183 + )
184 + );
163 185
164 186 // Uninstall Streams and Deactivate plugin.
165 - $uninstall = new Uninstall( $this->plugin );
166 - add_action( 'wp_ajax_wp_stream_uninstall', array( $uninstall, 'uninstall' ) );
187 + $uninstall = $this->plugin->db->driver->purge_storage( $this->plugin );
167 188
168 189 // Auto purge setup.
169 190 add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) );
170 - add_action( 'wp_stream_auto_purge', array( $this, 'purge_scheduled_action' ) );
191 + add_action(
192 + 'wp_stream_auto_purge',
193 + array(
194 + $this,
195 + 'purge_scheduled_action',
196 + )
197 + );
171 198
172 199 // Ajax users list.
173 - add_action( 'wp_ajax_wp_stream_filters', array( $this, 'ajax_filters' ) );
200 + add_action(
201 + 'wp_ajax_wp_stream_filters',
202 + array(
203 + $this,
204 + 'ajax_filters',
205 + )
206 + );
174 207 }
175 208
176 209 /**
177 210 * Load admin classes
@@ -331,9 +364,15 @@
331 364 */
332 365 do_action( 'wp_stream_admin_menu_screens' );
333 366
334 367 // Register the list table early, so it associates the column headers with 'Screen settings'.
335 - add_action( 'load-' . $this->screen_id['main'], array( $this, 'register_list_table' ) );
368 + add_action(
369 + 'load-' . $this->screen_id['main'],
370 + array(
371 + $this,
372 + 'register_list_table',
373 + )
374 + );
336 375 }
337 376 }
338 377
339 378 /**
@@ -345,10 +384,10 @@
345 384 *
346 385 * @return void
347 386 */
348 387 public function admin_enqueue_scripts( $hook ) {
349 - wp_register_script( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/js/select2.js', array( 'jquery' ), '3.5.2', true );
350 - wp_register_style( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/css/select2.css', array(), '3.5.2' );
388 + wp_register_script( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/js/select2.full.min.js', array( 'jquery' ), '3.5.2', true );
389 + wp_register_style( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/css/select2.min.css', array(), '3.5.2' );
351 390 wp_register_script( 'wp-stream-timeago', $this->plugin->locations['url'] . 'ui/lib/timeago/jquery.timeago.js', array(), '1.4.1', true );
352 391
353 392 $locale = strtolower( substr( get_locale(), 0, 2 ) );
354 393 $file_tmpl = 'ui/lib/timeago/locales/jquery.timeago.%s.js';
@@ -358,9 +397,10 @@
358 397 } else {
359 398 wp_register_script( 'wp-stream-timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, 'en' ), array( 'wp-stream-timeago' ), '1' );
360 399 }
361 400
362 - wp_enqueue_style( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/css/admin.css', array(), $this->plugin->get_version() );
401 + $min = wp_stream_min_suffix();
402 + wp_enqueue_style( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/css/admin.' . $min . 'css', array(), $this->plugin->get_version() );
363 403
364 404 $script_screens = array( 'plugins.php' );
365 405
366 406 if ( in_array( $hook, $this->screen_id, true ) || in_array( $hook, $script_screens, true ) ) {
@@ -369,11 +409,35 @@
369 409
370 410 wp_enqueue_script( 'wp-stream-timeago' );
371 411 wp_enqueue_script( 'wp-stream-timeago-locale' );
372 412
373 - wp_enqueue_script( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/js/admin.js', array( 'jquery', 'wp-stream-select2' ), $this->plugin->get_version() );
374 - wp_enqueue_script( 'wp-stream-admin-exclude', $this->plugin->locations['url'] . 'ui/js/exclude.js', array( 'jquery', 'wp-stream-select2' ), $this->plugin->get_version() );
375 - wp_enqueue_script( 'wp-stream-live-updates', $this->plugin->locations['url'] . 'ui/js/live-updates.js', array( 'jquery', 'heartbeat' ), $this->plugin->get_version() );
413 + wp_enqueue_script(
414 + 'wp-stream-admin',
415 + $this->plugin->locations['url'] . 'ui/js/admin.' . $min . 'js',
416 + array(
417 + 'jquery',
418 + 'wp-stream-select2',
419 + ),
420 + $this->plugin->get_version()
421 + );
422 + wp_enqueue_script(
423 + 'wp-stream-admin-exclude',
424 + $this->plugin->locations['url'] . 'ui/js/exclude.' . $min . 'js',
425 + array(
426 + 'jquery',
427 + 'wp-stream-select2',
428 + ),
429 + $this->plugin->get_version()
430 + );
431 + wp_enqueue_script(
432 + 'wp-stream-live-updates',
433 + $this->plugin->locations['url'] . 'ui/js/live-updates.' . $min . 'js',
434 + array(
435 + 'jquery',
436 + 'heartbeat',
437 + ),
438 + $this->plugin->get_version()
439 + );
376 440
377 441 wp_localize_script(
378 442 'wp-stream-admin',
379 443 'wp_stream',
@@ -392,12 +456,16 @@
392 456 'wp-stream-live-updates',
393 457 'wp_stream_live_updates',
394 458 array(
395 459 'current_screen' => $hook,
396 - 'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // input var okay
397 - 'current_order' => isset( $_GET['order'] ) ? esc_js( $_GET['order'] ) : 'desc', // input var okay
398 - 'current_query' => wp_stream_json_encode( $_GET ), // input var okay
399 - 'current_query_count' => count( $_GET ), // input var okay
460 + 'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // WPCS: CSRF ok.
461 + // input var okay, CSRF okay
462 + 'current_order' => isset( $_GET['order'] ) ? esc_js( $_GET['order'] ) : 'desc', // WPCS: CSRF ok.
463 + // input var okay, CSRF okay
464 + 'current_query' => wp_stream_json_encode( $_GET ), // WPCS: CSRF ok.
465 + // input var okay, CSRF okay
466 + 'current_query_count' => count( $_GET ), // WPCS: CSRF ok.
467 + // input var okay, CSRF okay
400 468 )
401 469 );
402 470 }
403 471
@@ -414,15 +482,16 @@
414 482 * @return int
415 483 */
416 484 $bulk_actions_threshold = apply_filters( 'wp_stream_bulk_actions_threshold', 100 );
417 485
418 - wp_enqueue_script( 'wp-stream-global', $this->plugin->locations['url'] . 'ui/js/global.js', array( 'jquery' ), $this->plugin->get_version() );
486 + wp_enqueue_script( 'wp-stream-global', $this->plugin->locations['url'] . 'ui/js/global.' . $min . 'js', array( 'jquery' ), $this->plugin->get_version() );
419 487 wp_localize_script(
420 488 'wp-stream-global',
421 489 'wp_stream_global',
422 490 array(
423 - 'bulk_actions' => array(
424 - 'i18n' => array(
491 + 'bulk_actions' => array(
492 + 'i18n' => array(
493 + // translators: Placeholder refers to a number of items (e.g. "1,742")
425 494 'confirm_action' => sprintf( esc_html__( 'Are you sure you want to perform bulk actions on over %s items? This process could take a while to complete.', 'stream' ), number_format( absint( $bulk_actions_threshold ) ) ),
426 495 ),
427 496 'threshold' => absint( $bulk_actions_threshold ),
428 497 ),
@@ -441,9 +510,9 @@
441 510 return true;
442 511 }
443 512
444 513 $screen = get_current_screen();
445 - if ( is_admin() && 'post' === $screen->base && Alerts::POST_TYPE === $screen->post_type ) {
514 + if ( is_admin() && Alerts::POST_TYPE === $screen->post_type ) {
446 515 return true;
447 516 }
448 517
449 518 return false;
@@ -463,10 +532,10 @@
463 532
464 533 if ( $this->is_stream_screen() ) {
465 534 $stream_classes[] = $this->admin_body_class;
466 535
467 - if ( isset( $_GET['page'] ) ) {
468 - $stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay
536 + if ( isset( $_GET['page'] ) ) { // CSRF okay
537 + $stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay, CSRF okay
469 538 }
470 539 }
471 540
472 541 /**
@@ -487,9 +556,10 @@
487 556 *
488 557 * @action admin_enqueue_scripts
489 558 */
490 559 public function admin_menu_css() {
491 - wp_register_style( 'wp-stream-datepicker', $this->plugin->locations['url'] . 'ui/css/datepicker.css', array(), $this->plugin->get_version() );
560 + $min = wp_stream_min_suffix();
561 + wp_register_style( 'wp-stream-datepicker', $this->plugin->locations['url'] . 'ui/css/datepicker.' . $min . 'css', array(), $this->plugin->get_version() );
492 562 wp_register_style( 'wp-stream-icons', $this->plugin->locations['url'] . 'ui/stream-icons/style.css', array(), $this->plugin->get_version() );
493 563
494 564 // Make sure we're working off a clean version
495 565 if ( ! file_exists( ABSPATH . WPINC . '/version.php' ) ) {
@@ -494,9 +564,9 @@
494 564 // Make sure we're working off a clean version
495 565 if ( ! file_exists( ABSPATH . WPINC . '/version.php' ) ) {
496 566 return;
497 567 }
498 - include( ABSPATH . WPINC . '/version.php' );
568 + include ABSPATH . WPINC . '/version.php';
499 569
500 570 if ( ! isset( $wp_version ) ) {
501 571 return;
502 572 }
@@ -555,10 +625,15 @@
555 625
556 626 \wp_add_inline_style( 'wp-admin', $css );
557 627 }
558 628
629 + /**
630 + * Handle the reset AJAX request to reset logs.
631 + *
632 + * @return bool
633 + */
559 634 public function wp_ajax_reset() {
560 - check_ajax_referer( 'stream_nonce', 'wp_stream_nonce' );
635 + check_ajax_referer( 'stream_nonce_reset', 'wp_stream_nonce_reset' );
561 636
562 637 if ( ! current_user_can( $this->settings_cap ) ) {
563 638 wp_die(
564 639 esc_html__( "You don't have sufficient privileges to do this action.", 'stream' )
@@ -588,9 +663,9 @@
588 663 global $wpdb;
589 664
590 665 $where = '';
591 666
592 - if ( is_multisite() && ! is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
667 + if ( is_multisite() && ! $this->plugin->is_network_activated() ) {
593 668 $where .= $wpdb->prepare( ' AND `blog_id` = %d', get_current_blog_id() );
594 669 }
595 670
596 671 $wpdb->query(
@@ -616,14 +691,14 @@
616 691 is_multisite()
617 692 &&
618 693 is_network_admin()
619 694 &&
620 - ! is_plugin_active_for_network( $this->plugin->locations['plugin'] )
695 + ! $this->plugin->is_network_activated()
621 696 ) {
622 697 return;
623 698 }
624 699
625 - if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
700 + if ( is_multisite() && $this->plugin->is_network_activated() ) {
626 701 $options = (array) get_site_option( 'wp_stream_network', array() );
627 702 } else {
628 703 $options = (array) get_option( 'wp_stream', array() );
629 704 }
@@ -631,10 +706,11 @@
631 706 if ( ! empty( $options['general_keep_records_indefinitely'] ) || ! isset( $options['general_records_ttl'] ) ) {
632 707 return;
633 708 }
634 709
635 - $days = $options['general_records_ttl'];
636 - $date = new DateTime( 'now', $timezone = new DateTimeZone( 'UTC' ) );
710 + $days = $options['general_records_ttl'];
711 + $timezone = new DateTimeZone( 'UTC' );
712 + $date = new DateTime( 'now', $timezone );
637 713
638 714 $date->sub( DateInterval::createFromDateString( "$days days" ) );
639 715
640 716 $where = $wpdb->prepare( ' AND `stream`.`created` < %s', $date->format( 'Y-m-d H:i:s' ) );
@@ -639,9 +715,9 @@
639 715
640 716 $where = $wpdb->prepare( ' AND `stream`.`created` < %s', $date->format( 'Y-m-d H:i:s' ) );
641 717
642 718 // Multisite but NOT network activated, only purge the current blog
643 - if ( is_multisite() && ! is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
719 + if ( is_multisite() && ! $this->plugin->is_network_activated() ) {
644 720 $where .= $wpdb->prepare( ' AND `blog_id` = %d', get_current_blog_id() );
645 721 }
646 722
647 723 $wpdb->query(
@@ -653,9 +729,9 @@
653 729 );
654 730 }
655 731
656 732 /**
657 - * @param array $links
733 + * @param array $links
658 734 * @param string $file
659 735 *
660 736 * @filter plugin_action_links
661 737 *
@@ -666,29 +742,41 @@
666 742 return $links;
667 743 }
668 744
669 745 // Also don't show links in Network Admin if Stream isn't network enabled
670 - if ( is_network_admin() && is_multisite() && ! is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
746 + if ( is_network_admin() && is_multisite() && ! $this->plugin->is_network_activated() ) {
671 747 return $links;
672 748 }
673 749
674 750 if ( is_network_admin() ) {
675 - $admin_page_url = add_query_arg( array( 'page' => $this->network->network_settings_page_slug ), network_admin_url( $this->admin_parent_page ) );
751 + $admin_page_url = add_query_arg(
752 + array(
753 + 'page' => $this->network->network_settings_page_slug,
754 + ),
755 + network_admin_url( $this->admin_parent_page )
756 + );
676 757 } else {
677 - $admin_page_url = add_query_arg( array( 'page' => $this->settings_page_slug ), admin_url( $this->admin_parent_page ) );
758 + $admin_page_url = add_query_arg(
759 + array(
760 + 'page' => $this->settings_page_slug,
761 + ),
762 + admin_url( $this->admin_parent_page )
763 + );
678 764 }
679 765
680 766 $links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) );
681 767
682 - $url = add_query_arg(
683 - array(
684 - 'action' => 'wp_stream_uninstall',
685 - 'wp_stream_nonce' => wp_create_nonce( 'stream_nonce' ),
686 - ),
687 - admin_url( 'admin-ajax.php' )
688 - );
768 + if ( ! defined( 'DISALLOW_FILE_MODS' ) || false === DISALLOW_FILE_MODS ) {
769 + $url = add_query_arg(
770 + array(
771 + 'action' => 'wp_stream_uninstall',
772 + 'wp_stream_nonce' => wp_create_nonce( 'stream_nonce' ),
773 + ),
774 + admin_url( 'admin-ajax.php' )
775 + );
689 776
690 - $links[] = sprintf( '<span id="wp_stream_uninstall" class="delete"><a href="%s">%s</a></span>', esc_url( $url ), esc_html__( 'Uninstall', 'stream' ) );
777 + $links[] = sprintf( '<span id="wp_stream_uninstall" class="delete"><a href="%s">%s</a></span>', esc_url( $url ), esc_html__( 'Uninstall', 'stream' ) );
778 + }
691 779
692 780 return $links;
693 781 }
694 782
@@ -698,12 +786,12 @@
698 786 public function render_list_table() {
699 787 $this->list_table->prepare_items();
700 788 ?>
701 789 <div class="wrap">
702 - <h1><?php echo esc_html( get_admin_page_title() ) ?></h1>
703 - <?php $this->list_table->display() ?>
790 + <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
791 + <?php $this->list_table->display(); ?>
704 792 </div>
705 - <?php
793 + <?php
706 794 }
707 795
708 796 /**
709 797 * Render settings page
@@ -715,28 +803,28 @@
715 803 $page_description = apply_filters( 'wp_stream_settings_form_description', '' );
716 804
717 805 $sections = $this->plugin->settings->get_fields();
718 806 $active_tab = wp_stream_filter_input( INPUT_GET, 'tab' );
719 -
720 - wp_enqueue_script( 'wp-stream-settings', $this->plugin->locations['url'] . 'ui/js/settings.js', array( 'jquery' ), $this->plugin->get_version(), true );
807 + $min = wp_stream_min_suffix();
808 + wp_enqueue_script( 'wp-stream-settings', $this->plugin->locations['url'] . 'ui/js/settings.' . $min . 'js', array( 'jquery' ), $this->plugin->get_version(), true );
721 809 ?>
722 810 <div class="wrap">
723 - <h1><?php echo esc_html( get_admin_page_title() ) ?></h1>
811 + <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
724 812
725 813 <?php if ( ! empty( $page_description ) ) : ?>
726 - <p><?php echo esc_html( $page_description ) ?></p>
814 + <p><?php echo esc_html( $page_description ); ?></p>
727 815 <?php endif; ?>
728 816
729 - <?php settings_errors() ?>
817 + <?php settings_errors(); ?>
730 818
731 819 <?php if ( count( $sections ) > 1 ) : ?>
732 820 <h2 class="nav-tab-wrapper">
733 - <?php $i = 0 ?>
821 + <?php $i = 0; ?>
734 822 <?php foreach ( $sections as $section => $data ) : ?>
735 - <?php $i ++ ?>
736 - <?php $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section ) ?>
737 - <a href="<?php echo esc_url( add_query_arg( 'tab', $section ) ) ?>" class="nav-tab<?php if ( $is_active ) { echo esc_attr( ' nav-tab-active' ); } ?>">
738 - <?php echo esc_html( $data['title'] ) ?>
823 + <?php $i++; ?>
824 + <?php $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section ); ?>
825 + <a href="<?php echo esc_url( add_query_arg( 'tab', $section ) ); ?>" class="nav-tab <?php echo $is_active ? esc_attr( ' nav-tab-active' ) : ''; ?>">
826 + <?php echo esc_html( $data['title'] ); ?>
739 827 </a>
740 828 <?php endforeach; ?>
741 829 </h2>
742 830 <?php endif; ?>
@@ -741,29 +829,29 @@
741 829 </h2>
742 830 <?php endif; ?>
743 831
744 832 <div class="nav-tab-content" id="tab-content-settings">
745 - <form method="post" action="<?php echo esc_attr( $form_action ) ?>" enctype="multipart/form-data">
833 + <form method="post" action="<?php echo esc_attr( $form_action ); ?>" enctype="multipart/form-data">
746 834 <div class="settings-sections">
747 - <?php
748 - $i = 0;
749 - foreach ( $sections as $section => $data ) {
750 - $i++;
835 + <?php
836 + $i = 0;
837 + foreach ( $sections as $section => $data ) {
838 + $i++;
751 839
752 - $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section );
840 + $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section );
753 841
754 - if ( $is_active ) {
755 - settings_fields( $option_key );
756 - do_settings_sections( $option_key );
757 - }
758 - }
759 - ?>
842 + if ( $is_active ) {
843 + settings_fields( $option_key );
844 + do_settings_sections( $option_key );
845 + }
846 + }
847 + ?>
760 848 </div>
761 - <?php submit_button() ?>
849 + <?php submit_button(); ?>
762 850 </form>
763 851 </div>
764 852 </div>
765 - <?php
853 + <?php
766 854 }
767 855
768 856 /**
769 857 * Instantiate the list table
@@ -768,9 +856,14 @@
768 856 /**
769 857 * Instantiate the list table
770 858 */
771 859 public function register_list_table() {
772 - $this->list_table = new List_Table( $this->plugin, array( 'screen' => $this->screen_id['main'] ) );
860 + $this->list_table = new List_Table(
861 + $this->plugin,
862 + array(
863 + 'screen' => $this->screen_id['main'],
864 + )
865 + );
773 866 }
774 867
775 868 /**
776 869 * Check if a particular role has access
@@ -868,9 +961,13 @@
868 961
869 962 switch ( wp_stream_filter_input( INPUT_GET, 'filter' ) ) {
870 963 case 'user_id':
871 964 $users = array_merge(
872 - array( 0 => (object) array( 'display_name' => 'WP-CLI' ) ),
965 + array(
966 + 0 => (object) array(
967 + 'display_name' => 'WP-CLI',
968 + ),
969 + ),
873 970 get_users()
874 971 );
875 972
876 973 $search = wp_stream_filter_input( INPUT_GET, 'q' );
@@ -877,9 +974,9 @@
877 974 if ( $search ) {
878 975 // `search` arg for get_users() is not enough
879 976 $users = array_filter(
880 977 $users,
881 - function( $user ) use ( $search ) {
978 + function ( $user ) use ( $search ) {
882 979 return false !== mb_strpos( mb_strtolower( $user->display_name ), mb_strtolower( $search ) );
883 980 }
884 981 );
885 982 }
@@ -907,13 +1004,13 @@
907 1004 foreach ( $authors as $user_id => $args ) {
908 1005 $author = new Author( $args->ID );
909 1006
910 1007 $authors_records[ $user_id ] = array(
911 - 'text' => $author->get_display_name(),
912 - 'id' => $author->id,
913 - 'label' => $author->get_display_name(),
914 - 'icon' => $author->get_avatar_src( 32 ),
915 - 'title' => '',
1008 + 'text' => $author->get_display_name(),
1009 + 'id' => $author->id,
1010 + 'label' => $author->get_display_name(),
1011 + 'icon' => $author->get_avatar_src( 32 ),
1012 + 'title' => '',
916 1013 );
917 1014 }
918 1015
919 1016 return $authors_records;
@@ -921,18 +1018,19 @@
921 1018
922 1019 /**
923 1020 * Get user meta in a way that is also safe for VIP
924 1021 *
925 - * @param int $user_id
1022 + * @param int $user_id
926 1023 * @param string $meta_key
927 - * @param bool $single (optional)
1024 + * @param bool $single (optional)
928 1025 *
929 1026 * @return mixed
930 1027 */
931 - function get_user_meta( $user_id, $meta_key, $single = true ) {
1028 + public function get_user_meta( $user_id, $meta_key, $single = true ) {
932 1029 if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
933 1030 return get_user_attribute( $user_id, $meta_key );
934 1031 }
1032 +
935 1033 return get_user_meta( $user_id, $meta_key, $single );
936 1034 }
937 1035
938 1036 /**
@@ -937,19 +1035,20 @@
937 1035
938 1036 /**
939 1037 * Update user meta in a way that is also safe for VIP
940 1038 *
941 - * @param int $user_id
1039 + * @param int $user_id
942 1040 * @param string $meta_key
943 1041 * @param mixed $meta_value
944 - * @param mixed $prev_value (optional)
1042 + * @param mixed $prev_value (optional)
945 1043 *
946 1044 * @return int|bool
947 1045 */
948 - function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
1046 + public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
949 1047 if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
950 1048 return update_user_attribute( $user_id, $meta_key, $meta_value );
951 1049 }
1050 +
952 1051 return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
953 1052 }
954 1053
955 1054 /**
@@ -954,17 +1053,18 @@
954 1053
955 1054 /**
956 1055 * Delete user meta in a way that is also safe for VIP
957 1056 *
958 - * @param int $user_id
1057 + * @param int $user_id
959 1058 * @param string $meta_key
960 - * @param mixed $meta_value (optional)
1059 + * @param mixed $meta_value (optional)
961 1060 *
962 1061 * @return bool
963 1062 */
964 - function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
1063 + public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
965 1064 if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
966 1065 return delete_user_attribute( $user_id, $meta_key, $meta_value );
967 1066 }
1067 +
968 1068 return delete_user_meta( $user_id, $meta_key, $meta_value );
969 1069 }
970 1070 }