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


PHP Author::get_display_name方法代码示例

本文整理汇总了PHP中Author::get_display_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::get_display_name方法的具体用法?PHP Author::get_display_name怎么用?PHP Author::get_display_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Author的用法示例。


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

示例1: log

 /**
  * Log handler
  *
  * @param Connector $connector Connector responsible for logging the event
  * @param string $message      sprintf-ready error message string
  * @param array  $args         sprintf (and extra) arguments to use
  * @param int $object_id       Target object id
  * @param string $context      Context of the event
  * @param string $action       Action of the event
  * @param int $user_id         User responsible for the event
  *
  * @return mixed True if updated, otherwise false|WP_Error
  */
 public function log($connector, $message, $args, $object_id, $context, $action, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = get_current_user_id();
     }
     if (is_null($object_id)) {
         $object_id = 0;
     }
     $wp_cron_tracking = isset($this->plugin->settings->options['advanced_wp_cron_tracking']) ? $this->plugin->settings->options['advanced_wp_cron_tracking'] : false;
     $author = new Author($user_id);
     $agent = $author->get_current_agent();
     // WP Cron tracking requires opt-in and WP Cron to be enabled
     if (!$wp_cron_tracking && 'wp_cron' === $agent) {
         return false;
     }
     $user = new \WP_User($user_id);
     if ($this->is_record_excluded($connector, $context, $action, $user)) {
         return false;
     }
     $user_meta = array('user_email' => (string) (!empty($user->user_email)) ? $user->user_email : '', 'display_name' => (string) $author->get_display_name(), 'user_login' => (string) (!empty($user->user_login)) ? $user->user_login : '', 'user_role_label' => (string) $author->get_role(), 'agent' => (string) $agent);
     if ('wp_cli' === $agent && function_exists('posix_getuid')) {
         $uid = posix_getuid();
         $user_info = posix_getpwuid($uid);
         $user_meta['system_user_id'] = (int) $uid;
         $user_meta['system_user_name'] = (string) $user_info['name'];
     }
     // Prevent any meta with null values from being logged
     $stream_meta = array_filter($args, function ($var) {
         return !is_null($var);
     });
     // Add user meta to Stream meta
     $stream_meta['user_meta'] = $user_meta;
     // All meta must be strings, so we will serialize any array meta values
     array_walk($stream_meta, function (&$v) {
         $v = (string) maybe_serialize($v);
     });
     // Get the current time in milliseconds
     $iso_8601_extended_date = wp_stream_get_iso_8601_extended_date();
     $recordarr = array('object_id' => (int) $object_id, 'site_id' => (int) is_multisite() ? get_current_site()->id : 1, 'blog_id' => (int) apply_filters('wp_stream_blog_id_logged', get_current_blog_id()), 'user_id' => (int) $user_id, 'user_role' => (string) (!empty($user->roles)) ? $user->roles[0] : '', 'created' => (string) $iso_8601_extended_date, 'summary' => (string) vsprintf($message, $args), 'connector' => (string) $connector, 'context' => (string) $context, 'action' => (string) $action, 'ip' => (string) wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP), 'meta' => (array) $stream_meta);
     if (0 === $recordarr['object_id']) {
         unset($recordarr['object_id']);
     }
     $result = $this->plugin->db->insert($recordarr);
     $this->debug_backtrace($recordarr);
     return $result;
 }
开发者ID:azanebrain,项目名称:representme,代码行数:59,代码来源:class-log.php

示例2: get_users_dropdown_items

 /**
  * Get users as dropdown items
  *
  * @param array $users
  *
  * @return array
  */
 public function get_users_dropdown_items($users)
 {
     $record_meta = array();
     foreach ($users as $user_id => $args) {
         $user = new Author($user_id);
         $disabled = isset($args['disabled']) ? $args['disabled'] : null;
         $record_meta[$user_id] = array('text' => $user->get_display_name(), 'id' => $user_id, 'label' => $user->get_display_name(), 'icon' => $user->get_avatar_src(32), 'title' => '', 'disabled' => $disabled);
     }
     return $record_meta;
 }
开发者ID:evgenykireev,项目名称:stream,代码行数:17,代码来源:class-list-table.php

示例3: test_get_display_name

 public function test_get_display_name()
 {
     $user = wp_get_current_user();
     $this->assertEquals($user->display_name, $this->author->get_display_name());
 }
开发者ID:rclilly,项目名称:stream,代码行数:5,代码来源:test-class-author.php


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