Beispiel #1
0
/**
 * Called on plugin activation and upgrading.
 *
 * @see register_activation_hook
 */
function openid_activate_plugin()
{
    global $wp_rewrite;
    // if first time activation, set OpenID capability for administrators
    if (get_option('openid_plugin_revision') === false) {
        global $wp_roles;
        $role = $wp_roles->get_role('administrator');
        if ($role) {
            $role->add_cap('use_openid_provider');
        }
    }
    // for some reason, show_on_front is not always set, causing is_front_page() to fail
    $show_on_front = get_option('show_on_front');
    if (empty($show_on_front)) {
        update_option('show_on_front', 'posts');
    }
    // Add custom OpenID options
    add_option('openid_enable_commentform', true);
    add_option('openid_plugin_enabled', true);
    add_option('openid_plugin_revision', 0);
    add_option('openid_db_revision', 0);
    add_option('openid_enable_approval', false);
    add_option('openid_xrds_returnto', true);
    add_option('openid_comment_displayname_length', 12);
    openid_create_tables();
    openid_migrate_old_data();
    // setup schedule cleanup
    wp_clear_scheduled_hook('cleanup_openid');
    wp_schedule_event(time(), 'hourly', 'cleanup_openid');
    // flush rewrite rules
    if (!isset($wp_rewrite)) {
        $wp_rewrite = new WP_Rewrite();
    }
    $wp_rewrite->flush_rules();
    // set current revision
    update_option('openid_plugin_revision', OPENID_PLUGIN_REVISION);
    openid_remove_historical_options();
}
function wpi_flush_rewrite_rules()
{
    global $wp_rewrite;
    $wp_rewrite = new WP_Rewrite();
    $wp_rewrite->flush_rules();
}