Automattic / Automattic/jetpack

Add filters/actions to customize widget visibility

Open
#7,800 3 comments 0 reactions 0 assignees View on GitHub
[Feature] Widget Visibility [Pri] Normal Enhancement
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

See previous #167 #434 #6371.

It would be very helpful for us to be able to customize the list of criteria. Many of the previous proposals have been very broad and have been rejected.

If we could filter `widget_conditions_data`, that would be a good start:

Right now, we have:

wp_localize_script( 'widget-conditions', 'widget_conditions_data', $widget_conditions_data );

The easiest change would be to filter the output:

$widget_conditions_data = apply_filters( 'jetpack_widget_visibility_conditions_data',$ widget_conditions_data );
wp_localize_script( 'widget-conditions', 'widget_conditions_data', $widget_conditions_data );

For more control, it would be good to be able to include/exclude both (Category, Author, Tag, Date, Page, Taxonomy) and the values for each key.

Contributor guide

Open the contributing guide

Research direction

Start by locating the `wp_localize_script` call for `widget-conditions` and tracing how `widget_conditions_data` is assembled. Compare the proposed filter with the requested category, author, tag, date, page, and taxonomy controls; done means the visibility criteria can be customized through the supported extension points.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.