From a6b0f07be2ddb9fb3c6f53170b508abb2db076aa Mon Sep 17 00:00:00 2001 From: Eduard Pech <80007889+SimStim@users.noreply.github.com> Date: Thu, 1 May 2025 17:01:48 -0600 Subject: [PATCH] Fix "Display 1 to 0 of 0 URLs" on admin list page (#3910) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update index.php You know how it is - you got something perfect, a bleach-white shirt, and people will notice the tiniest speck. This one fixes the message "Display 1 to 0 of 0 URLs." on a new installation. Best regards from your friendly autist. ;-) * Update index.php Using yourls__ for text string now * Update index.php oops, missing closing parenthesis * Update index.php Message on zero URLs has been made more universal: - If no URLs in database, "No URLs." - If no URLs found while searching with filters, an additional recommendation to be less specific is added. Later it still outputs ", counting 0 clicks." - which I don't consider helpful in this particular case. But let's not lump everything into one big pull request. And the "proper" behaviour is not for me to decide anyway. So I think, my original idea "is done here." * Code feedback in the form of a commit Tab! Apply directly to the SPACES! Also more nuanced logic: only show "counting _n_ clicks" if there are more than 0 items. * check $search with empty Co-authored-by: Léo Colombaro --------- Co-authored-by: dgw Co-authored-by: Léo Colombaro --- admin/index.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/admin/index.php b/admin/index.php index 10ef6c55..da52bca5 100644 --- a/admin/index.php +++ b/admin/index.php @@ -243,9 +243,15 @@ yourls_do_action( 'admin_page_before_content' ); if ( !$is_bookmark ) { ?>

%1$s to %2$s of %3$s URLs' ), $display_on_page, $max_on_page, $total_items ); - if( $total_items_clicks !== false ) - echo ", " . sprintf( yourls_n( 'counting 1 click', 'counting %s clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) ); + if ( $total_items === 0 ) { + printf( yourls__( 'No URLs.' ) ); + if ( ! empty( $search ) ) + printf( ' ' . yourls__( 'Try being less specific' ) ); + } else { + printf( yourls__( 'Display %1$s to %2$s of %3$s URLs' ), $display_on_page, $max_on_page, $total_items ); + if( $total_items_clicks !== false ) + echo ", " . sprintf( yourls_n( 'counting 1 click', 'counting %s clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) ); + } ?>.

%1$s links, %2$s clicks, and counting!' ), yourls_number_format_i18n( $total_urls ), yourls_number_format_i18n( $total_clicks ) ); ?>