Controller
2 weeks ago
Helper
2 years ago
Plugin.php
2 years ago
plugin.json
2 years ago
resmushit.class.php
2 weeks ago
resmushitUI.class.php
1 month ago
resmushitWPCLI.class.php
2 years ago
Plugin.php
82 lines
| 1 | <?php |
| 2 | namespace Resmush; |
| 3 | |
| 4 | use \Resmush\ShortPixelLogger\ShortPixelLogger as Log; |
| 5 | |
| 6 | use \Resmush\Controller\AdminController as AdminController; |
| 7 | use \Resmush\Controller\AjaxController as AjaxController; |
| 8 | use \Resmush\Controller\CronController as CronController; |
| 9 | use \Resmush\Controller\ProcessController as ProcessController; |
| 10 | |
| 11 | |
| 12 | use Resmush\FileSystem\Controller\FileSystemController as FileSystem; |
| 13 | |
| 14 | |
| 15 | |
| 16 | if (! defined('ABSPATH')) { |
| 17 | exit; // Exit if accessed directly. |
| 18 | } |
| 19 | |
| 20 | |
| 21 | // One day the basis of it all. |
| 22 | class Plugin |
| 23 | { |
| 24 | |
| 25 | protected static $instance; |
| 26 | |
| 27 | public function __construct() |
| 28 | { |
| 29 | // Regulare init after wp is loaded. This is fairly late. |
| 30 | add_action('wp_loaded', array($this, 'init')); |
| 31 | } |
| 32 | |
| 33 | public static function getInstance() |
| 34 | { |
| 35 | if (is_null(self::$instance)) |
| 36 | self::$instance = new Plugin(); |
| 37 | |
| 38 | return self::$instance; |
| 39 | } |
| 40 | |
| 41 | public function init() |
| 42 | { |
| 43 | $this->initHooks(); |
| 44 | |
| 45 | // All hooks init |
| 46 | AjaxController::getInstance(); |
| 47 | AdminController::getInstance(); |
| 48 | CronController::getInstance(); |
| 49 | ProcessController::getInstance(); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | public function initHooks() |
| 54 | { |
| 55 | |
| 56 | } |
| 57 | |
| 58 | public function fs() |
| 59 | { |
| 60 | return new FileSystem(); |
| 61 | } |
| 62 | |
| 63 | public function process() |
| 64 | { |
| 65 | return ProcessController::getInstance(); |
| 66 | } |
| 67 | |
| 68 | public static function checkLogger() |
| 69 | { |
| 70 | $log = Log::getInstance(); |
| 71 | if (Log::debugIsActive()) // upload dir can be expensive, so only do this when log is actually active. |
| 72 | { |
| 73 | $uploaddir = wp_upload_dir(null, false, false); |
| 74 | if (isset($uploaddir['basedir'])) |
| 75 | { |
| 76 | $log->setLogPath($uploaddir['basedir'] . "/resmushit.log"); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | } |
| 82 |