get_menu_locations example


    public function prepare_item_for_response( $term$request ) {
        $nav_menu = wp_get_nav_menu_object( $term );
        $response = parent::prepare_item_for_response( $nav_menu$request );

        $fields = $this->get_fields_for_response( $request );
        $data   = $response->get_data();

        if ( rest_is_field_included( 'locations', $fields ) ) {
            $data['locations'] = $this->get_menu_locations( $nav_menu->term_id );
        }

        if ( rest_is_field_included( 'auto_add', $fields ) ) {
            $data['auto_add'] = $this->get_menu_auto_add( $nav_menu->term_id );
        }

        $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
        $data    = $this->add_additional_fields_to_object( $data$request );
        $data    = $this->filter_response_by_context( $data$context );

        $response = rest_ensure_response( $data );

        
Home | Imprint | This part of the site doesn't use cookies.