Changeset 11352
- Timestamp:
- 12/02/2021 12:59:04 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
r11294 r11352 72 72 */ 73 73 function workshop_details_render_callback( $attributes, $content ) { 74 $post = get_post(); 75 $topics = wp_get_post_terms( $post->ID, 'topic', array( 'fields' => 'names' ) ); 76 $level = wp_get_post_terms( $post->ID, 'level', array( 'fields' => 'names' ) ); 77 $captions = get_post_meta( $post->ID, 'video_caption_language' ); 74 $post = get_post(); 75 $topic_ids = wp_get_post_terms( $post->ID, 'topic', array( 'fields' => 'ids' ) ); 76 $level = wp_get_post_terms( $post->ID, 'level', array( 'fields' => 'names' ) ); 77 $captions = get_post_meta( $post->ID, 'video_caption_language' ); 78 79 $topic_names = array(); 80 foreach ( $topic_ids as $id ) { 81 $topic_names[] = get_term( $id )->name; 82 } 78 83 79 84 $fields = array( 80 __( 'Length', 'wporg-learn' ) => get_workshop_duration( $post, 'string' ), 81 __( 'Topic', 'wporg-learn' ) => implode( ', ', array_map( 'esc_html', $topics ) ), 82 __( 'Level', 'wporg-learn' ) => implode( ', ', array_map( 'esc_html', $level ) ), 83 __( 'Language', 'wporg-learn' ) => esc_html( get_locale_name_from_code( $post->video_language, 'native' ) ), 84 __( 'Subtitles', 'wporg-learn' ) => implode( 85 ', ', 86 array_map( 85 'length' => array( 86 'label' => __( 'Length', 'wporg-learn' ), 87 'param' => array(), 88 'value' => array( get_workshop_duration( $post, 'string' ) ), 89 ), 90 'topic' => array( 91 'label' => __( 'Topic', 'wporg-learn' ), 92 'param' => $topic_ids, 93 'value' => $topic_names, 94 ), 95 'level' => array( 96 'label' => __( 'Level', 'wporg-learn' ), 97 'param' => array(), 98 'value' => $level, 99 ), 100 'language' => array( 101 'label' => __( 'Language', 'wporg-learn' ), 102 'param' => array( $post->video_language ), 103 'value' => array( esc_html( get_locale_name_from_code( $post->video_language, 'native' ) ) ), 104 ), 105 'captions' => array( 106 'label' => __( 'Subtitles', 'wporg-learn' ), 107 'param' => $captions, 108 'value' => array_map( 87 109 function( $caption_lang ) { 88 110 return esc_html( get_locale_name_from_code( $caption_lang, 'native' ) ); 89 111 }, 90 112 $captions 91 ) 92 ), 93 ); 94 95 // Remove empty fields. 96 $fields = array_filter( $fields ); 113 ), 114 ), 115 ); 116 117 // Remove fields with empty values. 118 $fields = array_filter( $fields, function( $data ) { 119 return $data['value']; 120 } ); 97 121 98 122 $lesson_id = get_post_meta( $post->ID, 'linked_lesson_id', true ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/views/block-workshop-details.php
r11324 r11352 18 18 <?php if ( ! empty( $fields ) ) : ?> 19 19 <ul class="workshop-details-list"> 20 <?php foreach ( $fields as $key => $ value) : ?>20 <?php foreach ( $fields as $key => $field ) : ?> 21 21 <li> 22 <b><?php echo esc_html( $key ); ?></b> 23 <span><?php echo esc_html( $value ); ?></span> 22 <b><?php echo esc_html( $field['label'] ); ?></b> 23 <span> 24 <?php 25 $i = 0; 26 foreach ( $field['value'] as $field_key => $value ) { 27 $url = ''; 28 if ( ! empty( $field['param'] ) ) { 29 $url = trailingslashit( site_url() ) . 'workshops/?' . $key . '=' . $field['param'][ $field_key ]; 30 } 31 32 if ( 0 < $i ) { 33 echo ', '; 34 } 35 36 if ( $url ) { 37 echo '<a href="' . esc_url( $url ) . '">' . esc_html( $value ) . '</a>'; 38 } else { 39 echo esc_html( $value ); 40 } 41 $i++; 42 } 43 ?> 44 </span> 24 45 </li> 25 46 <?php endforeach; ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php
r11336 r11352 166 166 167 167 /** 168 * Get the values associated to the page/post 168 * Get the values associated to the page/post formatted as a string 169 169 * 170 170 * @param string $post_id Id of the post. … … 180 180 181 181 /** 182 * Get the values associated to the page/post formatted as an array 183 * 184 * @param string $post_id Id of the post. 185 * @param string $tax_slug The slug for the custom taxonomy. 186 * 187 * @return array 188 */ 189 function wporg_learn_get_taxonomy_terms_array( $post_id, $tax_slug ) { 190 $term_ids = wp_get_post_terms( $post_id, $tax_slug, array( 'fields' => 'ids' ) ); 191 192 $terms = array(); 193 foreach ( $term_ids as $id ) { 194 $terms[ $id ] = get_term( $id )->name; 195 } 196 197 return $terms; 198 } 199 200 /** 201 * Get the values associated to the page/post according to the context 202 * 203 * @param int $post_id ID of the post. 204 * @param string $tax_slug The slug for the custom taxonomy. 205 * @param string $context The context for display. 206 * 207 * @return array|string 208 */ 209 function wporg_learn_get_taxonomy_terms( $post_id, $tax_slug, $context ) { 210 switch ( $context ) { 211 case 'archive': 212 return wporg_learn_get_taxonomy_terms_string( $post_id, $tax_slug ); 213 break; 214 case 'single': 215 return wporg_learn_get_taxonomy_terms_array( $post_id, $tax_slug ); 216 break; 217 } 218 } 219 220 /** 182 221 * Returns the taxonomies associated to a lesson or workshop 183 222 * … … 186 225 * @return array 187 226 */ 188 function wporg_learn_get_lesson_plan_taxonomy_data( $post_id ) {227 function wporg_learn_get_lesson_plan_taxonomy_data( $post_id, $context ) { 189 228 return array( 190 229 array( 191 230 'icon' => 'clock', 231 'slug' => 'duration', 192 232 'label' => wporg_label_with_colon( get_taxonomy_labels( get_taxonomy( 'duration' ) )->singular_name ), 193 'value' => wporg_learn_get_taxonomy_terms _string( $post_id, 'duration'),233 'value' => wporg_learn_get_taxonomy_terms( $post_id, 'duration', $context ), 194 234 ), 195 235 array( 196 236 'icon' => 'admin-users', 237 'slug' => 'audience', 197 238 'label' => wporg_label_with_colon( get_taxonomy_labels( get_taxonomy( 'audience' ) )->singular_name ), 198 'value' => wporg_learn_get_taxonomy_terms _string( $post_id, 'audience'),239 'value' => wporg_learn_get_taxonomy_terms( $post_id, 'audience', $context ), 199 240 ), 200 241 array( 201 242 'icon' => 'dashboard', 243 'slug' => 'level', 202 244 'label' => wporg_label_with_colon( get_taxonomy_labels( get_taxonomy( 'level' ) )->singular_name ), 203 'value' => wporg_learn_get_taxonomy_terms _string( $post_id, 'level'),245 'value' => wporg_learn_get_taxonomy_terms( $post_id, 'level', $context ), 204 246 ), 205 247 array( 206 248 'icon' => 'welcome-learn-more', 249 'slug' => 'type', 207 250 'label' => wporg_label_with_colon( get_taxonomy_labels( get_taxonomy( 'instruction_type' ) )->singular_name ), 208 'value' => wporg_learn_get_taxonomy_terms _string( $post_id, 'instruction_type'),251 'value' => wporg_learn_get_taxonomy_terms( $post_id, 'instruction_type', $context ), 209 252 ), 210 253 ); … … 301 344 if ( $query->is_main_query() && $query->is_search() ) { 302 345 $public_post_types = array_keys( get_post_types( array( 'public' => true ) ) ); 303 $omit_from_search = array( 'attachment', ' lesson', 'quiz', 'sensei_message', 'meeting' );346 $omit_from_search = array( 'attachment', 'page', 'lesson', 'quiz', 'sensei_message', 'meeting' ); 304 347 $searchable_post_types = array_diff( $public_post_types, $omit_from_search ); 348 349 // Only show featured courses, but don't limit other post types 350 $query->set( 351 'meta_query', 352 array( 353 'relation' => 'OR', 354 array( 355 'key' => '_course_featured', 356 'value' => 'featured', 357 ), 358 array( 359 'key' => '_course_featured', 360 'compare' => 'NOT EXISTS', 361 ), 362 ) 363 ); 305 364 306 365 $query->set( 'post_type', $searchable_post_types ); … … 564 623 565 624 case 'lesson-plan': 566 $args['meta'] = wporg_learn_get_lesson_plan_taxonomy_data( $post_id );625 $args['meta'] = wporg_learn_get_lesson_plan_taxonomy_data( $post_id, 'archive' ); 567 626 break; 568 627 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/header.php
r11309 r11352 50 50 <?php get_search_form(); ?> 51 51 </div> 52 <?php elseif ( is_page() ) : ?>53 <h1 class="site-title"><a href="<?php echo esc_url( get_the_permalink() ); ?>" rel="home"><?php the_title(); ?></a></h1>54 52 <?php else : ?> 55 53 <p class="site-title"> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/page.php
r10513 r11352 21 21 <?php get_template_part( 'template-parts/component', 'breadcrumbs' ); ?> 22 22 23 <div class="row align-middle between section-heading section-heading--with-space"> 24 <?php the_title( '<h1 class="section-heading_title h2">', '</h1>' ); ?> 25 </div> 26 <hr> 27 23 28 <div id="main-content"> 24 29 <?php -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/sidebar-lesson-plan.php
r11322 r11352 15 15 <ul> 16 16 <?php 17 foreach ( wporg_learn_get_lesson_plan_taxonomy_data( get_the_ID() ) as $detail ) {17 foreach ( wporg_learn_get_lesson_plan_taxonomy_data( get_the_ID(), 'single' ) as $detail ) { 18 18 if ( ! empty( $detail['value'] ) ) { 19 19 include locate_template( 'template-parts/component-taxonomy-item.php' ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/template-parts/component-taxonomy-item.php
r10513 r11352 14 14 <span><?php echo esc_html( $detail['label'] ); ?></span> 15 15 <strong> 16 <span><?php echo esc_html( $detail['value'] ); ?></span> 16 <span> 17 <?php //echo esc_html( $detail['value'] ); ?> 18 19 <?php 20 $i = 0; 21 foreach ( $detail['value'] as $key => $value ) { 22 $url = trailingslashit( site_url() ) . 'lesson-plans/?' . $detail['slug'] . '[]=' . $key; 23 24 if ( 0 < $i ) { 25 echo ', '; 26 } 27 28 echo '<a href="' . esc_attr( $url ) . '">' . esc_html( $value ) . '</a>'; 29 $i++; 30 } 31 ?> 32 </span> 17 33 </strong> 18 34 </li>
Note: See TracChangeset
for help on using the changeset viewer.