$args The GraphQL args passed to the resolver. * @param array $unfiltered_args Array of arguments input in the field as part of the GraphQL query. * * @hookGroup connections * @since 2.18.0 */ $restrict_to_locations = $has_explicit_location || apply_filters( 'graphql_menu_item_connection_restrict_to_locations', true, $locations, $args, $this->get_unfiltered_args() ); // Only query for menu items in assigned locations. if ( $restrict_to_locations && isset( $locations ) ) { // unset the location arg // we don't need this passed as a taxonomy parameter to wp_query unset( $query_args['location'] ); $query_args['tax_query'][] = [ 'taxonomy' => 'nav_menu', 'field' => 'term_id', 'terms' => $locations, 'include_children' => false, 'operator' => 'IN', ]; } return $query_args; } /** * {@inheritDoc} */ protected function prepare_args( array $args ): array { if ( ! empty( $args['where'] ) ) { // Ensure all IDs are converted to database IDs. foreach ( $args['where'] as $input_key => $input_value ) { if ( empty( $input_value ) ) { continue; } switch ( $input_key ) { case 'parentId': $args['where'][ $input_key ] = Utils::get_database_id_from_id( $input_value ); break; } } } /** * * Filters the GraphQL args before they are used in get_query_args(). * * @param array $args The GraphQL args passed to the resolver. * @param array $unfiltered_args Array of arguments input in the field as part of the GraphQL query. * * @hookGroup connections * @since 1.11.0 */ return apply_filters( 'graphql_menu_item_connection_args', $args, $this->get_unfiltered_args() ); } }