Core class used to implement the translation set route.

since 1.0.0
package GlotPress
inherited_from \GP_Route_Main

 Methods

__construct()

__construct() 
Inherited

after_request()

after_request() 
Inherited

before_request()

before_request() 
Inherited

Checks whether a user is allowed to do an action.

can(string $action, string|null $object_type = null, integer|null $object_id = null, array|null $extra = null) : boolean
Inherited
since 2.3.0 Added the `$extra` parameter.

Parameters

$action

string

The action.

$object_type

stringnull

Optional. Type of an object. Default null.

$object_id

integernull

Optional. ID of an object. Default null.

$extra

arraynull

Optional. Extra information for deciding the outcome.

Returns

booleanThe verdict.

Determines whether a user can perfom an action and redirects in case of a failure.

can_or_forbidden(string $action, string|null $object_type = null, integer|null $object_id = null, string|null $message = null, array|null $extra = null) : false
Inherited
since 1.0.0

Parameters

$action

string

The action.

$object_type

stringnull

Optional. Type of an object. Default null.

$object_id

integernull

Optional. ID of an object. Default null.

$message

stringnull

Error message in case of a failure. Default: 'You are not allowed to do that!'.

$extra

arraynull

Pass-through parameter to can().

Returns

false

Redirects and exits if the current user isn't allowed to do an action.

cannot_and_redirect(string $action, string|null $object_type = null, integer|null $object_id = null, string|null $url = null) : boolean
Inherited
since 1.0.0

Parameters

$action

string

The action.

$object_type

stringnull

Optional. Type of an object. Default null.

$object_id

integernull

Optional. ID of an object. Default null.

$url

stringnull

Optional. URL to redirect to. Default: referrer or index page, if referrer is missing.

Returns

booleanWhether a redirect happened.

Displays the delete page for translations sets.

delete_get(integer $set_id) 
since 2.0.0

Parameters

$set_id

integer

The id of the translation set to delete.

Deletes a translation set.

delete_post(integer $set_id) 
since 2.0.0

Parameters

$set_id

integer

The id of the translation set to delete.

die_with_404()

die_with_404($args = array()
Inherited

Parameters

$args

die_with_error()

die_with_error($message, $status = 500
Inherited

Parameters

$message

$status

edit_get()

edit_get($set_id) 

Parameters

$set_id

Saves settings for a translation set and redirects back to the project locales page.

edit_post(integer $set_id) 
since 1.0.0

Parameters

$set_id

integer

A translation set id to edit the settings of.

exit_()

exit_($message = 0
Inherited

Parameters

$message

header()

header($string) 
Inherited

Parameters

$string

Sets HTTP headers for content download.

headers_for_download(string $filename, string $last_modified = ''
Inherited

Parameters

$filename

string

The name of the file.

$last_modified

string

Optional. Date when the file was last modified. Default: ''.

Same as validate(), but redirects to $url if the thing isn't valid.

invalid_and_redirect(object $thing, string $url = null) : boolean
Inherited

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

Parameters

$thing

object

a GP_Thing instance to validate

$url

string

where to redirect if the thing doesn't validate

Returns

booleanwhether the thing is valid

Verifies a nonce for a route and redirects in case the nonce is invalid.

invalid_nonce_and_redirect(string $action, string|null $url = null) : boolean
Inherited
since 2.0.0

Parameters

$action

string

Context for the created nonce.

$url

stringnull

The URL to redirect. Default: 'null', the referrer.

Returns

booleanFalse if the nonce is valid, true if the redirect has happened.

logged_in_or_forbidden()

logged_in_or_forbidden() 
Inherited

new_get()

new_get() 

new_post()

new_post() 

redirect()

redirect($url = null
Inherited

Parameters

$url

redirect_with_error()

redirect_with_error($message, $url = null
Inherited

Parameters

$message

$url

set_notices_and_errors()

set_notices_and_errors() 
Inherited

single()

single($set_id) 

Parameters

$set_id

status_header()

status_header($status) 
Inherited

Parameters

$status

Loads a template.

tmpl(string $template, array $args = array(), boolean|string $honor_api = true
Inherited

Parameters

$template

string

template name to load

$args

array

Associative array with arguements, which will be exported in the template PHP file

$honor_api

booleanstring

If this is true or 'api' and the route is processing an API request the template name will be suffixed with .api. The actual file loaded will be template.api.php

Validates a thing and add its errors to the route's errors.

validate(object $thing) : boolean
Inherited

Parameters

$thing

object

a GP_Thing instance to validate

Returns

booleanwhether the thing is valid

Verifies a nonce for a route.

verify_nonce(string $action) : boolean
Inherited
since 2.0.0

Parameters

$action

string

Context for the created nonce.

Returns

booleanFalse if the nonce is invalid, true if valid.

Determines whether the current user can edit a translation set.

cannot_edit_set_and_redirect(\GP_Translation_Set $set) 

Parameters

$set

\GP_Translation_Set

The translation set to edit.

Retrieves referer from '_wp_http_referer' or HTTP referer.

get_http_referer() : false | string
Inherited

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

since 2.0.0

Returns

falsestringFalse on failure. Referer URL on success.

Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.

get_raw_referer() : string | false
Inherited
since 2.0.0

Returns

stringfalseReferer URL on success, false on failure.

get_set_project_and_locale_from_set_id_or_404()

get_set_project_and_locale_from_set_id_or_404($set_id) 

Parameters

$set_id

 Properties

 

$api

$api 

Default

false
 

$class_name

$class_name 

Default

 

$errors

$errors 

Default

array()
 

$exit_message

$exit_message 

Default

 

$exited

$exited 

Default

false
 

$fake_request

$fake_request 

Default

false
 

$headers

$headers 

Default

array()
 

$http_status

$http_status 

Default

 

$last_method_called

$last_method_called 

Default

 

$loaded_template

$loaded_template 

Default

null
 

$notices

$notices 

Default

array()
 

$redirected

$redirected 

Default

false
 

$redirected_to

$redirected_to 

Default

null
 

$rendered_template

$rendered_template 

Default

false
 

$request_running

$request_running 

Default

false
 

$template_output

$template_output 

Default

null
 

$template_path

$template_path 

Default

null