Changeset 4259
- Timestamp:
- 10/19/2016 02:27:58 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r4224 r4259 336 336 add_shortcode( 'wporg-plugins-screenshots', array( __NAMESPACE__ . '\Shortcodes\Screenshots', 'display' ) ); 337 337 add_shortcode( 'wporg-plugins-reviews', array( __NAMESPACE__ . '\Shortcodes\Reviews', 'display' ) ); 338 add_shortcode( 'readme-validator', array( __NAMESPACE__ . '\Shortcodes\Readme_Validator', 'display' ) ); 338 339 } 339 340 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
r4223 r4259 72 72 73 73 $readme = ''; 74 $temp_file = Filesystem::temp_directory() . '/readme.txt';75 $warnings = array();76 $notes = array();77 74 78 75 if ( ! empty( $_REQUEST['readme_url'] ) ) { … … 98 95 } 99 96 97 return $this->validate_content( $readme ); 98 } 99 100 /** 101 * Validates content via a string paramater and adds feedback. 102 */ 103 public function validate_content( $readme ) { 104 105 $temp_file = Filesystem::temp_directory() . '/readme.txt'; 106 $errors = array(); 107 $warnings = array(); 108 $notes = array(); 109 100 110 file_put_contents( $temp_file, $readme ); 101 111 $readme = new Parser( $temp_file ); … … 105 115 /* Translators: Plugin header tag; */ 106 116 add_settings_error( 'wporg-plugins-readme', 'readme-validator', sprintf( __( "Fatal Error:\nNo plugin name detected. Plugin names look like: %s", 'wporg-plugins' ), '<code>=== Plugin Name ===</code>' ) ); 107 return; 117 $errors[] = array( 'error', sprintf( __( "Fatal Error:\nNo plugin name detected. Plugin names look like: %s", 'wporg-plugins' ), '<code>=== Plugin Name ===</code>' ) ); 118 return $errors; 108 119 } 109 120 … … 133 144 $message .= "</ul>\n</div>"; 134 145 135 add_settings_error( 'wporg-plugins-readme', 'readme-validator', $message, 'notice-warning' ); 136 return; 146 if ( function_exists( 'add_settings_error' ) ) { 147 add_settings_error( 'wporg-plugins-readme', 'readme-validator', $message, 'notice-warning' ); 148 } 149 return $message; 137 150 } 138 151 … … 165 178 $message .= "</ul>\n</div>"; 166 179 167 add_settings_error( 'wporg-plugins-readme', 'readme-validator', $message, 'notice-info' ); 168 return; 180 if ( function_exists( 'add_settings_error' ) ) { 181 add_settings_error( 'wporg-plugins-readme', 'readme-validator', $message, 'notice-info' ); 182 } 183 return $message; 169 184 } 170 185 171 186 /* Translators: File name; */ 172 add_settings_error( 'wporg-plugins-readme', 'readme-validator', sprintf( __( 'Your %s rocks. Seriously. Flying colors.', 'wporg-plugins' ), '<code>readme.txt</code>' ), 'updated' ); 173 } 187 if ( function_exists( 'add_settings_error' ) ) { 188 add_settings_error( 'wporg-plugins-readme', 'readme-validator', sprintf( __( 'Your %s rocks. Seriously. Flying colors.', 'wporg-plugins' ), '<code>readme.txt</code>' ), 'updated' ); 189 } 190 } 191 174 192 175 193 /**
Note: See TracChangeset
for help on using the changeset viewer.