/** * Handler for updating the blog date when a published post is deleted. * * @since 3.4.0 * * @param int $post_id Post ID */ function _update_blog_date_on_post_delete($post_id) { $post = get_post($post_id); $post_type_obj = get_post_type_object($post->post_type); if (!$post_type_obj || !$post_type_obj->public) { return; } if ('publish' != $post->post_status) { return; } wpmu_update_blogs_date(); }
/** * Handler for updating the blog date when a post is published or an already published post is changed. * * @since 3.3.0 * * @param string $new_status The new post status * @param string $old_status The old post status * @param object $post Post object */ function _update_blog_date_on_post_publish($new_status, $old_status, $post) { $post_type_obj = get_post_type_object($post->post_type); if (!$post_type_obj->public) { return; } if ('publish' != $new_status && 'publish' != $old_status) { return; } // Post was freshly published, published post was saved, or published post was unpublished. wpmu_update_blogs_date(); }
function test_wpmu_update_blogs_date() { global $wpdb; wpmu_update_blogs_date(); // compare the update time with the current time, allow delta < 2 $blog = get_blog_details( $wpdb->blogid ); $current_time = time(); $time_difference = $current_time - strtotime( $blog->last_updated ); $this->assertLessThan( 2, $time_difference ); }
@unlink($dir_to_copy_into . '/sitemap.xml'); } } else { _e("<span class=\"error\">Was unable to copy images and uploads!</span>", 'acswpmu_trdom'); } } } //reset permalink structure if (!$error) { switch_to_blog($new_blog_id); //_e("Switched from here to $new_blog_id to reset permalinks<br>", 'acswpmu_trdom' ); global $wp_rewrite; $wp_rewrite->init(); $wp_rewrite->flush_rules(); //now that we are here, update the date of the new site wpmu_update_blogs_date(); //go back to admin restore_current_blog(); _e("Permalinks updated.<br>", 'acswpmu_trdom'); } // count succesfull and failed sites if (!$error) { _e("Job done, sucesfully created {$fulldomain} with site id: {$new_blog_id}<br>", 'acswpmu_trdom'); if ($domainmap) { _e("and mapped the site to: <a href=\"http://{$siteurl}\" target=\"test\">{$siteurl}</a>.<br>", 'acswpmu_trdom'); } // count succesfull cloned sites $cloned[] = $siteurl; } else { // count failed sites $failed[] = $siteurl;