$_REQUEST['redirect_to']), site_url('/wp-login.php', 'login_post')); } } function openid_login_errors() { $self = basename( $GLOBALS['pagenow'] ); if ($self != 'wp-login.php') return; if ($_REQUEST['openid_error']) { global $error; $error = $_REQUEST['openid_error']; } if ($_REQUEST['registration_closed']) { global $error; $error = __('OpenID authentication valid, but unable to find a WordPress account associated with this OpenID.', 'openid') . '

' . __('Enable "Anyone can register" to allow creation of new accounts via OpenID.', 'openid'); } } function openid_wp_login_head() { openid_style(); wp_enqueue_script('jquery.xpath', openid_plugin_url() . '/f/jquery.xpath.min.js', array('jquery'), OPENID_PLUGIN_REVISION); wp_print_scripts(array('jquery.xpath')); } /** * Add OpenID input field to wp-login.php * * @action: login_form **/ function openid_wp_login_form() { global $wp_version; echo '
'; echo '

'.__('What is OpenID?', 'openid').'

'; } /** * Add information about registration to wp-login.php?action=register * * @action: register_form **/ function openid_wp_register_form() { global $wp_version; if (get_option('openid_required_for_registration')) { $label = __('Register using an OpenID:', 'openid'); echo ' '; } else { $label = __('Or register using an OpenID:', 'openid'); echo '
'; echo ' '; } echo '

'.__('What is OpenID?', 'openid').'

'; } /** * Action method for completing the 'login' action. This action is used when a user is logging in from * wp-login.php. * * @param string $identity_url verified OpenID URL */ function openid_finish_login($identity_url) { if ($_REQUEST['action'] != 'login') return; $redirect_to = urldecode($_REQUEST['redirect_to']); if (empty($identity_url)) { $url = get_option('siteurl') . '/wp-login.php?openid_error=' . urlencode(openid_message()); wp_safe_redirect($url); exit; } openid_set_current_user($identity_url); if (!is_user_logged_in()) { if ( get_option('users_can_register') ) { $user_data =& openid_get_user_data($identity_url); $user = openid_create_new_user($identity_url, $user_data); openid_set_current_user($user->ID); } else { // TODO - Start a registration loop in WPMU. $url = get_option('siteurl') . '/wp-login.php?registration_closed=1'; wp_safe_redirect($url); exit; } } if (empty($redirect_to)) { $redirect_to = 'wp-admin/'; } if ($redirect_to == 'wp-admin/') { if (!current_user_can('edit_posts')) { $redirect_to .= 'profile.php'; } } if (!preg_match('#^(http|\/)#', $redirect_to)) { $wpp = parse_url(get_option('siteurl')); $redirect_to = $wpp['path'] . '/' . $redirect_to; } wp_safe_redirect( $redirect_to ); exit; } /** * Intercept login requests on wp-login.php if they include an 'openid_identifier' * value and start OpenID authentication. This hook is only necessary in * WordPress 2.5.x because it has the 'wp_authenticate' action call in the * wrong place. */ function wp25_login_openid() { $self = basename( $GLOBALS['pagenow'] ); if ($self == 'wp-login.php' && !empty($_POST['openid_identifier'])) { wp_signon(array('user_login'=>'openid', 'user_password'=>'openid')); } } function openid_registration_errors($errors) { if (get_option('openid_required_for_registration')) { $errors = new WP_Error(); if (empty($_POST['openid_identifier'])) { $errors->add('openid_only', __('ERROR: ', 'openid') . __('New users must register using OpenID.', 'openid')); } } if (!empty($_POST['openid_identifier'])) { $errors->add('invalid_openid', __('ERROR: ', 'openid') . openid_message()); } return $errors; } function openid_register_post($errors) { if (!empty($_POST['openid_identifier'])) { wp_signon(array('user_login'=>'openid', 'user_password'=>'openid')); } } function openid_wp_login_return_url($urls) { $url = site_url('/wp-login.php', 'login_post'); $urls[] = $url; return $urls; } ?>