Making WordPress.org

Changeset 3512


Ignore:
Timestamp:
06/20/2016 05:50:53 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Documentation and formatting update.

See #1584.

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

Legend:

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

    r3033 r3512  
    88 */
    99class Filesystem {
     10
     11    /**
     12     * Path to temporary directory.
     13     *
     14     * @var string
     15     */
    1016    const TMP_DIR = '/tmp/plugin-directory/';
    1117
     
    1521     * The temporary directory returned will be removed upon script termination.
    1622     *
    17      * @param string $prefix The prefix for the directory, 'hello-dolly' for example. Optional.
     23     * @static
    1824     *
     25     * @param string $prefix Optional. The prefix for the directory, 'hello-dolly' for example. Default: empty string.
    1926     * @return string The temporary directory.
    2027     */
     
    2431        }
    2532
    26         // Generate a unique filename
     33        // Generate a unique filename.
    2734        $tmp_dir = tempnam( self::TMP_DIR, $prefix );
    2835
    29         // Replace that filename with a directory
     36        // Replace that filename with a directory.
    3037        unlink( $tmp_dir );
    3138        mkdir( $tmp_dir, 0777 );
     
    4047     * Extract a ZIP file to a directory.
    4148     *
     49     * @static
     50     *
    4251     * @param string $zip_file  The ZIP file to extract.
    43      * @param string $directory The Directory to extract the ZIP to. Optional. Default: A Temporary directory.
    44      *
     52     * @param string $directory Optional. The Directory to extract the ZIP to. Default: A Temporary directory.
    4553     * @return string The directory the ZIP was extracted to.
    4654     */
     
    6876     * Returns all (usable) files of a given directory.
    6977     *
     78     * @static
     79     *
    7080     * @param string $directory Path to directory to search.
    71      * @param bool   $recursive Whether to recurse into subdirectories. Default: false.
    72      * @param string $pattern   A regular expression to match files against. Optional.
    73      *
     81     * @param bool   $recursive Optional. Whether to recurse into subdirectories. Default: false.
     82     * @param string $pattern   Optional. A regular expression to match files against. Default: null.
    7483     * @return array All files within the passed directory.
    7584     */
     
    104113     * Forcibly remove a directory recursively.
    105114     *
     115     * @static
     116     *
    106117     * @param string $dir The directory to remove.
    107      *
    108118     * @return bool Whether the directory was removed.
    109119     */
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php

    r3370 r3512  
    1212     * Import a local directory to a SVN path.
    1313     *
    14      * @param string $path    The local folder to import into SVN.
    15      * @param string $url     The URL to import to.
    16      * @param string $message The commit message.
    17      *
     14     * @static
     15     *
     16     * @param string $path     The local folder to import into SVN.
     17     * @param string $url      The URL to import to.
     18     * @param string $message  The commit message.
    1819     * @return array {
    19      *   @type bool $result   The result of the operation.
    20      *   @type int  $revision The revision imported.
     20     *     @type bool $result   The result of the operation.
     21     *     @type int  $revision The revision imported.
    2122     * }
    2223     */
    2324    public static function import( $path, $url, $message ) {
    24         $options = array(
     25        $options     = array(
    2526            'non-interactive',
    26             'm' => $message,
     27            'm'    => $message,
    2728            'user' => PLUGIN_SVN_MANAGEMENT_USER,
    2829            'pass' => PLUGIN_SVN_MANAGEMENT_PASS,
     
    4849     * Create an SVN Export of a URL to a local directory.
    4950     *
     51     * @static
     52     *
    5053     * @param string $url         The URL to export.
    5154     * @param string $destination The local folder to export into.
    52      * @param array  $options     A list of options to pass to SVN. Optional.
    53      *
     55     * @param array  $options     Optional. A list of options to pass to SVN. Default: empty array.
    5456     * @return array {
    55      *   @type bool $result   The result of the operation.
    56      *   @type int  $revision The revision exported.
     57     *     @type bool $result   The result of the operation.
     58     *     @type int  $revision The revision exported.
    5759     * }
    5860     */
    5961    public static function export( $url, $destination, $options = array() ) {
    60         $options[] = 'non-interactive';
     62        $options[]   = 'non-interactive';
    6163        $esc_options = self::parse_esc_parameters( $options );
    6264
    63         $esc_url = escapeshellarg( $url );
     65        $esc_url         = escapeshellarg( $url );
    6466        $esc_destination = escapeshellarg( $destination );
    6567
     
    6769        if ( preg_match( '/Exported revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
    6870            $revision = (int) $m['revision'];
    69             $result = true;
     71            $result   = true;
    7072        } else {
    7173            $result = false;
     
    7981     * List the files in a remote SVN destination.
    8082     *
     83     * @static
     84     *
    8185     * @param string $url     The URL to export.
    82      * @param bool   $verbose Whether to list the files verbosely with extra metadata.
    83      *
    84      * @return array If non-verbose a list of files, if verbose an array of items containing the filename, date, filesize, author and revision.
     86     * @param bool   $verbose Optional. Whether to list the files verbosely with extra metadata. Default: false.
     87     * @return array If non-verbose a list of files, if verbose an array of items containing the filename, date,
     88     *               filesize, author and revision.
    8589     */
    8690    public static function ls( $url, $verbose = false ) {
    8791        $options = array(
    88             'non-interactive'
     92            'non-interactive',
    8993        );
    9094        if ( $verbose ) {
     
    9296        }
    9397        $esc_options = self::parse_esc_parameters( $options );
    94         $esc_url = escapeshellarg( $url );
     98        $esc_url     = escapeshellarg( $url );
    9599
    96100        $output = self::shell_exec( "svn ls $esc_options $esc_url 2>&1" );
    97 
    98101        $errors = self::parse_svn_errors( $output );
    99102        if ( $errors ) {
     
    104107            return array_filter( array_map( 'trim', explode( "\n", $output ) ) );
    105108        } else {
    106             // Parse SVN verbose output.
    107             // ^revision author [filesize] date filename$
     109
     110            /*
     111             * Parse SVN verbose output.
     112             * ^revision author [filesize] date filename$
     113             */
    108114            preg_match_all( '!^\s*(?P<revision>\d+)\s(?P<author>\S+)\s*(?P<filesize>\d+)?\s*(?P<date>.+?)\s*(?P<filename>\S+)\s*$!im', $output, $files, PREG_SET_ORDER );
    109115
    110             // Remove numeric keys from output
    111             $files = array_map( function( $item ) {
     116            // Remove numeric keys from output.
     117            $files = array_map( function ( $item ) {
    112118                return array_filter( $item, 'is_string', ARRAY_FILTER_USE_KEY );
    113119            }, $files );
     
    120126     * Fetch SVN revisions for a given revision or range of revisions.
    121127     *
     128     * @static
     129     *
    122130     * @param string       $url      The URL to fetch.
    123      * @param string|array $revision The revision to get information about. Default HEAD.
    124      * @param array        $options  A list of options to pass to SVN. Optional.
    125      *
     131     * @param string|array $revision Optional. The revision to get information about. Default HEAD.
     132     * @param array        $options  Optional. A list of options to pass to SVN. Default: empty array.
    126133     * @return array {
    127      *   @type array|false $errors  Whether any errors or warnings were encountered.
    128      *   @type array       $log     The SVN log data struct.
     134     *     @type array|false $errors Whether any errors or warnings were encountered.
     135     *     @type array       $log    The SVN log data struct.
    129136     * }
    130137     */
    131138    public static function log( $url, $revision = 'HEAD', $options = array() ) {
    132         $options[] = 'non-interactive';
    133         $options[] = 'verbose';
    134         $options[] = 'xml';
     139        $options[]           = 'non-interactive';
     140        $options[]           = 'verbose';
     141        $options[]           = 'xml';
    135142        $options['revision'] = is_array( $revision ) ? "{$revision[0]}:{$revision[1]}" : $revision;
    136         $esc_options = self::parse_esc_parameters( $options );
     143        $esc_options         = self::parse_esc_parameters( $options );
    137144
    138145        $esc_url = escapeshellarg( $url );
    139146
    140147        $output = self::shell_exec( "svn log $esc_options $esc_url 2>&1" );
    141 
    142148        $errors = self::parse_svn_errors( $output );
    143149
    144150        $log = array();
    145151
    146         // We use funky string mangling here to extract the XML as it may have been truncated by a SVN error, or suffixed by a SVN warning
     152        /*
     153         * We use funky string mangling here to extract the XML as it may have been truncated by a SVN error,
     154         * or suffixed by a SVN warning.
     155         */
    147156        $xml = substr( $output, $start = stripos( $output, '<?xml' ), $end = ( strripos( $output, '</log>' ) - $start + 6 ) );
    148157        if ( $xml && false !== $start && false !== $end ) {
    149158
    150159            $user_errors = libxml_use_internal_errors( true );
    151             $simple_xml = simplexml_load_string( $xml );
     160            $simple_xml  = simplexml_load_string( $xml );
    152161            libxml_use_internal_errors( $user_errors );
    153162
     
    157166                foreach ( $simple_xml->logentry as $entry ) {
    158167                    $revision = (int) $entry->attributes()['revision'];
    159                     $paths = array();
    160                     foreach ( $entry->paths->children() as $p ) {
    161                         $paths[] = (string) $p;
     168                    $paths    = array();
     169
     170                    foreach ( $entry->paths->children() as $child_path ) {
     171                        $paths[] = (string) $child_path;
    162172                    }
    163173
     
    182192     * prefixed with -, it'll be prefixed with 1 or 2 dashes as appropriate.
    183193     *
     194     * @static
     195     * @access protected
     196     *
    184197     * @param array $params The array of parameters provided.
    185      *
    186198     * @return string The parameters formatted and escaped for CLI usage.
    187199     */
    188      protected static function parse_esc_parameters( $params ) {
     200    protected static function parse_esc_parameters( $params ) {
    189201        $result = array();
     202
    190203        foreach ( $params as $key => $value ) {
    191204            $no_parameters = is_numeric( $key );
     
    193206                $key = $value;
    194207            }
    195             // Prefix options with `-` or `--` if they're longer than 2 characters
     208
     209            // Prefix options with `-` or `--` if they're longer than 2 characters.
    196210            if ( '-' != substr( $key, 0, 1 ) ) {
    197211                $key = '-' . ( strlen( $key ) > 2 ? '-' : '' ) . $key;
     
    207221     * Parses SVN output to detect SVN errors and throw an exception.
    208222     *
     223     * @static
     224     * @access protected
     225     *
    209226     * @param string $output The output from SVN.
    210      *
    211      * @return false|array False if no errors/warnings detected in output, An array of arrays containing warning/error_code/error_message if detected.
     227     * @return false|array False if no errors/warnings detected in output, An array of arrays containing
     228     *                     warning/error_code/error_message if detected.
    212229     */
    213230    protected static function parse_svn_errors( $output ) {
    214231        if ( preg_match_all( '!^svn: (?P<warning>warning:)?\s*(?<error_code>[EW]\d+):\s*(?P<error_message>.+)$!im', $output, $messages, PREG_SET_ORDER ) ) {
     232
    215233            // We only want the string keys - strip out the numeric keys
    216             $messages = array_map( function( $item ) {
     234            $messages = array_map( function ( $item ) {
    217235                return array_filter( $item, 'is_string', ARRAY_FILTER_USE_KEY );
    218236            }, $messages );
     237
    219238            return $messages;
    220239        }
     
    228247     *
    229248     * WordPress.org uses the en_US.UTF-8 locale.
     249     *
     250     * @static
     251     * @access protected
     252     *
     253     * @param string $command The command to be executed.
     254     * @return mixed The output from the executed command or NULL if an error occurred or the command produces no
     255     *               output.
    230256     */
    231257    protected static function shell_exec( $command ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-donate.php

    r3422 r3512  
    3636
    3737            <p class="aside"><?php _e( 'Would you like to support the advancement of this plugin?', 'wporg-plugins' ); ?></p>
    38             <p><a class="button button-secondary" href="<?php echo esc_url( $donate_link ); ?>" rel="nofollow"><?php _e( 'Donate to this plugin', 'wporg-plugins' ); ?></a></p>
     38            <p>
     39                <a class="button button-secondary" href="<?php echo esc_url( $donate_link ); ?>" rel="nofollow">
     40                    <?php _e( 'Donate to this plugin', 'wporg-plugins' ); ?>
     41                </a>
     42            </p>
    3943
    4044            <?php
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php

    r3426 r3512  
    6464
    6565        <?php else : ?>
    66            
     66
    6767            <div class="rating">
    6868                <p><?php _e( 'This plugin has not been rated yet.', 'wporg-plugins' ); ?></p>
     
    7575                <a class="button button-secondary" href="<?php echo esc_url( 'https://wordpress.org/support/view/plugin-reviews/' . $post->post_name . '#postform' ); ?>"><?php _e( 'Add your review', 'wporg-plugins' ); ?></a>
    7676            </div>
    77         <?php
     77            <?php
    7878        endif;
    7979
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support.php

    r3423 r3512  
    5959                    <?php
    6060                    /* Translators: 1: AMount of resolved threads; 2: Amount of total threads; */
    61                     printf( __( '%1$s out of %2$s'), $resolved, $threads );
     61                    printf( __( '%1$s out of %2$s' ), $resolved, $threads );
    6262                    ?>
    6363                </span>
Note: See TracChangeset for help on using the changeset viewer.