WPDK
1.5.0
WordPress Development Kit
|
Very useful functions for common cases. More...
Go to the source code of this file.
Functions | |
wpdk_is_bool ($str) | |
wpdk_is_url ($url) | |
wpdk_is_infinity ($value) | |
wpdk_is_ajax () | |
Ajax validation. More... | |
wpdk_is_child ($parent= '') | |
wpdk_sanitize_function ($key) | |
Sanitize for function name. More... | |
wpdk_get_image_size ($name) | |
wpdk_checked ($haystack, $current, $echo=true) | |
wpdk_selected ($haystack, $current, $echo=true) | |
wpdk_content_page_with_slug ($slug, $post_type, $alternative_slug= '') | |
wpdk_permalink_page_with_slug ($slug, $post_type= 'page') | |
wpdk_delta_object ($last_version, $old_version) | |
Object delta compare for combine. More... | |
wpdk_get_image_in_post_content ($id_post) | |
Get an img tag from the content. More... | |
wpdk_get_image_from_post_thumbnail ($id_post) | |
Get thumbnail image. More... | |
wpdk_get_image_from_attachments ($id_post) | |
Get image from post attachment. More... | |
is_wpdk_error ($thing) | |
Check whether variable is a WPDK result error. More... | |
is_wpdk_warning ($thing) | |
Check whether variable is a WPDK result warning. More... | |
is_wpdk_status ($thing) | |
Check whether variable is a WPDK result status. More... | |
wpdk_add_page ($page_slug, $page_title, $capability, $function= '', $hook_head= '', $hook_load= '') | |
Add a page. More... | |
wpdk_enqueue_script_page ($pages, $handle, $src=false, $deps=array(), $ver=false, $in_footer=false) | |
Enqueue script. More... | |
wpdk_enqueue_script_page_template ($page_templates, $handle, $src=false, $deps=array(), $ver=false, $in_footer=false) | |
Enqueue script. More... | |
wpdk_set_user_transient ($transient, $value, $expiration=0, $user_id=null) | |
Set. More... | |
wpdk_get_user_transient ($transient, $user_id=null) | |
Get. More... | |
wpdk_delete_user_transient ($transient, $user_id=null) | |
Delete. More... | |
wpdk_is_request ($verb) | |
Check request. More... | |
wpdk_is_request_get () | |
Check if request is get. More... | |
wpdk_is_request_post () | |
Check if request is post. More... | |
Very useful functions for common cases.
Infinity.
Check URI.
Check for generic boolean.
Very useful functions for common cases. All that is missing in WordPress
This file contains the pure inline function without class wrapper. You can use these function directly from code.
Return TRUE if the string NOT contains '', 'false', '0', 'no', 'n', 'off', null.
string | $str | String to check |
Return TRUE if a url is a URI
string | $url |
Check if infinity
float | string | $value | Check value |
Definition in file wpdk-functions.php.
is_wpdk_error | ( | $thing | ) |
Check whether variable is a WPDK result error.
Looks at the object and if a WPDKError class. Does not check to see if the parent is also WPDKError or a WPDKResult, so can't inherit both the classes and still use this function.
mixed | $thing | Check if unknown variable is WPDKError object. |
Definition at line 425 of file wpdk-functions.php.
is_wpdk_status | ( | $thing | ) |
Check whether variable is a WPDK result status.
Looks at the object and if a WPDKStatus class. Does not check to see if the parent is also WPDKStatus or a WPDKResult, so can't inherit both the classes and still use this function.
mixed | $thing | Check if unknown variable is WPDKStatus object. |
Definition at line 461 of file wpdk-functions.php.
is_wpdk_warning | ( | $thing | ) |
Check whether variable is a WPDK result warning.
Looks at the object and if a WPDKWarning class. Does not check to see if the parent is also WPDKWarning or a WPDKResult, so can't inherit both the classes and still use this function.
mixed | $thing | Check if unknown variable is WPDKWarning object. |
Definition at line 443 of file wpdk-functions.php.
wpdk_add_page | ( | $page_slug, | |
$page_title, | |||
$capability, | |||
$function = '' , |
|||
$hook_head = '' , |
|||
$hook_load = '' |
|||
) |
Add a page.
Add a custom hidden (without menu) page in the admin backend area and return the page's hook_suffix.
string | $page_slug | The slug name to refer to this hidden pahe by (should be unique) |
string | $page_title | The text to be displayed in the title tags of the page when the page is selected |
string | $capability | The capability required for this page to be displayed to the user. |
callback | string | $function | Optional. The function to be called to output the content for this page. |
string | $hook_head | Optional. Callback when head is loaded |
string | $hook_load | Optional. Callback when loaded |
Definition at line 485 of file wpdk-functions.php.
wpdk_checked | ( | $haystack, | |
$current, | |||
$echo = true |
|||
) |
Commodity to extends checked() WordPress function with array check
string | array | $haystack | Single value or array |
mixed | $current | (true) The other value to compare if not just true |
bool | $echo | Whether to echo or just return the string |
Definition at line 178 of file wpdk-functions.php.
wpdk_content_page_with_slug | ( | $slug, | |
$post_type, | |||
$alternative_slug = '' |
|||
) |
Get the post content from the slug.
string | $slug | Post slug |
string | $post_type | Post type |
string | $alternative_slug | Alternative slug if post not found |
Definition at line 226 of file wpdk-functions.php.
wpdk_delete_user_transient | ( | $transient, | |
$user_id = null |
|||
) |
Delete.
Delete a user transient.
do_action() Calls 'delete_user_transient_$transient' hook before transient is deleted. do_action() Calls 'deleted_user_transient' hook on success.
string | $transient | Transient name. Expected to not be SQL-escaped. |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 630 of file wpdk-functions.php.
wpdk_delta_object | ( | $last_version, | |
$old_version | |||
) |
Object delta compare for combine.
Do a merge/combine between two object tree. If the old version not contains an object or property, that is added. If the old version contains an object or property less in last version, that is deleted.
mixed | $last_version | Object tree with new or delete object/value |
mixed | $old_version | Current Object tree, loaded from serialize or database for example |
Definition at line 320 of file wpdk-functions.php.
wpdk_enqueue_script_page | ( | $pages, | |
$handle, | |||
$src = false , |
|||
$deps = array() , |
|||
$ver = false , |
|||
$in_footer = false |
|||
) |
Enqueue script.
Enqueue script for list of page template
array | $pages | Array of page slug |
string | $handle | The script /unique) handle |
bool | $src | Optional. Source URI |
array | $deps | Optional. Array of other handle |
bool | $ver | Optional. Version to avoid cache |
bool | $in_footer | Optional. Load in footer |
Definition at line 525 of file wpdk-functions.php.
wpdk_enqueue_script_page_template | ( | $page_templates, | |
$handle, | |||
$src = false , |
|||
$deps = array() , |
|||
$ver = false , |
|||
$in_footer = false |
|||
) |
Enqueue script.
Enqueue script for list of page template. Return FALSE if $page_templates is empty
array | $page_templates | Array of page slug template |
string | $handle | The script /unique) handle |
bool | $src | Optional. Source URI |
array | $deps | Optional. Array of other handle |
bool | $ver | Optional. Version to avoid cache |
bool | $in_footer | Optional. Load in footer |
Definition at line 550 of file wpdk-functions.php.
wpdk_get_image_from_attachments | ( | $id_post | ) |
Get image from post attachment.
Get src url image from first image attachment post
int | $id_post | ID post |
Definition at line 380 of file wpdk-functions.php.
wpdk_get_image_from_post_thumbnail | ( | $id_post | ) |
Get thumbnail image.
Function to find image using WP available function get_the_post_thumbnail().
int | $id_post | ID post |
Definition at line 359 of file wpdk-functions.php.
wpdk_get_image_in_post_content | ( | $id_post | ) |
Get an img tag from the content.
Get the img src value fron content of a post or page.
int | $id_post | ID post |
Definition at line 335 of file wpdk-functions.php.
wpdk_get_image_size | ( | $name | ) |
Return registered image size information
string | $name | Image size ID |
Definition at line 160 of file wpdk-functions.php.
wpdk_get_user_transient | ( | $transient, | |
$user_id = null |
|||
) |
Get.
Get the value of a user transient. If the transient does not exist or does not have a value, then the return value will be false.
apply_filters() Calls 'pre_user_transient_$transient' hook before checking the transient. Any value other than false will "short-circuit" the retrieval of the transient and return the returned value. apply_filters() Calls 'user_transient_$transient' hook, after checking the transient, with the transient value.
string | $transient | Transient name. Expected to not be SQL-escaped |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 610 of file wpdk-functions.php.
wpdk_is_ajax | ( | ) |
Ajax validation.
Return TRUE if we are called by Ajax. Used to be sure that we are responding to an HTTPRequest request and that the WordPress define DOING_AJAX is defined.
Definition at line 87 of file wpdk-functions.php.
wpdk_is_bool | ( | $str | ) |
Definition at line 33 of file wpdk-functions.php.
wpdk_is_child | ( | $parent = '' | ) |
Returns TRUE if the current page is a child of another.
array | int | string | $parent | Mixed format for parent page |
Definition at line 109 of file wpdk-functions.php.
wpdk_is_infinity | ( | $value | ) |
Definition at line 73 of file wpdk-functions.php.
wpdk_is_request | ( | $verb | ) |
Check request.
Return true if the $verb param in input match with REQUEST METHOD
string | $verb | The verb, for instance; GET, post, delete, etc... |
Definition at line 658 of file wpdk-functions.php.
wpdk_is_request_get | ( | ) |
Check if request is get.
Return true if the REQUEST METHOD is GET
Definition at line 671 of file wpdk-functions.php.
wpdk_is_request_post | ( | ) |
Check if request is post.
Return true if the REQUEST METHOD is POST
Definition at line 683 of file wpdk-functions.php.
wpdk_is_url | ( | $url | ) |
Definition at line 51 of file wpdk-functions.php.
wpdk_permalink_page_with_slug | ( | $slug, | |
$post_type = 'page' |
|||
) |
Get the post permalink from the slug.
string | $slug | Post slug |
string | $post_type | Post type. Default 'page' |
Definition at line 272 of file wpdk-functions.php.
wpdk_sanitize_function | ( | $key | ) |
Sanitize for function name.
Return a possibile function name
string | $key | String key |
Definition at line 148 of file wpdk-functions.php.
wpdk_selected | ( | $haystack, | |
$current, | |||
$echo = true |
|||
) |
Commodity to extends selected() WordPress function with array check
string | array | $haystack | Single value or array |
mixed | $current | (true) The other value to compare if not just true |
bool | $echo | Whether to echo or just return the string |
Definition at line 196 of file wpdk-functions.php.
wpdk_set_user_transient | ( | $transient, | |
$value, | |||
$expiration = 0 , |
|||
$user_id = null |
|||
) |
Set.
Set/update the value of a user transient.
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
apply_filters() Calls 'pre_set_user_transient_$transient' hook to allow overwriting the transient value to be stored. do_action() Calls 'set_user_transient_$transient' and 'setted_transient' hooks on success.
string | $transient | Transient name. Expected to not be SQL-escaped. |
mixed | $value | Transient value. Expected to not be SQL-escaped. |
int | $expiration | Time until expiration in seconds, default 0 |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 587 of file wpdk-functions.php.