Making WordPress.org


Ignore:
Timestamp:
11/23/2020 09:41:51 PM (4 years ago)
Author:
coreymckrill
Message:

WordPress.org Learn: Sync with GitHub

https://github.com/WordPress/learn/compare/2c9bbc5fc4eefb1f1a367f7bb8afcd3da6ef32b0...886286a12b9802be8d34715149f55ddf67832432

File:
1 edited

Legend:

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

    r10376 r10461  
    44
    55use Error;
     6use Sensei_Lesson;
    67use function WordPressdotorg\Locales\get_locale_name_from_code;
    7 use function WPOrg_Learn\{ get_build_path, get_build_url };
     8use function WPOrg_Learn\{get_build_path, get_build_url, get_views_path};
    89use function WPOrg_Learn\Form\render_workshop_application_form;
    910use function WPOrg_Learn\Post_Meta\get_workshop_duration;
     
    5051
    5152    wp_register_style(
    52         'workshop-details-editor-style',
    53         get_build_url() . 'workshop-details.css',
    54         array(),
    55         filemtime( get_build_path() . 'workshop-details.css' )
    56     );
    57 
    58     wp_register_style(
    5953        'workshop-details-style',
    6054        get_build_url() . 'style-workshop-details.css',
     
    6559    register_block_type( 'wporg-learn/workshop-details', array(
    6660        'editor_script'   => 'workshop-details-editor-script',
    67         'editor_style'    => 'workshop-details-editor-style',
    6861        'style'           => 'workshop-details-style',
    6962        'render_callback' => __NAMESPACE__ . '\workshop_details_render_callback',
    7063    ) );
    71 }
    72 
    73 /**
    74  * Build the html output based on input fields
    75  *
    76  * @param array $fields
    77  * @return string HTML output.
    78  */
    79 function get_workshop_details_html_output( $fields ) {
    80     $output = '<ul class="wp-block-wporg-learn-workshop-details">';
    81 
    82     foreach ( $fields as $key => $value ) {
    83         $output .= sprintf(
    84             '<li><b>%1$s</b><span>%2$s</span></li>',
    85             $key,
    86             $value
    87         );
    88     }
    89 
    90     $output .= '</ul>';
    91 
    92     return $output;
    9364}
    9465
     
    12394
    12495    // Remove empty fields.
    125     $fields_to_output = array_filter( $fields );
     96    $fields = array_filter( $fields );
    12697
    127     return get_workshop_details_html_output( $fields_to_output );
     98    $lesson_id = get_post_meta( $post->ID, 'linked_lesson_id', true );
     99    $quiz_url = '';
     100    if ( $lesson_id && Sensei_Lesson::lesson_quiz_has_questions( $lesson_id ) ) {
     101        $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
     102        if ( $quiz_id ) {
     103            $quiz_url = get_permalink( $quiz_id );
     104        }
     105    }
     106
     107    ob_start();
     108    require get_views_path() . 'block-workshop-details.php';
     109
     110    return ob_get_clean();
    128111}
    129112
Note: See TracChangeset for help on using the changeset viewer.