taxonomy_exists example

if ( isset( $_GET['page'] ) ) {
    $plugin_page = wp_unslash( $_GET['page'] );
    $plugin_page = plugin_basename( $plugin_page );
}

if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
    $typenow = $_REQUEST['post_type'];
} else {
    $typenow = '';
}

if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) {
    $taxnow = $_REQUEST['taxonomy'];
} else {
    $taxnow = '';
}

if ( WP_NETWORK_ADMIN ) {
    require ABSPATH . 'wp-admin/network/menu.php';
} elseif ( WP_USER_ADMIN ) {
    require ABSPATH . 'wp-admin/user/menu.php';
} else {
    require ABSPATH . 'wp-admin/menu.php';
}
 elseif ( 'json' === $response_format ) {
                    echo wp_json_encode(
                        array(
                            'ID'         => $object_id,
                            'post_title' => get_the_title( $object_id ),
                            'post_type'  => get_post_type( $object_id ),
                        )
                    );
                    echo "\n";
                }
            }
        } elseif ( taxonomy_exists( $object_type ) ) {
            if ( isset( $request['ID'] ) ) {
                $object_id = (int) $request['ID'];

                if ( 'markup' === $response_format ) {
                    echo walk_nav_menu_tree(
                        array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id$object_type ) ) ),
                        0,
                        (object) $args
                    );
                } elseif ( 'json' === $response_format ) {
                    $post_obj = get_term( $object_id$object_type );
                    

    private function clean_query( &$query ) {
        if ( empty( $query['taxonomy'] ) ) {
            if ( 'term_taxonomy_id' !== $query['field'] ) {
                $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
                return;
            }

            // So long as there are shared terms, 'include_children' requires that a taxonomy is set.             $query['include_children'] = false;
        } elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) {
            $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
            return;
        }

        if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
            $query['terms'] = array_unique( (array) $query['terms'] );
        } else {
            $query['terms'] = wp_parse_id_list( $query['terms'] );
        }

        if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
            
if ( str_ends_with( $id, '-network' ) ) {
                $id       = substr( $id, 0, -8 );
                $in_admin = 'network';
            } elseif ( str_ends_with( $id, '-user' ) ) {
                $id       = substr( $id, 0, -5 );
                $in_admin = 'user';
            }

            $id = sanitize_key( $id );
            if ( 'edit-comments' !== $id && 'edit-tags' !== $id && str_starts_with( $id, 'edit-' ) ) {
                $maybe = substr( $id, 5 );
                if ( taxonomy_exists( $maybe ) ) {
                    $id       = 'edit-tags';
                    $taxonomy = $maybe;
                } elseif ( post_type_exists( $maybe ) ) {
                    $id        = 'edit';
                    $post_type = $maybe;
                }
            }

            if ( ! $in_admin ) {
                $in_admin = 'site';
            }
        }
$password       = $args[2];
        $content_struct = $args[3];

        $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.newTerm', $args$this );

        if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
            return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
        }

        $taxonomy = get_taxonomy( $content_struct['taxonomy'] );

        if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
            return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
        }

        $taxonomy = (array) $taxonomy;

        


        if ( ! isset( $this->value['title'] ) ) {
            $this->value['title'] = '';
        }

        if ( ! isset( $this->value['_invalid'] ) ) {
            $this->value['_invalid'] = false;
            $is_known_invalid        = (
                ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) )
                ||
                ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) )
            );
            if ( $is_known_invalid ) {
                $this->value['_invalid'] = true;
            }
        }

        // Remove remaining properties available on a setup nav_menu_item post object which aren't relevant to the setting value.         $irrelevant_properties = array(
            'ID',
            'comment_count',
            'comment_status',
            
$exclude_tree = array_merge( $exclude_treewp_parse_id_list( $parsed_args['exclude'] ) );
        }

        $parsed_args['exclude_tree'] = $exclude_tree;
        $parsed_args['exclude']      = '';
    }

    if ( ! isset( $parsed_args['class'] ) ) {
        $parsed_args['class'] = ( 'category' === $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
    }

    if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
        return false;
    }

    $show_option_all  = $parsed_args['show_option_all'];
    $show_option_none = $parsed_args['show_option_none'];

    $categories = get_categories( $parsed_args );

    $output = '';

    if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
        

function wp_get_nav_menu_items( $menu$args = array() ) {
    $menu = wp_get_nav_menu_object( $menu );

    if ( ! $menu ) {
        return false;
    }

    if ( ! taxonomy_exists( 'nav_menu' ) ) {
        return false;
    }

    $defaults = array(
        'order'                  => 'ASC',
        'orderby'                => 'menu_order',
        'post_type'              => 'nav_menu_item',
        'post_status'            => 'publish',
        'output'                 => ARRAY_A,
        'output_key'             => 'menu_order',
        'nopaging'               => true,
        

function get_taxonomy( $taxonomy ) {
    global $wp_taxonomies;

    if ( ! taxonomy_exists( $taxonomy ) ) {
        return false;
    }

    return $wp_taxonomies[ $taxonomy ];
}

/** * Determines whether the taxonomy name exists. * * Formerly is_taxonomy(), introduced in 2.3.0. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 3.0.0 * * @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies. * * @param string $taxonomy Name of taxonomy object. * @return bool Whether the taxonomy exists. */

        );

        $action    = $this->screen->action;
        $post_type = $this->screen->post_type;
        $taxonomy  = $this->screen->taxonomy;

        if ( empty( $taxonomy ) ) {
            $taxonomy = 'post_tag';
        }

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

        $tax = get_taxonomy( $taxonomy );

        // @todo Still needed? Maybe just the show_ui part.         if ( empty( $post_type ) || ! in_array( $post_typeget_post_types( array( 'show_ui' => true ) ), true ) ) {
            $post_type = 'post';
        }

    }

    

function is_taxonomy( $taxonomy ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' );
    return taxonomy_exists( $taxonomy );
}

/** * Check if Term exists. * * @since 2.3.0 * @deprecated 3.0.0 Use term_exists() * @see term_exists() * * @param int|string $term The term to check * @param string $taxonomy The taxonomy name to use * @param int $parent ID of parent term under which to confine the exists search. * @return mixed Get the term ID or term object, if exists. */

                }

                // If only one match was found, it's the one we want.             } elseif ( 1 === count( $terms ) ) {
                $_term = reset( $terms );

                // Otherwise, the term must be shared between taxonomies.             } else {
                // If the term is shared only with invalid taxonomies, return the one valid term.                 foreach ( $terms as $t ) {
                    if ( ! taxonomy_exists( $t->taxonomy ) ) {
                        continue;
                    }

                    // Only hit if we've already identified a term in a valid taxonomy.                     if ( $_term ) {
                        return new WP_Error( 'ambiguous_term_id', __( 'Term ID is shared between multiple taxonomies' )$term_id );
                    }

                    $_term = $t;
                }
            }

            


    /** * Retrieves the taxonomy for the current Tag cloud widget instance. * * @since 4.4.0 * * @param array $instance Current settings. * @return string Name of the current taxonomy if set, otherwise 'post_tag'. */
    public function _get_current_taxonomy( $instance ) {
        if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {
            return $instance['taxonomy'];
        }

        return 'post_tag';
    }
}

function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
    global $wpdb;

    $post = get_post();

    if ( ! $post || ! taxonomy_exists( $taxonomy ) ) {
        return null;
    }

    $current_post_date = $post->post_date;

    $join     = '';
    $where    = '';
    $adjacent = $previous ? 'previous' : 'next';

    if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
        // Back-compat, $excluded_terms used to be $excluded_categories with IDs separated by " and ".
Home | Imprint | This part of the site doesn't use cookies.