当前位置: 首页>>代码示例>>PHP>>正文


PHP get_blogs_of_user函数代码示例

本文整理汇总了PHP中get_blogs_of_user函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blogs_of_user函数的具体用法?PHP get_blogs_of_user怎么用?PHP get_blogs_of_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_blogs_of_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_logged_in_user

 /**
  * Get the user that is logged in
  */
 public function get_logged_in_user()
 {
     global $user_ID;
     if (is_user_logged_in()) {
         // this refers to the global method not local
         $loggedIn = (bool) true;
     } else {
         $loggedIn = (bool) false;
     }
     $avatarURL = get_avatar($user_ID);
     $user = get_userdata($user_ID);
     $dom = new DOMDocument();
     $dom->loadHTML($avatarURL);
     $avatarURL = $dom->getElementsByTagName('img')->item(0)->getAttribute('src');
     $result = array('id' => $user_ID, 'displayName' => "", 'loggedIn' => $loggedIn, 'avatar' => $avatarURL);
     if ($user) {
         $result['displayName'] = $user->data->display_name;
         $result['contact'] = $user->data->user_email;
     }
     if (is_multisite()) {
         $user_blogs = get_blogs_of_user($user_ID);
         $result['blogs'] = $user_blogs;
     }
     return $result;
 }
开发者ID:andreiRS,项目名称:Radii8,代码行数:28,代码来源:user.php

示例2: 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');
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:31,代码来源:class-wp-admin-bar.php

示例3: 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());
         $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');
 }
开发者ID:7press,项目名称:7press,代码行数:36,代码来源:class-wp-admin-bar.php

示例4: block_output

    /**
     * The content for the content section.
     *
     * @since Client Dash 1.4
     */
    public function block_output()
    {
        // Set up current user information
        $current_user = wp_get_current_user();
        // Get the blogs this current user has access to
        $blogs = get_blogs_of_user($current_user->ID);
        ?>
		<table class="widefat fixed">
			<tbody>
			<?php 
        // Construct a table row for each blog owned by user
        $i = 0;
        foreach ($blogs as $blog) {
            $i++;
            // Every other row is alternate for coloring
            if ($i % 2 == 0) {
                echo '<tr class="alternate">';
            } else {
                echo '<tr>';
            }
            echo '<td valign="top" style="border-right: 1px solid #ccc;">';
            echo '<h3>' . $blog->blogname . '</h3>';
            echo '<p><a href="' . $blog->siteurl . '">Visit</a> | ';
            echo '<a href="' . $blog->siteurl . '/wp-admin/">Dashboard</a></p>';
            echo '</td>';
            echo '</tr>';
        }
        ?>
			</tbody>
		</table>
	<?php 
    }
开发者ID:BenjaminCool,项目名称:client-dash,代码行数:37,代码来源:sites.php

示例5: handle_private_loggedin_multisite

 protected function handle_private_loggedin_multisite($options)
 {
     if (is_multisite() && $options['aioi_ms_requiremember'] && !is_network_admin()) {
         // Need to check logged-in user is a member of this sub-site
         $blogs = get_blogs_of_user(get_current_user_id());
         if (!wp_list_filter($blogs, array('userblog_id' => get_current_blog_id()))) {
             // Not a member
             $blog_name = get_bloginfo('name');
             $output = '<p>' . esc_html(sprintf('You attempted to access the "%1$s" sub-site, but you are not currently a member of this site. If you believe you should be able to access "%1$s", please contact your network administrator.', $blog_name)) . '</p>';
             if (!empty($blogs)) {
                 $output .= '<p>You <i>are</i> a member of the following sites:</p>';
                 $output .= '<table>';
                 foreach ($blogs as $blog) {
                     $output .= "<tr>";
                     $output .= "<td valign='top'>";
                     $output .= "<a href='" . esc_url(get_home_url($blog->userblog_id)) . "'>" . esc_html($blog->blogname) . "</a>";
                     $output .= "</td>";
                     $output .= "</tr>";
                 }
                 $output .= '</table>';
             }
             wp_die($output);
         }
     }
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:25,代码来源:premium_all_in_one_intranet.php

示例6: hide_dashboard

function hide_dashboard()
{
    global $blog, $current_user, $id, $parent_file, $wphd_user_capability;
    if (!current_user_can('' . $wphd_user_capability . '')) {
        /* First, let's get rid of the Help menu, Update nag, Personal Options section */
        echo "\n" . '<style type="text/css" media="screen">#your-profile { display: none; } .update-nag, #contextual-help-wrap, #contextual-help-link-wrap { display: none !important; }</style>';
        echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) { $(\'form#your-profile > h3:first\').hide(); $(\'form#your-profile > table:first\').hide(); $(\'form#your-profile\').show(); });</script>' . "\n";
        /* Now, let's fix the sidebar admin menu - go away, Dashboard link. */
        /* If Multisite, check whether they are in the User Dashboard before removing links */
        $user_id = get_current_user_id();
        $blogs = get_blogs_of_user($user_id);
        if (is_multisite() && is_admin() && empty($blogs)) {
            return;
        } else {
            remove_menu_page('index.php');
            /* Hides Dashboard menu */
            remove_menu_page('separator1');
            /* Hides separator under Dashboard menu*/
        }
        /* Last, but not least, let's redirect folks to their profile when they login or if they try to access the Dashboard via direct URL */
        if (is_multisite() && is_admin() && empty($blogs)) {
            return;
        } else {
            if ($parent_file == 'index.php') {
                if (headers_sent()) {
                    echo '<meta http-equiv="refresh" content="0;url=' . admin_url('profile.php') . '">';
                    echo '<script type="text/javascript">document.location.href="' . admin_url('profile.php') . '"</script>';
                } else {
                    wp_redirect(admin_url('profile.php'));
                    exit;
                }
            }
        }
    }
}
开发者ID:gp6shc,项目名称:aok,代码行数:35,代码来源:hide-dashboard.php

示例7: prepare_item_for_response

 /**
  * Prepare a single user output for response
  *
  * @param object $user User object.
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response Response data.
  */
 public function prepare_item_for_response($user, $request)
 {
     $roles = $user->roles;
     if (empty($roles)) {
         $isadmin = false;
     } else {
         $isadmin = hash_equals($roles[0], 'administrator');
     }
     $user_id = $user->ID;
     $user_blogs = get_blogs_of_user($user_id);
     $site = urldecode($request['site']);
     $data = array('id' => $user->ID, 'username' => $user->user_login, 'name' => $user->display_name, 'email' => $user->user_email, 'admin' => $isadmin, 'role' => $roles[0], 'site' => $_SERVER['SERVER_NAME'], 'host' => $_SERVER['HTTP_HOST'], 'blogs' => $user_blogs);
     $context = !empty($request['context']) ? $request['context'] : 'embed';
     $data = $this->filter_response_by_context($data, $context);
     $data = $this->add_additional_fields_to_object($data, $request);
     // Wrap the data in a response object
     $response = rest_ensure_response($data);
     //$response->add_links( $this->prepare_links( $user ) );
     /**
      * Filter user data returned from the REST API.
      *
      * @param WP_REST_Response $response  The response object.
      * @param object           $user      User object used to create response.
      * @param WP_REST_Request  $request   Request object.
      */
     return apply_filters('rest_prepare_user', $response, $user, $request);
 }
开发者ID:Afrozaar,项目名称:wp-api-v2-afrozaar-extras,代码行数:34,代码来源:class-wp-rest-users-extras-controller.php

示例8: projects_page

 function projects_page()
 {
     global $current_user;
     get_currentuserinfo();
     $user_id = $current_user->ID;
     $user_blogs = get_blogs_of_user($user_id);
     foreach ($user_blogs as $user_blog) {
         if ($user_blog->path == '/') {
             # do nothing
         } else {
             $user_blog_id = $user_blog->userblog_id;
         }
     }
     $output = '';
     if (current_user_can_for_blog($user_blog_id, 'administrator') || current_user_can_for_blog($user_blog_id, 'das_designer')) {
         $output .= '<div class="das-project-admin-wrap-main">';
         $output .= '<a class="buy-extensions-btn" href="http://www.slickremix.com/downloads/category/design-approval-system/" target="_blank">' . __('Get Extensions Here!', 'design-approval-system') . '</a>';
         $output .= '<h2 class="project-board-header">' . __('Project Board', 'design-approval-system') . '</h2>';
         $output .= '<div class="use-of-plugin">' . __('Below are your Clients and their Projects. Learn how it all works ', 'design-approval-system') . '<a href="http://www.slickremix.com/design-approval-system-docs" target="_blank">' . __('here', 'design-approval-system') . '</a>.</div>';
         // echo our short code for the Public Board
         $output .= do_shortcode('[DASPublicBoard]');
         $output .= '</div><!--das-project-admin-wrap-main-->';
     } else {
         $output .= '<div class="das-project-admin-wrap-main">';
         $output .= '<h2 class="project-board-header">' . __('Project Board', 'design-approval-system') . '</h2>';
         // echo our short code for the Private Board
         $output .= do_shortcode('[DASPrivateBoard]');
         $output .= '<br class="clear"/></div><!--das-project-admin-wrap-main-->';
     }
     // end if admin or das user can
     echo $output;
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:32,代码来源:das-projects-page.php

示例9: login

/**
 * Change redirect upon login to user's My Catalog page
 *
 * @param string $redirect_to
 * @param string $request_redirect_to
 * @param \WP_User $user
 *
 * @return string
 */
function login($redirect_to, $request_redirect_to, $user)
{
    if (false === is_a($user, 'WP_User')) {
        // Unknown user, bail with default
        return $redirect_to;
    }
    if (is_super_admin($user->ID)) {
        // This is an admin, don't mess
        return $redirect_to;
    }
    $blogs = get_blogs_of_user($user->ID);
    if (array_key_exists(get_current_blog_id(), $blogs)) {
        // Yes, user has access to this blog
        return $redirect_to;
    }
    if ($user->primary_blog) {
        // Force redirect the user to their blog or, if they have more than one, to their catalog, bypass wp_safe_redirect()
        if (count($blogs) > 1) {
            $redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/index.php?page=pb_catalog';
        } else {
            $redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/';
        }
        location($redirect);
    }
    // User has no primary_blog? Make them sign-up for one
    return network_site_url('/wp-signup.php');
}
开发者ID:Emaratilicious,项目名称:oddibooks,代码行数:36,代码来源:pb-redirect.php

示例10: custom_redirect_filter

function custom_redirect_filter($redirect_to, $request, $user)
{
    $user_blogs = get_blogs_of_user($user->ID);
    foreach ($user_blogs as $user_blog) {
        $user_blog->path;
        return site_url($user_blog->path);
    }
    return site_url();
}
开发者ID:wpmu,项目名称:wordpress-multisite-redirect,代码行数:9,代码来源:ms-redirect.php

示例11: wp_ozh_adminmenu_blogswitch_init

function wp_ozh_adminmenu_blogswitch_init()
{
    global $current_user, $current_blog;
    $blogs = get_blogs_of_user($current_user->ID);
    if (!$blogs) {
        return;
    }
    add_action('admin_menu', 'wp_ozh_adminmenu_blogswitch_ob_start');
    add_action('dashmenu', 'blogswitch_markup');
}
开发者ID:xenda,项目名称:camaraitalia,代码行数:10,代码来源:mu.php

示例12: test_get_active_blog_for_user_without_primary_site

 /**
  * @ticket 38355
  */
 public function test_get_active_blog_for_user_without_primary_site()
 {
     $sites = get_blogs_of_user(self::$user_id);
     $site_ids = array_keys($sites);
     $primary_site_id = $site_ids[0];
     delete_user_meta(self::$user_id, 'primary_blog');
     $result = get_active_blog_for_user(self::$user_id);
     wpmu_delete_blog($primary_site_id, true);
     $this->assertEquals($primary_site_id, $result->id);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:13,代码来源:getActiveBlogForUser.php

示例13: get_blog

 public static function get_blog($user_id)
 {
     $blogs = get_blogs_of_user($user_id);
     // if the user is associated with more than one site, we should assume it's an internal administrator(with no API keys), rather than a site user
     if (count($blogs) != 1) {
         wp_die(__("This user is associated with more than 1 site. Can't create API keys for these users"));
     }
     $blog = array_values($blogs)[0];
     return $blog;
 }
开发者ID:rooftopcms,项目名称:rooftop-api-authentication,代码行数:10,代码来源:class-rooftop-api-authentication-keys.php

示例14: admin_page_step_1

    /**
     * The default view of the 'Compare' admin menu page.
     */
    public function admin_page_step_1()
    {
        $user_id = get_current_user_id();
        $user_sites = get_blogs_of_user($user_id);
        ?>

		<h1>Compare Site Plugins</h1>
		<form action="plugins.php?page=bpp-compare-site-plugins" method="post">
			<label for="plugins">Paste the <strong>Plugin Code</strong> from another site running this plugin</label>
			<textarea name="plugins" id="plugins" rows="5" cols="70"></textarea>

		<?php 
        if (is_multisite() && $user_sites) {
            global $blog_id;
            ?>

			<p class="or">Or</p>
			<label>Select a Site</label>
			<select name="site_id">
				<option value=""></option>
			<?php 
            foreach ($user_sites as $site) {
                if ($site->userblog_id != $blog_id) {
                    ?>
				<option value="<?php 
                    echo intval($site->userblog_id);
                    ?>
"><?php 
                    echo $site->blogname;
                    ?>
</option>
			<?php 
                }
            }
            ?>
			</select>

		<?php 
        }
        ?>

			<?php 
        wp_nonce_field($user_id, 'nonce');
        ?>
			<input type="submit" class="button button-primary" value="Compare plugins">

			<label>Copy the following <strong>Plugin Code</strong> to compare the plugins on this site to another site</label>
			<textarea onclick="this.select()" rows="2" cols="70"><?php 
        echo base64_encode(serialize($this->sites_plugins));
        ?>
</textarea>

		</form>
		<?php 
    }
开发者ID:kingkool68,项目名称:wordpress-better-plugins-plugin,代码行数:58,代码来源:bpp-compare-site-plugins.php

示例15: wp_user_profiles_primary_site_metabox

/**
 * Render the primary-site metabox for user profile screen
 *
 * @since 0.1.0
 *
 * @param WP_User $user The WP_User object to be edited.
 */
function wp_user_profiles_primary_site_metabox($user = null)
{
    // Get sites
    $sites = (array) get_blogs_of_user($user->ID);
    $primary = (int) get_user_meta($user->ID, 'primary_blog', true);
    // If there is only 1 site, maybe do some clean-up
    if (count($sites) === 1) {
        $site = reset($sites);
        // Reset the primary site if it's out of sync
        if ($primary !== $site->userblog_id) {
            update_user_meta($user->ID, 'primary_blog', $site->userblog_id);
        }
    }
    ?>

	<table class="form-table">
		<tr>
			<th scope="row">
				<label for="primary_blog">
					<?php 
    _e('Primary Site', 'wp-user-profiles');
    ?>
				</label>
			</th>
			<td><?php 
    if (!empty($sites)) {
        // Sites
        ?>
<select name="primary_blog" id="primary_blog"><?php 
        foreach ($sites as $site) {
            ?>
<option value="<?php 
            echo esc_attr($site->userblog_id);
            ?>
" <?php 
            selected($primary, $site->userblog_id);
            ?>
><?php 
            echo esc_url(get_home_url($site->userblog_id));
            ?>
</option><?php 
        }
        ?>
</select><?php 
        // No sites
    } else {
        $user->ID === get_current_user_id() ? esc_html_e('You are not a member of any sites.', 'wp-user-profiles') : esc_html_e('This user is not a member of any sites.', 'wp-user-profiles');
    }
    ?>
</td>
		</tr>
	</table>

	<?php 
}
开发者ID:stuttter,项目名称:wp-user-profiles,代码行数:62,代码来源:sites-primary.php


注:本文中的get_blogs_of_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。