Last active
August 29, 2015 14:07
-
-
Save saaiful/37e4406667a0a08f1d7d to your computer and use it in GitHub Desktop.
Theme and Plugins Folder Direct Access Deny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Theme and Plugins Folder Direct Access Deny | |
Plugin URI: htp://saiful.im/ | |
Description: WordPress Theme and Plugins Folder Direct Access Deny | |
Author: Saiful Islam | |
Version: 0.0.2 | |
Author URI: http://saiful.im/ | |
*/ | |
function bugFixactivate(){ | |
$rule = ' | |
<Files /index.php> | |
Order Allow,Deny | |
Allow from all | |
</Files> | |
<FilesMatch ".*\.(php)$"> | |
deny from all | |
</FilesMatch> | |
ErrorDocument 404 /index.php?error=404 | |
ErrorDocument 403 /index.php?error=404 | |
'; | |
@file_put_contents(__DIR__."/../themes/.htaccess", $rule); | |
@file_put_contents(__DIR__."/../plugins/.htaccess", $rule); | |
@file_put_contents(__DIR__."/../../wp-content/.htaccess", $rule); | |
@file_put_contents(__DIR__."/../../wp-admin/includes/.htaccess", $rule); | |
} | |
function bugFixdeactivation(){ | |
if(file_exists(__DIR__.'/../themes/.htaccess')) | |
{ | |
@unlink(__DIR__."/../themes/.htaccess"); | |
} | |
if(file_exists(__DIR__."/../../wp-content/.htaccess")) | |
{ | |
@unlink(__DIR__."/../../wp-content/.htaccess"); | |
} | |
if(file_exists(__DIR__."/../../wp-content/.htaccess")) | |
{ | |
@unlink(__DIR__."/../../wp-content/.htaccess"); | |
} | |
if(file_exists(__DIR__."/../../wp-admin/includes/.htaccess")) | |
{ | |
@unlink(__DIR__."/../../wp-admin/includes/.htaccess"); | |
} | |
} | |
register_activation_hook( __FILE__ , 'bugFixactivate' ); | |
register_deactivation_hook( __FILE__ , 'bugFixdeactivation'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment