_update_blog_date_on_post_publish

函式
_update_blog_date_on_post_publish ( $new_status, $old_status, $post )
引數
  • (string) $new_status The new post status.
    Required:
  • (string) $old_status The old post status.
    Required:
  • (WP_Post) $post Post object.
    Required:
定義位置
相關方法
_update_blog_date_on_post_deleteupdate_blog_publicupdate_blog_detailsupdate_blog_statuswpmu_update_blogs_date
引入
3.3.0
棄用
-

_update_blog_date_on_post_publish: 這個函式在文章釋出時更新部落格的日期。它被用來確保部落格的日期即使在新增新的文章時也保持準確。

當一個文章被髮表或已經發表的文章被修改時,更新網站最後更新日期的處理程式。
已經發表的文章被改變時,更新網站最後更新日期的處理程式。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 || ! $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 _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 || ! $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 _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 || ! $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();
}

常見問題

FAQs
檢視更多 >