<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29856] trunk/src: Language packs: Remove translations when deleting a theme or a plugin.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/29856">29856</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/29856","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>ocean90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-10-08 19:04:05 +0000 (Wed, 08 Oct 2014)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Language packs: Remove translations when deleting a theme or a plugin.
This is for translation files in WP_LANG_DIR which are installed through a language pack.
Change `wp_get_installed_translations()` to only return a translation if the .mo file also exists.
fixes <a href="https://core.trac.wordpress.org/ticket/29860">#29860</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludespluginphp">trunk/src/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunksrcwpadminincludesthemephp">trunk/src/wp-admin/includes/theme.php</a></li>
<li><a href="#trunksrcwpadminnetworkthemesphp">trunk/src/wp-admin/network/themes.php</a></li>
<li><a href="#trunksrcwpadminpluginsphp">trunk/src/wp-admin/plugins.php</a></li>
<li><a href="#trunksrcwpincludesl10nphp">trunk/src/wp-includes/l10n.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludespluginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin.php 2014-10-08 15:11:14 UTC (rev 29855)
+++ trunk/src/wp-admin/includes/plugin.php 2014-10-08 19:04:05 UTC (rev 29856)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -797,29 +797,50 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Get the base plugin folder
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Get the base plugin folder.
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugins_dir = $wp_filesystem->wp_plugins_dir();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty($plugins_dir) )
- return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $plugins_dir ) ) {
+ return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $plugins_dir = trailingslashit( $plugins_dir );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translations_dir = $wp_filesystem->wp_lang_dir();
+ $translations_dir = trailingslashit( $translations_dir );
+
+ $plugin_translations = wp_get_installed_translations( 'plugins' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $errors = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach( $plugins as $plugin_file ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Run Uninstall hook
- if ( is_uninstallable_plugin( $plugin_file ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Run Uninstall hook.
+ if ( is_uninstallable_plugin( $plugin_file ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> uninstall_plugin($plugin_file);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // If plugin is in its own directory, recursively delete the directory.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
- $deleted = $wp_filesystem->delete($this_plugin_dir, true);
- else
- $deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
+ $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
+ } else {
+ $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $deleted )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $deleted ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $errors[] = $plugin_file;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ continue;
+ }
+
+ // Remove language files, silently.
+ $plugin_slug = dirname( $plugin_file );
+ if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
+ $translations = $plugin_translations[ $plugin_slug ];
+
+ foreach ( $translations as $translation => $data ) {
+ $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
+ $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Remove deleted plugins from the plugin updates list.
</span></span></pre></div>
<a id="trunksrcwpadminincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/theme.php 2014-10-08 15:11:14 UTC (rev 29855)
+++ trunk/src/wp-admin/includes/theme.php 2014-10-08 19:04:05 UTC (rev 29856)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -55,21 +55,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Get the base plugin folder
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Get the base plugin folder.
</ins><span class="cx" style="display: block; padding: 0 10px"> $themes_dir = $wp_filesystem->wp_themes_dir();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty($themes_dir) )
- return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $themes_dir ) ) {
+ return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $themes_dir = trailingslashit( $themes_dir );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $theme_dir = trailingslashit($themes_dir . $stylesheet);
- $deleted = $wp_filesystem->delete($theme_dir, true);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $theme_dir = trailingslashit( $themes_dir . $stylesheet );
+ $deleted = $wp_filesystem->delete( $theme_dir, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $deleted )
- return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $deleted ) {
+ return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Force refresh of theme update information
- delete_site_transient('update_themes');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translations_dir = $wp_filesystem->wp_lang_dir();
+ $translations_dir = trailingslashit( $translations_dir );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $theme_translations = wp_get_installed_translations( 'themes' );
+
+ // Remove language files, silently.
+ if ( ! empty( $theme_translations[ $stylesheet ] ) ) {
+ $translations = $theme_translations[ $stylesheet ];
+
+ foreach ( $translations as $translation => $data ) {
+ $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
+ $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
+ }
+ }
+
+ // Force refresh of theme update information.
+ delete_site_transient( 'update_themes' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminnetworkthemesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/network/themes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/network/themes.php 2014-10-08 15:11:14 UTC (rev 29855)
+++ trunk/src/wp-admin/network/themes.php 2014-10-08 19:04:05 UTC (rev 29856)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,8 +96,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require_once(ABSPATH . 'wp-admin/admin-footer.php');
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'delete-selected':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can( 'delete_themes' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'delete_themes' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( __('You do not have sufficient permissions to delete themes for this site.') );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'bulk-themes' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,9 +117,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $files_to_delete = $theme_info = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $theme_translations = wp_get_installed_translations( 'themes' );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $themes as $key => $theme ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_info[ $theme ] = wp_get_theme( $theme );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $files_to_delete = array_merge( $files_to_delete, list_files( $theme_info[ $theme ]->get_stylesheet_directory() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Locate all the files in that folder.
+ $files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() );
+ if ( $files ) {
+ $files_to_delete = array_merge( $files_to_delete, $files );
+ }
+
+ // Add translation files.
+ $theme_slug = $theme_info[ $theme ]->get_stylesheet();
+ if ( ! empty( $theme_translations[ $theme_slug ] ) ) {
+ $translations = $theme_translations[ $theme_slug ];
+
+ foreach ( $translations as $translation => $data ) {
+ $files_to_delete[] = $theme_slug . '-' . $translation . '.po';
+ $files_to_delete[] = $theme_slug . '-' . $translation . '.mo';
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> include(ABSPATH . 'wp-admin/update.php');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,16 +155,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This theme may be active on other sites in the network.', 'These themes may be active on other sites in the network.', $themes_to_delete ); ?></p></div>
</span><span class="cx" style="display: block; padding: 0 10px"> <p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> <ul class="ul-disc">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php foreach ( $theme_info as $theme )
- echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>'; /* translators: 1: theme name, 2: theme author */ ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+ foreach ( $theme_info as $theme ) {
+ /* translators: 1: theme name, 2: theme author */
+ echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>';
+ }
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </ul>
</span><span class="cx" style="display: block; padding: 0 10px"> <p><?php _e('Are you sure you wish to delete these themes?'); ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="verify-delete" value="1" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="action" value="delete-selected" />
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array) $themes as $theme )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $themes as $theme ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php wp_nonce_field('bulk-themes') ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -158,8 +182,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="files-list" style="display:none;">
</span><span class="cx" style="display: block; padding: 0 10px"> <ul class="code">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array) $files_to_delete as $file )
- echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . "/themes", '', $file) ) . '</li>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $files_to_delete as $file ) {
+ echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . '/themes', '', $file ) ) . '</li>';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </ul>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span></span></pre></div>
<a id="trunksrcwpadminpluginsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugins.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugins.php 2014-10-08 15:11:14 UTC (rev 29855)
+++ trunk/src/wp-admin/plugins.php 2014-10-08 19:04:05 UTC (rev 29856)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,8 +207,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'delete-selected':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! current_user_can('delete_plugins') )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can('delete_plugins') ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer('bulk-plugins');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,30 +238,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> $files_to_delete = $plugin_info = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $have_non_network_plugins = false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugin_translations = wp_get_installed_translations( 'plugins' );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $plugins as $plugin ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '.' == dirname($plugin) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $plugin_slug = dirname( $plugin );
+
+ if ( '.' == $plugin_slug ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $plugin_info[ $plugin ] = $data;
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $plugin_info[ $plugin ]['Network'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $plugin_info[ $plugin ]['Network'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $have_non_network_plugins = true;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Locate all the files in that folder
- $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Locate all the files in that folder.
+ $files = list_files( WP_PLUGIN_DIR . '/' . $plugin_slug );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $files ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $files_to_delete = array_merge($files_to_delete, $files);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $files_to_delete = array_merge( $files_to_delete, $files );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Get plugins list from that folder
- if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Get plugins list from that folder.
+ if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach( $folder_plugins as $plugin_file => $data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $plugin_info[ $plugin_file ]['Network'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $have_non_network_plugins = true;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Add translation files.
+ if ( ! empty( $plugin_translations[ $plugin_slug ] ) ) {
+ $translations = $plugin_translations[ $plugin_slug ];
+
+ foreach ( $translations as $translation => $data ) {
+ $files_to_delete[] = $plugin_slug . '-' . $translation . '.po';
+ $files_to_delete[] = $plugin_slug . '-' . $translation . '.mo';
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $plugins_to_delete = count( $plugin_info );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,8 +312,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="verify-delete" value="1" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" name="action" value="delete-selected" />
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array) $plugins as $plugin )
- echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $plugins as $plugin ) {
+ echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php wp_nonce_field('bulk-plugins') ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -309,8 +327,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="files-list" style="display:none;">
</span><span class="cx" style="display: block; padding: 0 10px"> <ul class="code">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array)$files_to_delete as $file )
- echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $files_to_delete as $file ) {
+ echo '<li>' . esc_html( str_replace( WP_PLUGIN_DIR, '', $file ) ) . '</li>';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </ul>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span></span></pre></div>
<a id="trunksrcwpincludesl10nphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/l10n.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/l10n.php 2014-10-08 15:11:14 UTC (rev 29855)
+++ trunk/src/wp-includes/l10n.php 2014-10-08 19:04:05 UTC (rev 29856)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -797,16 +797,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $language_data = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $files as $file ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '.' === $file[0] || is_dir( $file ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( '.' === $file[0] || is_dir( $file ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( substr( $file, -3 ) !== '.po' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+ if ( substr( $file, -3 ) !== '.po' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+ if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+ if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) {
+ continue;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> list( , $textdomain, $language ) = $match;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '' === $textdomain )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( '' === $textdomain ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $textdomain = 'default';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $language_data;
</span></span></pre>
</div>
</div>
</body>
</html>