/** * Constructor. * */ public function __construct($manager, $id, $args = array()) { //let the parent educate us parent::__construct($manager, $id, $args); $this->contexts = hu_get_contexts_list(); $_default_locations = hu_get_builtin_widget_zones_location(); //generates the locations for json $locations = array(); foreach ($_default_locations as $_id => $data) { $_k = key($data); $locations[$_k] = $data[$_k]; } $this->locations = $locations; //generates the default widget zone for json $default_zones = array(); foreach (hu_get_default_widget_zones() as $_zone_id => $_data) { //get the default location $_loc = isset($_default_locations[$_zone_id]) ? key($_default_locations[$_zone_id]) : ''; $default_zones[] = array('id' => $_data['id'], 'title' => $_data['name'], 'contexts' => array('_all_'), 'locations' => array($_loc), 'is_builtin' => true, 'description' => $_data['description']); } $this->default_zones = $default_zones; //print the pre add view content add_action('customize_controls_print_footer_scripts', array($this, 'hu_print_pre_add_view_template'), 1); //print template for built-in models like primary, secondary, footer-1, etc... add_action('customize_controls_print_footer_scripts', array($this, 'hu_print_built_in_templates'), 1); }
function hu_get_old_contexts($_zone_id, $__options) { $contexts = array(); $_old_sd_options = array('s1-home', 's2-home', 's1-single', 's2-single', 's1-archive', 's2-archive', 's1-archive-category', 's2-archive-category', 's1-search', 's2-search', 's1-404', 's2-404', 's1-page', 's2-page'); $_default_contexts = array(); //populates the map with the contexts foreach (hu_get_contexts_list() as $c => $title) { if ('_all_' == $c) { continue; } $_default_contexts[] = $c; } //the following zones are assigned to fixed contexts //user will be able to change this with the new options //edge case : a user who had assigned the footer-1 to the s1 location on home will loose this setting //=> the fix is to create a new zone, and select the home context + assign it to the s1 (right sidebar) location $_fixed_contexts = array('primary', 'secondary', 'header-ads', 'footer-ads', 'footer-1', 'footer-2', 'footer-3', 'footer-4'); if (in_array($_zone_id, $_fixed_contexts)) { $contexts = $_default_contexts; return $contexts; } foreach ($_old_sd_options as $opt_name) { //does the option exists ? if (!array_key_exists($opt_name, $__options)) { continue; } //if exists, grab its value $value = $__options[$opt_name]; if ($value != $_zone_id) { continue; } //we have a match, extract the context if not already there $con = substr($opt_name, 3); if (!in_array($con, $contexts)) { $contexts[] = $con; } } return $contexts; }