Functions

Installs GlotPress.

_install_glotpress() 
package GlotPress

Loads GlotPress.

_load_glotpress() 
package GlotPress

Load GlotPress.

_manually_load_plugin() 
package GlotPress

display_status()

display_status($status) 
package GlotPress

Parameters

$status

Escapes translations for HTML blocks.

esc_translation(string $text) : string

Similar to esc_html(), but double encode entities.

package GlotPress
since 1.0.0

Parameters

$text

string

The text prior to being escaped.

Returns

stringThe text after it has been escaped.

Prevents executing WP_Query's default queries on GlotPress requests.

gp_abort_main_wp_query(array $sql, \WP_Query $wp_query) : string | false

The following code effectively avoid running the main WP_Query queries by setting values before they are run.

package GlotPress
link Original source.
since 1.0.0

Parameters

$sql

array

The complete SQL query.

$wp_query

\WP_Query

The WP_Query instance (passed by reference).

Returns

stringfalseFalse if GlotPress request, SQL query if not.

Perform necessary actions on activation.

gp_activate_plugin() 
package GlotPress
since 1.0.0

Maps the translation check to the translation-set.

gp_allow_approving_translations_with_validator_permissions(string|boolean $verdict, array $args) : string | boolean
package GlotPress
since 2.3.0

Parameters

$verdict

stringboolean

Previous decision whether the user can do this.

$args

array

Permission details.

Returns

stringbooleanNew decision whether the user can do this.

gp_allow_everyone_to_translate()

gp_allow_everyone_to_translate($verdict, $args) 
package GlotPress

Parameters

$verdict

$args

gp_array_all()

gp_array_all($callback, $array) 
package GlotPress

Parameters

$callback

$array

gp_array_any()

gp_array_any($callback, $array, $arg = null
package GlotPress

Parameters

$callback

$array

$arg

Makes from an array of arrays a flat array.

gp_array_flatten(array $array) : array
package GlotPress

Parameters

$array

array

the arra to flatten

Returns

arrayflattenned array

Retrieves a value from $array

gp_array_get(array $array, string $key, mixed $default = '') : mixed
package GlotPress

Parameters

$array

array

$key

string

name of array value

$default

mixed

value to return if $array[$key] doesn't exist. Default is ''

Returns

mixed$array[$key] if exists or $default

gp_array_of_array_of_things_to_json()

gp_array_of_array_of_things_to_json($array) 
package GlotPress

Parameters

$array

gp_array_of_things_to_json()

gp_array_of_things_to_json($array) 
package GlotPress

Parameters

$array

Returns an array of arrays, where the i-th array contains the i-th element from each of the argument arrays. The returned array is truncated in length to the length of the shortest argument array.

gp_array_zip() 

Previously this function was documented as:

 The function works only with numerical arrays.

However this was incorrect, this function would only return an array of arrays with numeric basic indexes, but would process any array whether it was numeric or reference based, using the order in which the array was created as the index value to return.

For example:

 $first_array[] = "First"
 $first_array[] = "Second"
 $first_array[] = "Third"

 $second_array[0]    = "Fourth"
 $second_array[test] = "Fifth"
 $second_array[1]    = "Sixth"

 $result = gp_array_zip( $first_array, $second_array );

Would produce:

 $result[0][0] = "First"
 $result[0][1] = "Fourth"
 $result[1][0] = "Second"
 $result[1][1] = "Fifth"
 $result[2][0] = "Third"
 $result[2][1] = "Sixth"

Instead of either failing (which is probably what should have happened) or something like:

 $result[0][0] = "First"
 $result[0][1] = "Fourth"
 $result[1][0] = "Second"
 $result[1][1] = "Sixth"

Or some other random result.

package GlotPress

gp_attrs_add_class()

gp_attrs_add_class($attrs, $class_name) 
package GlotPress

Parameters

$attrs

$class_name

gp_breadcrumb()

gp_breadcrumb($breadcrumb = null, $args = array()
package GlotPress

Parameters

$breadcrumb

$args

gp_breadcrumb_project()

gp_breadcrumb_project($project) 
package GlotPress

Parameters

$project

gp_checked()

gp_checked($checked) 
package GlotPress

Parameters

$checked

Delete translation set counts cache.

gp_clean_translation_set_cache(integer $id) 
package GlotPress
global bool $_wp_suspend_cache_invalidation

Parameters

$id

integer

Translation set ID.

Delete counts cache for all translation sets of a project

gp_clean_translation_sets_cache(integer $project_id) 
package GlotPress

Parameters

$project_id

integer

project ID

gp_cli_register()

gp_cli_register() 
package GlotPress

gp_const_get()

gp_const_get($name, $default = ''
package GlotPress

Parameters

$name

$default

gp_const_set()

gp_const_set($name, $value) 
package GlotPress

Parameters

$name

$value

Run the plugin de-activation code.

gp_deactivate_plugin(boolean $network_wide) 
package GlotPress
since 1.0.0

Parameters

$network_wide

boolean

Whether the plugin is deactivated for all sites in the network or just the current site.

Deletes meta data from the database.

gp_delete_meta(integer $object_id = 0, string $meta_key, mixed $meta_value, string $type, boolean $global = false) : boolean
package GlotPress
since 1.0.0

Parameters

$object_id

integer

ID of the object metadata is for.

$meta_key

string

Metadata key.

$meta_value

mixed

The value to store.

$type

string

The object type.

$global

boolean

Overrides the requirement of $object_id to be a number OR not empty.

Returns

boolean

Deletes user's permissions when they are deleted from WordPress via WP's 'deleted_user' action.

gp_delete_user_permissions($user_id) 
package GlotPress
since 1.0.0

Parameters

$user_id

Displays an admin notice on the plugins page that GlotPress has been disabled and why.

gp_display_disabled_admin_notice(string $short_notice, string $long_notice) 

.

package GlotPress
since 2.0.0

Parameters

$short_notice

string

The message to display on the first line of the notice beside "GlotPress Disabled".

$long_notice

string

The message to display below the "GlotPress Disabled" line.

gp_endswith()

gp_endswith($haystack, $needle) 
package GlotPress

Parameters

$haystack

$needle

Enqueue one or more scripts.

gp_enqueue_script(string $handle) 
package GlotPress
since 1.0.0

Parameters

$handle

string

A single script handle to enqueue.

Enqueue one or more scripts.

gp_enqueue_scripts(string|array $handles) 
package GlotPress
since 2.2.0

Parameters

$handles

stringarray

A single script handle to enqueue or an array of enqueue handles to enqueue.

Enqueue one or more styles.

gp_enqueue_style(string $handle) 
package GlotPress
since 1.0.0

Parameters

$handle

string

A single style handle to enqueue.

Enqueue one or more styles.

gp_enqueue_styles(string|array $handles) 
package GlotPress
since 2.2.0

Parameters

$handles

stringarray

A single style handle to enqueue or an array or style handles to enqueue.

gp_entry_actions()

gp_entry_actions($seperator = ' • '
package GlotPress

Parameters

$seperator

gp_error_log_dump()

gp_error_log_dump($value) 
package GlotPress

Parameters

$value

Escaping for HTML attributes.

gp_esc_attr_with_entities(string $text) : string

Similar to esc_attr(), but double encode entities.

package GlotPress
since 1.0.0

Parameters

$text

string

The text prior to being escaped.

Returns

stringThe text after it has been escaped.

Generate the WP rewrite rules.

gp_generate_rewrite_rules(string|boolean $gp_base = false) : array
package GlotPress
since 1.0.0

Parameters

$gp_base

stringboolean

Optional. The base of all GlotPress URLs. Defaults to the GP_URL_BASE constant.

Returns

arrayRewrite rules that transform the URL structure to a set of query vars

Retrieves a value from $_GET

gp_get(string $key, mixed $default = '') : mixed
package GlotPress

Parameters

$key

string

name of get value

$default

mixed

value to return if $_GET[$key] doesn't exist. Default is ''

Returns

mixed$_GET[$key] if exists or $default

Determines the format to use based on the selected format type or by auto detection based on the file name.

gp_get_import_file_format(string $selected_format, string $filename) : object | null

Used during import of translations and originals.

package GlotPress

Parameters

$selected_format

string

The format that the user selected on the import page.

$filename

string

The filname that was uploaded by the user.

Returns

objectnullA GP_Format child object or null if not found.

Retrieves and returns a meta value from the database.

gp_get_meta(string $object_type, integer $object_id, string|null $meta_key = null) : mixed | false
package GlotPress
since 1.0.0

Parameters

$object_type

string

The object type.

$object_id

integer

ID of the object metadata is for.

$meta_key

stringnull

Optional. Metadata key. Default null.

Returns

mixedfalseMetadata or false.

Returns a multi-dimensional array with the sort by types, descriptions and SQL query for each.

gp_get_sort_by_fields() : array
package GlotPress
since 2.1.0

Returns

arrayAn array of sort by field types.

Generates a list of classes to be added to the translation row, based on translation entry properties.

gp_get_translation_row_classes(\Translation_Entry $translation) : array
package GlotPress
since 2.2.0

Parameters

$translation

\Translation_Entry

The translation entry object for the row.

Returns

array

Converts a string represented time/date to a utime int, adding a GMT offset if not found.

gp_gmt_strtotime(string $string) : integer
package GlotPress
since 1.0.0

Parameters

$string

string

The string representation of the time to convert.

Returns

integer

Has this translation been updated since the passed timestamp?

gp_has_translation_been_updated(\GP_Translation_Set $translation_set, integer $timestamp = 0) : boolean
package GlotPress

Parameters

$translation_set

\GP_Translation_Set

Translation to check

$timestamp

integer

Optional; unix timestamp to compare against. Defaults to HTTP_IF_MODIFIED_SINCE if set.

Returns

boolean

gp_head()

gp_head() 
package GlotPress

gp_html_attributes()

gp_html_attributes($attrs) 
package GlotPress

Parameters

$attrs

gp_html_excerpt()

gp_html_excerpt($str, $count, $ellipsis = '…'
package GlotPress

Parameters

$str

$count

$ellipsis

gp_in()

gp_in($needle, $haystack) 
package GlotPress

Parameters

$needle

$haystack

Initializes rewrite rules and provides the 'gp_init' action.

gp_init() 
package GlotPress
since 1.0.0

Checks if the passed value is between the start and end value or is the same.

gp_is_between(string $value, $start, $end) : boolean
package GlotPress

Parameters

$value

stringstringstring

The value you want to check.

$start

$end

Returns

boolean

Checks if the passed value is between the start and end value.

gp_is_between_exclusive(string $value, $start, $end) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

$start

$end

Returns

boolean

Checks if the passed value is empty.

gp_is_empty(string $value) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

Returns

boolean

Checks if the passed value is an empty string.

gp_is_empty_string(string $value) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

Returns

boolean

Checks if the passed value is an integer.

gp_is_int(integer|string $value) : boolean
package GlotPress

Parameters

$value

integerstring

The value you want to check.

Returns

boolean

Checks if the passed value isn't an empty string.

gp_is_not_empty_string(string $value) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

Returns

boolean

Checks if the passed value is not null.

gp_is_not_null(string $value) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

Returns

boolean

Checks if the passed value is null.

gp_is_null(string $value) : boolean
package GlotPress

Parameters

$value

string

The value you want to check.

Returns

boolean

Checks if the passed value is a positive integer.

gp_is_positive_int(integer $value) : boolean
package GlotPress

Parameters

$value

integer

The value you want to check.

Returns

boolean

gp_js_focus_on()

gp_js_focus_on($html_id) 
package GlotPress

Parameters

$html_id

gp_levenshtein()

gp_levenshtein($str1, $str2, $length1, $length2) 
package GlotPress

Parameters

$str1

$str2

$length1

$length2

Returns HTML markup for a select element for all locales of a project.

gp_locales_by_project_dropdown(integer $project_id, string $name_and_id, string $selected_slug = null, array $attrs = array()) : string
package GlotPress
since 1.0.0

Parameters

$project_id

integer

ID of a project.

$name_and_id

string

Name and ID of the select element.

$selected_slug

string

Slug of the current selected locale.

$attrs

array

Extra attributes.

Returns

stringHTML markup for a select element.

Returns HTML markup for a select element for all locales.

gp_locales_dropdown(string $name_and_id, string $selected_slug = null, array $attrs = array()) : string
package GlotPress
since 1.0.0

Parameters

$name_and_id

string

Name and ID of the select element.

$selected_slug

string

Slug of the current selected locale.

$attrs

array

Extra attributes.

Returns

stringHTML markup for a select element.

gp_member_get()

gp_member_get($object, $key, $default = ''
package GlotPress

Parameters

$object

$key

$default

gp_nav_menu()

gp_nav_menu($location = 'main'
package GlotPress

Parameters

$location

gp_nav_menu_items()

gp_nav_menu_items($location = 'main'
package GlotPress

Parameters

$location

Retrieves a notice message, set by {@link gp_notice()}

gp_notice(string $key = 'notice'
package GlotPress

Parameters

$key

string

Optional. Message key. The default is 'notice'

Passes the message set through the next redirect.

gp_notice_set(string $message, string $key = 'notice'

Works best for edit requests, which want to pass error message or notice back to the listing page.

package GlotPress

Parameters

$message

string

The message to be passed.

$key

string

Optional. Key for the message. You can pass several messages under different keys. A key has one message. The default is 'notice'.

gp_object_has_var()

gp_object_has_var($object, $var_name) 
package GlotPress

Parameters

$object

$var_name

gp_pagination()

gp_pagination($page, $per_page, $objects) 
package GlotPress

Parameters

$page

$per_page

$objects

Fires during the WP parse_request hook to check to see if we're on a GlotPress page, if so we can abort the main WP_Query logic as we won't need it in GlotPress.

gp_parse_request() 

a matching page.

package GlotPress
since 1.0.0

gp_plugin_url()

gp_plugin_url($path = ''
package GlotPress

Parameters

$path

gp_populate_notices()

gp_populate_notices() 
package GlotPress

Retrieves a value from $_POST

gp_post(string $key, mixed $default = '') : mixed
package GlotPress

Parameters

$key

string

name of post value

$default

mixed

value to return if $_POST[$key] doesn't exist. Default is ''

Returns

mixed$_POST[$key] if exists or $default

gp_preferred_sans_serif_style_tag()

gp_preferred_sans_serif_style_tag($locale) 
package GlotPress

Parameters

$locale

Prepares a translation string to be printed out in a translation row by adding an 'extra' return/newline if it starts with one.

gp_prepare_translation_textarea(string $text) : string
package GlotPress
since 2.4.0

Parameters

$text

string

A single style handle to enqueue or an array or style handles to enqueue.

Returns

stringThe prepared string for output.

Print the scripts that have been enqueued.

gp_print_scripts() 

Only output the scripts that GlotPress has registered, otherwise we'd be sending any scripts that the WordPress theme or plugins may have enqueued.

package GlotPress
since 2.2.0

Print the styles that have been enqueued.

gp_print_styles() 

Only output the styles that GlotPress has registered, otherwise we'd be sending any style that the WordPress theme or plugins may have enqueued.

package GlotPress
since 2.2.0

gp_project_actions()

gp_project_actions($project, $translation_sets) 
package GlotPress

Parameters

$project

$translation_sets

gp_project_names_from_root()

gp_project_names_from_root($leaf_project) 
package GlotPress

Parameters

$leaf_project

gp_project_options_form()

gp_project_options_form($project) 
package GlotPress

Parameters

$project

Returns HTML markup for a select element for projects.

gp_projects_dropdown(string $name_and_id, string $selected_project_id = null, array $attrs = array(), array $exclude = array(), array $exclude_no_parent = false) : string
package GlotPress
since 1.0.0

Parameters

$name_and_id

string

Name and ID of the select element.

$selected_project_id

string

The project id to mark as the currently selected.

$attrs

array

Extra attributes.

$exclude

array

An array of locales to exclude from the list.

$exclude_no_parent

array

Exclude the "No Parent" option from the list of locales.

Returns

stringHTML markup for a select element.

Query vars for GP rewrite rules

gp_query_vars($query_vars) 
package GlotPress
since 1.0.0

Parameters

$query_vars

gp_radio_buttons()

gp_radio_buttons($name, $radio_buttons, $checked_key) 
package GlotPress

Parameters

$name

$radio_buttons

$checked_key

Filter for can_user, which tries if the user has permissions on project parents

gp_recurse_project_permissions($verdict, $args) 
package GlotPress

Parameters

$verdict

$args

gp_recurse_validator_permission()

gp_recurse_validator_permission($verdict, $args) 
package GlotPress

Parameters

$verdict

$args

Register the GlotPress scripts.

gp_register_default_scripts() 
package GlotPress

Registers the GlotPress styles and loads the base style sheet.

gp_register_default_styles() 
package GlotPress

Add WP rewrite rules to avoid WP thinking that GP pages are 404.

gp_rewrite_rules() 
package GlotPress
since 1.0.0

Prints a nonce hidden field for route actions.

gp_route_nonce_field(integer|string $action, boolean $echo = true) : string
package GlotPress
since 2.0.0
see

Parameters

$action

integerstring

Action name.

$echo

boolean

Optional. Whether to display or return hidden form field. Default true.

Returns

stringNonce field HTML markup.

Retrieves a URL with a nonce added to URL query for route actions.

gp_route_nonce_url(string $url, integer|string $action) : string
package GlotPress
since 2.0.0
see

Parameters

$url

string

URL to add nonce action.

$action

integerstring

Action name.

Returns

stringEscaped URL with nonce action added.

gp_route_translation_set_permissions_to_validator_permissions()

gp_route_translation_set_permissions_to_validator_permissions($verdict, $args) 
package GlotPress

Parameters

$verdict

$args

GP run route

gp_run_route() 
package GlotPress
since 1.0.0

Sanitizes a key name to be used to store meta data in to the database.

gp_sanitize_meta_key(string $key) : string
package GlotPress
since 1.0.0

Parameters

$key

string

Metadata key.

Returns

string

Sanitizes a string for use as a slug, replacing whitespace and a few other characters with dashes.

gp_sanitize_slug(string $slug) : string

Limits the output to alphanumeric characters, underscore (_), periods (.) and dash (-). Whitespace becomes a dash.

package GlotPress
since 2.1.0

Parameters

$slug

string

The string to be sanitized for use as a slug.

Returns

stringThe sanitized title.

Includes the database schema definitions and comments

gp_schema_get() 
package GlotPress

gp_select()

gp_select($name_and_id, $options, $selected_key, $attrs = array()
package GlotPress

Parameters

$name_and_id

$options

$selected_key

$attrs

Makes all key/value pairs in $vars global variables

gp_set_globals($vars) 
package GlotPress

Parameters

$vars

Sets `WP_Query->is_home` to false during GlotPress requests.

gp_set_is_home_false(\WP_Query $query) 
package GlotPress
since 1.0.0

Parameters

$query

\WP_Query

The WP_Query instance.

Sort a set of glossary entries by length for use in map_glossary_entries_to_translation_originals().

gp_sort_glossary_entries_terms(array $glossary_entries) : array
package GlotPress

Parameters

$glossary_entries

array

An array of glossary entries to sort.

Returns

arrayThe sorted entries.

Functions, which make work with strings easier

gp_startswith($haystack, $needle) 
package GlotPress

Parameters

$haystack

$needle

gp_string_similarity()

gp_string_similarity($str1, $str2) 
package GlotPress

Parameters

$str1

$str2

Compat function to mimic mb_stripos().

gp_stripos(string $haystack, string $needle, integer $offset = 0, string|null $encoding = null) : integer | false

Falls back to stripos() if mb_stripos() doesn't exists.

package GlotPress
since 1.0.0

Parameters

$haystack

string

The string from which to get the position of the first occurrence of needle.

$needle

string

The string to find in haystack.

$offset

integer

The position in haystack to start searching.

$encoding

stringnull

Optional. Character encoding to use. Default null.

Returns

integerfalseThe numeric position of the first occurrence of needle in the haystack string, or false if needle is not found.

Compat function to mimic mb_strlen().

gp_strlen(string $str, string|null $encoding = null) : integer

Without a function_exists() check because WordPress includes a compat function for mb_strlen().

package GlotPress
since 1.0.0
see

Parameters

$str

string

The string to retrieve the character length from.

$encoding

stringnull

Optional. Character encoding to use. Default null.

Returns

integerString length of `$str`.

Compat function to mimic mb_strtolower().

gp_strtolower(string $str, string|null $encoding = null) : integer

Falls back to strtolower() if mb_strtolower() doesn't exists.

package GlotPress
since 1.0.0

Parameters

$str

string

The string being lowercased.

$encoding

stringnull

Optional. Character encoding to use. Default null.

Returns

integerString length of `$str`.

Compat function to mimic mb_substr().

gp_substr(string $str, integer $start, integer|null $length, string|null $encoding = null) : string

Without a function_exists() check because WordPress includes a compat function for mb_substr().

package GlotPress
since 1.0.0
see

Parameters

$str

string

The string to extract the substring from.

$start

integer

Position to being extraction from in $str.

$length

integernull

Optional. Maximum number of characters to extract from $str. Default null.

$encoding

stringnull

Optional. Character encoding to use. Default null.

Returns

stringExtracted substring.

gp_title()

gp_title($title = null
package GlotPress

Parameters

$title

gp_tmpl_404()

gp_tmpl_404($args = array()
package GlotPress

Parameters

$args

gp_tmpl_filter_args()

gp_tmpl_filter_args($args) 
package GlotPress

Parameters

$args

gp_tmpl_get_output()

gp_tmpl_get_output() 
package GlotPress

gp_tmpl_header()

gp_tmpl_header($args = array()
package GlotPress

Parameters

$args

gp_tmpl_load()

gp_tmpl_load($template, $args = array(), $template_path = null
package GlotPress

Parameters

$template

$args

$template_path

Outputs space separated list of classes for the translation row, based on translation entry properties.

gp_translation_row_classes(\Translation_Entry $translation) : void
package GlotPress
since 2.2.0

Parameters

$translation

\Translation_Entry

The translation entry object for the row.

Output the bulk actions toolbar in the translations page.

gp_translations_bulk_actions_toolbar(string $bulk_action, string $can_write, string $translation_set, string $location = 'top'
package GlotPress

Parameters

$bulk_action

string

The URL to submit the form to.

$can_write

string

Can the current user write translations to the database.

$translation_set

string

The current translation set.

$location

string

The location of this toolbar, used to make id's unique for each instance on a page.

Adds a message if the required minimum PHP version is not detected.

gp_unsupported_php_version_notice() 

Message is only displayed on the plugin screen.

package GlotPress
since 2.0.0

Adds a message if an incompatible version of WordPress is running.

gp_unsupported_version_admin_notice() 

Message is only displayed on the plugin screen.

package GlotPress
since 1.0.0

Adds and updates meta data in the database

gp_update_meta(integer $object_id = 0, string $meta_key, mixed $meta_value, string $type, boolean $global = false) : boolean | integer
package GlotPress
since 1.0.0

Parameters

$object_id

integer

ID of the object metadata is for.

$meta_key

string

Metadata key.

$meta_value

mixed

The value to store.

$type

string

The object type.

$global

boolean

Overrides the requirement of $object_id to be a number OR not empty.

Returns

booleanintegerTrue if meta updated, false if there is an error and the id of the inserted row otherwise.

Updates existing data in the database during an upgrade.

gp_upgrade_data(integer $db_version) 
package GlotPress
since 1.0.0

Parameters

$db_version

integer

The current version of the database before the upgrade.

Runs the install/upgrade of the database.

gp_upgrade_db() 
package GlotPress
since 1.0.0

Builds a URL relative to the GlotPress' domain root.

gp_url(mixed $path = '/', array $query = null
package GlotPress

Parameters

$path

mixed

string path or array of path components

$query

array

associative array of query arguments (optional)

gp_url_add_path_and_query()

gp_url_add_path_and_query($base, $path, $query) 
package GlotPress

Parameters

$base

$path

$query

gp_url_base_path()

gp_url_base_path() 
package GlotPress

The URL of the current page

gp_url_current() 
package GlotPress

Get the URL for an image file

gp_url_img(string $file) : string
package GlotPress

Parameters

$file

string

Image filename

Returns

string

Joins paths, and takes care of slashes between them

gp_url_join() : string

Example: gp_url_join( '/project', array( 'wp', 'dev) ) -> '/project/wp/dev'

The function will keep leading and trailing slashes of the whole URL, but won't allow more than consecutive slash inside.

package GlotPress

Returns

stringURL, built of all the components, separated with /

Returns the path of an URL.

gp_url_path(string $url = null) : string
package GlotPress
since 1.0.0

Parameters

$url

string

Optional. The URL to parse. Defaults to GlotPress URL.

Returns

stringPath of the URL. Empty string if no path was parsed.

gp_url_profile()

gp_url_profile($user_nicename = ''
package GlotPress

Parameters

$user_nicename

Get the URL for a project

gp_url_project(boolean|string|object $project_or_path = '', string|array $path = '', array $query = null) : string

A leading double-slash will avoid prepending /projects/ to the path.

package GlotPress

Parameters

$project_or_path

booleanstringobject

Project path or object

$path

stringarray

Addition path to append to the base path

$query

array

associative array of query arguments (optional)

Returns

string

Constructs URL for a project and locale.

gp_url_project_locale($project_or_path, $locale, $path = '', $query = null

////

package GlotPress

Parameters

$project_or_path

$locale

$path

$query

gp_url_public_root()

gp_url_public_root() 
package GlotPress

Converts an absolute URL to the corresponding SSL URL if the GlotPress settings allow SSL

gp_url_ssl($url) 
package GlotPress

Parameters

$url

gp_urldecode_deep()

gp_urldecode_deep($value) 
package GlotPress

Parameters

$value

Displays the GlotPress administrator option in the user profile screen for WordPress administrators.

gp_wp_profile_options(\WP_User $user) 
package GlotPress
since 2.0.0

Parameters

$user

\WP_User

The WP_User object to display the profile for.

Saves the settings for the GlotPress administrator option in the user profile screen for WordPress administrators.

gp_wp_profile_options_update(integer $user_id) 
package GlotPress
since 2.0.0

Parameters

$user_id

integer

The WordPress user id to save the setting for.

Determine if the page requested is handled by GlotPress.

is_glotpress() : boolean
package GlotPress
since 1.0.0

Returns

booleanWhether the request is handled by GlotPress.

Add markup to a translation original to identify the glossary terms.

map_glossary_entries_to_translation_originals(\GP_Translation $translation, \GP_Glossary $glossary, array $glossary_entries_terms = null) : \obj
package GlotPress

Parameters

$translation

\GP_Translation

A GP Translation object.

$glossary

\GP_Glossary

A GP Glossary object.

$glossary_entries_terms

array

A list of terms to highligh.

Returns

\objThe marked up translation entry.

Prepare an original string to be printed out in a translation row by adding encoding special characters, adding glossary entires and other markup.

prepare_original(string $text) : string
package GlotPress

Parameters

$text

string

A single style handle to enqueue or an array or style handles to enqueue.

Returns

stringThe prepared string for output.

references()

references($project, $entry) 
package GlotPress

Parameters

$project

$entry

textareas()

textareas($entry, $permissions, $index = 0
package GlotPress

Parameters

$entry

$permissions

$index

things_to_fields()

things_to_fields($data) 
package GlotPress

Parameters

$data

Classes, interfaces, and traits

GP

Core class used to store singleton instances.

« More »

GP_Administrator_Permission

Core class used to implement the administrator permissions.

« More »

GP_Builtin_Translation_Warnings

Class used to register built-in translation warnings.

« More »

GP_CLI_Add_Admin

« More »

GP_CLI_Branch_Project

« More »

GP_CLI_Import_Originals

« More »

GP_CLI_Regenerate_Paths

« More »

GP_CLI_Remove_Multiple_Currents

« More »

GP_CLI_Translation_Set

« More »

GP_CLI_Upgrade_Set_Permissions

« More »

GP_CLI_Wipe_Permissions

« More »

GP_Format

GlotPress Format base class. It is supposed to be inherited.

« More »

GP_Format_Android

Format class used to support Android XML file format.

« More »

GP_Format_JSON

Format class used to support JSON file format.

« More »

GP_Format_Jed1x

Format class used to support Jed 1.x compatible JSON file format.

« More »

GP_Format_MO

GlotPress Format base class. It is supposed to be inherited.

« More »

GP_Format_NGX

Format class used to support NGX Translate JSON file format.

« More »

GP_Format_PO

GlotPress Format base class. It is supposed to be inherited.

« More »

GP_Format_Properties

GlotPress Format base class. It is supposed to be inherited.

« More »

GP_Format_ResX

GlotPress Format base class. It is supposed to be inherited.

« More »

GP_Format_Strings

Format class used to support Mac OS X / iOS Translate strings file format.

« More »

GP_Glossary

Core class used to implement the glossaries.

« More »

GP_Glossary_Entry

Core class used to implement the glossary entries.

« More »

GP_Import

« More »

GP_Locale

« More »

GP_Locales

« More »

GP_My_Table

Core base class extended to register things.

« More »

GP_Note

Core class used to implement the notes system.

« More »

GP_Original

Core class used to implement the originals.

« More »

GP_Permission

Core class used to implement the permissions.

« More »

GP_Project

Core class used to implement the projects.

« More »

GP_Route

Base controller class

« More »

GP_Route_Glossary

Core class used to implement the glossary route.

« More »

GP_Route_Glossary_Entry

Core class used to implement the glossary entry route.

« More »

GP_Route_Index

Core class used to implement the index route.

« More »

GP_Route_Locale

Core class used to implement the locale route.

« More »

GP_Route_Main

Core class used to implement the main route.

« More »

GP_Route_Note

Class for all note related actions

« More »

GP_Route_Original

Core class used to implement the original route.

« More »

GP_Route_Profile

Core class used to implement the profile route.

« More »

GP_Route_Project

Core class used to implement the project route.

« More »

GP_Route_Settings

Core class used to implement the settings route.

« More »

GP_Route_Translation

Core class used to implement the translation route.

« More »

GP_Route_Translation_Set

Core class used to implement the translation set route.

« More »

GP_Router

« More »

GP_Test_Builtin_Translation_Warnings

« More »

GP_Test_Default_Factories

« More »

GP_Test_Format_Android

« More »

GP_Test_Format_JSON

« More »

GP_Test_Format_Jed1x

« More »

GP_Test_Format_MO

« More »

GP_Test_Format_NGX

« More »

GP_Test_Format_PO

« More »

GP_Test_Format_Properties

« More »

GP_Test_Format_ResX

« More »

GP_Test_Format_Strings

« More »

GP_Test_Glossary

« More »

GP_Test_Glossary_Entry

« More »

GP_Test_JSON_Pretty_Print

« More »

GP_Test_Locale

« More »

GP_Test_Meta

« More »

GP_Test_Misc

« More »

GP_Test_NOOP_Translations

« More »

GP_Test_Note

« More »

GP_Test_Permissions

« More »

GP_Test_Project

« More »

GP_Test_Projects_API

« More »

GP_Test_Route

« More »

GP_Test_Route_Note

« More »

GP_Test_Route_Translation

« More »

GP_Test_Route_Translation_Set

« More »

GP_Test_Strings

« More »

GP_Test_Template_Functions

« More »

GP_Test_Template_Helper_Functions

« More »

GP_Test_Thing

« More »

GP_Test_Thing_Original

« More »

GP_Test_Thing_Translation

« More »

GP_Test_Thing_Translation_set

« More »

GP_Test_Translation_Entry

« More »

GP_Test_Translation_Warnings

« More »

GP_Test_Translations

« More »

GP_Test_Unittest_Factory

« More »

GP_Test_Urls

« More »

GP_Test_Validation

« More »

GP_Thing

Core base class extended to register things.

« More »

GP_Thing_Test_Factory

« More »

GP_Translation

Core class used to implement the translations.

« More »

GP_Translation_Set

Core class used to implement the translation sets.

« More »

GP_Translation_Warnings

Class used to handle translation warnings.

« More »

GP_UnitTestCase

« More »

GP_UnitTestCase_Request

« More »

GP_UnitTestCase_Route

« More »

GP_UnitTest_Factory

« More »

GP_UnitTest_Factory_Callback_After_Create

« More »

GP_UnitTest_Factory_For_Glossary

« More »

GP_UnitTest_Factory_For_Locale

« More »

GP_UnitTest_Factory_For_Original

« More »

GP_UnitTest_Factory_For_Project

« More »

GP_UnitTest_Factory_For_Thing

« More »

GP_UnitTest_Factory_For_Translation

« More »

GP_UnitTest_Factory_For_Translation_Set

« More »

GP_UnitTest_Factory_For_User

« More »

GP_UnitTest_Generator_Locale_Name

« More »

GP_UnitTest_Generator_Sequence

« More »

GP_Validation_Rules

Core class to handle validation of translations.

« More »

GP_Validator_Permission

Core class used to implement the validator permissions.

« More »

GP_Validators

« More »

MockOriginal

Core class used to implement the originals.

« More »

Mouse

Core base class extended to register things.

« More »

Testable_GP_Format_MO

Class used test private/protected and/or override methods.

« More »

Testable_GP_Format_PO

Class used test private/protected and/or override methods.

« More »

Testable_GP_Format_Strings_escape

Class that makes it possible to test protected functions.

« More »

Testable_GP_Route_Translation

Class that makes it possible to test protected functions.

« More »

Constants

 

$name

$name = $value 
package GlotPress
 

DATE_MYSQL

DATE_MYSQL = 'Y-m-d H:i:s' 
package GlotPress
 

GP_CACHE_VERSION

GP_CACHE_VERSION = '3.0' 
package GlotPress
 

GP_DB_VERSION

GP_DB_VERSION = '990' 
package GlotPress
 

GP_DIR_TESTDATA

GP_DIR_TESTDATA = GP_TESTS_DIR . '/data' 
package GlotPress
 

GP_INC

GP_INC = 'gp-includes/' 
package GlotPress
 

GP_LOCALES_PATH

GP_LOCALES_PATH = GP_PATH . 'locales/' 
package GlotPress
 

GP_PATH

GP_PATH = __DIR__ . '/' 
package GlotPress
 

GP_PHP_REQUIRED_VERSION

GP_PHP_REQUIRED_VERSION = '5.6' 
package GlotPress
 

GP_PLUGIN_FILE

GP_PLUGIN_FILE = __FILE__ 
package GlotPress
 

GP_ROUTING

GP_ROUTING = true 
package GlotPress
 

GP_ROUTING

GP_ROUTING = false 
package GlotPress
 

GP_TESTS_DIR

GP_TESTS_DIR = dirname(__DIR__) 
package GlotPress
 

GP_TESTS_PATH

GP_TESTS_PATH = GP_PATH . 't/' 
package GlotPress
     

GP_TMPL_PATH

GP_TMPL_PATH = GP_PATH . 'gp-templates/' 
package GlotPress
 

GP_VERSION

GP_VERSION = '2.4.0-alpha' 
package GlotPress
 

GP_WP_REQUIRED_VERSION

GP_WP_REQUIRED_VERSION = '4.4' 
package GlotPress
 

WP_ROOT_DIR

WP_ROOT_DIR = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) 
package GlotPress
 

WP_TESTS_CONFIG_PATH

WP_TESTS_CONFIG_PATH = dirname(dirname(WP_TESTS_DIR)) . '/wp-tests-config.php' 
package GlotPress
 

WP_TESTS_DIR

WP_TESTS_DIR = WP_ROOT_DIR . '/tests/phpunit' 
package GlotPress