/** * * Tribe_Widget_Builder Constructor * requires Tribe_WP_Widget_Factory to extend the register method to pass args through * */ function Tribe_Widget_Builder_Display($param = null) { extract($param); $this->token = $token; // new instance of the widget builder class $this->widget_builder = Tribe_Widget_Builder::get_instance(); // blank out the widget description so that it doesn't duplicate the widget title $widget_description = empty($widget_description) ? ' ' : $widget_description; // override default post title by filter for customization $title = $title != '' ? apply_filters('tribe_widget_builder_title', $title) : $title; // allow for class overrides $classname = apply_filters('tribe_widget_builder_classes', array('widget_' . $this->token . '_' . $ID)); $widget_ops = array('classname' => implode(" ", $classname), 'description' => __($widget_description, 'widget-builder'), 'data' => $param); $control_ops = array('width' => 200, 'height' => 200, 'id_base' => 'widget_' . $this->token . '_' . $ID); parent::__construct('widget_' . $this->token . '_' . $ID, __($title, 'widget-builder'), $widget_ops, $control_ops); }
/** * Get (and instantiate, if necessary) the instance of the class * * @static * @return Tribe_Widget_Builder */ public static function get_instance() { if (!is_a(self::$instance, __CLASS__)) { self::$instance = new self(); } return self::$instance; }
<?php // this is PHP v5.3+ safe add_action(is_multisite() ? 'wp_network_dashboard_setup' : 'wp_dashboard_setup', function ($widget) use($widget) { wp_add_dashboard_widget($widget['token'] . '-' . $widget['ID'], $widget['title'], function ($widget) use($widget) { // apply filters $content = apply_filters('the_content', empty($widget['content']) ? '' : $widget['content']); $content = str_replace(']]>', ']]>', $content); // get template hierarchy include Tribe_Widget_Builder::get_template_hierarchy('widget_dashboard'); }); });