Making WordPress.org

Changeset 13237


Ignore:
Timestamp:
02/22/2024 06:44:16 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Readme: Add a note for when the tags specified have low usage.

See #6108.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r13236 r13237  
    307307                                $this->warnings['ignored_tags'] = true;
    308308                        }
     309
     310                        // Check if the tags are low-quality (ie. little used)
     311                        if ( $this->tags && taxonomy_exists( 'plugin_tags' ) ) {
     312                                $tags = get_terms( array(
     313                                        'taxonomy' => 'plugin_tags',
     314                                        'name'     => $this->tags,
     315                                ) );
     316
     317                                $low_usage_tags = array_filter(
     318                                        $tags,
     319                                        function( $term ) {
     320                                                return $term->count < 5;
     321                                        }
     322                                );
     323
     324                                $this->warnings['low_usage_tags'] = wp_list_pluck( $low_usage_tags, 'name' );
     325                        }
     326
    309327                        if ( count( $this->tags ) > 5 ) {
    310328                                $this->tags = array_slice( $this->tags, 0, 5 );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    r13235 r13237  
    8181                }
    8282
    83                 // Warnings.
     83                // Warnings & Notes.
    8484                if ( isset( $readme->warnings['requires_header_ignored'] ) ) {
    8585                        $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '5.0';
    … …  
    138138                        );
    139139                } elseif ( ! count( $readme->contributors ) ) {
    140                         $warnings[] = sprintf(
     140                        $notes[] = sprintf(
    141141                                /* translators: %s: plugin header tag */
    142142                                __( 'The %s field is missing.', 'wporg-plugins' ),
    … …  
    157157                }
    158158
    159                 // Notes.
     159                if ( isset( $readme->warnings['low_usage_tags'] ) ) {
     160                        $notes[] = sprintf(
     161                                /* translators: %s: list of tags with low usage. */
     162                                __( 'The following tags are not widely used: %s', 'wporg-plugins' ),
     163                                '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $readme->warnings['low_usage_tags'] ) ) . '</code>'
     164                        );
     165                }
     166
    160167                if ( empty( $readme->requires ) ) {
    161168                        $notes[] = sprintf(
Note: See TracChangeset for help on using the changeset viewer.