Making WordPress.org


Ignore:
Timestamp:
08/12/2020 01:23:13 AM (6 years ago)
Author:
coreymckrill
Message:

WP.org Learn: Sync with GitHub

https://github.com/WordPress/learn/compare/826f579465d0a1689ef260161158b585197d6112...fbb4955f0cff52e01350d2ff38e636e1c9c17645

File:
1 edited

Legend:

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

    r10142 r10147  
    5555}
    5656
     57
     58
     59/**
     60 * Build the html output based on input fields
     61 *
     62 * @param array   $fields
     63 * @return string HTML output.
     64 */
     65function get_workshop_details_html_output( $fields ) {
     66    $output = '<ul class="wp-block-wporg-learn-workshop-details">';
     67
     68    foreach( $fields as $key => $value ) {
     69        $output .= sprintf( '<li><b>%1$s</b><span>%2$s</span></li>', $key, $value );
     70    }
     71
     72    $output .= '</ul>';
     73
     74    return $output;
     75}
     76
    5777/**
    5878 * Render the block content (html) on the frontend of the site.
     
    6080 * @param array  $attributes
    6181 * @param string $content
    62  * @return string HTML output used by the calendar JS.
     82 * @return string HTML output used by the block
    6383 */
    6484function workshop_details_render_callback( $attributes, $content ) {
     
    6888    $captions = get_post_meta( $post->ID, 'video_caption_language' );
    6989
    70     return sprintf(
    71         '<ul class="wp-block-wporg-learn-workshop-details">
    72             <li><b>Length</b><span>%1$s</span></li>
    73             <li><b>Topic</b><span>%2$s</span></li>
    74             <li><b>Level</b><span>%3$s</span></li>
    75             <li><b>Language</b><span>%4$s</span></li>
    76             <li><b>Captions</b><span>%5$s</span></li>
    77         </ul>',
    78         get_workshop_duration( $post, 'string' ),
    79         implode( ', ', array_map( 'esc_html', $topics ) ),
    80         implode( ', ', array_map( 'esc_html', $level ) ),
    81         esc_html( $post->video_language ),
    82         implode( ', ', array_map( 'esc_html', $captions ) )
    83     );
     90    $fields = array(
     91        __( 'Length' , 'wporg-learn') => get_workshop_duration( $post, 'string' ),
     92        __( 'Topic' , 'wporg-learn') => implode( ', ', array_map( 'esc_html', $topics ) ),
     93        __( 'Level' , 'wporg-learn') => implode( ', ', array_map( 'esc_html', $level ) ),
     94        __( 'Language' , 'wporg-learn') => esc_html( $post->video_language ),
     95        __( 'Captions' , 'wporg-learn') => implode( ', ', array_map( 'esc_html', $captions ) ),
     96    );
     97
     98    // Remove empty fields
     99    $fields_to_output = array_filter( $fields );
     100
     101    return get_workshop_details_html_output( $fields_to_output );
    84102}
    85103
Note: See TracChangeset for help on using the changeset viewer.