Skip to content

Commit

Permalink
Added constant to stop execution of admin init hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
cixtor committed Jun 10, 2016
1 parent 51b6eb7 commit 423916c
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions sucuri.php
Expand Up @@ -306,10 +306,13 @@
*/
add_action('init', 'SucuriScanInterface::initialize', 1);
add_action('init', 'SucuriScanBlockedUsers::blockUserLogin', 1);
add_action('admin_init', 'SucuriScanInterface::handleOldPlugins');
add_action('admin_init', 'SucuriScanInterface::createStorageFolder');
add_action('admin_enqueue_scripts', 'SucuriScanInterface::enqueueScripts', 1);

if (SucuriScan::runAdminInit()) {
add_action('admin_init', 'SucuriScanInterface::handleOldPlugins');
add_action('admin_init', 'SucuriScanInterface::createStorageFolder');
}

/**
* Display extension menu and submenu items in the correct interface. For single
* site installations the menu items can be displayed normally as always but for
Expand Down Expand Up @@ -370,7 +373,10 @@
add_action($hook_name, $hook_func, 50, 5);
}

add_action('admin_init', 'SucuriScanHook::hook_undefined_actions');
if (SucuriScan::runAdminInit()) {
add_action('admin_init', 'SucuriScanHook::hook_undefined_actions');
}

add_action('login_form', 'SucuriScanHook::hook_undefined_actions');
} else {
SucuriScanInterface::error('Function call interceptors are not working properly.');
Expand Down Expand Up @@ -538,6 +544,29 @@ public static function human_filesize($bytes = 0, $decimals = 2)
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[ $factor ];
}

/**
* Check if the admin init hook must not be intercepted.
*
* @return boolean True if the admin init hook must not be intercepted.
*/
public static function noAdminInit()
{
return (bool) (
defined('SUCURISCAN_ADMIN_INIT')
&& SUCURISCAN_ADMIN_INIT === false
);
}

/**
* Check if the admin init hook must be intercepted.
*
* @return boolean True if the admin init hook must be intercepted.
*/
public static function runAdminInit()
{
return (bool) (self::noAdminInit() === false);
}

/**
* Fix the deliminar of a resource path.
*
Expand Down Expand Up @@ -6771,6 +6800,19 @@ private static function replacePseudoVars($content = '', $params = array())
return false;
}

/**
* Check if the ads in the sidebar are visible or not.
*
* @return boolean True if the ads must be hidden.
*/
private static function noAdvertisement()
{
return (bool) (
defined('SUCURISCAN_HIDE_ADS')
&& SUCURISCAN_HIDE_ADS === true
);
}

/**
* Gather and generate the information required globally by all the template files.
*
Expand Down Expand Up @@ -6801,7 +6843,7 @@ private static function sharedParams($target = null, $params = array())
}

// Hide the advertisements from the layout.
if (defined('SUCURISCAN_HIDE_ADS') && SUCURISCAN_HIDE_ADS === true) {
if (self::noAdvertisement()) {
$params['LayoutType'] = 'onecolumn';
$params['AdsVisibility'] = 'hidden';
$params['ReviewNavbarButton'] = 'visible';
Expand Down

0 comments on commit 423916c

Please sign in to comment.