wp/wp-admin/includes/class-language-pack-upgrader.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   109 	 *
   109 	 *
   110 	 * @since 3.7.0
   110 	 * @since 3.7.0
   111 	 */
   111 	 */
   112 	public function upgrade_strings() {
   112 	public function upgrade_strings() {
   113 		$this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
   113 		$this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
   114 		$this->strings['up_to_date']       = __( 'The translations are up to date.' );
   114 		$this->strings['up_to_date']       = __( 'Your translations are all up to date.' );
   115 		$this->strings['no_package']       = __( 'Update package not available.' );
   115 		$this->strings['no_package']       = __( 'Update package not available.' );
   116 		/* translators: %s: package URL */
   116 		/* translators: %s: Package URL. */
   117 		$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s&#8230;' ), '<span class="code">%s</span>' );
   117 		$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s&#8230;' ), '<span class="code">%s</span>' );
   118 		$this->strings['unpack_package']      = __( 'Unpacking the update&#8230;' );
   118 		$this->strings['unpack_package']      = __( 'Unpacking the update&#8230;' );
   119 		$this->strings['process_failed']      = __( 'Translation update failed.' );
   119 		$this->strings['process_failed']      = __( 'Translation update failed.' );
   120 		$this->strings['process_success']     = __( 'Translation updated successfully.' );
   120 		$this->strings['process_success']     = __( 'Translation updated successfully.' );
   121 		$this->strings['remove_old']          = __( 'Removing the old version of the translation&#8230;' );
   121 		$this->strings['remove_old']          = __( 'Removing the old version of the translation&#8230;' );
   186 			$this->skin->bulk_footer();
   186 			$this->skin->bulk_footer();
   187 			$this->skin->footer();
   187 			$this->skin->footer();
   188 			return true;
   188 			return true;
   189 		}
   189 		}
   190 
   190 
   191 		if ( 'upgrader_process_complete' == current_filter() ) {
   191 		if ( 'upgrader_process_complete' === current_filter() ) {
   192 			$this->skin->feedback( 'starting_upgrade' );
   192 			$this->skin->feedback( 'starting_upgrade' );
   193 		}
   193 		}
   194 
   194 
   195 		// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230
   195 		// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230.
   196 		remove_all_filters( 'upgrader_pre_install' );
   196 		remove_all_filters( 'upgrader_pre_install' );
   197 		remove_all_filters( 'upgrader_clear_destination' );
   197 		remove_all_filters( 'upgrader_clear_destination' );
   198 		remove_all_filters( 'upgrader_post_install' );
   198 		remove_all_filters( 'upgrader_post_install' );
   199 		remove_all_filters( 'upgrader_source_selection' );
   199 		remove_all_filters( 'upgrader_source_selection' );
   200 
   200 
   201 		add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 );
   201 		add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 );
   202 
   202 
   203 		$this->skin->header();
   203 		$this->skin->header();
   204 
   204 
   205 		// Connect to the Filesystem first.
   205 		// Connect to the filesystem first.
   206 		$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
   206 		$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
   207 		if ( ! $res ) {
   207 		if ( ! $res ) {
   208 			$this->skin->footer();
   208 			$this->skin->footer();
   209 			return false;
   209 			return false;
   210 		}
   210 		}
   230 		foreach ( $language_updates as $language_update ) {
   230 		foreach ( $language_updates as $language_update ) {
   231 
   231 
   232 			$this->skin->language_update = $language_update;
   232 			$this->skin->language_update = $language_update;
   233 
   233 
   234 			$destination = WP_LANG_DIR;
   234 			$destination = WP_LANG_DIR;
   235 			if ( 'plugin' == $language_update->type ) {
   235 			if ( 'plugin' === $language_update->type ) {
   236 				$destination .= '/plugins';
   236 				$destination .= '/plugins';
   237 			} elseif ( 'theme' == $language_update->type ) {
   237 			} elseif ( 'theme' === $language_update->type ) {
   238 				$destination .= '/themes';
   238 				$destination .= '/themes';
   239 			}
   239 			}
   240 
   240 
   241 			$this->update_current++;
   241 			$this->update_current++;
   242 
   242 
   330 
   330 
   331 		// Check that the folder contains a valid language.
   331 		// Check that the folder contains a valid language.
   332 		$files = $wp_filesystem->dirlist( $remote_source );
   332 		$files = $wp_filesystem->dirlist( $remote_source );
   333 
   333 
   334 		// Check to see if a .po and .mo exist in the folder.
   334 		// Check to see if a .po and .mo exist in the folder.
   335 		$po = $mo = false;
   335 		$po = false;
       
   336 		$mo = false;
   336 		foreach ( (array) $files as $file => $filedata ) {
   337 		foreach ( (array) $files as $file => $filedata ) {
   337 			if ( '.po' == substr( $file, -3 ) ) {
   338 			if ( '.po' === substr( $file, -3 ) ) {
   338 				$po = true;
   339 				$po = true;
   339 			} elseif ( '.mo' == substr( $file, -3 ) ) {
   340 			} elseif ( '.mo' === substr( $file, -3 ) ) {
   340 				$mo = true;
   341 				$mo = true;
   341 			}
   342 			}
   342 		}
   343 		}
   343 
   344 
   344 		if ( ! $mo || ! $po ) {
   345 		if ( ! $mo || ! $po ) {
   366 	 * @return string The name of the item being updated.
   367 	 * @return string The name of the item being updated.
   367 	 */
   368 	 */
   368 	public function get_name_for_update( $update ) {
   369 	public function get_name_for_update( $update ) {
   369 		switch ( $update->type ) {
   370 		switch ( $update->type ) {
   370 			case 'core':
   371 			case 'core':
   371 				return 'WordPress'; // Not translated
   372 				return 'WordPress'; // Not translated.
   372 
   373 
   373 			case 'theme':
   374 			case 'theme':
   374 				$theme = wp_get_theme( $update->slug );
   375 				$theme = wp_get_theme( $update->slug );
   375 				if ( $theme->exists() ) {
   376 				if ( $theme->exists() ) {
   376 					return $theme->Get( 'Name' );
   377 					return $theme->Get( 'Name' );