Making WordPress.org


Ignore:
Timestamp:
04/03/2024 07:01:21 AM (6 months ago)
Author:
dd32
Message:

Plugin Directory: Store error codes (rather than english error messages) that occur during a plugin import, to allow the errors to be generated with the appropriate translations.

This expands some errors to better highlight what is invalid as well.

See #6108.

File:
1 edited

Legend:

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

    r13292 r13443  
    308308            $this->tags = array_map( 'trim', $this->tags );
    309309            $this->tags = array_filter( $this->tags );
     310
    310311            if ( array_intersect( $this->tags, $this->ignore_tags ) ) {
    311312                $this->tags = array_diff( $this->tags, $this->ignore_tags );
     
    313314            }
    314315
    315             // Check if the tags are low-quality (ie. little used)
    316             if ( $this->tags && taxonomy_exists( 'plugin_tags' ) ) {
    317                 $tags = get_terms( array(
    318                     'taxonomy' => 'plugin_tags',
    319                     'name'     => $this->tags,
    320                 ) );
    321 
    322                 $low_usage_tags = array_filter(
    323                     $tags,
    324                     function( $term ) {
    325                         return $term->count < 5;
    326                     }
    327                 );
    328 
    329                 $this->warnings['low_usage_tags'] = wp_list_pluck( $low_usage_tags, 'name' );
    330             }
    331 
    332316            if ( count( $this->tags ) > 5 ) {
     317                $this->warnings['too_many_tags'] = array_slice( $this->tags, 4 );
    333318                $this->tags = array_slice( $this->tags, 0, 5 );
    334                 $this->warnings['too_many_tags'] = true;
    335319            }
    336320        }
     
    715699            // In the event that something invalid is used, we'll ignore it (Example: 'Joe Bloggs (Australian Translation)')
    716700            if ( ! $user ) {
     701                $this->warnings['contributor_ignored'] ??= [];
     702                $this->warnings['contributor_ignored'][] = $name;
    717703                unset( $users[ $i ] );
    718                 $this->warnings['contributor_ignored'] = true;
    719704                continue;
    720705            }
     
    723708            $users[ $i ] = $user->user_nicename;
    724709        }
    725 
    726710        return $users;
    727711    }
Note: See TracChangeset for help on using the changeset viewer.