Changeset 12532 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
- Timestamp:
- 04/12/2023 04:50:46 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r12526 r12532 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\CLI\Import; 4 5 use WordPressdotorg\Plugin_Directory\Readme\Parser; 5 6 use WordPressdotorg\Plugin_Directory\Plugin_Directory; … … 64 65 $this->plugin_dir = Filesystem::unzip( $zip_file ); 65 66 66 $plugin_files = Filesystem::list_files( $this->plugin_dir, true /* Recursive */, '!\.php$!i', 1 /* Depth */ ); 67 foreach ( $plugin_files as $plugin_file ) { 68 $plugin_data = get_plugin_data( $plugin_file, false, false ); // No markup/translation needed. 69 if ( ! empty( $plugin_data['Name'] ) ) { 70 $this->plugin = $plugin_data; 71 $this->plugin_root = dirname( $plugin_file ); 72 break; 73 } 67 $plugin_data = (array) Import::find_plugin_headers( $this->plugin_dir, 1 /* Max Depth to search */ ); 68 if ( ! empty( $plugin_data['Name'] ) ) { 69 $this->plugin = $plugin_data; 70 $this->plugin_root = dirname( $plugin_data['PluginFile'] ); 74 71 } 75 72 … … 262 259 263 260 // Check for a valid readme. 264 $readme = $this->find_readme_file();261 $readme = Import::find_readme_file( $this->plugin_root ); 265 262 if ( empty( $readme ) ) { 266 263 $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' ); … … 381 378 'header_textdomain' => $this->plugin['TextDomain'], 382 379 'header_description' => $this->plugin['Description'], 380 'requires_plugins' => $this->plugin['RequiresPlugins'], 383 381 'assets_screenshots' => array(), 384 382 'assets_icons' => array(), … … 677 675 678 676 /** 679 * Find the plugin readme file.680 *681 * Looks for either a readme.txt or readme.md file, prioritizing readme.txt.682 *683 * @return string The plugin readme.txt or readme.md filename.684 */685 protected function find_readme_file() {686 $files = Filesystem::list_files( $this->plugin_root, false /* non-recursive */, '!^readme\.(txt|md)$!i' );687 688 // Prioritize readme.txt file.689 foreach ( $files as $file ) {690 if ( '.txt' === strtolower( substr( $file, -4 ) ) ) {691 return $file;692 }693 }694 695 return reset( $files );696 }697 698 /**699 677 * Sends a plugin through Plugin Check. 700 678 *
Note: See TracChangeset
for help on using the changeset viewer.