WordPress.org

Making WordPress.org

Changeset 6162


Ignore:
Timestamp:
11/23/2017 02:08:54 AM (6 months ago)
Author:
SergeyBiryukov
Message:

Plugin Directory, Author Card: Display close reason for closed or disabled plugins.

Fixes #3278.

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/admin/metabox/class-author-card.php

    r5556 r6162  
    44require_once dirname( dirname( __DIR__ ) ) . '/class-tools.php';
    55
     6use WordPressdotorg\Plugin_Directory\Template;
    67use WordPressdotorg\Plugin_Directory\Tools;
    78
     
    153154                    $plugin_slug = $plugin->post_name;
    154155                    if ( in_array( $plugin->post_status, array( 'new', 'pending' ) ) ) {
    155                         $extra .= ' (requested ' . human_time_diff( strtotime( $last_updated ) ) . ' ago)';
     156                        $extra .= sprintf( '(requested %s ago)', human_time_diff( strtotime( $last_updated ) ) );
    156157                        $tooltips[] = 'Requested, remains unapproved.';
    157158                        $classes[]  = 'profile-plugin-requested';
     
    163164
    164165                    } elseif ( 'closed' === $plugin->post_status ) {
     166                        $extra .= sprintf( '(closed: %s)', Template::get_close_reason( $plugin ) );
    165167                        $tooltips[] = 'Plugin is closed.';
    166168                        $classes[]  = 'profile-plugin-closed';
    167169
    168170                    } elseif ( 'disabled' === $plugin->post_status ) {
     171                        $extra .= sprintf( '(disabled: %s)', Template::get_close_reason( $plugin ) );
    169172                        $tooltips[] = 'Plugin is disabled (updates are active).';
    170173                        $classes[]  = 'profile-plugin-closed';
     
    206209
    207210                    if ( $extra ) {
    208                         echo $extra;
     211                        echo ' ' . $extra;
    209212                    }
    210213
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php

    r6043 r6162  
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
    33use WordPressdotorg\Plugin_Directory\Admin\Status_Transitions;
     4use WordPressdotorg\Plugin_Directory\Template;
    45
    56/**
     
    7374
    7475    /**
    75      * Get reasons for closing or disabling a plugin.
    76      *
    77      * @return array Close/disable reason labels.
    78      */
    79     public static function get_close_reasons() {
    80         return array(
    81             'security-issue'                => __( 'Security Issue', 'wporg-plugins' ),
    82             'author-request'                => __( 'Author Request', 'wporg-plugins' ),
    83             'guideline-violation'           => __( 'Guideline Violation', 'wporg-plugins' ),
    84             'licensing-trademark-violation' => __( 'Licensing/Trademark Violation', 'wporg-plugins' ),
    85             'merged-into-core'              => __( 'Merged into Core', 'wporg-plugins' ),
    86             'unused'                        => __( 'Unused', 'wporg-plugins' ),
    87         );
    88     }
    89 
    90     /**
    9176     * Displays the Plugin Status control in the Publish metabox.
    9277     */
     
    10590        }
    10691
    107         $close_reasons = self::get_close_reasons();
    108         $close_reason  = (string) get_post_meta( $post->ID, '_close_reason', true );
     92        $close_reasons  = Template::get_close_reasons();
     93        $close_reason   = (string) get_post_meta( $post->ID, '_close_reason', true );
    10994
    110         if ( isset( $close_reasons[ $close_reason ] ) ) {
    111             $reason_label   = $close_reasons[ $close_reason ];
    112             $reason_unknown = false;
    113         } else {
    114             $reason_label   = _x( 'Unknown', 'unknown close reason', 'wporg-plugins' );
    115             $reason_unknown = true;
    116         }
     95        $reason_label   = Template::get_close_reason();
     96        $reason_unknown = ( _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ) === $reason_label );
    11797        ?>
    11898        <div class="misc-pub-section misc-pub-plugin-status">
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r6139 r6162  
    663663
    664664    /**
     665     * Returns the reasons for closing or disabling a plugin.
     666     *
     667     * @return array Close/disable reason labels.
     668     */
     669    public static function get_close_reasons() {
     670        return array(
     671            'security-issue'                => __( 'Security Issue', 'wporg-plugins' ),
     672            'author-request'                => __( 'Author Request', 'wporg-plugins' ),
     673            'guideline-violation'           => __( 'Guideline Violation', 'wporg-plugins' ),
     674            'licensing-trademark-violation' => __( 'Licensing/Trademark Violation', 'wporg-plugins' ),
     675            'merged-into-core'              => __( 'Merged into Core', 'wporg-plugins' ),
     676            'unused'                        => __( 'Unused', 'wporg-plugins' ),
     677        );
     678    }
     679
     680    /**
     681     * Returns the close/disable reason for a plugin.
     682     *
     683     * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
     684     * @return string Close/disable reason.
     685     */
     686    public static function get_close_reason( $post = null ) {
     687        $post = get_post( $post );
     688
     689        $close_reasons = self::get_close_reasons();
     690        $close_reason  = (string) get_post_meta( $post->ID, '_close_reason', true );
     691       
     692        if ( isset( $close_reasons[ $close_reason ] ) ) {
     693            $reason_label = $close_reasons[ $close_reason ];
     694        } else {
     695            $reason_label = _x( 'Unknown', 'unknown close reason', 'wporg-plugins' );
     696        }
     697
     698        return $reason_label;
     699    }
     700
     701    /**
    665702     * Adds hreflang link attributes to WordPress.org pages.
    666703     *
Note: See TracChangeset for help on using the changeset viewer.