Making WordPress.org


Ignore:
Timestamp:
11/15/2023 11:32:17 PM (2 years ago)
Author:
coffee2code
Message:

Photo Directory: Show a message adjacent to pagination navigation on the last archive pagination page if user is not logged in.

Unless user is logged in, w.org enforces up to 50 pages of pagination, which can lead visitors to think that's all the photos we have. This message recommends the visitor log in to see more photos.

See #6214.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-photos/functions.php

    r12385 r12969  
    358358}
    359359add_filter( 'body_class', __NAMESPACE__ . '\body_class_for_taxonomy_roots' );
     360
     361/**
     362 * Outputs a message adjacent to the navigation markup when viewing the last page
     363 * in the pagination.
     364 *
     365 * Only affects logged-out users on w.org since pagination is limited to 49 pages.
     366 *
     367 * @param string $markup  The default markup.
     368 * @return string
     369 */
     370function show_logged_out_max_pagination_message( $markup ) {
     371    // Only concerned if...
     372    if (
     373        // ...the w.org page limiter is present
     374        defined( '\WPORG_Page_Limiter::MAX_PAGES' )
     375    &&
     376        // ...user is not logged in
     377        ! is_user_logged_in()
     378    &&
     379        // ...on max pagination page
     380        get_query_var( 'paged' ) === \WPORG_Page_Limiter::MAX_PAGES
     381    ) {
     382        $markup .= '<div class="navigation-wporg-max-page">'
     383            . sprintf(
     384                __( '<a href="%s">Log in</a> to see the full archive of photos!', 'wporg-photos' ),
     385                // Escape '%' characters since this function's return value will be passed through `sprintf()`.
     386                str_replace( '%', '%%', esc_url( wp_login_url() ) )
     387            )
     388            . '</div>';
     389    }
     390
     391    return $markup;
     392}
     393add_filter( 'navigation_markup_template', __NAMESPACE__ . '\show_logged_out_max_pagination_message' );
Note: See TracChangeset for help on using the changeset viewer.