Title: WP_REST_Global_Styles_Controller::prepare_links
Published: February 3, 2022
Last modified: August 20, 2026

---

# WP_REST_Global_Styles_Controller::prepare_links( integer $id ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#wp--skip-link--target)

Prepares links for the request.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#parameters)󠁿

 `$id`integerrequired

ID.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#return)󠁿

 array Links for the given post.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#source)󠁿

    ```php
    protected function prepare_links( $id ) {
    	$base = sprintf( '%s/%s', $this->namespace, $this->rest_base );

    	$links = array(
    		'self'  => array(
    			'href' => rest_url( trailingslashit( $base ) . $id ),
    		),
    		'about' => array(
    			'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
    		),
    	);

    	if ( post_type_supports( $this->post_type, 'revisions' ) ) {
    		$revisions                = wp_get_latest_revision_id_and_total_count( $id );
    		$revisions_count          = ! is_wp_error( $revisions ) ? $revisions['count'] : 0;
    		$revisions_base           = sprintf( '/%s/%d/revisions', $base, $id );
    		$links['version-history'] = array(
    			'href'  => rest_url( $revisions_base ),
    			'count' => $revisions_count,
    		);
    	}

    	return $links;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php#L392)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php#L392-L415)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_latest_revision_id_and_total_count()](https://developer.wordpress.org/reference/functions/wp_get_latest_revision_id_and_total_count/)`wp-includes/revision.php` |

Returns the latest revision ID and count of revisions for a post.

  | 
| [post_type_supports()](https://developer.wordpress.org/reference/functions/post_type_supports/)`wp-includes/post.php` |

Checks a post type’s support for a given feature.

  | 
| [rest_url()](https://developer.wordpress.org/reference/functions/rest_url/)`wp-includes/rest-api.php` |

Retrieves the URL to a REST endpoint.

  | 
| [trailingslashit()](https://developer.wordpress.org/reference/functions/trailingslashit/)`wp-includes/formatting.php` |

Appends a trailing slash.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#)

| Used by | Description | 
| [WP_REST_Global_Styles_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php` |

Prepare a global styles config output for response.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_controller/prepare_links/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Adds revisions count and rest URL href to version-history. | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_global_styles_controller%2Fprepare_links%2F)
before being able to contribute a note or feedback.