Code Duplication    Length = 11-13 lines in 5 locations

includes/api/class-wc-rest-product-attributes-controller.php 1 location

@@ 499-511 (lines=13) @@
496
	 * @param object $attribute Attribute object.
497
	 * @return array Links for the given attribute.
498
	 */
499
	protected function prepare_links( $attribute ) {
500
		$base  = '/' . $this->namespace . '/' . $this->rest_base;
501
		$links = array(
502
			'self' => array(
503
				'href' => rest_url( trailingslashit( $base ) . $attribute->attribute_id ),
504
			),
505
			'collection' => array(
506
				'href' => rest_url( $base ),
507
			),
508
		);
509
510
		return $links;
511
	}
512
513
	/**
514
	 * Get the Attribute's schema, conforming to JSON Schema.

includes/api/class-wc-rest-shipping-zone-locations-controller.php 1 location

@@ 125-137 (lines=13) @@
122
	 * @param int $zone_id Given Shipping Zone ID.
123
	 * @return array Links for the given Shipping Zone Location.
124
	 */
125
	protected function prepare_links( $zone_id ) {
126
		$base  = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id;
127
		$links = array(
128
			'collection' => array(
129
				'href' => rest_url( $base . '/locations' ),
130
			),
131
			'describes'  => array(
132
				'href' => rest_url( $base ),
133
			),
134
		);
135
136
		return $links;
137
	}
138
139
	/**
140
	 * Get the Shipping Zone Locations schema, conforming to JSON Schema

includes/api/class-wc-rest-settings-controller.php 1 location

@@ 90-100 (lines=11) @@
87
	 * @param string $group_id Group ID.
88
	 * @return array Links for the given group.
89
	 */
90
	protected function prepare_links( $group_id ) {
91
		$base  = '/' . $this->namespace . '/' . $this->rest_base;
92
		$links = array(
93
			'item' => array(
94
				'href'       => rest_url( trailingslashit( $base ) . $group_id ),
95
				'embeddable' => true,
96
			),
97
		);
98
99
		return $links;
100
	}
101
102
	/**
103
	 * Prepare a report sales object for serialization.

includes/api/class-wc-rest-system-status-tools-controller.php 1 location

@@ 315-325 (lines=11) @@
312
	 * @param string $id
313
	 * @return array
314
	 */
315
	protected function prepare_links( $id ) {
316
		$base  = '/' . $this->namespace . '/' . $this->rest_base;
317
		$links = array(
318
			'item' => array(
319
				'href'       => rest_url( trailingslashit( $base ) . $id ),
320
				'embeddable' => true,
321
			),
322
		);
323
324
		return $links;
325
	}
326
327
	/**
328
	 * Get any query params needed.

includes/api/class-wc-rest-settings-options-controller.php 1 location

@@ 289-301 (lines=13) @@
286
	 * @param string $group_id Group ID.
287
	 * @return array Links for the given setting.
288
	 */
289
	protected function prepare_links( $setting_id, $group_id ) {
290
		$base  = '/' . $this->namespace . '/' . $this->rest_base . '/' . $group_id;
291
		$links = array(
292
			'self' => array(
293
				'href' => rest_url( trailingslashit( $base ) . $setting_id ),
294
			),
295
			'collection' => array(
296
				'href' => rest_url( $base ),
297
			),
298
		);
299
300
		return $links;
301
	}
302
303
	/**
304
	 * Makes sure the current user has access to READ the settings APIs.