/** * Function for handling the widget control in admin panel * * @param array $instance * * @return void|string * @since 1.0 */ public function form($instance) { $authors = $this->plugin->getUsers(); $terms = $this->plugin->getTerms(); // Create a lookup table with all the terms indexed by their ID $terms_by_id = array(); foreach ($terms as $taxonomyTerms) { foreach ($taxonomyTerms as $term) { $terms_by_id[$term->term_id] = $term; } } // Create a lookup table with all the authors indexed by their ID $authors_by_id = array(); foreach ($authors as $author) { $authors_by_id[$author->ID] = $author; } $data = array('dataConfig' => new UTCW_DataConfig($instance, $this->plugin), 'renderConfig' => new UTCW_RenderConfig($instance, $this->plugin), 'configurations' => $this->plugin->getConfigurations(), 'available_post_types' => $this->plugin->getAllowedPostTypes(), 'available_taxonomies' => $this->plugin->getAllowedTaxonomiesObjects(), 'authors' => $authors, 'terms' => $terms, 'authors_by_id' => $authors_by_id, 'terms_by_id' => $terms_by_id); $this->render('settings', $data); }
/** * Creates a new instance of the class and adds all the options * * @param array $input * @param UTCW_Plugin $plugin * * @since 2.3 */ public function __construct(array $input, UTCW_Plugin $plugin) { $this->addOption('strategy', 'class', array('classMap' => array('popularity' => 'UTCW_PopularityStrategy', 'random' => 'UTCW_RandomStrategy', 'creation' => 'UTCW_CreationTimeStrategy', 'current_list' => 'UTCW_CurrentListStrategy'), 'baseClass' => 'UTCW_SelectionStrategy', 'default' => 'popularity', 'factory' => array($this, 'strategyFactory'))); $this->addOption('order', 'set', array('values' => array('name', 'random', 'slug', 'id', 'color', 'count'))); $this->addOption('tags_list_type', 'set', array('values' => array('exclude', 'include'))); $this->addOption('color', 'set', array('values' => array('none', 'random', 'set', 'span'))); $this->addOption('color_span_to', 'color', array('default' => '')); $this->addOption('color_span_from', 'color', array('default' => '')); $this->addOption('color_set', 'array', array('type' => 'color')); $this->addOption('taxonomy', 'array', array('type' => 'set', 'typeOptions' => array('values' => $plugin->getAllowedTaxonomies()), 'default' => array('post_tag'))); $this->addOption('post_type', 'array', array('type' => 'set', 'typeOptions' => array('values' => $plugin->getAllowedPostTypes()), 'default' => array('post'))); $this->addOption('authors', 'array', array('type' => 'integer')); $this->addOption('tags_list', 'array', array('type' => 'integer')); $this->addOption('post_term', 'array', array('type' => 'integer')); $this->addOption('size_from', 'measurement', array('default' => '10px')); $this->addOption('size_to', 'measurement', array('default' => '30px')); $this->addOption('max', 'integer', array('default' => 45, 'min' => 1)); $this->addOption('minimum', 'integer', array('default' => 1)); $this->addOption('days_old', 'integer'); $this->addOption('reverse', 'boolean'); $this->addOption('case_sensitive', 'boolean'); $this->addOption('post_term_query_var', 'boolean'); $this->plugin = $plugin; parent::__construct($input, $plugin); $this->checkSizes(); }