Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jmoria

    (@jmoria)

    So, what do you think? Will you update the plugin to delete only the cache of the trashed post, not the whole cache? It would be great if you do that, it’s much better than deleting whole cache when only one post is trashed.

    Also, do you have any clue why $this->singleDeleteCache(false, $post->ID) is not working for trashed post?

    Sorry for bothering you, I just want to make this plugin even better.

    Thread Starter jmoria

    (@jmoria)

    Also, I replaced $this->deleteCache() (line 678) with the code below, and it’s working fine, haha.

    $permalink = get_permalink($post_id);
    
    if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
    	$path = $this->getWpContentDir()."/cache/all/".$out[1];
    	$mobile_path = $this->getWpContentDir()."/cache/wpfc-mobile-cache/".$out[1];
    
    	if(is_dir($path)){
    		$this->rm_folder_recursively($path);
    	}
    	if(is_dir($mobile_path)){
    		$this->rm_folder_recursively($mobile_path);
    	}
    }
    Thread Starter jmoria

    (@jmoria)

    Last time I made the test on my local WAMP server, installed on my PC. Now I checked on my web server (1and1.com hosting), and found some very strange behavior.

    When I “Trash” a post, the “all” directory is deleted (../wp-content/cache/all), not just the cache of the trashed post. It’s because you use $this->deleteCache() (to delete whole cache) instead of $this->singleDeleteCache(false, $post->ID) (to delete only single post cache).

    BUT, I changed $this->deleteCache() to $this->singleDeleteCache(false, $post->ID) and again it’s not working. It’s very strange because a few lines below (on post update) it’s working fine, the cache of updated post is deleted, but when I use $this->singleDeleteCache(false, $post->ID) for trashed post – it’s not working.

    Everything is tested via FileZilla.

    Thread Starter jmoria

    (@jmoria)

    *I forgot one zero in ‘numberposts’ => ‘3’. It should be ‘numberposts’ => ’30’. But you get it… 🙂

    Thread Starter jmoria

    (@jmoria)

    Exellent!

    Here are few sugesstions for new features.

    In Delete Cache tab:

    New features (with button and action triggered at the moment when user click on the button, same as Delete Cache feature):
    Delete Homepage Cache
    Delete Posts Cache
    Delete Categories Cache
    Delete Pages Cache

    New features in the same tab, but with checkboxes (like in the Settings tab):
    if new post is published, delete cache of homepage + pages, categories & tags associated with the post
    if post is trashed, delete the cache of that post. Here can be added another bonus feature/function to check if trashed post is in the last 20-30 posts, if it is – delete homepage cache too.

    Example:

    if($new_status == "trash" && $old_status != "trash"){
    
    $args = array(
    'numberposts' => '3',
    'post_status' => 'publish'
    );
    
    $recent_posts = wp_get_recent_posts($args);
    foreach($recent_posts as $recent){
    	if( $recent['ID'] == $post_id ){
    		@unlink($this->getWpContentDir()."/cache/all/index.html");
    		@unlink($this->getWpContentDir()."/cache/wpfc-mobile-cache/index.html");
    	}
    }
    
    //here is some other code to delete cache of the trashed post
    }
Viewing 5 replies - 1 through 5 (of 5 total)