Make WordPress Core

Ticket #17447: register_post_type_args-hook-v2.diff

File register_post_type_args-hook-v2.diff, 2.3 KB (added by MikeSchinkel, 11 years ago)

Revised 'register_post_type_args' based on current trunk and with hook documentation.

  • trunk/wp-includes/post.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    12101210                '_edit_link'           => 'post.php?post=%d',
    12111211        );
    12121212        $args = wp_parse_args( $args, $defaults );
    1213         $args = (object) $args;
     1213        $args['name'] = sanitize_key( $post_type );
     1214        /**
     1215         * Allow preprocessing of post type arguments.
     1216         *
     1217         * Empowers developers to:
     1218         *
     1219         *    - Change visbility values or disable post types or provided by a plugin/theme
     1220         *                      not needed for a specific site.
     1221         *              - Add new plugin/theme specific "supports" for default post types and
     1222         *      custom post types that don't explicity specify supports.
     1223         *              - Add new plugin/theme specific values to support  plugin/theme added features.
     1224         *                      For example, 'my_exporter' value could be set to information that the My Exporter
     1225         *      plugin uses to implement an export such as columns to include, column labels,
     1226         *      WP_Query args for default export as well as meta fields to include.
     1227         *    - Disable default rewrite rule addition so customized rewrite rules could be added
     1228         *      in a function called for the 'registered_post_type' hook.
     1229         *    - Disable default metabox callback registration so customized metabox callback registration
     1230         *      could be performed in a function called for the 'registered_post_type' hook.
     1231         *    - Disable taxonomy registration for object so customized taxonomy registration for
     1232         *      object could be performed in a function called for the 'registered_post_type' hook.
     1233         *
     1234         * @since 3.9.0
     1235         *
     1236         * @param array|string $args See optional args description in function header above.
     1237         * @param string $post_type Post type key passed to register_post_type(), after
     1238         *                          sanitization. Should not exceed 20 characters.
     1239         */
     1240        $args = apply_filters( 'register_post_type_args', $args, $post_type );
     1241        if ( empty( $args ) ) {
     1242                return false;
     1243        }
    12141244
    1215         $post_type = sanitize_key( $post_type );
    1216         $args->name = $post_type;
     1245        $post_type = $args['name'];
     1246
     1247        $args = (object) $args;
    12171248
    12181249        if ( strlen( $post_type ) > 20 )
    12191250                return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );