Support » Plugins » Error using add_filter(‘pre_option_widget_text’, ‘function’)

  • Resolved marc_M


    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

Viewing 1 replies (of 1 total)
  • 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

Viewing 1 replies (of 1 total)
  • The topic ‘Error using add_filter(‘pre_option_widget_text’, ‘function’)’ is closed to new replies.