Ticket #18200: lp.diff
| File lp.diff, 12.1 KB (added by dd32, 15 months ago) |
|---|
-
wp-includes/l10n.php
540 540 } 541 541 542 542 return $languages; 543 } 544 545 function get_translation_file_data( $file ) { 546 // Just incase someone calls with the machine file instead of the textual version 547 $file = preg_replace( '!\.mo$!i', '.po', $file ); 548 549 // Lets just assume that it's within the WP_LANG_DIR for now 550 // if we keep track of the loaded text domains later, we can probably include a lookup for the location of the files instead. 551 $data = get_file_data( WP_LANG_DIR . '/' . $file, 552 array( 553 'date' => '"PO-Revision-Date', 554 'generator' => '"X-Generator', 555 'project-id' => '"Project-Id-Version' 556 ) 557 ); 558 559 // Strip the .po field endings off the values, which may, or may not, include a textual \n 560 foreach ( (array)$data as $key => $value ) 561 $data[$key] = preg_replace( '!(\\\n)?"$!', '', $value); 562 563 return $data; 543 564 } 565 No newline at end of file -
wp-admin/includes/update.php
232 232 return $update_themes; 233 233 } 234 234 235 function get_language_updates() { 236 237 //$current = get_site_transient('update_languages'); 238 // Uh ...Lets just hard code this for now. 239 240 return array( 241 (object)array( 242 'type' => 'core', 243 'lang' => 'de_DE', // The language it is.. This isn't currently used anywhere 244 'version' => '2012-02-18 08:48:04', // New Version - Nothing looks at this either. 245 'package' => 'http://tools.dd32.id.au/wordpress/core-downloads/core-de_DE.zip' 246 ), 247 (object)array( 248 'type' => 'plugin', // The type of the upgrade, 'plugin' or 'theme' will throw files into that folder, any other name (ie. 'core') is thrown into WP_LANG_DIR.. 249 'slug' => 'akismet', // not used. 250 'for' => 'akismet/akismet.php', // again, not used yet. 251 'lang' => 'de_DE', 252 'version' => '2012-02-18 08:48:04', 253 'package' => 'http://tools.dd32.id.au/wordpress/core-downloads/akismet-de_DE.zip' 254 ), 255 (object)array( 256 'type' => 'theme', 257 'slug' => 'twentytwelve', 258 'lang' => 'de_DE', 259 'version' => '2012-02-18 08:48:04', 260 'package' => 'http://tools.dd32.id.au/wordpress/core-downloads/twentytwelve-de_DE.zip' // And no, this isn't a translation of 2012, I believe it's a out of date Core set. 261 ) 262 ); 263 } 264 235 265 function wp_update_theme($theme, $feedback = '') { 236 266 if ( !empty($feedback) ) 237 267 add_filter('update_feedback', $feedback); -
wp-admin/includes/class-wp-upgrader.php
165 165 function install_package($args = array()) { 166 166 global $wp_filesystem; 167 167 $defaults = array( 'source' => '', 'destination' => '', //Please always pass these 168 'clear_destination' => false, 'clear_working' => false, 168 'clear_destination' => false, 'clear_working' => false, 'abort_if_destination_exists' => true, 169 169 'hook_extra' => array()); 170 170 171 171 $args = wp_parse_args($args, $defaults); … … 224 224 return $removed; 225 225 else if ( ! $removed ) 226 226 return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); 227 } elseif ( $ wp_filesystem->exists($remote_destination) ) {227 } elseif ( $abort_if_destination_exists && $wp_filesystem->exists($remote_destination) ) { 228 228 //If we're not clearing the destination folder and something exists there already, Bail. 229 229 //But first check to see if there are actually any files in the folder. 230 230 $_files = $wp_filesystem->dirlist($remote_destination); … … 272 272 $defaults = array( 'package' => '', //Please always pass this. 273 273 'destination' => '', //And this 274 274 'clear_destination' => false, 275 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please 275 276 'clear_working' => true, 276 277 'is_multi' => false, 277 278 'hook_extra' => array() //Pass any extra $hook_extra args here, this will be passed to any hooked filters. … … 318 319 'source' => $working_dir, 319 320 'destination' => $destination, 320 321 'clear_destination' => $clear_destination, 322 'abort_if_destination_exists' => $abort_if_destination_exists, 321 323 'clear_working' => $clear_working, 322 324 'hook_extra' => $hook_extra 323 325 ) ); … … 410 412 if ( ! $this->result || is_wp_error($this->result) ) 411 413 return $this->result; 412 414 415 do_action( 'upgrader_process_complete', $this, 'install-plugin', $package ); 416 413 417 // Force refresh of plugin update information 414 418 delete_site_transient('update_plugins'); 415 419 … … 454 458 if ( ! $this->result || is_wp_error($this->result) ) 455 459 return $this->result; 456 460 461 do_action( 'upgrader_process_complete', $this, 'update-plugin', $plugin ); 462 457 463 // Force refresh of plugin update information 458 464 delete_site_transient('update_plugins'); 459 465 } … … 535 541 // Cleanup our hooks, in case something else does a upgrade on this connection. 536 542 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin')); 537 543 544 do_action( 'upgrader_process_complete', $this, 'bulk-upgrade-plugins', $plugins ); 545 538 546 // Force refresh of plugin update information 539 547 delete_site_transient('update_plugins'); 540 548 … … 685 693 if ( ! $this->result || is_wp_error($this->result) ) 686 694 return $this->result; 687 695 696 do_action( 'upgrader_process_complete', $this, 'install-theme', $package ); 697 688 698 // Force refresh of theme update information 689 699 delete_site_transient('update_themes'); 690 700 … … 731 741 if ( ! $this->result || is_wp_error($this->result) ) 732 742 return $this->result; 733 743 744 do_action( 'upgrader_process_complete', $this, 'upgrade-theme', $theme ); 745 734 746 // Force refresh of theme update information 735 747 delete_site_transient('update_themes'); 736 748 … … 818 830 remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); 819 831 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); 820 832 833 do_action( 'upgrader_process_complete', $this, 'bulk-upgrade-themes', $themes ); 834 821 835 // Force refresh of theme update information 822 836 delete_site_transient('update_themes'); 823 837 … … 985 999 986 1000 require(ABSPATH . 'wp-admin/includes/update-core.php'); 987 1001 1002 // @TODO: Add the upgrader_process_complete bizzo here somewhere 988 1003 return update_core($working_dir, $wp_dir); 989 1004 } 990 1005 991 1006 } 992 1007 1008 // This be before "Plugin updated successfully", next new action is afterwards. 1009 // add_filter( 'upgrader_post_install', '_lp_kickoff', 5, 4); 1010 // function _lp_kickoff( $success, $hook_extra, $omething, $upgrader ); 1011 1012 add_action( 'upgrader_process_complete', '_lp_kickfoff', 5, 3); // This is after the "Plugin Udated.. actions.." line. 1013 function _lp_kickfoff( $upgrader, $context, $package ) { 1014 // Don't do Language updates on language updates on language updates.. 1015 if ( $upgrader instanceof Language_Pack_Upgrader ) 1016 return; 1017 1018 echo '<!-- start languages --><div style="padding-left: 3em; border-left: 5px solid grey">'; 1019 1020 $lp_upgrader = new Language_Pack_Upgrader( new Language_Pack_Skin() ); 1021 1022 $lp_upgrader->upgrade(); 1023 1024 echo '</div><!-- end of languages -->'; 1025 } 1026 1027 class Language_Pack_Skin extends WP_Upgrader_Skin { 1028 function before() {} 1029 function after() {} 1030 function header() {} 1031 function footer() {} 1032 } 1033 1034 class Language_Pack_Upgrader extends WP_Upgrader { 1035 1036 var $result; 1037 var $bulk = false; 1038 1039 function __construct( $skin, $main_upgrader ) { 1040 parent::__construct($skin); 1041 } 1042 1043 function upgrade_strings() { 1044 $this->strings['up_to_date'] = __('The language is up to date.'); // We need to silently skip this case 1045 $this->strings['no_package'] = __('Update package not available.'); 1046 $this->strings['downloading_package'] = __('Downloading language update from <span class="code">%s</span>…'); 1047 $this->strings['unpack_package'] = __('Unpacking the update…'); 1048 $this->strings['remove_old'] = __('Removing the old version of the language…'); 1049 $this->strings['remove_old_failed'] = __('Could not remove the old language.'); 1050 $this->strings['process_failed'] = __('Language update failed.'); 1051 $this->strings['process_success'] = __('Language updated successfully.'); 1052 } 1053 1054 /* // Not yet implemented or used, Bulk Upgrade below will bulk update/install any new languages, probably don't need a specific install method. 1055 function install_strings() { 1056 $this->strings['no_package'] = __('Install package not available.'); 1057 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); 1058 $this->strings['unpack_package'] = __('Unpacking the package…'); 1059 $this->strings['installing_package'] = __('Installing the language…'); 1060 $this->strings['process_failed'] = __('Language install failed.'); 1061 $this->strings['process_success'] = __('Language installed successfully.'); 1062 } 1063 1064 function install() { 1065 return $this->bulk_upgrade(); 1066 }*/ 1067 1068 function upgrade() { 1069 return $this->bulk_upgrade(); 1070 } 1071 1072 function bulk_upgrade() { 1073 1074 $this->init(); 1075 $this->bulk = true; 1076 $this->upgrade_strings(); 1077 1078 $language_updates = get_language_updates(); 1079 1080 if ( empty($language_updates) ) 1081 return true; 1082 1083 $this->skin->feedback( 'Doing the Language Dance, Oooh yeah.' ); 1084 1085 add_filter('upgrader_source_selection', array(&$this, 'check_package'), 10, 3 ); 1086 1087 //$this->skin->header(); 1088 1089 // Connect to the Filesystem first. 1090 $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_LANG_DIR) ); 1091 if ( ! $res ) { 1092 $this->skin->footer(); 1093 return false; 1094 } 1095 1096 // ..When do we need to start maintainence mode? 1097 //$this->maintenance_mode(true); 1098 1099 $results = array(); 1100 1101 $this->update_count = count($language_updates); 1102 $this->update_current = 0; 1103 foreach ( $language_updates as $language_update ) { 1104 1105 $destination = WP_LANG_DIR; 1106 if ( 'plugin' == $language_update->type ) { 1107 $destination .= '/plugins'; 1108 } elseif ( 'theme' == $language_update->type ) { 1109 $destination .= '/themes'; 1110 } 1111 1112 $this->update_current++; 1113 1114 $options = array( 1115 'package' => $language_update->package, 1116 'destination' => $destination, 1117 'clear_destination' => false, 1118 'abort_if_destination_exists' => false, // We expect the destination to exist. 1119 'clear_working' => true, 1120 'is_multi' => true, 1121 'hook_extra' => array( 1122 'language_update_type' => $language_update->type, 1123 'language_update' => $language_update, 1124 ) 1125 ); 1126 1127 $result = $this->run($options); 1128 1129 $results[] = $this->result; 1130 1131 // Prevent credentials auth screen from displaying multiple times 1132 if ( false === $result ) 1133 break; 1134 } //end foreach $language_updates 1135 1136 //$this->maintenance_mode(false); 1137 1138 // Cleanup our hooks, in case something else does a upgrade on this connection. 1139 remove_filter('upgrader_source_selection', array(&$this, 'check_package'), 10, 2 ); 1140 1141 // Force refresh of language update information 1142 delete_site_transient('update_languages'); 1143 1144 return $results; 1145 } 1146 1147 function check_package( $source, $remote_source ) { 1148 global $wp_filesystem; 1149 1150 if ( is_wp_error($source) ) 1151 return $source; 1152 1153 // Check the folder contains a valid language 1154 $files = $wp_filesystem->dirlist( $remote_source ); 1155 1156 // Check to see if a .po and .mo exist in the folder.. check they're named right? 1157 $po = $mo = false; 1158 foreach ( (array)$files as $file => $filedata ) { 1159 if ( '.po' == substr( $file, -3) ) 1160 $po = true; 1161 elseif ( '.mo' == substr($file, -3) ) 1162 $mo = true; 1163 } 1164 1165 if ( ! $mo || ! $po ) 1166 return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __( 'The language pack is missing either the <code>.po</code> or <code>.mo</code> files.' ) ); 1167 1168 return $source; 1169 } 1170 1171 } 1172 993 1173 /** 994 1174 * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes. 995 1175 *
