function upgrade_options() { $site_options = new thesis_site_options(); $site_options->get_options(); $default_site_options = new thesis_site_options(); $default_site_options->default_options(); $design_options = new thesis_design_options(); $design_options->get_options(); $default_design_options = new thesis_design_options(); $default_design_options->default_options(); // This is necessary for the 1.8 upgrade $page_options = new thesis_page_options(); $page_options->get_options(); $page_options->upgrade_terms(); // Begin code to upgrade all Thesis Options to the newest data structures if (isset($site_options->multimedia_box)) { $multimedia_box = $site_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'); } } // If any new data structures have been introduced, incorporate them now foreach ($default_site_options as $option_name => $value) { if (!isset($site_options->{$option_name})) { $site_options->{$option_name} = $default_site_options->{$option_name}; } } foreach ($default_design_options as $option_name => $value) { if (!isset($design_options->{$option_name})) { $design_options->{$option_name} = $value; } } // 1.8 nav upgrade and cleanup if (isset($site_options->nav)) { if (!isset($site_options->nav['type'])) { $site_options->nav['type'] = 'thesis'; } if (isset($site_options->nav['submenu_width'])) { unset($site_options->nav['submenu_width']); } if (isset($site_options->nav['border'])) { unset($site_options->nav['border']); } if (isset($site_options->nav['style'])) { unset($site_options->nav['style']); } } // Home page options upgrade for 1.8 if (isset($site_options->home)) { if (isset($site_options->home['meta']['description'])) { $site_options->home['head']['meta']['description'] = $site_options->home['meta']['description']; unset($site_options->home['meta']['description']); } elseif (isset($site_options->head['meta']['description'])) { $site_options->home['head']['meta']['description'] = $site_options->head['meta']['description']; unset($site_options->head['meta']['description']); } if (isset($site_options->home['meta']['keywords'])) { $site_options->home['head']['meta']['keywords'] = $site_options->home['meta']['keywords']; unset($site_options->home['meta']['keywords']); } elseif (isset($site_options->head['meta']['keywords'])) { $site_options->home['head']['meta']['keywords'] = $site_options->head['meta']['keywords']; unset($site_options->head['meta']['keywords']); } if (isset($site_options->home['features'])) { $design_options->home['body']['content']['features'] = $site_options->home['features']; unset($site_options->home['features']); } } else { if (isset($site_options->meta_description)) { $site_options->home['head']['meta']['description'] = $site_options->meta_description; } if (isset($site_options->meta_keywords)) { $site_options->home['head']['meta']['keywords'] = $site_options->meta_keywords; } } if (isset($design_options->layout['home'])) { if ($design_options->layout['home'] == 'teasers') { $design_options->home['body']['content']['features'] = $design_options->teasers['features'] ? $design_options->teasers['features'] : 2; unset($design_options->teasers['features']); } else { $design_options->home['body']['content']['features'] = get_option('posts_per_page'); } #wp 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)) { $design_options->home['body']['content']['features'] = $features; } // Display options move for 1.8 if (isset($site_options->display)) { $design_options->display = $site_options->display; if (isset($site_options->comments)) { $design_options->display['comments'] = $site_options->comments; } } // Home page options move for 1.8 if (isset($page_options->home)) { if (isset($page_options->home['head'])) { $site_options->home['head'] = $page_options->home['head']; } if (isset($page_options->home['body'])) { $design_options->home['body'] = $page_options->home['body']; } if (isset($page_options->home['javascript'])) { $design_options->home['javascript'] = $page_options->home['javascript']; } } // Updated $head array for 1.7 if (isset($site_options->head['title']['title']) || isset($site_options->head['title']['tagline'])) { $separator = $site_options->head['title']['separator'] ? urldecode($site_options->head['title']['separator']) : '—'; if ($site_options->head['title']['title'] && $site_options->head['title']['tagline']) { $title = $site_options->head['title']['tagline_first'] ? get_bloginfo('description') . " {$separator} " . get_bloginfo('name') : get_bloginfo('name') . " {$separator} " . get_bloginfo('description'); } elseif ($site_options->head['title']['title']) { $title = get_bloginfo('name'); } else { $title = get_bloginfo('description'); } $site_options->home['head']['title'] = urlencode($title); unset($site_options->head['title']['title'], $site_options->head['title']['tagline'], $site_options->head['title']['tagline_first']); } if (isset($site_options->head['noindex'])) { $site_options->head['meta']['robots']['noindex'] = $site_options->head['meta']['robots']['nofollow'] = $site_options->head['noindex']; $site_options->head['meta']['robots']['noindex']['sub'] = true; unset($site_options->head['noindex']); } if (!isset($site_options->head['meta']['robots']['nofollow'])) { $site_options->head['meta']['robots']['nofollow'] = $default_site_options->head['meta']['robots']['nofollow']; } if (!isset($site_options->head['meta']['robots']['noarchive'])) { $site_options->head['meta']['robots']['noarchive'] = $default_site_options->head['meta']['robots']['noarchive']; } if (!isset($site_options->head['meta']['robots']['noodp'])) { $site_options->head['meta']['robots']['noodp'] = $default_site_options->head['meta']['robots']['noodp']; } if (!isset($site_options->head['meta']['robots']['noydir'])) { $site_options->head['meta']['robots']['noydir'] = $default_site_options->head['meta']['robots']['noydir']; } if (isset($site_options->head['canonical'])) { $site_options->head['links']['canonical'] = $site_options->head['canonical']; unset($site_options->head['canonical']); } if (isset($site_options->head['version'])) { unset($site_options->head['version']); } if ($site_options->feed['url']) { $site_options->head['feed']['url'] = $site_options->feed['url']; } elseif (isset($site_options->feed_url)) { $site_options->head['feed']['url'] = $site_options->feed_url; } if (isset($site_options->scripts)) { $site_options->head['scripts'] = $site_options->scripts['header']; $site_options->javascript['scripts'] = $site_options->scripts['footer']; } if (isset($site_options->header_scripts)) { $site_options->head['scripts'] = $site_options->header_scripts; } elseif (isset($site_options->mint)) { $site_options->head['scripts'] = $site_options->mint; } if (isset($site_options->footer_scripts)) { $site_options->javascript['scripts'] = $site_options->footer_scripts; } elseif (isset($site_options->analytics)) { $site_options->javascript['scripts'] = $site_options->analytics; } // Custom stylesheet option, updated for 1.8 if (isset($design_options->layout['custom']) && !isset($site_options->custom['stylesheet'])) { $site_options->custom['stylesheet'] = (bool) $design_options->layout['custom']; unset($design_options->layout['custom']); } elseif (isset($site_options->style)) { $site_options->custom['stylesheet'] = (bool) $site_options->style['custom']; } // Display options (updated for 1.8) if (isset($site_options->show_title)) { $design_options->display['header']['title'] = (bool) $site_options->show_title; } if (isset($site_options->show_tagline)) { $design_options->display['header']['tagline'] = (bool) $site_options->show_tagline; } if (isset($site_options->show_author)) { $design_options->display['byline']['author']['show'] = (bool) $site_options->show_author; } if (isset($site_options->link_author_names)) { $design_options->display['byline']['author']['link'] = (bool) $site_options->link_author_names; } if (isset($site_options->author_nofollow)) { $design_options->display['byline']['author']['nofollow'] = (bool) $site_options->author_nofollow; } if (isset($site_options->show_date)) { $design_options->display['byline']['date']['show'] = (bool) $site_options->show_date; } if (isset($site_options->show_author_on_pages)) { $design_options->display['byline']['page']['author'] = (bool) $site_options->show_author_on_pages; } if (isset($site_options->show_date_on_pages)) { $design_options->display['byline']['page']['date'] = (bool) $site_options->show_date_on_pages; } if (isset($site_options->show_num_comments)) { $design_options->display['byline']['num_comments']['show'] = (bool) $site_options->show_num_comments; } if (isset($site_options->show_categories)) { $design_options->display['byline']['categories']['show'] = (bool) $site_options->show_categories; } if (isset($site_options->read_more_text)) { $design_options->display['posts']['read_more_text'] = $site_options->read_more_text; } elseif (isset($site_options->display['read_more_text'])) { $design_options->display['posts']['read_more_text'] = $site_options->display['read_more_text']; } if (isset($site_options->show_post_nav)) { $design_options->display['posts']['nav'] = (bool) $site_options->show_post_nav; } elseif (isset($site_options->display['navigation'])) { $design_options->display['posts']['nav'] = (bool) $site_options->display['navigation']; } if (isset($site_options->archive_style)) { $design_options->display['archives']['style'] = $site_options->archive_style; } if (isset($site_options->tags_single)) { $design_options->display['tags']['single'] = (bool) $site_options->tags_single; } if (isset($site_options->tags_index)) { $design_options->display['tags']['index'] = (bool) $site_options->tags_index; } if (isset($site_options->tags_nofollow)) { $design_options->display['tags']['nofollow'] = (bool) $site_options->tags_nofollow; } if (isset($site_options->show_default_widgets)) { $design_options->display['sidebars']['default_widgets'] = (bool) $site_options->show_default_widgets; } if (isset($site_options->edit_post_link)) { $design_options->display['admin']['edit_post'] = (bool) $site_options->edit_post_link; } if (isset($site_options->admin_link)) { $design_options->display['admin']['link'] = $site_options->admin_link == 'always' ? true : false; } // Update old comment options for version 1.8 if (isset($site_options->display['comments'])) { // Thesis Options $design_options->display['comments']['disable_pages'] = (bool) $site_options->display['comments']['disable_pages']; // Design Options $design_options->comments['comments']['options']['meta']['number']['show'] = (bool) $site_options->display['comments']['numbers']; $design_options->comments['comments']['options']['meta']['avatar']['options']['size'] = $site_options->display['comments']['avatar_size']; } if (isset($site_options->show_comment_numbers)) { $design_options->comments['comments']['options']['meta']['number']['show'] = (bool) $site_options->show_comment_numbers; } if (isset($site_options->avatar_size)) { $design_options->comments['comments']['options']['meta']['avatar']['options']['size'] = $site_options->avatar_size; } if (isset($site_options->disable_comments)) { $design_options->display['comments']['disable_pages'] = (bool) $site_options->disable_comments; } // Nav menu if (isset($site_options->nav_menu_pages)) { $nav_menu_pages = explode(',', $site_options->nav_menu_pages); foreach ($nav_menu_pages as $nav_page) { if ($nav_page) { $site_options->nav['pages'][$nav_page]['show'] = true; } } } if (isset($site_options->nav_category_pages)) { $site_options->nav['categories'] = $site_options->nav_category_pages; } if (isset($site_options->nav_link_category)) { $site_options->nav['links'] = $site_options->nav_link_category; } if (isset($site_options->nav_home_text)) { $site_options->nav['home']['text'] = $site_options->nav_home_text; } if (isset($site_options->show_feed_link)) { $site_options->nav['feed']['show'] = (bool) $site_options->show_feed_link; } if (isset($site_options->feed_link_text)) { $site_options->nav['feed']['text'] = $site_options->feed_link_text; } // Post images and thumbnails if (isset($site_options->image)) { // This is for 1.7 $design_options->image = $site_options->image; } else { // This is suuuuper legacy if (isset($design_options->post_image_horizontal)) { $design_options->image['post']['x'] = $design_options->post_image_horizontal; } if (isset($design_options->post_image_vertical)) { $design_options->image['post']['y'] = $design_options->post_image_vertical; } if (isset($design_options->post_image_frame)) { $design_options->image['post']['frame'] = $design_options->post_image_frame ? 'on' : 'off'; } if (isset($design_options->post_image_single)) { $design_options->image['post']['single'] = $design_options->post_image_single; } if (isset($design_options->post_image_archives)) { $design_options->image['post']['archives'] = $design_options->post_image_archives; } if (isset($design_options->thumb_horizontal)) { $design_options->image['thumb']['x'] = $design_options->thumb_horizontal; } if (isset($design_options->thumb_vertical)) { $design_options->image['thumb']['y'] = $design_options->thumb_vertical; } if (isset($design_options->thumb_frame)) { $design_options->image['thumb']['frame'] = $design_options->thumb_frame ? 'on' : 'off'; } if (isset($design_options->thumb_size)) { $design_options->image['thumb']['width'] = $design_options->thumb_size['width']; $design_options->image['thumb']['height'] = $design_options->thumb_size['height']; } } // 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 ($site_options->image_alt_tags) { foreach ($site_options->image_alt_tags as $image_name => $alt_text) { if ($alt_text != '') { $design_options->multimedia_box['alt_tags'][$image_name] = $alt_text; } } } if ($site_options->image_link_urls) { foreach ($site_options->image_link_urls as $image_name => $link_url) { if ($link_url != '') { $design_options->multimedia_box['link_urls'][$image_name] = $link_url; } } } if ($site_options->video_code) { $design_options->multimedia_box['video'] = $site_options->video_code; } if ($site_options->custom_code) { $design_options->multimedia_box['code'] = $site_options->custom_code; } } // Loop back through all existing Thesis Options and make changes as necessary foreach ($site_options as $option_name => $value) { if (!isset($default_site_options->{$option_name})) { unset($site_options->{$option_name}); } // Has this option been nuked? If so, kill it! } if (version_compare($site_options->version, thesis_version(), '<')) { $site_options->version = thesis_version(); } update_option('thesis_options', $site_options); // Save upgraded Thesis Options update_option('thesis_design_options', $design_options); // Save upgraded Design Options delete_option('thesis_pages'); }
// Internationalization load_theme_textdomain('thesis', THESIS_LIB . '/languages'); // Add Thesis Options and Design Options pages to the WordPress Dashboard if (is_admin()) { thesis_admin_setup(); } // Register sidebars and widgets thesis_register_sidebars(); thesis_register_widgets(); $thesis_site = new thesis_site_options(); $thesis_design = new thesis_design_options(); $thesis_pages = new thesis_page_options(); $thesis_site->get_options(); $thesis_design->get_options(); $thesis_pages->get_options(); if ($_GET['activated']) { thesis_upgrade(); } // Deconstruct the WordPress header to make way for Thesis pwnage remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'adjacent_posts_rel_link'); remove_action('wp_head', 'next_post_rel_link'); remove_action('wp_head', 'prev_post_rel_link'); remove_action('wp_head', 'parent_post_rel_link'); remove_action('wp_head', 'rel_canonical'); // Handy 301 redirect option for posts and pages add_action('template_redirect', 'thesis_redirect'); // WP process filters
function manage_options() { if (isset($_GET['download'])) { if ($_GET['download'] == 'site') { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="thesis-site-options-' . date("Ymd") . '.dat"'); $site_options = new thesis_site_options(); $site_options->get_options(); echo serialize($site_options); exit; } elseif ($_GET['download'] == 'design') { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="thesis-design-options-' . date("Ymd") . '.dat"'); $design_options = new thesis_design_options(); $design_options->get_options(); echo serialize($design_options); exit; } elseif ($_GET['download'] == 'pages') { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="thesis-page-options-' . date("Ymd") . '.dat"'); $page_options = new thesis_page_options(); $page_options->get_options(); echo serialize($page_options); exit; } elseif ($_GET['download'] == 'all') { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="thesis-all-options-' . date("Ymd") . '.dat"'); $site_options = new thesis_site_options(); $site_options->get_options(); $design_options = new thesis_design_options(); $design_options->get_options(); $page_options = new thesis_page_options(); $page_options->get_options(); echo serialize(array('site_options' => $site_options, 'design_options' => $design_options, 'page_options' => $page_options)); exit; } } elseif (isset($_GET['restore'])) { if ($_GET['restore'] == 'site') { $default_site_options = new thesis_site_options(); $default_site_options->default_options(); update_option('thesis_options', $default_site_options); #wp wp_redirect(admin_url('admin.php?page=options-manager&restored=true&type=Site')); #wp } elseif ($_GET['restore'] == 'design') { $default_design_options = new thesis_design_options(); $default_design_options->default_options(); update_option('thesis_design_options', $default_design_options); #wp thesis_generate_css(); wp_redirect(admin_url('admin.php?page=options-manager&restored=true&type=Design')); #wp } elseif ($_GET['restore'] == 'pages') { $default_page_options = new thesis_page_options(); $default_page_options->default_options(); update_option('thesis_pages', $default_page_options); #wp wp_redirect(admin_url('admin.php?page=options-manager&restored=true&type=Page')); #wp } elseif ($_GET['restore'] == 'all') { $default_site_options = new thesis_site_options(); $default_site_options->default_options(); $default_design_options = new thesis_design_options(); $default_design_options->default_options(); $default_page_options = new thesis_page_options(); $default_page_options->default_options(); update_option('thesis_options', $default_site_options); #wp update_option('thesis_design_options', $default_design_options); #wp update_option('thesis_pages', $default_page_options); #wp thesis_generate_css(); wp_redirect(admin_url('admin.php?page=options-manager&restored=true&type=All')); #wp } } elseif (isset($_POST['upload'])) { if ($_POST['upload'] == 'site') { if (strpos($_FILES['file']['name'], 'thesis-site-options') === false) { wp_redirect(admin_url('admin.php?page=options-manager&type=Site&error=wrongfile')); } elseif ($_FILES['file']['error'] > 0) { wp_redirect(admin_url('admin.php?page=options-manager&type=Site&error=file')); } else { $raw_options = file_get_contents($_FILES['file']['tmp_name']); $site_options = new thesis_site_options(); $site_options = unserialize($raw_options); if (is_object($site_options)) { update_option('thesis_options', $site_options); } #wp if (function_exists('wp_cache_clean_cache')) { #wp global $file_prefix; wp_cache_clean_cache($file_prefix); } wp_redirect(admin_url('admin.php?page=options-manager&imported=true&type=Site')); #wp } } elseif ($_POST['upload'] == 'design') { if (strpos($_FILES['file']['name'], 'thesis-design-options') === false) { wp_redirect(admin_url('admin.php?page=options-manager&type=Design&error=wrongfile')); } elseif ($_FILES['file']['error'] > 0) { wp_redirect(admin_url('admin.php?page=options-manager&type=Design&error=file')); } else { $raw_options = file_get_contents($_FILES['file']['tmp_name']); $design_options = new thesis_design_options(); $design_options = unserialize($raw_options); if (is_object($design_options)) { update_option('thesis_design_options', $design_options); } #wp if (function_exists('wp_cache_clean_cache')) { #wp global $file_prefix; wp_cache_clean_cache($file_prefix); } thesis_generate_css(); wp_redirect(admin_url('admin.php?page=options-manager&imported=true&type=Design')); #wp } } elseif ($_POST['upload'] == 'pages') { if (strpos($_FILES['file']['name'], 'thesis-page-options') === false) { wp_redirect(admin_url('admin.php?page=options-manager&type=Page&error=wrongfile')); } elseif ($_FILES['file']['error'] > 0) { wp_redirect(admin_url('admin.php?page=options-manager&type=Page&error=file')); } else { $raw_options = file_get_contents($_FILES['file']['tmp_name']); $page_options = new thesis_page_options(); $page_options = unserialize($raw_options); if (is_object($page_options)) { update_option('thesis_pages', $page_options); } #wp if (function_exists('wp_cache_clean_cache')) { #wp global $file_prefix; wp_cache_clean_cache($file_prefix); } thesis_generate_css(); wp_redirect(admin_url('admin.php?page=options-manager&imported=true&type=Page')); #wp } } elseif ($_POST['upload'] == 'all') { if (strpos($_FILES['file']['name'], 'thesis-all-options') === false) { wp_redirect(admin_url('admin.php?page=options-manager&type=All&error=wrongfile')); } elseif ($_FILES['file']['error'] > 0) { wp_redirect(admin_url('admin.php?page=options-manager&type=All&error=file')); } else { $raw_options = file_get_contents($_FILES['file']['tmp_name']); $all_options = unserialize($raw_options); $site_options = new thesis_site_options(); $design_options = new thesis_design_options(); $page_options = new thesis_page_options(); $site_options = $all_options['site_options']; $design_options = $all_options['design_options']; $page_options = $all_options['page_options']; if (is_object($site_options)) { update_option('thesis_options', $site_options); } #wp if (is_object($design_options)) { update_option('thesis_design_options', $design_options); } #wp if (is_object($page_options)) { update_option('thesis_pages', $page_options); } #wp if (function_exists('wp_cache_clean_cache')) { #wp global $file_prefix; wp_cache_clean_cache($file_prefix); #wp } thesis_generate_css(); wp_redirect(admin_url('admin.php?page=options-manager&imported=true&type=All')); #wp } } } }
function upgrade_options() { $page_options = new thesis_page_options(); $default_options = new thesis_page_options(); $page_options->get_options(); $default_options->default_options(); foreach ($default_options as $option_name => $value) { if (!isset($page_options->{$option_name})) { $page_options->{$option_name} = $default_options->{$option_name}; } } update_option('thesis_pages', $page_options); }