/** * AJAX callback to revoke the secret URL for the system info. * * @access private * @since 8.3 * @static */ public static function revokeSystemInfoURL() { if (!check_ajax_referer('revoke_remote_system_info_url', FALSE, FALSE)) { wp_send_json_error(__('Invalid AJAX action or nonce validation failed.', 'connections')); } if (!current_user_can('manage_options')) { wp_send_json_error(__('You do not have sufficient permissions to perform this action.', 'connections')); } cnCache::clear('system_info_remote_token', 'option-cache'); wp_send_json_success(__('Secret URL has been revoked.', 'connections')); }
/** * Clear a fragment cache object or object group. * * @access public * @since 8.1.6 * @static * @param mixed $key bool | string The cache key to clear. When set to TRUE, clear a fragment cache group. * @param string $group The cache group to clear * @return void */ public static function clear($key, $group = '') { if (TRUE !== $key) { cnCache::clear($key, 'transient', self::PREFIX); } else { $group_key = empty($group) ? self::PREFIX : $group; cnCache::clear(TRUE, 'transient', $group_key); } }
/** * Download the CSV file. * * @access public * @since 8.5 * * @uses cnCSV_Export::headers() * @uses cnCSV_Batch_Export::fileContents() */ public function download() { // Clear the fields and types query caches. cnCache::clear(TRUE, 'transient', 'cn-csv'); $this->headers(); $file = $this->fileContents(); @unlink($this->file); echo $file; die; }
/** * Purge entry related caches when an entry is added/edited. * * @access public * @since 8.1 * * @uses cnCache::clear() * * @return void */ public static function clearCache() { cnCache::clear(TRUE, 'transient', 'cn_category'); cnCache::clear(TRUE, 'transient', 'cn_relative'); /** * Action fired after entry related caches are cleared. * * The `cn_process_cache-entry` action is deprecated since 8.2.5 and should not be used. * * @since 8.2.5 */ do_action('cn_clean_entry_cache'); do_action('cn_process_cache-entry'); }
/** * Will remove all of the term ids from the cache. * * NOTE: This is the Connections equivalent of @see clean_term_cache() in WordPress core ../wp-includes/taxonomy.php * * @access public * @since 8.1.6 * @static * * @global $wpdb * * @uses wpdb::get_results() * @uses wp_cache_delete() * @uses delete_option() * @uses cnTerm::get_hierarchy() * @uses do_action() * @uses wp_cache_set() * * @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. */ public static function cleanCache($ids, $taxonomy = '', $clean_taxonomy = TRUE) { /** @var $wpdb wpdb */ global $wpdb; 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 = $wpdb->get_results("SELECT term_id, taxonomy FROM " . CN_TERM_TAXONOMY_TABLE . " WHERE term_taxonomy_id IN ({$tt_ids})"); $ids = array(); foreach ((array) $terms as $term) { $taxonomies[] = $term->taxonomy; $ids[] = $term->term_id; wp_cache_delete($term->term_id, 'cn_' . $term->taxonomy); } $taxonomies = array_unique($taxonomies); } else { $taxonomies = array($taxonomy); foreach ($taxonomies as $taxonomy) { foreach ($ids as $id) { wp_cache_delete($id, 'cn_' . $taxonomy); } } } foreach ($taxonomies as $taxonomy) { if ($clean_taxonomy) { wp_cache_delete('all_ids', 'cn_' . $taxonomy); wp_cache_delete('get', 'cn_' . $taxonomy); delete_option("cn_{$taxonomy}_children"); // Regenerate {$taxonomy}_children self::get_hierarchy($taxonomy); } /** * Fires once after each taxonomy's term cache has been cleaned. * * @since 8.1.6 * * @param array $ids An array of term IDs. * @param string $taxonomy Taxonomy slug. */ do_action('cn_clean_term_cache', $ids, $taxonomy); } wp_cache_set('last_changed', microtime(), 'cn_terms'); // Clear any transients/cache fragments that were set. cnCache::clear(TRUE, 'transient', "cn_{$taxonomy}"); }
/** * Output the CSV column headers. * * @access public * @since 8.5.1 */ public function writeHeaders() { $this->setHeaderNames(); $header = ''; $count = count($this->fields); // Clear the fields and types query caches. cnCache::clear(TRUE, 'transient', 'cn-csv'); for ($i = 0; $i < $count; $i++) { // If there is a special type, export it, otherwise, just draw it $header .= $this->explodeBreakoutHeader($this->fields[$i]); } // Trim the hanging comma and space. $header = rtrim($header, ','); // Now write the header... $this->write($header . "\r\n"); }