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


PHP WP_User::get方法代码示例

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


在下文中一共展示了WP_User::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: printForm

 /**
  * Return form HTML replacing variables in a template string.
  *
  * @return string
  */
 private function printForm()
 {
     $title = apply_filters('the_title', $this->post->post_title);
     $nonce = self::NONCE . get_current_blog_id();
     $data = ['action' => esc_attr(Launcher::SLUG . '_send_mail'), 'postId' => $this->post->ID, 'postTitle' => esc_attr($title), 'recipient' => esc_attr($this->author->get('user_email')), 'messageLabel' => esc_html__('Message:', 'reject-notify'), 'button' => get_submit_button(esc_html__('Send', 'reject-notify')), 'nonce' => wp_nonce_field($nonce, self::NONCE, true, false), 'title' => sprintf(esc_html__('Send reject mail to %s', 'reject-notify'), esc_html($this->author->get('display_name'))), 'message' => vsprintf(esc_html__('Sorry %s, your post %s was rejected.', 'reject-notify'), [esc_html($this->author->get('display_name')), '"' . esc_html($title) . '"'])];
     $template = file_get_contents(dirname($this->path) . '/templates/form.php');
     foreach ($data as $key => $value) {
         $template = str_replace("{{{{$key}}}}", $value, $template);
     }
     return $template;
 }
开发者ID:makeandship,项目名称:RejectNotify,代码行数:16,代码来源:FormCase.php

示例3: _convertToEntity

 /**
  * @param \WP_User $user
  * @return UserEntity|null
  */
 protected function _convertToEntity(\WP_User $user)
 {
     $id = (int) $user->ID;
     if ($entity = $this->_getEntity($id)) {
         return $entity;
     }
     $caps = $user->get_role_caps();
     $isAdmin = (bool) Vars::get($caps['administrator'], false);
     $data = new Data(['id' => $id, 'login' => $user->get('user_login'), 'name' => $user->get('display_name'), 'email' => $user->get('user_email'), 'is_admin' => $isAdmin]);
     $this->_users[$id] = new UserEntity($data);
     return $this->_users[$id];
 }
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:16,代码来源:User.php

示例4: replace_merge_tag

 /**
  * Exactly like Gravity Forms' User Meta functionality, but instead shows information on the user who created the entry
  * instead of the currently logged-in user.
  *
  * @see http://docs.gravityview.co/article/281-the-createdby-merge-tag Read how to use the `{created_by}` merge tag
  *
  * @since 1.16
  *
  * @param array $matches Array of Merge Tag matches found in text by preg_match_all
  * @param string $text Text to replace
  * @param array $form Gravity Forms form array
  * @param array $entry Entry array
  * @param bool $url_encode Whether to URL-encode output
  * @param bool $esc_html Whether to apply `esc_html()` to output
  *
  * @return string Text, with user variables replaced, if they existed
  */
 public function replace_merge_tag($matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false)
 {
     // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
     if (empty($entry['created_by'])) {
         return $text;
     }
     // Get the creator of the entry
     $entry_creator = new WP_User($entry['created_by']);
     foreach ($matches as $match) {
         $full_tag = $match[0];
         $property = $match[1];
         switch ($property) {
             /** @since 1.13.2 */
             case 'roles':
                 $value = implode(', ', $entry_creator->roles);
                 break;
             default:
                 $value = $entry_creator->get($property);
         }
         $value = $url_encode ? urlencode($value) : $value;
         $value = $esc_html ? esc_html($value) : $value;
         $text = str_replace($full_tag, $value, $text);
     }
     unset($entry_creator);
     return $text;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:43,代码来源:class-gravityview-field-created-by.php

示例5: is_users_email

 public static function is_users_email($email, $user_id = false)
 {
     if (!$user_id) {
         $user_id = get_current_user_id();
     }
     $user = new WP_User($user_id);
     return $user->get('user_email') == $email;
 }
开发者ID:Inteleck,项目名称:hwc,代码行数:8,代码来源:userregistration.php

示例6: add_note

 public function add_note($entry_id, $note, $user_id = false)
 {
     if ($user_id) {
         $user = new WP_User($user_id);
         $user_name = $user->get('display_name');
     } else {
         $user_id = 0;
         $user_name = 'System';
     }
     GFFormsModel::add_note($entry_id, $user_id, $user_name, $note);
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:11,代码来源:class-gf-payment-addon.php

示例7: user_to_property_map

 /**
  * Convert a WP_User instance to an associative array with the keys defined
  * in the AmeUserPropertyMap interface in actor-manager.ts.
  *
  * @param WP_User $user
  * @return array
  */
 public function user_to_property_map($user)
 {
     return array('user_login' => $user->get('user_login'), 'id' => $user->ID, 'roles' => !empty($user->roles) ? (array) $user->roles : array(), 'capabilities' => $this->castValuesToBool($user->caps), 'display_name' => $user->display_name, 'is_super_admin' => is_multisite() && is_super_admin($user->ID));
 }
开发者ID:kohactive,项目名称:sage-but-better,代码行数:11,代码来源:menu-editor-core.php

示例8: check_meta_values

 /**
  * Track changes to ACF values within rendered post meta forms
  *
  * @param string $type       Type of object, post or user
  * @param string $action     Added, updated, deleted
  * @param integer $meta_id
  * @param integer $object_id
  * @param string $key
  * @param mixed|null $value
  *
  * @return bool
  */
 public function check_meta_values($type, $action, $meta_id, $object_id, $key, $value = null)
 {
     unset($action);
     unset($meta_id);
     if (empty($this->cached_field_values_updates)) {
         return false;
     }
     $object_key = $object_id;
     if ('user' === $type) {
         $object_key = 'user_' . $object_id;
     } elseif ('taxonomy' === $type) {
         if (0 === strpos($key, '_')) {
             // Ignore the 'revision' stuff!
             return false;
         }
         if (1 !== preg_match('#([a-z0-9_-]+)_([\\d]+)_([a-z0-9_-]+)#', $key, $matches)) {
             return false;
         }
         list(, $taxonomy, $term_id, $key) = $matches;
         // Skips 0 index
         $object_key = $taxonomy . '_' . $term_id;
     }
     if (isset($this->cached_field_values_updates[$object_key][$key])) {
         if ('post' === $type) {
             $posts_connector = new Connector_Posts();
             $post = get_post($object_id);
             $title = $post->post_title;
             $type_name = strtolower($posts_connector->get_post_type_name($post->post_type));
         } elseif ('user' === $type) {
             $user = new \WP_User($object_id);
             $title = $user->get('display_name');
             $type_name = esc_html__('user', 'stream');
         } elseif ('taxonomy' === $type && isset($term_id) && isset($taxonomy)) {
             $term = get_term($term_id, $taxonomy);
             $title = $term->name;
             $tax_obj = get_taxonomy($taxonomy);
             $type_name = strtolower(get_taxonomy_labels($tax_obj)->singular_name);
         } else {
             return false;
         }
         $cache = $this->cached_field_values_updates[$object_key][$key];
         $this->log(esc_html_x('"%1$s" of "%2$s" %3$s updated', 'acf', 'stream'), array('field_label' => $cache['field']['label'], 'title' => $title, 'singular_name' => $type_name, 'meta_value' => $value, 'meta_key' => $key, 'meta_type' => $type), $object_id, 'values', 'updated');
     }
     return true;
 }
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:57,代码来源:class-connector-acf.php

示例9: sendEmailTwoFactorVerify

 /**
  * @param WP_User $oUser
  * @param string $sIpAddress
  * @param string $sSessionId
  * @return boolean
  */
 public function sendEmailTwoFactorVerify(WP_User $oUser, $sIpAddress, $sSessionId)
 {
     $sEmail = $oUser->get('user_email');
     $sAuthLink = $this->generateTwoFactorVerifyLink($oUser->get('user_login'), $sSessionId);
     $aMessage = array(_wpsf__('You, or someone pretending to be you, just attempted to login into your WordPress site.'), _wpsf__('The IP Address / Cookie from which they tried to login is not currently verified.'), _wpsf__('Click the following link to validate and complete the login process.') . ' ' . _wpsf__('You will be logged in automatically upon successful authentication.'), sprintf(_wpsf__('Username: %s'), $oUser->get('user_login')), sprintf(_wpsf__('IP Address: %s'), $sIpAddress), sprintf(_wpsf__('Authentication Link: %s'), $sAuthLink));
     $sEmailSubject = sprintf(_wpsf__('Two-Factor Login Verification for %s'), $this->loadWpFunctionsProcessor()->getHomeUrl());
     $bResult = $this->getEmailProcessor()->sendEmailTo($sEmail, $sEmailSubject, $aMessage);
     if ($bResult) {
         $sAuditMessage = sprintf(_wpsf__('User "%s" was sent an email to verify their Identity using Two-Factor Login Auth for IP address "%s".'), $oUser->get('user_login'), $sIpAddress);
         $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_two_factor_email_send');
     } else {
         $sAuditMessage = sprintf(_wpsf__('Tried to send email to User "%s" to verify their identity using Two-Factor Login Auth for IP address "%s", but email sending failed.'), $oUser->get('user_login'), $sIpAddress);
         $this->addToAuditEntry($sAuditMessage, 3, 'login_protect_two_factor_email_send_fail');
     }
     return $bResult;
 }
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:22,代码来源:loginprotect_twofactorauth.php

示例10: show_user_profile

 /**
  * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
  *
  * The action only fires if the current user is editing their own profile.
  *
  * @since WP 2.0.0
  *
  * @param WP_User $profileuser The current WP_User object.
  */
 public function show_user_profile($profileuser)
 {
     echo '<br clear="all" /><a name="wpdk"></a>';
     $message = __('This view <strong>is enhanced</strong> by wpXtreme and WPDK framework. Please, have a look below for additional information.', WPDK_TEXTDOMAIN);
     $alert = new WPDKUIAlert('wpdk-alert-show_user_profile', $message, WPDKUIAlertType::INFORMATION);
     $alert->dismissPermanent = true;
     $alert->display();
     // Only the administrator can edit this extra information
     $disabled = !current_user_can('manage_options');
     // Sanitize values
     $last_time_success_login = $profileuser->get(WPDKUserMeta::LAST_TIME_SUCCESS_LOGIN);
     $last_time_wrong_login = $profileuser->get(WPDKUserMeta::LAST_TIME_WRONG_LOGIN);
     $last_time_logout = $profileuser->get(WPDKUserMeta::LAST_TIME_LOGOUT);
     $status_description = $profileuser->get(WPDKUserMeta::STATUS_DESCRIPTION);
     // Display WPDK user extends information
     $fields = array(__('Login information', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_SUCCESS_LOGIN, 'label' => __('Last success login', WPDK_TEXTDOMAIN), 'value' => empty($last_time_success_login) ? '' : WPDKDateTime::format($last_time_success_login, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled), array('type' => WPDKUIControlType::NUMBER, 'name' => WPDKUserMeta::COUNT_SUCCESS_LOGIN, 'label' => __('# success login', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::COUNT_SUCCESS_LOGIN), 'disabled' => true)), array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_WRONG_LOGIN, 'label' => __('Last wrong login', WPDK_TEXTDOMAIN), 'value' => empty($last_time_wrong_login) ? '' : WPDKDateTime::format($last_time_wrong_login, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled), array('type' => WPDKUIControlType::NUMBER, 'name' => WPDKUserMeta::COUNT_WRONG_LOGIN, 'label' => __('# wrong login', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::COUNT_WRONG_LOGIN), 'disabled' => $disabled))), __('Logout information', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_LOGOUT, 'label' => __('Last logout', WPDK_TEXTDOMAIN), 'value' => empty($last_time_logout) ? '' : WPDKDateTime::format($last_time_logout, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled))), __('Status', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::SELECT, 'name' => WPDKUserMeta::STATUS, 'label' => __('Status', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::STATUS), 'options' => WPDKUserStatus::statuses(), 'disabled' => $disabled)), array(array('type' => WPDKUIControlType::TEXTAREA, 'name' => WPDKUserMeta::STATUS_DESCRIPTION, 'rows' => 3, 'cols' => 40, 'label' => __('Description', WPDK_TEXTDOMAIN), 'placeholder' => __('eg: this user is disabled because...', WPDK_TEXTDOMAIN), 'value' => $status_description, 'disabled' => $disabled))));
     /**
      * Filter the layout control array with the extra WPDK fields.
      *
      * You can use this filter or `wpdk_users_show_user_profile` action to modify the default layout control array.
      *
      * @param array   $fields      Layout array fields.
      * @param WP_User $profileuser The current WP_User object.
      */
     $fields = apply_filters('wpdk_users_fields_profile', $fields, $profileuser);
     $layout = new WPDKUIControlsLayout($fields);
     /**
      * Fires after display the layout controls.
      *
      * You can use this action or `wpdk_users_fields_profile` filter to modify the default layout control array.
      *
      * @deprecated since 1.7.2 - Use `wpdk_user_profile_tabs` filter instead
      *
      * @param WP_User $profileuser The current WP_User object.
      */
     do_action('wpdk_users_show_user_profile', $profileuser);
     // Defaults
     $tabs = array();
     if (current_user_can('edit_users')) {
         // WPDK tabs
         $tabs = array(new WPDKjQueryTab('wpdk-user-profile', __('WPDK'), '<div id="wpdk-user-profile">' . $layout->html() . '</div>'));
     }
     /**
      * Filter the tabs list used to extends user profile edit.
      *
      * @since 1.7.2
      *
      * @param array   $tabs        The array tabs list.
      * @param WP_User $profileuser The current WP_User object.
      */
     $tabs = apply_filters('wpdk_user_profile_tabs', $tabs, $profileuser);
     $jquery_tabs = new WPDKjQueryTabsView('wpdk-users', $tabs, true);
     $jquery_tabs->display();
 }
开发者ID:wpxtreme,项目名称:wpdk,代码行数:63,代码来源:wpdk-users.php

示例11: get_donor_name

 /**
  * Returns the name of the donor. 
  *
  * @return  string
  * @access  private
  * @since   1.0.0
  */
 private function get_donor_name()
 {
     $user = new WP_User($this->get_donation_data_value('user_id', 0));
     $user_data = $this->get_donation_data_value('user');
     $first_name = isset($user_data['first_name']) ? $user_data['first_name'] : $user->get('first_name');
     $last_name = isset($user_data['last_name']) ? $user_data['last_name'] : $user->get('last_name');
     return trim(sprintf('%s %s', $first_name, $last_name));
 }
开发者ID:altatof,项目名称:Charitable,代码行数:15,代码来源:class-charitable-donation-processor.php

示例12: sendLoginEmailNotification

 /**
  * @param WP_User $oUser
  * @return bool
  */
 protected function sendLoginEmailNotification($oUser)
 {
     if (!$oUser instanceof WP_User) {
         return false;
     }
     $fIsAdministrator = isset($oUser->caps['administrator']) && $oUser->caps['administrator'];
     if (!$fIsAdministrator) {
         return false;
     }
     $oDp = $this->loadDataProcessor();
     $oEmailer = $this->getFeatureOptions()->getEmailProcessor();
     $sHomeUrl = $this->loadWpFunctionsProcessor()->getHomeUrl();
     $aMessage = array(sprintf(_wpsf__('As requested, %s is notifying you of an administrator login to a WordPress site that you manage.'), $this->getController()->getHumanName()), _wpsf__('Details for this user are below:'), '- ' . sprintf(_wpsf__('Site URL: %s'), $sHomeUrl), '- ' . sprintf(_wpsf__('Username: %s'), $oUser->get('user_login')), '- ' . sprintf(_wpsf__('IP Address: %s'), $oDp->getVisitorIpAddress(true)), _wpsf__('Thanks.'));
     $bResult = $oEmailer->sendEmailTo($this->getOption('enable_admin_login_email_notification'), sprintf(_wpsf__('Notice - %s'), sprintf(_wpsf__('An Administrator Just Logged Into %s'), $sHomeUrl)), $aMessage);
     return $bResult;
 }
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:20,代码来源:user_management.php

示例13: checkYubikeyOtpAuth_Filter

 /**
  * @param WP_User $oUser
  * @return WP_User|WP_Error
  */
 public function checkYubikeyOtpAuth_Filter($oUser)
 {
     $oError = new WP_Error();
     $sUsername = $oUser->get('user_login');
     // Before anything else we check that a Yubikey pair has been provided for this username (and that there are pairs in the first place!)
     $aYubikeyUsernamePairs = $this->getOption('yubikey_unique_keys');
     if (!$this->getIsYubikeyConfigReady()) {
         // configuration is clearly not completed yet.
         return $oUser;
     }
     $sOneTimePassword = empty($_POST['yubiotp']) ? '' : trim($_POST['yubiotp']);
     $sAppId = $this->getOption('yubikey_app_id');
     $sApiKey = $this->getOption('yubikey_api_key');
     // check that if we have a list of permitted keys, that the one used is on that list connected with the username.
     $sYubikey12 = substr($sOneTimePassword, 0, 12);
     $fUsernameFound = false;
     // if username is never found, it means there's no yubikey specified which means we can bypass this authentication method.
     $fFoundMatch = false;
     foreach ($aYubikeyUsernamePairs as $aUsernameYubikeyPair) {
         if (isset($aUsernameYubikeyPair[$sUsername])) {
             $fUsernameFound = true;
             if ($aUsernameYubikeyPair[$sUsername] == $sYubikey12) {
                 $fFoundMatch = true;
                 break;
             }
         }
     }
     // If no yubikey-username pair found for given username, we by-pass Yubikey auth.
     if (!$fUsernameFound) {
         $sAuditMessage = sprintf(_wpsf__('User "%s" logged in without a Yubikey One Time Password because no username-yubikey pair was found for this user.'), $sUsername);
         $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_yubikey_bypass');
         return $oUser;
     }
     // Username was found in the list of key pairs, but the yubikey provided didn't match that username.
     if (!$fFoundMatch) {
         $oError->add('yubikey_not_allowed', sprintf(_wpsf__('ERROR: %s'), _wpsf__('The Yubikey provided is not on the list of permitted keys for this user.')));
         $sAuditMessage = sprintf(_wpsf__('User "%s" attempted to login but Yubikey ID "%s" used was not in list of authorised keys.'), $sUsername, $sYubikey12);
         $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_yubikey_fail_permitted_id');
         return $oError;
     }
     $oFs = $this->loadFileSystemProcessor();
     $sNonce = md5(uniqid(rand()));
     $sUrl = sprintf(self::YubikeyVerifyApiUrl, $sAppId, $sOneTimePassword, $sNonce);
     $sRawYubiRequest = $oFs->getUrlContent($sUrl);
     // Validate response.
     // 1. Check OTP and Nonce
     if (!preg_match('/otp=' . $sOneTimePassword . '/', $sRawYubiRequest, $aMatches) || !preg_match('/nonce=' . $sNonce . '/', $sRawYubiRequest, $aMatches)) {
         $oError->add('yubikey_validate_fail', sprintf(_wpsf__('ERROR: %s'), _wpsf__('The Yubikey authentication was not validated successfully.')));
         $sAuditMessage = sprintf(_wpsf__('User "%s" attempted to login but Yubikey One Time Password failed to validate due to invalid Yubi API.'), $sUsername);
         $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_yubikey_fail_invalid_api');
         return $oError;
     }
     // Optionally we can check the hash, but since we're using HTTPS, this isn't necessary and adds more PHP requirements
     // 2. Check status directly within response
     preg_match('/status=([a-zA-Z0-9_]+)/', $sRawYubiRequest, $aMatches);
     $sStatus = $aMatches[1];
     if ($sStatus != 'OK' && $sStatus != 'REPLAYED_OTP') {
         $oError->add('yubikey_validate_fail', sprintf(_wpsf__('ERROR: %s'), _wpsf__('The Yubikey authentication was not validated successfully.')));
         $sAuditMessage = sprintf(_wpsf__('User "%s" attempted to login but Yubikey One Time Password failed to validate due to invalid Yubi API response status: "%s".'), $sUsername, $sStatus);
         $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_yubikey_fail_invalid_api_response');
         return $oError;
     }
     $sAuditMessage = sprintf(_wpsf__('User "%s" successfully logged in using a validated Yubikey One Time Password.'), $sUsername);
     $this->addToAuditEntry($sAuditMessage, 2, 'login_protect_yubikey_login_success');
     return $oUser;
 }
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:70,代码来源:loginprotect_yubikey.php

示例14: foreach

 /**
  * Target for the gform_pre_replace_merge_tags filter. Replaces the workflow_timeline and created_by merge tags.
  *
  *
  * @param string $text
  * @param array $form
  * @param array $entry
  * @param bool $url_encode
  * @param bool $esc_html
  * @param bool $nl2br
  * @param string $format
  *
  * @return string
  */
 function replace_variables($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format)
 {
     preg_match_all('/{workflow_timeline(:(.*?))?}/', $text, $timeline_matches, PREG_SET_ORDER);
     if (is_array($timeline_matches) && isset($timeline_matches[0])) {
         $full_tag = $timeline_matches[0][0];
         require_once gravity_flow()->get_base_path() . '/includes/pages/class-entry-detail.php';
         $notes = Gravity_Flow_Entry_Detail::get_timeline_notes($entry);
         $html = '';
         foreach ($notes as $note) {
             $html .= '<br />';
             $html .= GFCommon::format_date($note->date_created, false, 'd M Y g:i a', false);
             $html .= ': ';
             if (empty($note->user_id)) {
                 if ($note->user_name !== 'gravityflow') {
                     $step = Gravity_Flow_Steps::get($note->user_name);
                     if ($step) {
                         $html .= $step->get_label();
                     }
                 } else {
                     $html .= esc_html(gravity_flow()->translate_navigation_label('Workflow'));
                 }
             } else {
                 $html .= esc_html($note->user_name);
             }
             $html .= '<br />';
             $html .= nl2br(esc_html($note->value));
             $html .= '<br />';
         }
         $text = str_replace($full_tag, $html, $text);
     }
     preg_match_all('/{created_by(:(.*?))?}/', $text, $created_by_matches, PREG_SET_ORDER);
     if (is_array($created_by_matches)) {
         if (!empty($entry['created_by'])) {
             $entry_creator = new WP_User($entry['created_by']);
             foreach ($created_by_matches as $created_by_match) {
                 if (!isset($created_by_match[2])) {
                     continue;
                 }
                 $full_tag = $created_by_match[0];
                 $property = $created_by_match[2];
                 if ($property == 'roles') {
                     $value = implode(', ', $entry_creator->roles);
                 } else {
                     $value = $entry_creator->get($property);
                 }
                 $value = esc_html($value);
                 $text = str_replace($full_tag, $value, $text);
             }
         }
     }
     return $text;
 }
开发者ID:jakejackson1,项目名称:gravityflow,代码行数:66,代码来源:class-gravity-flow.php

示例15: 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


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