Created
February 6, 2017 00:00
-
-
Save sepiariver/a1e693eaf1ecdae12528e94a935e864f to your computer and use it in GitHub Desktop.
MODX Client Preview Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($modx->context->get('key') === 'mgr') return; | |
$key = $modx->getOption('key', $scriptProperties, 'my-secret-key'); | |
$val = $modx->getOption('val', $scriptProperties, 'my-secret-value'); | |
switch ($modx->event->name) { | |
case 'OnHandleRequest': | |
if (!$modx->getOption('site_status')) { | |
if ($_GET[$key] === $val) { | |
$modx->config['site_status'] = 1; | |
} else { | |
$modx->config['site_status'] = 0; | |
} | |
} | |
break; | |
case 'OnLoadWebDocument': | |
case 'OnLoadWebPageCache': | |
if (!$modx->getOption('site_status')) { | |
if ($_GET[$key] === $val) { | |
if ($modx->resource instanceof modResource) $modx->resource->set('cacheable', false); | |
} | |
} | |
break; | |
default: | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment