Changeset 10461 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
- Timestamp:
- 11/23/2020 09:41:51 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
r10376 r10461 4 4 5 5 use Error; 6 use Sensei_Lesson; 6 7 use function WordPressdotorg\Locales\get_locale_name_from_code; 7 use function WPOrg_Learn\{ get_build_path, get_build_url};8 use function WPOrg_Learn\{get_build_path, get_build_url, get_views_path}; 8 9 use function WPOrg_Learn\Form\render_workshop_application_form; 9 10 use function WPOrg_Learn\Post_Meta\get_workshop_duration; … … 50 51 51 52 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(59 53 'workshop-details-style', 60 54 get_build_url() . 'style-workshop-details.css', … … 65 59 register_block_type( 'wporg-learn/workshop-details', array( 66 60 'editor_script' => 'workshop-details-editor-script', 67 'editor_style' => 'workshop-details-editor-style',68 61 'style' => 'workshop-details-style', 69 62 'render_callback' => __NAMESPACE__ . '\workshop_details_render_callback', 70 63 ) ); 71 }72 73 /**74 * Build the html output based on input fields75 *76 * @param array $fields77 * @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 $value87 );88 }89 90 $output .= '</ul>';91 92 return $output;93 64 } 94 65 … … 123 94 124 95 // Remove empty fields. 125 $fields _to_output= array_filter( $fields );96 $fields = array_filter( $fields ); 126 97 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(); 128 111 } 129 112
Note: See TracChangeset
for help on using the changeset viewer.