-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed model controller and init the classes in main plugin file
Added some comments to code
- Loading branch information
Andreas Ek
committed
Jan 5, 2016
1 parent
af2c105
commit 39ef57c
Showing
7 changed files
with
106 additions
and
54 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,60 @@ | ||
<?php | ||
namespace Bladerunner; | ||
|
||
/** | ||
* Initialize the plugin inside WordPress wp-admin to check for errors | ||
*/ | ||
class Init { | ||
|
||
protected $cache; | ||
|
||
function __construct() { | ||
$this->cache = Template::cache(); | ||
add_action( 'admin_init', [ $this, 'check_writeable_upload' ] ); | ||
} | ||
|
||
/** | ||
* Check if the cache folder exists and is writable and assigns admin notice if not | ||
* @return void | ||
*/ | ||
static function check_writeable_upload() { | ||
|
||
if( !file_exists( $this->cache ) ) { | ||
add_action( 'admin_notices', [ $this, 'notice_create_cache' ] ); | ||
} | ||
else { | ||
|
||
$is_writable = @file_put_contents( $this->cache . '/.folder_writable', "true" ); | ||
if( !$is_writable ) { | ||
add_action( 'admin_notices', [ $this, 'notice_writable_cache' ] ); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
/** | ||
* Echo admin notice inside wp-admin if cache folder doesnt exist. | ||
* @return void | ||
*/ | ||
static function notice_create_cache() { | ||
echo '<div class="error"> '; | ||
echo '<p><strong>Cache folder missing</strong></p>'; | ||
echo '<p>Bladerunner needs a .cache -folder in uploads. Please create the folder and make it writable!</p>'; | ||
echo '<p>Eg, <i>mkdir ' . $this->cache . '</i></p>'; | ||
echo '</div>'; | ||
} | ||
|
||
/** | ||
* Echo admin notice inside wp-admin if cache folder not writable. | ||
* @return void | ||
*/ | ||
static function notice_writable_cache() { | ||
echo '<div class="error"> '; | ||
echo '<p><strong>Cache not writable</strong></p>'; | ||
echo '<p>Bladerunner cache folder .cache in uploads not writable. Please make the folder writable for your web server!</p>'; | ||
echo '<p>Eg, <i>chmod -R 777 ' . $this->cache . '</i></p>'; | ||
echo '</div>'; | ||
} | ||
|
||
} |
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