Making WordPress.org

Changeset 14152


Ignore:
Timestamp:
10/29/2024 02:31:15 AM (22 months ago)
Author:
dd32
Message:

Plugin Directory: Standardise on the data exposed for closed plugins.

See #7057.

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

Legend:

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

    r13645 r14152  
    6262                                'description' => $close_text,
    6363                                'closed'      => true,
    64                                 'closed_date' => $close_data['date'] ?: false,
     64                                'closed_date' => $close_data['date'] ? gmdate( 'Y-m-d', strtotime( $close_data['date'] ) ) : false,
    6565                                'reason'      => $close_data['public'] ? $close_data['reason'] : false,
    6666                                'reason_text' => $close_data['public'] ? $close_data['label'] : false,
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r14075 r14152  
    10911091                }
    10921092
    1093                 $result['label'] = self::get_close_reasons()[ $result['reason'] ] ?? _x( 'Unknown', 'unknown close reason', 'wporg-plugins' );
    1094                 $days_closed     = $result['date'] ? (int) ( ( time() - strtotime( $result['date'] ) ) / DAY_IN_SECONDS ) : false;
     1093                $result['label'] = self::get_close_reasons()[ $result['reason'] ] ?? false;
     1094
     1095                // If not known reason, use 'unknown'.
     1096                if ( ! $result['label'] ) {
     1097                        $result['reason'] = 'unknown';
     1098                        $result['label']  = _x( 'Unknown', 'unknown close reason', 'wporg-plugins' );
     1099                }
    10951100
    10961101                // If it's closed for more than 60 days, it's by author request, or we're unsure about the close date, it's publicly known.
     1102                $days_closed = $result['date'] ? (int) ( ( time() - strtotime( $result['date'] ) ) / DAY_IN_SECONDS ) : false;
    10971103                if ( ! $result['date'] || $days_closed >= 60 || 'author-request' === $result['reason'] ) {
    10981104                        $result['public'] = true;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php

    r13628 r14152  
    8383
    8484                if ( in_array( $post->post_status, array( 'disabled', 'closed' ) ) ) {
    85                         $closed_data           = Template::get_close_data( $post );
    86                         $meta['closed_at']     = $closed_data['date'] ?? false;
    87                         if ( $closed_data['public'] ?? false ) {
    88                                 $meta['closed_reason'] = $closed_data['reason'];
    89                                 $meta['closed_label']  = $closed_data['label'];
     85                        $closed_data = Template::get_close_data( $post );
     86                        if ( $closed_data ) {
     87                                // Close date is sometimes unknown, only include the Day of closure.
     88                                $meta['closed_at'] = $closed_data['date'] ? gmdate( 'Y-m-d', strtotime( $closed_data['date'] ) ) : false;
     89                                if ( $closed_data['public'] ) {
     90                                        $meta['closed_reason'] = $closed_data['reason'] ?: 'unknown';
     91                                        $meta['closed_label']  = $closed_data['label'];
     92                                }
    9093                        }
    9194                }
Note: See TracChangeset for help on using the changeset viewer.