WordPress.org

Ready to get started?Download WordPress

Ideas

Passing Arguments to Widget

  1. kenneth.howe
    Member

    It'd be great to be able to pass arguments to a widget. So, I already did it. In wp-includes/widgets.php:

    Replace the WP_Widget_Factory->register function:

    function register($widget_class, $args) {
    		$this->widgets[$widget_class] = & new $widget_class($args);
    	}

    Replace the register_widget function (around line 428):

    function register_widget($widget_class, $args) {
    	global $wp_widget_factory;
    
    	$wp_widget_factory->register($widget_class, $args);
    }

    It'd be great if WordPress added this to the abilities so we can update our installation as new releases are added.

    Posted: 2 years ago #
  2. Ipstenu (Mika Epstein)
    Administrator

    To what end are you thinking of using the arguments? I'm curious to see your use case.

    Posted: 2 years ago #
  3. Gundars
    Member

    Clever, but I would like to see example in code as well.

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    2 Votes
  • Status

    This idea is under consideration