[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/ -> misc.php (summary)

(no description)

File Size: 622 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 35 functions

  gp_post()
  gp_get()
  gp_route_nonce_field()
  gp_route_nonce_url()
  gp_array_get()
  gp_const_get()
  gp_const_set()
  gp_member_get()
  gp_array_flatten()
  gp_notice_set()
  gp_notice()
  gp_populate_notices()
  gp_array_zip()
  gp_array_any()
  gp_array_all()
  gp_error_log_dump()
  gp_object_has_var()
  gp_has_translation_been_updated()
  gp_clean_translation_set_cache()
  gp_clean_translation_sets_cache()
  gp_is_empty()
  gp_is_empty_string()
  gp_is_not_empty_string()
  gp_is_positive_int()
  gp_is_int()
  gp_is_null()
  gp_is_not_null()
  gp_is_between()
  gp_is_between_exclusive()
  gp_set_cookie()
  gp_gmt_strtotime()
  gp_get_import_file_format()
  gp_wp_profile_options()
  gp_wp_profile_options_update()
  gp_get_sort_by_fields()

Functions
Functions that are not part of a class:

gp_post( $key, $default = '' )   X-Ref
Retrieves a value from $_POST

param: string $key name of post value
param: mixed $default value to return if $_POST[$key] doesn't exist. Default is ''
return: mixed $_POST[$key] if exists or $default

gp_get( $key, $default = '' )   X-Ref
Retrieves a value from $_GET

param: string $key name of get value
param: mixed $default value to return if $_GET[$key] doesn't exist. Default is ''
return: mixed $_GET[$key] if exists or $default

gp_route_nonce_field( $action, $echo = true )   X-Ref
Prints a nonce hidden field for route actions.

since: 2.0.0
param: int|string $action Action name.
param: bool       $echo   Optional. Whether to display or return hidden form field. Default true.
return: string Nonce field HTML markup.

gp_route_nonce_url( $url, $action )   X-Ref
Retrieves a URL with a nonce added to URL query for route actions.

since: 2.0.0
param: string     $url    URL to add nonce action.
param: int|string $action Action name.
return: string Escaped URL with nonce action added.

gp_array_get( $array, $key, $default = '' )   X-Ref
Retrieves a value from $array

param: array $array
param: string $key name of array value
param: mixed $default value to return if $array[$key] doesn't exist. Default is ''
return: mixed $array[$key] if exists or $default

gp_const_get( $name, $default = '' )   X-Ref
No description

gp_const_set( $name, $value )   X-Ref
No description

gp_member_get( $object, $key, $default = '' )   X-Ref
No description

gp_array_flatten( $array )   X-Ref
Makes from an array of arrays a flat array.

param: array $array the arra to flatten
return: array flattenned array

gp_notice_set( $message, $key = 'notice' )   X-Ref
Passes the message set through the next redirect.

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

param: string $message The message to be passed.
param: string $key     Optional. Key for the message. You can pass several messages under different keys.

gp_notice( $key = 'notice' )   X-Ref
Retrieves a notice message, set by {@link gp_notice()}

param: string $key Optional. Message key. The default is 'notice'

gp_populate_notices()   X-Ref
No description

gp_array_zip()   X-Ref
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.

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.


gp_array_any( $callback, $array, $arg = null )   X-Ref
No description

gp_array_all( $callback, $array )   X-Ref
No description

gp_error_log_dump( $value )   X-Ref
No description

gp_object_has_var( $object, $var_name )   X-Ref
No description

gp_has_translation_been_updated( $translation_set, $timestamp = 0 )   X-Ref
Has this translation been updated since the passed timestamp?

param: GP_Translation_Set $translation_set Translation to check
param: int $timestamp Optional; unix timestamp to compare against. Defaults to HTTP_IF_MODIFIED_SINCE if set.
return: bool

gp_clean_translation_set_cache( $id )   X-Ref
Delete translation set counts cache.

param: int $id Translation set ID.

gp_clean_translation_sets_cache( $project_id )   X-Ref
Delete counts cache for all translation sets of a project

param: int $project_id project ID

gp_is_empty( $value )   X-Ref
Checks if the passed value is empty.

param: string $value The value you want to check.
return: bool

gp_is_empty_string( $value )   X-Ref
Checks if the passed value is an empty string.

param: string $value The value you want to check.
return: bool

gp_is_not_empty_string( $value )   X-Ref
Checks if the passed value isn't an empty string.

param: string $value The value you want to check.
return: bool

gp_is_positive_int( $value )   X-Ref
Checks if the passed value is a positive integer.

param: int $value The value you want to check.
return: bool

gp_is_int( $value )   X-Ref
Checks if the passed value is an integer.

param: int|string $value The value you want to check.
return: bool

gp_is_null( $value )   X-Ref
Checks if the passed value is null.

param: string $value The value you want to check.
return: bool

gp_is_not_null( $value )   X-Ref
Checks if the passed value is not null.

param: string $value The value you want to check.
return: bool

gp_is_between( $value, $start, $end )   X-Ref
Checks if the passed value is between the start and end value or is the same.

param: string $value The value you want to check.
param: string $value The lower value you want to check against.
param: string $value The upper value you want to check against.
return: bool

gp_is_between_exclusive( $value, $start, $end )   X-Ref
Checks if the passed value is between the start and end value.

param: string $value The value you want to check.
return: bool

gp_set_cookie()   X-Ref
Acts the same as core PHP setcookie() but its arguments are run through the gp_set_cookie filter.

If the filter returns false, setcookie() isn't called.

gp_gmt_strtotime( $string )   X-Ref
Converts a string represented time/date to a utime int, adding a GMT offset if not found.

since: 1.0.0
param: string $string The string representation of the time to convert.
return: int

gp_get_import_file_format( $selected_format, $filename )   X-Ref
Determines the format to use based on the selected format type or by auto detection based on the file name.

Used during import of translations and originals.

param: string $selected_format The format that the user selected on the import page.
param: string $filename The filname that was uploaded by the user.
return: object|null A GP_Format child object or null if not found.

gp_wp_profile_options( $user )   X-Ref
Displays the GlotPress administrator option in the user profile screen for WordPress administrators.

since: 2.0.0
param: WP_User $user The WP_User object to display the profile for.

gp_wp_profile_options_update( $user_id )   X-Ref
Saves the settings for the GlotPress administrator option in the user profile screen for WordPress administrators.

since: 2.0.0
param: int $user_id The WordPress user id to save the setting for.

gp_get_sort_by_fields()   X-Ref
Returns a multi-dimensional array with the sort by types, descriptions and SQL query for each.

since: 2.1.0
return: array An array of sort by field types.



Generated: Tue Mar 19 01:01:50 2019 Cross-referenced by PHPXref 0.7.1