PHP code example of philipnewcomer / widget-output-filters

1. Go to this page and download the library: Download philipnewcomer/widget-output-filters library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

philipnewcomer / widget-output-filters example snippets


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 );