Automattic\WooCommerce\Internal\Admin\Settings
PaymentsRestController::add_suggestion_links
Add links to suggestions list items.
Method of the class: PaymentsRestController{}
No Hooks.
Returns
Array. The suggestions list with added links.
Usage
// private - for code of main (parent) class only $result = $this->add_suggestion_links( $suggestions ): array;
- $suggestions(array) (required)
- The suggestions list.
PaymentsRestController::add_suggestion_links() PaymentsRestController::add suggestion links code WC 10.8.1
private function add_suggestion_links( array $suggestions ): array {
foreach ( $suggestions as $key => $suggestion ) {
if ( empty( $suggestion['id'] ) ) {
continue;
}
if ( empty( $suggestion['_links'] ) ) {
$suggestions[ $key ]['_links'] = array();
}
$suggestions[ $key ]['_links']['attach'] = array(
'href' => rest_url( sprintf( '/%s/%s/suggestion/%s/attach', $this->route_namespace, $this->rest_base, $suggestion['id'] ) ),
);
$suggestions[ $key ]['_links']['hide'] = array(
'href' => rest_url( sprintf( '/%s/%s/suggestion/%s/hide', $this->route_namespace, $this->rest_base, $suggestion['id'] ) ),
);
}
return $suggestions;
}