当前位置: 首页>>代码示例>>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;未经允许,请勿转载。