WordPress.org

Make WordPress Core

Changeset 34242


Ignore:
Timestamp:
09/16/15 15:46:14 (22 months ago)
Author:
SergeyBiryukov
Message:

Add register_post_type_args filter for changing register_post_type() arguments before further processing.

Does not apply to built-in post types.

Props MikeSchinkel, nickciske, engelen, swissspidy.
Fixes #17447.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-functions.php

    r34240 r34242  
    985985    global $wp_post_types, $wp_rewrite, $wp; 
    986986 
    987     if ( ! is_array( $wp_post_types ) ) 
     987    if ( ! is_array( $wp_post_types ) ) { 
    988988        $wp_post_types = array(); 
     989    } 
     990 
     991    // Sanitize post type name 
     992    $post_type = sanitize_key( $post_type ); 
     993 
     994    if ( empty( $args['_builtin'] ) ) { 
     995        /** 
     996         * Filter the arguments for registering a post type. 
     997         * 
     998         * Not available for built-in post types. 
     999         * 
     1000         * @since 4.4.0 
     1001         * 
     1002         * @param array|string $args      Array or string of arguments for registering a post type. 
     1003         * @param string       $post_type Post type key. 
     1004         */ 
     1005        $args = apply_filters( 'register_post_type_args', $args, $post_type ); 
     1006    } 
    9891007 
    9901008    // Args prefixed with an underscore are reserved for internal use. 
     
    10191037    $args = (object) $args; 
    10201038 
    1021     $post_type = sanitize_key( $post_type ); 
    10221039    $args->name = $post_type; 
    10231040 
Note: See TracChangeset for help on using the changeset viewer.