Making WordPress.org

Changeset 14012


Ignore:
Timestamp:
09/01/2024 11:46:40 PM (8 months ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@daa4713

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

Legend:

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

    r13999 r14012  
    1414add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_assets' );
    1515add_filter( 'wporg_locale_switcher_options', __NAMESPACE__ . '\locale_switcher_options' );
    16 add_filter( 'wp_headers', __NAMESPACE__ . '\disable_caching' );
    1716add_filter( 'posts_clauses', __NAMESPACE__ . '\wporg_archive_query_prioritize_locale', 10, 2 );
    1817
     
    130129
    131130    return $options;
    132 }
    133 
    134 /**
    135  * Disable nginx caching when locale switching is available.
    136  *
    137  * The nginx cache currently doesn't vary on the value of the cookie that gets set when a locale other than en_US is
    138  * chosen. This causes problems when, e.g. a user visits the page with their browser language set to de_DE, which gets
    139  * cached by nginx, and then another user visits with their browser set to en_US, and they are served the page in
    140  * German regardless of they choose something else in the locale switcher.
    141  *
    142  * nginx does respect the Cache-Control header, though, so this offers a quick, hacky fix to the problem by turning
    143  * off caching altogether.
    144  *
    145  * This should be removed if a way is found to vary the cache by the cookie value, e.g. to include the cookie value
    146  * in the cache key as suggested in the discussion of this systems request:
    147  * https://make.wordpress.org/systems/2021/03/26/vary-nginx-cache-by-wporg_locale-cookie-value/
    148  *
    149  * @param array $headers
    150  *
    151  * @return array
    152  */
    153 function disable_caching( $headers ) {
    154     if ( class_exists( '\WordPressdotorg\LocaleDetection\Detector' ) ) {
    155         $headers['Cache-Control'] = 'no-cache';
    156     }
    157 
    158     return $headers;
    159131}
    160132
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php

    r13981 r14012  
    2323add_action( 'admin_footer', __NAMESPACE__ . '\render_locales_list' );
    2424add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_editor_assets' );
     25add_action( 'wp_insert_post', __NAMESPACE__ . '\set_default_lesson_preview', 10, 3 );
    2526
    2627/**
     
    5253        ),
    5354    );
     55}
     56
     57/**
     58 * Set public preview to be enabled on lessons created within a course by default.
     59 * This post meta is registered by Sensei with no default value, so we set it here on lesson creation.
     60 *
     61 * @param int     $post_ID Post ID.
     62 * @param WP_Post $post    Post object.
     63 * @param bool    $update  Whether this is an existing post being updated.
     64 */
     65function set_default_lesson_preview( $post_ID, $post, $update ) {
     66    // Only run for new lessons.
     67    if ( $update || 'lesson' !== $post->post_type ) {
     68        return;
     69    }
     70
     71    // Check if the lesson belongs to a course.
     72    $course_id = get_post_meta( $post_ID, '_lesson_course', true );
     73
     74    if ( empty( $course_id ) ) {
     75        return;
     76    }
     77
     78    $existing_value = get_post_meta( $post_ID, '_lesson_preview', true );
     79
     80    if ( '' === $existing_value ) {
     81        update_post_meta( $post_ID, '_lesson_preview', 'preview' );
     82    }
    5483}
    5584
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/style.css

    r14010 r14012  
    55 * Author URI: http://wordpress.org/
    66 * Description: A theme for learn.wordpress.org, built in 2024.
    7  * Version: 1.0.0-77218e6
     7 * Version: 1.0.0-b8bb677
    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.