get_taxonomies example


function get_taxonomies_for_attachments( $output = 'names' ) {
    $taxonomies = array();

    foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
        foreach ( $taxonomy->object_type as $object_type ) {
            if ( 'attachment' === $object_type || str_starts_with( $object_type, 'attachment:' ) ) {
                if ( 'names' === $output ) {
                    $taxonomies[] = $taxonomy->name;
                } else {
                    $taxonomies[ $taxonomy->name ] = $taxonomy;
                }
                break;
            }
        }
    }

    

                        }
                    }
                    break;
                case 'tag':
                    _wp_build_title_and_description_for_taxonomy_block_template( 'post_tag', $slug_remaining$template );
                    break;
                case 'category':
                    _wp_build_title_and_description_for_taxonomy_block_template( 'category', $slug_remaining$template );
                    break;
                case 'taxonomy':
                    $taxonomies = get_taxonomies();

                    foreach ( $taxonomies as $taxonomy ) {
                        $taxonomy_length = strlen( $taxonomy ) + 1;

                        // If $slug_remaining starts with $taxonomy followed by a hyphen.                         if ( 0 === strncmp( $slug_remaining$taxonomy . '-', $taxonomy_length ) ) {
                            $slug  = substr( $slug_remaining$taxonomy_lengthstrlen( $slug_remaining ) );
                            $found = _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy$slug$template );

                            if ( $found ) {
                                break;
                            }

function upgrade_350() {
    global $wp_current_db_version$wpdb;

    if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
        update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options().     }

    if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
        $meta_keys = array();
        foreach ( array_merge( get_post_types()get_taxonomies() ) as $name ) {
            if ( str_contains( $name, '-' ) ) {
                $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
            }
        }
        if ( $meta_keys ) {
            $meta_keys = implode( "', '", $meta_keys );
            $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
        }
    }

    if ( $wp_current_db_version < 22422 ) {
        


    require_once ABSPATH . 'wp-admin/includes/nav-menu.php';

    if ( isset( $_POST['item-type'] ) && 'post_type' === $_POST['item-type'] ) {
        $type     = 'posttype';
        $callback = 'wp_nav_menu_item_post_type_meta_box';
        $items    = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
    } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' === $_POST['item-type'] ) {
        $type     = 'taxonomy';
        $callback = 'wp_nav_menu_item_taxonomy_meta_box';
        $items    = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
    }

    if ( ! empty( $_POST['item-object'] ) && isset( $items[ $_POST['item-object'] ] ) ) {
        $menus_meta_box_object = $items[ $_POST['item-object'] ];

        /** This filter is documented in wp-admin/includes/nav-menu.php */
        $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object );

        $box_args = array(
            'id'       => 'add-' . $item->name,
            'title'    => $item->labels->name,
            

    $core_menu_positions = array( 59, 60, 65, 70, 75, 80, 85, 99 );
    while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position$core_menu_positions, true ) ) {
        $ptype_menu_position++;
    }

    $menu[ $ptype_menu_position ] = array( esc_attr( $ptype_obj->labels->menu_name )$ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class$ptype_menu_id$menu_icon );
    $submenu[ $ptype_file ][5]    = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, $ptype_file );
    $submenu[ $ptype_file ][10]   = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, $post_new_file );

    $i = 15;
    foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
        if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array( $ptype(array) $tax->object_type, true ) ) {
            continue;
        }

        $submenu[ $ptype_file ][ $i++ ] = array( esc_attr( $tax->labels->menu_name )$tax->cap->manage_terms, sprintf( $edit_tags_file$tax->name ) );
    }
}
unset( $ptype$ptype_obj$ptype_for_id$ptype_menu_position$menu_icon$i$tax$post_new_file );

$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );

$controller->register_routes();

    // Post statuses.     $controller = new WP_REST_Post_Statuses_Controller();
    $controller->register_routes();

    // Taxonomies.     $controller = new WP_REST_Taxonomies_Controller();
    $controller->register_routes();

    // Terms.     foreach ( get_taxonomies( array( 'show_in_rest' => true ), 'object' ) as $taxonomy ) {
        $controller = $taxonomy->get_rest_controller();

        if ( ! $controller ) {
            continue;
        }

        $controller->register_routes();
    }

    // Users.     $controller = new WP_REST_Users_Controller();
    
$cats  = array();
    $tags  = array();
    $terms = array();
    if ( isset( $term ) && $term ) {
        $cat  = get_term( $term['term_id'], 'category' );
        $cats = array( $cat->term_id => $cat );
        unset( $term$cat );
    } elseif ( 'all' === $args['content'] ) {
        $categories = (array) get_categories( array( 'get' => 'all' ) );
        $tags       = (array) get_tags( array( 'get' => 'all' ) );

        $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
        $custom_terms      = (array) get_terms(
            array(
                'taxonomy' => $custom_taxonomies,
                'get'      => 'all',
            )
        );

        // Put categories in order with no child going before its parent.         while ( $cat = array_shift( $categories ) ) {
            if ( ! $cat->parent || isset( $cats[ $cat->parent ] ) ) {
                $cats[ $cat->term_id ] = $cat;
            }
class WP_REST_Term_Search_Handler extends WP_REST_Search_Handler {

    /** * Constructor. * * @since 5.6.0 */
    public function __construct() {
        $this->type = 'term';

        $this->subtypes = array_values(
            get_taxonomies(
                array(
                    'public'       => true,
                    'show_in_rest' => true,
                ),
                'names'
            )
        );
    }

    /** * Searches the object type content for a given search request. * * @since 5.6.0 * * @param WP_REST_Request $request Full REST request. * @return array { * Associative array containing found IDs and total count for the matching search results. * * @type int[] $ids Found IDs. * @type string|int|WP_Error $total Numeric string containing the number of terms in that * taxonomy, 0 if there are no results, or WP_Error if * the requested taxonomy does not exist. * } */
if ( ! $taxnow ) {
    wp_die( __( 'Invalid taxonomy.' ) );
}

$tax = get_taxonomy( $taxnow );

if ( ! $tax ) {
    wp_die( __( 'Invalid taxonomy.' ) );
}

if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ), true ) ) {
    wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
}

if ( ! current_user_can( $tax->cap->manage_terms ) ) {
    wp_die(
        '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
        '<p>' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '</p>',
        403
    );
}


    public function form( $instance ) {
        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
        $count = isset( $instance['count'] ) ? (bool) $instance['count'] : false;
        ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /> </p> <?php         $taxonomies       = get_taxonomies( array( 'show_tagcloud' => true ), 'object' );
        $current_taxonomy = $this->_get_current_taxonomy( $instance );

        switch ( count( $taxonomies ) ) {

            // No tag cloud supporting taxonomies found, display error message.             case 0:
                ?> <input type="hidden" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>" value="" /> <p> <?php _e( 'The tag cloud will not be displayed since there are no taxonomies that support the tag cloud widget.' ); ?> </p>
return $variation;
}

/** * Register the navigation link block. * * @uses render_block_core_navigation() * @throws WP_Error An WP_Error exception parsing the block definition. */
function register_block_core_navigation_link() {
    $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
    $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );

    // Use two separate arrays as a way to order the variations in the UI.     // Known variations (like Post Link and Page Link) are added to the     // `built_ins` array. Variations for custom post types and taxonomies are     // added to the `variations` array and will always appear after `built-ins.     $built_ins  = array();
    $variations = array();

    if ( $post_types ) {
        foreach ( $post_types as $post_type ) {
            $variation = build_variation_for_navigation_link( $post_type, 'post-type' );
            
$attributes['term'],
        wp_kses_post( $prefix ),
        '<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
        wp_kses_post( $suffix )
    );
}

/** * Registers the `core/post-terms` block on the server. */
function register_block_core_post_terms() {
    $taxonomies = get_taxonomies(
        array(
            'publicly_queryable' => true,
            'show_in_rest'       => true,
        ),
        'objects'
    );

    // Split the available taxonomies to `built_in` and custom ones,     // in order to prioritize the `built_in` taxonomies at the     // search results.     $built_ins         = array();
    
$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
        }

        $user = $this->login( $username$password );
        if ( ! $user ) {
            return $this->error;
        }

        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
        do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args$this );

        $taxonomies = get_taxonomies( $filter, 'objects' );

        // Holds all the taxonomy data.         $struct = array();

        foreach ( $taxonomies as $taxonomy ) {
            // Capability check for post types.             if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
                continue;
            }

            $struct[] = $this->_prepare_taxonomy( $taxonomy$fields );
        }

        }
    }
}

/** * Creates meta boxes for any taxonomy menu item. * * @since 3.0.0 */
function wp_nav_menu_taxonomy_meta_boxes() {
    $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );

    if ( ! $taxonomies ) {
        return;
    }

    foreach ( $taxonomies as $tax ) {
        /** This filter is documented in wp-admin/includes/nav-menu.php */
        $tax = apply_filters( 'nav_menu_meta_box_object', $tax );

        if ( $tax ) {
            $id = $tax->name;
            
$this->object_type = 'term';
    }

    /** * Returns all public, registered taxonomies. * * @since 5.5.0 * * @return WP_Taxonomy[] Array of registered taxonomy objects keyed by their name. */
    public function get_object_subtypes() {
        $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );

        $taxonomies = array_filter( $taxonomies, 'is_taxonomy_viewable' );

        /** * Filters the list of taxonomy object subtypes available within the sitemap. * * @since 5.5.0 * * @param WP_Taxonomy[] $taxonomies Array of registered taxonomy objects keyed by their name. */
        return apply_filters( 'wp_sitemaps_taxonomies', $taxonomies );
    }
Home | Imprint | This part of the site doesn't use cookies.