コード例 #1
0
ファイル: common.php プロジェクト: nxtclass/NXTClass-Plugin
/**
 * Called on plugin activation and upgrading.
 *
 * @see register_activation_hook
 */
function openid_activate_plugin()
{
    global $nxt_rewrite;
    // if first time activation, set OpenID capability for administrators
    if (get_option('openid_plugin_revision') === false) {
        global $nxt_roles;
        $role = $nxt_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
    nxt_clear_scheduled_hook('cleanup_openid');
    nxt_schedule_event(time(), 'hourly', 'cleanup_openid');
    // flush rewrite rules
    if (!isset($nxt_rewrite)) {
        $nxt_rewrite = new nxt_Rewrite();
    }
    $nxt_rewrite->flush_rules();
    // set current revision
    update_option('openid_plugin_revision', OPENID_PLUGIN_REVISION);
    openid_remove_historical_options();
}
コード例 #2
0
ファイル: common.php プロジェクト: alx/pressid
/**
 * Called on plugin activation.
 *
 * @see register_activation_hook
 */
function openid_activate_plugin()
{
    // 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');
        }
    }
    // 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_enable_email_mapping', false);
    add_option('openid_xrds_returnto', true);
    add_option('openid_xrds_idib', true);
    add_option('openid_xrds_eaut', true);
    openid_create_tables();
    openid_migrate_old_data();
    wp_schedule_event(time(), 'hourly', 'cleanup_openid');
    // cleanup old option names
    delete_option('oid_db_revision');
    delete_option('oid_db_version');
    delete_option('oid_enable_approval');
    delete_option('oid_enable_commentform');
    delete_option('oid_enable_email_mapping');
    delete_option('oid_enable_foaf');
    delete_option('oid_enable_localaccounts');
    delete_option('oid_enable_loginform');
    delete_option('oid_enable_selfstyle');
    delete_option('oid_enable_unobtrusive');
    delete_option('oid_plugin_enabled');
    delete_option('oid_plugin_revision');
    delete_option('oid_plugin_version');
    delete_option('oid_trust_root');
}