Making WordPress.org

Changeset 14037


Ignore:
Timestamp:
09/10/2024 05:30:16 AM (4 weeks ago)
Author:
renyot
Message:

Learn: Sync with git WordPress/learn@1b11312

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

Legend:

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

    r14012 r14037  
    2929 */
    3030function register() {
     31    register_course_meta();
    3132    register_lesson_meta();
    3233    register_lesson_plan_meta();
    3334    register_workshop_meta();
    3435    register_misc_meta();
     36}
     37
     38/**
     39 * Register post meta keys for courses.
     40 */
     41function register_course_meta() {
     42    register_post_meta(
     43        'course',
     44        '_course_completion_success_message',
     45        array(
     46            'description'       => __( 'The message displayed to users upon successful course completion.', 'wporg-learn' ),
     47            'type'              => 'string',
     48            'single'            => true,
     49            'sanitize_callback' => 'sanitize_text_field',
     50            'show_in_rest'      => true,
     51            'auth_callback'     => function( $allowed, $meta_key, $post_id ) {
     52                return current_user_can( 'edit_post', $post_id );
     53            },
     54        )
     55    );
     56
     57    register_post_meta(
     58        'course',
     59        '_course_completion_survey_link',
     60        array(
     61            'description'       => __( 'The survey link to be shown alongside the completion message.', 'wporg-learn' ),
     62            'type'              => 'string',
     63            'single'            => true,
     64            'default'           => '',
     65            'sanitize_callback' => 'esc_url_raw',
     66            'show_in_rest'      => true,
     67            'auth_callback'     => function( $allowed, $meta_key, $post_id ) {
     68                return current_user_can( 'edit_post', $post_id );
     69            },
     70        )
     71    );
    3572}
    3673
     
    656693    enqueue_lesson_featured_meta_assets();
    657694    enqueue_duration_meta_assets();
     695    enqueue_course_completion_meta_assets();
    658696}
    659697
     
    761799    }
    762800}
     801
     802/**
     803 * Enqueue scripts for the course completion meta block.
     804 */
     805function enqueue_course_completion_meta_assets() {
     806    global $typenow;
     807
     808    if ( 'course' === $typenow ) {
     809        $script_asset_path = get_build_path() . 'course-completion-meta.asset.php';
     810        if ( ! file_exists( $script_asset_path ) ) {
     811            wp_die( 'You need to run `yarn start` or `yarn build` to build the required assets.' );
     812        }
     813
     814        $script_asset = require( $script_asset_path );
     815        wp_enqueue_script(
     816            'wporg-learn-course-completion-meta',
     817            get_build_url() . 'course-completion-meta.js',
     818            $script_asset['dependencies'],
     819            $script_asset['version'],
     820            true
     821        );
     822
     823        wp_set_script_translations( 'wporg-learn-course-completion-meta', 'wporg-learn' );
     824    }
     825}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/webpack.config.js

    r13981 r14037  
    55 */
    66config.entry = {
     7    'course-completion-meta': './js/course-completion-meta/index.js',
    78    'course-status': './js/course-status/src/index.js',
    89    'duration-meta': './js/duration-meta/index.js',
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/patterns/page-course-complete-content.php

    r13878 r14037  
    55 * Inserter: no
    66 */
     7
     8$course_id = isset( $_GET['course_id'] ) ? intval( $_GET['course_id'] ) : get_the_ID();
     9$success_message = get_post_meta( $course_id, '_course_completion_success_message', true ) ?: __( 'Congratulations on completing this course!', 'wporg-learn' );
     10$survey_link = get_post_meta( $course_id, '_course_completion_survey_link', true ) ?: 'https://docs.google.com/forms/d/e/1FAIpQLSf0QMflUedxjta0u5qS4_pl-9aY06BDBXgRn2PoZA1gRvD9jw/viewform';
    711
    812?>
     
    1620<!-- wp:heading {"style":{"spacing":{"margin":{"top":"40px","bottom":"10px"}}},"fontSize":"large","fontFamily":"inter"} -->
    1721<h2 class="wp-block-heading has-inter-font-family has-large-font-size" style="margin-top:40px;margin-bottom:10px">
    18     <?php esc_html_e( 'Congratulations on completing this course!', 'wporg-learn' ); ?>
     22    <?php echo esc_html( $success_message ); ?>
    1923</h2>
    2024<!-- /wp:heading -->
     
    3034    <!-- wp:button {"style":{"spacing":{"padding":{"left":"32px","right":"32px","top":"17px","bottom":"17px"}}}} -->
    3135    <div class="wp-block-button">
    32         <a class="wp-block-button__link wp-element-button" href="https://docs.google.com/forms/d/e/1FAIpQLSf0QMflUedxjta0u5qS4_pl-9aY06BDBXgRn2PoZA1gRvD9jw/viewform" style="padding-top:17px;padding-right:32px;padding-bottom:17px;padding-left:32px">
     36        <a class="wp-block-button__link wp-element-button" href="<?php echo esc_url( $survey_link ); ?>" style="padding-top:17px;padding-right:32px;padding-bottom:17px;padding-left:32px">
    3337            <?php esc_html_e( 'Complete the survey', 'wporg-learn' ); ?>
    3438        </a>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/style.css

    r14032 r14037  
    55 * Author URI: http://wordpress.org/
    66 * Description: A theme for learn.wordpress.org, built in 2024.
    7  * Version: 1.0.0-6616fa5
     7 * Version: 1.0.0-bcce0c1
    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.