/** * Function to update sk into the new widget. */ function skLegacy_updateWidget() { $options = get_option('widget_sk'); $add = 1; $data = array('title' => $options['title'], 'items' => $options['items'], 'rss' => $options['rss']); //Update the widget data update_option('sk_options', $options); // old format, conver if single widget $settings = wp_convert_widget_settings('sk', 'widget_sk', $options); //Update the widgets in the sidebar $pos = 0; //The position where the widget is $sidebars_widgets = get_option('sidebars_widgets'); foreach ((array) $sidebars_widgets as $index => $sidebar) { if (is_array($sidebar)) { $count = 0; //New counter foreach ($sidebar as $i => $name) { //Check if the widget has the name from the old one if ($name == 'schreikasten') { //We found something, set the data $sb_pos = $index; $pos = $index; $changed = true; } $count++; } //If we found the widget, move all the widgets after the one where we are //searching, then add the new widgets if ($changed) { $sidebar = $sidebars_widgets[$sb_pos]; //How many widgets do we have in this sidebar? $size = count($sidebar); //Add from end to begin $aux = 0; $sidebar_aux = array(); for ($i = 0; $i < $size; $i++) { if ($i == $pos) { for ($j = 2; $j < $add + 2; $j++) { $sidebar_aux[$count] = "sk-{$j}"; $count++; } } else { $sidebar_aux[$count] = $sidebar[$i]; $count++; } } //Update the sidebars_widgets $sidebars_widgets[$sb_pos] = $sidebar_aux; update_option('sidebars_widgets', $sidebars_widgets); $changed = false; } } } }
function get_settings() { $settings = get_option($this->option_name); if (false === $settings && isset($this->alt_option_name)) { $settings = get_option($this->alt_option_name); } if (!is_array($settings)) { $settings = array(); } if (!empty($settings) && !array_key_exists('_multiwidget', $settings)) { // old format, convert if single widget $settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings); } unset($settings['_multiwidget'], $settings['__i__']); return $settings; }
/** * Get the settings for all instances of the widget class. * * @since 2.8.0 * @access public * * @return array Multi-dimensional array of widget instance settings. */ public function get_settings() { $settings = get_option($this->option_name); if (false === $settings && isset($this->alt_option_name)) { $settings = get_option($this->alt_option_name); } if (!is_array($settings) && !($settings instanceof ArrayObject || $settings instanceof ArrayIterator)) { $settings = array(); } if (!empty($settings) && !isset($settings['_multiwidget'])) { // Old format, convert if single widget. $settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings); } unset($settings['_multiwidget'], $settings['__i__']); return $settings; }
/** * Retrieves the settings for all instances of the widget class. * * @since 2.8.0 * @access public * * @return array Multi-dimensional array of widget instance settings. */ public function get_settings() { $settings = get_option($this->option_name); if (false === $settings) { if (isset($this->alt_option_name)) { $settings = get_option($this->alt_option_name); } else { // Save an option so it can be autoloaded next time. $this->save_settings(array()); } } if (!is_array($settings) && !($settings instanceof ArrayObject || $settings instanceof ArrayIterator)) { $settings = array(); } if (!empty($settings) && !isset($settings['_multiwidget'])) { // Old format, convert if single widget. $settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings); } unset($settings['_multiwidget'], $settings['__i__']); return $settings; }
function simple_section_nav_activate() { if (get_option('ssn_sortby') === false) { return false; } //if not upgrading, leave $show_all = get_option('ssn_show_all') ? 1 : 0; $exclude = str_replace(" ", "", get_option('ssn_exclude')); $hide_on_excluded = get_option('ssn_hide_on_excluded') ? 1 : 0; $show_on_home = get_option('ssn_show_on_home') ? 1 : 0; $show_empty = get_option('ssn_show_empty') ? 1 : 0; $a_heading = get_option('ssn_a_heading') ? 1 : 0; $settings = array('show_all' => $show_all, 'exclude' => $exclude, 'hide_on_excluded' => $hide_on_excluded, 'show_on_home' => $show_on_home, 'show_empty' => $show_empty, 'sort_by' => get_option('ssn_sortby'), 'a_heading' => $a_heading); wp_convert_widget_settings('simple-section-nav', 'widget_simple-section-nav', $settings); //delete old settings ... done supporting 1.x delete_option('ssn_show_all'); delete_option('ssn_exclude'); delete_option('ssn_hide_on_excluded'); delete_option('ssn_show_on_home'); delete_option('ssn_show_empty'); delete_option('ssn_sortby'); delete_option('ssn_a_heading'); }