Changeset 10169 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
- Timestamp:
- 08/13/2020 11:43:14 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
r10147 r10169 12 12 * 13 13 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/ 14 * @throws Error If the build files are not found. 14 15 */ 15 16 function workshop_details_init() { … … 23 24 } 24 25 25 $script_asset = require ( $script_asset_path );26 $script_asset = require $script_asset_path; 26 27 wp_register_script( 27 28 'workshop-details-editor-script', … … 51 52 'editor_style' => 'workshop-details-editor-style', 52 53 'style' => 'workshop-details-style', 53 'render_callback' => __NAMESPACE__ . '\workshop_details_render_callback' 54 'render_callback' => __NAMESPACE__ . '\workshop_details_render_callback', 54 55 ) ); 55 56 } 56 57 58 57 59 58 /** 60 59 * Build the html output based on input fields 61 60 * 62 * @param array 61 * @param array $fields 63 62 * @return string HTML output. 64 63 */ … … 66 65 $output = '<ul class="wp-block-wporg-learn-workshop-details">'; 67 66 68 foreach ( $fields as $key => $value ) {67 foreach ( $fields as $key => $value ) { 69 68 $output .= sprintf( '<li><b>%1$s</b><span>%2$s</span></li>', $key, $value ); 70 69 } … … 83 82 */ 84 83 function workshop_details_render_callback( $attributes, $content ) { 85 $post = get_post();86 $topics = wp_get_post_terms( $post->ID, 'topic', array( 'fields' => 'names' ) );87 $level = wp_get_post_terms( $post->ID, 'level', array( 'fields' => 'names' ) );84 $post = get_post(); 85 $topics = wp_get_post_terms( $post->ID, 'topic', array( 'fields' => 'names' ) ); 86 $level = wp_get_post_terms( $post->ID, 'level', array( 'fields' => 'names' ) ); 88 87 $captions = get_post_meta( $post->ID, 'video_caption_language' ); 89 88 90 89 $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 ) ),90 __( 'Length', 'wporg-learn' ) => get_workshop_duration( $post, 'string' ), 91 __( 'Topic', 'wporg-learn' ) => implode( ', ', array_map( 'esc_html', $topics ) ), 92 __( 'Level', 'wporg-learn' ) => implode( ', ', array_map( 'esc_html', $level ) ), 93 __( 'Language', 'wporg-learn' ) => esc_html( $post->video_language ), 94 __( 'Captions', 'wporg-learn' ) => implode( ', ', array_map( 'esc_html', $captions ) ), 96 95 ); 97 96 98 // Remove empty fields 97 // Remove empty fields. 99 98 $fields_to_output = array_filter( $fields ); 100 99 … … 104 103 /** 105 104 * Enqueue scripts and stylesheets for custom block styles. 105 * 106 * @throws Error If the build files are not found. 106 107 */ 107 108 function enqueue_block_style_assets() { … … 116 117 } 117 118 118 $script_asset = require ( $script_asset_path );119 $script_asset = require $script_asset_path; 119 120 wp_enqueue_script( 120 121 'wporg-learn-block-styles',
Note: See TracChangeset
for help on using the changeset viewer.