Changeset 336473
- Timestamp:
- 01/24/2011 11:29:42 AM (15 years ago)
- Location:
- nginx-manager/trunk
- Files:
-
- 3 edited
-
nginx-manager.php (modified) (3 diffs)
-
nginxmNginx.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nginx-manager/trunk/nginx-manager.php
r334646 r336473 5 5 Description: Manage Nginx cache 6 6 Author: Simone Fumagalli & Marco Zanzottera 7 Version: 1.2. 17 Version: 1.2.2 8 8 Author URI: http://www.iliveinperego.com 9 9 Network: true … … 44 44 class nginxmLoader { 45 45 46 var $version = '1.2. 1'; // Plugin version46 var $version = '1.2.2'; // Plugin version 47 47 var $db_version = '1.2'; // DB version, change it to show the upgrade page 48 48 var $minium_WP = '3.0'; … … 86 86 add_action( 'publish_post', array(&$nginxmNginx, 'purgePost'), 200, 1); 87 87 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); 89 92 90 93 /* Purge custom post types, @since Nginx Manager 1.2 */ -
nginx-manager/trunk/nginxmNginx.php
r326617 r336473 56 56 57 57 } 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." ); 64 79 65 80 switch ( current_filter() ) { 66 81 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() ) { 72 101 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( "* * * * *" ); 74 107 break; 75 108 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 ===" ); 79 130 80 131 /* Homepage */ … … 103 154 104 155 /* 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 */ 108 159 $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']); 109 160 110 161 } else { 111 162 112 /* When a post/page is modified */163 /* When a post/page/custom post type is modified */ 113 164 $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']); 114 165 } … … 211 262 function purgeUrl($url, $feed = true) { 212 263 213 $this->log( " Purging URL | ".$url );264 $this->log( "- Purging URL | ".$url ); 214 265 215 266 $parse = parse_url($url); … … 235 286 switch ( $response['response']['code'] ) { 236 287 case 200: 237 $this->log( $url." *** PURGED ***" );288 $this->log( "- - ".$url." *** PURGED ***" ); 238 289 break; 239 290 case 404: 240 $this->log( $url." is currently not cached" );291 $this->log( "- - ".$url." is currently not cached" ); 241 292 break; 242 293 default: 243 $this->log( $url." not found (".$response['response']['code'].")", "WARNING" );294 $this->log( "- - ".$url." not found (".$response['response']['code'].")", "WARNING" ); 244 295 } 245 296 } -
nginx-manager/trunk/readme.txt
r334646 r336473 63 63 == Changelog == 64 64 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 65 69 = 1.2.1 (2011 01 19) = 66 70 * EDIT : Set default options when a new blog is installed
Note: See TracChangeset
for help on using the changeset viewer.