Example #1
0
function yarpp_upgrade_check($inuse = false)
{
    global $wpdb, $yarpp_value_options, $yarpp_binary_options;
    foreach (array_keys($yarpp_value_options) as $option) {
        if (get_option("yarpp_{$option}", YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT) {
            add_option("yarpp_{$option}", $yarpp_value_options[$option] . ' ');
        }
    }
    foreach (array_keys($yarpp_binary_options) as $option) {
        if (get_option("yarpp_{$option}", YARPP_UNLIKELY_DEFAULT) == YARPP_UNLIKELY_DEFAULT) {
            add_option("yarpp_{$option}", $yarpp_binary_options[$option]);
        }
    }
    // upgrade check
    if (get_option('threshold') and get_option('limit') and get_option('len')) {
        yarpp_activate();
        yarpp_upgrade_one_five();
        update_option('yarpp_version', '1.5');
    }
    if (version_compare('3.1.3', get_option('yarpp_version')) > 0) {
        $wpdb->query("ALTER TABLE {$wpdb->prefix}yarpp_related_cache DROP PRIMARY KEY ,\n                  ADD PRIMARY KEY ( score , date , reference_ID , ID )");
    }
    update_option('yarpp_version', YARPP_VERSION);
    // just in case, try to add the index one more time.
    if (!yarpp_enabled()) {
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_title` ( `post_title`)");
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_content` ( `post_content`)");
    }
}
function yarpp_upgrade_check($inuse = false)
{
    global $wpdb, $yarpp_value_options, $yarpp_binary_options;
    foreach (array_keys($yarpp_value_options) as $option) {
        if (!get_option("yarpp_{$option}") or get_option("yarpp_{$option}") == '') {
            add_option("yarpp_{$option}", $yarpp_value_options[$option] . ' ');
        }
    }
    foreach (array_keys($yarpp_binary_options) as $option) {
        if (!get_option("yarpp_{$option}") or get_option("yarpp_{$option}") == '') {
            add_option("yarpp_{$option}", $yarpp_binary_options[$option] . " ");
        }
    }
    // upgrade check
    if (get_option('threshold') and get_option('limit') and get_option('len')) {
        yarpp_activate();
        yarpp_upgrade_one_five();
        update_option('yarpp_version', '1.5');
    }
    if (get_option('yarpp_version') < 2) {
        foreach (array_keys($yarpp_value_options) as $option) {
            if (!get_option("yarpp_{$option}")) {
                add_option("yarpp_{$option}", $yarpp_value_options[$option] . ' ');
            }
        }
        foreach (array_keys($yarpp_binary_options) as $option) {
            if (!get_option("yarpp_{$option}")) {
                add_option("yarpp_{$option}", $yarpp_binary_options[$option]);
            }
        }
        if (!$inuse) {
            echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);">' . __('<h3>An important message from YARPP:</h3><p>Thank you for upgrading to YARPP 2. YARPP 2.0 adds the much requested ability to limit related entry results by certain tags or categories. 2.0 also brings more fine tuned control of the magic algorithm, letting you specify how the algorithm should consider or not consider entry content, titles, tags, and categories. Make sure to adjust the new settings to your liking and perhaps readjust your threshold.</p><p>For more information, check out the <a href="http://mitcho.com/code/yarpp/">YARPP documentation</a>. (This message will not be displayed again.)</p>', 'yarpp') . '</div>';
        }
    }
    if (get_option('yarpp_version') < 2.03) {
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_title` ( `post_title`)");
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_content` ( `post_content`)");
        update_option('yarpp_version', '2.03');
    }
    if (get_option('yarpp_version') < 2.16) {
        update_option('yarpp_version', '2.16');
    }
    // just in case, try to add the index one more time.
    if (!yarpp_enabled()) {
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_title` ( `post_title`)");
        $wpdb->query("ALTER TABLE {$wpdb->posts} ADD FULLTEXT `yarpp_content` ( `post_content`)");
    }
}