From 1b92568d33cf8938da7d7281e655a7df95655d01 Mon Sep 17 00:00:00 2001 From: Adam Wood <1017872+adamwoodnz@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:39:46 +1200 Subject: [PATCH] Add tutorial template with wordpress.tv video embed (#2565) * Add tutorial template with wordpress.tv video embed * Add sidebar meta info --- .../patterns/single-tutorial-embed.php | 25 +++++++++ .../src/sensei-meta-list/index.php | 37 +++++++++++++ .../templates/single-wporg_workshop.html | 53 +++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 wp-content/themes/pub/wporg-learn-2024/patterns/single-tutorial-embed.php create mode 100644 wp-content/themes/pub/wporg-learn-2024/templates/single-wporg_workshop.html diff --git a/wp-content/themes/pub/wporg-learn-2024/patterns/single-tutorial-embed.php b/wp-content/themes/pub/wporg-learn-2024/patterns/single-tutorial-embed.php new file mode 100644 index 000000000..b02e2bc68 --- /dev/null +++ b/wp-content/themes/pub/wporg-learn-2024/patterns/single-tutorial-embed.php @@ -0,0 +1,25 @@ +video_url ) ) { + return; +} + +?> + + + + diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-meta-list/index.php b/wp-content/themes/pub/wporg-learn-2024/src/sensei-meta-list/index.php index f6d6ae2fe..ab3411103 100644 --- a/wp-content/themes/pub/wporg-learn-2024/src/sensei-meta-list/index.php +++ b/wp-content/themes/pub/wporg-learn-2024/src/sensei-meta-list/index.php @@ -10,6 +10,8 @@ use Sensei_Utils; use Sensei_Reports_Overview_Service_Courses; +use function WPOrg_Learn\Post_Meta\{get_workshop_duration}; +use function WordPressdotorg\Locales\get_locale_name_from_code; add_action( 'init', __NAMESPACE__ . '\init' ); @@ -90,6 +92,41 @@ function render( $attributes, $content, $block ) { 'key' => 'last-updated', ), ); + } else if ( 'wporg_workshop' === $block->context['postType'] ) { + $workshop = get_post( $block->context['postId'] ); + + if ( ! $workshop ) { + return ''; + } + + $meta_fields = array( + array( + 'label' => __( 'Length', 'wporg-learn' ), + 'value' => get_workshop_duration( $workshop, 'string' ), + 'key' => 'length', + ), + array( + 'label' => __( 'Language', 'wporg-learn' ), + 'value' => esc_html( get_locale_name_from_code( $workshop->language, 'native' ) ), + 'key' => 'language', + ), + ); + + $captions = get_post_meta( $block->context['postId'], 'video_caption_language' ); + $subtitles = array_map( + function( $caption_lang ) { + return esc_html( get_locale_name_from_code( $caption_lang, 'native' ) ); + }, + $captions + ); + + if ( ! empty( $captions ) ) { + $meta_fields[] = array( + 'label' => __( 'Subtitles', 'wporg-learn' ), + 'value' => implode( ', ', $subtitles ), + 'key' => 'subtitles', + ); + } } foreach ( $meta_fields as $field ) { diff --git a/wp-content/themes/pub/wporg-learn-2024/templates/single-wporg_workshop.html b/wp-content/themes/pub/wporg-learn-2024/templates/single-wporg_workshop.html new file mode 100644 index 000000000..4dff02adb --- /dev/null +++ b/wp-content/themes/pub/wporg-learn-2024/templates/single-wporg_workshop.html @@ -0,0 +1,53 @@ + + + +
+ + + +