Make WordPress Core

Changeset 27399


Ignore:
Timestamp:
03/04/2014 09:06:48 PM (13 years ago)
Author:
nacin
Message:

i18n tools: Have makepot search for the main file of the plugin.

props Otto42.
fixes #25665.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/i18n/makepot.php

    r25254 r27399  
    434434                        $slug = $this->guess_plugin_slug($dir);
    435435                }
    436                 $main_file = $dir.'/'.$slug.'.php';
    437                 $source = $this->get_first_lines($main_file, $this->max_header_lines);
     436
     437                $plugins_dir = @opendir( $dir );
     438                $plugin_files = array();
     439                if ( $plugins_dir ) {
     440                        while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
     441                                if ( '.' === substr( $file, 0, 1 ) ) {
     442                                        continue;
     443                                }
     444
     445                                if ( '.php' === substr( $file, -4 ) ) {
     446                                        $plugin_files[] = $file;
     447                                }
     448                        }
     449                        closedir( $plugins_dir );
     450                }
     451
     452                if ( empty( $plugin_files ) ) {
     453                        return false;
     454                }
     455
     456                $main_file = '';
     457                foreach ( $plugin_files as $plugin_file ) {
     458                        if ( ! is_readable( "$dir/$plugin_file" ) ) {
     459                                continue;
     460                        }
     461
     462                        $source = $this->get_first_lines( "$dir/$plugin_file", $this->max_header_lines );
     463
     464                        // Stop when we find a file with a plugin name header in it.
     465                        if ( $this->get_addon_header( 'Plugin Name', $source ) != false ) {
     466                                $main_file = "$dir/$plugin_file";
     467                                break;
     468                        }
     469                }
     470
     471                if ( empty( $main_file ) ) {
     472                        return false;
     473                }
    438474
    439475                $placeholders['version'] = $this->get_addon_header('Version', $source);
Note: See TracChangeset for help on using the changeset viewer.