public static
integer|false
|
#
image_id_from_url( string $img_url )
Utility method that attempts to get an attachment's ID by it's url
Utility method that attempts to get an attachment's ID by it's url
Parameters
Returns
integer|false Attachment ID or false
Since
1.0.0
|
public static
array
|
#
get_available_image_sizes( )
Utility method to get a combined list of default and custom registered image sizes
Utility method to get a combined list of default and custom registered image sizes
Returns
array The image sizes
Since
2.2.4
Link
|
public static
false|string
|
#
get_named_size( array|string $size )
Utility method to return the closest named size from an array of values
Utility method to return the closest named size from an array of values
Based off of WordPress's image_get_intermediate_size()
If the size matches an existing size then it will be used. If there is no
direct match, then the nearest image size larger than the specified size
will be used. If nothing is found, then the function will return false.
Uses get_available_image_sizes() to get all available sizes.
Parameters
- $size
- Image size. Accepts an array of width and height (in that order).
Returns
false|string Named image size e.g. 'thumbnail'
Since
2.2.4
|
public static
string
|
#
timezone_offset( string $tzstring )
Utility method that returns time string offset by timezone
Utility method that returns time string offset by timezone
Parameters
Returns
string Offset time string
Since
1.0.0
|
public static
string
|
#
timezone_string( )
Utility method that returns a timezone string representing the default timezone for the site.
Utility method that returns a timezone string representing the default timezone for the site.
Roughly copied from WordPress, as get_option('timezone_string') will return
an empty string if no value has been set on the options page.
A timezone string is required by the wp_timezone_choice() used by the
select_timezone field.
Returns
string Timezone string
Since
1.0.0
|
public static
integer
|
#
make_valid_time_stamp( string|integer $string )
Returns a unix timestamp, first checking if value already is a timestamp.
Returns a unix timestamp, first checking if value already is a timestamp.
Parameters
- $string
- Possible timestamp string.
Returns
integer Time stamp.
Since
2.0.0
|
public static
boolean
|
#
is_valid_date( mixed $date )
Determine if a value is a valid date.
Determine if a value is a valid date.
Parameters
Returns
boolean Whether value is a valid date
Since
2.9.1
|
public static
boolean
|
#
is_valid_time_stamp( mixed $timestamp )
Determine if a value is a valid timestamp
Determine if a value is a valid timestamp
Parameters
- $timestamp
- Value to check.
Returns
boolean Whether value is a valid timestamp
Since
2.0.0
|
public static
boolean
|
#
isempty( mixed $value )
Checks if a value is 'empty'. Still accepts 0.
Checks if a value is 'empty'. Still accepts 0.
Parameters
Returns
boolean True or false
Since
2.0.0
|
public static
boolean
|
#
notempty( mixed $value )
Checks if a value is not 'empty'. 0 doesn't count as empty.
Checks if a value is not 'empty'. 0 doesn't count as empty.
Parameters
Returns
boolean True or false
Since
2.2.2
|
public static
array
|
#
filter_empty( mixed $value )
Filters out empty values (not including 0).
Filters out empty values (not including 0).
Parameters
Returns
array True or false.
Since
2.2.2
|
public static
|
#
array_insert( array & $array, array $new, integer $position )
Insert a single array item inside another array at a set position
Insert a single array item inside another array at a set position
Parameters
- $array
- Array to modify. Is passed by reference, and no return is needed. Passed by reference.
- $new
- New array to insert.
- $position
- Position in the main array to insert the new array.
Since
2.0.2
|
public static
string
|
#
url( string $path = '' )
Defines the url which is used to load local resources.
This may need to be filtered for local Window installations.
If resources do not load, please check the wiki for details.
Defines the url which is used to load local resources.
This may need to be filtered for local Window installations.
If resources do not load, please check the wiki for details.
Parameters
Returns
string URL to CMB2 resources
Since
1.0.1
|
public static
string
|
#
get_url_from_dir( string $dir )
Converts a system path to a URL
Converts a system path to a URL
Parameters
- $dir
- Directory path to convert.
Returns
string Converted URL.
Since
2.2.2
|
protected static
string
|
#
get_normalized_abspath( )
Get the normalized absolute path defined by WordPress.
Get the normalized absolute path defined by WordPress.
Returns
string Normalized absolute path.
Since
2.2.6
|
protected static
string
|
#
normalize_path( string $path )
wp_normalize_path wrapper for back-compat. Normalize a filesystem path.
wp_normalize_path wrapper for back-compat. Normalize a filesystem path.
On windows systems, replaces backslashes with forward slashes
and forces upper-case drive letters.
Allows for two leading slashes for Windows network shares, but
ensures that all other duplicate slashes are reduced to a single.
Parameters
Returns
string Normalized path.
Since
2.2.0
|
public static
mixed
|
#
get_timestamp_from_value( string $value, string $date_format )
Get timestamp from text date
Get timestamp from text date
Parameters
- $value
- Date value.
- $date_format
- Expected date format.
Returns
mixed Unix timestamp representing the date.
Since
2.2.0
|
public static
string
|
#
php_to_js_dateformat( string $format )
Takes a php date() format string and returns a string formatted to suit for the date/time pickers
It will work only with the following subset of date() options:
Takes a php date() format string and returns a string formatted to suit for the date/time pickers
It will work only with the following subset of date() options:
Formats: d, l, j, z, m, F, n, y, and Y.
A slight effort is made to deal with escaped characters.
Other options are ignored, because they would either bring compatibility problems between PHP and JS, or
bring even more translation troubles.
Parameters
Returns
string reformatted string
Since
2.2.0
|
public static
string
|
#
wrap_escaped_chars( string $value )
Helper function for CMB_Utils::php_to_js_dateformat().
Helper function for CMB_Utils::php_to_js_dateformat().
Parameters
- $value
- Value to wrap/escape.
Returns
string Modified value
Since
2.2.0
|
public static
|
#
log_if_debug( string $function, integer $line, mixed $msg, mixed $debug = null )
Send to debug.log if WP_DEBUG is defined and true
Send to debug.log if WP_DEBUG is defined and true
Parameters
- $function
- Function name.
- $line
- Line number.
- $msg
- Message to output.
- $debug
- Variable to print_r.
Since
2.2.0
|
public static
string|false
|
#
get_file_ext( string $file )
Determine a file's extension
Determine a file's extension
Parameters
Returns
string|false File extension or false
Since
1.0.0
|
public static
string
|
#
get_file_name_from_path( string $value )
Get the file name from a url
Get the file name from a url
Parameters
Returns
string File name
Since
2.0.0
|
public static
boolean
|
#
wp_at_least( string $version )
Check if WP version is at least $version.
Check if WP version is at least $version.
Parameters
- $version
- WP version string to compare.
Returns
boolean Result of comparison check.
Since
2.2.2
|
public static
string
|
#
concat_attrs( array $attrs, array $attr_exclude = array() )
Combines attributes into a string for a form element.
Combines attributes into a string for a form element.
Parameters
- $attrs
- Attributes to concatenate.
- $attr_exclude
- Attributes that should NOT be concatenated.
Returns
string String of attributes for form element.
Since
1.1.0
|
public static
boolean
|
#
is_data_attribute( string $att )
Check if given attribute is a data attribute.
Check if given attribute is a data attribute.
Parameters
Returns
boolean
Since
2.2.5
|
public static
array
|
#
ensure_array( mixed $value, array $default = array() )
Ensures value is an array.
Ensures value is an array.
Parameters
- $value
- Value to ensure is array.
- $default
- Default array. Defaults to empty array.
Returns
array The array.
Since
2.2.3
|
public static
mixed
|
#
normalize_if_numeric( mixed $value )
If number is numeric, normalize it with floatval or intval, depending on if decimal is found.
If number is numeric, normalize it with floatval or intval, depending on if decimal is found.
Parameters
- $value
- Value to normalize (if numeric).
Returns
mixed Possibly normalized value.
Since
2.2.6
|
public static
string
|
#
generate_hash( string $string )
Generates a 12 character unique hash from a string.
Generates a 12 character unique hash from a string.
Parameters
- $string
- String to create a hash from.
Returns
string
Since
2.4.0
|