本文整理汇总了PHP中user_admin_url函数的典型用法代码示例。如果您正苦于以下问题:PHP user_admin_url函数的具体用法?PHP user_admin_url怎么用?PHP user_admin_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_admin_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize()
{
$this->user = new stdClass();
if (is_user_logged_in()) {
/* Populate settings we need for the menu based on the current user. */
$this->user->blogs = get_blogs_of_user(get_current_user_id());
if (is_multisite()) {
$this->user->active_blog = get_active_blog_for_user(get_current_user_id());
$this->user->domain = empty($this->user->active_blog) ? user_admin_url() : trailingslashit(get_home_url($this->user->active_blog->blog_id));
$this->user->account_domain = $this->user->domain;
} else {
$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
$this->user->domain = trailingslashit(home_url());
$this->user->account_domain = $this->user->domain;
}
}
add_action('wp_head', 'wp_admin_bar_header');
add_action('admin_head', 'wp_admin_bar_header');
if (current_theme_supports('admin-bar')) {
$admin_bar_args = get_theme_support('admin-bar');
// add_theme_support( 'admin-bar', array( 'callback' => '__return_false') );
$header_callback = $admin_bar_args[0]['callback'];
}
if (empty($header_callback)) {
$header_callback = '_admin_bar_bump_cb';
}
add_action('wp_head', $header_callback);
wp_enqueue_script('admin-bar');
wp_enqueue_style('admin-bar');
do_action('admin_bar_init');
}
示例2: otl_authenticate_one_time_login
/**
* Process one time login
*
* @since 1.0.0
*
* @return void
*/
function otl_authenticate_one_time_login()
{
// No need to run if not a singular query for the one time login
if (!is_single()) {
return;
}
// No need to run if not a onetimelogin post
global $post;
if ('onetimelogin' !== $post->post_type) {
return;
}
$user_id = get_post_meta(get_the_ID(), 'otl_user', true);
$valid_user = get_userdata($user_id) ? true : false;
$login_uses = get_post_meta(get_the_ID(), 'otl_times_used', true);
// If the one time login is unused and the user is valid, log in
if ('0' === $login_uses && $valid_user) {
// Log in
wp_clear_auth_cookie();
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
// Update some meta for logging and to prevent multiple uses
update_post_meta(get_the_ID(), 'otl_times_used', '1');
update_post_meta(get_the_ID(), 'otl_datetime_used', current_time('mysql'));
// Redirect to wp-admin
wp_safe_redirect(user_admin_url());
exit;
} else {
wp_redirect(home_url());
exit;
}
return;
}
示例3: getParams
/**
* Generate the parameters for the raas plugin.
* @return array
*/
public function getParams()
{
// Parameters to be sent to the DOM.
$params = array('actionRaas' => 'gigya_raas', 'redirect' => user_admin_url(), 'canEditUsers' => current_user_can('edit_users'), 'raasWebScreen' => _gigParam($this->login_options, 'raasWebScreen', 'Default-RegistrationLogin'), 'raasMobileScreen' => _gigParam($this->login_options, 'raasMobileScreen', 'DefaultMobile-RegistrationLogin'), 'raasLoginScreen' => _gigParam($this->login_options, 'raasLoginScreen', 'gigya-login-screen'), 'raasRegisterScreen' => _gigParam($this->login_options, 'raasRegisterScreen', 'gigya-register-screen'), 'raasProfileWebScreen' => _gigParam($this->login_options, 'raasProfileWebScreen', 'Default-ProfileUpdate'), 'raasProfileMobileScreen' => _gigParam($this->login_options, 'raasProfileMobileScreen', 'DefaultMobile-ProfileUpdate'), 'raasOverrideLinks' => _gigParamDefaultOn($this->login_options, 'raasOverrideLinks'), 'raasLoginDiv' => _gigParam($this->login_options, 'raasLoginDiv', 'loginform'), 'raasRegisterDiv' => _gigParam($this->login_options, 'raasRegisterDiv', 'registerform'), 'raasProfileDiv' => _gigParam($this->login_options, 'raasProfileDiv', 'profile-page'));
// Let others plugins to modify the raas parameters.
$params = apply_filters('gigya_raas_params', $params);
return $params;
}
示例4: self_admin_url
function self_admin_url($path = '', $scheme = 'admin')
{
if (defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN) {
return network_admin_url($path, $scheme);
} elseif (defined('WP_USER_ADMIN') && WP_USER_ADMIN) {
return user_admin_url($path, $scheme);
} else {
return admin_url($path, $scheme);
}
}
示例5: thatcamp_edit_profile_url
function thatcamp_edit_profile_url($url)
{
$path = 'profile.php';
$scheme = 'admin';
$active = get_active_blog_for_user(get_current_user_id());
if ($active) {
$url = get_admin_url($active->blog_id, $path, $scheme);
} else {
$url = user_admin_url($path, $scheme);
}
return $url;
}
示例6: initialize
/**
* @access public
*/
public function initialize() {
$this->user = new stdClass;
if ( is_user_logged_in() ) {
/* Populate settings we need for the menu based on the current user. */
$this->user->blogs = get_blogs_of_user( get_current_user_id() );
if ( is_multisite() ) {
$this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
$this->user->account_domain = $this->user->domain;
} else {
$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
$this->user->domain = trailingslashit( home_url() );
$this->user->account_domain = $this->user->domain;
}
}
add_action( 'wp_head', 'wp_admin_bar_header' );
add_action( 'admin_head', 'wp_admin_bar_header' );
if ( current_theme_supports( 'admin-bar' ) ) {
/**
* To remove the default padding styles from WordPress for the Toolbar, use the following code:
* add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
*/
$admin_bar_args = get_theme_support( 'admin-bar' );
$header_callback = $admin_bar_args[0]['callback'];
}
if ( empty($header_callback) )
$header_callback = '_admin_bar_bump_cb';
add_action('wp_head', $header_callback);
wp_enqueue_script( 'admin-bar' );
wp_enqueue_style( 'admin-bar' );
/**
* Fires after WP_Admin_Bar is initialized.
*
* @since 3.1.0
*/
do_action( 'admin_bar_init' );
}
示例7: getParams
/**
* Generate the parameters for the login plugin.
* @return array
*/
public function getParams()
{
// Parameters to be sent to the DOM.
$params = array('actionLogin' => 'gigya_login', 'actionCustomLogin' => 'custom_login', 'redirect' => _gigParam($this->login_options, 'redirect', user_admin_url()));
$params['ui'] = array();
$params['ui']['showTermsLink'] = false;
$params['ui']['version'] = 2;
if (!empty($this->login_options['width'])) {
$params['ui']['width'] = $this->login_options['width'];
}
if (!empty($this->login_options['height'])) {
$params['ui']['height'] = $this->login_options['height'];
}
if (!empty($this->login_options['showTermsLink'])) {
$params['ui']['showTermsLink'] = $this->login_options['showTermsLink'];
}
if (!empty($this->login_options['enabledProviders'])) {
$params['ui']['enabledProviders'] = $this->login_options['enabledProviders'];
}
if (!empty($this->login_options['buttonsStyle'])) {
$params['ui']['buttonsStyle'] = $this->login_options['buttonsStyle'];
}
if (!empty($this->login_options['advancedLoginUI'])) {
$arr = gigyaCMS::parseJSON($this->login_options['advancedLoginUI']);
if (!empty($arr)) {
foreach ($arr as $key => $val) {
$params['ui'][$key] = $val;
}
}
}
if (!empty($this->login_options['advancedAddConnectionsUI'])) {
$arr = gigyaCMS::parseJSON($this->login_options['advancedAddConnectionsUI']);
if (!empty($arr)) {
foreach ($arr as $key => $val) {
$params['addConnection'][$key] = $val;
}
}
}
// Let others plugins to modify the login parameters.
$params = apply_filters('gigya_login_params', $params);
return $params;
}
示例8: getContent
/**
* @param $args
* @param $instance
*
* @return string
*/
public function getContent($args, $instance)
{
$output = '';
$title = apply_filters('widget_title', $instance['title']);
// Get the data from the argument.
// require_once GIGYA__PLUGIN_DIR . 'features/login/GigyaRaasSet.php';
// $raas = new GigyaLoginSet();
// $data = $raas->getParams();
//
// // Override params or take the defaults.
// if ( ! empty( $instance['override'] ) ) {
// foreach ( $instance as $key => $value ) {
// if ( ! empty( $value ) ) {
// $data['ui'][$key] = esc_attr( $value );
// }
// }
// }
// Set the output.
$output .= $args['before_widget'];
if (!empty($title)) {
$output .= $args['before_title'] . $title . $args['after_title'];
}
if (!is_user_logged_in()) {
$output .= '<div class="gigya-raas-widget">';
$output .= '<a href="wp-login.php">' . __('Login') . '</a> | ';
$output .= '<a href="wp-login.php?action=register">' . __('Register') . '</a>';
$output .= '</div>';
} else {
$current_user = wp_get_current_user();
$output .= '<div class="gigya-wp-account-widget">';
$output .= '<a class="gigya-wp-avatar" href="' . user_admin_url('profile.php') . '">' . get_avatar($current_user->ID) . '</a>';
$output .= '<div class="gigya-wp-info">';
$output .= '<a class="gigya-wp-name" href="' . user_admin_url('profile.php') . '">' . $current_user->display_name . '</a>';
$output .= '<a class="gigya-wp-logout" href="' . wp_logout_url() . '">' . __('Log Out') . '</a>';
$output .= '</div></div>';
}
$output .= $args['after_widget'];
return $output;
}
示例9: getContent
/**
* @param $args
* @param $instance
*
* @return string
*/
public function getContent($args, $instance)
{
$output = '';
$title = apply_filters('widget_title', $instance['title']);
// Get the data from the argument.
require_once GIGYA__PLUGIN_DIR . 'features/login/GigyaLoginSet.php';
$login = new GigyaLoginSet();
$data = $login->getParams();
// Override params or take the defaults.
if (!empty($instance['override'])) {
foreach ($instance as $key => $value) {
if (!empty($value)) {
$data['ui'][$key] = esc_attr($value);
}
}
}
// Set the output.
$output .= $args['before_widget'];
if (!empty($title)) {
$output .= $args['before_title'] . $title . $args['after_title'];
}
if (!is_user_logged_in()) {
$output .= '<div class="gigya-login-widget"></div>';
$output .= '<script class="data-login" type="application/json">' . json_encode($data) . '</script>';
} else {
$current_user = wp_get_current_user();
$output .= '<div class="gigya-wp-account-widget">';
$output .= '<a class="gigya-wp-avatar" href="' . user_admin_url('profile.php') . '">' . get_avatar($current_user->ID) . '</a>';
$output .= '<div class="gigya-wp-info">';
$output .= '<a class="gigya-wp-name" href="' . user_admin_url('profile.php') . '">' . $current_user->display_name . '</a>';
$output .= '<a class="gigya-wp-logout" href="' . wp_logout_url() . '">' . __('Log Out') . '</a>';
$output .= '</div></div>';
}
$output .= $args['after_widget'];
return $output;
}
示例10: login
/**
* Login user. SSL support is not tested.
*/
public function login()
{
global $json_api;
$secure_cookie = '';
// If the user wants ssl but the session is not ssl, force a secure cookie.
if (!empty($_POST['log']) && !force_ssl_admin()) {
$user_name = sanitize_user($_POST['log']);
if ($user = get_user_by('login', $user_name)) {
// i'm guessing the user can change their login options to work with SSL
if (get_user_option('use_ssl', $user->ID)) {
$secure_cookie = true;
//passing true to like so, force_ssl_admin(true), makes force_ssl_admin() return true and vice versa
//force_ssl_admin(true); http://codex.wordpress.org/Function_Reference/force_ssl_admin
// we are declaring error but not returning it for now
$errors = new WP_Error();
$errors->add('use_ssl', __("The login must use ssl."));
// not implemeted now
//return $errors;
}
}
}
if (isset($_REQUEST['redirect_to'])) {
$redirect_to = $_REQUEST['redirect_to'];
// Redirect to https if user wants ssl
if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
}
} else {
$redirect_to = admin_url();
}
$reauth = empty($_REQUEST['reauth']) ? false : true;
// If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
// cookie and redirect back to the referring non-secure admin page. This allows logins to always be POSTed over SSL while allowing the user to choose visiting
// the admin via http or https.
if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
$secure_cookie = false;
}
//$user = wp_authenticate_username_password('', $_POST['log'], $_POST['pwd']);
$user = wp_signon('', $secure_cookie);
if (is_wp_error($user)) {
// user is an error object
$errors = $user;
// if both login and password are empty no error is added so we add one now
if (empty($_POST['log']) && empty($_POST['pwd'])) {
$errors->add('invalid_username', __("The username is empty."));
}
// Clear errors if loggedout is set.
if (!empty($_GET['loggedout']) || $reauth) {
$errors = new WP_Error();
}
// If cookies are disabled we can't log in even with a valid user+pass
if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) {
$errors->add('test_cookie', __("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
}
// Some parts of this script use the main login form to display a message
if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
$errors->add('loggedout', __('You are now logged out.'), 'message');
} elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
$errors->add('registerdisabled', __('User registration is currently not allowed.'));
} elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
$errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
} elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
$errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
} elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
$errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
} elseif ($interim_login) {
$errors->add('expired', __('Your session has expired. Please log-in again.'), 'message');
}
// Clear any stale cookies.
if ($reauth) {
wp_clear_auth_cookie();
}
return $errors;
}
//if (!$reauth) {
// does not redirect
if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
// If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
$redirect_to = user_admin_url();
} elseif (is_multisite() && !$user->has_cap('read')) {
$redirect_to = get_dashboard_url($user->ID);
} elseif (!$user->has_cap('edit_posts')) {
$redirect_to = admin_url('profile.php');
}
}
wp_set_current_user($user->ID);
$user = $this->get_logged_in_user();
// left in redirect_to since we could return the value later if we wanted
return $user;
//}
}
示例11: get_edit_profile_url
/**
* Get the URL to the user's profile editor.
*
* @since 3.1.0
*
* @param int $user User ID
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Dashboard url link with optional path appended
*/
function get_edit_profile_url($user, $scheme = 'admin')
{
$user = (int) $user;
if (is_user_admin()) {
$url = user_admin_url('profile.php', $scheme);
} elseif (is_network_admin()) {
$url = network_admin_url('profile.php', $scheme);
} else {
$url = get_dashboard_url($user, 'profile.php', $scheme);
}
return apply_filters('edit_profile_url', $url, $user, $scheme);
}
示例12: test_get_dashboard_url_for_user_with_no_sites
/**
* @ticket 39065
*/
public function test_get_dashboard_url_for_user_with_no_sites()
{
add_filter('get_blogs_of_user', '__return_empty_array');
$expected = is_multisite() ? user_admin_url() : admin_url();
$this->assertEquals($expected, get_dashboard_url(self::$user_id));
}
示例13: test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite
/**
* @ticket 37949
* @group multisite
*/
public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite()
{
if (!is_multisite()) {
$this->markTestSkipped('Test only runs in multisite');
}
// User is not a member of a site.
remove_user_from_blog(self::$no_role_id, get_current_blog_id());
wp_set_current_user(self::$no_role_id);
$wp_admin_bar = $this->get_standard_admin_bar();
$wp_logo_node = $wp_admin_bar->get_node('wp-logo');
$about_node = $wp_admin_bar->get_node('about');
$this->assertNotNull($wp_logo_node);
$this->assertSame(user_admin_url('about.php'), $wp_logo_node->href);
$this->assertArrayNotHasKey('tabindex', $wp_logo_node->meta);
$this->assertNotNull($about_node);
}
示例14: template_redirect
//.........这里部分代码省略.........
case 'register':
if (!get_option('users_can_register')) {
$redirect_to = site_url('wp-login.php?registration=disabled');
wp_redirect($redirect_to);
exit;
}
$user_login = '';
$user_email = '';
if ($http_post) {
$user_login = $_POST['user_login'];
$user_email = $_POST['user_email'];
$this->errors = self::register_new_user($user_login, $user_email);
if (!is_wp_error($this->errors)) {
$redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : site_url('wp-login.php?checkemail=registered');
wp_safe_redirect($redirect_to);
exit;
}
}
break;
case 'login':
default:
$secure_cookie = '';
$interim_login = isset($_REQUEST['interim-login']);
// If the user wants ssl but the session is not ssl, force a secure cookie.
if (!empty($_POST['log']) && !force_ssl_admin()) {
$user_name = sanitize_user($_POST['log']);
if ($user = get_user_by('login', $user_name)) {
if (get_user_option('use_ssl', $user->ID)) {
$secure_cookie = true;
force_ssl_admin(true);
}
}
}
if (!empty($_REQUEST['redirect_to'])) {
$redirect_to = $_REQUEST['redirect_to'];
// Redirect to https if user wants ssl
if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
}
} else {
$redirect_to = admin_url();
}
$reauth = empty($_REQUEST['reauth']) ? false : true;
// If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
// cookie and redirect back to the referring non-secure admin page. This allows logins to always be POSTed over SSL while allowing the user to choose visiting
// the admin via http or https.
if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
$secure_cookie = false;
}
if ($http_post && isset($_POST['log'])) {
$user = wp_signon('', $secure_cookie);
$redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
if (!is_wp_error($user) && !$reauth) {
if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
// If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
$redirect_to = user_admin_url();
} elseif (is_multisite() && !$user->has_cap('read')) {
$redirect_to = get_dashboard_url($user->ID);
} elseif (!$user->has_cap('edit_posts')) {
$redirect_to = admin_url('profile.php');
}
}
wp_safe_redirect($redirect_to);
exit;
}
$this->errors = $user;
}
// Clear errors if loggedout is set.
if (!empty($_GET['loggedout']) || $reauth) {
$this->errors = new WP_Error();
}
// Some parts of this script use the main login form to display a message
if (isset($_GET['loggedout']) && true == $_GET['loggedout']) {
$this->errors->add('loggedout', __('You are now logged out.', 'theme-my-login'), 'message');
} elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
$this->errors->add('registerdisabled', __('User registration is currently not allowed.', 'theme-my-login'));
} elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
$this->errors->add('confirm', __('Check your e-mail for the confirmation link.', 'theme-my-login'), 'message');
} elseif (isset($_GET['resetpass']) && 'complete' == $_GET['resetpass']) {
$this->errors->add('password_reset', __('Your password has been reset.', 'theme-my-login'), 'message');
} elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
$this->errors->add('registered', __('Registration complete. Please check your e-mail.', 'theme-my-login'), 'message');
} elseif ($interim_login) {
$this->errors->add('expired', __('Your session has expired. Please log-in again.', 'theme-my-login'), 'message');
} elseif (strpos($redirect_to, 'about.php?updated')) {
$this->errors->add('updated', __('<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.', 'theme-my-login'), 'message');
} elseif ($reauth) {
$this->errors->add('reauth', __('Please log in to continue.', 'theme-my-login'), 'message');
}
// Clear any stale cookies.
if ($reauth) {
wp_clear_auth_cookie();
}
break;
}
// end switch
}
// endif has_filter()
}
示例15: pods_v
//.........这里部分代码省略.........
$scheme = $var[1];
}
} else {
$path = $var;
}
$output = network_home_url($path, $scheme);
break;
case 'network-admin-url':
$path = '';
$scheme = null;
if (is_array($var)) {
if (isset($var[0])) {
$path = $var[0];
} elseif (isset($var[1])) {
$scheme = $var[1];
}
} else {
$path = $var;
}
$output = network_admin_url($path, $scheme);
break;
case 'user-admin-url':
$path = '';
$scheme = null;
if (is_array($var)) {
if (isset($var[0])) {
$path = $var[0];
} elseif (isset($var[1])) {
$scheme = $var[1];
}
} else {
$path = $var;
}
$output = user_admin_url($path, $scheme);
break;
case 'prefix':
global $wpdb;
$output = $wpdb->prefix;
break;
case 'server':
if (!pods_strict()) {
if (isset($_SERVER[$var])) {
$output = pods_unslash($_SERVER[$var]);
} elseif (isset($_SERVER[strtoupper($var)])) {
$output = pods_unslash($_SERVER[strtoupper($var)]);
}
}
break;
case 'session':
if (isset($_SESSION[$var])) {
$output = $_SESSION[$var];
}
break;
case 'global':
case 'globals':
if (isset($GLOBALS[$var])) {
$output = $GLOBALS[$var];
}
break;
case 'cookie':
if (isset($_COOKIE[$var])) {
$output = pods_unslash($_COOKIE[$var]);
}
break;
case 'constant':
if (defined($var)) {