Changeset 14012
- Timestamp:
- 09/01/2024 11:46:40 PM (8 months ago)
- 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 14 14 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_assets' ); 15 15 add_filter( 'wporg_locale_switcher_options', __NAMESPACE__ . '\locale_switcher_options' ); 16 add_filter( 'wp_headers', __NAMESPACE__ . '\disable_caching' );17 16 add_filter( 'posts_clauses', __NAMESPACE__ . '\wporg_archive_query_prioritize_locale', 10, 2 ); 18 17 … … 130 129 131 130 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 is138 * chosen. This causes problems when, e.g. a user visits the page with their browser language set to de_DE, which gets139 * cached by nginx, and then another user visits with their browser set to en_US, and they are served the page in140 * 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 turning143 * 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 value146 * 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 $headers150 *151 * @return array152 */153 function disable_caching( $headers ) {154 if ( class_exists( '\WordPressdotorg\LocaleDetection\Detector' ) ) {155 $headers['Cache-Control'] = 'no-cache';156 }157 158 return $headers;159 131 } 160 132 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
r13981 r14012 23 23 add_action( 'admin_footer', __NAMESPACE__ . '\render_locales_list' ); 24 24 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_editor_assets' ); 25 add_action( 'wp_insert_post', __NAMESPACE__ . '\set_default_lesson_preview', 10, 3 ); 25 26 26 27 /** … … 52 53 ), 53 54 ); 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 */ 65 function 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 } 54 83 } 55 84 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/style.css
r14010 r14012 5 5 * Author URI: http://wordpress.org/ 6 6 * Description: A theme for learn.wordpress.org, built in 2024. 7 * Version: 1.0.0- 77218e67 * Version: 1.0.0-b8bb677 8 8 * License: GNU General Public License v2 or later 9 9 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.