| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTInstallerAccessPoint extends CJTAccessPoint { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $stopNotices = false; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
// Initialize parent. |
| 27 |
parent::__construct(); |
| 28 |
// Set name! |
| 29 |
$this->name = 'installer'; |
| 30 |
} |
| 31 |
/** |
| 32 |
* put your comment there... |
| 33 |
* |
| 34 |
*/ |
| 35 |
protected function doListen() { |
| 36 |
// If not installed and not in manage page display admin notice! |
| 37 |
if (!CJTPlugin::getInstance()->isInstalled() && $this->hasAccess()) { |
| 38 |
add_action('admin_notices', array(&$this, 'notInstalledAdminNotice')); |
| 39 |
} |
| 40 |
|
| 41 |
//if ( class_exists( 'CJTPlus' ) && $this->isOldCJTPlus()) add_action( 'admin_notices', [ $this, '_oldCJTPlusDetected' ] ); |
| 42 |
} |
| 43 |
|
| 44 |
protected function isOldCJTPlus() |
| 45 |
{ |
| 46 |
if ( ! function_exists( 'get_plugin_data' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 47 |
|
| 48 |
$reflector = new \ReflectionClass( 'CJTPlus' ); |
| 49 |
$CJTPlusVersion = get_plugin_data( str_replace( 'plus.class', 'plus', $reflector->getFileName() ) )['Version']; |
| 50 |
|
| 51 |
if ( version_compare( $CJTPlusVersion, '8.4', '<=' ) ) return true; |
| 52 |
return false; |
| 53 |
} |
| 54 |
|
| 55 |
public function _oldCJTPlusDetected() |
| 56 |
{ |
| 57 |
$class = 'notice notice-error'; |
| 58 |
$message = __( 'You are currently using CJT PLUS version 8.4 or under. Unfortunately, this version is not optimized for the new Gutenberg Editor. |
| 59 |
<br> |
| 60 |
<br> |
| 61 |
Please make sure you have added your license key and update CJT PLUS with the latest version. If your license has expired, please click to: <a target="_blank" href="https://css-javascript-toolbox.com/pricing">purchase a new subscription</a>. |
| 62 |
<br> |
| 63 |
If you wish to continue using your current version, it may be best to roll back to: <a target="_blank" href="https://downloads.wordpress.org/plugin/css-javascript-toolbox.8.4.2.zip">CJT Free - version 8.4.2</a>' ); |
| 64 |
|
| 65 |
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), $message ); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* put your comment there... |
| 70 |
* |
| 71 |
*/ |
| 72 |
public function installationPage() { |
| 73 |
if ($this->hasAccess()) { |
| 74 |
// Set as connected object! |
| 75 |
$this->connected(); |
| 76 |
// Set controller internal parameters. |
| 77 |
return $this->route(null, array('view' => 'installer/install')) |
| 78 |
// Set Action |
| 79 |
->setAction('install'); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* put your comment there... |
| 85 |
* |
| 86 |
*/ |
| 87 |
public function notInstalledAdminNotice() { |
| 88 |
// Show Not installed admin notice only |
| 89 |
// if there is no access point processed/connected the request |
| 90 |
if (!$this->stopNotices) { |
| 91 |
// Set MVC request parameters. |
| 92 |
$this->route(null , array('view' => 'installer/notice')) |
| 93 |
// Set action name. |
| 94 |
->setAction('notInstalledNotice') |
| 95 |
// Fire action! |
| 96 |
->_doAction(); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* put your comment there... |
| 102 |
* |
| 103 |
*/ |
| 104 |
public function stopNotices() { |
| 105 |
// Do not show admin notcies! |
| 106 |
$this->stopNotices = true; |
| 107 |
} |
| 108 |
|
| 109 |
} // End class. |
| 110 |
|
| 111 |
// Hookable! |
| 112 |
CJTInstallerAccessPoint::define('CJTInstallerAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |