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. |
|---|
stringThe action.
stringnullOptional. Type of an object. Default null.
integernullOptional. ID of an object. Default null.
arraynullOptional. Extra information for deciding the outcome.
booleanThe 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 |
|---|
stringThe action.
stringnullOptional. Type of an object. Default null.
integernullOptional. ID of an object. Default null.
stringnullError message in case of a failure. Default: 'You are not allowed to do that!'.
arraynullPass-through parameter to can().
falsecannot_and_redirect(string $action, string|null $object_type= null, integer|null $object_id= null, string|null $url= null) : boolean
| since | 1.0.0 |
|---|
stringThe action.
stringnullOptional. Type of an object. Default null.
integernullOptional. ID of an object. Default null.
stringnullOptional. URL to redirect to. Default: referrer or index page, if referrer is missing.
booleanWhether 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 = '')
stringThe name of the file.
stringOptional. 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.
objecta GP_Thing instance to validate
stringwhere to redirect if the thing doesn't validate
booleanwhether the thing is validinvalid_nonce_and_redirect(string $action, string|null $url = null) : boolean
| since | 2.0.0 |
|---|
stringContext for the created nonce.
stringnullThe URL to redirect. Default: 'null', the referrer.
booleanFalse 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_Settranslation_set for which to retrieve the glossary.
\GP_Projectproject for finding potential parent projects.
\GP_Glossaryextended glossarytmpl(string $template, array $args= array(), boolean|string $honor_api= true)
stringTemplate name to load.
arrayAssociative array with arguements, which will be exported in the template PHP file.
booleanstringIf 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
objecta GP_Thing instance to validate
booleanwhether the thing is validverify_nonce(string $action) : boolean
| since | 2.0.0 |
|---|
stringContext for the created nonce.
booleanFalse 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_SetTranslation set for which to retrieve the glossary.
\GP_ProjectProject for finding potential parent projects.
\GP_GlossaryExtended glossary._bulk_approve($bulk)
_bulk_fuzzy(array $bulk)
| since | 2.3.0 |
|---|
arrayThe 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_ProjectThe project.
\GP_LocaleThe GlotPress locale.
\GP_Translation_SetThe translation set.
\GP_TranslationThe translation object.
edit_single_translation(string $project_path, string $locale_slug, string $translation_set_slug, callable $edit_function)
| since | 1.0.0 |
|---|
stringThe path of the project.
stringThe locale slug.
stringThe slug of the translation set.
callableThe 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 |
|---|
falsestringFalse 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