From a4e803fbd4633566258f6a39ca91257289bc89b6 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 2 Jul 2015 22:32:25 +0000 Subject: [PATCH] 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 --- wp-admin/includes/post.php | 4 ++-- wp-admin/post.php | 4 ++-- wp-includes/class-wp-xmlrpc-server.php | 20 ++++++++++---------- wp-includes/post.php | 3 ++- wp-includes/version.php | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 1be48680b1..2ab53352ad 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -610,8 +610,8 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) $post->post_status = 'draft'; $post->to_ping = ''; $post->pinged = ''; - $post->comment_status = get_option( 'default_comment_status' ); - $post->ping_status = get_option( 'default_ping_status' ); + $post->comment_status = get_default_comment_status( $post_type ); + $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); $post->post_pingback = get_option( 'default_pingback_flag' ); $post->post_category = get_option( 'default_category' ); $post->page_template = 'default'; diff --git a/wp-admin/post.php b/wp-admin/post.php index 65140aaa73..c049d6a937 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -129,8 +129,8 @@ case 'post-quickdraft-save': $post = get_post( $_REQUEST['post_ID'] ); check_admin_referer( 'add-' . $post->post_type ); - $_POST['comment_status'] = get_option( 'default_comment_status' ); - $_POST['ping_status'] = get_option( 'default_ping_status' ); + $_POST['comment_status'] = get_default_comment_status( $post->post_type ); + $_POST['ping_status'] = get_default_comment_status( $post->post_type, 'pingback' ); edit_post(); wp_dashboard_quick_press(); diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 4a68aaae5a..0573b71490 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -4809,7 +4809,7 @@ class wp_xmlrpc_server extends IXR_Server { $comment_status = 'open'; break; default: - $comment_status = get_option('default_comment_status'); + $comment_status = get_default_comment_status( $post_type ); break; } } else { @@ -4822,12 +4822,12 @@ class wp_xmlrpc_server extends IXR_Server { $comment_status = 'open'; break; default: - $comment_status = get_option('default_comment_status'); + $comment_status = get_default_comment_status( $post_type ); break; } } } else { - $comment_status = get_option('default_comment_status'); + $comment_status = get_default_comment_status( $post_type ); } if ( isset($content_struct['mt_allow_pings']) ) { @@ -4840,7 +4840,7 @@ class wp_xmlrpc_server extends IXR_Server { $ping_status = 'open'; break; default: - $ping_status = get_option('default_ping_status'); + $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } else { @@ -4852,12 +4852,12 @@ class wp_xmlrpc_server extends IXR_Server { $ping_status = 'open'; break; default: - $ping_status = get_option('default_ping_status'); + $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } } else { - $ping_status = get_option('default_ping_status'); + $ping_status = get_default_comment_status( $post_type, 'pingback' ); } if ( $post_more ) @@ -5120,7 +5120,7 @@ class wp_xmlrpc_server extends IXR_Server { $comment_status = 'open'; break; default: - $comment_status = get_option('default_comment_status'); + $comment_status = get_default_comment_status( $post_type ); break; } } else { @@ -5133,7 +5133,7 @@ class wp_xmlrpc_server extends IXR_Server { $comment_status = 'open'; break; default: - $comment_status = get_option('default_comment_status'); + $comment_status = get_default_comment_status( $post_type ); break; } } @@ -5149,7 +5149,7 @@ class wp_xmlrpc_server extends IXR_Server { $ping_status = 'open'; break; default: - $ping_status = get_option('default_ping_status'); + $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } else { @@ -5161,7 +5161,7 @@ class wp_xmlrpc_server extends IXR_Server { $ping_status = 'open'; break; default: - $ping_status = get_option('default_ping_status'); + $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } diff --git a/wp-includes/post.php b/wp-includes/post.php index 52600b847e..5237f941ae 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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, * 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_{$post_type}_default_comment_status", $status, $comment_type ); + return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index b7f4556163..51763a69a9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.