wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_default_comment_status › WordPress Function

Seit4.3.0
Veraltetn/v
get_default_comment_status ( $post_type = 'post', $comment_type = 'comment' )
Parameter: (2)
  • (string) $post_type Optional. Post type. Default 'post'.
    Erforderlich: Nein
    Standard: 'post'
  • (string) $comment_type Optional. Comment type. Default 'comment'.
    Erforderlich: Nein
    Standard: 'comment'
Gibt zurück:
  • (string) Either 'open' or 'closed'.
Definiert in:
Codex:

Gets the default comment status for a post type.



Quellcode

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';
			break;
	}

	// 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';
	}

	/**
	 * Filters 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 );
}