Skip to content

Instantly share code, notes, and snippets.

@soachishti
Created March 28, 2017 16:53
Show Gist options
  • Save soachishti/41c5ca35003c0d62bff62afca81a5410 to your computer and use it in GitHub Desktop.
Save soachishti/41c5ca35003c0d62bff62afca81a5410 to your computer and use it in GitHub Desktop.
Reset permission of all files and directory to 0755 - WordPress
<?php
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/public_html/'));
$files = array();
foreach ($rii as $file) {
if (!$file->isDir()) {
chmod($file->getPathname(), 0755);
}
else {
chmod($file->getPathname(), 0755);
}
}
$wp = array(
'/public_html/',
);
foreach ($wp as $site) {
echo "Processing $site ...\n";
chmod($site, 0755);
chmod($site . 'wp-includes', 0755);
chmod($site . 'wp-admin', 0755);
chmod($site . 'wp-admin/js', 0755);
chmod($site . 'wp-admin', 0755);
chmod($site . 'wp-content/themes', 0755);
chmod($site . 'wp-content/plugins', 0755);
chmod($site . 'wp-content', 0755);
chmod($site . 'wp-content/uploads', 0755);
chmod($site . 'wp-config.php', 0444);
chmod($site . '.htaccess', 0444);
}
echo "Done.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment