Fix "Display 1 to 0 of 0 URLs" on admin list page (#3910)

* 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 <LeoColomb@users.noreply.github.com>

---------

Co-authored-by: dgw <dgw@technobabbl.es>
Co-authored-by: Léo Colombaro <LeoColomb@users.noreply.github.com>
This commit is contained in:
Eduard Pech 2025-05-01 17:01:48 -06:00 committed by GitHub
parent c6a1b102ac
commit a6b0f07be2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -243,9 +243,15 @@ yourls_do_action( 'admin_page_before_content' );
if ( !$is_bookmark ) { ?>
<p><?php echo $search_sentence; ?></p>
<p><?php
if ( $total_items === 0 ) {
printf( yourls__( 'No URLs.' ) );
if ( ! empty( $search ) )
printf( ' ' . yourls__( 'Try being less specific' ) );
} else {
printf( yourls__( 'Display <strong>%1$s</strong> to <strong class="increment">%2$s</strong> of <strong class="increment">%3$s</strong> URLs' ), $display_on_page, $max_on_page, $total_items );
if( $total_items_clicks !== false )
echo ", " . sprintf( yourls_n( 'counting <strong>1</strong> click', 'counting <strong>%s</strong> clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) );
}
?>.</p>
<?php } ?>
<p id="overall_tracking"><?php printf( yourls__( 'Overall, tracking <strong class="increment">%1$s</strong> links, <strong>%2$s</strong> clicks, and counting!' ), yourls_number_format_i18n( $total_urls ), yourls_number_format_i18n( $total_clicks ) ); ?></p>