Example #1
0
 /**
  * Get action param (from $_GET or uri - /name/value)
  * @param string $key
  * @return string
  */
 public static function _getParam($name)
 {
     if (empty(self::$_params)) {
         $req_uri = $_SERVER['REQUEST_URI'];
         $home_path = parse_url(home_url());
         if (isset($home_path['path'])) {
             $home_path = $home_path['path'];
         } else {
             $home_path = '';
         }
         $home_path = trim($home_path, '/');
         $req_uri = trim($req_uri, '/');
         $req_uri = preg_replace("|^{$home_path}|", '', $req_uri);
         $req_uri = trim($req_uri, '/');
         $parts = explode('/', $req_uri);
         if (!empty($parts)) {
             $params = array();
             for ($i = count($parts) - 1; $i > 1; $i -= 2) {
                 $params[$parts[$i - 1]] = $parts[$i];
             }
             self::$_params = $params + $_REQUEST;
         }
     }
     return isset(self::$_params[$name]) ? self::$_params[$name] : '';
 }
 /**
  * Get action param (from $_GET or uri - /name/value)
  * Marcin Dudek: WHY not just use get_query_var()?
  *
  * @param string $key
  * @return string
  * @author REC
  */
 public static function _getParam($name)
 {
     if (empty(self::$_params)) {
         $req_uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
         $home_path = parse_url(home_url());
         $home_path = isset($home_path['path']) ? $home_path['path'] : '';
         $home_path = trim($home_path, '/');
         $req_uri = trim($req_uri, '/');
         $req_uri = preg_replace("/^" . preg_quote($home_path, "/") . "/", '', $req_uri);
         $req_uri = trim($req_uri, '/');
         $parts = explode('/', $req_uri);
         if (!empty($parts)) {
             $params = array();
             for ($i = count($parts) - 1; $i > 0; $i -= 2) {
                 $params[$parts[$i - 1]] = $parts[$i];
             }
             self::$_params = $params + $_REQUEST;
         }
     }
     return isset(self::$_params[$name]) ? self::$_params[$name] : '';
 }