Making WordPress.org

Changeset 13981


Ignore:
Timestamp:
08/20/2024 12:45:15 AM (2 years ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@d055511

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php

    r13902 r13981  
    4343                array(
    4444                        'description'       => __( 'Whether the lesson is featured.', 'wporg-learn' ),
    45                         'type'              => 'string',
    46                         'single'            => true,
    47                         'sanitize_callback' => 'sanitize_text_field',
    48                         'show_in_rest'      => true,
    49                         'auth_callback'     => function( $allowed, $meta_key, $post_id ) {
    50                                 return current_user_can( 'edit_post', $post_id );
    51                         },
    52                 ),
    53         );
    54 
    55         register_post_meta(
    56                 'lesson',
    57                 '_lesson_archive_excluded',
    58                 array(
    59                         'description'       => __( 'Whether the lesson should be excluded from archive views.', 'wporg-learn' ),
    6045                        'type'              => 'string',
    6146                        'single'            => true,
    … …  
    484469        $locales           = get_locales_with_english_names();
    485470        $captions          = get_post_meta( $post->ID, 'video_caption_language' ) ?: array();
    486         $all_lessons       = get_posts( array(
    487                 'post_type'      => 'lesson',
    488                 'post_status'    => 'publish',
    489                 'posts_per_page' => 999,
    490                 'orderby'        => 'title',
    491                 'order'          => 'asc',
    492         ) );
    493471
    494472        require get_views_path() . 'metabox-workshop-details.php';
    … …  
    576554                }
    577555        }
    578 
    579         $lesson_id = filter_input( INPUT_POST, 'linked-lesson-id', FILTER_SANITIZE_NUMBER_INT );
    580         update_post_meta( $post_id, 'linked_lesson_id', $lesson_id );
    581556
    582557        $presenter_wporg_username = filter_input( INPUT_POST, 'presenter-wporg-username' );
    … …  
    650625        enqueue_expiration_date_assets();
    651626        enqueue_language_meta_assets();
    652         enqueue_lesson_archive_excluded_meta_assets();
    653627        enqueue_lesson_featured_meta_assets();
    654628        enqueue_duration_meta_assets();
    … …  
    709683
    710684/**
    711  * Enqueue scripts for the archive excluded lesson meta block.
    712  */
    713 function enqueue_lesson_archive_excluded_meta_assets() {
    714         global $typenow;
    715 
    716         if ( 'lesson' === $typenow ) {
    717                 $script_asset_path = get_build_path() . 'lesson-archive-excluded-meta.asset.php';
    718                 if ( ! file_exists( $script_asset_path ) ) {
    719                         wp_die( 'You need to run `yarn start` or `yarn build` to build the required assets.' );
    720                 }
    721 
    722                 $script_asset = require( $script_asset_path );
    723                 wp_enqueue_script(
    724                         'wporg-learn-lesson-archive-excluded-meta',
    725                         get_build_url() . 'lesson-archive-excluded-meta.js',
    726                         $script_asset['dependencies'],
    727                         $script_asset['version'],
    728                         true
    729                 );
    730 
    731                 wp_set_script_translations( 'wporg-learn-lesson-archive-excluded-meta', 'wporg-learn' );
    732         }
    733 }
    734 
    735 /**
    736685 * Enqueue scripts for the featured lesson meta block.
    737686 */
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/views/metabox-workshop-details.php

    r12276 r13981  
    88/** @var array $locales */
    99/** @var array $captions */
    10 /** @var array $all_lessons */
    11 /** @var array $selected_lessons */
    1210?>
    1311
    … …  
    7775</p>
    7876
    79 <p>
    80         <label for="workshop-linked-lesson-id"><?php esc_html_e( 'Linked Quiz', 'wporg_learn' ); ?></label>
    81         <select id="workshop-linked-lesson-id" name="linked-lesson-id" style="width: 100%;">
    82                 <option value="" disabled hidden <?php selected( ! $post->linked_lesson_id ); ?>></option>
    83                 <?php foreach ( $all_lessons as $lesson ) : ?>
    84                         <option value="<?php echo esc_attr( $lesson->ID ); ?>" <?php selected( $lesson->ID, $post->linked_lesson_id ); ?>>
    85                                 <?php echo esc_html( get_the_title( $lesson->ID ) ); ?>
    86                         </option>
    87                 <?php endforeach; ?>
    88         </select>
    89 </p>
    90 
    9177<script>
    9278        ( function( $ ) {
    93                 $( '#workshop-video-language, #workshop-video-caption-language, #workshop-linked-lesson-id' ).select2();
     79                $( '#workshop-video-language, #workshop-video-caption-language' ).select2();
    9480        } )( jQuery );
    9581</script>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/webpack.config.js

    r13963 r13981  
    88        'duration-meta': './js/duration-meta/index.js',
    99        'expiration-date': './js/expiration-date/index.js',
    10         'lesson-archive-excluded-meta': './js/lesson-archive-excluded-meta/index.js',
    1110        'lesson-count': './js/lesson-count/src/index.js',
    1211        'lesson-featured-meta': './js/lesson-featured-meta/index.js',
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/inc/query.php

    r13973 r13981  
    77
    88add_action( 'pre_get_posts', __NAMESPACE__ . '\add_language_to_archive_queries' );
    9 add_action( 'pre_get_posts', __NAMESPACE__ . '\add_excluded_to_lesson_archive_query' );
     9add_action( 'pre_get_posts', __NAMESPACE__ . '\filter_hidden_lessons_from_archive_and_search' );
    1010add_action( 'pre_get_posts', __NAMESPACE__ . '\filter_search_queries_by_post_type' );
    1111add_filter( 'request', __NAMESPACE__ . '\handle_all_level_query' );
    … …  
    4747
    4848/**
    49  * Modify the query by adding meta query for excluding the lesson from the archive if set.
     49 * Modify lessons archive and search queries by adding a taxonomy query for filtering out hidden lessons.
    5050 *
    5151 * @param WP_Query $query The query object.
    5252 */
    53 function add_excluded_to_lesson_archive_query( $query ) {
     53function filter_hidden_lessons_from_archive_and_search( $query ) {
    5454        // Ensure this code runs only for the main query on lesson archive pages and search results.
    5555        if ( ! is_admin() && $query->is_main_query() && ( $query->is_archive( 'lesson' ) || $query->is_search() ) ) {
    56                 $meta_query = $query->get( 'meta_query', array() );
    5756                $tax_query = $query->get( 'tax_query', array() );
    58 
    59                 $exclude_lessons_by_post_meta = array(
    60                         'relation' => 'OR',
    61                         array(
    62                                 'key'     => '_lesson_archive_excluded',
    63                                 'compare' => 'NOT EXISTS',
    64                         ),
    65                         array(
    66                                 'key'     => '_lesson_archive_excluded',
    67                                 'value'   => 'excluded',
    68                                 'compare' => '!=',
    69                         ),
    70                 );
    71 
    72                 // If there's an existing meta query, wrap both in an AND relation
    73                 if ( ! empty( $meta_query ) ) {
    74                         $meta_query = array(
    75                                 'relation' => 'AND',
    76                                 $meta_query,
    77                                 $exclude_lessons_by_post_meta,
    78                         );
    79                 } else {
    80                         $meta_query = $exclude_lessons_by_post_meta;
    81                 }
    8257
    8358                $exclude_lessons_by_taxonomy = array(
    … …  
    9671                }
    9772
    98                 $query->set( 'meta_query', $meta_query );
    9973                $query->set( 'tax_query', $tax_query );
    10074        }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/style.css

    r13973 r13981  
    55 * Author URI: http://wordpress.org/
    66 * Description: A theme for learn.wordpress.org, built in 2024.
    7  * Version: 1.0.0-fdd9e55
     7 * Version: 1.0.0-3128a62
    88 * License: GNU General Public License v2 or later
    99 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.