Make WordPress Core

Ticket #17447: 17447.diff

File 17447.diff, 1.2 KB (added by swissspidy, 10 years ago)
  • src/wp-includes/post-functions.php

    diff --git src/wp-includes/post-functions.php src/wp-includes/post-functions.php
    index fdd01ee..4733f3b 100644
    function register_post_type( $post_type, $args = array() ) { 
    986986        if ( ! is_array( $wp_post_types ) )
    987987                $wp_post_types = array();
    988988
     989        // Sanitize post type name.
     990        $post_type = sanitize_key( $post_type );
     991
     992        if ( empty( $args['_builtin'] ) ) {
     993                /**
     994                 * Filter the arguments for registering a post type.
     995                 *
     996                 * Not available for built-in post types.
     997                 *
     998                 * @since 4.4.0
     999                 *
     1000                 * @param array|string $args      Array or string of arguments for registering a post type.
     1001                 * @param string       $post_type Post type key.
     1002                 */
     1003                $args = apply_filters( 'register_post_type_args', $args, $post_type );
     1004        }
     1005
    9891006        // Args prefixed with an underscore are reserved for internal use.
    9901007        $defaults = array(
    9911008                'labels'               => array(),
    function register_post_type( $post_type, $args = array() ) { 
    10171034        $args = wp_parse_args( $args, $defaults );
    10181035        $args = (object) $args;
    10191036
    1020         $post_type = sanitize_key( $post_type );
    10211037        $args->name = $post_type;
    10221038
    10231039        if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {