public static function init($options = []) { $self = new self($options); if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { if (isset($_GET['reset']) && $self->getOption('allow_reset')) { echo '{ "success": "' . ($self->resetCache() ? 'yes' : 'no') . '" }'; } else { if (isset($_GET['invalidate']) && $self->getOption('allow_invalidate')) { echo '{ "success": "' . ($self->resetCache($_GET['invalidate']) ? 'yes' : 'no') . '" }'; } else { echo json_encode($self->getData(empty($_GET['section']) ? null : $_GET['section'])); } } exit; } else { if (isset($_GET['reset']) && $self->getOption('allow_reset')) { $self->resetCache(); header('Location: ?'); exit; } else { if (isset($_GET['invalidate']) && $self->getOption('allow_invalidate')) { $self->resetCache($_GET['invalidate']); header('Location: ?'); exit; } } } return $self; }