From 253541556eecc85026ee63045a03ac4b8f556f4f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 2 Oct 2017 22:02:47 +0000 Subject: [PATCH] Widgets: Pass `$instance` to widget argument filters: * `widget_archives_dropdown_args` * `widget_archives_args` * `widget_categories_dropdown_args` * `widget_categories_args` * `widget_meta_poweredby` * `widget_pages_args` * `widget_comments_args` * `widget_posts_args` * `widget_tag_cloud_args` See [33971] for `widget_links_args` and [34662] for `widget_nav_menu_args`. Props Takahashi_Fumiki. Fixes #38017. Built from https://develop.svn.wordpress.org/trunk@41685 git-svn-id: http://core.svn.wordpress.org/trunk@41519 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/widgets/class-wp-widget-archives.php | 12 ++++++++---- wp-includes/widgets/class-wp-widget-categories.php | 8 ++++++-- wp-includes/widgets/class-wp-widget-links.php | 2 +- wp-includes/widgets/class-wp-widget-meta.php | 4 +++- wp-includes/widgets/class-wp-widget-pages.php | 8 +++++--- .../widgets/class-wp-widget-recent-comments.php | 4 +++- wp-includes/widgets/class-wp-widget-recent-posts.php | 6 ++++-- wp-includes/widgets/class-wp-widget-tag-cloud.php | 6 ++++-- 9 files changed, 35 insertions(+), 17 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 14a4384c5b..88a90720d0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41684'; +$wp_version = '4.9-alpha-41685'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-archives.php b/wp-includes/widgets/class-wp-widget-archives.php index 632193d0dd..08c693d613 100644 --- a/wp-includes/widgets/class-wp-widget-archives.php +++ b/wp-includes/widgets/class-wp-widget-archives.php @@ -61,16 +61,18 @@ class WP_Widget_Archives extends WP_Widget { * Filters the arguments for the Archives widget drop-down. * * @since 2.8.0 + * @since 4.9.0 Added the `$instance` parameter. * * @see wp_get_archives() * - * @param array $args An array of Archives widget drop-down arguments. + * @param array $args An array of Archives widget drop-down arguments. + * @param array $instance Settings for the current Archives widget instance. */ $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => $c - ) ); + ), $instance ); switch ( $dropdown_args['type'] ) { case 'yearly': @@ -102,15 +104,17 @@ class WP_Widget_Archives extends WP_Widget { * Filters the arguments for the Archives widget. * * @since 2.8.0 + * @since 4.9.0 Added the `$instance` parameter. * * @see wp_get_archives() * - * @param array $args An array of Archives option arguments. + * @param array $args An array of Archives option arguments. + * @param array $instance Array of settings for the current widget. */ wp_get_archives( apply_filters( 'widget_archives_args', array( 'type' => 'monthly', 'show_post_count' => $c - ) ) ); + ), $instance ) ); ?> '; ?> @@ -111,10 +113,12 @@ class WP_Widget_Categories extends WP_Widget { * Filters the arguments for the Categories widget. * * @since 2.8.0 + * @since 4.9.0 Added the `$instance` parameter. * * @param array $cat_args An array of Categories widget options. + * @param array $instance Array of settings for the current widget. */ - wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) ); + wp_list_categories( apply_filters( 'widget_categories_args', $cat_args, $instance ) ); ?> %s', esc_url( __( 'https://wordpress.org/' ) ), esc_attr__( 'Powered by WordPress, state-of-the-art semantic personal publishing platform.' ), _x( 'WordPress.org', 'meta widget link text' ) - ) ); + ), $instance ); wp_meta(); ?> diff --git a/wp-includes/widgets/class-wp-widget-pages.php b/wp-includes/widgets/class-wp-widget-pages.php index d584e029ab..8f271495f1 100644 --- a/wp-includes/widgets/class-wp-widget-pages.php +++ b/wp-includes/widgets/class-wp-widget-pages.php @@ -47,7 +47,7 @@ class WP_Widget_Pages extends WP_Widget { * @since 2.6.0 * * @param string $title The widget title. Default 'Pages'. - * @param array $instance An array of the widget's settings. + * @param array $instance Array of settings for the current widget. * @param mixed $id_base The widget ID. */ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base ); @@ -62,17 +62,19 @@ class WP_Widget_Pages extends WP_Widget { * Filters the arguments for the Pages widget. * * @since 2.8.0 + * @since 4.9.0 Added the `$instance` parameter. * * @see wp_list_pages() * - * @param array $args An array of arguments to retrieve the pages list. + * @param array $args An array of arguments to retrieve the pages list. + * @param array $instance Array of settings for the current widget. */ $out = wp_list_pages( apply_filters( 'widget_pages_args', array( 'title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude - ) ) ); + ), $instance ) ); if ( ! empty( $out ) ) { echo $args['before_widget']; diff --git a/wp-includes/widgets/class-wp-widget-recent-comments.php b/wp-includes/widgets/class-wp-widget-recent-comments.php index 484d0e7d54..a5c9b1d3bd 100644 --- a/wp-includes/widgets/class-wp-widget-recent-comments.php +++ b/wp-includes/widgets/class-wp-widget-recent-comments.php @@ -85,16 +85,18 @@ class WP_Widget_Recent_Comments extends WP_Widget { * Filters the arguments for the Recent Comments widget. * * @since 3.4.0 + * @since 4.9.0 Added the `$instance` parameter. * * @see WP_Comment_Query::query() for information on accepted arguments. * * @param array $comment_args An array of arguments used to retrieve the recent comments. + * @param array $instance Array of settings for the current widget. */ $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' - ) ) ); + ), $instance ) ); $output .= $args['before_widget']; if ( $title ) { diff --git a/wp-includes/widgets/class-wp-widget-recent-posts.php b/wp-includes/widgets/class-wp-widget-recent-posts.php index 2c111f931d..c8d19055b4 100644 --- a/wp-includes/widgets/class-wp-widget-recent-posts.php +++ b/wp-includes/widgets/class-wp-widget-recent-posts.php @@ -59,17 +59,19 @@ class WP_Widget_Recent_Posts extends WP_Widget { * Filters the arguments for the Recent Posts widget. * * @since 3.4.0 + * @since 4.9.0 Added the `$instance` parameter. * * @see WP_Query::get_posts() * - * @param array $args An array of arguments used to retrieve the recent posts. + * @param array $args An array of arguments used to retrieve the recent posts. + * @param array $instance Array of settings for the current widget. */ $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true - ) ) ); + ), $instance ) ); if ($r->have_posts()) : ?> diff --git a/wp-includes/widgets/class-wp-widget-tag-cloud.php b/wp-includes/widgets/class-wp-widget-tag-cloud.php index 9e332e5ac6..765d67a7e8 100644 --- a/wp-includes/widgets/class-wp-widget-tag-cloud.php +++ b/wp-includes/widgets/class-wp-widget-tag-cloud.php @@ -58,16 +58,18 @@ class WP_Widget_Tag_Cloud extends WP_Widget { * * @since 2.8.0 * @since 3.0.0 Added taxonomy drop-down. + * @since 4.9.0 Added the `$instance` parameter. * * @see wp_tag_cloud() * - * @param array $args Args used for the tag cloud widget. + * @param array $args Args used for the tag cloud widget. + * @param array $instance Array of settings for the current widget. */ $tag_cloud = wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 'taxonomy' => $current_taxonomy, 'echo' => false, 'show_count' => $show_count, - ) ) ); + ), $instance ) ); if ( empty( $tag_cloud ) ) { return;