Changeset 10147 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
- Timestamp:
- 08/12/2020 01:23:13 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
r10142 r10147 55 55 } 56 56 57 58 59 /** 60 * Build the html output based on input fields 61 * 62 * @param array $fields 63 * @return string HTML output. 64 */ 65 function 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 57 77 /** 58 78 * Render the block content (html) on the frontend of the site. … … 60 80 * @param array $attributes 61 81 * @param string $content 62 * @return string HTML output used by the calendar JS.82 * @return string HTML output used by the block 63 83 */ 64 84 function workshop_details_render_callback( $attributes, $content ) { … … 68 88 $captions = get_post_meta( $post->ID, 'video_caption_language' ); 69 89 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 ); 84 102 } 85 103
Note: See TracChangeset
for help on using the changeset viewer.