Changeset 33122
- Timestamp:
- 07/08/2015 03:43:24 PM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r33021 r33122 1035 1035 1036 1036 /** 1037 * Get the default comment status for a post type. 1038 * 1039 * @since 4.3.0 1040 * 1041 * @param string $post_type Optional. Post type. Default 'post'. 1042 * @param string $comment_type Optional. Comment type. Default 'comment'. 1043 * @return string Expected return value is 'open' or 'closed'. 1044 */ 1045 function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { 1046 switch ( $comment_type ) { 1047 case 'pingback' : 1048 case 'trackback' : 1049 $supports = 'trackbacks'; 1050 $option = 'ping'; 1051 break; 1052 default : 1053 $supports = 'comments'; 1054 $option = 'comment'; 1055 } 1056 1057 // Set the status. 1058 if ( 'page' === $post_type ) { 1059 $status = 'closed'; 1060 } elseif ( post_type_supports( $post_type, $supports ) ) { 1061 $status = get_option( "default_{$option}_status" ); 1062 } else { 1063 $status = 'closed'; 1064 } 1065 1066 /** 1067 * Filter the default comment status for the given post type. 1068 * 1069 * @since 4.3.0 1070 * 1071 * @param string $status Default status for the given post type, 1072 * either 'open' or 'closed'. 1073 * @param string $post_type Post type. Default is `post`. 1074 * @param string $comment_type Type of comment. Default is `comment`. 1075 */ 1076 return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); 1077 } 1078 1079 /** 1037 1080 * The date the last comment was modified. 1038 1081 * -
trunk/src/wp-includes/post.php
r33054 r33122 4076 4076 4077 4077 /** 4078 * Get the default comment status for a post type.4079 *4080 * @since 4.3.04081 *4082 * @param string $post_type Optional. Post type. Default 'post'.4083 * @param string $comment_type Optional. Comment type. Default 'comment'.4084 * @return string Expected return value is 'open' or 'closed'.4085 */4086 function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) {4087 switch ( $comment_type ) {4088 case 'pingback' :4089 case 'trackback' :4090 $supports = 'trackbacks';4091 $option = 'ping';4092 break;4093 default :4094 $supports = 'comments';4095 $option = 'comment';4096 }4097 4098 // Set the status.4099 if ( 'page' === $post_type ) {4100 $status = 'closed';4101 } elseif ( post_type_supports( $post_type, $supports ) ) {4102 $status = get_option( "default_{$option}_status" );4103 } else {4104 $status = 'closed';4105 }4106 4107 /**4108 * Filter the default comment status for the given post type.4109 *4110 * @since 4.3.04111 *4112 * @param string $status Default status for the given post type,4113 * either 'open' or 'closed'.4114 * @param string $post_type Post type. Default is `post`.4115 * @param string $comment_type Type of comment. Default is `comment`.4116 */4117 return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type );4118 }4119 4120 /**4121 4078 * Add a URL to those already pinged. 4122 4079 *
Note: See TracChangeset
for help on using the changeset viewer.