function arras_options_upgrade() { // If we've already done this, bail if (arras_get_option('updated')) { return; } $new_options = array(); $settings = arras_get_settings_data(); // Load our Arras 3 default settings foreach ($settings as $key => $value) { $new_options[$key] = $value[0]; } // See if we have any old options, $old_options = maybe_unserialize(get_option('arras_options')); if ('object' == gettype($old_options)) { // Arras 1.x stored tapestry info in a second place in the options table $old_tapestry_default = maybe_unserialize(get_option('arras_tapestry_default')); // Retrieve the old defaults into an array foreach ($old_options->defaults as $key => $value) { $new_options[$key] = $value; } // Now get the non-default settings (and overwrite the defaults for those that have been set) unset($old_options->defaults); // we're done with those foreach ($old_options as $key => $value) { $new_options[$key] = $value; } // Add the loose settings, too! if (is_array($old_tapestry_default)) { $new_options['nodes_per_row'] = $old_tapestry_default['nodes']; $new_options['nodes_excerpt'] = $old_tapestry_default['excerpt']; } // Check for renamed settings $new_names = array('logo' => 'site_logo', 'header_color' => 'header_background_color', 'facebook_profile' => 'facebook', 'twitter_username' => 'twitter', 'gplus_profile' => 'google', 'flickr_profile' => 'flickr', 'youtube_profile' => 'youtube'); foreach ($new_names as $old_name => $new_name) { if (array_key_exists($old_name, $new_options) && !empty($new_options[$old_name])) { $new_options[$new_name] = $new_options[$old_name]; } } } // One last pass to clean things up foreach ($new_options as $key => $value) { if (!array_key_exists($key, $settings)) { unset($new_options[$key]); } } // Write the translated options back to the database as Arras 3 options $new_options['updated'] = true; update_option('arras-options', $new_options); }
$panels = apply_filters('arras_customizer_panels', $panels); foreach ($panels as $id => $args) { $wp_customize->add_panel($id, array('title' => $args[0], 'description' => $args[1], 'active_callback' => $args[2], 'priority' => $args[3])); } /** * Array for adding custom sections. * 'section-id' => array( 'panel-id', 'title', 'description', 'active_callback', priority ) * @var array */ $sections = array('post-meta' => array('', __('Post Display', 'arras'), __('Options for displaying meta-data on single posts.', 'arras'), 35), 'social' => array('', __('Social Media Links', 'arras'), '', 100), 'duplicate-posts' => array('homepage', __('Duplicate Posts', 'arras'), '', 10), 'slideshow' => array('homepage', __('Slideshow', 'arras'), '', 20), 'featured-1' => array('homepage', __('Featured #1', 'arras'), '', 20), 'featured-2' => array('homepage', __('Featured #2', 'arras'), '', 20), 'news' => array('homepage', __('News', 'arras'), '', 20)); $sections = apply_filters('arras_customizer_sections', $sections); foreach ($sections as $id => $args) { $wp_customize->add_section($id, array('panel' => $args[0], 'title' => $args[1], 'description' => $args[2], 'priority' => $args[3])); } // Generate Settings Objects $settings = arras_get_settings_data(); foreach ($settings as $id => $args) { $wp_customize->add_setting('arras-options[' . $id . ']', array('default' => $args[0], 'type' => $args[1], 'sanitize_callback' => $args[2])); } // Colors Settings & Controls $wp_customize->add_setting('color_scheme', array('default' => 'default', 'sanitize_callback' => array($arras_colors, 'sanitize_color_scheme'), 'transport' => 'postMessage')); $wp_customize->add_control('color_scheme', array('label' => __('Base Color Scheme', 'arras'), 'section' => 'colors', 'type' => 'select', 'choices' => $arras_colors->get_color_scheme_names(), 'priority' => 1)); $wp_customize->add_setting('header_background_color', array('default' => $color_scheme[0], 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_background_color', array('label' => __('Header Background Color', 'arras'), 'section' => 'colors', 'priority' => 3))); /** * Array for custom controls using default control class. * 'control-id' => * array( 'label', 'description', 'section', 'settings', 'type', 'choices', priority ) * @var array */ $controls = array('footer-message' => array(__('Footer Message', 'arras'), __('You may use some limited html here (for links, etc).', 'arras'), 'title_tagline', 'footer_message', 'textarea', '', 35), 'enable-slideshow' => array(__('Enable Slideshow', 'arras'), '', 'slideshow', 'enable_slideshow', 'checkbox', '', 1), 'slideshow-posttype' => array(__('Slideshow Post Type', 'arras'), __('If you change this, please save and then refresh the page to get updated taxonomy and term choices.', 'arras'), 'slideshow', 'slideshow_posttype', 'select', arras_get_posttypes(), 5), 'slideshow-taxonomy' => array(__('Slideshow Taxonomy', 'arras'), __('If you change this, please save and then refresh the page to get updated term choices.', 'arras'), 'slideshow', 'slideshow_tax', 'select', arras_get_taxonomies(arras_get_option('slideshow_posttype')), 7), 'slideshow-count' => array(__('Maximum Posts in Slideshow', 'arras'), '', 'slideshow', 'slideshow_count', 'number', '', 13), 'enable-featured1' => array(__('Enable Featured #1', 'arras'), '', 'featured-1', 'enable_featured1', 'checkbox', '', 1), 'featured1-title' => array(__('Header for Featured #1 Section', 'arras'), '', 'featured-1', 'featured1_title', 'text', '', 3), 'featured1-posttype' => array(__('Featured #1 Post Type', 'arras'), __('If you change this, please save and then refresh the page to get updated taxonomy and term choices.', 'arras'), 'featured-1', 'featured1_posttype', 'select', arras_get_posttypes(), 5), 'featured1-taxonomy' => array(__('Featured #1 Taxonomy', 'arras'), __('If you change this, please save and then refresh the page to get updated term choices.', 'arras'), 'featured-1', 'featured1_tax', 'select', arras_get_taxonomies(arras_get_option('featured1_posttype')), 7), 'featured1-display' => array(__('Display Mode for Featured #1', 'arras'), '', 'featured-1', 'featured1_display', 'select', arras_get_tapestry_choices(), 11), 'featured1-count' => array(__('Maximum Posts in Featured #1', 'arras'), '', 'featured-1', 'featured1_count', 'number', '', 13), 'enable-featured2' => array(__('Enable Featured #2', 'arras'), '', 'featured-2', 'enable_featured2', 'checkbox', '', 1), 'featured2-title' => array(__('Header for Featured #2 Section', 'arras'), '', 'featured-2', 'featured2_title', 'text', '', 3), 'featured2-posttype' => array(__('Featured #2 Post Type', 'arras'), __('If you change this, please save and then refresh the page to get updated taxonomy and term choices.', 'arras'), 'featured-2', 'featured2_posttype', 'select', arras_get_posttypes(), 5), 'featured2-taxonomy' => array(__('Featured #2 Taxonomy', 'arras'), __('If you change this, please save and then refresh the page to get updated term choices.', 'arras'), 'featured-2', 'featured2_tax', 'select', arras_get_taxonomies(arras_get_option('featured2_posttype')), 7), 'featured2-display' => array(__('Display Mode for Featured #2', 'arras'), '', 'featured-2', 'featured2_display', 'select', arras_get_tapestry_choices(), 11), 'featured2-count' => array(__('Maximum Posts in Featured #2', 'arras'), '', 'featured-2', 'featured2_count', 'number', '', 13), 'enable-news' => array(__('Enable News', 'arras'), '', 'news', 'enable_news', 'checkbox', '', 1), 'news-title' => array(__('Header for News Section', 'arras'), '', 'news', 'news_title', 'text', '', 3), 'news-posttype' => array(__('News Post Type', 'arras'), __('If you change this, please save and then refresh the page to get updated taxonomy and term choices.', 'arras'), 'news', 'news_posttype', 'select', arras_get_posttypes(), 5), 'news-taxonomy' => array(__('News Taxonomy', 'arras'), __('If you change this, please save and then refresh the page to get updated term choices.', 'arras'), 'news', 'news_tax', 'select', arras_get_taxonomies(arras_get_option('news_posttype')), 7), 'news-display' => array(__('Display Mode for News', 'arras'), '', 'news', 'news_display', 'select', arras_get_tapestry_choices(), 11), 'news-count' => array(__('Maximum Posts in News', 'arras'), '', 'news', 'news_count', 'number', '', 13));