Coding Standards: Move `WP_List_Table::get_views_links()` to a more appropriate place.

This moves the newly introduced `::get_views_links()` method to a more predictable location, next to the the `::get_views()` and `::views()` methods.

Follow-up to [54215].

See #42066.
Built from https://develop.svn.wordpress.org/trunk@54223


git-svn-id: http://core.svn.wordpress.org/trunk@53782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-09-19 22:24:09 +00:00
parent 6c48acbbd3
commit 7d0a24c29e
2 changed files with 74 additions and 73 deletions

View File

@ -376,6 +376,79 @@ class WP_List_Table {
<?php
}
/**
* Generates views links.
*
* @since 6.1.0
*
* @param array $link_data {
* An array of link data.
*
* @type string $url The link URL.
* @type string $label The link label.
* @type bool $current Optional. Whether this is the currently selected view.
* }
* @return array An array of link markup. Keys match the `$link_data` input array.
*/
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;
}
/**
* Gets the list of views available on this table.
*
@ -1513,78 +1586,6 @@ class WP_List_Table {
die( wp_json_encode( $response ) );
}
/**
* Generates views links.
*
* @since 6.1.0
*
* @param array $link_data {
* An array of link data.
*
* @type string $url The link URL.
* @type string $label The link label.
* @type bool $current Optional. Whether this is the currently selected view.
* }
* @return array An array of link markup. Keys match the $link_data input array.
*/
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;
}
/**
* Sends required variables to JavaScript land.
*

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-54222';
$wp_version = '6.1-alpha-54223';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.