-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from moderntribe/fix/generate-htaccess
Generates a .htaccess file if missing in the WP root
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Functions for WordPress specific actions. | ||
*/ | ||
|
||
namespace Tribe\Test; | ||
|
||
/** | ||
* Generates a .htaccess file in the WP root if missing. | ||
*/ | ||
function maybe_generate_htaccess() { | ||
$htaccess_path = root( '_wordpress/.htaccess' ); | ||
$htaccess = file_get_contents( $htaccess_path ); | ||
|
||
if ( $htaccess ) { | ||
return; | ||
} | ||
|
||
$htaccess = <<< HTACCESS | ||
# BEGIN WordPress | ||
RewriteEngine On | ||
RewriteBase / | ||
RewriteRule ^index\.php$ - [L] | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule . /index.php [L] | ||
# END WordPress | ||
HTACCESS; | ||
|
||
file_put_contents( $htaccess_path, $htaccess ); | ||
} |
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