ACF_Rest_Embed_Links::prepare_links
Add links to internal property for subsequent use in [ACF_Rest_Embed_Links::load_item_links()](/plugin/acf/function/ACF_Rest_Embed_Links::load_item_links).
Method of the class: ACF_Rest_Embed_Links{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ACF_Rest_Embed_Links = new ACF_Rest_Embed_Links(); $ACF_Rest_Embed_Links->prepare_links( $post_id, $field );
- $post_id(required)
- .
- $field(array) (required)
- .
ACF_Rest_Embed_Links::prepare_links() ACF Rest Embed Links::prepare links code ACF 6.0.4
public function prepare_links( $post_id, array $field ) {
$links = acf_get_field_rest_links( $post_id, $field );
if ( ! $links ) {
return;
}
foreach ( $links as $link ) {
// If required array keys are not provided, skip.
if ( empty( $link['rel'] ) or empty( $link['href'] ) ) {
continue;
}
// Use the 'rel' and 'href' to for a key. The key only prevents against the same object
// appearing more than once within the same 'rel' property.
$this->links[ $link['rel'] . ':' . $link['href'] ] = $link;
}
}