WordPress.org

Making WordPress.org


Ignore:
Timestamp:
11/23/17 02:08:54 (3 weeks ago)
Author:
SergeyBiryukov
Message:

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

Fixes #3278.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.