Making WordPress.org

Changeset 13705


Ignore:
Timestamp:
05/15/2024 01:45:40 AM (13 months ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@af83214

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

Legend:

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

    r12570 r13705  
    77use function WordPressdotorg\Locales\get_locale_name_from_code;
    88use function WPOrg_Learn\Post_Meta\get_available_post_type_locales;
     9use function WPOrg_Learn\Taxonomy\get_available_taxonomy_terms;
    910
    1011defined( 'WPINC' ) || die();
     
    3435add_action( 'bulk_edit_custom_box', __NAMESPACE__ . '\add_language_bulk_edit_field', 10, 2 );
    3536add_action( 'save_post', __NAMESPACE__ . '\language_bulk_edit_save' );
     37add_filter( 'sensei_course_custom_navigation_tabs', __NAMESPACE__ . '\add_sensei_course_custom_navigation_tabs' );
    3638
    3739/**
     
    224226
    225227/**
    226  * Add filtering controls for the tutorial and lesson plan list tables.
     228 * Add filtering controls for the tutorial, lesson plan, lesson and course list tables.
    227229 *
    228230 * @param string $post_type
     
    232234 */
    233235function add_admin_list_table_filters( $post_type, $which ) {
    234     if ( ( 'wporg_workshop' !== $post_type && 'lesson-plan' !== $post_type ) || 'top' !== $which ) {
    235         return;
    236     }
    237 
    238     $post_status       = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING );
    239     $available_locales = get_available_post_type_locales( 'language', $post_type, $post_status );
    240     $language          = filter_input( INPUT_GET, 'language', FILTER_SANITIZE_STRING );
     236    if (
     237        (
     238            'wporg_workshop' !== $post_type &&
     239            'lesson-plan' !== $post_type &&
     240            'lesson' !== $post_type &&
     241            'course' !== $post_type
     242        )
     243        || 'top' !== $which
     244    ) {
     245        return;
     246    }
     247
     248    $audience    = filter_input( INPUT_GET, 'wporg_audience', FILTER_SANITIZE_STRING );
     249    $language    = filter_input( INPUT_GET, 'language', FILTER_SANITIZE_STRING );
     250    $level       = filter_input( INPUT_GET, 'wporg_experience_level', FILTER_SANITIZE_STRING );
     251    $post_status = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING );
     252
     253    $available_audiences = get_available_taxonomy_terms( 'audience', $post_type, $post_status );
     254    $available_levels    = get_available_taxonomy_terms( 'level', $post_type, $post_status );
     255    $available_locales   = get_available_post_type_locales( 'language', $post_type, $post_status );
    241256
    242257    ?>
    243     <label for="filter-by-language" class="screen-reader-text">
    244         <?php esc_html_e( 'Filter by language', 'wporg-learn' ); ?>
    245     </label>
    246     <select id="filter-by-language" name="language">
    247         <option value=""<?php selected( ! $language ); ?>><?php esc_html_e( 'Any language', 'wporg-learn' ); ?></option>
    248         <?php foreach ( $available_locales as $code => $name ) : ?>
    249             <option value="<?php echo esc_attr( $code ); ?>"<?php selected( $code, $language ); ?>>
    250                 <?php
    251                 printf(
    252                     '%s [%s]',
    253                     esc_html( $name ),
    254                     esc_html( $code )
    255                 );
    256                 ?>
    257             </option>
    258         <?php endforeach; ?>
    259     </select>
     258
     259        <label for="filter-by-language" class="screen-reader-text">
     260            <?php esc_html_e( 'Filter by language', 'wporg-learn' ); ?>
     261        </label>
     262        <select id="filter-by-language" name="language">
     263            <option value=""<?php selected( ! $language ); ?>><?php esc_html_e( 'Any language', 'wporg-learn' ); ?></option>
     264            <?php foreach ( $available_locales as $code => $name ) : ?>
     265                <option value="<?php echo esc_attr( $code ); ?>"<?php selected( $code, $language ); ?>>
     266                    <?php
     267                    printf(
     268                        '%s [%s]',
     269                        esc_html( $name ),
     270                        esc_html( $code )
     271                    );
     272                    ?>
     273                </option>
     274            <?php endforeach; ?>
     275        </select>
     276
     277        <label for="filter-by-audience" class="screen-reader-text">
     278            <?php esc_html_e( 'Filter by audience', 'wporg-learn' ); ?>
     279        </label>
     280        <select id="filter-by-audience" name="wporg_audience">
     281            <option value=""<?php selected( ! $audience ); ?>><?php esc_html_e( 'Any audience', 'wporg-learn' ); ?></option>
     282            <?php foreach ( $available_audiences as $code => $name ) : ?>
     283                <option value="<?php echo esc_attr( $code ); ?>"<?php selected( $code, $audience ); ?>>
     284                    <?php echo esc_html( $name ); ?>
     285                </option>
     286            <?php endforeach; ?>
     287        </select>
     288
     289        <label for="filter-by-level" class="screen-reader-text">
     290            <?php esc_html_e( 'Filter by level', 'wporg-learn' ); ?>
     291        </label>
     292        <select id="filter-by-level" name="wporg_experience_level">
     293            <option value=""<?php selected( ! $level ); ?>><?php esc_html_e( 'Any level', 'wporg-learn' ); ?></option>
     294            <?php foreach ( $available_levels as $code => $name ) : ?>
     295                <option value="<?php echo esc_attr( $code ); ?>"<?php selected( $code, $level ); ?>>
     296                    <?php echo esc_html( $name ); ?>
     297                </option>
     298            <?php endforeach; ?>
     299        </select>
     300
    260301    <?php
    261302}
    262303
    263304/**
    264  * Alter the query to include tutorial and lesson plan list table filters.
     305 * Alter the query to include tutorial, lesson plan, lesson and course list table filters.
    265306 *
    266307 * @param WP_Query $query
     
    279320    }
    280321
    281     if ( 'edit-wporg_workshop' === $current_screen->id || 'edit-lesson-plan' === $current_screen->id ) {
     322    if (
     323        'edit-wporg_workshop' === $current_screen->id ||
     324        'edit-lesson-plan' === $current_screen->id ||
     325        'edit-lesson' === $current_screen->id ||
     326        'edit-course' === $current_screen->id
     327    ) {
     328        $audience = filter_input( INPUT_GET, 'wporg_audience', FILTER_SANITIZE_STRING );
    282329        $language = filter_input( INPUT_GET, 'language', FILTER_SANITIZE_STRING );
    283 
     330        $level    = filter_input( INPUT_GET, 'wporg_experience_level', FILTER_SANITIZE_STRING );
     331
     332        // Tax queries
     333        $tax_query = $query->get( 'tax_query', array() );
     334
     335        if ( $audience ) {
     336            $tax_query[] = array(
     337                'relation' => 'AND',
     338                array(
     339                    'taxonomy' => 'audience',
     340                    'field'    => 'slug',
     341                    'terms'    => $audience,
     342                ),
     343            );
     344        }
     345
     346        if ( $level ) {
     347            $tax_query[] = array(
     348                'relation' => 'AND',
     349                array(
     350                    'taxonomy' => 'level',
     351                    'field'    => 'slug',
     352                    'terms'    => $level,
     353                ),
     354            );
     355        }
     356
     357        if ( ! empty( $tax_query ) ) {
     358            $query->set( 'tax_query', $tax_query );
     359        }
     360
     361        // Meta queries
    284362        if ( $language ) {
    285363            $meta_query = $query->get( 'meta_query', array() );
     
    475553    update_post_meta( $post_id, 'language', $_REQUEST['language'] );
    476554}
     555
     556/**
     557 * Add custom navigation tabs for Sensei courses.
     558 *
     559 * @param array $tabs The existing navigation tabs.
     560 * @return array The modified navigation tabs.
     561 */
     562function add_sensei_course_custom_navigation_tabs( $tabs ) {
     563    $tabs['learning-pathways'] = array(
     564        'label'     => __( 'Learning Pathways', 'wporg-learn' ),
     565        'url'       => admin_url( 'edit-tags.php?taxonomy=learning-pathway&post_type=course' ),
     566        'screen_id' => 'edit-learning-pathway',
     567    );
     568
     569    return $tabs;
     570}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/taxonomy.php

    r12268 r13705  
    3333    register_included_content();
    3434    register_topic();
     35    register_learning_pathway();
    3536}
    3637
     
    6263    );
    6364
    64     $args   = array(
     65    $args = array(
    6566        'labels'            => $labels,
    6667        'hierarchical'      => true,
     
    7778    );
    7879
    79     register_taxonomy( 'audience', array( 'lesson-plan' ), $args );
     80    register_taxonomy( 'audience', array( 'lesson-plan', 'lesson', 'course' ), $args );
    8081}
    8182
     
    241242    );
    242243
    243     $args   = array(
     244    $args = array(
    244245        'labels'            => $labels,
    245246        'hierarchical'      => true,
     
    256257    );
    257258
    258     register_taxonomy( 'level', array( 'lesson-plan' ), $args );
     259    register_taxonomy( 'level', array( 'lesson-plan', 'lesson', 'course' ), $args );
    259260}
    260261
     
    527528
    528529    register_taxonomy( 'wporg_included_content', $post_types, $args );
     530}
     531
     532/**
     533 * Register the Learning Pathway taxonomy.
     534 */
     535function register_learning_pathway() {
     536    $labels = array(
     537        'name'                       => _x( 'Learning Pathways', 'Taxonomy General Name', 'wporg-learn' ),
     538        'singular_name'              => _x( 'Learning Pathway', 'Taxonomy Singular Name', 'wporg-learn' ),
     539        'menu_name'                  => __( 'Learning pathway', 'wporg-learn' ),
     540        'all_items'                  => __( 'All learning pathways', 'wporg-learn' ),
     541        'parent_item'                => __( 'Parent learning pathway', 'wporg-learn' ),
     542        'parent_item_colon'          => __( 'Parent learning pathway:', 'wporg-learn' ),
     543        'new_item_name'              => __( 'New learning pathway Name', 'wporg-learn' ),
     544        'add_new_item'               => __( 'Add New learning pathway', 'wporg-learn' ),
     545        'edit_item'                  => __( 'Edit learning pathway', 'wporg-learn' ),
     546        'update_item'                => __( 'Update learning pathway', 'wporg-learn' ),
     547        'view_item'                  => __( 'View learning pathway', 'wporg-learn' ),
     548        'separate_items_with_commas' => __( 'Separate learning pathways with commas', 'wporg-learn' ),
     549        'add_or_remove_items'        => __( 'Add or remove learning pathways', 'wporg-learn' ),
     550        'choose_from_most_used'      => __( 'Choose from the most used', 'wporg-learn' ),
     551        'popular_items'              => __( 'Popular learning pathways', 'wporg-learn' ),
     552        'search_items'               => __( 'Search learning pathways', 'wporg-learn' ),
     553        'not_found'                  => __( 'No learning pathway found', 'wporg-learn' ),
     554        'no_terms'                   => __( 'No learning pathways', 'wporg-learn' ),
     555        'items_list'                 => __( 'Learning pathways list', 'wporg-learn' ),
     556        'items_list_navigation'      => __( 'Learning pathways list navigation', 'wporg-learn' ),
     557    );
     558
     559    $args = array(
     560        'labels'            => $labels,
     561        'hierarchical'      => false,
     562        'public'            => true,
     563        'query_var'         => 'wporg_learning_pathway', // Prevent collisions with query params in the archive
     564        'show_ui'           => true,
     565        'show_admin_column' => true,
     566        'show_in_nav_menus' => true,
     567        'show_tagcloud'     => false,
     568        'show_in_rest'      => true,
     569        'capabilities'      => array(
     570            'assign_terms' => 'edit_others_posts',
     571        ),
     572    );
     573
     574    register_taxonomy( 'learning-pathway', array( 'course' ), $args );
    529575}
    530576
     
    604650    );
    605651}
     652
     653/**
     654 * Get available taxonomy terms for a post type.
     655 *
     656 * @param string $taxonomy The taxonomy.
     657 * @param string $post_type The post type.
     658 * @param string $post_status The post status.
     659 * @return array The available taxonomy terms.
     660 */
     661function get_available_taxonomy_terms( $taxonomy, $post_type, $post_status = null ) {
     662    $posts = get_posts( array(
     663        'post_status'    => $post_status ?? 'any',
     664        'post_type'      => $post_type,
     665        'posts_per_page' => -1,
     666    ) );
     667
     668    if ( empty( $posts ) ) {
     669        return array();
     670    }
     671
     672    $term_ids = array();
     673    foreach ( $posts as $post ) {
     674        $post_terms = wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
     675
     676        if ( ! is_wp_error( $post_terms ) ) {
     677            $term_ids = array_merge( $term_ids, $post_terms );
     678        }
     679    }
     680
     681    if ( empty( $term_ids ) ) {
     682        return array();
     683    }
     684
     685    $term_ids = array_unique( $term_ids );
     686
     687    $term_objects = get_terms( array(
     688        'taxonomy'   => $taxonomy,
     689        'include'    => $term_ids,
     690        'hide_empty' => false,
     691    ) );
     692
     693    return array_reduce( $term_objects, function( $terms, $term_object ) {
     694        $terms[ $term_object->slug ] = $term_object->name;
     695        return $terms;
     696    }, array());
     697}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php

    r13700 r13705  
    22
    33namespace WordPressdotorg\Theme\Learn_2024;
    4 
    5 /**
    6  * Shortcut to the build directory.
    7  *
    8  * @return string
    9  */
    10 function get_build_path() {
    11     return get_stylesheet_directory() . '/build/';
    12 }
    13 
    14 /**
    15  * Shortcut to the build URL.
    16  *
    17  * @return string
    18  */
    19 function get_build_url() {
    20     return get_stylesheet_directory_uri() . '/build/';
    21 }
    22 
    23 /**
    24  * Shortcut to the includes directory.
    25  *
    26  * @return string
    27  */
    28 function get_includes_path() {
    29     return get_stylesheet_directory() . '/inc/';
    30 }
    31 
    32 /**
    33  * Shortcut to the views directory.
    34  *
    35  * @return string
    36  */
    37 function get_views_path() {
    38     return get_stylesheet_directory() . '/views/';
    39 }
    40 
    41 /**
    42  * Admin.
    43  */
    44 require get_includes_path() . 'admin.php';
    45 
    46 /**
    47  * Capabilities.
    48  */
    49 require get_includes_path() . 'capabilities.php';
    50 
    51 /**
    52  * Taxonomies.
    53  */
    54 require get_includes_path() . 'taxonomy.php';
    554
    565/**
     
    11261    wp_enqueue_style(
    11362        'wporg-learn-2024-style',
    114         get_build_url() . 'style/style-index.css',
     63        get_stylesheet_directory_uri() . '/build/style/style-index.css',
    11564        array( 'wporg-parent-2021-style', 'wporg-global-fonts' ),
    116         filemtime( get_build_path() . 'style/style-index.css' )
     65        filemtime( get_stylesheet_directory() . '/build/style/style-index.css' )
    11766    );
    11867
     
    14493        'learn' => array(
    14594            array(
     95                'label' => __( 'Learning Pathways', 'wporg-learn' ),
     96                'url'   => '/learning-pathways/',
     97            ),
     98            array(
    14699                'label' => __( 'User', 'wporg-learn' ),
    147                 'url'   => '/learning-pathways/user/',
     100                'url'   => '/learning-pathway/user/',
    148101            ),
    149102            array(
    150103                'label' => __( 'Designer', 'wporg-learn' ),
    151                 'url'   => '/learning-pathways/designer/',
     104                'url'   => '/learning-pathway/designer/',
    152105            ),
    153106            array(
    154107                'label' => __( 'Contributor', 'wporg-learn' ),
    155                 'url'   => '/learning-pathways/contributor/',
     108                'url'   => '/learning-pathway/contributor/',
    156109            ),
    157110            array(
    158111                'label' => __( 'Developer', 'wporg-learn' ),
    159                 'url'   => '/learning-pathways/developer/',
     112                'url'   => '/learning-pathway/developer/',
     113            ),
     114            array(
     115                'label' => __( 'Courses', 'wporg-learn' ),
     116                'url'   => '/courses/',
     117            ),
     118            array(
     119                'label' => __( 'Lessons', 'wporg-learn' ),
     120                'url'   => '/lessons/',
     121            ),
     122            array(
     123                'label' => __( 'Online Workshops', 'wporg-learn' ),
     124                'url'   => '/online-workshops/',
    160125            ),
    161126        ),
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/patterns/front-page-content.php

    r13656 r13705  
    1010<!-- wp:group {"align":"wide","layout":{"type":"default"}} -->
    1111<div class="wp-block-group alignwide">
    12    
     12
    1313    <!-- wp:heading {"style":{"typography":{"fontStyle":"normal","fontWeight":"600"}},"className":"is-style-short-text","fontSize":"heading-5"} -->
    1414    <h2 class="wp-block-heading is-style-short-text has-heading-5-font-size" style="font-style:normal;font-weight:600"><?php esc_html_e( 'Get Started', 'wporg-learn' ); ?></h2>
    1515    <!-- /wp:heading -->
    1616
     17    <!-- wp:pattern {"slug":"wporg-learn-2024/learning-pathways-terms"} /-->
     18
    1719</div>
    1820<!-- /wp:group -->
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/style.css

    r13701 r13705  
    55 * Author URI: http://wordpress.org/
    66 * Description: A theme for learn.wordpress.org, built in 2024.
    7  * Version: 1.0.0-d28b25b
     7 * Version: 1.0.0-a6877da
    88 * License: GNU General Public License v2 or later
    99 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/templates/archive-course.html

    r13699 r13705  
    99        <!-- wp:query-title {"type":"archive","showPrefix":false} /-->
    1010
    11         <!-- wp:query {"queryId":10,"query":{"perPage":6,"pages":0,"offset":0,"postType":"course","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"metadata":{"categories":["posts"],"patternName":"core/query-grid-posts","name":"Grid"}} -->
     11        <!-- wp:query {"queryId":10,"query":{"perPage":6,"pages":0,"offset":0,"postType":"course","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":true},"metadata":{"categories":["posts"],"patternName":"core/query-grid-posts","name":"Grid"}} -->
    1212        <div class="wp-block-query">
    1313
     
    2727
    2828            <!-- /wp:post-template -->
     29
     30            <!-- wp:pattern {"slug":"wporg-learn-2024/query-no-results-course"} /-->
     31
    2932        </div>
    3033        <!-- /wp:query -->
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/templates/single-lesson.html

    r13699 r13705  
    1 <!-- wp:pattern {"slug":"wporg-learn-2024/sensei-lesson"} /-->
     1<!-- Original source: https://github.com/Automattic/sensei/blob/af62fb1115daf2063bc56331a7d8b1b3ea805866/themes/sensei-course-theme/templates/default/lesson.php /-->
     2
     3<!-- wp:pattern {"slug":"wporg-learn-2024/sensei-lesson-header"} /-->
     4
     5<!-- wp:sensei-lms/ui {"elementClass":"sensei-course-theme__columns","className":"sensei-version\u002d\u002d4-16-2"} -->
     6<div class="wp-block-sensei-lms-ui sensei-course-theme__columns sensei-version--4-16-2">
     7
     8    <!-- wp:sensei-lms/ui {"elementClass":"sensei-course-theme__sidebar","className":"","style"={"spacing":{"margin":{"top":"var:preset|spacing|50"},"padding":{"top":"var:preset|spacing|20","right":"var:preset|spacing|30","bottom":"var:preset|spacing|50","left":"var:preset|spacing|edge-space"}}}} -->
     9    <div class="wp-block-sensei-lms-ui sensei-course-theme__frame sensei-course-theme__sidebar" style="margin-top:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--edge-space)">
     10
     11        <!-- wp:sensei-lms/course-navigation /-->
     12
     13    </div>
     14    <!-- /wp:sensei-lms/ui -->
     15
     16    <!-- wp:sensei-lms/ui {"elementClass":"sensei-course-theme__main-content","lock":{"move":false,"remove":false},"style"={"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|edge-space"}}}} -->
     17    <div class="wp-block-sensei-lms-ui sensei-course-theme__main-content" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--edge-space)">
     18
     19        <!-- wp:sensei-lms/course-theme-lesson-module /-->
     20
     21        <!-- wp:post-title {"level":1,"fontSize":"heading-1"} /-->
     22
     23        <!-- wp:sensei-lms/course-theme-notices /-->
     24
     25        <!-- wp:post-content {"layout":{"inherit":true}} /-->
     26
     27        <!-- wp:group {"style":{"spacing":{"margin":{"top":"40px"}}},"layout":{"type":"constrained"}} -->
     28        <div class="wp-block-group" style="margin-top:40px">
     29            <!-- wp:sensei-lms/page-actions {"style":{"spacing":{"blockGap":"43px"}}} /-->
     30
     31            <!-- wp:group {"style":{"spacing":{"margin":{"top":"20px"}}},"className":"sensei-lesson-footer","layout":{"type":"flex","flexWrap":"nowrap"}} -->
     32            <div class="wp-block-group sensei-lesson-footer" style="margin-top:20px">
     33
     34                <!-- wp:pattern {"slug":"wporg-learn-2024/sensei-lesson-actions"} /-->
     35
     36            </div>
     37            <!-- /wp:group -->
     38        </div>
     39        <!-- /wp:group -->
     40    </div>
     41    <!-- /wp:sensei-lms/ui -->
     42</div>
     43<!-- /wp:sensei-lms/ui -->
Note: See TracChangeset for help on using the changeset viewer.