Changeset 12319
- Timestamp:
- 12/12/2022 03:55:38 AM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r12318 r12319 332 332 333 333 /** 334 * Returns the available sections for a plugin. 335 * 336 * @static 337 * 338 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 334 * Returns the section names for plugins. 335 * 336 * @static 339 337 * @return array 340 338 */ 341 public static function get_plugin_sections( $post = null ) { 342 $plugin = get_post( $post ); 343 344 $default_sections = array( 345 'description', 346 'screenshots', 347 'faq', 348 'blocks', 349 'stats', 350 'support', 351 'reviews', 352 'installation', 353 'developers', 354 'changelog', 355 ); 356 if ( ! get_post_meta( $plugin->ID, 'assets_screenshots', true ) ) { 357 unset( $default_sections[ array_search( 'screenshots', $default_sections ) ] ); 358 } 359 if ( ! get_post_meta( $plugin->ID, 'all_blocks' ) ) { 360 unset( $default_sections[ array_search( 'blocks', $default_sections ) ] ); 361 } 362 363 $raw_sections = get_post_meta( $plugin->ID, 'sections', true ) ?: array(); 364 $raw_sections = array_unique( array_merge( $raw_sections, $default_sections ) ); 365 366 $sections = array(); 367 $title = ''; 368 $permalink = get_permalink(); 369 370 foreach ( $raw_sections as $section_slug ) { 371 switch ( $section_slug ) { 372 373 case 'description': 374 $title = _x( 'Description', 'plugin tab title', 'wporg-plugins' ); 375 break; 376 377 case 'installation': 378 $title = _x( 'Installation', 'plugin tab title', 'wporg-plugins' ); 379 break; 380 381 case 'faq': 382 $title = _x( 'FAQ', 'plugin tab title', 'wporg-plugins' ); 383 break; 384 385 case 'screenshots': 386 $title = _x( 'Screenshots', 'plugin tab title', 'wporg-plugins' ); 387 break; 388 389 case 'changelog': 390 $title = _x( 'Changelog', 'plugin tab title', 'wporg-plugins' ); 391 break; 392 393 case 'stats': 394 $title = _x( 'Stats', 'plugin tab title', 'wporg-plugins' ); 395 break; 396 397 case 'support': 398 $title = _x( 'Support', 'plugin tab title', 'wporg-plugins' ); 399 break; 400 401 case 'reviews': 402 $title = _x( 'Reviews', 'plugin tab title', 'wporg-plugins' ); 403 break; 404 405 case 'developers': 406 $title = _x( 'Contributors & Developers', 'plugin tab title', 'wporg-plugins' ); 407 break; 408 409 case 'other_notes': 410 $title = _x( 'Other Notes', 'plugin tab title', 'wporg-plugins' ); 411 break; 412 413 case 'blocks': 414 $title = _x( 'Blocks', 'plugin tab title', 'wporg-plugins' ); 415 break; 416 417 default: 418 // Skip ahead to the next section 419 continue 2; 420 } 421 422 $sections[] = array( 423 'slug' => $section_slug, 424 'title' => $title, 425 ); 426 } 427 428 return $sections; 339 public static function get_plugin_section_titles() { 340 return [ 341 'description' => _x( 'Description', 'plugin tab title', 'wporg-plugins' ), 342 'installation' => _x( 'Installation', 'plugin tab title', 'wporg-plugins' ), 343 'faq' => _x( 'FAQ', 'plugin tab title', 'wporg-plugins' ), 344 'screenshots' => _x( 'Screenshots', 'plugin tab title', 'wporg-plugins' ), 345 'changelog' => _x( 'Changelog', 'plugin tab title', 'wporg-plugins' ), 346 'stats' => _x( 'Stats', 'plugin tab title', 'wporg-plugins' ), 347 'support' => _x( 'Support', 'plugin tab title', 'wporg-plugins' ), 348 'reviews' => _x( 'Reviews', 'plugin tab title', 'wporg-plugins' ), 349 'developers' => _x( 'Contributors & Developers', 'plugin tab title', 'wporg-plugins' ), 350 'other_notes' => _x( 'Other Notes', 'plugin tab title', 'wporg-plugins' ), 351 'blocks' => _x( 'Blocks', 'plugin tab title', 'wporg-plugins' ), 352 ]; 429 353 } 430 354 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
r12266 r12319 13 13 use WordPressdotorg\Plugin_Directory\Template; 14 14 15 global $section , $section_slug, $section_content, $post;15 global $section_slug, $section_title, $section_content, $post; 16 16 17 17 $content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content() ); … … 79 79 <div class="entry-content"> 80 80 <?php 81 if ( get_query_var( 'plugin_advanced' ) ) :81 if ( get_query_var( 'plugin_advanced' ) ) { 82 82 get_template_part( 'template-parts/section-advanced' ); 83 else :84 $plugin_sections = Template::get_plugin_sections();83 } else { 84 $plugin_sections_titles = Template::get_plugin_section_titles(); 85 85 86 foreach ( array( 'description', 'screenshots', 'blocks', 'installation', 'faq', 'reviews', 'developers', 'changelog' ) as $section_slug ) :86 foreach ( array( 'description', 'screenshots', 'blocks', 'installation', 'faq', 'reviews', 'developers', 'changelog' ) as $section_slug ) { 87 87 $section_content = ''; 88 $section_title = $plugin_sections_titles[ $section_slug ] ?? ''; 88 89 89 if ( 'description' === $section_slug && $is_closed ) { 90 if ( $is_closed && in_array( $section_slug, [ 'screenshots', 'installation', 'faq', 'changelog' ], true ) ) { 91 // Don't show these sections when closed. 92 $section_content = ''; 93 94 } elseif ( $is_closed && 'description' === $section_slug ) { 90 95 // Don't show the description for closed plugins, show a notice instead. 91 96 $section_content = get_closed_plugin_notice(); … … 93 98 } elseif ( 'blocks' === $section_slug ) { 94 99 $section_content = get_post_meta( get_the_ID(), 'all_blocks', true ); 95 } elseif ( ! in_array( $section_slug, [ 'screenshots', 'installation', 'faq', 'changelog' ], true ) || ! $is_closed ) { 96 if ( isset( $content[ $section_slug ] ) ) { 97 $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) ); 98 } 100 101 } elseif ( isset( $content[ $section_slug ] ) ) { 102 $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) ); 99 103 } 100 104 … … 103 107 } 104 108 105 $section = wp_list_filter( $plugin_sections, array( 'slug' => $section_slug ) ); 106 $section = array_pop( $section ); 107 108 if ( 'blocks' === $section_slug ) { 109 get_template_part( 'template-parts/section-blocks' ); 110 } else { 111 get_template_part( 'template-parts/section' ); 112 } 113 endforeach; 114 endif; // plugin_advanced. 109 get_template_part( 'template-parts/section', $section_slug ); 110 } 111 } // plugin_advanced. 115 112 ?> 116 113 </div><!-- .entry-content --> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-blocks.php
r11355 r12319 8 8 */ 9 9 10 global $section , $section_slug, $section_content;10 global $section_slug, $section_title, $section_content; 11 11 12 12 $prefix = in_array( $section_slug, array( 'screenshots', 'faq', 'blocks' ), true ) ? '' : 'tab-'; … … 37 37 38 38 <div id="<?php echo esc_attr( $prefix . $section_slug ); ?>" class="<?php echo esc_attr( $classes ); ?>"> 39 <h2 id="<?php echo esc_attr( $section_slug . '-header' ); ?>"><?php echo esc_html( $section ['title']); ?></h2>39 <h2 id="<?php echo esc_attr( $section_slug . '-header' ); ?>"><?php echo esc_html( $section_title ); ?></h2> 40 40 41 41 <p><?php printf( esc_html( _n( 'This plugin provides %d block.', 'This plugin provides %d blocks.', count( $section_content ), 'wporg-plugins' ) ), count( $section_content ) ); ?></p> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section.php
r8882 r12319 8 8 */ 9 9 10 global $section , $section_slug, $section_content;10 global $section_slug, $section_title, $section_content; 11 11 12 12 $prefix = in_array( $section_slug, array( 'screenshots', 'faq' ), true ) ? '' : 'tab-'; … … 17 17 18 18 <div id="<?php echo esc_attr( $prefix . $section_slug ); ?>" class="<?php echo esc_attr( $classes ); ?>"> 19 <h2 id="<?php echo esc_attr( $section_slug . '-header' ); ?>"><?php echo esc_html( $section ['title']); ?></h2>19 <h2 id="<?php echo esc_attr( $section_slug . '-header' ); ?>"><?php echo esc_html( $section_title ); ?></h2> 20 20 <?php echo $section_content; ?> 21 21 </div>
Note: See TracChangeset
for help on using the changeset viewer.