/** * Generate the section. * * @param string $section * @param array|object $params * @param bool $isArray * * @return string */ public static function generate($section, $params = array(), $isArray = false) { $priorities = array_key_exists_v($section, self::$ViewSections, array()); if (!$isArray && !is_array($params)) { $params = array($params); } $ob = self::runObStart($section, $priorities); if (self::hasCustomHandler($section)) { call_user_func_array($priorities['handler'] . '_run', array($section, $params)); } else { self::runFunctions($params, $priorities); } return self::getObContents($ob); }
/** * Run the hook. * * @param string $hook * @param array|object $params * @param bool $isArray */ public static function run($hook, $params = array(), $isArray = false) { $priorities = array_key_exists_v($hook, self::$Hooks); if (is_array($priorities)) { ksort($priorities); if ($isArray || !is_array($params)) { $params = array($params); } foreach ($priorities as $functions) { foreach ($functions as $function) { call_user_func_array($function, $params); } } } }
/** * Run the filter. * * @param $filter * @param array $params * * @return mixed */ public static function run($filter, $params = []) { if (isset($params[0])) { $value = $params[0]; } else { $value = null; } $priorities = array_key_exists_v($filter, self::$FilterSections); if (is_array($priorities)) { ksort($priorities); if (!is_array($params)) { $params = [$params]; } foreach ($priorities as $functions) { foreach ($functions as $function) { $value = call_user_func_array($function, $params); $params[0] = $value; } } } return $value; }
/** * Performs the security check, verify nonce and if user can perform action. * * @param BaseController $controller * @param $data * @param string $action * * @return bool */ public function perform($controller, $data, $action = '') { $s = Security::create(); if ($this->nonce_base) { $nonce = array_key_exists_v('_asnonce', $controller->values); if ($nonce) { $verified_nonce = $s->verifyNonce($nonce, $this->nonce_base); if (!$verified_nonce) { return false; } } else { return false; } } if ($s->currentUserIsLoggedIn()) { if (!$this->useraction || $s->currentUserCan($this->useraction)) { return true; } } $controller->getRenderer()->RenderText('You cannot perform this action'); return false; }
/** * @param $key * * @return mixed */ private function fetchTuple($key) { return array_key_exists_v(strtolower($key), $this->values, null); }
public function wp_section_handler_run($section, $params = array()) { $section = array_key_exists_v($section, $this->view_sections) ?: $section; if (!empty($params)) { call_user_func_array('do_action', array($section, $params)); } else { call_user_func_array('do_action', array($section)); } }
/** * Check if redirect should be used and if so return the redirect url. * * @return bool|mixed */ public static function useRedirect() { return array_key_exists_v('_redirect', $_POST); }