| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImageOptimization\Modules\Connect; |
| 4 |
|
| 5 |
use ImageOptimization\Classes\Module_Base; |
| 6 |
use ImageOptimization\Modules\Connect\Classes\{ |
| 7 |
Data, |
| 8 |
Utils, |
| 9 |
}; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Class Module |
| 17 |
*/ |
| 18 |
class Module extends Module_Base { |
| 19 |
|
| 20 |
/** |
| 21 |
* Get module name. |
| 22 |
* Retrieve the module name. |
| 23 |
* @access public |
| 24 |
* @return string Module name. |
| 25 |
*/ |
| 26 |
public function get_name() { |
| 27 |
return 'connect'; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* component_list |
| 32 |
* @return string[] |
| 33 |
*/ |
| 34 |
public static function component_list() : array { |
| 35 |
return [ |
| 36 |
'Handler', |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* routes_list |
| 42 |
* @return string[] |
| 43 |
*/ |
| 44 |
public static function routes_list() : array { |
| 45 |
return [ |
| 46 |
'Authorize', |
| 47 |
'Disconnect', |
| 48 |
'Deactivate', |
| 49 |
'Deactivate_And_Disconnect', |
| 50 |
'Version', |
| 51 |
'Switch_Domain', |
| 52 |
]; |
| 53 |
} |
| 54 |
|
| 55 |
public static function is_connected() : bool { |
| 56 |
return ! ! Data::get_access_token() && Utils::is_valid_home_url(); |
| 57 |
} |
| 58 |
|
| 59 |
public static function is_active() : bool { |
| 60 |
// TODO: Add login to check if the function should be active or not. |
| 61 |
return empty( get_option( 'image_optimizer_client_data' ) ); |
| 62 |
} |
| 63 |
|
| 64 |
public function __construct() { |
| 65 |
$this->register_components(); |
| 66 |
$this->register_routes(); |
| 67 |
} |
| 68 |
} |
| 69 |
|