本文整理汇总了PHP中nxt_cache_set函数的典型用法代码示例。如果您正苦于以下问题:PHP nxt_cache_set函数的具体用法?PHP nxt_cache_set怎么用?PHP nxt_cache_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nxt_cache_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_topic
function get_topic($id, $cache = true)
{
global $bbdb;
if (!is_numeric($id)) {
list($slug, $sql) = bb_get_sql_from_slug('topic', $id);
$id = nxt_cache_get($slug, 'bb_topic_slug');
}
// not else
if (is_numeric($id)) {
$id = (int) $id;
$sql = "topic_id = {$id}";
}
if (0 === $id || !$sql) {
return false;
}
// &= not =&
$cache &= 'AND topic_status = 0' == ($where = apply_filters('get_topic_where', 'AND topic_status = 0'));
if (($cache || !$where) && is_numeric($id) && false !== ($topic = nxt_cache_get($id, 'bb_topic'))) {
return $topic;
}
// $where is NOT bbdb:prepared
$topic = $bbdb->get_row("SELECT * FROM {$bbdb->topics} WHERE {$sql} {$where}");
$topic = bb_append_meta($topic, 'topic');
if ($cache) {
nxt_cache_set($topic->topic_id, $topic, 'bb_topic');
nxt_cache_add($topic->topic_slug, $topic->topic_id, 'bb_topic_slug');
}
return $topic;
}
示例2: bb_get_post
function bb_get_post($post_id)
{
global $bbdb;
$post_id = (int) $post_id;
if (false === ($post = nxt_cache_get($post_id, 'bb_post'))) {
$post = $bbdb->get_row($bbdb->prepare("SELECT * FROM {$bbdb->posts} WHERE post_id = %d", $post_id));
$post = bb_append_meta($post, 'post');
nxt_cache_set($post_id, $post, 'bb_post');
}
return $post;
}
示例3: bp_adminbar_blogs_menu
function bp_adminbar_blogs_menu()
{
global $bp;
if (!is_user_logged_in() || !bp_is_active('blogs')) {
return false;
}
if (!is_multisite()) {
return false;
}
if (!($blogs = nxt_cache_get('bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp'))) {
$blogs = bp_blogs_get_blogs_for_user($bp->loggedin_user->id, true);
nxt_cache_set('bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp');
}
$counter = 0;
if (is_array($blogs['blogs']) && (int) $blogs['count']) {
echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit($bp->loggedin_user->domain . bp_get_blogs_slug()) . '">';
_e('My Sites', 'buddypress');
echo '</a>';
echo '<ul>';
foreach ((array) $blogs['blogs'] as $blog) {
$alt = 0 == $counter % 2 ? ' class="alt"' : '';
$site_url = esc_attr($blog->siteurl);
echo '<li' . $alt . '>';
echo '<a href="' . $site_url . '">' . esc_html($blog->name) . '</a>';
echo '<ul>';
echo '<li class="alt"><a href="' . $site_url . 'nxt-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
echo '<li><a href="' . $site_url . 'nxt-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
echo '<li class="alt"><a href="' . $site_url . 'nxt-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
echo '<li><a href="' . $site_url . 'nxt-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
echo '</ul>';
do_action('bp_adminbar_blog_items', $blog);
echo '</li>';
$counter++;
}
$alt = 0 == $counter % 2 ? ' class="alt"' : '';
if (bp_blog_signup_enabled()) {
echo '<li' . $alt . '>';
echo '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __('Create a Site!', 'buddypress') . '</a>';
echo '</li>';
}
echo '</ul>';
echo '</li>';
}
}
示例4: groups_update_groupmeta
function groups_update_groupmeta($group_id, $meta_key, $meta_value)
{
global $nxtdb, $bp;
if (!is_numeric($group_id)) {
return false;
}
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
if (is_string($meta_value)) {
$meta_value = stripslashes($nxtdb->escape($meta_value));
}
$meta_value = maybe_serialize($meta_value);
if (empty($meta_value)) {
return groups_delete_groupmeta($group_id, $meta_key);
}
$cur = $nxtdb->get_row($nxtdb->prepare("SELECT * FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key));
if (!$cur) {
$nxtdb->query($nxtdb->prepare("INSERT INTO " . $bp->groups->table_name_groupmeta . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value));
} else {
if ($cur->meta_value != $meta_value) {
$nxtdb->query($nxtdb->prepare("UPDATE " . $bp->groups->table_name_groupmeta . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key));
} else {
return false;
}
}
// Update the cached object and recache
nxt_cache_set('bp_groups_groupmeta_' . $group_id . '_' . $meta_key, $meta_value, 'bp');
return true;
}
示例5: dpa_get_achievement_picture
/**
* Returns Achievement's picture; takes into account size of image required
*
* @since 2.0
* @global DPA_Achievement_Template $achievements_template Achievements template tag object
* @global int $blog_id Site ID
* @global object $bp BuddyPress global settings
* @param string $size Optional; set to "thumb" to fetch thumbnail-sized picture, and "activitystream" for a thumbnail-sized picture with width/height style tags.
* @return string HTML image tag
*/
function dpa_get_achievement_picture($size = '')
{
global $achievements_template, $blog_id, $bp;
$achievement_slug = dpa_get_achievement_slug();
$achievement_id = dpa_get_achievement_id();
if ('thumb' == $size || 'activitystream' == $size) {
$is_thumbnail = true;
} else {
$is_thumbnail = dpa_get_achievement_picture_is_thumbnail();
}
if (($picture_id = dpa_get_achievement_picture_id()) < 1) {
if (empty($bp->grav_default->user)) {
$default_grav = 'wavatar';
} elseif ('mystery' == $bp->grav_default->user) {
$default_grav = apply_filters('bp_core_mysteryman_src', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg');
} else {
$default_grav = $bp->grav_default->user;
}
if ('thumb' == $size) {
$grav_size = apply_filters('dpa_get_achievement_picture_gravatar_width', BP_AVATAR_THUMB_WIDTH, 'thumb');
} elseif ('activitystream' == $size) {
$grav_size = apply_filters('dpa_get_achievement_picture_gravatar_width', 20, 'activitystream');
} else {
$grav_size = apply_filters('dpa_get_achievement_picture_gravatar_width', BP_AVATAR_FULL_WIDTH, 'full');
}
$email = apply_filters('bp_core_gravatar_email', $achievement_slug . '@' . $bp->root_domain, $achievement_id, 'achievements');
if (is_ssl()) {
$host = 'https://secure.gravatar.com/avatar/';
} else {
$host = 'http://www.gravatar.com/avatar/';
}
$avatar_url = apply_filters('bp_gravatar_url', $host) . md5($email) . '?d=' . $default_grav . '&s=' . $grav_size;
} else {
if ($cached_urls = nxt_cache_get('dpa_achievement_picture_urls', 'dpa') && isset($cached_urls) && is_array($cached_urls) && isset($cached_urls[$picture_id]) && $cached_urls[$picture_id]) {
$avatar_url = $cached_urls[$picture_id];
} else {
if ($is_nonroot_multisite = is_multisite() && BP_ROOT_BLOG != $blog_id) {
switch_to_blog(BP_ROOT_BLOG);
}
// Necessary evil
list($avatar_url, $avatar_width, $avatar_height, $is_intermediate) = image_downsize($picture_id, 'large');
if ($is_nonroot_multisite) {
restore_current_blog();
}
if (!is_array($cached_urls)) {
$cached_urls = array($picture_id => $avatar_url);
} else {
$cached_urls[$picture_id] = $avatar_url;
}
$grav_size = 0;
nxt_cache_set('dpa_achievement_picture_urls', $cached_urls, 'dpa');
}
}
$style = '';
if ('activitystream' == $size && ('mystery' == $bp->grav_default->user || $picture_id > 0)) {
$style = 'width="20" height="20"';
}
if ($is_thumbnail) {
$picture_type = "avatar-thumbnail";
} else {
$picture_type = "avatar-full";
}
$url = '<img src="' . esc_url($avatar_url) . '" alt="' . esc_attr(dpa_get_achievement_name()) . '" title="' . esc_attr(dpa_get_achievement_name()) . '" ' . $style . ' class="avatar' . esc_attr(' achievement-' . $achievement_slug . '-avatar ') . $picture_type . '" />';
return apply_filters('dpa_get_achievement_picture', $url, $achievement_id, $picture_id, $grav_size, $style);
}
示例6: update_object_term_cache
/**
* Updates the cache for Term ID(s).
*
* Will only update the cache for terms not already cached.
*
* The $object_ids expects that the ids be separated by commas, if it is a
* string.
*
* It should be noted that update_object_term_cache() is very time extensive. It
* is advised that the function is not called very often or at least not for a
* lot of terms that exist in a lot of taxonomies. The amount of time increases
* for each term and it also increases for each taxonomy the term belongs to.
*
* @package NXTClass
* @subpackage Taxonomy
* @since 2.3.0
* @uses $this->get_object_terms() Used to get terms from the database to update
*
* @param string|array $object_ids Single or list of term object ID(s)
* @param string $object_type The taxonomy object type
* @return null|bool Null value is given with empty $object_ids. False if
*/
function update_object_term_cache($object_ids, $object_type)
{
if (empty($object_ids)) {
return;
}
if (!is_array($object_ids)) {
$object_ids = explode(',', $object_ids);
}
$object_ids = array_map('intval', $object_ids);
$taxonomies = $this->get_object_taxonomies($object_type);
$ids = array();
foreach ((array) $object_ids as $id) {
foreach ($taxonomies as $taxonomy) {
if (false === nxt_cache_get($id, "{$taxonomy}_relationships")) {
$ids[] = $id;
break;
}
}
}
if (empty($ids)) {
return false;
}
$terms = $this->get_object_terms($ids, $taxonomies, 'fields=all_with_object_id');
$object_terms = array();
foreach ((array) $terms as $term) {
$object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
}
foreach ($ids as $id) {
foreach ($taxonomies as $taxonomy) {
if (!isset($object_terms[$id][$taxonomy])) {
if (!isset($object_terms[$id])) {
$object_terms[$id] = array();
}
$object_terms[$id][$taxonomy] = array();
}
}
}
foreach ($object_terms as $id => $value) {
foreach ($value as $taxonomy => $terms) {
nxt_cache_set($id, $terms, "{$taxonomy}_relationships");
}
}
}
示例7: get_adjacent_post
/**
* Retrieve adjacent post.
*
* Can either be next or previous post.
*
* @since 2.5.0
*
* @param bool $in_same_cat Optional. Whether post should be in a same category.
* @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
* @param bool $previous Optional. Whether to retrieve previous post.
* @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
*/
function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true)
{
global $post, $nxtdb;
if (empty($post)) {
return null;
}
$current_post_date = $post->post_date;
$join = '';
$posts_in_ex_cats_sql = '';
if ($in_same_cat || !empty($excluded_categories)) {
$join = " INNER JOIN {$nxtdb->term_relationships} AS tr ON p.ID = tr.object_id INNER JOIN {$nxtdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
if ($in_same_cat) {
$cat_array = nxt_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
}
$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
if (!empty($excluded_categories)) {
if (!is_array($excluded_categories)) {
// back-compat, $excluded_categories used to be IDs separated by " and "
if (strpos($excluded_categories, ' and ') !== false) {
_deprecated_argument(__FUNCTION__, '3.3', sprintf(__('Use commas instead of %s to separate excluded categories.'), "'and'"));
$excluded_categories = explode(' and ', $excluded_categories);
} else {
$excluded_categories = explode(',', $excluded_categories);
}
}
$excluded_categories = array_map('intval', $excluded_categories);
if (!empty($cat_array)) {
$excluded_categories = array_diff($excluded_categories, $cat_array);
$posts_in_ex_cats_sql = '';
}
if (!empty($excluded_categories)) {
$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
}
}
}
$adjacent = $previous ? 'previous' : 'next';
$op = $previous ? '<' : '>';
$order = $previous ? 'DESC' : 'ASC';
$join = apply_filters("get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories);
$where = apply_filters("get_{$adjacent}_post_where", $nxtdb->prepare("WHERE p.post_date {$op} %s AND p.post_type = %s AND p.post_status = 'publish' {$posts_in_ex_cats_sql}", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories);
$sort = apply_filters("get_{$adjacent}_post_sort", "ORDER BY p.post_date {$order} LIMIT 1");
$query = "SELECT p.* FROM {$nxtdb->posts} AS p {$join} {$where} {$sort}";
$query_key = 'adjacent_post_' . md5($query);
$result = nxt_cache_get($query_key, 'counts');
if (false !== $result) {
return $result;
}
$result = $nxtdb->get_row("SELECT p.* FROM {$nxtdb->posts} AS p {$join} {$where} {$sort}");
if (null === $result) {
$result = '';
}
nxt_cache_set($query_key, $result, 'counts');
return $result;
}
示例8: bb_set_transient
/**
* Set/update the value of a transient
*
* You do not need to serialize values, if the value needs to be serialize, then
* it will be serialized before it is set.
*
* @since 1.0
* @package bbPress
* @subpackage Transient
*
* @param string $transient Transient name. Expected to not be SQL-escaped
* @param mixed $value Transient value.
* @param int $expiration Time until expiration in seconds, default 0
* @return bool False if value was not set and true if value was set.
*/
function bb_set_transient($transient, $value, $expiration = 0)
{
global $_bb_using_ext_object_cache, $bbdb;
if ($_bb_using_ext_object_cache) {
return nxt_cache_set($transient, $value, 'transient', $expiration);
} else {
$transient_timeout = '_transient_timeout_' . $bbdb->escape($transient);
$transient = '_transient_' . $bbdb->escape($transient);
if (0 != $expiration) {
bb_update_option($transient_timeout, time() + $expiration);
}
return bb_update_option($transient, $value);
}
}
示例9: get_calendar
/**
* Display calendar with days that have posts as links.
*
* The calendar is cached, which will be retrieved, if it exists. If there are
* no posts for the month, then it will not be displayed.
*
* @since 1.0.0
*
* @param bool $initial Optional, default is true. Use initial calendar names.
* @param bool $echo Optional, default is true. Set to false for return.
*/
function get_calendar($initial = true, $echo = true)
{
global $nxtdb, $m, $monthnum, $year, $nxt_locale, $posts;
$cache = array();
$key = md5($m . $monthnum . $year);
if ($cache = nxt_cache_get('get_calendar', 'calendar')) {
if (is_array($cache) && isset($cache[$key])) {
if ($echo) {
echo apply_filters('get_calendar', $cache[$key]);
return;
} else {
return apply_filters('get_calendar', $cache[$key]);
}
}
}
if (!is_array($cache)) {
$cache = array();
}
// Quick check. If we have no posts at all, abort!
if (!$posts) {
$gotsome = $nxtdb->get_var("SELECT 1 as test FROM {$nxtdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
if (!$gotsome) {
$cache[$key] = '';
nxt_cache_set('get_calendar', $cache, 'calendar');
return;
}
}
if (isset($_GET['w'])) {
$w = '' . intval($_GET['w']);
}
// week_begins = 0 stands for Sunday
$week_begins = intval(get_option('start_of_week'));
// Let's figure out when we are
if (!empty($monthnum) && !empty($year)) {
$thismonth = '' . zeroise(intval($monthnum), 2);
$thisyear = '' . intval($year);
} elseif (!empty($w)) {
// We need to get the month from MySQL
$thisyear = '' . intval(substr($m, 0, 4));
$d = ($w - 1) * 7 + 6;
//it seems MySQL's weeks disagree with PHP's
$thismonth = $nxtdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL {$d} DAY) ), '%m')");
} elseif (!empty($m)) {
$thisyear = '' . intval(substr($m, 0, 4));
if (strlen($m) < 6) {
$thismonth = '01';
} else {
$thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
}
} else {
$thisyear = gmdate('Y', current_time('timestamp'));
$thismonth = gmdate('m', current_time('timestamp'));
}
$unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
$last_day = date('t', $unixmonth);
// Get the next and previous month and year with at least one post
$previous = $nxtdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$nxtdb->posts}\n\t\tWHERE post_date < '{$thisyear}-{$thismonth}-01'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date DESC\n\t\t\tLIMIT 1");
$next = $nxtdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$nxtdb->posts}\n\t\tWHERE post_date > '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date ASC\n\t\t\tLIMIT 1");
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
$calendar_caption = _x('%1$s %2$s', 'calendar caption');
$calendar_output = '<table id="nxt-calendar">
<caption>' . sprintf($calendar_caption, $nxt_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
<thead>
<tr>';
$myweek = array();
for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
$myweek[] = $nxt_locale->get_weekday(($wdcount + $week_begins) % 7);
}
foreach ($myweek as $wd) {
$day_name = true == $initial ? $nxt_locale->get_weekday_initial($wd) : $nxt_locale->get_weekday_abbrev($wd);
$wd = esc_attr($wd);
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
}
$calendar_output .= '
</tr>
</thead>
<tfoot>
<tr>';
if ($previous) {
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s'), $nxt_locale->get_month($previous->month), date('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">« ' . $nxt_locale->get_month_abbrev($nxt_locale->get_month($previous->month)) . '</a></td>';
} else {
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>';
}
$calendar_output .= "\n\t\t" . '<td class="pad"> </td>';
if ($next) {
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s'), $nxt_locale->get_month($next->month), date('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $nxt_locale->get_month_abbrev($nxt_locale->get_month($next->month)) . ' »</a></td>';
} else {
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>';
//.........这里部分代码省略.........
示例10: bp_get_friend_reject_request_link
function bp_get_friend_reject_request_link()
{
global $members_template, $bp;
if (!($friendship_id = nxt_cache_get('friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id))) {
$friendship_id = friends_get_friendship_id($members_template->member->id, $bp->loggedin_user->id);
nxt_cache_set('friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id, $friendship_id, 'bp');
}
return apply_filters('bp_get_friend_reject_request_link', nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship'));
}
示例11: friends_get_total_friend_count
function friends_get_total_friend_count($user_id = 0)
{
global $bp;
if (!$user_id) {
$user_id = $bp->displayed_user->id ? $bp->displayed_user->id : $bp->loggedin_user->id;
}
if (!($count = nxt_cache_get('bp_total_friend_count_' . $user_id, 'bp'))) {
$count = bp_get_user_meta($user_id, 'total_friend_count', true);
if (empty($count)) {
$count = 0;
}
nxt_cache_set('bp_total_friend_count_' . $user_id, $count, 'bp');
}
return apply_filters('friends_get_total_friend_count', $count);
}
示例12: dpa_get_actions
/**
* Loads the actions from the database.
*
* @global object $bp BuddyPress global settings
* @global nxtdb $nxtdb NXTClass database object
* @return string
* @since 2.0
*/
function dpa_get_actions()
{
global $bp, $nxtdb;
if (!($actions = nxt_cache_get('dpa_actions', 'dpa'))) {
$actions = $nxtdb->get_results($nxtdb->prepare("SELECT * FROM {$bp->achievements->table_actions} ORDER BY category, description"));
nxt_cache_set('dpa_actions', $actions, 'dpa');
}
return apply_filters('dpa_get_actions', (array) $actions);
}
示例13: populate
/**
* Populate the instantiated class with data based on the User ID provided.
*
* @global object $bp Global BuddyPress settings object
* @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
* @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
* @uses bp_core_get_user_email() Returns the email address for the user based on user ID
* @uses bp_get_user_meta() BP function returns the value of passed usermeta name from usermeta table
* @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
* @uses bp_profile_last_updated_date() Returns the last updated date for a user.
*/
function populate()
{
global $bp;
if (bp_is_active('xprofile')) {
$this->profile_data = $this->get_profile_data();
}
if (!empty($this->profile_data)) {
$full_name_field_name = bp_xprofile_fullname_field_name();
$this->user_url = bp_core_get_user_domain($this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login']);
$this->fullname = esc_attr($this->profile_data[$full_name_field_name]['field_data']);
$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
$this->email = esc_attr($this->profile_data['user_email']);
} else {
$this->user_url = bp_core_get_user_domain($this->id);
$this->user_link = bp_core_get_userlink($this->id);
$this->fullname = esc_attr(bp_core_get_user_displayname($this->id));
$this->email = esc_attr(bp_core_get_user_email($this->id));
}
// Cache a few things that are fetched often
nxt_cache_set('bp_user_fullname_' . $this->id, $this->fullname, 'bp');
nxt_cache_set('bp_user_email_' . $this->id, $this->email, 'bp');
nxt_cache_set('bp_user_url_' . $this->id, $this->user_url, 'bp');
$this->avatar = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'full'));
$this->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'thumb'));
$this->avatar_mini = bp_core_fetch_avatar(array('item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30));
$this->last_active = bp_core_get_last_activity(bp_get_user_meta($this->id, 'last_activity', true), __('active %s', 'buddypress'));
}
示例14: htmlspecialchars
$blogname = htmlspecialchars(substr($_SERVER['REQUEST_URI'], strlen($path)));
if (false !== strpos($blogname, '/')) {
$blogname = substr($blogname, 0, strpos($blogname, '/'));
}
if (false !== strpos($blogname, '?')) {
$blogname = substr($blogname, 0, strpos($blogname, '?'));
}
$reserved_blognames = array('page', 'comments', 'blog', 'nxt-admin', 'nxt-includes', 'nxt-content', 'files', 'feed');
if ($blogname != '' && !in_array($blogname, $reserved_blognames) && !is_file($blogname)) {
$path .= $blogname . '/';
}
$current_blog = nxt_cache_get('current_blog_' . $domain . $path, 'site-options');
if (!$current_blog) {
$current_blog = get_blog_details(array('domain' => $domain, 'path' => $path), false);
if ($current_blog) {
nxt_cache_set('current_blog_' . $domain . $path, $current_blog, 'site-options');
}
}
unset($reserved_blognames);
}
if (!defined('nxt_INSTALLING') && is_subdomain_install() && !is_object($current_blog)) {
if (defined('NOBLOGREDIRECT')) {
$destination = NOBLOGREDIRECT;
if ('%siteurl%' == $destination) {
$destination = "http://" . $current_site->domain . $current_site->path;
}
} else {
$destination = 'http://' . $current_site->domain . $current_site->path . 'nxt-signup.php?new=' . str_replace('.' . $current_site->domain, '', $domain);
}
header('Location: ' . $destination);
die;
示例15: get_blog_id_from_url
/**
* Get a blog's numeric ID from its URL.
*
* On a subdirectory installation like example.com/blog1/,
* $domain will be the root 'example.com' and $path the
* subdirectory '/blog1/'. With subdomains like blog1.example.com,
* $domain is 'blog1.example.com' and $path is '/'.
*
* @since MU 2.6.5
*
* @param string $domain
* @param string $path Optional. Not required for subdomain installations.
* @return int
*/
function get_blog_id_from_url($domain, $path = '/')
{
global $nxtdb;
$domain = strtolower($nxtdb->escape($domain));
$path = strtolower($nxtdb->escape($path));
$id = nxt_cache_get(md5($domain . $path), 'blog-id-cache');
if ($id == -1) {
// blog does not exist
return 0;
} elseif ($id) {
return (int) $id;
}
$id = $nxtdb->get_var("SELECT blog_id FROM {$nxtdb->blogs} WHERE domain = '{$domain}' and path = '{$path}' /* get_blog_id_from_url */");
if (!$id) {
nxt_cache_set(md5($domain . $path), -1, 'blog-id-cache');
return false;
}
nxt_cache_set(md5($domain . $path), $id, 'blog-id-cache');
return $id;
}