PluginProbe ʕ •ᴥ•ʔ
Easy HTTPS Redirection (SSL) / trunk
Easy HTTPS Redirection (SSL) vtrunk
trunk 1.5 1.6 1.8 1.9.1 1.9.2 2.0.0 2.0.1
https-redirection / easy-https-ssl-core.php
https-redirection Last commit date
admin 1 day ago classes 1 day ago css 1 day ago images 1 year ago js 1 day ago languages 1 year ago logs 1 year ago easy-https-ssl-core.php 1 day ago https-redirection.php 1 day ago license.txt 1 year ago readme.txt 1 day ago
easy-https-ssl-core.php
133 lines
1 <?php
2
3 if ( !class_exists('Easy_HTTPS_SSL') ) {
4 class Easy_HTTPS_SSL
5 {
6 public $plugin_url;
7 public $plugin_path;
8 public $plugin_configs;//TODO - does it need to be static?
9 public $admin_init;
10 public $debug_logger;
11
12 public function __construct() {
13 $this->load_configs();
14 $this->define_constants();
15 $this->includes();
16 $this->initialize_and_run_classes();
17
18 // Register action hooks.
19 add_action('plugins_loaded', array($this, 'plugins_loaded_handler'));
20 // Note: There is a init time tasks class which will do other init time tasks.
21 add_action('init', array($this, 'ehssl_load_language'));
22
23 // Trigger EHSSL plugin loaded action.
24 do_action('ehssl_loaded');
25 }
26
27 public function plugin_url() {
28 if ($this->plugin_url) {
29 return $this->plugin_url;
30 }
31
32 return $this->plugin_url = plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__));
33 }
34
35 public function plugin_path() {
36 if ($this->plugin_path) {
37 return $this->plugin_path;
38 }
39
40 return $this->plugin_path = untrailingslashit(plugin_dir_path(__FILE__));
41 }
42
43 public function load_configs() {
44 include_once 'classes/ehssl-config.php';
45 $this->plugin_configs = EHSSL_Config::get_instance();
46 }
47
48 public function define_constants() {
49 define('EASY_HTTPS_SSL_URL', $this->plugin_url());
50 define('EASY_HTTPS_SSL_PATH', $this->plugin_path());
51 define('EHSSL_MANAGEMENT_PERMISSION', 'add_users');
52 define('EHSSL_MENU_SLUG_PREFIX', 'ehssl');
53 define('EHSSL_MAIN_MENU_SLUG', 'ehssl');
54 define('EHSSL_SETTINGS_MENU_SLUG', 'ehssl_settings');
55 define('EHSSL_CERTIFICATE_EXPIRY_MENU_SLUG', 'ehssl_certificate_expiry');
56 define('EHSSL_SSL_MGMT_MENU_SLUG', 'ehssl-ssl-mgmt');
57 }
58
59 public function includes() {
60 //Load common files for everywhere
61 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-debug-logger.php';
62 include_once EASY_HTTPS_SSL_PATH . '/classes/utilities/ehssl-utils.php';
63 include_once EASY_HTTPS_SSL_PATH . '/classes/utilities/ehssl-ssl-utils.php';
64 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-cronjob.php';
65 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-custom-post-types.php';
66 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-email-handler.php';
67 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-init-time-tasks.php';
68
69 require_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-installation.php';
70
71 if (is_admin()) { //Load admin side only files
72 include_once EASY_HTTPS_SSL_PATH. '/admin/ehssl-admin-init.php';
73 include_once EASY_HTTPS_SSL_PATH . '/classes/ehssl-non-https-resources-scan-result-table.php';
74 } else {
75 //Load front end side only files
76 }
77 }
78
79 public function initialize_and_run_classes() {
80 //Initialize the various classes and start running.
81
82 //Common classes.
83 $this->debug_logger = new EHSSL_Logger();
84 new EHSSL_Init_Time_Tasks();// This will register the init time tasks.
85
86 if (is_admin()) {
87 // Admin side only classes.
88 $this->admin_init = new EHSSL_Admin_Init();
89 }
90 }
91
92 public static function plugin_activate_handler() {
93 wp_schedule_event(time(), 'daily', 'ehssl_daily_cron_event');
94
95 EHSSL_Installation::run_safe_installer();
96 }
97
98 public static function plugin_deactivate_handler() {
99 wp_clear_scheduled_hook('ehssl_daily_cron_event');
100 }
101
102 public static function plugin_uninstall_handler() {
103 //NOP.
104 }
105
106 public function ehssl_load_language() {
107 // Internationalization.
108 // A better practice for text domain is to use dashes instead of underscores.
109 load_plugin_textdomain('https-redirection', false, EASY_HTTPS_SSL_PATH . '/languages/');
110 }
111
112 public function plugins_loaded_handler() {
113 // Runs when plugins_loaded action gets fired
114 if (is_admin()) {
115 // Do admin side plugins_loaded operations
116 $this->do_db_upgrade_check();
117 }
118 }
119
120 public function do_db_upgrade_check() {
121 //Check if DB needs to be updated
122 $existing_db_version = get_option('ehssl_db_version');
123 if ($existing_db_version != EASY_HTTPS_SSL_DB_VERSION) {
124 EHSSL_Installation::run_safe_installer();
125 }
126 }
127
128 } // End of class.
129
130 } // End of class not exists check.
131
132 $GLOBALS['ehssl'] = new Easy_HTTPS_SSL();
133