Esempio n. 1
0
/**
 * Update Genesis to the latest version.
 *
 * This iterative update function will take a Genesis installation, no matter
 * how old, and update its options to the latest version.
 *
 * It used to iterate over theme version, but now uses a database version
 * system, which allows for changes within pre-releases, too.
 *
 * @since 1.0.1
 *
 * @uses _genesis_vestige()
 * @uses genesis_get_option()     Get theme setting value.
 * @uses genesis_get_seo_option() Get SEO setting value.
 * @uses genesis_upgrade_1700()
 * @uses genesis_upgrade_1800()
 * @uses genesis_upgrade_1901()
 * @uses genesis_upgrade_2001()
 * @uses genesis_upgrade_2003()
 * @uses PARENT_DB_VERSION
 * @uses GENESIS_SETTINGS_FIELD
 * @uses GENESIS_SEO_SETTINGS_FIELD
 *
 * @return null Return early if we're already on the latest version.
 */
function genesis_upgrade()
{
    //* Don't do anything if we're on the latest version
    if (genesis_get_option('db_version', null, false) >= PARENT_DB_VERSION) {
        return;
    }
    #########################
    # UPDATE TO VERSION 1.0.1
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.0.1', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('nav_home' => 1, 'nav_twitter_text' => 'Follow me on Twitter', 'subnav_home' => 1, 'theme_version' => '1.0.1');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    #########################
    # UPDATE TO VERSION 1.1
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.1', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('content_archive_thumbnail' => genesis_get_option('thumbnail'), 'theme_version' => '1.1');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    #########################
    # UPDATE TO VERSION 1.1.2
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.1.2', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('header_right' => genesis_get_option('header_full') ? 0 : 1, 'nav_superfish' => 1, 'subnav_superfish' => 1, 'nav_extras_enable' => genesis_get_option('nav_right') ? 1 : 0, 'nav_extras' => genesis_get_option('nav_right'), 'nav_extras_twitter_id' => genesis_get_option('twitter_id'), 'nav_extras_twitter_text' => genesis_get_option('nav_twitter_text'), 'theme_version' => '1.1.2');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    #########################
    # UPDATE TO VERSION 1.2
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.2', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('update' => 1, 'theme_version' => '1.2');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    #########################
    # UPDATE TO VERSION 1.3
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.3', '<')) {
        //* Update theme settings
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('author_box_single' => genesis_get_option('author_box'), 'theme_version' => '1.3');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
        //* Update SEO settings
        $seo_settings = get_option(GENESIS_SEO_SETTINGS_FIELD);
        $new_settings = array('noindex_cat_archive' => genesis_get_seo_option('index_cat_archive') ? 0 : 1, 'noindex_tag_archive' => genesis_get_seo_option('index_tag_archive') ? 0 : 1, 'noindex_author_archive' => genesis_get_seo_option('index_author_archive') ? 0 : 1, 'noindex_date_archive' => genesis_get_seo_option('index_date_archive') ? 0 : 1, 'noindex_search_archive' => genesis_get_seo_option('index_search_archive') ? 0 : 1, 'noodp' => 1, 'noydir' => 1, 'canonical_archives' => 1);
        $settings = wp_parse_args($new_settings, $seo_settings);
        update_option(GENESIS_SEO_SETTINGS_FIELD, $settings);
        //* Delete the store transient, force refresh
        delete_transient('genesis-remote-store');
    }
    #########################
    # UPDATE TO VERSION 1.6
    #########################
    if (version_compare(genesis_get_option('theme_version', null, false), '1.6', '<')) {
        //* Vestige nav settings, for backward compatibility
        if ('nav-menu' !== genesis_get_option('nav_type')) {
            _genesis_vestige(array('nav_type', 'nav_superfish', 'nav_home', 'nav_pages_sort', 'nav_categories_sort', 'nav_depth', 'nav_exclude', 'nav_include'));
        }
        //* Vestige subnav settings, for backward compatibility
        if ('nav-menu' !== genesis_get_option('subnav_type')) {
            _genesis_vestige(array('subnav_type', 'subnav_superfish', 'subnav_home', 'subnav_pages_sort', 'subnav_categories_sort', 'subnav_depth', 'subnav_exclude', 'subnav_include'));
        }
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('theme_version' => '1.6');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    ###########################
    # UPDATE DB TO VERSION 1700
    ###########################
    if (genesis_get_option('db_version', null, false) < '1700') {
        genesis_upgrade_1700();
    }
    ###########################
    # UPDATE DB TO VERSION 1800
    ###########################
    if (genesis_get_option('db_version', null, false) < '1800') {
        genesis_upgrade_1800();
    }
    ###########################
    # UPDATE DB TO VERSION 1901
    ###########################
    if (genesis_get_option('db_version', null, false) < '1901') {
        genesis_upgrade_1901();
    }
    ###########################
    # UPDATE DB TO VERSION 2001
    ###########################
    if (genesis_get_option('db_version', null, false) < '2001') {
        genesis_upgrade_2001();
    }
    ###########################
    # UPDATE DB TO VERSION 2003
    ###########################
    if (genesis_get_option('db_version', null, false) < '2003') {
        genesis_upgrade_2003();
    }
    ###########################
    # UPDATE DB TO VERSION 2100
    ###########################
    if (genesis_get_option('db_version', null, false) < '2100') {
        genesis_upgrade_2100();
    }
    ###########################
    # UPDATE DB TO VERSION 2201
    ###########################
    if (genesis_get_option('db_version', null, false) < '2201') {
        genesis_upgrade_2201();
    }
    ###########################
    # UPDATE DB TO VERSION 2205
    ###########################
    if (genesis_get_option('db_version', null, false) < '2205') {
        genesis_upgrade_2205();
    }
    do_action('genesis_upgrade');
}
Esempio n. 2
0
/**
 * Update Genesis to the latest version.
 *
 * This iterative update function will take a Genesis installation, no matter
 * how old, and update its options to the latest version.
 *
 * It used to iterate over theme version, but now uses a database version
 * system, which allows for changes within pre-releases, too.
 *
 * @since 1.0.1
 *
 * @return null Return early if we're already on the latest version.
 */
function genesis_upgrade()
{
    // Don't do anything if we're on the latest version.
    if (genesis_get_option('db_version', null, false) >= PARENT_DB_VERSION) {
        return;
    }
    global $wp_db_version;
    // If the WP db hasn't been upgraded, make them upgrade first.
    if (get_option('db_version') != $wp_db_version) {
        wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(wp_unslash($_SERVER['REQUEST_URI']))));
        exit;
    }
    // UPDATE TO VERSION 1.0.1.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.0.1', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('nav_home' => 1, 'nav_twitter_text' => 'Follow me on Twitter', 'subnav_home' => 1, 'theme_version' => '1.0.1');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    // UPDATE TO VERSION 1.1.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.1', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('content_archive_thumbnail' => genesis_get_option('thumbnail'), 'theme_version' => '1.1');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    // UPDATE TO VERSION 1.1.2.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.1.2', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('header_right' => genesis_get_option('header_full') ? 0 : 1, 'nav_superfish' => 1, 'subnav_superfish' => 1, 'nav_extras_enable' => genesis_get_option('nav_right') ? 1 : 0, 'nav_extras' => genesis_get_option('nav_right'), 'nav_extras_twitter_id' => genesis_get_option('twitter_id'), 'nav_extras_twitter_text' => genesis_get_option('nav_twitter_text'), 'theme_version' => '1.1.2');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    // UPDATE TO VERSION 1.2.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.2', '<')) {
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('update' => 1, 'theme_version' => '1.2');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    // UPDATE TO VERSION 1.3.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.3', '<')) {
        // Update theme settings.
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('author_box_single' => genesis_get_option('author_box'), 'theme_version' => '1.3');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
        // Update SEO settings.
        $seo_settings = get_option(GENESIS_SEO_SETTINGS_FIELD);
        $new_settings = array('noindex_cat_archive' => genesis_get_seo_option('index_cat_archive') ? 0 : 1, 'noindex_tag_archive' => genesis_get_seo_option('index_tag_archive') ? 0 : 1, 'noindex_author_archive' => genesis_get_seo_option('index_author_archive') ? 0 : 1, 'noindex_date_archive' => genesis_get_seo_option('index_date_archive') ? 0 : 1, 'noindex_search_archive' => genesis_get_seo_option('index_search_archive') ? 0 : 1, 'noodp' => 1, 'noydir' => 1, 'canonical_archives' => 1);
        $settings = wp_parse_args($new_settings, $seo_settings);
        update_option(GENESIS_SEO_SETTINGS_FIELD, $settings);
        // Delete the store transient, force refresh.
        delete_transient('genesis-remote-store');
    }
    // UPDATE TO VERSION 1.6.
    if (version_compare(genesis_get_option('theme_version', null, false), '1.6', '<')) {
        // Vestige nav settings, for backward compatibility.
        if ('nav-menu' !== genesis_get_option('nav_type')) {
            _genesis_vestige(array('nav_type', 'nav_superfish', 'nav_home', 'nav_pages_sort', 'nav_categories_sort', 'nav_depth', 'nav_exclude', 'nav_include'));
        }
        // Vestige subnav settings, for backward compatibility.
        if ('nav-menu' !== genesis_get_option('subnav_type')) {
            _genesis_vestige(array('subnav_type', 'subnav_superfish', 'subnav_home', 'subnav_pages_sort', 'subnav_categories_sort', 'subnav_depth', 'subnav_exclude', 'subnav_include'));
        }
        $theme_settings = get_option(GENESIS_SETTINGS_FIELD);
        $new_settings = array('theme_version' => '1.6');
        $settings = wp_parse_args($new_settings, $theme_settings);
        update_option(GENESIS_SETTINGS_FIELD, $settings);
    }
    // UPDATE DB TO VERSION 1700.
    if (genesis_get_option('db_version', null, false) < '1700') {
        genesis_upgrade_1700();
    }
    // UPDATE DB TO VERSION 1800.
    if (genesis_get_option('db_version', null, false) < '1800') {
        genesis_upgrade_1800();
    }
    // UPDATE DB TO VERSION 1901.
    if (genesis_get_option('db_version', null, false) < '1901') {
        genesis_upgrade_1901();
    }
    // UPDATE DB TO VERSION 2001.
    if (genesis_get_option('db_version', null, false) < '2001') {
        genesis_upgrade_2001();
    }
    // UPDATE DB TO VERSION 2003.
    if (genesis_get_option('db_version', null, false) < '2003') {
        genesis_upgrade_2003();
    }
    // UPDATE DB TO VERSION 2100.
    if (genesis_get_option('db_version', null, false) < '2100') {
        genesis_upgrade_2100();
    }
    // UPDATE DB TO VERSION 2201.
    if (genesis_get_option('db_version', null, false) < '2201') {
        genesis_upgrade_2201();
    }
    // UPDATE DB TO VERSION 2207.
    if (genesis_get_option('db_version', null, false) < '2207') {
        genesis_upgrade_2207();
    }
    // UPDATE DB TO VERSION 2209.
    if (genesis_get_option('db_version', null, false) < '2209') {
        genesis_upgrade_2209();
    }
    // UPDATE DB TO VERSION 2403.
    if (genesis_get_option('db_version', null, false) < '2403') {
        genesis_upgrade_2403();
    }
    do_action('genesis_upgrade');
}