[resolved] Error using add_filter('pre_option_widget_text', 'function') (2 posts)

  1. marc_M
    Posted 7 years ago #

    i am trying to add the following filter in a plugin
    add_filter('pre_option_widget_text', 'some_function');

    this causes the following error to appear at the top of the admin and site.

    Warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/wordpress-test/wp-includes/widgets.php on line 1044

    does anyone have an example of using this filter or can provide any help? Thanks

  2. marc_M
    Posted 7 years ago #

    solved... somewhat.

    my function was:

    function some_function($content) {
       return "filtered the widget text";
       //var_dump($content); die();

    commented out the return and used var_dump showed that $content was a bool. Not what i was expecting as the widget_text option.

    looking in wp code (wp-includes/widgets.php) i saw a direct filter for 'widget_text' that looks like it should work.

    my goal is to filter the widgets text before it is written to the DB and again before display to screen. If anyone has an example or knows other/better filters to use, let me know. Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic