WP_List_Table::get_views_links()
Generates views links.
Метод класса: WP_List_Table{}
Хуков нет.
Возвращает
Строку[]
. An array of link markup. Keys match the $link_data input array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_views_links( $link_data );
- $link_data(массив)
An array of link data.
По умолчанию: array()
-
url(строка)
The link URL. -
label(строка)
The link label. - current(true|false)
Optional. Whether this is the currently selected view.
-
Список изменений
С версии 6.1.0 | Введена. |
Код WP_List_Table::get_views_links() WP List Table::get views links WP 6.4.3
protected function get_views_links( $link_data = array() ) { if ( ! is_array( $link_data ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %s: The $link_data argument. */ __( 'The %s argument must be an array.' ), '<code>$link_data</code>' ), '6.1.0' ); return array( '' ); } $views_links = array(); foreach ( $link_data as $view => $link ) { if ( empty( $link['url'] ) || ! is_string( $link['url'] ) || '' === trim( $link['url'] ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %1$s: The argument name. %2$s: The view name. */ __( 'The %1$s argument must be a non-empty string for %2$s.' ), '<code>url</code>', '<code>' . esc_html( $view ) . '</code>' ), '6.1.0' ); continue; } if ( empty( $link['label'] ) || ! is_string( $link['label'] ) || '' === trim( $link['label'] ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %1$s: The argument name. %2$s: The view name. */ __( 'The %1$s argument must be a non-empty string for %2$s.' ), '<code>label</code>', '<code>' . esc_html( $view ) . '</code>' ), '6.1.0' ); continue; } $views_links[ $view ] = sprintf( '<a href="%s"%s>%s</a>', esc_url( $link['url'] ), isset( $link['current'] ) && true === $link['current'] ? ' class="current" aria-current="page"' : '', $link['label'] ); } return $views_links; }