Class that makes it possible to test protected functions.
package | GlotPress |
---|---|
inherited_from | \GP_Route_Translation |
__construct()
after_request()
before_request()
bulk_post($project_path, $locale_slug, $translation_set_slug)
can(string $action, string|null $object_type= null
, integer|null $object_id= null
, array|null $extra= null
) : boolean
since | 2.3.0 Added the `$extra` parameter. |
---|
string
The action.
string
null
Optional. Type of an object. Default null.
integer
null
Optional. ID of an object. Default null.
array
null
Optional. Extra information for deciding the outcome.
boolean
The verdict.can_or_forbidden(string $action, string|null $object_type= null
, integer|null $object_id= null
, string|null $message= null
, array|null $extra= null
) : false
since | 1.0.0 |
---|
string
The action.
string
null
Optional. Type of an object. Default null.
integer
null
Optional. ID of an object. Default null.
string
null
Error message in case of a failure. Default: 'You are not allowed to do that!'.
array
null
Pass-through parameter to can().
false
cannot_and_redirect(string $action, string|null $object_type= null
, integer|null $object_id= null
, string|null $url= null
) : boolean
since | 1.0.0 |
---|
string
The action.
string
null
Optional. Type of an object. Default null.
integer
null
Optional. ID of an object. Default null.
string
null
Optional. URL to redirect to. Default: referrer or index page, if referrer is missing.
boolean
Whether a redirect happened.die_with_404($args = array()
)
die_with_error($message, $status = 500
)
discard_warning($project_path, $locale_slug, $translation_set_slug)
exit_($message = 0
)
export_translations_get($project_path, $locale_slug, $translation_set_slug)
header($string)
headers_for_download(string $filename, string $last_modified = ''
)
string
The name of the file.
string
Optional. Date when the file was last modified. Default: ''.
import_translations_get($project_path, $locale_slug, $translation_set_slug)
import_translations_post($project_path, $locale_slug, $translation_set_slug)
invalid_and_redirect(object $thing, string $url = null
) : boolean
Note: this method calls $this->exit_() after the redirect and the code after it won't be executed.
object
a GP_Thing instance to validate
string
where to redirect if the thing doesn't validate
boolean
whether the thing is validinvalid_nonce_and_redirect(string $action, string|null $url = null
) : boolean
since | 2.0.0 |
---|
string
Context for the created nonce.
string
null
The URL to redirect. Default: 'null', the referrer.
boolean
False if the nonce is valid, true if the redirect has happened.logged_in_or_forbidden()
redirect($url = null
)
redirect_with_error($message, $url = null
)
set_notices_and_errors()
set_status($project_path, $locale_slug, $translation_set_slug)
status_header($status)
testable_get_extended_glossary(\GP_Translation_Set $translation_set, \GP_Project $project) : \GP_Glossary
\GP_Translation_Set
translation_set for which to retrieve the glossary.
\GP_Project
project for finding potential parent projects.
\GP_Glossary
extended glossarytmpl(string $template, array $args= array()
, boolean|string $honor_api= true
)
string
Template name to load.
array
Associative array with arguements, which will be exported in the template PHP file.
boolean
string
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($project_path, $locale_slug, $translation_set_slug)
translations_post($project_path, $locale_slug, $translation_set_slug)
validate(object $thing) : boolean
object
a GP_Thing instance to validate
boolean
whether the thing is validverify_nonce(string $action) : boolean
since | 2.0.0 |
---|
string
Context for the created nonce.
boolean
False if the nonce is invalid, true if valid.get_extended_glossary(\GP_Translation_Set $translation_set, \GP_Project $project) : \GP_Glossary
This also fetches contents from a potential locale glossary, as well as from a parent project.
since | 2.3.0 |
---|
\GP_Translation_Set
Translation set for which to retrieve the glossary.
\GP_Project
Project for finding potential parent projects.
\GP_Glossary
Extended glossary._bulk_approve($bulk)
_bulk_fuzzy(array $bulk)
since | 2.3.0 |
---|
array
The bulk data to process.
_bulk_set_priority($project, $bulk)
can_approve_translation_or_forbidden($translation)
discard_warning_edit_function(\GP_Project $project, \GP_Locale $locale, \GP_Translation_Set $translation_set, \GP_Translation $translation)
since | 1.0.0 |
---|
\GP_Project
The project.
\GP_Locale
The GlotPress locale.
\GP_Translation_Set
The translation set.
\GP_Translation
The translation object.
edit_single_translation(string $project_path, string $locale_slug, string $translation_set_slug, callable $edit_function)
since | 1.0.0 |
---|
string
The path of the project.
string
The locale slug.
string
The slug of the translation set.
callable
The edit function to call on the translation.
get_http_referer() : false | string
Unlike wp_get_referer()
, it doesn't check if the referer is
the same as the current request URL.
since | 2.0.0 |
---|
false
string
False on failure. Referer URL on success.set_status_edit_function($project, $locale, $translation_set, $translation)
$api
false
$class_name
$errors
array()
$exited
false
$fake_request
false
$headers
array()
$http_status
$last_method_called
$loaded_template
null
$notices
array()
$redirected
false
$redirected_to
null
$rendered_template
false
$request_running
false
$template_output
null
$template_path
null