Changeset 25520
- Timestamp:
- 09/20/2013 07:12:45 PM (12 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
-
l10n.php (modified) (1 diff)
-
update.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/l10n.php
r25493 r25520 626 626 return $languages; 627 627 } 628 629 /** 630 * Get installed language data. 631 * 632 * Looks in the wp-content/languages directory for translations of 633 * plugins or themes. 634 * 635 * @since 3.7.0 636 * 637 * @param string $type What to search for. Accepts 'plugins', 'themes'. 638 * @return array Array of language data. 639 */ 640 function wp_get_installed_language_data( $type ) { 641 if ( $type !== 'themes' && $type !== 'plugins' ) 642 return array(); 643 644 if ( ! is_dir( WP_LANG_DIR ) || ! is_dir( WP_LANG_DIR . "/$type" ) ) 645 return array(); 646 647 $files = scandir( WP_LANG_DIR . "/$type" ); 648 if ( ! $files ) 649 return array(); 650 651 $language_data = array(); 652 653 foreach ( $files as $file ) { 654 if ( '.' === $file[0] || is_dir( $file ) ) 655 continue; 656 if ( substr( $file, -3 ) !== '.po' ) 657 continue; 658 if ( ! preg_match( '/(.*)-([A-Za-z_]{2,6}).po/', $file, $match ) ) 659 continue; 660 661 list( , $textdomain, $language ) = $match; 662 $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "/$type/$file" ); 663 } 664 return $language_data; 665 } 666 667 /** 668 * Extract headers from a PO file. 669 * 670 * @since 3.7.0 671 * 672 * @param string $po_file Path to PO file. 673 * @return array PO file headers. 674 */ 675 function wp_get_pomo_file_data( $po_file ) { 676 $headers = get_file_data( $po_file, array( 677 'POT-Creation-Date' => '"POT-Creation-Date', 678 'PO-Revision-Date' => '"PO-Revision-Date', 679 'Project-Id-Version' => '"Project-Id-Version', 680 'X-Generator' => '"X-Generator', 681 ) ); 682 foreach ( $headers as &$header ) { 683 // Remove possible contextual '\n' and closing double quote. 684 $header = preg_replace( '~(\\\n)?"$~', '', $header ); 685 } 686 return $headers; 687 } -
trunk/src/wp-includes/update.php
r25514 r25520 147 147 148 148 $plugins = get_plugins(); 149 $languages = wp_get_installed_language_data( 'plugins' ); 150 149 151 $active = get_option( 'active_plugins', array() ); 150 152 $current = get_site_transient( 'update_plugins' ); … … 201 203 $options = array( 202 204 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), 203 'body' => array( 'plugins' => json_encode( $to_send ) ),205 'body' => array( 'plugins' => json_encode( $to_send ), 'languages' => json_encode( $languages ) ), 204 206 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 205 207 ); … … 244 246 245 247 $installed_themes = wp_get_themes(); 248 $languages = wp_get_installed_language_data( 'themes' ); 249 246 250 $last_update = get_site_transient( 'update_themes' ); 247 251 if ( ! is_object($last_update) ) … … 311 315 $options = array( 312 316 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), 313 'body' => array( 'themes' => json_encode( $request ) ),317 'body' => array( 'themes' => json_encode( $request ), 'languages' => json_encode( $languages ) ), 314 318 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 315 319 );
Note: See TracChangeset
for help on using the changeset viewer.