當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_User::has_prop方法代碼示例

本文整理匯總了PHP中WP_User::has_prop方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_User::has_prop方法的具體用法?PHP WP_User::has_prop怎麽用?PHP WP_User::has_prop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_User的用法示例。


在下文中一共展示了WP_User::has_prop方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: user_meta_shortcode_handler

/**
 * User Meta Shortcode handler
 * Retrieve the value of a property or meta key from the users and usermeta tables.
 * usage: [user_meta user_id=1 key="first_name" size="50" wpautop="on" pre="Pre Label " post="Post Label "]
 * @param  array $atts
 * @param  string $content
 * @return stirng
 */
function user_meta_shortcode_handler($atts, $content = null)
{
    if (!isset($atts['user_id'])) {
        $user = wp_get_current_user();
        $atts['user_id'] = $user->ID;
    }
    if (!isset($atts['size'])) {
        $atts['size'] = '50';
    }
    $user = new WP_User($atts['user_id']);
    if (!$user->exists()) {
        return;
    }
    if ($atts['key'] == 'avatar') {
        return $atts['pre'] . get_avatar($user->ID, $atts['size']) . $atts['post'];
    }
    if ($user->has_prop($atts['key'])) {
        if ($atts['wpautop'] == 'on') {
            $value = wpautop($user->get($atts['key']));
        } else {
            $value = $user->get($atts['key']);
        }
    }
    if (!empty($value)) {
        return $atts['pre'] . $value . $atts['post'];
    }
    return;
}
開發者ID:alvarpoon,項目名稱:aeg,代碼行數:36,代碼來源:pb_user_meta_shortcode.php

示例2:

 function test_has_prop()
 {
     $user_id = self::factory()->user->create(array('role' => 'author', 'user_login' => 'test_wp_user_has_prop', 'user_pass' => 'password', 'user_email' => 'test2@test.com'));
     $user = new WP_User($user_id);
     $this->assertTrue($user->has_prop('user_email'));
     $this->assertTrue($user->has_prop('use_ssl'));
     $this->assertFalse($user->has_prop('field_that_does_not_exist'));
     update_user_meta($user_id, 'dashed-key', 'abcdefg');
     $this->assertTrue($user->has_prop('dashed-key'));
 }
開發者ID:rclilly,項目名稱:wordpress-develop,代碼行數:10,代碼來源:user.php

示例3: get_user_option

/**
 * Retrieve user option that can be either per Site or per Network.
 *
 * If the user ID is not given, then the current user will be used instead. If
 * the user ID is given, then the user data will be retrieved. The filter for
 * the result, will also pass the original option name and finally the user data
 * object as the third parameter.
 *
 * The option will first check for the per site name and then the per Network name.
 *
 * @since 2.0.0
 * @uses $wpdb WordPress database object for queries.
 * @uses apply_filters() Calls 'get_user_option_$option' hook with result,
 *		option parameter, and user data object.
 *
 * @param string $option User option name.
 * @param int $user Optional. User ID.
 * @param bool $deprecated Use get_option() to check for an option in the options table.
 * @return mixed
 */
function get_user_option($option, $user = 0, $deprecated = '')
{
    global $wpdb;
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '3.0');
    }
    if (empty($user)) {
        $user = wp_get_current_user();
    } else {
        $user = new WP_User($user);
    }
    if (!isset($user->ID)) {
        return false;
    }
    if ($user->has_prop($wpdb->prefix . $option)) {
        // Blog specific
        $result = $user->get($wpdb->prefix . $option);
    } elseif ($user->has_prop($option)) {
        // User specific and cross-blog
        $result = $user->get($option);
    } else {
        $result = false;
    }
    return apply_filters("get_user_option_{$option}", $result, $option, $user);
}
開發者ID:prostart,項目名稱:cobblestonepath,代碼行數:45,代碼來源:user.php

示例4: column_hidden

 /**
  * Hide the SEO Title, Meta Desc and Focus KW columns if the user hasn't chosen which columns to hide
  *
  * @param array|false $result
  * @param string      $option
  * @param WP_User     $user
  *
  * @return array|false $result
  */
 public function column_hidden($result, $option, $user)
 {
     global $wpdb;
     $prefix = $wpdb->get_blog_prefix();
     if (!$user->has_prop($prefix . $option) && !$user->has_prop($option)) {
         if (!is_array($result)) {
             $result = array();
         }
         array_push($result, 'wpseo-title', 'wpseo-metadesc', 'wpseo-focuskw');
     }
     return $result;
 }
開發者ID:Nisha318,項目名稱:p3edtech,代碼行數:21,代碼來源:class-metabox.php

示例5:

 function test_has_prop()
 {
     $user = new WP_User(self::$author_id);
     $this->assertTrue($user->has_prop('user_email'));
     $this->assertTrue($user->has_prop('use_ssl'));
     $this->assertFalse($user->has_prop('field_that_does_not_exist'));
     update_user_meta(self::$author_id, 'dashed-key', 'abcdefg');
     $this->assertTrue($user->has_prop('dashed-key'));
 }
開發者ID:agup006,項目名稱:WordPress,代碼行數:9,代碼來源:user.php


注:本文中的WP_User::has_prop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。