Making WordPress.org

Ticket #3460: 3460.diff

File 3460.diff, 1.9 KB (added by dufresnesteven, 2 years ago)

Add a warning to display to the user if the readme size is larger than 8kb.

  • wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
    index cc3dc4188..3698b73f1 100644
    class Parser { 
    9494         */
    9595        public $warnings = array();
    9696
     97        /**
     98         * Any readme.txt file larger than this will receive a warning
     99         *
     100         * @var integer
     101         */
     102        private $README_WARNING_KB_SIZE = 8;
     103
    97104        /**
    98105         * These are the readme sections that we expect.
    99106         *
    class Parser { 
    329336                        $current .= $line . "\n";
    330337                }
    331338
     339                // Check the file size
     340                if( $this->show_filesize_warning( $file ) ) {
     341                        $this->warnings['filesize_warning'] = true;
     342                }
     343
    332344                if ( ! empty( $section_name ) ) {
    333345                        $this->sections[ $section_name ] .= trim( $current );
    334346                }
    class Parser { 
    772784
    773785                return true;
    774786        }
     787
     788        /**
     789         * @access protected
     790         *
     791         * @param string $file
     792         * @return string
     793         */
     794        protected function show_filesize_warning( $file ) {
     795                return ( strlen( $file ) / 1024 ) > $this->README_WARNING_KB_SIZE;
     796        }
     797
    775798}
  • wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
    index 7e984c648..46a6088cb 100644
    class Validator { 
    139139                        );
    140140                }
    141141
     142                if ( isset( $readme->warnings['filesize_warning'] ) ) {
     143                        $warnings[] = __( 'Your readme file is large. Try to reduce content to keep it more concise.', 'wporg-plugins' );
     144                }
     145
    142146                // Notes.
    143147                if ( empty( $readme->requires ) ) {
    144148                        $notes[] = sprintf(