Plugin Directory

Changeset 336473


Ignore:
Timestamp:
01/24/2011 11:29:42 AM (15 years ago)
Author:
rukbat
Message:

Upgrade to version 1.2.2

Location:
nginx-manager/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nginx-manager/trunk/nginx-manager.php

    r334646 r336473  
    55Description: Manage Nginx cache
    66Author: Simone Fumagalli & Marco Zanzottera
    7 Version: 1.2.1
     7Version: 1.2.2
    88Author URI: http://www.iliveinperego.com
    99Network: true
     
    4444    class nginxmLoader {
    4545       
    46         var $version            = '1.2.1'; // Plugin version
     46        var $version            = '1.2.2'; // Plugin version
    4747        var $db_version         = '1.2'; // DB version, change it to show the upgrade page
    4848        var $minium_WP          = '3.0';
     
    8686            add_action( 'publish_post', array(&$nginxmNginx, 'purgePost'), 200, 1);
    8787            add_action( 'publish_page', array(&$nginxmNginx, 'purgePost'), 200, 1);
    88             add_action( 'comment_post', array(&$nginxmNginx, 'purgePost'), 200, 1);
     88            add_action( 'comment_post', array(&$nginxmNginx, 'purgePostOnComment'), 200, 1);
     89           
     90            /* Purge URL when the status of a comment changes, @since Nginx Manager 1.2.2 */
     91            add_action( 'wp_set_comment_status', array(&$nginxmNginx, 'purgePostOnComment'), 200, 2);
    8992           
    9093            /* Purge custom post types, @since Nginx Manager 1.2 */
  • nginx-manager/trunk/nginxmNginx.php

    r326617 r336473  
    5656       
    5757        }
    58 
    59         function purgePost($_ID) {
    60            
    61             global $nginxm, $blog_id;
    62            
    63             $this->log( "Function purgePost BEGIN ===" );
     58       
     59        /**
     60         * Runs when a comment is saved in the database or when the status of the comment changes.
     61         * Retrieves post id and call purgePost().
     62         *
     63         * @param $_comment_id
     64         * @param $_comment_status
     65         * @since Nginx Manager 1.2.2
     66         */
     67        function purgePostOnComment( $_comment_id, $_comment_status = '' ) {
     68           
     69            global $blog_id;
     70           
     71            // Retrieves post ID.
     72            $_comment = get_comment( $_comment_id );
     73            $_post_id = $_comment->comment_post_ID;
     74           
     75            $this->log( "* * * * *" );
     76            $this->log( "* Blog :: ".addslashes( get_bloginfo('name') )." ($blog_id)." );
     77            $this->log( "* Post :: ".get_the_title($_post_id)." ($_post_id)." );
     78            $this->log( "* Comment :: $_comment_id." );
    6479           
    6580            switch ( current_filter() ) {
    6681                case 'comment_post':
    67                     $_comment_ID = $_ID;
    68                     $_comment = get_comment($_ID);
    69                     $_ID = $_comment->comment_post_ID;
    70                     $this->log( "New comment published/edited (id $_comment_ID) on post ($_ID) on blog '".addslashes(get_bloginfo('name'))."' ($blog_id)" );
    71                     break;
     82                    $this->log( "* New comment ($_comment_id) saved in the database. Let's purge the post ($_post_id)." );
     83                    break;
     84                case 'wp_set_comment_status':
     85                    $this->log( "* Comment ($_comment_id) set to status '$_comment_status'. Let's purge the post ($_post_id)." );
     86                    break;
     87            }
     88           
     89            $this->log( "* * * * *" );
     90           
     91            // Calls purgePost().
     92            $this->purgePost( $_post_id );
     93           
     94        }
     95
     96        function purgePost($_ID) {
     97           
     98            global $nginxm, $blog_id;
     99           
     100            switch ( current_filter() ) {
    72101                case 'publish_post':
    73                     $this->log( "New post published/edited (id $_ID) on blog '".addslashes(get_bloginfo('name'))."' ($blog_id)" );
     102                    $this->log( "* * * * *" );
     103                    $this->log( "* Blog :: ".addslashes( get_bloginfo('name') )." ($blog_id)." );
     104                    $this->log( "* Post :: ".get_the_title($_ID)." ($_ID)." );
     105                    $this->log( "* Post ($_ID) published or edited and its status is published" );
     106                    $this->log( "* * * * *" );
    74107                    break;
    75108                case 'publish_page':
    76                     $this->log( "New page published/edited (id $_ID) on blog '".addslashes(get_bloginfo('name'))."' ($blog_id)" );
    77                     break;
    78             }
     109                    $this->log( "* * * * *" );
     110                    $this->log( "* Blog :: ".addslashes( get_bloginfo('name') )." ($blog_id)." );
     111                    $this->log( "* Page :: ".get_the_title($_ID)." ($_ID)." );
     112                    $this->log( "* Page ($_ID) published or edited and its status is published" );
     113                    $this->log( "* * * * *" );
     114                    break;
     115                case 'comment_post':
     116                case 'wp_set_comment_status':
     117                    break;
     118                default:
     119                    // It's a custom post type.
     120                    $_post_type = get_post_type($_ID);
     121                    $this->log( "* * * * *" );
     122                    $this->log( "* Blog :: ".addslashes( get_bloginfo('name') )." ($blog_id)." );
     123                    $this->log( "* Custom post type '$_post_type' :: ".get_the_title($_ID)." ($_ID)." );
     124                    $this->log( "* CPT '$_post_type' ($_ID) published or edited and its status is published" );
     125                    $this->log( "* * * * *" );
     126                    break;
     127            }
     128           
     129            $this->log( "Function purgePost BEGIN ===" );
    79130           
    80131            /* Homepage */
     
    103154           
    104155            /* Post or comment */
    105             if ( current_filter() == 'comment_post' ) {
    106                
    107                 /* When a new comment is published */
     156            if ( current_filter() == 'comment_post' || current_filter() == 'wp_set_comment_status' ) {
     157               
     158                /* When a comment is published/edited */
    108159                $this->_purge_by_options($_ID, $blog_id, $nginxm->options['automatically_purge_comment_page'], $nginxm->options['automatically_purge_comment_archive'], $nginxm->options['automatically_purge_comment_custom_taxa']);
    109160               
    110161            } else {
    111162               
    112                 /* When a post/page is modified */
     163                /* When a post/page/custom post type is modified */
    113164                $this->_purge_by_options($_ID, $blog_id, $nginxm->options['automatically_purge_page'], $nginxm->options['automatically_purge_page_archive'], $nginxm->options['automatically_purge_page_custom_taxa']);
    114165            }
     
    211262        function purgeUrl($url, $feed = true) {
    212263           
    213             $this->log( "Purging URL | ".$url );
     264            $this->log( "- Purging URL | ".$url );
    214265           
    215266            $parse      = parse_url($url);
     
    235286                    switch ( $response['response']['code'] ) {
    236287                        case 200:
    237                             $this->log( $url." *** PURGED ***" );
     288                            $this->log( "- - ".$url." *** PURGED ***" );
    238289                            break;
    239290                        case 404:
    240                             $this->log( $url." is currently not cached" );
     291                            $this->log( "- - ".$url." is currently not cached" );
    241292                            break;
    242293                        default:
    243                             $this->log( $url." not found (".$response['response']['code'].")", "WARNING" );
     294                            $this->log( "- - ".$url." not found (".$response['response']['code'].")", "WARNING" );
    244295                    }
    245296                }
  • nginx-manager/trunk/readme.txt

    r334646 r336473  
    6363== Changelog ==
    6464
     65= 1.2.2 (2011 01 24) =
     66* BUG : Fixed purge when comments are approved/trashed/etc
     67* EDIT : Log file beautified (more readable)
     68
    6569= 1.2.1 (2011 01 19) =
    6670* EDIT : Set default options when a new blog is installed
Note: See TracChangeset for help on using the changeset viewer.