Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jetpack Authors Widget Filter #13167

Merged
merged 2 commits into from Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6521,6 +6521,7 @@ public function deprecated_hooks() {
'atd_http_post_timeout' => null,
'atd_http_post_error' => null,
'atd_service_domain' => null,
'jetpack_widget_authors_exclude' => 'jetpack_widget_authors_params',
);

// This is a silly loop depth. Better way?
Expand Down
23 changes: 19 additions & 4 deletions modules/widgets/authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,41 @@ public function widget( $args, $instance ) {
// We need to query at least one post to determine whether an author has written any posts or not
$query_number = max( $instance['number'], 1 );

$default_excluded_authors = array();
/**
* Filter authors from the Widget Authors widget.
*
* @module widgets
*
* @deprecated 7.7.0 Use jetpack_widget_authors_params instead.
*
* @since 4.5.0
*
* @param array $default_excluded_authors Array of user ID's that will be excluded
*/
$excluded_authors = apply_filters( 'jetpack_widget_authors_exclude', $default_excluded_authors );
$excluded_authors = apply_filters( 'jetpack_widget_authors_exclude', array() );

$authors = get_users(
/**
* Filter the parameters of `get_users` call in the Widget Authors widget.
*
* See the following for `get_users` default arguments:
* https://codex.wordpress.org/Function_Reference/get_users
*
* @module widgets
*
* @since 7.7.0
*
* @param array $get_author_params Array of params used in `get_user`
*/
$get_author_params = apply_filters(
'jetpack_widget_authors_params',
array(
'fields' => 'all',
jeherve marked this conversation as resolved.
Show resolved Hide resolved
'who' => 'authors',
'exclude' => (array) $excluded_authors,
)
);

$authors = get_users( $get_author_params );

echo $args['before_widget'];
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
Expand Down