Changeset 12268
- Timestamp:
- 11/23/2022 02:00:20 AM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 1 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/taxonomy.php
r12259 r12268 10 10 add_action( 'init', __NAMESPACE__ . '\register' ); 11 11 add_action( 'audience_add_form_fields', __NAMESPACE__ . '\register_custom_fields' ); 12 add_action( 'wporg_lesson_category_add_form_fields', __NAMESPACE__ . '\register_custom_fields' );13 12 add_action( 'topic_add_form_fields', __NAMESPACE__ . '\register_custom_fields' ); 14 13 add_action( 'audience_edit_form_fields', __NAMESPACE__ . '\tax_edit_term_fields', 10, 2 ); 15 add_action( 'wporg_lesson_category_edit_form_fields', __NAMESPACE__ . '\tax_edit_term_fields', 10, 2 );16 14 add_action( 'topic_edit_form_fields', __NAMESPACE__ . '\tax_edit_term_fields', 10, 2 ); 17 15 add_action( 'created_audience', __NAMESPACE__ . '\tax_save_term_fields' ); 18 16 add_action( 'edited_audience', __NAMESPACE__ . '\tax_save_term_fields' ); 19 add_action( 'created_wporg_lesson_category', __NAMESPACE__ . '\tax_save_term_fields' );20 add_action( 'edited_wporg_lesson_category', __NAMESPACE__ . '\tax_save_term_fields' );21 17 add_action( 'created_topic', __NAMESPACE__ . '\tax_save_term_fields' ); 22 18 add_action( 'edited_topic', __NAMESPACE__ . '\tax_save_term_fields' ); … … 27 23 function register() { 28 24 register_lesson_audience(); 29 register_lesson_category();30 25 register_lesson_duration(); 31 26 register_lesson_group(); … … 83 78 84 79 register_taxonomy( 'audience', array( 'lesson-plan' ), $args ); 85 }86 87 /**88 * Register the Lesson Category taxonomy.89 */90 function register_lesson_category() {91 $labels = array(92 'name' => _x( 'Lesson Categories', 'Taxonomy General Name', 'wporg-learn' ),93 'singular_name' => _x( 'Lesson Category', 'Taxonomy Singular Name', 'wporg-learn' ),94 'menu_name' => __( 'Categories', 'wporg-learn' ),95 'all_items' => __( 'All Lesson Categories', 'wporg-learn' ),96 'new_item_name' => __( 'New Lesson Category', 'wporg-learn' ),97 'add_new_item' => __( 'Add New Lesson Category', 'wporg-learn' ),98 'edit_item' => __( 'Edit Lesson Category', 'wporg-learn' ),99 'update_item' => __( 'Update Lesson Category', 'wporg-learn' ),100 'view_item' => __( 'View Lesson Category', 'wporg-learn' ),101 'separate_items_with_commas' => __( 'Separate lesson categories with commas', 'wporg-learn' ),102 'add_or_remove_items' => __( 'Add or remove lesson categories', 'wporg-learn' ),103 'choose_from_most_used' => __( 'Choose from the most used', 'wporg-learn' ),104 'popular_items' => __( 'Popular lesson categories', 'wporg-learn' ),105 'search_items' => __( 'Search lesson categories', 'wporg-learn' ),106 'not_found' => __( 'Not Found', 'wporg-learn' ),107 'no_terms' => __( 'No lesson categories', 'wporg-learn' ),108 'items_list' => __( 'Lesson Categories list', 'wporg-learn' ),109 'items_list_navigation' => __( 'Lesson Categories list navigation', 'wporg-learn' ),110 );111 112 $args = array(113 'labels' => $labels,114 'hierarchical' => true,115 'public' => true,116 'rewrite' => array(117 'slug' => 'lesson-plans',118 ),119 'show_ui' => true,120 'show_admin_column' => true,121 'show_in_nav_menus' => false,122 'show_tagcloud' => false,123 'show_in_rest' => true,124 'capabilities' => array(125 'assign_terms' => 'edit_lesson_plans',126 ),127 );128 129 register_taxonomy( 'wporg_lesson_category', array( 'lesson-plan' ), $args );130 80 } 131 81 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/archive-lesson-plan.php
r12153 r12268 43 43 <hr> 44 44 <?php 45 $categories = get_terms( array( 46 'taxonomy' => 'wporg_lesson_category', 47 'hide_empty' => false, 48 'orderby' => 'id', 49 'order' => 'DESC', 50 ) ); 51 ?> 52 <div class="lp-taxonomy"> 53 <h2 class="h4 lp-taxonomy-header"><?php echo esc_html__( 'Topic', 'wporg-learn' ); ?></h2> 54 <div class="lp-taxonomy-description"><?php echo esc_html__( 'Browse lesson plans by their high-level topic.', 'wporg-learn' ); ?></div> 55 <div class="card-grid card-grid_4"> 56 <?php foreach ( $categories as $category ) : 57 $is_sticky = get_term_meta( $category->term_id, 'sticky', true ); 58 if ( $is_sticky ) : 59 ?> 60 <a class="card button" href="<?php echo esc_url( get_term_link( $category ) ); ?>"> 61 <?php $category_icon = get_term_meta( $category->term_id, 'dashicon-class', true ) ?? 'wordpress-alt'; ?> 62 <div> 63 <span aria-hidden="true" class="dashicons dashicons-<?php echo esc_attr( $category_icon ); ?>"></span> 64 </div> 65 <?php echo esc_html( $category->name ); ?> 66 </a> 67 <?php 68 endif; 69 endforeach; ?> 70 </div> 71 </div> 45 $topics = wporg_learn_get_sticky_topics_with_selected_first(); 46 if ( ! empty( $topics ) ) { 47 ?> 48 <div class="lp-taxonomy"> 49 <h2 class="h4 lp-taxonomy-header"><?php echo esc_html__( 'Topic', 'wporg-learn' ); ?></h2> 50 <div class="lp-taxonomy-description"><?php echo esc_html__( 'Browse lesson plans by their high-level topic.', 'wporg-learn' ); ?></div> 51 <div class="card-grid card-grid_4"> 52 <?php foreach ( $topics as $topic ) : ?> 53 <a class="card button topic-<?php echo esc_attr( $topic->term_id ); ?>" href="<?php echo esc_url( get_term_link( $topic ) ); ?>"> 54 <?php $topic_icon = get_term_meta( $topic->term_id, 'dashicon-class', true ) ?? 'wordpress-alt'; ?> 55 <div> 56 <span aria-hidden="true" class="dashicons dashicons-<?php echo esc_attr( $topic_icon ); ?>"></span> 57 </div> 58 <?php echo esc_html( $topic->name ); ?> 59 </a> 60 <?php endforeach; ?> 61 </div> 62 </div> 63 <?php 64 } ?> 72 65 73 66 <?php … … 152 145 endforeach; 153 146 154 if ( $any_duration_arr['duration']) :147 if ( isset( $any_duration_arr['duration'] ) ) : 155 148 ?> 156 149 <li> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php
r12067 r12268 341 341 // Some lesson plans were created at exactly the same second, so we're adding the ID to the implicit sort order to avoid randomization. 342 342 if ( 343 ( $query->is_post_type_archive( 'lesson-plan' ) || $query->is_tax( ' wporg_lesson_category' ) ) &&343 ( $query->is_post_type_archive( 'lesson-plan' ) || $query->is_tax( 'topic' ) ) && 344 344 empty( $query->get( 'orderby' ) ) 345 345 ) { … … 1202 1202 } 1203 1203 add_filter( 'mime_types', 'wporg_learn_mime_types' ); 1204 1205 /** 1206 * Get the sticky Topic terms, with the selected topic first 1207 * 1208 * @param string $first The slug of the topic to return first. 1209 * @return array 1210 */ 1211 function wporg_learn_get_sticky_topics_with_selected_first( $first = 'general' ) { 1212 $first_topic; 1213 $topics = array(); 1214 $all_topics = get_terms( array( 1215 'taxonomy' => 'topic', 1216 'hide_empty' => false, 1217 ) ); 1218 1219 foreach ( $all_topics as $topic ) { 1220 $is_sticky = get_term_meta( $topic->term_id, 'sticky', true ); 1221 1222 if ( $is_sticky ) { 1223 if ( $topic->slug === $first ) { 1224 $first_topic = $topic; 1225 } else { 1226 array_push( $topics, $topic ); 1227 } 1228 } 1229 } 1230 1231 if ( isset( $first_topic ) ) { 1232 array_unshift( $topics, $first_topic ); 1233 } 1234 1235 return $topics; 1236 }
Note: See TracChangeset
for help on using the changeset viewer.