Use `get_default_comment_status()` globally.

Also makes the filter name static and passes the post type for context.

Props valendesigns.
Fixes #31168.


Built from https://develop.svn.wordpress.org/trunk@33054


git-svn-id: http://core.svn.wordpress.org/trunk@33025 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2015-07-02 22:32:25 +00:00
parent cd7a40bdc7
commit a4e803fbd4
5 changed files with 17 additions and 16 deletions

View File

@ -610,8 +610,8 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
$post->post_status = 'draft'; $post->post_status = 'draft';
$post->to_ping = ''; $post->to_ping = '';
$post->pinged = ''; $post->pinged = '';
$post->comment_status = get_option( 'default_comment_status' ); $post->comment_status = get_default_comment_status( $post_type );
$post->ping_status = get_option( 'default_ping_status' ); $post->ping_status = get_default_comment_status( $post_type, 'pingback' );
$post->post_pingback = get_option( 'default_pingback_flag' ); $post->post_pingback = get_option( 'default_pingback_flag' );
$post->post_category = get_option( 'default_category' ); $post->post_category = get_option( 'default_category' );
$post->page_template = 'default'; $post->page_template = 'default';

View File

@ -129,8 +129,8 @@ case 'post-quickdraft-save':
$post = get_post( $_REQUEST['post_ID'] ); $post = get_post( $_REQUEST['post_ID'] );
check_admin_referer( 'add-' . $post->post_type ); check_admin_referer( 'add-' . $post->post_type );
$_POST['comment_status'] = get_option( 'default_comment_status' ); $_POST['comment_status'] = get_default_comment_status( $post->post_type );
$_POST['ping_status'] = get_option( 'default_ping_status' ); $_POST['ping_status'] = get_default_comment_status( $post->post_type, 'pingback' );
edit_post(); edit_post();
wp_dashboard_quick_press(); wp_dashboard_quick_press();

View File

@ -4809,7 +4809,7 @@ class wp_xmlrpc_server extends IXR_Server {
$comment_status = 'open'; $comment_status = 'open';
break; break;
default: default:
$comment_status = get_option('default_comment_status'); $comment_status = get_default_comment_status( $post_type );
break; break;
} }
} else { } else {
@ -4822,12 +4822,12 @@ class wp_xmlrpc_server extends IXR_Server {
$comment_status = 'open'; $comment_status = 'open';
break; break;
default: default:
$comment_status = get_option('default_comment_status'); $comment_status = get_default_comment_status( $post_type );
break; break;
} }
} }
} else { } else {
$comment_status = get_option('default_comment_status'); $comment_status = get_default_comment_status( $post_type );
} }
if ( isset($content_struct['mt_allow_pings']) ) { if ( isset($content_struct['mt_allow_pings']) ) {
@ -4840,7 +4840,7 @@ class wp_xmlrpc_server extends IXR_Server {
$ping_status = 'open'; $ping_status = 'open';
break; break;
default: default:
$ping_status = get_option('default_ping_status'); $ping_status = get_default_comment_status( $post_type, 'pingback' );
break; break;
} }
} else { } else {
@ -4852,12 +4852,12 @@ class wp_xmlrpc_server extends IXR_Server {
$ping_status = 'open'; $ping_status = 'open';
break; break;
default: default:
$ping_status = get_option('default_ping_status'); $ping_status = get_default_comment_status( $post_type, 'pingback' );
break; break;
} }
} }
} else { } else {
$ping_status = get_option('default_ping_status'); $ping_status = get_default_comment_status( $post_type, 'pingback' );
} }
if ( $post_more ) if ( $post_more )
@ -5120,7 +5120,7 @@ class wp_xmlrpc_server extends IXR_Server {
$comment_status = 'open'; $comment_status = 'open';
break; break;
default: default:
$comment_status = get_option('default_comment_status'); $comment_status = get_default_comment_status( $post_type );
break; break;
} }
} else { } else {
@ -5133,7 +5133,7 @@ class wp_xmlrpc_server extends IXR_Server {
$comment_status = 'open'; $comment_status = 'open';
break; break;
default: default:
$comment_status = get_option('default_comment_status'); $comment_status = get_default_comment_status( $post_type );
break; break;
} }
} }
@ -5149,7 +5149,7 @@ class wp_xmlrpc_server extends IXR_Server {
$ping_status = 'open'; $ping_status = 'open';
break; break;
default: default:
$ping_status = get_option('default_ping_status'); $ping_status = get_default_comment_status( $post_type, 'pingback' );
break; break;
} }
} else { } else {
@ -5161,7 +5161,7 @@ class wp_xmlrpc_server extends IXR_Server {
$ping_status = 'open'; $ping_status = 'open';
break; break;
default: default:
$ping_status = get_option('default_ping_status'); $ping_status = get_default_comment_status( $post_type, 'pingback' );
break; break;
} }
} }

View File

@ -4111,9 +4111,10 @@ function get_default_comment_status( $post_type = 'post', $comment_type = 'comme
* *
* @param string $status Default status for the given post type, * @param string $status Default status for the given post type,
* either 'open' or 'closed'. * either 'open' or 'closed'.
* @param string $post_type Post type. Default is `post`.
* @param string $comment_type Type of comment. Default is `comment`. * @param string $comment_type Type of comment. Default is `comment`.
*/ */
return apply_filters( "get_{$post_type}_default_comment_status", $status, $comment_type ); return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type );
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.3-beta1-33053'; $wp_version = '4.3-beta1-33054';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.