| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Easy Code Manager |
| 4 |
Plugin URI: https://easy-code-manager.com/ |
| 5 |
Description: Easy Code Manager is a code management plugin for WordPress that allows you to easily add CSS, JavaScript, PHP or HTML code to unique Code Blocks & assign them anywhere on your website. |
| 6 |
Version: 10 |
| 7 |
Text Domain: easy-code-manager |
| 8 |
Domain Path: /locals/languages |
| 9 |
Author: Wipeout Media |
| 10 |
Author URI: https://easy-code-manager.com |
| 11 |
License: |
| 12 |
|
| 13 |
The Software is package as a WordPress¨ plugin. The PHP code associated with the Software is licensed under the GPL version 2.0 license (as found at http://www.gnu.org/licenses/gpl-2.0.txt GNU/GPLv2 or "GPLv2"). You may redistribute, repackage, and modify the PHP code as you see fit and as consistent with GPLv2. |
| 14 |
|
| 15 |
The remaining portions of the Software ("Proprietary Portion"), which includes all images, cascading style sheets, and JavaScript are NOT licensed under GPLv2 and are considered proprietary to Licensor and are solely licensed under the remaining terms of this Agreement. The Proprietary Portion may not be redistributed, repackaged, or otherwise modified. |
| 16 |
*/ |
| 17 |
|
| 18 |
// Disallow direct access. |
| 19 |
defined('ABSPATH') or die(-1); |
| 20 |
|
| 21 |
/** |
| 22 |
* ECM Checker Interface for checking for |
| 23 |
* CJT exisdtance |
| 24 |
* |
| 25 |
*/ |
| 26 |
final class ECMCI |
| 27 |
{ |
| 28 |
|
| 29 |
/** |
| 30 |
* |
| 31 |
*/ |
| 32 |
const DIR = __DIR__; |
| 33 |
|
| 34 |
/** |
| 35 |
* |
| 36 |
*/ |
| 37 |
const DB_VERSION_OPTION_NAME = 'ecm_db_version'; |
| 38 |
|
| 39 |
/** |
| 40 |
* |
| 41 |
*/ |
| 42 |
const FILE = __FILE__; |
| 43 |
|
| 44 |
/** |
| 45 |
* |
| 46 |
*/ |
| 47 |
const VERSION = '1.2'; |
| 48 |
|
| 49 |
/** |
| 50 |
* put your comment there... |
| 51 |
* |
| 52 |
* @var mixed |
| 53 |
*/ |
| 54 |
private static $instance; |
| 55 |
|
| 56 |
/** |
| 57 |
* put your comment there... |
| 58 |
* |
| 59 |
*/ |
| 60 |
private function __construct() {} |
| 61 |
|
| 62 |
/** |
| 63 |
* put your comment there... |
| 64 |
* |
| 65 |
*/ |
| 66 |
public function _OnAdminNotice() |
| 67 |
{ |
| 68 |
require __DIR__ . DIRECTORY_SEPARATOR . 'CJTChecker' . |
| 69 |
DIRECTORY_SEPARATOR . 'CJTDetectedNotice.html.php'; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* put your comment there... |
| 74 |
* |
| 75 |
*/ |
| 76 |
public function _OnCheckCompatibility() |
| 77 |
{ |
| 78 |
|
| 79 |
add_action('admin_notices', array($this, 'ECMFreeGtECMPLUS')); |
| 80 |
|
| 81 |
if (class_exists('CJTPlugin') && |
| 82 |
CJTPlugin::DB_VERSION_OPTION_NAME == 'cjtoolbox_db_version') |
| 83 |
{ |
| 84 |
|
| 85 |
// Show Asdmin notice |
| 86 |
add_action('admin_notices', array($this, '_OnAdminNotice')); |
| 87 |
add_action('network_admin_notices', array($this, '_OnAdminNotice')); |
| 88 |
|
| 89 |
|
| 90 |
// Enqueue Notice scripts/styles |
| 91 |
add_action('admin_enqueue_scripts', array($this, '_OnCheckerScripts')); |
| 92 |
add_action('admin_print_styles', array($this, '_OnCheckerStyles')); |
| 93 |
|
| 94 |
// Migrate Ajax action |
| 95 |
add_action('wp_ajax_ecm-migrate-cjt', array($this, '_OnMigrate')); |
| 96 |
|
| 97 |
// Dont run ECM as long as CJT is activated/detected |
| 98 |
return; |
| 99 |
} |
| 100 |
|
| 101 |
// Load ECM |
| 102 |
require __DIR__ . DIRECTORY_SEPARATOR . 'Plugin.class.php'; |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* put your comment there... |
| 107 |
* |
| 108 |
*/ |
| 109 |
public function _OnCheckerScripts() |
| 110 |
{ |
| 111 |
wp_enqueue_script('jquery-ui-dialog'); |
| 112 |
wp_enqueue_script('ecm-cjt-checker', plugin_dir_url(__FILE__) . '/CJTChecker/CJTChecker.js'); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* put your comment there... |
| 117 |
* |
| 118 |
*/ |
| 119 |
public function _OnCheckerStyles() |
| 120 |
{ |
| 121 |
wp_enqueue_style('ecm-cjt-checker-jquery-ui-dialog', plugin_dir_url(__FILE__) . '/CJTChecker/jQueryDialogCSS/jquery-ui.min.css'); |
| 122 |
wp_enqueue_style('ecm-cjt-checker', plugin_dir_url(__FILE__) . '/CJTChecker/CJTChecker.css'); |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* put your comment there... |
| 127 |
* |
| 128 |
*/ |
| 129 |
public function _OnMigrate() |
| 130 |
{ |
| 131 |
|
| 132 |
$nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : false; |
| 133 |
|
| 134 |
if (is_super_admin() && |
| 135 |
wp_verify_nonce($nonce)) |
| 136 |
{ |
| 137 |
|
| 138 |
require __DIR__ . DIRECTORY_SEPARATOR . 'CJTChecker' . |
| 139 |
DIRECTORY_SEPARATOR . 'Migrate.class.php'; |
| 140 |
|
| 141 |
$migrator = new ECMMigrateCJT(); |
| 142 |
|
| 143 |
try |
| 144 |
{ |
| 145 |
$migrator->migrate(); |
| 146 |
} |
| 147 |
catch (Exception $exception) |
| 148 |
{ |
| 149 |
echo $exception->getMessage(); |
| 150 |
} |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
die(); |
| 155 |
} |
| 156 |
|
| 157 |
public function ECMFreeGtECMPLUS() |
| 158 |
{ |
| 159 |
$screen = get_current_screen(); |
| 160 |
|
| 161 |
$isBannerDismissed = get_user_option('settings.CJTInstallerModel.warningNoticeDismissed'); |
| 162 |
|
| 163 |
if (!$isBannerDismissed && $screen->id != 'toplevel_page_ecm') : |
| 164 |
if (defined('ECM_PLUS_FILE')) : |
| 165 |
$ecmpPluginData = get_plugin_data(ECM_PLUS_FILE, false, false); |
| 166 |
|
| 167 |
if (version_compare(ECMCI::VERSION, $ecmpPluginData['Version'], '>')) { |
| 168 |
require "includes" . DIRECTORY_SEPARATOR . "html" . DIRECTORY_SEPARATOR . "lowerECMPlusVersion.html.php"; |
| 169 |
} |
| 170 |
|
| 171 |
endif; |
| 172 |
endif; |
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* put your comment there... |
| 177 |
* |
| 178 |
*/ |
| 179 |
private function init() |
| 180 |
{ |
| 181 |
|
| 182 |
// admin notice when CJT detected |
| 183 |
add_action('plugins_loaded', array($this, '_OnCheckCompatibility'), 1); |
| 184 |
|
| 185 |
} |
| 186 |
|
| 187 |
/** |
| 188 |
* put your comment there... |
| 189 |
* |
| 190 |
*/ |
| 191 |
public static function & plug() |
| 192 |
{ |
| 193 |
|
| 194 |
if (!self::$instance) |
| 195 |
{ |
| 196 |
self::$instance = new ECMCI(); |
| 197 |
|
| 198 |
self::$instance->init(); |
| 199 |
} |
| 200 |
|
| 201 |
return self::$instance; |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
function deprecatedPHPCheck() |
| 206 |
{ ?> |
| 207 |
<div class="notice notice-error"> |
| 208 |
<p><strong>ECM</strong>: Easy Code Manager need PHP version 7.3 or greater to operate properly. Please ask your hosting provider to update the PHP version.<br> |
| 209 |
Current PHP Version: <strong><?php echo phpversion(); ?></strong> |
| 210 |
</p> |
| 211 |
</div> |
| 212 |
<?php } |
| 213 |
|
| 214 |
if ( version_compare( phpversion(), 7.3, '>=' ) ) { |
| 215 |
ECMCI::plug(); |
| 216 |
} else { |
| 217 |
add_action( 'admin_notices', 'deprecatedPHPCheck' ); |
| 218 |
} |
| 219 |
|
| 220 |
|