function friends_clear_friend_object_cache($friendship_id) { if (!($friendship = new BP_Friends_Friendship($friendship_id))) { return false; } nxt_cache_delete('friends_friend_ids_' . $friendship->initiator_user_id, 'bp'); nxt_cache_delete('friends_friend_ids_' . $friendship->friend_user_id, 'bp'); nxt_cache_delete('bp_total_friend_count_' . $friendship->initiator_user_id, 'bp'); nxt_cache_delete('bp_total_friend_count_' . $friendship->friend_user_id, 'bp'); }
/** * Clear the blog details cache. * * @since MU * * @param int $blog_id Blog ID */ function refresh_blog_details($blog_id) { $blog_id = (int) $blog_id; $details = get_blog_details($blog_id, false); nxt_cache_delete($blog_id, 'blog-details'); nxt_cache_delete($blog_id . 'short', 'blog-details'); nxt_cache_delete(md5($details->domain . $details->path), 'blog-lookup'); nxt_cache_delete('current_blog_' . $details->domain, 'site-options'); nxt_cache_delete('current_blog_' . $details->domain . $details->path, 'site-options'); }
function bb_move_forum_topics($from_forum_id, $to_forum_id) { global $bbdb; $from_forum_id = (int) $from_forum_id; $to_forum_id = (int) $to_forum_id; add_filter('get_forum_where', 'bb_no_where'); // Just in case $from_forum = bb_get_forum($from_forum_id); if (!($to_forum = bb_get_forum($to_forum_id))) { return false; } $posts = $to_forum->posts + ($from_forum ? $from_forum->posts : 0); $topics = $to_forum->topics + ($from_forum ? $from_forum->topics : 0); $bbdb->update($bbdb->forums, compact('topics', 'posts'), array('forum_id' => $to_forum_id)); $bbdb->update($bbdb->forums, array('topics' => 0, 'posts' => 0), array('forum_id' => $from_forum_id)); $bbdb->update($bbdb->posts, array('forum_id' => $to_forum_id), array('forum_id' => $from_forum_id)); $topic_ids = $bbdb->get_col($bbdb->prepare("SELECT topic_id FROM {$bbdb->topics} WHERE forum_id = %d", $from_forum_id)); $return = $bbdb->update($bbdb->topics, array('forum_id' => $to_forum_id), array('forum_id' => $from_forum_id)); nxt_cache_flush('bb_post'); if ($topic_ids) { foreach ($topic_ids as $topic_id) { // should maybe just flush these groups nxt_cache_delete($topic_id, 'bb_topic'); nxt_cache_delete($topic_id, 'bb_thread'); } } nxt_cache_delete($from_forum_id, 'bb_forum'); nxt_cache_delete($to_forum_id, 'bb_forum'); nxt_cache_flush('bb_forums'); return $return; }
function bp_xprofile_delete_meta($object_id, $object_type, $meta_key = false, $meta_value = false) { global $nxtdb, $bp; $object_id = (int) $object_id; if (!$object_id) { return false; } if (!isset($object_type)) { return false; } if (!in_array($object_type, array('group', 'field', 'data'))) { return false; } $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if (is_array($meta_value) || is_object($meta_value)) { $meta_value = serialize($meta_value); } $meta_value = trim($meta_value); if (!$meta_key) { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->profile->table_name_meta . " WHERE object_id = %d AND object_type = %s", $object_id, $object_type)); } else { if ($meta_value) { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->profile->table_name_meta . " WHERE object_id = %d AND object_type = %s AND meta_key = %s AND meta_value = %s", $object_id, $object_type, $meta_key, $meta_value)); } else { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->profile->table_name_meta . " WHERE object_id = %d AND object_type = %s AND meta_key = %s", $object_id, $object_type, $meta_key)); } } // Delete the cached object nxt_cache_delete('bp_xprofile_meta_' . $object_type . '_' . $object_id . '_' . $meta_key, 'bp'); return true; }
function useNonce($server_url, $timestamp, $salt) { global $Auth_OpenID_SKEW; if (abs($timestamp - time()) > $Auth_OpenID_SKEW) { return false; } $key = $this->_getNonceKey($server_url, $timestamp, $salt); // prevent the likelihood of a race condition - don't rely on cache nxt_cache_delete('openid_nonces', 'options'); $nonces = get_option('openid_nonces'); if ($nonces == null) { $nonces = array(); } if (array_key_exists($key, $nonces)) { return false; } else { $nonces[$key] = $timestamp; update_option('openid_nonces', $nonces); return true; } }
/** * Deleting Activity * * If you're looking to hook into one action that provides the ID(s) of * the activity/activities deleted, then use: * * add_action( 'bp_activity_deleted_activities', 'my_function' ); * * The action passes one parameter that is a single activity ID or an * array of activity IDs depending on the number deleted. * * If you are deleting an activity comment please use bp_activity_delete_comment(); * * @since 1.0.0 * * @param array $args See docs for $defaults for details * * @global object $bp BuddyPress global settings * @uses nxt_parse_args() * @uses bp_activity_adjust_mention_count() * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity} * @uses do_action() To call the 'bp_before_activity_delete' hook * @uses bp_get_user_meta() * @uses bp_delete_user_meta() * @uses do_action() To call the 'bp_activity_delete' hook * @uses do_action() To call the 'bp_activity_deleted_activities' hook * @uses nxt_cache_delete() * * @return bool True on success, false on failure */ function bp_activity_delete($args = '') { global $bp; // Pass one or more the of following variables to delete by those variables $defaults = array('id' => false, 'action' => false, 'content' => false, 'component' => false, 'type' => false, 'primary_link' => false, 'user_id' => false, 'item_id' => false, 'secondary_item_id' => false, 'date_recorded' => false, 'hide_sitewide' => false); $args = nxt_parse_args($args, $defaults); // Adjust the new mention count of any mentioned member bp_activity_adjust_mention_count($args['id'], 'delete'); if (!($activity_ids_deleted = BP_Activity_Activity::delete($args))) { return false; } // Check if the user's latest update has been deleted if (empty($args['user_id'])) { $user_id = $bp->loggedin_user->id; } else { $user_id = $args['user_id']; } do_action('bp_before_activity_delete', $args); $latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true); if (!empty($latest_update)) { if (in_array((int) $latest_update['id'], (array) $activity_ids_deleted)) { bp_delete_user_meta($user_id, 'bp_latest_update'); } } do_action('bp_activity_delete', $args); do_action('bp_activity_deleted_activities', $activity_ids_deleted); nxt_cache_delete('bp_activity_sitewide_front', 'bp'); return true; }
/** * Builds the sitemap and writes it into a xml file. * * ATTENTION PLUGIN DEVELOPERS! DONT CALL THIS METHOD DIRECTLY! * The method is probably not available, since it is only loaded when needed. * Use do_action("sm_rebuild"); if you want to rebuild the sitemap. * Please refer to the documentation.txt for more details. * * @since 3.0 * @access public * @author Arne Brachhold <himself [at] arnebrachhold [dot] de> * @return array An array with messages such as failed writes etc. */ function BuildSitemap() { global $nxtdb, $posts, $nxt_version; $this->Initate(); if ($this->GetOption("b_memory") != '') { @ini_set("memory_limit", $this->GetOption("b_memory")); } if ($this->GetOption("b_time") != -1) { @set_time_limit($this->GetOption("b_time")); } //This object saves the status information of the script directly to the database $status = new GoogleSitemapGeneratorStatus(); //Other plugins can detect if the building process is active $this->_isActive = true; //$this->AddElement(new GoogleSitemapGeneratorXmlEntry()); //Debug mode? $debug = $this->GetOption("b_debug"); if ($this->GetOption("b_xml")) { $fileName = $this->GetXmlPath(); $status->StartXml($this->GetXmlPath(), $this->GetXmlUrl()); if ($this->IsFileWritable($fileName)) { $this->_fileHandle = fopen($fileName, "w"); if (!$this->_fileHandle) { $status->EndXml(false, "Not openable"); } } else { $status->EndXml(false, "not writable"); } } //Write gzipped sitemap file if ($this->IsGzipEnabled()) { $fileName = $this->GetZipPath(); $status->StartZip($this->GetZipPath(), $this->GetZipUrl()); if ($this->IsFileWritable($fileName)) { $this->_fileZipHandle = gzopen($fileName, "w1"); if (!$this->_fileZipHandle) { $status->EndZip(false, "Not openable"); } } else { $status->EndZip(false, "not writable"); } } if (!$this->_fileHandle && !$this->_fileZipHandle) { $status->End(); return; } //Content of the XML file $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<?xml version="1.0" encoding="UTF-8"' . '?' . '>')); $styleSheet = $this->GetDefaultStyle() && $this->GetOption('b_style_default') === true ? $this->GetDefaultStyle() : $this->GetOption('b_style'); if (!empty($styleSheet)) { $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<' . '?xml-stylesheet type="text/xsl" href="' . $styleSheet . '"?' . '>')); } $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generator=\"nxtclass/" . get_bloginfo('version') . "\"")); $this->AddElement(new GoogleSitemapGeneratorDebugEntry("sitemap-generator-url=\"http://www.arnebrachhold.de\" sitemap-generator-version=\"" . $this->GetVersion() . "\"")); $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generated-on=\"" . date(get_option("date_format") . " " . get_option("time_format")) . "\"")); //All comments as an asso. Array (postID=>commentCount) $comments = $this->GetOption("b_prio_provider") != "" ? $this->GetComments() : array(); //Full number of comments $commentCount = count($comments) > 0 ? $this->GetCommentCount($comments) : 0; if ($debug && $this->GetOption("b_prio_provider") != "") { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Total comment count: " . $commentCount)); } //Go XML! $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')); $home = get_bloginfo('url'); $homePid = 0; // Load qTranslate settings require_once "sitemap-qtranslate.php"; $qt = qt_settings(); //Add the home page (WITH a slash!) if ($this->GetOption("in_home")) { if ('page' == get_option('show_on_front') && get_option('page_on_front')) { $pageOnFront = get_option('page_on_front'); $p = get_page($pageOnFront); if ($p) { $homePid = $p->ID; if (!$qt["enabled"]) { $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } qt_permalink($qt, trailingslashit($home), null, $p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt, $this->GetOption("cf_home"), $this->GetOption("pr_home"), $this); } } else { if (!$qt["enabled"]) { $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql(get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home")); } qt_permalink($qt, trailingslashit($home), null, get_lastpostmodified('GMT'), $this->GetOption("cf_home"), $this->GetOption("pr_home"), $this); } } //Add the posts if ($this->GetOption("in_posts") || $this->GetOption("in_pages")) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Postings")); } //Pre 2.1 compatibility. 2.1 introduced 'future' as post_status so we don't need to check post_date $nxtCompat = floatval($nxt_version) < 2.1; $excludes = $this->GetOption('b_exclude'); //Excluded posts and pages (user enetered ID) $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats if ($exclCats && count($exclCats) > 0 && $this->IsTaxonomySupported()) { $excludedCatPosts = get_objects_in_term($exclCats, "category"); // Get all posts in excl. cats. Unforttunately this also gives us pages, revisions and so on... //Remove the pages, revisions etc from the exclude by category list, because they are always in the uncategorized one. if (count($excludedCatPosts) > 0) { $exclPages = $nxtdb->get_col("SELECT ID FROM `" . $nxtdb->posts . "` WHERE post_type!='post' AND ID IN ('" . implode("','", $excludedCatPosts) . "')"); $exclPages = array_map('intval', $exclPages); //Remove the pages from the exlusion list before if (count($exclPages) > 0) { $excludedCatPosts = array_diff($excludedCatPosts, $exclPages); } //Merge the category exclusion list with the users one if (count($excludedCatPosts) > 0) { $excludes = array_merge($excludes, $excludedCatPosts); } } } $contentStmt = ''; if ($qt["enabled"]) { $contentStmt .= ', post_content '; } $postPageStmt = ''; $inSubPages = $this->GetOption('in_posts_sub') === true; if ($inSubPages && $this->GetOption('in_posts') === true) { $pageDivider = '<!--nextpage-->'; $postPageStmt = ", (character_length(`post_content`) - character_length(REPLACE(`post_content`, '{$pageDivider}', ''))) / " . strlen($pageDivider) . " as postPages"; } $sql = "SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` {$postPageStmt} {$contentStmt} FROM `" . $nxtdb->posts . "` WHERE "; $where = '('; if ($this->GetOption('in_posts')) { //nxt < 2.1: posts are post_status = publish //nxt >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future' if ($nxtCompat) { $where .= "(post_status = 'publish' AND post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "')"; } else { if ($this->IsCustomPostTypesSupported() && count($this->GetOption('in_customtypes')) > 0) { $where .= " (post_status = 'publish' AND (post_type in ('','post'"; foreach ($this->GetOption('in_customtypes') as $customType) { $where .= ",'{$customType}'"; } $where .= "))) "; } else { $where .= " (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) "; } } } if ($this->GetOption('in_pages')) { if ($this->GetOption('in_posts')) { $where .= " OR "; } if ($nxtCompat) { //nxt < 2.1: posts have post_status = published, pages have post_status = static $where .= " post_status='static' "; } else { //nxt >= 2.1: posts have post_type = 'post' and pages have post_type = 'page'. Both must be published. $where .= " (post_status = 'publish' AND post_type = 'page') "; } } $where .= ") "; if (is_array($excludes) && count($excludes) > 0) { $where .= " AND ID NOT IN ('" . implode("','", $excludes) . "')"; } $where .= " AND post_password='' ORDER BY post_modified DESC"; $sql .= $where; if ($this->GetOption("b_max_posts") > 0) { $sql .= " LIMIT 0," . $this->GetOption("b_max_posts"); } $postCount = intval($nxtdb->get_var("SELECT COUNT(*) AS cnt FROM `" . $nxtdb->posts . "` WHERE " . $where, 0, 0)); //Create a new connection because we are using mysql_unbuffered_query and don't want to disturb the nxt connection //Safe Mode for other plugins which use mysql_query() without a connection handler and will destroy our resultset :( $con = $postRes = null; //In 2.2, a bug which prevented additional DB connections was fixed if (floatval($nxt_version) < 2.2) { $this->SetOption("b_safemode", true); } if ($this->GetOption("b_safemode") === true) { $postRes = mysql_query($sql, $nxtdb->dbh); if (!$postRes) { trigger_error("MySQL query failed: " . mysql_error(), E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode return; } } else { $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true); if (!$con) { trigger_error("MySQL Connection failed: " . mysql_error(), E_USER_NOTICE); return; } if (!mysql_select_db(DB_NAME, $con)) { trigger_error("MySQL DB Select failed: " . mysql_error(), E_USER_NOTICE); return; } $postRes = mysql_unbuffered_query($sql, $con); if (!$postRes) { trigger_error("MySQL unbuffered query failed: " . mysql_error(), E_USER_NOTICE); return; } } if ($postRes) { //#type $prioProvider GoogleSitemapGeneratorPrioProviderBase $prioProvider = NULL; if ($this->GetOption("b_prio_provider") != '') { $providerClass = $this->GetOption('b_prio_provider'); $prioProvider = new $providerClass($commentCount, $postCount); } //$posts is used by Alex King's Popularity Contest plugin //if($posts == null || !is_array($posts)) { // $posts = &$postRes; //} $z = 1; $zz = 1; //Default priorities $default_prio_posts = $this->GetOption('pr_posts'); $default_prio_pages = $this->GetOption('pr_pages'); //Change frequencies $cf_pages = $this->GetOption('cf_pages'); $cf_posts = $this->GetOption('cf_posts'); $minPrio = $this->GetOption('pr_posts_min'); //Cycle through all posts and add them while ($post = mysql_fetch_object($postRes)) { //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later. $cache = array(&$post); update_post_cache($cache); //Set the current working post for other plugins which depend on "the loop" $GLOBALS['post'] =& $post; $permalink = get_permalink($post->ID); if ($permalink != $home && $post->ID != $homePid) { $isPage = false; if ($nxtCompat) { $isPage = $post->post_status == 'static'; } else { $isPage = $post->post_type == 'page'; } //Default Priority if auto calc is disabled $prio = 0; if ($isPage) { //Priority for static pages $prio = $default_prio_pages; } else { //Priority for normal posts $prio = $default_prio_posts; } //If priority calc. is enabled, calculate (but only for posts, not pages)! if ($prioProvider !== null && !$isPage) { //Comment count for this post $cmtcnt = isset($comments[$post->ID]) ? $comments[$post->ID] : 0; $prio = $prioProvider->GetPostPriority($post->ID, $cmtcnt, $post); if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry('Debug: Priority report of postID ' . $post->ID . ': Comments: ' . $cmtcnt . ' of ' . $commentCount . ' = ' . $prio . ' points')); } } if (!$isPage && $minPrio > 0 && $prio < $minPrio) { $prio = $minPrio; } //Add it if (!$qt["enabled"]) { $this->AddUrl($permalink, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio); } qt_permalink($qt, $permalink, $post->post_content, $post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt, $isPage ? $cf_pages : $cf_posts, $prio, $this); if ($inSubPages) { $subPage = ''; for ($p = 1; $p <= $post->postPages; $p++) { if (get_option('permalink_structure') == '') { $subPage = $permalink . '&page=' . ($p + 1); } else { $subPage = trailingslashit($permalink) . user_trailingslashit($p + 1, 'single_paged'); } if (!$qt["enabled"]) { $this->AddUrl($subPage, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio); } //qt_permalink($qt, $subPage, $post->post_content, ($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt), ($isPage?$cf_pages:$cf_posts), $prio, $this); } } } //Update the status every 100 posts and at the end. //If the script breaks because of memory or time limit, //we have a "last reponded" value which can be compared to the server settings if ($zz == 100 || $z == $postCount) { $status->SaveStep($z); $zz = 0; } else { $zz++; } $z++; //Clean cache because it's incomplete if (version_compare($nxt_version, "2.5", ">=")) { //nxt 2.5 makes a mysql query for every clean_post_cache to clear the child cache //so I've copied the function here until a patch arrives... nxt_cache_delete($post->ID, 'posts'); nxt_cache_delete($post->ID, 'post_meta'); clean_object_term_cache($post->ID, 'post'); } else { clean_post_cache($post->ID); } } unset($postRes); unset($prioProvider); if ($this->GetOption("b_safemode") !== true && $con) { mysql_close($con); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings")); } } //Add the cats if ($this->GetOption("in_cats")) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Cats")); } $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats if ($exclCats == null) { $exclCats = array(); } if (!$this->IsTaxonomySupported()) { $catsRes = $nxtdb->get_results("\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tc.cat_ID AS ID,\r\n\t\t\t\t\t\t\t\tMAX(p.post_modified_gmt) AS last_mod\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t`" . $nxtdb->categories . "` c,\r\n\t\t\t\t\t\t\t\t`" . $nxtdb->post2cat . "` pc,\r\n\t\t\t\t\t\t\t\t`" . $nxtdb->posts . "` p\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tpc.category_id = c.cat_ID\r\n\t\t\t\t\t\t\t\tAND p.ID = pc.post_id\r\n\t\t\t\t\t\t\t\tAND p.post_status = 'publish'\r\n\t\t\t\t\t\t\t\tAND p.post_type='post'\r\n\t\t\t\t\t\t\tGROUP\r\n\t\t\t\t\t\t\t\tBY c.cat_id\r\n\t\t\t\t\t\t\t"); if ($catsRes) { foreach ($catsRes as $cat) { if ($cat && $cat->ID && $cat->ID > 0 && !in_array($cat->ID, $exclCats)) { if ($debug) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Cat-ID:" . $cat->ID)); } } if (!$qt["enabled"]) { $this->AddUrl(get_category_link($cat->ID), $this->GetTimestampFromMySql($cat->last_mod), $this->GetOption("cf_cats"), $this->GetOption("pr_cats")); } qt_permalink($qt, get_category_link($cat->ID), null, $cat->last_mod, $this->GetOption("cf_cats"), $this->GetOption("pr_cats"), $this); } } } } else { $cats = get_terms("category", array("hide_empty" => true, "hierarchical" => false)); if ($cats && is_array($cats) && count($cats) > 0) { foreach ($cats as $cat) { if (!in_array($cat->term_id, $exclCats)) { if (!$qt["enabled"]) { $this->AddUrl(get_category_link($cat->term_id), 0, $this->GetOption("cf_cats"), $this->GetOption("pr_cats")); } qt_permalink($qt, get_category_link($cat->term_id), null, 0, $this->GetOption("cf_cats"), $this->GetOption("pr_cats"), $this); } } } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Cats")); } } //Add the archives if ($this->GetOption("in_arch")) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Archive")); } $now = current_time('mysql'); //nxt2.1 introduced post_status='future', for earlier nxt versions we need to check the post_date_gmt $arcresults = $nxtdb->get_results("\r\n\t\t\t\t\t\tSELECT DISTINCT\r\n\t\t\t\t\t\t\tYEAR(post_date_gmt) AS `year`,\r\n\t\t\t\t\t\t\tMONTH(post_date_gmt) AS `month`,\r\n\t\t\t\t\t\t\tMAX(post_date_gmt) as last_mod,\r\n\t\t\t\t\t\t\tcount(ID) as posts\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t{$nxtdb->posts}\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tpost_date < '{$now}'\r\n\t\t\t\t\t\t\tAND post_status = 'publish'\r\n\t\t\t\t\t\t\tAND post_type = 'post'\r\n\t\t\t\t\t\t\t" . (floatval($nxt_version) < 2.1 ? "AND {$nxtdb->posts}.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "\r\n\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\tYEAR(post_date_gmt),\r\n\t\t\t\t\t\t\tMONTH(post_date_gmt)\r\n\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\tpost_date_gmt DESC"); if ($arcresults) { foreach ($arcresults as $arcresult) { $url = get_month_link($arcresult->year, $arcresult->month); $changeFreq = ""; //Archive is the current one if ($arcresult->month == date("n") && $arcresult->year == date("Y")) { $changeFreq = $this->GetOption("cf_arch_curr"); } else { // Archive is older $changeFreq = $this->GetOption("cf_arch_old"); } if (!$qt["enabled"]) { $this->AddUrl($url, $this->GetTimestampFromMySql($arcresult->last_mod), $changeFreq, $this->GetOption("pr_arch")); } qt_permalink($qt, $url, null, $arcresult->last_mod, $changeFreq, $this->GetOption("pr_arch"), $this); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Archive")); } } //Add the author pages if ($this->GetOption("in_auth")) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Author pages")); } $linkFunc = null; //get_author_link is deprecated in nxt 2.1, try to use get_author_posts_url first. if (function_exists('get_author_posts_url')) { $linkFunc = 'get_author_posts_url'; } else { if (function_exists('get_author_link')) { $linkFunc = 'get_author_link'; } } //Who knows what happens in later nxt versions, so check again if it worked if ($linkFunc !== null) { //Unfortunately there is no API function to get all authors, so we have to do it the dirty way... //We retrieve only users with published and not password protected posts (and not pages) //nxt2.1 introduced post_status='future', for earlier nxt versions we need to check the post_date_gmt $sql = "SELECT DISTINCT\r\n\t\t\t\t\t\t\tu.ID,\r\n\t\t\t\t\t\t\tu.user_nicename,\r\n\t\t\t\t\t\t\tMAX(p.post_modified_gmt) AS last_post\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t{$nxtdb->users} u,\r\n\t\t\t\t\t\t\t{$nxtdb->posts} p\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tp.post_author = u.ID\r\n\t\t\t\t\t\t\tAND p.post_status = 'publish'\r\n\t\t\t\t\t\t\tAND p.post_type = 'post'\r\n\t\t\t\t\t\t\tAND p.post_password = ''\r\n\t\t\t\t\t\t\t" . (floatval($nxt_version) < 2.1 ? "AND p.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "\r\n\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\tu.ID,\r\n\t\t\t\t\t\t\tu.user_nicename"; $authors = $nxtdb->get_results($sql); if ($authors && is_array($authors)) { foreach ($authors as $author) { if ($debug) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Author-ID:" . $author->ID)); } } $url = $linkFunc == 'get_author_posts_url' ? get_author_posts_url($author->ID, $author->user_nicename) : get_author_link(false, $author->ID, $author->user_nicename); if (!$qt["enabled"]) { $this->AddUrl($url, $this->GetTimestampFromMySql($author->last_post), $this->GetOption("cf_auth"), $this->GetOption("pr_auth")); } qt_permalink($qt, $url, null, $author->last_post, $this->GetOption("cf_auth"), $this->GetOption("pr_auth"), $this); } } } else { //Too bad, no author pages for you :( if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: No valid author link function found")); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Author pages")); } } //Add tag pages if ($this->GetOption("in_tags") && $this->IsTaxonomySupported()) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Tags")); } $tags = get_terms("post_tag", array("hide_empty" => true, "hierarchical" => false)); if ($tags && is_array($tags) && count($tags) > 0) { foreach ($tags as $tag) { if (!$qt["enabled"]) { $this->AddUrl(get_tag_link($tag->term_id), 0, $this->GetOption("cf_tags"), $this->GetOption("pr_tags")); } qt_permalink($qt, get_tag_link($tag->term_id), null, 0, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"), $this); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Tags")); } } //Add custom taxonomy pages if ($this->GetOption("in_tax") && $this->IsTaxonomySupported()) { if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start custom taxonomies")); } $enabledTaxonomies = $this->GetOption("in_tax"); $taxList = array(); foreach ($enabledTaxonomies as $taxName) { $taxonomy = get_taxonomy($taxName); if ($taxonomy) { $taxList[] = $nxtdb->escape($taxonomy->name); } } if (count($taxList) > 0) { //We're selecting all term information (t.*) plus some additional fields //like the last mod date and the taxonomy name, so nxt doesnt need to make //additional queries to build the permalink structure. //This does NOT work for categories and tags yet, because nxt uses get_category_link //and get_tag_link internally and that would cause one additional query per term! $sql = "\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\tt.*,\r\n\t\t\t\t\t\ttt.taxonomy AS _taxonomy,\r\n\t\t\t\t\t\tUNIX_TIMESTAMP(MAX(post_date_gmt)) as _mod_date\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t{$nxtdb->posts} p ,\r\n\t\t\t\t\t\t{$nxtdb->term_relationships} r,\r\n\t\t\t\t\t\t{$nxtdb->terms} t,\r\n\t\t\t\t\t\t{$nxtdb->term_taxonomy} tt\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tp.ID = r.object_id\r\n\t\t\t\t\t\tAND p.post_status = 'publish'\r\n\t\t\t\t\t\tAND p.post_type = 'post'\r\n\t\t\t\t\t\tAND p.post_password = ''\r\n\t\t\t\t\t\tAND r.term_taxonomy_id = t.term_id\r\n\t\t\t\t\t\tAND t.term_id = tt.term_id\r\n\t\t\t\t\t\tAND tt.count > 0\r\n\t\t\t\t\t\tAND tt.taxonomy IN ('" . implode("','", $taxList) . "')\r\n\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\tt.term_id"; $termInfo = $nxtdb->get_results($sql); foreach ($termInfo as $term) { $this->AddUrl(get_term_link($term, $term->_taxonomy), $term->_mod_date, $this->GetOption("cf_tags"), $this->GetOption("pr_tags")); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End custom taxonomies")); } } //Add the custom pages if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Custom Pages")); } if ($this->_pages && is_array($this->_pages) && count($this->_pages) > 0) { //#type $page GoogleSitemapGeneratorPage foreach ($this->_pages as $page) { $this->AddUrl($page->GetUrl(), $page->getLastMod(), $page->getChangeFreq(), $page->getPriority()); } } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Custom Pages")); } if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start additional URLs")); } do_action('sm_buildmap'); if ($debug) { $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End additional URLs")); } $this->AddElement(new GoogleSitemapGeneratorXmlEntry("</urlset>")); $pingUrl = ''; if ($this->GetOption("b_xml")) { if ($this->_fileHandle && fclose($this->_fileHandle)) { $this->_fileHandle = null; $status->EndXml(true); $pingUrl = $this->GetXmlUrl(); } else { $status->EndXml(false, "Could not close the sitemap file."); } } if ($this->IsGzipEnabled()) { if ($this->_fileZipHandle && fclose($this->_fileZipHandle)) { $this->_fileZipHandle = null; $status->EndZip(true); $pingUrl = $this->GetZipUrl(); } else { $status->EndZip(false, "Could not close the zipped sitemap file"); } } //Ping Google if ($this->GetOption("b_ping") && !empty($pingUrl)) { $sPingUrl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($pingUrl); $status->StartGooglePing($sPingUrl); $pingres = $this->RemoteOpen($sPingUrl); if ($pingres == NULL || $pingres === false) { $status->EndGooglePing(false, $this->_lastError); trigger_error("Failed to ping Google: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE); } else { $status->EndGooglePing(true); } } //Ping Ask.com if ($this->GetOption("b_pingask") && !empty($pingUrl)) { $sPingUrl = "http://submissions.ask.com/ping?sitemap=" . urlencode($pingUrl); $status->StartAskPing($sPingUrl); $pingres = $this->RemoteOpen($sPingUrl); if ($pingres == NULL || $pingres === false || strpos($pingres, "successfully received and added") === false) { //Ask.com returns 200 OK even if there was an error, so we need to check the content. $status->EndAskPing(false, $this->_lastError); trigger_error("Failed to ping Ask.com: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE); } else { $status->EndAskPing(true); } } //Ping Bing if ($this->GetOption("b_pingmsn") && !empty($pingUrl)) { $sPingUrl = "http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl); $status->StartMsnPing($sPingUrl); $pingres = $this->RemoteOpen($sPingUrl); //Bing returns ip/country-based success messages, so there is no way to check the content. Rely on HTTP 500 only then... if ($pingres == NULL || $pingres === false || strpos($pingres, " ") === false) { trigger_error("Failed to ping Bing: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE); $status->EndMsnPing(false, $this->_lastError); } else { $status->EndMsnPing(true); } } $status->End(); $this->_isActive = false; //done... return $status; }
/** * Validates class variables and saves to database * * @access public * @global object $bp BuddyPress global settings * @global nxtdb $nxtdb NXTClass database object * @param DPA_Achievement $old_achievement A copy of the Achievement which is about to be saved, for comparision purposes * @return bool Whether the achievement was saved successfully or not. * @since 2.0 * @uses nxt_Error */ function save($old_achievement = null) { global $bp, $nxtdb; $errors = new nxt_Error(); if ($this->id) { $this->id = apply_filters('dpa_achievement_id_before_save', (int) $this->id, $this); } $this->action_id = apply_filters('dpa_achievement_action_id_before_save', (int) $this->action_id, $this); $this->picture_id = apply_filters('dpa_achievement_picture_id_before_save', (int) $this->picture_id, $this); $this->action_count = apply_filters('dpa_achievement_action_count_before_save', (int) $this->action_count, $this); $this->name = stripslashes(apply_filters('dpa_achievement_name_before_save', $this->name, $this)); $this->description = stripslashes(apply_filters('dpa_achievement_description_before_save', $this->description, $this)); $this->points = apply_filters('dpa_achievement_points_before_save', (int) $this->points, $this); $this->is_active = apply_filters('dpa_achievement_is_active_before_save', (int) $this->is_active, $this); $this->slug = apply_filters('dpa_achievement_slug_before_save', $this->slug, $this); $this->site_id = apply_filters('dpa_achievement_site_id_before_save', (int) $this->site_id, $this); $this->group_id = apply_filters('dpa_achievement_group_id_before_save', (int) $this->group_id, $this); DPA_Achievement::validate_achievement_details($this, $old_achievement, $errors); do_action('dpa_achievement_before_save', $this, $old_achievement, $errors); if ($errors->get_error_code()) { return $errors; } if ($this->id) { $result = $nxtdb->query($nxtdb->prepare("UPDATE {$bp->achievements->table_achievements} SET action_id = %d, picture_id = %d, action_count = %d, name = %s, description = %s, points = %d, is_active = %d, slug = %s, site_id = %d, group_id = %d WHERE id = %d LIMIT 1", $this->action_id, $this->picture_id, $this->action_count, $this->name, $this->description, $this->points, $this->is_active, $this->slug, $this->site_id, $this->group_id, $this->id)); } else { // Save $result = $nxtdb->insert($bp->achievements->table_achievements, array('action_id' => $this->action_id, 'picture_id' => $this->picture_id, 'action_count' => $this->action_count, 'name' => $this->name, 'description' => $this->description, 'points' => $this->points, 'is_active' => $this->is_active, 'slug' => $this->slug, 'site_id' => $this->site_id, 'group_id' => $this->group_id), array('%d', '%d', '%d', '%s', '%s', '%d', '%d', '%s', '%d', '%d')); $this->id = $nxtdb->insert_id; } // Remove active actions cache nxt_cache_delete('dpa_active_actions', 'dpa'); do_action('dpa_achievement_after_save', $this, $old_achievement); return $result; }
/** * Updates the user's password with a new encrypted one. * * For integration with other applications, this function can be overwritten to * instead use the other package password checking algorithm. * * @since 2.5 * @uses $nxtdb NXTClass database object for queries * @uses nxt_hash_password() Used to encrypt the user's password before passing to the database * * @param string $password The plaintext new user password * @param int $user_id User ID */ function nxt_set_password($password, $user_id) { global $nxtdb; $hash = nxt_hash_password($password); $nxtdb->update($nxtdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id)); nxt_cache_delete($user_id, 'users'); }
/** * When someone unlocks an Achievement, create/update the relevant metas. * * @param int $achievement_id * @param int $user_id * @since 2.0 */ function dpa_achievement_unlocked_update_meta($achievement_id, $user_id) { $meta = dpa_get_achievements_meta(); $meta[$achievement_id]['no_of_unlocks'] += apply_filters('dpa_achievement_unlocked_update_meta', 1); update_site_option('achievements_meta', $meta); nxt_cache_delete('dpa_achievements_meta', 'dpa'); dpa_delete_highscore_cache(); }
function groups_clear_group_user_object_cache($group_id, $user_id) { nxt_cache_delete('bp_total_groups_for_user_' . $user_id); }
/** * Update metadata of user. * * There is no need to serialize values, they will be serialized if it is * needed. The metadata key can only be a string with underscores. All else will * be removed. * * Will remove the metadata, if the meta value is empty. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use update_user_meta() * @see update_user_meta() * * @param int $user_id User ID * @param string $meta_key Metadata key. * @param mixed $meta_value Metadata value. * @return bool True on successful update, false on failure. */ function update_usermeta($user_id, $meta_key, $meta_value) { _deprecated_function(__FUNCTION__, '3.0', 'update_user_meta()'); global $nxtdb; if (!is_numeric($user_id)) { return false; } $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); /** @todo Might need fix because usermeta data is assumed to be already escaped */ if (is_string($meta_value)) { $meta_value = stripslashes($meta_value); } $meta_value = maybe_serialize($meta_value); if (empty($meta_value)) { return delete_usermeta($user_id, $meta_key); } $cur = $nxtdb->get_row($nxtdb->prepare("SELECT * FROM {$nxtdb->usermeta} WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); if ($cur) { do_action('update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); } if (!$cur) { $nxtdb->insert($nxtdb->usermeta, compact('user_id', 'meta_key', 'meta_value')); } else { if ($cur->meta_value != $meta_value) { $nxtdb->update($nxtdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key')); } else { return false; } } clean_user_cache($user_id); nxt_cache_delete($user_id, 'user_meta'); if (!$cur) { do_action('added_usermeta', $nxtdb->insert_id, $user_id, $meta_key, $meta_value); } else { do_action('updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); } return true; }
/** * Update an user in the database. * * It is possible to update a user's password by specifying the 'user_pass' * value in the $userdata parameter array. * * If $userdata does not contain an 'ID' key, then a new user will be created * and the new user's ID will be returned. * * If current user's password is being updated, then the cookies will be * cleared. * * @since 2.0.0 * @see nxt_insert_user() For what fields can be set in $userdata * @uses nxt_insert_user() Used to update existing user or add new one if user doesn't exist already * * @param array $userdata An array of user data. * @return int The updated user's ID. */ function nxt_update_user($userdata) { $ID = (int) $userdata['ID']; // First, get all of the original fields $user_obj = get_userdata($ID); $user = get_object_vars($user_obj->data); // Add additional custom fields foreach (_get_additional_user_keys($user_obj) as $key) { $user[$key] = get_user_meta($ID, $key, true); } // Escape data pulled from DB. $user = add_magic_quotes($user); // If password is changing, hash it now. if (!empty($userdata['user_pass'])) { $plaintext_pass = $userdata['user_pass']; $userdata['user_pass'] = nxt_hash_password($userdata['user_pass']); } nxt_cache_delete($user['user_email'], 'useremail'); // Merge old and new fields with new fields overwriting old ones. $userdata = array_merge($user, $userdata); $user_id = nxt_insert_user($userdata); // Update the cookies if the password changed. $current_user = nxt_get_current_user(); if ($current_user->ID == $ID) { if (isset($plaintext_pass)) { nxt_clear_auth_cookie(); nxt_set_auth_cookie($ID); } } return $user_id; }
/** * Add a user to a blog. * * Use the 'add_user_to_blog' action to fire an event when * users are added to a blog. * * @since MU 1.0 * * @param int $blog_id ID of the blog you're adding the user to. * @param int $user_id ID of the user you're adding. * @param string $role The role you want the user to have * @return bool */ function add_user_to_blog($blog_id, $user_id, $role) { switch_to_blog($blog_id); $user = new nxt_User($user_id); if (empty($user->ID)) { restore_current_blog(); return new nxt_Error('user_does_not_exist', __('That user does not exist.')); } if (!get_user_meta($user_id, 'primary_blog', true)) { update_user_meta($user_id, 'primary_blog', $blog_id); $details = get_blog_details($blog_id); update_user_meta($user_id, 'source_domain', $details->domain); } $user->set_role($role); do_action('add_user_to_blog', $user_id, $role, $blog_id); nxt_cache_delete($user_id, 'users'); restore_current_blog(); return true; }
function groups_delete_groupmeta($group_id, $meta_key = false, $meta_value = false) { global $nxtdb, $bp; if (!is_numeric($group_id)) { return false; } $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if (is_array($meta_value) || is_object($meta_value)) { $meta_value = serialize($meta_value); } $meta_value = trim($meta_value); if (!$meta_key) { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id)); } else { if ($meta_value) { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value)); } else { $nxtdb->query($nxtdb->prepare("DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key)); } } // Delete the cached object nxt_cache_delete('bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp'); return true; }
/** * Delete a site transient. * * @since 2.9.0 * @package NXTClass * @subpackage Transient * * @uses do_action() Calls 'delete_site_transient_$transient' hook before transient is deleted. * @uses do_action() Calls 'deleted_site_transient' hook on success. * * @param string $transient Transient name. Expected to not be SQL-escaped. * @return bool True if successful, false otherwise */ function delete_site_transient($transient) { global $_nxt_using_ext_object_cache; do_action('delete_site_transient_' . $transient, $transient); if ($_nxt_using_ext_object_cache) { $result = nxt_cache_delete($transient, 'site-transient'); } else { $option_timeout = '_site_transient_timeout_' . $transient; $option = '_site_transient_' . $transient; $result = delete_site_option($option); if ($result) { delete_site_option($option_timeout); } } if ($result) { do_action('deleted_site_transient', $transient); } return $result; }
function bp_blogs_format_clear_blog_cache($recorded_blog_obj) { bp_blogs_clear_blog_object_cache(false, $recorded_blog_obj->user_id); nxt_cache_delete('bp_total_blogs', 'bp'); }
/** * Delete meta data by meta ID * * @since 3.3.0 * * @uses get_metadata_by_mid() Calls get_metadata_by_mid() to fetch the meta key, value * and object_id of the given meta_id. * * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) * @param int $meta_id ID for a specific meta row * @return bool True on successful delete, false on failure. */ function delete_metadata_by_mid($meta_type, $meta_id) { global $nxtdb; // Make sure everything is valid. if (!$meta_type) { return false; } if (!($meta_id = absint($meta_id))) { return false; } if (!($table = _get_meta_table($meta_type))) { return false; } // object and id columns $column = esc_sql($meta_type . '_id'); $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; // Fetch the meta and go on if it's found. if ($meta = get_metadata_by_mid($meta_type, $meta_id)) { $object_id = $meta->{$column}; do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value); if ('post' == $meta_type) { do_action('delete_postmeta', $meta_id); } // Run the query, will return true if deleted, false otherwise $result = (bool) $nxtdb->query($nxtdb->prepare("DELETE FROM {$table} WHERE {$id_column} = %d LIMIT 1;", $meta_id)); // Clear the caches. nxt_cache_delete($object_id, $meta_type . '_meta'); do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value); if ('post' == $meta_type) { do_action('deleted_postmeta', $meta_id); } return $result; } // Meta id was not found. return false; }
/** * Hook for managing future post transitions to published. * * @since 2.3.0 * @access private * @uses $nxtdb * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call. * @uses nxt_clear_scheduled_hook() with 'publish_future_post' and post ID. * * @param string $new_status New post status * @param string $old_status Previous post status * @param object $post Object type containing the post information */ function _transition_post_status($new_status, $old_status, $post) { global $nxtdb; if ($old_status != 'publish' && $new_status == 'publish') { // Reset GUID if transitioning to publish and it is empty if ('' == get_the_guid($post->ID)) { $nxtdb->update($nxtdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID)); } do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish } // If published posts changed clear the lastpostmodified cache if ('publish' == $new_status || 'publish' == $old_status) { foreach (array('server', 'gmt', 'blog') as $timezone) { nxt_cache_delete("lastpostmodified:{$timezone}", 'timeinfo'); nxt_cache_delete("lastpostdate:{$timezone}", 'timeinfo'); } } // Always clears the hook in case the post status bounced from future to draft. nxt_clear_scheduled_hook('publish_future_post', array($post->ID)); }
function _bb_delete_post($post_id, $post_status) { global $bbdb; $post_id = (int) $post_id; $post_status = (int) $post_status; $bbdb->update($bbdb->posts, compact('post_status'), compact('post_id')); nxt_cache_delete($post_id, 'bb_post'); do_action('_bb_delete_post', $post_id, $post_status); }
/** * Delete a transient * * @since 1.0 * @package bbPress * @subpackage Transient * * @param string $transient Transient name. Expected to not be SQL-escaped * @return bool true if successful, false otherwise */ function bb_delete_transient($transient) { global $_bb_using_ext_object_cache, $bbdb; if ($_bb_using_ext_object_cache) { return nxt_cache_delete($transient, 'transient'); } else { $transient = '_transient_' . $bbdb->escape($transient); return bb_delete_option($transient); } }
/** * bb_destroy_tag() - Completely removes a bb_topic_tag. * * @param int $tt_id The TT_ID of the tag to destroy * @return bool */ function bb_destroy_tag($tt_id, $recount_topics = true) { global $nxt_taxonomy_object; $tt_id = (int) $tt_id; if (!($tag = bb_get_tag($tt_id))) { return false; } if (is_nxt_error($tag)) { return false; } $topic_ids = bb_get_tagged_topic_ids($tag->term_id); $return = $nxt_taxonomy_object->delete_term($tag->term_id, 'bb_topic_tag'); if (is_nxt_error($return)) { return false; } if (!is_nxt_error($topic_ids) && is_array($topic_ids)) { global $bbdb; $bbdb->query("UPDATE {$bbdb->topics} SET tag_count = tag_count - 1 WHERE topic_id IN (" . join(',', $topic_ids) . ")"); foreach ($topic_ids as $topic_id) { nxt_cache_delete($topic_id, 'bb_topic'); } } return $return; }
function bb_unstick_topic($topic_id) { global $bbdb; $topic_id = (int) $topic_id; nxt_cache_delete($topic_id, 'bb_topic'); $r = $bbdb->update($bbdb->topics, array('topic_sticky' => 0), compact('topic_id')); do_action('unstick_topic', $topic_id, $r); return $r; }
/** * Clears all cached objects for a user, or a user is part of. * * @package BuddyPress Core */ function bp_core_clear_user_object_cache($user_id) { nxt_cache_delete('bp_user_' . $user_id, 'bp'); }
function bp_blogs_delete_blogmeta($blog_id, $meta_key = false, $meta_value = false) { global $nxtdb, $bp; if (!is_numeric($blog_id)) { return false; } $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if (is_array($meta_value) || is_object($meta_value)) { $meta_value = serialize($meta_value); } $meta_value = trim($meta_value); if (!$meta_key) { $nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id)); } else { if ($meta_value) { $nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value)); } else { $nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key)); } } nxt_cache_delete('bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp'); return true; }
/** * Will remove all of the term ids from the cache. * * @package NXTClass * @subpackage Taxonomy * @since 2.3.0 * @uses $nxtdb * * @param int|array $ids Single or list of Term IDs * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context. * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true. */ function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { global $nxtdb; static $cleaned = array(); if (!is_array($ids)) { $ids = array($ids); } $taxonomies = array(); // If no taxonomy, assume tt_ids. if (empty($taxonomy)) { $tt_ids = array_map('intval', $ids); $tt_ids = implode(', ', $tt_ids); $terms = $nxtdb->get_results("SELECT term_id, taxonomy FROM {$nxtdb->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})"); $ids = array(); foreach ((array) $terms as $term) { $taxonomies[] = $term->taxonomy; $ids[] = $term->term_id; nxt_cache_delete($term->term_id, $term->taxonomy); } $taxonomies = array_unique($taxonomies); } else { $taxonomies = array($taxonomy); foreach ($taxonomies as $taxonomy) { foreach ($ids as $id) { nxt_cache_delete($id, $taxonomy); } } } foreach ($taxonomies as $taxonomy) { if (isset($cleaned[$taxonomy])) { continue; } $cleaned[$taxonomy] = true; if ($clean_taxonomy) { nxt_cache_delete('all_ids', $taxonomy); nxt_cache_delete('get', $taxonomy); delete_option("{$taxonomy}_children"); // Regenerate {$taxonomy}_children _get_term_hierarchy($taxonomy); } do_action('clean_term_cache', $ids, $taxonomy); } nxt_cache_set('last_changed', time(), 'terms'); }
function delete_meta($args = null) { $defaults = array('id' => 0, 'meta_key' => null, 'meta_value' => null, 'meta_table' => 'usermeta', 'meta_field' => 'user_id', 'meta_id_field' => 'umeta_id', 'cache_group' => 'users'); $args = nxt_parse_args($args, $defaults); extract($args, EXTR_SKIP); $user = $this->get_user($id); if (!$user || is_nxt_error($user)) { return $user; } $id = (int) $id; if (is_null($meta_key)) { return false; } $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $meta_tuple = compact('id', 'meta_key', 'meta_value', 'meta_table'); $meta_tuple = apply_filters(__CLASS__ . '::' . __FUNCTION__, $meta_tuple); extract($meta_tuple, EXTR_OVERWRITE); $_meta_value = is_null($meta_value) ? null : maybe_serialize($meta_value); if (is_null($_meta_value)) { $meta_id = $this->db->get_var($this->db->prepare("SELECT {$meta_id_field} FROM {$this->db->{$meta_table}} WHERE {$meta_field} = %d AND meta_key = %s", $id, $meta_key)); } else { $meta_id = $this->db->get_var($this->db->prepare("SELECT {$meta_id_field} FROM {$this->db->{$meta_table}} WHERE {$meta_field} = %d AND meta_key = %s AND meta_value = %s", $id, $meta_key, $_meta_value)); } if (!$meta_id) { return false; } if (is_null($_meta_value)) { $this->db->query($this->db->prepare("DELETE FROM {$this->db->{$meta_table}} WHERE {$meta_field} = %d AND meta_key = %s", $id, $meta_key)); } else { $this->db->query($this->db->prepare("DELETE FROM {$this->db->{$meta_table}} WHERE {$meta_id_field} = %d", $meta_id)); } nxt_cache_delete($id, $cache_group); return true; }
function flush_widget_cache() { nxt_cache_delete('widget_recent_comments', 'widget'); }
/** * Will remove all of the term ids from the cache. * * @package NXTClass * @subpackage Taxonomy * @since 2.3.0 * * @param int|array $ids Single or list of Term IDs * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context. */ function clean_term_cache($ids, $taxonomy = '') { static $cleaned = array(); if (!is_array($ids)) { $ids = array($ids); } $taxonomies = array(); // If no taxonomy, assume tt_ids. if (empty($taxonomy)) { $tt_ids = implode(',', array_map('intval', $ids)); $terms = $this->db->get_results("SELECT term_id, term_taxonomy_id, taxonomy FROM {$this->db->term_taxonomy} WHERE term_taxonomy_id IN ({$tt_ids})"); foreach ((array) $terms as $term) { $taxonomies[] = $term->taxonomy; nxt_cache_delete($term->term_id, $term->taxonomy); nxt_cache_delete($term->term_taxonomy_id, "{$term->taxonomy}:tt_id"); } $taxonomies = array_unique($taxonomies); } else { $tt_ids = implode(',', array_map('intval', $ids)); $terms = $this->db->get_results("SELECT term_id, term_taxonomy_id FROM {$this->db->term_taxonomy} WHERE term_id IN ({$tt_ids})"); foreach ((array) $terms as $term) { nxt_cache_delete($term->term_id, $taxonomy); nxt_cache_delete($term->term_taxonomy_id, "{$taxonomy}:tt_id"); } $taxonomies = array($taxonomy); } foreach ($taxonomies as $taxonomy) { if (isset($cleaned[$taxonomy])) { continue; } $cleaned[$taxonomy] = true; nxt_cache_delete('all_ids', $taxonomy); nxt_cache_delete('get', $taxonomy); $this->delete_children_cache($taxonomy); } nxt_cache_delete('get_terms', 'terms'); do_action('clean_term_cache', $ids, $taxonomy); }
/** * Purge the cached results of get_calendar. * * @see get_calendar * @since 2.1.0 */ function delete_get_calendar_cache() { nxt_cache_delete('get_calendar', 'calendar'); }