Example #1
1
 /**
  * Clear something from the cache
  *
  * @param array $args
  * @param array $vars
  */
 function flush($args = array(), $vars = array())
 {
     if (function_exists('w3tc_pgcache_flush')) {
         $args = array_unique($args);
         do {
             $cache_type = array_shift($args);
             switch ($cache_type) {
                 case 'db':
                 case 'database':
                     if (w3tc_dbcache_flush()) {
                         WP_CLI::success('The object cache is flushed successfully.');
                     } else {
                         WP_CLI::error('Flushing the object cache failed.');
                     }
                     break;
                 case 'minify':
                     if (w3tc_minify_flush()) {
                         WP_CLI::success('The object cache is flushed successfully.');
                     } else {
                         WP_CLI::error('Flushing the object cache failed.');
                     }
                     break;
                 case 'object':
                     if (w3tc_objectcache_flush()) {
                         WP_CLI::success('The object cache is flushed successfully.');
                     } else {
                         WP_CLI::error('Flushing the object cache failed.');
                     }
                     break;
                 case 'post':
                 default:
                     if (isset($vars['post_id'])) {
                         if (is_numeric($vars['post_id'])) {
                             w3tc_pgcache_flush_post($vars['post_id']);
                         } else {
                             WP_CLI::error('This is not a valid post id.');
                         }
                         w3tc_pgcache_flush_post($vars['post_id']);
                     } elseif (isset($vars['permalink'])) {
                         $id = url_to_postid($vars['permalink']);
                         if (is_numeric($id)) {
                             w3tc_pgcache_flush_post($id);
                         } else {
                             WP_CLI::error('There is no post with this permalink.');
                         }
                     } else {
                         if (isset($flushed_page_cache) && $flushed_page_cache) {
                             break;
                         }
                         $flushed_page_cache = true;
                         w3tc_pgcache_flush();
                     }
             }
         } while (!empty($args));
     } else {
         WP_CLI::error('The W3 Total Cache could not be found, is it installed?');
     }
 }
Example #2
0
 /**
  * Clear something from the cache
  *
  * @param array $args
  * @param array $vars
  */
 function flush($args = array(), $vars = array())
 {
     $args = array_unique($args);
     do {
         $cache_type = array_shift($args);
         switch ($cache_type) {
             case 'db':
             case 'database':
                 try {
                     $w3_db = w3_instance('W3_CacheFlush');
                     $w3_db->dbcache_flush();
                 } catch (Exception $e) {
                     WP_CLI::error('Flushing the DB cache failed.');
                 }
                 WP_CLI::success('The DB cache is flushed successfully.');
                 break;
             case 'minify':
                 try {
                     $w3_minify = w3_instance('W3_CacheFlush');
                     $w3_minify->minifycache_flush();
                 } catch (Exception $e) {
                     WP_CLI::error('Flushing the minify cache failed.');
                 }
                 WP_CLI::success('The minify cache is flushed successfully.');
                 break;
             case 'object':
                 try {
                     $w3_objectcache = w3_instance('W3_CacheFlush');
                     $w3_objectcache->objectcache_flush();
                 } catch (Exception $e) {
                     WP_CLI::error('Flushing the object cache failed.');
                 }
                 WP_CLI::success('The object cache is flushed successfully.');
                 break;
             case 'post':
             default:
                 if (isset($vars['post_id'])) {
                     if (is_numeric($vars['post_id'])) {
                         try {
                             $w3_cacheflush = w3_instance('W3_CacheFlush');
                             $w3_cacheflush->pgcache_flush_post($vars['post_id']);
                             $w3_cacheflush->varnish_flush_post($vars['post_id']);
                         } catch (Exception $e) {
                             WP_CLI::error('Flushing the page from cache failed.');
                         }
                         WP_CLI::success('The page is flushed from cache successfully.');
                     } else {
                         WP_CLI::error('This is not a valid post id.');
                     }
                     w3tc_pgcache_flush_post($vars['post_id']);
                 } elseif (isset($vars['permalink'])) {
                     $id = url_to_postid($vars['permalink']);
                     if (is_numeric($id)) {
                         try {
                             $w3_cacheflush = w3_instance('W3_CacheFlush');
                             $w3_cacheflush->pgcache_flush_post($id);
                             $w3_cacheflush->varnish_flush_post($id);
                         } catch (Exception $e) {
                             WP_CLI::error('Flushing the page from cache failed.');
                         }
                         WP_CLI::success('The page is flushed from cache successfully.');
                     } else {
                         WP_CLI::error('There is no post with this permalink.');
                     }
                 } else {
                     if (isset($flushed_page_cache) && $flushed_page_cache) {
                         break;
                     }
                     $flushed_page_cache = true;
                     try {
                         $w3_cacheflush = w3_instance('W3_CacheFlush');
                         $w3_cacheflush->pgcache_flush();
                         $w3_cacheflush->varnish_flush();
                     } catch (Exception $e) {
                         WP_CLI::error('Flushing the page cache failed.');
                     }
                     WP_CLI::success('The page cache is flushed successfully.');
                 }
         }
     } while (!empty($args));
 }
 /**
  * Tell caching plugins to clear their caches related to a post
  *
  * @static
  * @param int $post_id
  */
 public static function clear_post_cache($post_id)
 {
     if (function_exists('wp_cache_post_change')) {
         // WP Super Cache
         $GLOBALS['super_cache_enabled'] = 1;
         wp_cache_post_change($post_id);
     } elseif (function_exists('w3tc_pgcache_flush_post')) {
         // W3 Total Cache
         w3tc_pgcache_flush_post($post_id);
     }
 }
            delete_post_meta($post_ID, 'output_full');
            delete_post_meta($post_ID, 'all2html_ok');
            delete_post_meta($post_ID, 'all2html_upf');
            delete_post_meta($post_ID, 'all2html_arch');
            delete_post_meta($post_ID, 'all2html_pdfpath');
            delete_post_meta($post_ID, 'all2html_pdfoptpath');
            delete_post_meta($post_ID, 'output_optpdf');
            delete_post_meta($post_ID, 'all2html_htmlcontent');
            delete_post_meta($post_ID, 'all2html_hash');
            delete_post_meta($post_ID, 'all2html_zip');
            delete_post_meta($post_ID, 'all2html_outzip');
            delete_post_meta($post_ID, 'all2html_postID');
            break;
    }
    if (function_exists('w3tc_pgcache_flush_post')) {
        w3tc_pgcache_flush_post($post_ID);
    }
} else {
    echo 'No deberías estar aquí';
}
//Funciones para migrar imagen de Flickr a WordPress
function flickr_image_attach($flickrurl, $post_id)
{
    preg_match('/http\\:\\/\\/www\\.flickr\\.com\\/photos\\/(.*?)\\/([0-9]+)\\//si', $flickrurl, $m);
    if ($m) {
        $flickruser = $m[1];
        $photo_id = $m[2];
    } else {
        return;
    }
    update_post_meta($post_id, 'image_url_value', $flickrurl);
 public function clearCache($hard = false)
 {
     if (function_exists('w3tc_pgcache_flush_post')) {
         w3tc_pgcache_flush_post($this->getId());
     }
     if ($hard and function_exists('w3tc_pgcache_flush')) {
         w3tc_pgcache_flush();
     }
 }
 public function clear_post_cache($post_id)
 {
     switch (get_post_status($post_id)) {
         case 'draft':
         case 'pending':
         case 'future':
         case 'private':
         case 'publish':
             $lca = $this->p->cf['lca'];
             $lang = SucomUtil::get_locale();
             $permalink = get_permalink($post_id);
             $permalink_no_meta = add_query_arg(array('WPSSO_META_TAGS_DISABLE' => 1), $permalink);
             $sharing_url = $this->p->util->get_sharing_url($post_id);
             $transients = array('SucomCache::get' => array('url:' . $permalink, 'url:' . $permalink_no_meta), 'WpssoHead::get_header_array' => array('lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url, 'lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url . '_crawler:pinterest'), 'WpssoMeta::get_mod_column_content' => array('mod:post_lang:' . $lang . '_id:' . $post_id . '_column:' . $lca . '_og_image'));
             $transients = apply_filters($lca . '_post_cache_transients', $transients, $post_id, $lang, $sharing_url);
             $objects = array('SucomWebpage::get_content' => array('lang:' . $lang . '_post:' . $post_id . '_filtered', 'lang:' . $lang . '_post:' . $post_id . '_unfiltered'), 'SucomWebpage::get_hashtags' => array('lang:' . $lang . '_post:' . $post_id));
             $objects = apply_filters($lca . '_post_cache_objects', $objects, $post_id, $lang, $sharing_url);
             $deleted = $this->clear_cache_objects($transients, $objects);
             if (!empty($this->p->options['plugin_cache_info']) && $deleted > 0) {
                 $this->p->notice->inf($deleted . ' items removed from the WordPress object and transient caches.', true);
             }
             if (function_exists('w3tc_pgcache_flush_post')) {
                 // w3 total cache
                 w3tc_pgcache_flush_post($post_id);
             }
             if (function_exists('wp_cache_post_change')) {
                 // wp super cache
                 wp_cache_post_change($post_id);
             }
             break;
     }
 }
Example #7
0
 /**
  * Clear something from the cache.
  *
  * @synopsis <cache-type>... [--post_id=<post-id>] [--permalink=<permalink>]
  */
 function flush($args = array(), $assoc_args = array())
 {
     $args = array_unique($args);
     do {
         $cache_type = array_shift($args);
         switch ($cache_type) {
             case 'db':
             case 'database':
                 if (w3tc_dbcache_flush()) {
                     WP_CLI::success('The database cache is flushed successfully.');
                 } else {
                     WP_CLI::error('Flushing the database cache failed.');
                 }
                 break;
             case 'minify':
                 if (w3tc_minify_flush()) {
                     WP_CLI::success('The minify cache is flushed successfully.');
                 } else {
                     WP_CLI::error('Flushing the minify cache failed.');
                 }
                 break;
             case 'object':
                 if (w3tc_objectcache_flush()) {
                     WP_CLI::success('The object cache is flushed successfully.');
                 } else {
                     WP_CLI::error('Flushing the object cache failed.');
                 }
                 break;
             case 'page':
                 if (w3tc_pgcache_flush()) {
                     WP_CLI::success('The page cache is flushed successfully.');
                 } else {
                     WP_CLI::error('Flushing the page cache failed.');
                 }
                 break;
             case 'post':
             default:
                 if (isset($assoc_args['post_id'])) {
                     if (is_numeric($assoc_args['post_id']) && get_post($assoc_args['post_id'])) {
                         if (w3tc_pgcache_flush_post($assoc_args['post_id'])) {
                             WP_CLI::success('Post ' . $assoc_args['post_id'] . ' is flushed successfully.');
                         } else {
                             WP_CLI::error('Flushing ' . $assoc_args['post_id'] . ' from cache failed.');
                         }
                     } else {
                         WP_CLI::error('This is not a valid post id.');
                     }
                 } elseif (isset($assoc_args['permalink'])) {
                     $id = url_to_postid($assoc_args['permalink']);
                     if (is_numeric($id) && $id > 0) {
                         if (w3tc_pgcache_flush_post($id)) {
                             WP_CLI::success($id . ' is flushed successfully.');
                         } else {
                             WP_CLI::error('Flushing ' . $id . ' from cache failed.');
                         }
                     } else {
                         WP_CLI::error('There is no post with this permalink.');
                     }
                 }
         }
     } while (!empty($args));
 }
/**
 * Clear cache for the post on known big caching plugins.
 * 
 * @since 1.1.0
 *
 * @param int $comment_id ID of the comment there was a reaction to.
 */
function creactions_clear_caching($comment_id)
{
    $comment = get_comment($comment_id);
    if (function_exists('wp_cache_post_id_gc')) {
        wp_cache_post_id_gc('', $comment->comment_post_ID);
    } else {
        if (function_exists('w3tc_pgcache_flush_post')) {
            w3tc_pgcache_flush_post($comment->comment_post_ID);
        }
    }
}