Making WordPress.org


Ignore:
Timestamp:
12/15/2020 05:00:17 AM (5 years ago)
Author:
coreymckrill
Message:

WordPress.org Learn: Sync with GitHub

https://github.com/WordPress/learn/compare/dfe3d4faa4fe33dbbc7db72ef69373d2d6c1f623...66c78a0590c1f17bc907e64079a27a84d2aaa49f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/template-parts/component-breadcrumbs.php

    r10169 r10513  
    88 */
    99
    10 /**
    11  * Returns list of workshops based on slug
    12  *
    13  * @return array|bool
    14  */
    15 function get_workshop_from_slug( $slug ) {
    16     $args = array(
    17         'name'        => $slug,
    18         'post_type'   => 'workshop',
    19         'post_status' => 'publish',
    20         'numberposts' => 1,
    21     );
    22 
    23     $workshop = get_posts( $args );
    24 
    25     return isset( $workshop[0] ) ? $workshop[0] : false;
    26 }
    27 
    28 /**
    29  * Returns whether we are viewing a lesson from a workshop
    30  *
    31  * @param string $referer
    32  * @return bool
    33  */
    34 function lesson_came_from_workshop( $referer ) {
    35     return wporg_post_type_is_lesson() && strrpos( $referer, 'workshop' );
    36 }
    37 
    3810$crumbs = array(
    3911    array(
     
    4315);
    4416
    45 $referer = wp_get_referer();
     17// Get information about the post title.
     18$cpt_object = get_post_type_object( get_post_type( get_queried_object() ) );
    4619
    47 // If we came from a workshop, we want to modify the breadrumbs to bring us back to the workshop.
    48 if ( lesson_came_from_workshop( $referer ) ) {
    49     $workshop = get_workshop_from_slug( basename( $referer ) );
    50 
    51     if ( $workshop ) {
    52         array_push( $crumbs, array(
    53             'label' => __( 'Workshops', 'wporg-learn' ),
    54             'url'   => get_post_type_archive_link( 'workshop' ),
    55         ) );
    56 
    57         array_push( $crumbs, array(
    58             'label' => $workshop->post_title,
    59             'url'   => get_post_permalink( $workshop->ID ),
    60         ) );
    61     }
    62 } else {
    63 
    64     // Get information about the post title.
    65     $cpt_object = get_post_type_object( get_post_type( get_queried_object() ) );
    66 
    67     if ( wporg_post_type_is_lesson() ) {
    68         array_push( $crumbs, array(
    69             'label' => ucfirst( $cpt_object->labels->name ),
    70             'url'   => home_url( $cpt_object->has_archive ),
    71         ) );
    72     }
     20if ( 'lesson-plan' === get_post_type() ) {
     21    array_push( $crumbs, array(
     22        'label' => ucfirst( $cpt_object->labels->name ),
     23        'url'   => home_url( $cpt_object->has_archive ),
     24    ) );
    7325}
    7426
Note: See TracChangeset for help on using the changeset viewer.