add_hooks example

_doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2.0' );
        return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) );
    }

    $post_type_object = new WP_Post_Type( $post_type$args );
    $post_type_object->add_supports();
    $post_type_object->add_rewrite_rules();
    $post_type_object->register_meta_boxes();

    $wp_post_types[ $post_type ] = $post_type_object;

    $post_type_object->add_hooks();
    $post_type_object->register_taxonomies();

    /** * Fires after a post type is registered. * * @since 3.3.0 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object. * * @param string $post_type Post type. * @param WP_Post_Type $post_type_object Arguments used to register the post type. */
    
if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
        _doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2.0' );
        return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) );
    }

    $taxonomy_object = new WP_Taxonomy( $taxonomy$object_type$args );
    $taxonomy_object->add_rewrite_rules();

    $wp_taxonomies[ $taxonomy ] = $taxonomy_object;

    $taxonomy_object->add_hooks();

    // Add default term.     if ( ! empty( $taxonomy_object->default_term ) ) {
        $term = term_exists( $taxonomy_object->default_term['name']$taxonomy );
        if ( $term ) {
            update_option( 'default_term_' . $taxonomy_object->name, $term['term_id'] );
        } else {
            $term = wp_insert_term(
                $taxonomy_object->default_term['name'],
                $taxonomy,
                array(
                    
Home | Imprint | This part of the site doesn't use cookies.