WordPress at Your Fingertips
function is not described

WC_REST_Settings_V2_Controller::get_items() public WC 3.0.0

Get all settings groups items.

{} It's a method of the class: WC_REST_Settings_V2_Controller{}

Hooks from the method

Return

WP_Error|WP_REST_Response.

Usage

$WC_REST_Settings_V2_Controller = new WC_REST_Settings_V2_Controller();
$WC_REST_Settings_V2_Controller->get_items( $request );
$request(WP_REST_Request) (required)
Request data.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Settings_V2_Controller::get_items() WC 5.9.0

public function get_items( $request ) {
	$groups = apply_filters( 'woocommerce_settings_groups', array() );
	if ( empty( $groups ) ) {
		return new WP_Error( 'rest_setting_groups_empty', __( 'No setting groups have been registered.', 'woocommerce' ), array( 'status' => 500 ) );
	}

	$defaults        = $this->group_defaults();
	$filtered_groups = array();
	foreach ( $groups as $group ) {
		$sub_groups = array();
		foreach ( $groups as $_group ) {
			if ( ! empty( $_group['parent_id'] ) && $group['id'] === $_group['parent_id'] ) {
				$sub_groups[] = $_group['id'];
			}
		}
		$group['sub_groups'] = $sub_groups;

		$group = wp_parse_args( $group, $defaults );
		if ( ! is_null( $group['id'] ) && ! is_null( $group['label'] ) ) {
			$group_obj  = $this->filter_group( $group );
			$group_data = $this->prepare_item_for_response( $group_obj, $request );
			$group_data = $this->prepare_response_for_collection( $group_data );

			$filtered_groups[] = $group_data;
		}
	}

	$response = rest_ensure_response( $filtered_groups );
	return $response;
}