From 30e478b1fbf3e5d2feedffb585b3e6cdeee32333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Wed, 8 Jul 2015 15:44:28 +0000 Subject: [PATCH] Move `get_default_comment_status()` to `wp-includes/comment.php` to sit alongside `get_comment_statuses()`. props nacin. see #31168. Built from https://develop.svn.wordpress.org/trunk@33122 git-svn-id: http://core.svn.wordpress.org/trunk@33093 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 43 +++++++++++++++++++++++++++++++++++++++++ wp-includes/post.php | 43 ----------------------------------------- wp-includes/version.php | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index f62fc2a0e9..99b8706f57 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1033,6 +1033,49 @@ function get_comment_statuses() { return $status; } +/** + * Get the default comment status for a post type. + * + * @since 4.3.0 + * + * @param string $post_type Optional. Post type. Default 'post'. + * @param string $comment_type Optional. Comment type. Default 'comment'. + * @return string Expected return value is 'open' or 'closed'. + */ +function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { + switch ( $comment_type ) { + case 'pingback' : + case 'trackback' : + $supports = 'trackbacks'; + $option = 'ping'; + break; + default : + $supports = 'comments'; + $option = 'comment'; + } + + // Set the status. + if ( 'page' === $post_type ) { + $status = 'closed'; + } elseif ( post_type_supports( $post_type, $supports ) ) { + $status = get_option( "default_{$option}_status" ); + } else { + $status = 'closed'; + } + + /** + * Filter the default comment status for the given post type. + * + * @since 4.3.0 + * + * @param string $status Default status for the given post type, + * either 'open' or 'closed'. + * @param string $post_type Post type. Default is `post`. + * @param string $comment_type Type of comment. Default is `comment`. + */ + return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); +} + /** * The date the last comment was modified. * diff --git a/wp-includes/post.php b/wp-includes/post.php index 5237f941ae..6c58c853ef 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4074,49 +4074,6 @@ function wp_transition_post_status( $new_status, $old_status, $post ) { // Comment, trackback, and pingback functions. // -/** - * Get the default comment status for a post type. - * - * @since 4.3.0 - * - * @param string $post_type Optional. Post type. Default 'post'. - * @param string $comment_type Optional. Comment type. Default 'comment'. - * @return string Expected return value is 'open' or 'closed'. - */ -function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { - switch ( $comment_type ) { - case 'pingback' : - case 'trackback' : - $supports = 'trackbacks'; - $option = 'ping'; - break; - default : - $supports = 'comments'; - $option = 'comment'; - } - - // Set the status. - if ( 'page' === $post_type ) { - $status = 'closed'; - } elseif ( post_type_supports( $post_type, $supports ) ) { - $status = get_option( "default_{$option}_status" ); - } else { - $status = 'closed'; - } - - /** - * Filter the default comment status for the given post type. - * - * @since 4.3.0 - * - * @param string $status Default status for the given post type, - * either 'open' or 'closed'. - * @param string $post_type Post type. Default is `post`. - * @param string $comment_type Type of comment. Default is `comment`. - */ - return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); -} - /** * Add a URL to those already pinged. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 714f7e472c..0ed494bea2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta1-33121'; +$wp_version = '4.3-beta1-33122'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.