Esempio n. 1
0
function thesis_upgrade_options()
{
    // Retrieve Thesis Options and Thesis Options defaults
    $thesis_options = new Options();
    $thesis_options->get_options();
    $default_options = new Options();
    $default_options->default_options();
    // Retrieve Design Options and Design Options defaults
    $design_options = new Design();
    $design_options->get_design_options();
    $default_design_options = new Design();
    $default_design_options->default_design_options();
    // Begin code to upgrade all Thesis Options to the newest data structures
    if (isset($thesis_options->multimedia_box)) {
        $multimedia_box = $thesis_options->multimedia_box;
    }
    if (isset($design_options->home_layout)) {
        if ($design_options->home_layout) {
            $features = $design_options->teasers;
            unset($design_options->teasers);
        } else {
            $features = get_option('posts_per_page');
        }
    }
    foreach ($default_options as $option_name => $value) {
        if (!isset($thesis_options->{$option_name})) {
            $thesis_options->{$option_name} = $default_options->{$option_name};
        }
    }
    // Document head
    if (isset($thesis_options->title_home_name)) {
        $thesis_options->head['title']['title'] = (bool) $thesis_options->title_home_name;
    }
    if (isset($thesis_options->title_home_tagline)) {
        $thesis_options->head['title']['tagline'] = (bool) $thesis_options->title_home_tagline;
    }
    if (isset($thesis_options->title_tagline_first)) {
        $thesis_options->head['title']['tagline_first'] = (bool) $thesis_options->title_tagline_first;
    }
    if (isset($thesis_options->title_branded)) {
        $thesis_options->head['title']['branded'] = (bool) $thesis_options->title_branded;
    }
    if (isset($thesis_options->title_separator)) {
        $thesis_options->head['title']['separator'] = $thesis_options->title_separator;
    }
    if (isset($thesis_options->show_version)) {
        $thesis_options->head['version'] = $thesis_options->show_version;
    } elseif (isset($thesis_options->head['meta']['version'])) {
        $thesis_options->head['version'] = (bool) $thesis_options->head['meta']['version'];
    }
    if (isset($thesis_options->tags_noindex)) {
        $thesis_options->head['noindex']['tag'] = (bool) $thesis_options->tags_noindex;
    } elseif (is_array($thesis_options->head['meta']['noindex'])) {
        $thesis_options->head['noindex'] = $thesis_options->head['meta']['noindex'];
    }
    // Home Page options
    if (isset($thesis_options->meta_description)) {
        $thesis_options->home['meta']['description'] = $thesis_options->meta_description;
    } elseif (isset($thesis_options->head['meta']['description'])) {
        $thesis_options->home['meta']['description'] = $thesis_options->head['meta']['description'];
    }
    if (isset($thesis_options->meta_keywords)) {
        $thesis_options->home['meta']['keywords'] = $thesis_options->meta_keywords;
    } elseif (isset($thesis_options->head['meta']['keywords'])) {
        $thesis_options->home['meta']['keywords'] = $thesis_options->head['meta']['keywords'];
    }
    if (isset($design_options->layout['home'])) {
        if ($design_options->layout['home'] == 'teasers') {
            $thesis_options->home['features'] = $design_options->teasers['features'] ? $design_options->teasers['features'] : 2;
            unset($design_options->teasers['features']);
        } else {
            $thesis_options->home['features'] = get_option('posts_per_page');
        }
        foreach ($design_options->layout as $layout_var => $value) {
            if ($layout_var != 'home') {
                $new_layout[$layout_var] = $value;
            }
        }
        if ($new_layout) {
            $design_options->layout = $new_layout;
        }
    } elseif (isset($features)) {
        $thesis_options->home['features'] = $features;
    }
    // New $head array
    if (isset($thesis_options->head['meta'])) {
        $new_head['title'] = $thesis_options->head['title'];
        $new_head['noindex'] = $thesis_options->head['noindex'];
        $new_head['canonical'] = $thesis_options->head['canonical'];
        $new_head['version'] = $thesis_options->head['version'];
        $thesis_options->head = $new_head;
    }
    // Display options
    if (isset($thesis_options->show_title)) {
        $thesis_options->display['header']['title'] = (bool) $thesis_options->show_title;
    }
    if (isset($thesis_options->show_tagline)) {
        $thesis_options->display['header']['tagline'] = (bool) $thesis_options->show_tagline;
    }
    if (isset($thesis_options->show_author)) {
        $thesis_options->display['byline']['author']['show'] = (bool) $thesis_options->show_author;
    }
    if (isset($thesis_options->link_author_names)) {
        $thesis_options->display['byline']['author']['link'] = (bool) $thesis_options->link_author_names;
    }
    if (isset($thesis_options->author_nofollow)) {
        $thesis_options->display['byline']['author']['nofollow'] = (bool) $thesis_options->author_nofollow;
    }
    if (isset($thesis_options->show_date)) {
        $thesis_options->display['byline']['date']['show'] = (bool) $thesis_options->show_date;
    }
    if (isset($thesis_options->show_author_on_pages)) {
        $thesis_options->display['byline']['page']['author'] = (bool) $thesis_options->show_author_on_pages;
    }
    if (isset($thesis_options->show_date_on_pages)) {
        $thesis_options->display['byline']['page']['date'] = (bool) $thesis_options->show_date_on_pages;
    }
    if (isset($thesis_options->show_num_comments)) {
        $thesis_options->display['byline']['num_comments']['show'] = (bool) $thesis_options->show_num_comments;
    }
    if (isset($thesis_options->show_categories)) {
        $thesis_options->display['byline']['categories']['show'] = (bool) $thesis_options->show_categories;
    }
    if (isset($thesis_options->read_more_text)) {
        $thesis_options->display['posts']['read_more_text'] = $thesis_options->read_more_text;
    } elseif (isset($thesis_options->display['read_more_text'])) {
        $thesis_options->display['posts']['read_more_text'] = $thesis_options->display['read_more_text'];
        unset($thesis_options->display['read_more_text']);
    }
    if (isset($thesis_options->show_post_nav)) {
        $thesis_options->display['posts']['nav'] = (bool) $thesis_options->show_post_nav;
    } elseif (isset($thesis_options->display['navigation'])) {
        $thesis_options->display['posts']['nav'] = (bool) $thesis_options->display['navigation'];
        unset($thesis_options->display['navigation']);
    }
    if (isset($thesis_options->archive_style)) {
        $thesis_options->display['archives']['style'] = $thesis_options->archive_style;
    }
    if (isset($thesis_options->tags_single)) {
        $thesis_options->display['tags']['single'] = (bool) $thesis_options->tags_single;
    }
    if (isset($thesis_options->tags_index)) {
        $thesis_options->display['tags']['index'] = (bool) $thesis_options->tags_index;
    }
    if (isset($thesis_options->tags_nofollow)) {
        $thesis_options->display['tags']['nofollow'] = (bool) $thesis_options->tags_nofollow;
    }
    if (isset($thesis_options->show_comment_numbers)) {
        $thesis_options->display['comments']['numbers'] = (bool) $thesis_options->show_comment_numbers;
    }
    if (isset($thesis_options->show_allowed_tags)) {
        $thesis_options->display['comments']['allowed_tags'] = (bool) $thesis_options->show_allowed_tags;
    }
    if (isset($thesis_options->disable_comments)) {
        $thesis_options->display['comments']['disable_pages'] = (bool) $thesis_options->disable_comments;
    }
    if (isset($thesis_options->avatar_size)) {
        $thesis_options->display['comments']['avatar_size'] = $thesis_options->avatar_size;
    }
    if (isset($thesis_options->show_default_widgets)) {
        $thesis_options->display['sidebars']['default_widgets'] = (bool) $thesis_options->show_default_widgets;
    }
    if (isset($thesis_options->edit_post_link)) {
        $thesis_options->display['admin']['edit_post'] = (bool) $thesis_options->edit_post_link;
    }
    if (isset($thesis_options->edit_comment_link)) {
        $thesis_options->display['admin']['edit_comment'] = (bool) $thesis_options->edit_comment_link;
    }
    if (isset($thesis_options->admin_link)) {
        $thesis_options->display['admin']['link'] = $thesis_options->admin_link == 'always' ? true : false;
    }
    // Syndication
    if (isset($thesis_options->feed_url)) {
        $thesis_options->feed['url'] = $thesis_options->feed_url;
    }
    // Nav menu
    if (isset($thesis_options->nav_menu_pages)) {
        $nav_menu_pages = explode(',', $thesis_options->nav_menu_pages);
        foreach ($nav_menu_pages as $nav_page) {
            if ($nav_page) {
                $thesis_options->nav['pages'][$nav_page]['show'] = true;
            }
        }
    }
    if (isset($thesis_options->nav_category_pages)) {
        $thesis_options->nav['categories'] = $thesis_options->nav_category_pages;
    }
    if (isset($thesis_options->nav_link_category)) {
        $thesis_options->nav['links'] = $thesis_options->nav_link_category;
    }
    if (isset($thesis_options->nav_home_text)) {
        $thesis_options->nav['home']['text'] = $thesis_options->nav_home_text;
    }
    if (isset($thesis_options->show_feed_link)) {
        $thesis_options->nav['feed']['show'] = (bool) $thesis_options->show_feed_link;
    }
    if (isset($thesis_options->feed_link_text)) {
        $thesis_options->nav['feed']['text'] = $thesis_options->feed_link_text;
    }
    unset($thesis_options->nav['style']);
    // Remove support for old-style WP menu
    // Post images and thumbnails
    if (isset($design_options->post_image_horizontal)) {
        $thesis_options->image['post']['x'] = $design_options->post_image_horizontal;
        unset($design_options->post_image_horizontal);
    }
    if (isset($design_options->post_image_vertical)) {
        $thesis_options->image['post']['y'] = $design_options->post_image_vertical;
        unset($design_options->post_image_vertical);
    }
    if (isset($design_options->post_image_frame)) {
        $thesis_options->image['post']['frame'] = $design_options->post_image_frame ? 'on' : 'off';
        unset($design_options->post_image_frame);
    }
    if (isset($design_options->post_image_single)) {
        $thesis_options->image['post']['single'] = $design_options->post_image_single;
        unset($design_options->post_image_single);
    }
    if (isset($design_options->post_image_archives)) {
        $thesis_options->image['post']['archives'] = $design_options->post_image_archives;
        unset($design_options->post_image_archives);
    }
    if (isset($design_options->thumb_horizontal)) {
        $thesis_options->image['thumb']['x'] = $design_options->thumb_horizontal;
        unset($design_options->thumb_horizontal);
    }
    if (isset($design_options->thumb_vertical)) {
        $thesis_options->image['thumb']['y'] = $design_options->thumb_vertical;
        unset($design_options->thumb_vertical);
    }
    if (isset($design_options->thumb_frame)) {
        $thesis_options->image['thumb']['frame'] = $design_options->thumb_frame ? 'on' : 'off';
        unset($design_options->thumb_frame);
    }
    if (isset($design_options->thumb_size)) {
        $thesis_options->image['thumb']['width'] = $design_options->thumb_size['width'];
        $thesis_options->image['thumb']['height'] = $design_options->thumb_size['height'];
        unset($design_options->thumb_size);
    }
    // Multimedia box
    if (isset($multimedia_box) && is_array($multimedia_box)) {
        foreach ($multimedia_box as $item => $value) {
            $design_options->multimedia_box[$item] = $value;
        }
    } elseif (isset($multimedia_box)) {
        $design_options->multimedia_box['status'] = $multimedia_box;
        if ($thesis_options->image_alt_tags) {
            foreach ($thesis_options->image_alt_tags as $image_name => $alt_text) {
                if ($alt_text != '') {
                    $design_options->multimedia_box['alt_tags'][$image_name] = $alt_text;
                }
            }
        }
        if ($thesis_options->image_link_urls) {
            foreach ($thesis_options->image_link_urls as $image_name => $link_url) {
                if ($link_url != '') {
                    $design_options->multimedia_box['link_urls'][$image_name] = $link_url;
                }
            }
        }
        if ($thesis_options->video_code) {
            $design_options->multimedia_box['video'] = $thesis_options->video_code;
        }
        if ($thesis_options->custom_code) {
            $design_options->multimedia_box['code'] = $thesis_options->custom_code;
        }
    }
    // Loop back through all existing Thesis Options and make changes as necessary
    foreach ($thesis_options as $option_name => $value) {
        if ($option_name == 'mint' || $option_name == 'header_scripts') {
            $thesis_options->scripts['header'] = $value;
            unset($thesis_options->{$option_name});
        } elseif ($option_name == 'analytics' || $option_name == 'footer_scripts') {
            $thesis_options->scripts['footer'] = $value;
            unset($thesis_options->{$option_name});
        }
        if (!isset($default_options->{$option_name})) {
            unset($thesis_options->{$option_name});
        }
        // Has this option been nuked? If so, kill it!
    }
    if (version_compare($thesis_options->version, thesis_version(), '<')) {
        $thesis_options->version = thesis_version();
    }
    update_option('thesis_options', $thesis_options);
    // Save upgraded Thesis Options
    update_option('thesis_design_options', $design_options);
    // Save upgraded Design Options
}
Esempio n. 2
0
function arras_flush_options()
{
    global $arras_options;
    $arras_options = new Options();
    $arras_options->get_options();
    if (!get_option('arras_options')) {
        $arras_options->default_options();
    }
}
Esempio n. 3
0
function thesis_upgrade_design_options()
{
    // Retrieve Design Options and Design Options defaults
    $design_options = new Design();
    $design_options->get_design_options();
    $default_design_options = new Design();
    $default_design_options->default_design_options();
    // Retrieve Thesis Options and Thesis Options defaults
    $thesis_options = new Options();
    $thesis_options->get_options();
    $default_options = new Options();
    $default_options->default_options();
    if (isset($design_options->teasers) && !is_array($design_options->teasers)) {
        unset($design_options->teasers);
    }
    if (isset($design_options->feature_box_condition)) {
        $feature_box = $design_options->feature_box;
        unset($design_options->feature_box);
    }
    if (isset($thesis_options->multimedia_box)) {
        $multimedia_box = $thesis_options->multimedia_box;
    }
    // Ubiquitous options upgrade code
    foreach ($default_design_options as $option_name => $value) {
        if (!isset($design_options->{$option_name})) {
            $design_options->{$option_name} = $value;
        }
    }
    // 1.6b niceness
    if (!isset($design_options->nav['link']['parent'])) {
        $design_options->nav['link']['parent'] = $default_design_options->nav['link']['parent'];
    }
    if (!isset($design_options->nav['background']['parent'])) {
        $design_options->nav['background']['parent'] = $default_design_options->nav['background']['parent'];
    }
    // Version-specific upgrade code
    if (isset($design_options->font_sizes)) {
        foreach ($design_options->fonts as $area => $family) {
            $design_options->fonts['families'][$area] = $family ? $family : false;
        }
        foreach ($design_options->font_sizes as $area => $size) {
            $design_options->fonts['sizes'][$area] = $size;
        }
    }
    if (isset($design_options->num_columns)) {
        $design_options->layout['columns'] = $design_options->num_columns;
    }
    if (isset($design_options->widths)) {
        $design_options->layout['widths']['content'] = $design_options->widths['content'] ? $design_options->widths['content'] : 480;
        $design_options->layout['widths']['sidebar_1'] = $design_options->widths['sidebar_1'] ? $design_options->widths['sidebar_1'] : 195;
        $design_options->layout['widths']['sidebar_2'] = $design_options->widths['sidebar_2'] ? $design_options->widths['sidebar_2'] : 195;
    }
    if (isset($design_options->column_order)) {
        $design_options->layout['order'] = $design_options->column_order;
    }
    if (isset($design_options->html_framework)) {
        $design_options->layout['framework'] = $design_options->html_framework ? $design_options->html_framework : 'page';
    }
    if (isset($design_options->page_padding)) {
        $design_options->layout['page_padding'] = $design_options->page_padding;
    }
    if (isset($design_options->teaser_options) && isset($design_options->teaser_content)) {
        foreach ($design_options->teaser_content as $teaser_area) {
            $new_teaser_options[$teaser_area]['name'] = $design_options->teasers['options'][$teaser_area]['name'];
            $new_teaser_options[$teaser_area]['show'] = (bool) $design_options->teaser_options[$teaser_area];
        }
        if ($new_teaser_options) {
            $design_options->teasers['options'] = $new_teaser_options;
        }
    }
    if (isset($design_options->teaser_date)) {
        $design_options->teasers['date']['format'] = $design_options->teaser_date ? $design_options->teaser_date : 'standard';
    }
    if (isset($design_options->teaser_date_custom)) {
        $design_options->teasers['date']['custom'] = $design_options->teaser_date_custom ? $design_options->teaser_date_custom : 'F j, Y';
    }
    if (isset($design_options->teaser_font_sizes)) {
        foreach ($design_options->teaser_font_sizes as $teaser_area => $size) {
            $design_options->teasers['font_sizes'][$teaser_area] = $size;
        }
    }
    if (isset($design_options->teaser_link_text)) {
        $design_options->teasers['link_text'] = $design_options->teaser_link_text ? $design_options->teaser_link_text : false;
    }
    if (isset($feature_box)) {
        $design_options->feature_box['position'] = $feature_box;
        if (isset($design_options->feature_box_condition)) {
            $design_options->feature_box['status'] = $design_options->feature_box_condition;
        }
        if (isset($design_options->feature_box_after_post)) {
            $design_options->feature_box['after_post'] = $design_options->feature_box_after_post;
        }
    }
    // Multimedia box
    if (isset($multimedia_box) && is_array($multimedia_box)) {
        foreach ($multimedia_box as $item => $value) {
            $design_options->multimedia_box[$item] = $value;
        }
    } elseif (isset($multimedia_box)) {
        $design_options->multimedia_box['status'] = $multimedia_box;
        unset($thesis_options->multimedia_box);
        if ($thesis_options->image_alt_tags) {
            foreach ($thesis_options->image_alt_tags as $image_name => $alt_text) {
                if ($alt_text != '') {
                    $design_options->multimedia_box['alt_tags'][$image_name] = $alt_text;
                }
            }
            unset($thesis_options->image_alt_tags);
        }
        if ($thesis_options->image_link_urls) {
            foreach ($thesis_options->image_link_urls as $image_name => $link_url) {
                if ($link_url != '') {
                    $design_options->multimedia_box['link_urls'][$image_name] = $link_url;
                }
            }
            unset($thesis_options->image_link_urls);
        }
        if ($thesis_options->video_code) {
            $design_options->multimedia_box['video'] = $thesis_options->video_code;
            unset($thesis_options->video_code);
        }
        if ($thesis_options->custom_code) {
            $design_options->multimedia_box['code'] = $thesis_options->custom_code;
            unset($thesis_options->custom_code);
        }
    }
    // 1.6 Multimedia box style upgrades
    if (!isset($multimedia_box['color'])) {
        $design_options->multimedia_box['color'] = $default_design_options->multimedia_box['color'];
    }
    if (!isset($multimedia_box['background'])) {
        $design_options->multimedia_box['background']['image'] = $default_design_options->multimedia_box['background']['image'];
        $design_options->multimedia_box['background']['video'] = $default_design_options->multimedia_box['background']['video'];
        $design_options->multimedia_box['background']['code'] = $default_design_options->multimedia_box['background']['code'];
    }
    // Post images and thumbnails
    if (isset($design_options->post_image_horizontal)) {
        $thesis_options->image['post']['x'] = $design_options->post_image_horizontal;
    }
    if (isset($design_options->post_image_vertical)) {
        $thesis_options->image['post']['y'] = $design_options->post_image_vertical;
    }
    if (isset($design_options->post_image_frame)) {
        $thesis_options->image['post']['frame'] = $design_options->post_image_frame;
    }
    if (isset($design_options->post_image_single)) {
        $thesis_options->image['post']['single'] = $design_options->post_image_single;
    }
    if (isset($design_options->post_image_archives)) {
        $thesis_options->image['post']['archives'] = $design_options->post_image_archives;
    }
    if (isset($design_options->thumb_horizontal)) {
        $thesis_options->image['thumb']['x'] = $design_options->thumb_horizontal;
    }
    if (isset($design_options->thumb_vertical)) {
        $thesis_options->image['thumb']['y'] = $design_options->thumb_vertical;
    }
    if (isset($design_options->thumb_frame)) {
        $thesis_options->image['thumb']['frame'] = $design_options->thumb_frame;
    }
    if (isset($design_options->thumb_size)) {
        $thesis_options->image['thumb']['width'] = $design_options->thumb_size['width'];
        $thesis_options->image['thumb']['height'] = $design_options->thumb_size['height'];
    }
    // Preserve old font variables
    if ($design_options->font_body) {
        $design_options->fonts['families']['body'] = $design_options->font_body;
    }
    if ($design_options->font_content_subheads_family) {
        $design_options->fonts['families']['subheads'] = $design_options->font_content_subheads_family;
    }
    if ($design_options->font_nav_family) {
        $design_options->fonts['families']['nav_menu'] = $design_options->font_nav_family;
    }
    if ($design_options->font_header_family) {
        $design_options->fonts['families']['header'] = $design_options->font_header_family;
    }
    if ($design_options->font_header_tagline_family) {
        $design_options->fonts['families']['tagline'] = $design_options->font_header_tagline_family;
    }
    if ($design_options->font_headlines_family) {
        $design_options->fonts['families']['headlines'] = $design_options->font_headlines_family;
    }
    if ($design_options->font_bylines_family) {
        $design_options->fonts['families']['bylines'] = $design_options->font_bylines_family;
    }
    if ($design_options->font_multimedia_family) {
        $design_options->fonts['families']['multimedia_box'] = $design_options->font_multimedia_family;
    }
    if ($design_options->font_sidebars_family) {
        $design_options->fonts['families']['sidebars'] = $design_options->font_sidebars_family;
    }
    if ($design_options->font_sidebars_headings_family) {
        $design_options->fonts['families']['sidebar_headings'] = $design_options->font_sidebars_headings_family;
    }
    if ($design_options->font_footer_family) {
        $design_options->fonts['families']['footer'] = $design_options->font_footer_family;
    }
    // Preserve old font size variables
    if ($design_options->font_content_size) {
        $design_options->fonts['sizes']['content'] = $design_options->font_content_size;
    }
    if ($design_options->font_nav_size) {
        $design_options->fonts['sizes']['nav_menu'] = $design_options->font_nav_size;
    }
    if ($design_options->font_header_size) {
        $design_options->fonts['sizes']['header'] = $design_options->font_header_size;
    }
    if ($design_options->font_headlines_size) {
        $design_options->fonts['sizes']['headlines'] = $design_options->font_headlines_size;
    }
    if ($design_options->font_bylines_size) {
        $design_options->fonts['sizes']['bylines'] = $design_options->font_bylines_size;
    }
    if ($design_options->font_multimedia_size) {
        $design_options->fonts['sizes']['multimedia_box'] = $design_options->font_multimedia_size;
    }
    if ($design_options->font_sidebars_size) {
        $design_options->fonts['sizes']['sidebars'] = $design_options->font_sidebars_size;
    }
    if ($design_options->font_footer_size) {
        $design_options->fonts['sizes']['footer'] = $design_options->font_footer_size;
    }
    // Preserve old width settings
    if ($design_options->num_columns == 3 && $design_options->width_content_3) {
        $design_options->layout['widths']['content'] = $design_options->width_content_3;
    } elseif ($design_options->num_columns == 2 && $design_options->width_content_2) {
        $design_options->layout['widths']['content'] = $design_options->width_content_2;
        $design_options->layout['widths']['sidebar_1'] = $design_options->width_sidebar;
    } elseif ($design_options->num_columns == 3 && $design_options->width_content_1) {
        $design_options->layout['widths']['content'] = $design_options->width_content_1;
    }
    // Clean up the $design_options->fonts array from 1.5b r3 to 1.5
    foreach ($design_options->fonts as $type => $value) {
        if ($type == 'families' || $type == 'sizes') {
            $new_fonts_array[$type] = $value;
        }
    }
    $design_options->fonts = $new_fonts_array;
    foreach ($design_options as $option_name => $value) {
        if (!isset($default_design_options->{$option_name})) {
            unset($design_options->{$option_name});
        }
        // Has this option been nuked? If so, kill it!
    }
    update_option('thesis_design_options', $design_options);
    // Save upgraded options
    update_option('thesis_options', $thesis_options);
    thesis_generate_css();
}