| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTExtensionsAccessPoint extends CJTAccessPoint { |
| 13 |
|
| 14 |
/** |
| 15 |
* |
| 16 |
*/ |
| 17 |
const MENU_POSITION_INDEX = 2; |
| 18 |
|
| 19 |
/** |
| 20 |
* |
| 21 |
*/ |
| 22 |
const PLUGINS_PAGE_SEARCH_TERM = 'css-javascript-toolbox'; |
| 23 |
|
| 24 |
/** |
| 25 |
* put your comment there... |
| 26 |
* |
| 27 |
*/ |
| 28 |
public function __construct() { |
| 29 |
// Initialize Access Point base! |
| 30 |
parent::__construct(); |
| 31 |
// Set access point name! |
| 32 |
$this->name = 'extensions'; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
*/ |
| 39 |
protected function doListen() { |
| 40 |
// Only if permitted! |
| 41 |
if ($this->hasAccess()) { |
| 42 |
// Add menu pages. |
| 43 |
add_action('admin_menu', array(&$this, 'menu'), 13); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* put your comment there... |
| 49 |
* |
| 50 |
*/ |
| 51 |
public function menu() { |
| 52 |
// Extensions page. |
| 53 |
// add_submenu_page(CJTPlugin::PLUGIN_REQUEST_ID, null, cssJSToolbox::getText('Extensions'), 'administrator', null); |
| 54 |
// Hack Extensions menu item to point to Plugins page! |
| 55 |
// $GLOBALS['submenu'][CJTPlugin::PLUGIN_REQUEST_ID][self::MENU_POSITION_INDEX][2] = admin_url('plugins.php?s=' . self::PLUGINS_PAGE_SEARCH_TERM); |
| 56 |
// When plugins page loaded! |
| 57 |
|
| 58 |
/** |
| 59 |
* Need this to fix the menu issue with CJT PLUS 8.4 or lower. |
| 60 |
* |
| 61 |
*/ |
| 62 |
if ( class_exists( 'CJTPlus' ) ) : |
| 63 |
$reflector = new \ReflectionClass( 'CJTPlus' ); |
| 64 |
$CJTPlusVersion = get_plugin_data( str_replace( 'plus.class', 'plus', $reflector->getFileName() ) )['Version']; |
| 65 |
|
| 66 |
if ( version_compare( $CJTPlusVersion, '8.4', '<=' ) ) { |
| 67 |
global $menu, $submenu; |
| 68 |
|
| 69 |
# Find CJT Menu and Sub Menu, ADD PLUS to the title |
| 70 |
foreach( $menu as & $menuItem ) |
| 71 |
{ |
| 72 |
|
| 73 |
if ( $menuItem[ 2 ] == 'cjtoolbox' ) |
| 74 |
{ |
| 75 |
$submenu[ 'cjtoolbox' ][ 0 ] [ 0 ] = $menuItem[ 0 ]; |
| 76 |
$submenu[ 'cjtoolbox' ][ 0 ] [ 1 ] = 'administrator'; |
| 77 |
$submenu[ 'cjtoolbox' ][ 0 ] [ 2 ] = 'cjtoolbox'; |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
endif; |
| 82 |
|
| 83 |
add_action('load-plugins.php', array($this, 'route'), 10, 0); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* put your comment there... |
| 88 |
* |
| 89 |
*/ |
| 90 |
public function route($loadView = null, $request = array('view' => 'extensions/plugins-list')) { |
| 91 |
// Set as connected object! |
| 92 |
$this->connected(); |
| 93 |
// Load extensions view throughjt the default controller! |
| 94 |
parent::route($loadView, $request) |
| 95 |
// Set Action name! |
| 96 |
->setAction('extensions') |
| 97 |
// Dispatch the call! |
| 98 |
->_doAction(); |
| 99 |
} |
| 100 |
|
| 101 |
} // End class. |
| 102 |
|
| 103 |
// Hookable! |
| 104 |
CJTExtensionsAccessPoint::define('CJTExtensionsAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |