Changeset 12319 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 12/12/2022 03:55:38 AM (2 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.