function thatcamp_modify_admin_bar($admin_bar)
{
    remove_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3);
    $admin_bar->add_node(array('id' => 'edit-profile', 'href' => get_edit_profile_url(get_current_user_id())));
    $admin_bar->add_node(array('id' => 'user-info', 'href' => get_edit_profile_url(get_current_user_id())));
    $admin_bar->add_node(array('id' => 'my-account', 'href' => get_edit_profile_url(get_current_user_id())));
    add_filter('edit_profile_url', 'bp_members_edit_profile_url', 10, 3);
    $admin_bar->add_node(array('id' => 'my-account-activity', 'title' => 'About Me'));
    $admin_bar->add_node(array('id' => 'my-account-groups', 'title' => 'My THATCamps'));
    $admin_bar->add_node(array('id' => 'my-account-friends', 'title' => 'My Friends'));
    $admin_bar->remove_node('my-account-activity-mentions');
    $admin_bar->remove_node('my-account-activity-personal');
    $admin_bar->remove_node('my-account-activity-favorites');
    $admin_bar->remove_node('my-account-activity-friends');
    $admin_bar->remove_node('my-account-activity-groups');
    $admin_bar->remove_node('my-account-blogs');
    $admin_bar->remove_node('my-account-forums');
    $admin_bar->remove_node('my-account-friends-friendships');
    $admin_bar->remove_node('my-account-friends-requests');
    $admin_bar->remove_node('my-account-groups-memberships');
    $admin_bar->remove_node('my-account-groups-invites');
    $admin_bar->remove_node('my-account-messages');
    $admin_bar->remove_node('my-account-settings');
    $admin_bar->remove_node('my-account-xprofile');
}
Exemple #2
0
function appthemes_get_edit_profile_url()
{
    if ($page_id = APP_User_Profile::get_id()) {
        return get_permalink($page_id);
    }
    return get_edit_profile_url(get_current_user_id());
}
function appthemes_get_edit_profile_url()
{
    if ($page_id = APP_Page_Template::get_id('edit-profile.php')) {
        return get_permalink($page_id);
    }
    return get_edit_profile_url(get_current_user_id());
}
Exemple #4
0
 public function get_value($id)
 {
     $user_id = $this->get_raw_value($id);
     if (!$user_id) {
         return false;
     }
     $display_name = $this->get_display_name($user_id);
     if ($edit_link = get_edit_profile_url($user_id)) {
         $display_name = '<a href="' . $edit_link . ' ">' . $display_name . '</a>';
     }
     return $display_name;
 }
function tf_change_howdy($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if ($user_id != 0) {
        $avatar = get_avatar($user_id, 28);
        $howdy = sprintf(__('Welcome, %1$s'), $current_user->display_name);
        $class = empty($avatar) ? '' : 'with-avatar';
        $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
    }
}
Exemple #6
0
function wp_admin_bar_my_custom_account_menu($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (0 != $user_id) {
        /* Add the "My Account" menu */
        $avatar = get_avatar($user_id, 28);
        $howdy = sprintf(__('สวัสดี, %1$s'), $current_user->display_name);
        $class = empty($avatar) ? '' : 'with-avatar';
        $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
    }
}
Exemple #7
0
/**
 * Add the "My Account" menu and all submenus.
 *
 * @since 3.1.0
 */
function wp_admin_bar_my_account_menu($wp_admin_bar)
{
    global $user_identity;
    $user_id = get_current_user_id();
    if (0 != $user_id) {
        /* Add the 'My Account' menu */
        $avatar = get_avatar(get_current_user_id(), 16);
        $id = !empty($avatar) ? 'my-account-with-avatar' : 'my-account';
        $wp_admin_bar->add_menu(array('id' => $id, 'title' => $avatar . $user_identity, 'href' => get_edit_profile_url($user_id)));
        /* Add the "My Account" sub menus */
        $wp_admin_bar->add_menu(array('id' => 'edit-profile', 'parent' => $id, 'title' => __('Edit My Profile'), 'href' => get_edit_profile_url($user_id)));
        $wp_admin_bar->add_menu(array('id' => 'logout', 'parent' => $id, 'title' => __('Log Out'), 'href' => wp_logout_url()));
    }
}
function wp_admin_bar_my_custom_account_menu($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (0 != $user_id) {
        /* Add the "My Account" menu */
        $avatar = get_avatar($user_id, 28);
        $howdies = array("It's a great day to make an InMail", "Top o' th' mornin'", "Howdy", "I live to serve", "Sup", "Lookin' good", "Welcome", "Hello", "You make InMail look easy", "Nice to see you again", "The robot overlords say hi", "Awaiting your orders", "It's good to be InMailin'", "Hi", "I like working with you", "Mo' InMails, mo' problems", "Bonjour", "Bah-weep-Graaaaagnah wheep ni ni bong", "0100100001100101011011000110110001101111", "Your shoelaces are untied", "Greetings", "I hope Adam doesn't break me again", "You should see me as a blog", "This greeting is randomly selected", "Word to the mutha", ":)", "#yolo", "Yo", "If it's InMails you want, it's InMails I got", "Let's get crackin'", "Party on", "randomly_generated_greeting", "Start the party", "Stylin' like The Chicago Manual", "'I' before 'E', except after 'C'", "The postal service ain't got nothing on me", "So InMail me maybe", "Oppa InMail Style", "Love it, ship it", "Next play", "#swag", "Link Out", "With great power comes great responsibility", "Freedom after 5pm is the right of all CMs");
        $howdiesIndex = $howdies[rand(0, count($howdies) - 1)];
        $howdy = $howdiesIndex . sprintf(__(', %1$s.'), $current_user->display_name);
        $class = empty($avatar) ? '' : 'with-avatar';
        $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
    }
}
function _mw_adminimize_add_user_logout($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    $_mw_adminimize_ui_redirect = _mw_adminimize_get_option_value('_mw_adminimize_ui_redirect');
    if ('1' === $_mw_adminimize_ui_redirect) {
        $redirect = '&amp;redirect_to=' . get_option('siteurl');
    } else {
        $redirect = '';
    }
    if (!$user_id) {
        return;
    }
    $user_info = $current_user->display_name;
    $wp_admin_bar->add_menu(array('id' => 'mw-account', 'parent' => 'top-secondary', 'title' => $user_info . ' ' . __('Log Out'), 'href' => wp_logout_url() . $redirect));
}
 function get_edit_user_link($user_id = null)
 {
     if (!$user_id) {
         $user_id = get_current_user_id();
     }
     if (empty($user_id) || !current_user_can('edit_user', $user_id)) {
         return '';
     }
     $user = new WP_User($user_id);
     if (!$user->exists()) {
         return '';
     }
     if (get_current_user_id() == $user->ID) {
         $link = get_edit_profile_url($user->ID);
     } else {
         $link = add_query_arg('user_id', $user->ID, self_admin_url('user-edit.php'));
     }
     return apply_filters('get_edit_user_link', $link, $user->ID);
 }
function bbwp_howdy_mod($wp_admin_bar)
{
    // Get user info
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    // Custom greatings
    $messages = array('May the 4th be with you', 'Do... or do not. There is no try', 'Bazzinga', 'Kame Hame Ha');
    // Get a ranfom greating
    $all = count($messages) - 1;
    $num = rand(0, $all);
    $greating = $messages[$num];
    // Print user menu with custom greeting
    if (0 != $user_id) {
        $avatar = get_avatar($user_id, 28);
        $howdy = sprintf(__($greating . ', %1$s'), $current_user->display_name);
        $class = empty($avatar) ? '' : 'with-avatar';
        $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
    }
}
Exemple #12
0
 if ($header_profile_display) {
     $profile_li = '';
     $current_user = wp_get_current_user();
     if ($current_user->exists()) {
         $author_url = get_edit_profile_url($current_user->ID);
         $avatar_url = dmeng_get_avatar($current_user->ID, '54', dmeng_get_avatar_type($current_user->ID), false);
         $profile_li .= '<li class="clearfix">' . sprintf(__('<a href="%1$s" class="name" title="%2$s">%2$s</a>,你好!', 'dmeng'), get_edit_profile_url($current_user->ID), $current_user->display_name) . '<a href="' . wp_logout_url(dmeng_get_current_page_url()) . '" title="' . esc_attr__('Log out of this account') . '" data-no-instant>' . __('Log out &raquo;') . '</a></li>';
         $unread_count = intval(get_dmeng_message($current_user->ID, 'count', "( msg_type='unread' OR msg_type='unrepm' )"));
         $unread_count = $unread_count ? sprintf(__('(%s)', 'dmeng'), $unread_count) : '';
         $profile_tabs = array('message' => __('消息', 'dmeng') . $unread_count);
         $profile_tabs_output = '';
         foreach ($profile_tabs as $tab_key => $tab_title) {
             $tab_attr_title = sprintf(__('查看我的%s', 'dmeng'), $tab_title);
             $profile_tabs_output .= sprintf('<a href="%1$s" title="%2$s">%3$s</a>', dmeng_get_user_url($tab_key), $tab_attr_title, $tab_title);
         }
         $profile_tabs_output .= sprintf('<a href="%1$s" title="%2$s">%3$s</a>', get_edit_profile_url($current_user->ID), '修改个人资料', '修改个人资料');
         $profile_li .= '<li class="tabs">' . $profile_tabs_output . '</li>';
     } else {
         $weekname = date('l', current_time('timestamp', 0));
         $weekarray = array('Monday' => __('星期一', 'dmeng'), 'Tuesday' => __('星期二', 'dmeng'), 'Wednesday' => __('星期三', 'dmeng'), 'Thursday' => __('星期四', 'dmeng'), 'Friday' => __('星期五', 'dmeng'), 'Saturday' => __('星期六', 'dmeng'), 'Sunday' => __('星期天', 'dmeng'));
         $profile_li .= '<li class="date">' . sprintf(__('今天是%1$s,%2$s', 'dmeng'), date(__(' Y 年 m 月 d 日', 'dmeng'), current_time('timestamp', 0)), $weekarray[$weekname]) . '</li>';
         $author_url = 'javascript:;';
         $avatar_url = '';
         // $login_methods[] = array(
         // 	'key' => 'wordpress',
         // 	'name' => __( '本地' , 'dmeng' ),
         // 	'url' => wp_login_url(dmeng_get_current_page_url())
         // );
         // if(dmeng_is_open_qq()){
         // 	$login_methods[] = array(
         // 		'key' => 'qq',
Exemple #13
0
    function user_profile()
    {
        $blog_name = get_bloginfo('blogname');
        if (empty($blog_name)) {
            $blog_name = home_url('/');
        }
        ?>
		<div id="post-by-email" class="jetpack-targetable">
		<h3><?php 
        esc_html_e('Post by Email', 'jetpack');
        ?>
</h3>
		<table class="form-table">
			<tr>
				<th scope="row"><?php 
        esc_html_e('Email Address', 'jetpack');
        ?>
<span id="jp-pbe-spinner" class="spinner"></span></th>
				<td>
				<div id="jp-pbe-error" class="jetpack-inline-error"></div> <?php 
        if ($this->check_user_connection()) {
            $email = $this->get_post_by_email_address();
            if (empty($email)) {
                $enable_hidden = '';
                $info_hidden = ' style="display: none;"';
            } else {
                $enable_hidden = ' style="display: none;"';
                $info_hidden = '';
            }
            ?>

					<input type="button" name="jp-pbe-enable" id="jp-pbe-enable" class="button" value="<?php 
            esc_attr_e('Enable Post By Email', 'jetpack');
            ?>
 "<?php 
            echo $enable_hidden;
            ?>
 />
					<div id="jp-pbe-info"<?php 
            echo $info_hidden;
            ?>
>
						<p id="jp-pbe-email-wrapper">
							<input type="text" id="jp-pbe-email" value="<?php 
            echo esc_attr($email);
            ?>
" readonly="readonly" class="regular-text" />
							<span class="description"><a target="_blank" href="http://jetpack.me/support/post-by-email/"><?php 
            esc_html_e('More information', 'jetpack');
            ?>
</a></span>
						</p>
						<p>
							<input type="button" name="jp-pbe-regenerate" id="jp-pbe-regenerate" class="button" value="<?php 
            esc_attr_e('Regenerate Address', 'jetpack');
            ?>
 " />
							<input type="button" name="jp-pbe-disable" id="jp-pbe-disable" class="button" value="<?php 
            esc_attr_e('Disable Post By Email', 'jetpack');
            ?>
 " />
						</p>
					</div> <?php 
        } else {
            $jetpack = Jetpack::init();
            ?>

					<p class="jetpack-inline-message">
						<?php 
            printf(esc_html(wptexturize(__('To use Post By Email, you need to link your %s account to your WordPress.com account.', 'jetpack'))), '<strong>' . esc_html($blog_name) . '</strong>');
            ?>
<br />
						<?php 
            echo esc_html(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack')));
            ?>
					</p>
					<p>
						<a href="<?php 
            echo $jetpack->build_connect_url(false, get_edit_profile_url(get_current_user_id()) . '#post-by-email');
            ?>
" class="button button-connector" id="wpcom-connect"><?php 
            esc_html_e('Link account with WordPress.com', 'jetpack');
            ?>
</a>
					</p>
					<?php 
        }
        ?>
				</td>
			</tr>
		</table>
		</div>
	<?php 
    }
/**
 * Add the "My Account" submenu items.
 *
 * @since 3.1.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_menu($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (!$user_id) {
        return;
    }
    $wp_admin_bar->add_group(array('parent' => 'my-account', 'id' => 'user-actions'));
    $user_info = get_avatar($user_id, 64);
    $user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
    if ($current_user->display_name !== $current_user->user_login) {
        $user_info .= "<span class='username'>{$current_user->user_login}</span>";
    }
    $wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'user-info', 'title' => $user_info, 'href' => $profile_url, 'meta' => array('tabindex' => -1)));
    $wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'edit-profile', 'title' => __('Edit My Profile'), 'href' => $profile_url));
    $wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'logout', 'title' => __('Log Out'), 'href' => wp_logout_url()));
}
Exemple #15
0
?>
</h4>
			<p><?php 
printf(__('Embedding videos from Vine is as simple as pasting a URL onto its own line in a post. See the <a href="%s">full list</a> of supported embeds.'), 'http://codex.wordpress.org/Embeds');
?>
</p>
		</div>

		<div>
			<svg viewBox="-30 -30 160 160"><path d="M61.4,78.6V61.4L72.9,50v40H10V27.1h45.7L44.3,38.6H21.4v40H61.4z M44.3,10H90v45.7L78.6,50V32.4l-32,31.9l-8.1-8.1 l34.8-34.9H50L44.3,10z"/></svg>
			<h4><?php 
_e('Log out everywhere');
?>
</h4>
			<p><?php 
printf(__('If you&#8217;ve ever worried you forgot to sign out from a shared computer, you can now go to <a href="%s">your profile</a> and log out everywhere.'), get_edit_profile_url());
?>
</p>
		</div>

		<div class="last-feature">
			<svg viewBox="-30 -30 160 160"><path d="M35.1,30.1l4.7-5.8l46.4,46.4L80,75c-1.7,1.7-4.6,3.1-8.6,4.3c-4,1.1-7.7,1.7-11,1.7h-20L34,87.4 c-1.5,1.5-3.3,2.3-5.5,2.3c-2.1,0-3.9-0.8-5.5-2.3c-1.5-1.5-2.3-3.3-2.3-5.4c0-2.1,0.8-4,2.3-5.5l6.4-6.4v-20 c0-3.3,0.5-7,1.6-11.2C32.1,34.7,33.4,31.8,35.1,30.1z M76.2,21L59.6,37.7L49.9,28l16.7-16.7c0.9-0.9,2.1-1.2,3.7-0.8 c1.6,0.3,3,1.2,4.3,2.5c1.3,1.3,2.2,2.7,2.5,4.3C77.4,18.9,77.1,20.1,76.2,21z M72.4,50.5l16.7-16.7c0.9-0.9,2.1-1.2,3.7-0.9 c1.6,0.3,3,1.1,4.3,2.5c1.3,1.3,2.2,2.7,2.5,4.3c0.3,1.6,0,2.8-0.9,3.7L82,60.1L72.4,50.5z"/><path d="M10.9,40.4l3.4,6.8L21,48l-4.7,5.2l1.3,7.5l-6.8-3.4l-6.8,3.4l1.3-7.5L0.7,48l6.8-0.8L10.9,40.4z"/></svg>
			<h4><?php 
_e('Plugin recommendations');
?>
</h4>
			<p><?php 
$string = __('The <a href="%s">plugin installer</a> suggests plugins for you to try. Recommendations are based on the plugins you and other users have installed.');
if (!current_user_can('install_plugins')) {
    $string = strip_tags($string);
}
Exemple #16
0
/**
 * @since 2.8.0
 *
 * @global string $pagenow
 */
function default_password_nag()
{
    global $pagenow;
    // Short-circuit it.
    if ('profile.php' == $pagenow || !get_user_option('default_password_nag')) {
        return;
    }
    echo '<div class="error default-password-nag">';
    echo '<p>';
    echo '<strong>' . __('Notice:') . '</strong> ';
    _e('You&rsquo;re using the auto-generated password for your account. Would you like to change it?');
    echo '</p><p>';
    printf('<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url() . '#password');
    printf('<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0');
    echo '</p></div>';
}
Exemple #17
0
function jpatd_more_info()
{
    ?>
	<div class="jp-info-img">
		<a href="http://en.support.wordpress.com/proofreading/">
			<img class="jp-info-img" src="<?php 
    echo plugins_url(basename(dirname(dirname(__FILE__))) . '/_inc/images/after-the-deadline.gif');
    ?>
" alt="<?php 
    esc_attr_e('Spelling and Grammar', 'jetpack');
    ?>
" width="300" height="155" />
		</a>
	</div>

	<h4><?php 
    esc_html_e('Spelling and Grammar', 'jetpack');
    ?>
</h4>

	<p><?php 
    printf(__("The <a href='%s'>After&nbsp;the&nbsp;Deadline</a> Proofreading service improves your writing by using artificial intelligence to find your errors and offer smart suggestions.", 'jetpack'), 'http://www.afterthedeadline.com/');
    ?>
</p>
	<p><?php 
    printf(__('After the Deadline provides a number of <a href="%s">customization options</a>, which you can edit in your profile.', 'jetpack'), esc_url(get_edit_profile_url(get_current_user_id())) . '#atd');
    ?>
</p>
<?php 
}
/**
 * Function that changes the username on the top right menu (admin bar)
 *
 * @since v.2.0
 *
 * @return string
 */
function wppb_replace_username_on_admin_bar($wp_admin_bar)
{
    $wppb_general_settings = get_option('wppb_general_settings');
    if (isset($wppb_general_settings['loginWith']) && $wppb_general_settings['loginWith'] == 'email') {
        $current_user = wp_get_current_user();
        $my_account_main = $wp_admin_bar->get_node('my-account');
        $new_title1 = str_replace($current_user->display_name, $current_user->user_email, $my_account_main->title);
        $wp_admin_bar->add_node(array('id' => 'my-account', 'title' => $new_title1));
        $my_account_sub = $wp_admin_bar->get_node('user-info');
        $wp_admin_bar->add_node(array('parent' => 'user-actions', 'id' => 'user-info', 'title' => get_avatar($current_user->ID, 64) . "<span class='display-name'>{$current_user->user_email}</span>", 'href' => get_edit_profile_url($current_user->ID), 'meta' => array('tabindex' => -1)));
    }
    return $wp_admin_bar;
}
Exemple #19
0
    function edit_profile_fields($user)
    {
        wp_enqueue_style('genericons');
        ?>

		<h3 id="single-sign-on"><?php 
        _e('Single Sign On', 'jetpack');
        ?>
</h3>
		<p><?php 
        _e('Connecting with Single Sign On enables you to log in via your WordPress.com account.', 'jetpack');
        ?>
</p>

		<?php 
        if ($this->is_user_connected($user->ID)) {
            /* If the user is currently connected... */
            ?>
			<?php 
            $user_data = $this->get_user_data($user->ID);
            ?>
			<table class="form-table jetpack-sso-form-table">
				<tbody>
					<tr>
						<td>
							<div class="profile-card">
								<?php 
            echo get_avatar($user_data->email);
            ?>
								<p class="connected"><strong><?php 
            _e('Connected', 'jetpack');
            ?>
</strong></p>
								<p><?php 
            echo esc_html($user_data->login);
            ?>
</p>
								<span class="two_step">
									<?php 
            if ($user_data->two_step_enabled) {
                ?>
 <p class="enabled"><a href="https://wordpress.com/me/security/two-step"><?php 
                _e('Two-Step Authentication Enabled', 'jetpack');
                ?>
</a></p> <?php 
            } else {
                ?>
 <p class="disabled"><a href="https://wordpress.com/me/security/two-step"><?php 
                _e('Two-Step Authentication Disabled', 'jetpack');
                ?>
</a></p> <?php 
            }
            ?>
								</span>

							</div>
							<p><a class="button button-secondary" href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg('jetpack_sso', 'purge'), 'jetpack_sso_purge'));
            ?>
"><?php 
            _e('Unlink This Account', 'jetpack');
            ?>
</a></p>
						</td>
					</tr>
				</tbody>
			</table>

			<style>
			.jetpack-sso-form-table td {
				padding-left: 0;
			}

			.jetpack-sso-form-table .profile-card {
				padding: 10px;
				background: #fff;
				overflow: hidden;
				max-width: 400px;
				box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.1 );
				margin-bottom: 1em;
			}

			.jetpack-sso-form-table .profile-card img {
				float: left;
				margin-right: 1em;
				width: 48px;
				height: 48px;
			}

			.jetpack-sso-form-table .profile-card .connected {
				float: right;
				margin-right: 0.5em;
				color: #0a0;
			}

			.jetpack-sso-form-table .profile-card p {
				margin-top: 0.7em;
				font-size: 1.2em;
			}

			.jetpack-sso-form-table .profile-card .two_step .enabled a {
				float: right;
				color: #0a0;
			}

			.jetpack-sso-form-table .profile-card .two_step .disabled a {
				float: right;
				color: red;
			}
			</style>

		<?php 
        } elseif (get_current_user_id() == $user->ID && Jetpack::is_user_connected($user->ID)) {
            ?>

			<?php 
            echo $this->button('state=sso-link-user&_wpnonce=' . wp_create_nonce('sso-link-user'));
            // update
            ?>

		<?php 
        } else {
            ?>

			<p><?php 
            esc_html_e(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack')));
            ?>
</p>
			<a href="<?php 
            echo Jetpack::init()->build_connect_url(false, get_edit_profile_url(get_current_user_id()) . '#single-sign-on');
            ?>
" class="button button-connector" id="wpcom-connect"><?php 
            esc_html_e('Link account with WordPress.com', 'jetpack');
            ?>
</a>

		<?php 
        }
    }
 function AtD_configuration_load()
 {
     wp_safe_redirect(get_edit_profile_url(get_current_user_id()) . '#atd');
     exit;
 }
 function groundup_get_avatar($id_or_email, $size = '64', $placeholder = '404')
 {
     // get $email from input. Could be $comment, $email, or $user_id
     $authorURL = '';
     $authorName = '';
     if (is_numeric($id_or_email)) {
         $id = (int) $id_or_email;
         $user = get_userdata($id);
         if ($user) {
             $email = $user->user_email;
         }
     } elseif (is_object($id_or_email)) {
         if (!empty($id_or_email->user_id)) {
             $id = (int) $id_or_email->user_id;
             $user = get_userdata($id);
             if ($user) {
                 $email = $user->user_email;
                 $authorName = $user->display_name;
                 $authorURL = get_edit_profile_url($id);
             }
         } elseif (!empty($id_or_email->comment_author_email)) {
             $email = $id_or_email->comment_author_email;
             $authorName = $id_or_email->comment_author;
             $authorURL = $id_or_email->comment_author_url;
         }
     } else {
         $email = $id_or_email;
     }
     // Create gravatar url using placeholder or 404
     if ($placeholder != '404') {
         $placeholder = urlencode($placeholder);
     }
     $image = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $size . '&d=' . $placeholder;
     $headers = get_headers($image);
     if (!strpos($headers[0], '200')) {
         // no avatar
         return '';
     }
     $avatar = '<img src="' . $image . '" class="avatar" alt="' . $authorName . '">';
     if ($authorURL) {
         return '<a href="' . $authorURL . '" rel="external nofollow">' . $avatar . '</a>';
     } else {
         // no URL
         return $avatar;
     }
 }
 function admin_bar_menu()
 {
     global $wp_admin_bar;
     $GetData = $this->get_flit_data('admin_bar_menu');
     if (!empty($GetData["UPFN"])) {
         unset($GetData["UPFN"]);
         if (is_array($GetData)) {
             // admin bar initialize nodes
             $All_Nodes = $wp_admin_bar->get_nodes();
             foreach ($All_Nodes as $node) {
                 if ($node->id != 'top-secondary') {
                     $wp_admin_bar->remove_node($node->id);
                 }
             }
             $SettingNodes = $GetData;
             $user_id = get_current_user_id();
             $current_user = wp_get_current_user();
             $profile_url = get_edit_profile_url($user_id);
             $update_data = wp_get_update_data();
             $activated_plugin = $this->ActivatedPlugin;
             $other_plugin = $this->OtherPluginMenu;
             // all nodes adjustment
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $key => $node) {
                         if (strstr($node["id"], 'custom_node')) {
                             if (!empty($node["group"])) {
                                 $node["meta"]["class"] = 'ab-sub-secondary';
                             } else {
                                 $node["href"] = $this->val_replace($node["href"]);
                             }
                         } elseif ($node["id"] == 'view-post_type') {
                             if (is_admin()) {
                                 if (!empty($All_Nodes['preview'])) {
                                     $node["href"] = $All_Nodes['preview']->href;
                                     $node["meta"] = $All_Nodes['preview']->meta;
                                 } elseif (!empty($All_Nodes['view'])) {
                                     $node["href"] = $All_Nodes['view']->href;
                                     $node["meta"] = $All_Nodes['view']->meta;
                                 } else {
                                     unset($SettingNodes[$Boxtype][$node_type][$key]);
                                     continue;
                                 }
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif ($node["id"] == 'edit-post_type') {
                             if (!empty($All_Nodes["edit"])) {
                                 //$node["title"] = $All_Nodes["edit"]->title;
                                 $node["href"] = $All_Nodes["edit"]->href;
                                 $node["id"] = $All_Nodes["edit"]->id;
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif ($node["id"] == 'search') {
                             if (!empty($All_Nodes["search"])) {
                                 $node["title"] = $All_Nodes["search"]->title;
                                 $node["id"] = $All_Nodes["search"]->id;
                                 $node["href"] = "";
                                 $node["meta"]["class"] = $All_Nodes["search"]->meta["class"];
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif (!empty($All_Nodes[$node["id"]])) {
                             if ($node["id"] == 'search') {
                                 $node["href"] = $All_Nodes[$node["id"]]->href;
                                 $node["title"] = $All_Nodes[$node["id"]]->title;
                             } else {
                                 $node["href"] = $All_Nodes[$node["id"]]->href;
                             }
                         } else {
                             unset($SettingNodes[$Boxtype][$node_type][$key]);
                             continue;
                         }
                         if (!empty($All_Nodes[$node["id"]]->meta["title"])) {
                             $node["meta"]["title"] = $All_Nodes[$node["id"]]->meta["title"];
                         }
                         if ($Boxtype == 'right' && $node_type == 'main') {
                             $node["parent"] = "top-secondary";
                         }
                         if (strstr($node["title"], '[comment_count]')) {
                             if (!current_user_can('edit_posts')) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[comment_count]', '<span class="ab-icon"></span><span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-[comment_count]">[comment_count_format]</span>', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_total]')) {
                             if (!$update_data['counts']['total']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_total]', '<span class="ab-icon"></span><span class="ab-label">[update_total_format]</span>', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_plugins]')) {
                             if (!$update_data['counts']['plugins']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_plugins]', '[update_plugins_format]', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_themes]')) {
                             if (!$update_data['counts']['themes']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_themes]', '[update_themes_format]', $node["title"]);
                             }
                         }
                         if ($node["id"] == 'logout') {
                             $node["href"] = wp_logout_url();
                         }
                         if ($node["id"] == 'my-account') {
                             $avatar = get_avatar($user_id, 16);
                             $class = empty($avatar) ? '' : 'with-avatar';
                             $node["meta"]["class"] = $class;
                         }
                         if (!isset($node["group"])) {
                             $node["group"] = "";
                         }
                         $node["title"] = $this->val_replace($node["title"]);
                         $SettingNodes[$Boxtype][$node_type][$key] = $node;
                     }
                 }
             }
             // other plugin nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $key => $node) {
                         if (!empty($activated_plugin)) {
                             if ($node["id"] == 'bp-notifications') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'page_list') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'post_list') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'languages') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             }
                             foreach ($activated_plugin as $plugin_slug => $v) {
                                 if (!empty($other_plugin["admin_bar"][$plugin_slug]) && array_key_exists($node["id"], $other_plugin["admin_bar"][$plugin_slug])) {
                                     $SettingNodes[$Boxtype][$node_type][$key]["title"] = $All_Nodes[$node["id"]]->title;
                                     $SettingNodes[$Boxtype][$node_type][$key]["href"] = $All_Nodes[$node["id"]]->href;
                                 }
                             }
                         }
                     }
                 }
             }
             // add main nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     if ($node_type == 'main') {
                         foreach ($nodes as $node_id => $node) {
                             $args = array("id" => $node["id"], "title" => stripslashes($node["title"]), "href" => $node["href"], "parent" => $node["parent"], "group" => $node["group"], "meta" => $node["meta"]);
                             $wp_admin_bar->add_menu($args);
                             unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                         }
                     }
                 }
             }
             // add all nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     if ($node_type != 'main') {
                         foreach ($nodes as $node_id => $node) {
                             if (empty($node["group"])) {
                                 $args = array("id" => $node["id"], "title" => stripslashes($node["title"]), "href" => $node["href"], "parent" => $node["parent"], "group" => false, "meta" => $node["meta"]);
                                 $wp_admin_bar->add_menu($args);
                                 unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                             }
                         }
                     }
                 }
             }
             // add groups
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $node_id => $node) {
                         if (!empty($node["group"])) {
                             $args = array("id" => $node["id"], "parent" => $node["parent"], "meta" => $node["meta"]);
                             $wp_admin_bar->add_group($args);
                             unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #23
0
    ?>
><?php 
    bloginfo('description');
    ?>
</div>
		<?php 
}
?>
	</div><!-- end #branding -->
	
	<?php 
if (is_user_logged_in()) {
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_author_posts_url($user_id);
    $edit_profile_url = get_edit_profile_url($user_id);
    $current_url = get_current_url();
    ?>
		<div id="account-nav" class="user-nav">
			<a class="dropdown-handle" href="<?php 
    echo $profile_url;
    ?>
">
				<?php 
    echo get_avatar($user_id, 32);
    ?>
				<span class="display-name btn">
					<span class="arrow-down"><?php 
    echo $current_user->display_name;
    ?>
</span> 
Exemple #24
0
/**
 * Exibe no header um link para o perfil do usuário.
 * 
 * @return null
 */
function consulta_show_user_link()
{
    global $current_user;
    ?>
    <div id="logged-user-name">
        <a href="<?php 
    echo get_edit_profile_url($current_user->ID);
    ?>
">
            <?php 
    echo substr($current_user->display_name, 0, 38);
    ?>
        </a>
    </div>
    <?php 
}
function jetpack_post_by_email_more_info()
{
    ?>
	<div class="jp-info-img">
		<img class="jp-info-img" src="<?php 
    echo plugins_url(basename(dirname(dirname(__FILE__))) . '/images/screenshots/post-by-email.jpg');
    ?>
" alt="<?php 
    esc_attr_e('Post by Email', 'jetpack');
    ?>
" width="300" height="115" />
	</div>

	<p><?php 
    esc_html_e('Post by Email is a way of publishing posts on your blog by email. Any email client can be used to send the email, allowing you to publish quickly and easily from devices such as cell phones.', 'jetpack');
    ?>
</p>

	<p><?php 
    printf(__('Manage your Post By Email address from your <a href="%s">profile settings</a>.', 'jetpack'), esc_url(get_edit_profile_url(get_current_user_id()) . '#post-by-email'));
    ?>

	<p>&rarr; <a href="http://jetpack.me/support/post-by-email/"><?php 
    esc_html_e('More information on sending emails, attachments, and customizing your posts.', 'jetpack');
    ?>
</a></p>

<?php 
}
Exemple #26
0
function tin_user_profile_widget()
{
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $li_output = '';
        $li_output .= '<li style="line-height:36px;clear: both;">' . tin_get_avatar($current_user->ID, '36', tin_get_avatar_type($current_user->ID), false) . sprintf(__('登录者 <a href="%1$s">%2$s</a>', 'tinection'), get_edit_profile_url($current_user->ID), $current_user->display_name) . '<a href="' . wp_logout_url(tin_get_current_page_url()) . '" title="' . esc_attr__('登出本帐号') . '">' . __('登出 &raquo;') . '</a></li>';
        if (!filter_var($current_user->user_email, FILTER_VALIDATE_EMAIL)) {
            $li_output .= '<li><a href="' . tin_get_user_url('profile') . '#pass">' . __('【重要】请添加正确的邮箱以保证账户安全', 'tinection') . '</a></li>';
        }
        $shorcut_links[] = array('title' => __('个人主页', 'tinection'), 'url' => get_author_posts_url($current_user->ID));
        if (current_user_can('manage_options')) {
            $shorcut_links[] = array('title' => __('管理后台', 'tinection'), 'url' => admin_url());
        }
        $can_post_cat = ot_get_option('tin_can_post_cat');
        if (count($can_post_cat)) {
            $shorcut_links[] = array('title' => __('文章投稿', 'tinection'), 'url' => add_query_arg('action', 'new', tin_get_user_url('post')));
        }
        $shorcut_html = '<li class="active">';
        foreach ($shorcut_links as $shorcut) {
            $shorcut_html .= '<a href="' . $shorcut['url'] . '">' . $shorcut['title'] . ' &raquo;</a>';
        }
        $shorcut_html .= '</li>';
        $credit = intval(get_user_meta($current_user->ID, 'tin_credit', true));
        $credit_void = intval(get_user_meta($current_user->ID, 'tin_credit_void', true));
        $unread_count = intval(get_tin_message($current_user->ID, 'count', "( msg_type='unread' OR msg_type='unrepm' )"));
        $collects = get_user_meta($current_user->ID, 'tin_collect', true) ? get_user_meta($current_user->ID, 'tin_collect', true) : 0;
        $collects_array = explode(',', $collects);
        $collects_count = $collects != 0 ? count($collects_array) : 0;
        $info_array = array(array('title' => __('文章', 'tinection'), 'url' => tin_get_user_url('post'), 'count' => count_user_posts($current_user->ID)), array('title' => __('评论', 'tinection'), 'url' => tin_get_user_url('comment'), 'count' => get_comments(array('status' => '1', 'user_id' => $current_user->ID, 'count' => true))), array('title' => __('收藏', 'tinection'), 'url' => tin_get_user_url('collect'), 'count' => intval($collects_count)));
        if ($unread_count) {
            $info_array[] = array('title' => __('未读', 'tinection'), 'url' => tin_get_user_url('message'), 'count' => $unread_count);
        }
        $info_array[] = array('title' => __('积分', 'tinection'), 'url' => tin_get_user_url('credit'), 'count' => $credit);
        $info_html = '<li>';
        foreach ($info_array as $info) {
            $info_html .= $info['title'] . '<a href="' . $info['url'] . '"> ' . $info['count'] . '</a>';
        }
        $info_html .= tin_whether_signed($current_user->ID);
        $info_html .= '</li>';
        $friend_html = '
	<li>
		<div class="input-group">
			<span class="input-group-addon">' . __('本页推广链接', 'tinection') . '</span>
			<input class="tin_aff_url form-control" type="text" class="form-control" value="' . add_query_arg('aff', $current_user->ID, tin_canonical_url()) . '">
		</div>
	</li>
	';
        return $li_output . $shorcut_html . $info_html . $friend_html;
    } else {
        $html = '<li><span class="local-account"><a data-sign="0" class="btn btn-primary user-login"><i class="fa fa-wordpress"></i>' . __('本地帐号', 'tinection') . '</a></span>';
        if (ot_get_option('tin_open_qq') == 'on') {
            $html .= '<span class="other-sign"><a class="qqlogin btn" href="' . home_url('/?connect=qq&action=login&redirect=' . urlencode(tin_get_redirect_uri())) . '"><i class="fa fa-qq"></i><span>' . __('QQ 登 录', 'tinection') . '</span></a></span>';
        }
        if (ot_get_option('tin_open_weibo') == 'on') {
            $html .= '<span class="other-sign"><a class="weibologin btn" href="' . home_url('/?connect=weibo&action=login&redirect=' . urlencode(tin_get_redirect_uri())) . '"><i class="fa fa-weibo"></i><span>' . __('微博登录', 'tinection') . '</span></a></span>';
        }
        $html .= '</li>';
        return $html;
    }
}
Exemple #27
0
    function edit_profile_fields($user)
    {
        ?>

		<h3 id="single-sign-on"><?php 
        _e('Single Sign On', 'jetpack');
        ?>
</h3>
		<p><?php 
        _e('Connecting with Single Sign On enables you to log in via your WordPress.com account.', 'jetpack');
        ?>
</p>

		<?php 
        if ($this->is_user_connected($user->ID)) {
            /* If the user is currently connected... */
            ?>
			<?php 
            $user_data = $this->get_user_data($user->ID);
            ?>
			<table class="form-table jetpack-sso-form-table">
				<tbody>
					<tr>
						<td>
							<div class="profile-card">
								<?php 
            echo get_avatar($user_data->email);
            ?>
								<p class="connected"><strong><?php 
            _e('Connected', 'jetpack');
            ?>
</strong></p>
								<p><?php 
            echo esc_html($user_data->login);
            ?>
</p>
								<span class="two_step">
									<?php 
            if ($user_data->two_step_enabled) {
                ?>
 <p class="enabled"><a href="https://wordpress.com/me/security/two-step" target="_blank"><?php 
                _e('Two-Step Authentication Enabled', 'jetpack');
                ?>
</a></p> <?php 
            } else {
                ?>
 <p class="disabled"><a href="https://wordpress.com/me/security/two-step" target="_blank"><?php 
                _e('Two-Step Authentication Disabled', 'jetpack');
                ?>
</a></p> <?php 
            }
            ?>
								</span>

							</div>
							<p><a class="button button-secondary" href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg('jetpack_sso', 'purge'), 'jetpack_sso_purge'));
            ?>
"><?php 
            _e('Unlink This Account', 'jetpack');
            ?>
</a></p>
						</td>
					</tr>
				</tbody>
			</table>
		<?php 
        } elseif (get_current_user_id() == $user->ID && Jetpack::is_user_connected($user->ID)) {
            ?>

			<?php 
            echo $this->button('state=sso-link-user&_wpnonce=' . wp_create_nonce('sso-link-user'));
            // update
            ?>

		<?php 
        } else {
            ?>

			<p><?php 
            esc_html_e(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack')));
            ?>
</p>
			<a href="<?php 
            echo Jetpack::init()->build_connect_url(false, get_edit_profile_url(get_current_user_id()) . '#single-sign-on');
            ?>
" class="button button-connector" id="wpcom-connect"><?php 
            esc_html_e('Link account with WordPress.com', 'jetpack');
            ?>
</a>

		<?php 
        }
    }
Exemple #28
0
function hocwp_social_login_google_ajax_callback()
{
    $result = array('redirect_to' => '', 'logged_in' => false);
    $data = hocwp_get_method_value('data');
    $data = hocwp_json_string_to_array($data);
    $connect = hocwp_get_method_value('connect');
    if (hocwp_array_has_value($data)) {
        $verified = (bool) hocwp_get_value_by_key($data, 'verified');
        $allow_not_verified = apply_filters('hocwp_allow_social_user_signup_not_verified', true);
        if ($verified || $allow_not_verified) {
            $id = hocwp_get_value_by_key($data, 'id');
            $requested_redirect_to = hocwp_get_method_value('redirect_to');
            $redirect_to = home_url('/');
            $transient_name = hocwp_build_transient_name('hocwp_social_login_google_%s', $id);
            $user_id = get_transient($transient_name);
            $user = get_user_by('id', $user_id);
            if ($connect && is_user_logged_in()) {
                $user = wp_get_current_user();
                $user_id = $user->ID;
            }
            $find_users = get_users(array('meta_key' => 'google', 'meta_value' => $id));
            if (hocwp_array_has_value($find_users)) {
                $user = $find_users[0];
                $user_id = $user->ID;
            }
            if (false === $user_id || !hocwp_id_number_valid($user_id) || !is_a($user, 'WP_User') || $connect) {
                $avatar = hocwp_get_value_by_key($data, array('image', 'url'));
                if ($connect) {
                    update_user_meta($user_id, 'google', $id);
                    update_user_meta($user_id, 'avatar', $avatar);
                    update_user_meta($user_id, 'google_data', $data);
                    $result['redirect_to'] = get_edit_profile_url($user_id);
                    $result['logged_in'] = true;
                } else {
                    $email = hocwp_get_value_by_key($data, array('emails', 0, 'value'));
                    if (is_email($email)) {
                        $name = hocwp_get_value_by_key($data, 'displayName');
                        $first_name = hocwp_get_value_by_key($data, array('name', 'givenName'));
                        $last_name = hocwp_get_value_by_key($data, array('name', 'familyName'));
                        $password = wp_generate_password();
                        $user_id = null;
                        if (username_exists($email)) {
                            $user = get_user_by('login', $email);
                            $user_id = $user->ID;
                        } elseif (email_exists($email)) {
                            $user = get_user_by('email', $email);
                            $user_id = $user->ID;
                        }
                        $old_user = true;
                        if (!hocwp_id_number_valid($user_id)) {
                            $user_data = array('username' => $email, 'email' => $email, 'password' => $password);
                            $user_id = hocwp_add_user($user_data);
                            if (hocwp_id_number_valid($user_id)) {
                                $old_user = false;
                            }
                        }
                        if (hocwp_id_number_valid($user_id)) {
                            $user = get_user_by('id', $user_id);
                            $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
                            if (!$old_user) {
                                update_user_meta($user_id, 'google', $id);
                                $user_data = array('ID' => $user_id, 'display_name' => $name, 'first_name' => $first_name, 'last_name' => $last_name);
                                wp_update_user($user_data);
                                update_user_meta($user_id, 'avatar', $avatar);
                                update_user_meta($user_id, 'google_data', $data);
                            }
                            hocwp_user_force_login($user_id);
                            $result['redirect_to'] = $redirect_to;
                            $result['logged_in'] = true;
                            set_transient($transient_name, $user_id, DAY_IN_SECONDS);
                        }
                    }
                }
            } else {
                update_user_meta($user_id, 'google_data', $data);
                $user = get_user_by('id', $user_id);
                $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
                hocwp_user_force_login($user_id);
                $result['redirect_to'] = $redirect_to;
                $result['logged_in'] = true;
            }
        }
    }
    wp_send_json($result);
}
/**
 * Retrieve edit user link
 *
 * @since 3.5.0
 *
 * @param int $user_id Optional. User ID. Defaults to the current user.
 * @return string URL to edit user page or empty string.
 */
function get_edit_user_link($user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    if (empty($user_id) || !current_user_can('edit_user', $user_id)) {
        return '';
    }
    $user = get_userdata($user_id);
    if (!$user) {
        return '';
    }
    if (get_current_user_id() == $user->ID) {
        $link = get_edit_profile_url($user->ID);
    } else {
        $link = add_query_arg('user_id', $user->ID, self_admin_url('user-edit.php'));
    }
    /**
     * Filter the user edit link.
     *
     * @since 3.5.0
     *
     * @param string $link    The edit link.
     * @param int    $user_id User ID.
     */
    return apply_filters('get_edit_user_link', $link, $user->ID);
}
 function get_user_information()
 {
     $user_info = array();
     $user_id = get_current_user_id();
     $current_user = wp_get_current_user();
     $user_info['current_url'] = get_current_url();
     if ($user_id) {
         $user_info['is_connected'] = true;
         $user_info['wp_logout_url'] = wp_logout_url('/');
         $user_info['avatar'] = get_avatar($user_id, 19, null, 'fotografia-usuari-sofcatala');
         $user_info['avatar_48'] = get_avatar($user_id, 48, null, 'fotografia-usuari-sofcatala');
         $user_info['name'] = $current_user->display_name;
         $user_info['profile_url'] = get_edit_profile_url($user_id);
     } else {
         $user_info['avatar'] = get_avatar($user_id, 19, null, 'fotografia-usuari-sofcatala');
         $user_info['is_connected'] = false;
         $user_info['wp_login_url'] = wp_login_url(get_current_url());
     }
     return $user_info;
 }