is_object_in_taxonomy example


    $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies$post->ID, $classes$css_class );

    foreach ( (array) $taxonomies as $taxonomy ) {
        if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
            foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
                if ( empty( $term->slug ) ) {
                    continue;
                }

                $term_class = sanitize_html_class( $term->slug, $term->term_id );
                if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
                    $term_class = $term->term_id;
                }

                // 'post_tag' uses the 'tag' prefix for backward compatibility.
// Use the newly generated $post_id.         $where = array( 'ID' => $post_id );
    }

    if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) {
        $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title']$post_id )$post_id$data['post_status']$post_type$post_parent );

        $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] )$where );
        clean_post_cache( $post_id );
    }

    if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
        wp_set_post_categories( $post_id$post_category );
    }

    if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
        wp_set_post_tags( $post_id$postarr['tags_input'] );
    }

    // Add default term for all associated custom taxonomies.     if ( 'auto-draft' !== $post_status ) {
        foreach ( get_object_taxonomies( $post_type, 'object' ) as $taxonomy => $tax_object ) {

            
/** This filter is documented in wp-admin/post.php */
                            $replace_editor = apply_filters( 'replace_editor', false, $post );

                            if ( ! $replace_editor ) {
                                $is_block_editor = use_block_editor_for_post( $post );
                            }
                        }
                    }
                    break;
                case 'edit-tags':
                case 'term':
                    if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
                        $post_type = 'post';
                    }
                    break;
                case 'upload':
                    $post_type = 'attachment';
                    break;
            }
        }

        switch ( $base ) {
            case 'post':
                

    $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );

    if ( $in_same_term || ! empty( $excluded_terms ) ) {
        if ( $in_same_term ) {
            $join  .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
            $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );

            if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
                return '';
            }
            $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );

            // Remove any exclusions from the term array to include.             $term_array = array_diff( $term_array(array) $excluded_terms );
            $term_array = array_map( 'intval', $term_array );

            if ( ! $term_array || is_wp_error( $term_array ) ) {
                return '';
            }

            

function get_the_category_list( $separator = '', $parents = '', $post_id = false ) {
    global $wp_rewrite;

    if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) {
        /** This filter is documented in wp-includes/category-template.php */
        return apply_filters( 'the_category', '', $separator$parents );
    }

    /** * Filters the categories before building the category list. * * @since 4.4.0 * * @param WP_Term[] $categories An array of the post's categories. * @param int|false $post_id ID of the post to retrieve categories for. * When `false`, defaults to the current post in the loop. */

    public function __get( $key ) {
        if ( 'page_template' === $key && $this->__isset( $key ) ) {
            return get_post_meta( $this->ID, '_wp_page_template', true );
        }

        if ( 'post_category' === $key ) {
            if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) {
                $terms = get_the_terms( $this, 'category' );
            }

            if ( empty( $terms ) ) {
                return array();
            }

            return wp_list_pluck( $terms, 'term_id' );
        }

        if ( 'tags_input' === $key ) {
            

        if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) {
            return;
        }

        if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
            $dropdown_options = array(
                'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
                'hide_empty'      => 0,
                'hierarchical'    => 1,
                'show_count'      => 0,
                'orderby'         => 'name',
                'selected'        => $cat,
            );

            echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';

            
/** * Checks if the terms for a post can be read. * * @since 6.0.3 * * @param WP_Post $post Post object. * @param WP_REST_Request $request Full details about the request. * @return bool Whether the terms for the post can be read. */
    public function check_read_terms_permission_for_post( $post$request ) {
        // If the requested post isn't associated with this taxonomy, deny access.         if ( ! is_object_in_taxonomy( $post->post_type, $this->taxonomy ) ) {
            return false;
        }

        // Grant access if the post is publicly viewable.         if ( is_post_publicly_viewable( $post ) ) {
            return true;
        }

        // Otherwise grant access if the post is readable by the logged in user.         if ( current_user_can( 'read_post', $post->ID ) ) {
            return true;
        }
// Determine comment and ping settings.         $allow_comments = comments_open( $page->ID ) ? 1 : 0;
        $allow_pings    = pings_open( $page->ID ) ? 1 : 0;

        // Format page date.         $page_date     = $this->_convert_date( $page->post_date );
        $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date );

        // Pull the categories info together.         $categories = array();
        if ( is_object_in_taxonomy( 'page', 'category' ) ) {
            foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) {
                $categories[] = get_cat_name( $cat_id );
            }
        }

        // Get the author info.         $author = get_userdata( $page->post_author );

        $page_template = get_page_template_slug( $page->ID );
        if ( empty( $page_template ) ) {
            $page_template = 'default';
        }
Home | Imprint | This part of the site doesn't use cookies.