On some servers when you are trying to add/delete plugins using "Upgrade Automatically" option (via ftp) you might be notified with following message:
Upgrade Plugin
Unable to locate WordPress Content directory (wp-content).
The reason for this is that the ftp client is not allowed to access the path defined as absolute path (ABSPATH) in wordpress configuration. More details can about this problem can be found in this post http://wordpress-hints.blogspot.com/2011/01/upgrade-wordpress-unable-to-locate.html .
The workaround can be applied to WP_Filesystem_Base->search_for_folder() method (function). This function is called when the wp-content dir or wp-content plugins folder is not found.
In described situation search_for_folder() function will not find the folder since it can not access the wp-content folder passed as parameter, but we can cheat this function a little bit to force searching for correct folder.
In described situation search_for_folder() function will not find the folder since it can not access the wp-content folder passed as parameter, but we can cheat this function a little bit to force searching for correct folder.
- login with ftp to your server and edit file: wp-admin/includes/class-wp-filesystem-base.php
- in this file look for method (search_for_folder) and add following code at the beginning of the function :
if ($folder == WP_CONTENT_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content';
echo 'search_for_folder: path for '. WP_CONTENT_DIR .' changed from to '. $folder .' <br>';
}
if ($folder == WP_PLUGIN_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content/plugins';
echo 'search_for_folder: path for '. WP_PLUGIN_DIR .' changed from to '. $folder .' <br>';
}
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content';
echo 'search_for_folder: path for '. WP_CONTENT_DIR .' changed from to '. $folder .' <br>';
}
if ($folder == WP_PLUGIN_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content/plugins';
echo 'search_for_folder: path for '. WP_PLUGIN_DIR .' changed from to '. $folder .' <br>';
}
After the fix you should have something like:
(...)
function search_for_folder($folder, $base = '.', $loop = false ) {
if ($folder == WP_CONTENT_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content';
echo 'search_for_folder: path for '. WP_CONTENT_DIR .' changed from to '. $folder .' <br>';
}
if ($folder == WP_PLUGIN_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content/plugins';
echo 'search_for_folder: path for '. WP_PLUGIN_DIR .' changed from to '. $folder .' <br>';
}
if ( empty( $base ) || '.' == $base )
$base = trailingslashit($this->cwd());
(...)
if ($folder == WP_CONTENT_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content';
echo 'search_for_folder: path for '. WP_CONTENT_DIR .' changed from to '. $folder .' <br>';
}
if ($folder == WP_PLUGIN_DIR) {
$folder = '/PUT/HERE/YOUR/FTP/PATH/wp-content/plugins';
echo 'search_for_folder: path for '. WP_PLUGIN_DIR .' changed from to '. $folder .' <br>';
}
if ( empty( $base ) || '.' == $base )
$base = trailingslashit($this->cwd());
(...)
In above examples you should replace the /PUT/HERE/YOUR/FTP/PATH to your ftp dir where the wordpress is installed (change it to path pointing to wordpress root directory on ftp).
Now you can add / upgrade / remove plugins. On screen you should see the messages "search_for_folder: path for XXX (which is dir on webserver) changed from to XXX (which is dir on ftp).
Brak komentarzy:
Prześlij komentarz