wp_publish_post()
wp_publish_post( int|WP_Post $post ) 通过转换发布状态发布文章。 Publ…
wp_publish_post( int|WP_Post $post )
通过转换发布状态发布文章。
Publish a post by transitioning the post status.
目录锚点:#参数#源码
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$post | (int | WP_Post) | Post ID或Post对象。 |
源码(Source)
/** * Publish a post by transitioning the post status. * * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param int|WP_Post $post Post ID or post object. */ function wp_publish_post( $post ) { global $wpdb; if ( ! $post = get_post( $post ) ) return; if ( 'publish' == $post->post_status ) return; $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $old_status = $post->post_status; $post->post_status = 'publish'; wp_transition_post_status( 'publish', $old_status, $post ); /** This action is documented in wp-includes/post.php */ do_action( 'edit_post', $post->ID, $post ); /** This action is documented in wp-includes/post.php */ do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); /** This action is documented in wp-includes/post.php */ do_action( 'save_post', $post->ID, $post, true ); /** This action is documented in wp-includes/post.php */ do_action( 'wp_insert_post', $post->ID, $post, true ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.1.0 | wp-includes/post.php | 6 | 8 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!