load_available_items_query example

 else {
            wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
        }

        foreach ( $item_types as $item_type ) {
            if ( empty( $item_type['type'] ) || empty( $item_type['object'] ) ) {
                wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
            }
            $type   = sanitize_key( $item_type['type'] );
            $object = sanitize_key( $item_type['object'] );
            $page   = empty( $item_type['page'] ) ? 0 : absint( $item_type['page'] );
            $items  = $this->load_available_items_query( $type$object$page );
            if ( is_wp_error( $items ) ) {
                wp_send_json_error( $items->get_error_code() );
            }
            $all_items[ $item_type['type'] . ':' . $item_type['object'] ] = $items;
        }

        wp_send_json_success( array( 'items' => $all_items ) );
    }

    /** * Performs the post_type and taxonomy queries for loading available menu items. * * @since 4.3.0 * * @param string $object_type Optional. Accepts any custom object type and has built-in support for * 'post_type' and 'taxonomy'. Default is 'post_type'. * @param string $object_name Optional. Accepts any registered taxonomy or post type name. Default is 'page'. * @param int $page Optional. The page number used to generate the query offset. Default is '0'. * @return array|WP_Error An array of menu items on success, a WP_Error object on failure. */
Home | Imprint | This part of the site doesn't use cookies.