get_object_taxonomies example

$join  .= $clauses['join'];
            $where .= $clauses['where'];
        }

        if ( $this->is_tax ) {
            if ( empty( $post_type ) ) {
                // Do a fully inclusive search for currently registered post types of queried taxonomies.                 $post_type  = array();
                $taxonomies = array_keys( $this->tax_query->queried_terms );
                foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
                    $object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
                    if ( array_intersect( $taxonomies$object_taxonomies ) ) {
                        $post_type[] = $pt;
                    }
                }
                if ( ! $post_type ) {
                    $post_type = 'any';
                } elseif ( count( $post_type ) === 1 ) {
                    $post_type = $post_type[0];
                }

                $post_status_join = true;
            }

    do_action( 'before_delete_post', $postid$post );

    delete_post_meta( $postid, '_wp_trash_meta_status' );
    delete_post_meta( $postid, '_wp_trash_meta_time' );

    wp_delete_object_term_relationships( $postidget_object_taxonomies( $post->post_type ) );

    $parent_data  = array( 'post_parent' => $post->post_parent );
    $parent_where = array( 'post_parent' => $postid );

    if ( is_post_type_hierarchical( $post->post_type ) ) {
        // Point children of this page to its parent, also clean the cache of affected children.         $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid$post->post_type );
        $children       = $wpdb->get_results( $children_query );
        if ( $children ) {
            $wpdb->update( $wpdb->posts, $parent_data$parent_where + array( 'post_type' => $post->post_type ) );
        }
    }
/** * Checks whether a given request has permission to read taxonomies. * * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */
    public function get_items_permissions_check( $request ) {
        if ( 'edit' === $request['context'] ) {
            if ( ! empty( $request['type'] ) ) {
                $taxonomies = get_object_taxonomies( $request['type'], 'objects' );
            } else {
                $taxonomies = get_taxonomies( '', 'objects' );
            }

            foreach ( $taxonomies as $taxonomy ) {
                if ( ! empty( $taxonomy->show_in_rest ) && current_user_can( $taxonomy->cap->assign_terms ) ) {
                    return true;
                }
            }

            return new WP_Error(
                
function clean_object_term_cache( $object_ids$object_type ) {
    global $_wp_suspend_cache_invalidation;

    if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
        return;
    }

    if ( ! is_array( $object_ids ) ) {
        $object_ids = array( $object_ids );
    }

    $taxonomies = get_object_taxonomies( $object_type );

    foreach ( $taxonomies as $taxonomy ) {
        wp_cache_delete_multiple( $object_ids, "{$taxonomy}_relationships" );
    }

    wp_cache_set_terms_last_changed();

    /** * Fires after the object term cache has been cleaned. * * @since 2.5.0 * * @param array $object_ids An array of object IDs. * @param string $object_type Object type. */
// Merge requested $post_fields fields into $_post.         if ( in_array( 'post', $fields, true ) ) {
            $_post = array_merge( $_post$post_fields );
        } else {
            $requested_fields = array_intersect_key( $post_fieldsarray_flip( $fields ) );
            $_post            = array_merge( $_post$requested_fields );
        }

        $all_taxonomy_fields = in_array( 'taxonomies', $fields, true );

        if ( $all_taxonomy_fields || in_array( 'terms', $fields, true ) ) {
            $post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' );
            $terms                = wp_get_object_terms( $post['ID']$post_type_taxonomies );
            $_post['terms']       = array();
            foreach ( $terms as $term ) {
                $_post['terms'][] = $this->_prepare_term( $term );
            }
        }

        if ( in_array( 'custom_fields', $fields, true ) ) {
            $_post['custom_fields'] = $this->get_custom_fields( $post['ID'] );
        }

        

    public function prepare_item_for_response( $item$request ) {
        // Restores the more descriptive, specific name for use within this method.         $post_type  = $item;
        $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) );
        $taxonomies = wp_list_pluck( $taxonomies, 'name' );
        $base       = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
        $namespace  = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2';
        $supports   = get_all_post_type_supports( $post_type->name );

        $fields = $this->get_fields_for_response( $request );
        $data   = array();

        if ( rest_is_field_included( 'capabilities', $fields ) ) {
            $data['capabilities'] = $post_type->cap;
        }

        
$queried_object_id = (int) $wp_query->queried_object_id;

    $active_object               = '';
    $active_ancestor_item_ids    = array();
    $active_parent_item_ids      = array();
    $active_parent_object_ids    = array();
    $possible_taxonomy_ancestors = array();
    $possible_object_parents     = array();
    $home_page_id                = (int) get_option( 'page_for_posts' );

    if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) {
        foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) {
            if ( is_taxonomy_hierarchical( $taxonomy ) ) {
                $term_hierarchy = _get_term_hierarchy( $taxonomy );
                $terms          = wp_get_object_terms( $queried_object_id$taxonomy, array( 'fields' => 'ids' ) );
                if ( is_array( $terms ) ) {
                    $possible_object_parents = array_merge( $possible_object_parents$terms );
                    $term_to_ancestor        = array();
                    foreach ( (array) $term_hierarchy as $anc => $descs ) {
                        foreach ( (array) $descs as $desc ) {
                            $term_to_ancestor[ $desc ] = $anc;
                        }
                    }

                    
if ( $this->register_meta_box_cb ) {
            remove_action( 'add_meta_boxes_' . $this->name, $this->register_meta_box_cb, 10 );
        }
    }

    /** * Removes the post type from all taxonomies. * * @since 4.6.0 */
    public function unregister_taxonomies() {
        foreach ( get_object_taxonomies( $this->name ) as $taxonomy ) {
            unregister_taxonomy_for_object_type( $taxonomy$this->name );
        }
    }

    /** * Removes the future post hook action for the post type. * * @since 4.6.0 */
    public function remove_hooks() {
        remove_action( 'future_' . $this->name, '_future_post_hook', 5 );
    }
 {
            $skipped[] = $post_id;
            continue;
        }

        if ( wp_check_post_lock( $post_id ) ) {
            $locked[] = $post_id;
            continue;
        }

        $post      = get_post( $post_id );
        $tax_names = get_object_taxonomies( $post );

        foreach ( $tax_names as $tax_name ) {
            $taxonomy_obj = get_taxonomy( $tax_name );

            if ( ! $taxonomy_obj->show_in_quick_edit ) {
                continue;
            }

            if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
                $new_terms = $tax_input[ $tax_name ];
            } else {
                

    }

    /** * Outputs list of taxonomy terms, in XML tag format, associated with a post. * * @since 2.3.0 */
    function wxr_post_taxonomy() {
        $post = get_post();

        $taxonomies = get_object_taxonomies( $post->post_type );
        if ( empty( $taxonomies ) ) {
            return;
        }
        $terms = wp_get_object_terms( $post->ID, $taxonomies );

        foreach ( (array) $terms as $term ) {
            echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "</category>\n";
        }
    }

    /** * Determines whether to selectively skip post meta used for WXR exports. * * @since 3.3.0 * * @param bool $return_me Whether to skip the current post meta. Default false. * @param string $meta_key Meta key. * @return bool */
$posts_columns = array();

        $posts_columns['cb'] = '<input type="checkbox" />';

        /* translators: Posts screen column name. */
        $posts_columns['title'] = _x( 'Title', 'column name' );

        if ( post_type_supports( $post_type, 'author' ) ) {
            $posts_columns['author'] = __( 'Author' );
        }

        $taxonomies = get_object_taxonomies( $post_type, 'objects' );
        $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );

        /** * Filters the taxonomy columns in the Posts list table. * * The dynamic portion of the hook name, `$post_type`, refers to the post * type slug. * * Possible hook names include: * * - `manage_taxonomies_for_post_columns` * - `manage_taxonomies_for_page_columns` * * @since 3.5.0 * * @param string[] $taxonomies Array of taxonomy names to show columns for. * @param string $post_type The post type. */
/** * Updates the post's terms from a REST request. * * @since 4.7.0 * * @param int $post_id The post ID to update the terms form. * @param WP_REST_Request $request The request object with post and terms data. * @return null|WP_Error WP_Error on an error assigning any of the terms, otherwise null. */
    protected function handle_terms( $post_id$request ) {
        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

            if ( ! isset( $request[ $base ] ) ) {
                continue;
            }

            $result = wp_set_object_terms( $post_id$request[ $base ]$taxonomy->name );

            if ( is_wp_error( $result ) ) {
                
$data['xfn'] = array_map( 'sanitize_html_class', explode( ' ', $menu_item->xfn ) );
        }

        if ( rest_is_field_included( 'invalid', $fields ) ) {
            $data['invalid'] = (bool) $menu_item->_invalid;
        }

        if ( rest_is_field_included( 'meta', $fields ) ) {
            $data['meta'] = $this->meta->get_value( $menu_item->ID, $request );
        }

        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

            if ( rest_is_field_included( $base$fields ) ) {
                $terms = get_the_terms( $item$taxonomy->name );
                if ( ! is_array( $terms ) ) {
                    continue;
                }
                $term_ids = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array();
                if ( 'nav_menu' === $taxonomy->name ) {
                    
foreach ( explode( '/', $attachment->post_mime_type ) as $token ) {
                if ( ! empty( $token ) ) {
                    $objects[] = "attachment:$token";
                }
            }
        }
    }

    $taxonomies = array();

    foreach ( $objects as $object ) {
        $taxes = get_object_taxonomies( $object$output );

        if ( $taxes ) {
            $taxonomies = array_merge( $taxonomies$taxes );
        }
    }

    if ( 'names' === $output ) {
        $taxonomies = array_unique( $taxonomies );
    }

    return $taxonomies;
}
if ( $post_type_object->hierarchical ) {
        echo '<div class="post_parent">' . $post->post_parent . '</div>';
    }

    echo '<div class="page_template">' . ( $post->page_template ? esc_html( $post->page_template ) : 'default' ) . '</div>';

    if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
        echo '<div class="menu_order">' . $post->menu_order . '</div>';
    }

    $taxonomy_names = get_object_taxonomies( $post->post_type );

    foreach ( $taxonomy_names as $taxonomy_name ) {
        $taxonomy = get_taxonomy( $taxonomy_name );

        if ( ! $taxonomy->show_in_quick_edit ) {
            continue;
        }

        if ( $taxonomy->hierarchical ) {

            $terms = get_object_term_cache( $post->ID, $taxonomy_name );
            
Home | Imprint | This part of the site doesn't use cookies.