PHPackages                             philipnewcomer/widget-output-filters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. philipnewcomer/widget-output-filters

ActiveWordpress-plugin[Search &amp; Filtering](/categories/search)

philipnewcomer/widget-output-filters
====================================

A library which enables developers to filter the output of any WordPress widget.

1.2.0(9y ago)11265GPL-2.0+PHP

Since Sep 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/philipnewcomer/widget-output-filters)[ Packagist](https://packagist.org/packages/philipnewcomer/widget-output-filters)[ Docs](https://philipnewcomer.net/wordpress-plugins/widget-output-filters/)[ RSS](/packages/philipnewcomer-widget-output-filters/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Widget Output Filters
=====================

[](#widget-output-filters)

*Enables developers to filter the output of any WordPress widget.*

Sometimes developers need to filter the output of a widget that does not have its own output filter built-in. This plugin provides a filter which will allow developers to filter any widget's output, regardless of whether it has that capability natively or not.

This plugin was inspired by a similar filter in the [Widget Logic](https://wordpress.org/plugins/widget-logic/) plugin, and essentially duplicates that functionality, but with more flexibility.

Usage
-----

[](#usage)

This plugin provides a `widget_output` filter, which will be passed four parameters:

1. The complete HTML output of the widget
2. The widget type, or *base* ID; i.e. `meta` or `recent-posts`
3. The full widget ID; i.e. `meta-2` or `recent-posts-5`
4. The ID of the current sidebar; i.e. `sidebar-1`

### Example

[](#example)

```
function filter_widgets( $widget_output, $widget_type, $widget_id, $sidebar_id ) {

	if ( 'my_widget' == $widget_type ) {
		$widget_output = str_replace( 'something-to-find', 'something-to-replace', $widget_output );
	}

	return $widget_output;
}
add_filter( 'widget_output', 'filter_widgets', 10, 4 );
```

FAQ
---

[](#faq)

**Can't I just use output buffering in my sidebar.php template file, and modify widget output there?**
Yes, but that method does not work in the WordPress Theme Customizer, or with widgets used in locations other than your output-buffered widget area. It also requires that widget area output buffering be built into the theme, and does not provide an easy way to target only one specific widget or widget type. This plugin provides widget type and widget ID parameters to your filter function, it works in the Theme Customizer, and does not require any support from the theme.

**How is this plugin better than the widget\_content filter already existing in the Widget Logic plugin?**
This plugin provides the widget type (or *base* ID) in its filter, in addition to the unique widget ID. This makes it possible to target all widgets of a specific type, without resorting to complicated [regular expressions](http://en.wikipedia.org/wiki/Regular_expression). This plugin also provides the ID of the sidebar that the current widget is in, allowing you to target only widgets in a specific sidebar. With the Widget Logic filter, a developer has access only to the individual widget ID in his filter function, making it harder to target all widgets of a specific type, or widgets in a specific sidebar.

**If I am already using the Widget Logic plugin to control the visibility of my widgets, is this plugin compatible with Widget Logic's widget\_content filter?**
Yes, this plugin coexists nicely with the Widget Logic plugin. However, if you are already using Widget Logic to manage the visibility of your widgets, the only reason you would need to use this plugin would be if you require the additional flexibility that this plugin provides. Otherwise Widget Logic's `widget_content` filter will do the job just as well.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3529d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12f960edc40ea879fb20f1e250fcf74f951f231796423782a8aefd65fba4e5eb?d=identicon)[philipnewcomer](/maintainers/philipnewcomer)

---

Top Contributors

[![philipnewcomer](https://avatars.githubusercontent.com/u/1446874?v=4)](https://github.com/philipnewcomer "philipnewcomer (22 commits)")

---

Tags

wordpresswordpress-developmentwordpress-php-librarywordpress-widgetwordpresshtmlfilterwidgetwidgetsfiltersoutput

### Embed Badge

![Health badge](/badges/philipnewcomer-widget-output-filters/health.svg)

```
[![Health](https://phpackages.com/badges/philipnewcomer-widget-output-filters/health.svg)](https://phpackages.com/packages/philipnewcomer-widget-output-filters)
```

###  Alternatives

[millat/laravel-hooks

The WordPress filter, action system in Laravel

5715.1k](/packages/millat-laravel-hooks)[htmlawed/htmlawed

Official htmLawed PHP library for HTML filtering

401.1M9](/packages/htmlawed-htmlawed)[lincanbin/white-html-filter

A lightweight php-based HTML tag and attribute whitelist filter.

1215.1k1](/packages/lincanbin-white-html-filter)[mitogh/katana

Filters to control where the size of images are generated.

204.4k](/packages/mitogh-katana)[bakame/html-table

convert html table into a PHP data structure

113.0k](/packages/bakame-html-table)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
