Exemplo n.º 1
0
/**
 * Clears cache completely, via ajax
 *
 * @since 1.5
 */
function file_gallery_clear_cache_manual()
{
    check_ajax_referer('file-gallery-clear_cache');
    file_gallery_clear_cache();
    _e("You have successfully cleared the File Gallery cache.", "file-gallery");
    exit;
}
/**
 * A slightly modified copy of WordPress' _update_post_term_count function
 * 
 * Updates number of posts that use a certain media_tag
 */
function file_gallery_update_media_tag_term_count($terms)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships}, {$wpdb->posts} \r\n\t\t\t\t\t\t WHERE {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id \r\n\t\t\t\t\t\t AND post_type = 'attachment' \r\n\t\t\t\t\t\t AND term_taxonomy_id = %d", $term));
        do_action('edit_term_taxonomy', $term);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        do_action('edited_term_taxonomy', $term);
    }
    // clear cache
    file_gallery_clear_cache('mediatags_all');
}