Class that makes it possible to test protected functions.

package GlotPress
inherited_from \GP_Route_Translation

 Methods

__construct()

__construct() 
Inherited

after_request()

after_request() 
Inherited

before_request()

before_request() 
Inherited

bulk_post()

bulk_post($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

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.

die_with_404()

die_with_404($args = array()
Inherited

Parameters

$args

die_with_error()

die_with_error($message, $status = 500
Inherited

Parameters

$message

$status

discard_warning()

discard_warning($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

exit_()

exit_($message = 0
Inherited

Parameters

$message

export_translations_get()

export_translations_get($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

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: ''.

import_translations_get()

import_translations_get($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

import_translations_post()

import_translations_post($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

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

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

set_status()

set_status($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

status_header()

status_header($status) 
Inherited

Parameters

$status

Wraps the protected get_extended_glossary function

testable_get_extended_glossary(\GP_Translation_Set $translation_set, \GP_Project $project) : \GP_Glossary

Parameters

$translation_set

\GP_Translation_Set

translation_set for which to retrieve the glossary.

$project

\GP_Project

project for finding potential parent projects.

Returns

\GP_Glossaryextended glossary

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.

translations_get()

translations_get($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

translations_post()

translations_post($project_path, $locale_slug, $translation_set_slug) 
Inherited

Parameters

$project_path

$locale_slug

$translation_set_slug

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.

Get the glossary for the translation set.

get_extended_glossary(\GP_Translation_Set $translation_set, \GP_Project $project) : \GP_Glossary
Inherited

This also fetches contents from a potential locale glossary, as well as from a parent project.

since 2.3.0

Parameters

$translation_set

\GP_Translation_Set

Translation set for which to retrieve the glossary.

$project

\GP_Project

Project for finding potential parent projects.

Returns

\GP_GlossaryExtended glossary.

_bulk_approve()

_bulk_approve($bulk) 
Inherited

Parameters

$bulk

Processes the bulk action to set translations to fuzzy.

_bulk_fuzzy(array $bulk) 
Inherited
since 2.3.0

Parameters

$bulk

array

The bulk data to process.

_bulk_set_priority()

_bulk_set_priority($project, $bulk) 
Inherited

Parameters

$project

$bulk

can_approve_translation_or_forbidden()

can_approve_translation_or_forbidden($translation) 
Inherited

Parameters

$translation

Discard a warning.

discard_warning_edit_function(\GP_Project $project, \GP_Locale $locale, \GP_Translation_Set $translation_set, \GP_Translation $translation) 
Inherited
since 1.0.0

Parameters

$project

\GP_Project

The project.

$locale

\GP_Locale

The GlotPress locale.

$translation_set

\GP_Translation_Set

The translation set.

$translation

\GP_Translation

The translation object.

Edits a single translation.

edit_single_translation(string $project_path, string $locale_slug, string $translation_set_slug, callable $edit_function) 
Inherited
since 1.0.0

Parameters

$project_path

string

The path of the project.

$locale_slug

string

The locale slug.

$translation_set_slug

string

The slug of the translation set.

$edit_function

callable

The edit function to call on the translation.

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.

set_status_edit_function()

set_status_edit_function($project, $locale, $translation_set, $translation) 
Inherited

Parameters

$project

$locale

$translation_set

$translation

 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