Make WordPress Core

Ticket #17482: object-types.php

File object-types.php, 1.7 KB (added by mikeschinkel, 13 years ago)

/wp-includes/object-types.php

Line 
1<?php
2/**
3 * Object Type functions
4 *
5 * @package WordPress
6 * @subpackage Object
7 * @since 3.3
8 */
9
10/**
11 * Creates the list of object types when the 'init' action is fired.
12 *
13 * @since 3.3
14 */
15function create_object_types() {
16        global $wp_object_types;
17        $wp_object_types = array(
18                'post' => array( 'name' => __( 'Post' ) ),   // General case of a post type
19                'page' => array( 'name' => __( 'Page' ) ),   // Special case of $post->post_type == 'page'
20                'user' => array( 'name' => __( 'User' ) ),
21                'term' => array( 'name' => __( 'Term' ) ),
22                'term_taxonomy' => array( 'name' => __( 'Taxonomy Term' ) ),
23                'term_relationship' => array( 'name' => __( 'Taxonomy Term Object' ) ),
24                'link' => array( 'name' => __( 'Link' ) ),
25                'comment' => array( 'name' => __( 'Comment' ) ),
26                'option' => array( 'name' => __( 'Option' ) ),
27                'postmeta' => array( 'name' => __( 'Post Metadata' ) ),
28                'usermeta' => array( 'name' => __( 'User Metadata' ) ),
29                'commentmeta' => array( 'name' => __( 'Comment Metadata' ) ),
30                'site' => array( 'name' => __( 'Multisite Network' ) ),
31                'blog' => array( 'name' => __( 'Multisite Site/Blog' ) ),
32        );
33        return $wp_object_types;
34}
35add_action( 'init', 'create_object_types', 0 );  // 0 is highest priority
36
37/**
38 * Return the list of object types
39 *
40 * @since 3.3
41 */
42function get_object_types() {
43        global $wp_object_types;
44        return apply_filters( 'get_object_types', $wp_object_types );
45}
46
47/**
48 * Adds an object type.
49 *
50 * @since 3.3
51 */
52function add_object_type( $object_type, $args = array() ) {
53        global $wp_object_types;
54        $wp_object_types[ $object_type ] = $args;
55        return $wp_object_types;
56}
57
58/**
59 * Removes an object type.
60 *
61 * @since 3.3
62 */
63function remove_object_type( $object_type ) {
64        global $wp_object_types;
65        unset( $wp_object_types[ $object_type ] );
66}