[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/ -> route.php (summary)

(no description)

File Size: 360 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

GP_Route:: (22 methods):
  __construct()
  die_with_error()
  before_request()
  after_request()
  validate()
  invalid_and_redirect()
  can()
  cannot_and_redirect()
  verify_nonce()
  invalid_nonce_and_redirect()
  can_or_forbidden()
  logged_in_or_forbidden()
  redirect_with_error()
  redirect()
  get_http_referer()
  headers_for_download()
  set_notices_and_errors()
  tmpl()
  die_with_404()
  exit_()
  header()
  status_header()


Class: GP_Route  - X-Ref

Base controller class

__construct()   X-Ref
No description

die_with_error( $message, $status = 500 )   X-Ref
No description

before_request()   X-Ref
No description

after_request()   X-Ref
No description

validate( $thing )   X-Ref
Validates a thing and add its errors to the route's errors.

param: object $thing a GP_Thing instance to validate
return: bool whether the thing is valid

invalid_and_redirect( $thing, $url = null )   X-Ref
Same as validate(), but redirects to $url if the thing isn't valid.

Note: this method calls $this->exit_() after the redirect and the code after it won't
be executed.

param: object $thing a GP_Thing instance to validate
param: string $url where to redirect if the thing doesn't validate
return: bool whether the thing is valid

can( $action, $object_type = null, $object_id = null, $extra = null )   X-Ref
Checks whether a user is allowed to do an action.

param: string      $action      The action.
param: string|null $object_type Optional. Type of an object. Default null.
param: int|null    $object_id   Optional. ID of an object. Default null.
param: array|null  $extra       Optional. Extra information for deciding the outcome.
return: bool       The verdict.
since: 2.3.0 Added the `$extra` parameter.

cannot_and_redirect( $action, $object_type = null, $object_id = null, $url = null )   X-Ref
Redirects and exits if the current user isn't allowed to do an action.

param: string      $action      The action.
param: string|null $object_type Optional. Type of an object. Default null.
param: int|null    $object_id   Optional. ID of an object. Default null.
param: string|null $url         Optional. URL to redirect to. Default: referrer or index page, if referrer is missing.
return: bool Whether a redirect happened.
since: 1.0.0

verify_nonce( $action )   X-Ref
Verifies a nonce for a route.

param: string $action Context for the created nonce.
return: bool False if the nonce is invalid, true if valid.
since: 2.0.0

invalid_nonce_and_redirect( $action, $url = null )   X-Ref
Verifies a nonce for a route and redirects in case the nonce is invalid.

param: string      $action Context for the created nonce.
param: string|null $url    The URL to redirect. Default: 'null', the referrer.
return: bool False if the nonce is valid, true if the redirect has happened.
since: 2.0.0

can_or_forbidden( $action, $object_type = null, $object_id = null, $message = null, $extra = null )   X-Ref
Determines whether a user can perfom an action and redirects in case of a failure.

param: string      $action      The action.
param: string|null $object_type Optional. Type of an object. Default null.
param: int|null    $object_id   Optional. ID of an object. Default null.
param: string|null $message     Error message in case of a failure.
param: array|null  $extra       Pass-through parameter to can().
return: false
since: 1.0.0

logged_in_or_forbidden()   X-Ref
No description

redirect_with_error( $message, $url = null )   X-Ref
No description

redirect( $url = null )   X-Ref
No description

get_http_referer()   X-Ref
Retrieves referer from '_wp_http_referer' or HTTP referer.

Unlike `wp_get_referer()`, it doesn't check if the referer is
the same as the current request URL.

return: false|string False on failure. Referer URL on success.
since: 2.0.0

headers_for_download( $filename, $last_modified = '' )   X-Ref
Sets HTTP headers for content download.

param: string $filename      The name of the file.
param: string $last_modified Optional. Date when the file was last modified. Default: ''.

set_notices_and_errors()   X-Ref
No description

tmpl( $template, $args = array()   X-Ref
Loads a template.

param: string      $template  Template name to load.
param: array       $args      Associative array with arguements, which will be exported in the template PHP file.
param: bool|string $honor_api If this is true or 'api' and the route is processing an API request

die_with_404( $args = array()   X-Ref
No description

exit_( $message = 0 )   X-Ref
No description

header( $string )   X-Ref
No description

status_header( $status )   X-Ref
No description



Generated: Fri Dec 6 01:01:08 2024 Cross-referenced by PHPXref 0.7.1