Making WordPress.org


Ignore:
Timestamp:
06/18/2024 11:34:53 PM (2 years ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@6df8983

File:
1 edited

Legend:

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

    r13810 r13833  
    77// Block files
    88require_once __DIR__ . '/src/learning-pathway-cards/index.php';
     9require_once __DIR__ . '/src/learning-pathway-header/index.php';
    910require_once __DIR__ . '/src/search-results-context/index.php';
    1011require_once __DIR__ . '/src/upcoming-online-workshops/index.php';
     
    2930        return $args;
    3031} );
     32add_action( 'pre_get_posts', __NAMESPACE__ . '\modify_learning_pathways_query' );
    3133
    3234/**
     
    278280        return $breadcrumbs;
    279281}
     282
     283/**
     284 * Modify the main query.
     285 * If the 'all' level filter is set in the query, remove it to return all posts.
     286 *
     287 * @param WP_Query $query The main query.
     288 * @return WP_Query
     289 */
     290function modify_learning_pathways_query( $query ) {
     291        if ( is_admin() || ! $query->is_main_query() ) {
     292                return;
     293        }
     294
     295        $level = $query->get( 'wporg_lesson_level' );
     296
     297        if ( 'all' === $level ) {
     298                $query->set( 'wporg_lesson_level', '' );
     299        }
     300
     301        return $query;
     302}
Note: See TracChangeset for help on using the changeset viewer.