示例#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`)");
    }
}
示例#2
0
        yarpp_set_option('title', 1);
        yarpp_set_option('body', 1);
        $yarpp_myisam = false;
    }
}
$yarpp_twopointfive = true;
if (version_compare('2.5', $wp_version) > 0) {
    echo "{$wp_version}<div class='updated'>The \"consider tags\" and \"consider categories\" options require WordPress version 2.5. These two options have been disabled.</div>";
    yarpp_set_option('categories', 1);
    yarpp_set_option('tags', 1);
    $yarpp_twopointfive = false;
}
if ($yarpp_myisam) {
    if (!yarpp_enabled()) {
        echo '<div class="updated"><p>';
        if (yarpp_activate()) {
            _e('The YARPP database had an error but has been fixed.', 'yarpp');
        } else {
            __('The YARPP database has an error which could not be fixed.', 'yarpp') . str_replace('<A>', '<a href=\'http://mitcho.com/code/yarpp/sql.php?prefix=' . urlencode($wpdb->prefix) . '\'>', __('Please try <A>manual SQL setup</a>.', 'yarpp'));
        }
        echo '</div></p>';
    }
}
yarpp_reinforce();
// just in case, set default options, etc.
if (isset($_POST['update_yarpp'])) {
    foreach (array_keys($yarpp_value_options) as $option) {
        if (is_string($_POST[$option])) {
            yarpp_set_option($option, addslashes($_POST[$option]));
        }
    }
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`)");
    }
}