Overview

Classes

  • xu
  • Xu\Foundation\Foundation
  • Xu\Foundation\Jsonable
  • Xu\Model\Collection
  • Xu\Model\Model

Functions

  • xu
  • xu_add_option
  • xu_attachment_url_to_postid
  • xu_cache_delete
  • xu_cache_delete_group
  • xu_cache_get
  • xu_cache_key
  • xu_camel_case
  • xu_clean_attachment_cache
  • xu_clean_nav_menu_cache
  • xu_clean_post_cache
  • xu_contains
  • xu_convert_to_string
  • xu_current_attachment_url_to_postid
  • xu_current_url
  • xu_current_url_to_postid
  • xu_dashify
  • xu_delete_option
  • xu_delete_site_transient
  • xu_delete_transient
  • xu_doing_ajax
  • xu_ends_with
  • xu_get_class_name
  • xu_get_model
  • xu_get_option
  • xu_get_option_name
  • xu_get_option_post_id
  • xu_get_posts
  • xu_get_site_transient
  • xu_get_top_parent_post
  • xu_get_top_parent_post_type
  • xu_get_top_parent_post_type_object
  • xu_get_transient
  • xu_is_empty
  • xu_is_http_method
  • xu_is_json
  • xu_is_post_type
  • xu_is_wp
  • xu_is_xml
  • xu_post_exists
  • xu_register_large_option_post_type
  • xu_snake_case
  • xu_starts_with
  • xu_strip_spaces
  • xu_studly_case
  • xu_update_option
  • xu_url_to_postid
  • xu_valid_personnummer
  • xu_wp_get_attachment_image
  • xu_wp_get_attachment_image_sizes
  • xu_wp_get_attachment_image_src
  • xu_wp_get_attachment_image_srcset
  • xu_wp_get_attachment_url
  • xu_wp_nav_menu
  • Overview
  • Class
 1: <?php
 2: 
 3: /**
 4:  * Delete transient by key.
 5:  *
 6:  * @param  string $key Transient name.
 7:  *
 8:  * @return bool
 9:  */
10: function xu_delete_transient( $key ) {
11:     return delete_transient( $key );
12: }
13: 
14: /**
15:  * Delete site transient by key.
16:  *
17:  * @param  string $key Transient name.
18:  *
19:  * @return bool
20:  */
21: function xu_delete_site_transient( $key ) {
22:     return delete_site_transient( $key );
23: }
24: 
25: /**
26:  * Get/Set transient.
27:  *
28:  * @param  string $key        Transient name. Should be 172 (40 on site) characters or less since WordPress will prefix the name.
29:  * @param  mixed  $value      Transient value. Expected to not be SQL-escaped. Can be callable value. Optional.
30:  * @param  int    $expiration Time until expiration in seconds from now, or 0 for never expires. Default 0.
31:  * @param  bool   $site       Set to true if site transient. Default false.
32:  *
33:  * @return mixed
34:  */
35: function xu_get_transient( $key, $value = null, $expiration = 0, $site = false ) {
36:     if ( ! is_string( $key ) ) {
37:         return false;
38:     }
39: 
40:     $transient_value = ( $site ? get_site_transient( $key ) : get_transient( $key ) );
41: 
42:     // Return transient value if it exists or the return value if given value is null.
43:     if ( $transient_value || is_null( $value ) ) {
44:         return $transient_value;
45:     }
46: 
47:     // Support callable values.
48:     if ( is_callable( $value ) ) {
49:         $value = call_user_func( $value );
50: 
51:         // Return false if null value.
52:         if ( is_null( $value ) ) {
53:             return false;
54:         }
55:     }
56: 
57:     if ( $site ) {
58:         set_site_transient( $key, $value, $expiration );
59:     } else {
60:         set_transient( $key, $value, $expiration );
61:     }
62: 
63:     return $value;
64: }
65: 
66: /**
67:  * Get/Set site transient.
68:  *
69:  * @param  string $key        Transient name. Should be 40 characters or less since WordPress will prefix the name.
70:  * @param  mixed  $value      Transient value. Expected to not be SQL-escaped. Can be callable value. Optional.
71:  * @param  int    $expiration Time until expiration in seconds from now, or 0 for never expires. Default 0.
72:  *
73:  * @return mixed
74:  */
75: function xu_get_site_transient( $key, $value = null, $expiration = 0 ) {
76:     return xu_get_transient( $key, $value, $expiration, true );
77: }
78: 
API documentation generated by ApiGen