PHP Class Timber\Helper

Mostra file Open project: jarednova/timber Class Usage Examples

Public Methods

Method Description
_is_transient_locked ( string $slug )
_lock_transient ( string $slug, integer $lock_timeout )
_unlock_transient ( string $slug )
array_to_object ( array $array ) : stdClass
array_truncate ( array $array, integer $len ) : array
close_tags ( string $html ) : string
error_log ( $error ) : void
function_wrapper ( mixed $function_name, $defaults = [], $return_output_buffer = false ) : FunctionWrapper | mixed
get_comment_form ( integer $post_id = null, array $args = [] ) : string Gets the comment form for use on a single article page
get_current_url ( ) : string
get_object_by_property ( array $array, string $key, mixed $value ) : array | null
get_object_index_by_property ( array $array, string $key, mixed $value ) : boolean | integer
get_wp_title ( string $separator = ' ', string $seplocation = 'left' ) : string
is_array_assoc ( array $arr ) : boolean
is_true ( mixed $value ) : boolean
iseven ( integer $i ) : boolean
isodd ( integer $i ) : boolean
ob_function ( callback $function, array $args = [null] ) : string Calls a function with an output buffer. This is useful if you have a function that outputs text that you want to capture and use within a twig template.
osort ( array &$array, string $prop ) : void
paginate_links ( array $args = [] ) : array
pluck ( array $array, string $key ) Plucks the values of a certain key from an array of objects
start_timer ( ) : float For measuring time, this will start a timer
stop_timer ( integer $start ) : string For stopping time and getting the data
transient ( string $slug, callable $callback, integer $transient_time, integer $lock_timeout = 5, boolean $force = false ) : mixed A utility for a one-stop shop for Transients
trim_words ( string $text, integer $num_words = 55, string | null | false $more = null, string $allowed_tags = 'p a span b i br blockquote' ) : string
warn ( string $message ) : boolean

Protected Methods

Method Description
handle_transient_locking ( string $slug, callable $callback, integer $transient_time, integer $lock_timeout, boolean $force, boolean $enable_transients ) Does the dirty work of locking the transient, running the callback and unlocking

Method Details

_is_transient_locked() public static method

public static _is_transient_locked ( string $slug )
$slug string

_lock_transient() public static method

public static _lock_transient ( string $slug, integer $lock_timeout )
$slug string
$lock_timeout integer

_unlock_transient() public static method

public static _unlock_transient ( string $slug )
$slug string

array_to_object() public static method

public static array_to_object ( array $array ) : stdClass
$array array
return stdClass

array_truncate() public static method

public static array_truncate ( array $array, integer $len ) : array
$array array
$len integer
return array

close_tags() public static method

See also: TextHelper::close_tags
Deprecation: since 1.2.0
public static close_tags ( string $html ) : string
$html string
return string

error_log() public static method

public static error_log ( $error ) : void
return void

function_wrapper() public static method

public static function_wrapper ( mixed $function_name, $defaults = [], $return_output_buffer = false ) : FunctionWrapper | mixed
$function_name mixed or array( $class( string|object ), $function_name )
return FunctionWrapper | mixed

get_comment_form() public static method

Gets the comment form for use on a single article page
Deprecation: 0.21.8 use `{{ function('comment_form') }}` instead
public static get_comment_form ( integer $post_id = null, array $args = [] ) : string
$post_id integer which post_id should the form be tied to?
$args array this $args thing is a fucking mess, [fix at some point](http://codex.wordpress.org/Function_Reference/comment_form)
return string

get_current_url() public method

public get_current_url ( ) : string
return string

get_object_by_property() public static method

public static get_object_by_property ( array $array, string $key, mixed $value ) : array | null
$array array
$key string
$value mixed
return array | null

get_object_index_by_property() public static method

public static get_object_index_by_property ( array $array, string $key, mixed $value ) : boolean | integer
$array array
$key string
$value mixed
return boolean | integer

get_wp_title() public static method

public static get_wp_title ( string $separator = ' ', string $seplocation = 'left' ) : string
$separator string
$seplocation string
return string

handle_transient_locking() protected static method

Does the dirty work of locking the transient, running the callback and unlocking
protected static handle_transient_locking ( string $slug, callable $callback, integer $transient_time, integer $lock_timeout, boolean $force, boolean $enable_transients )
$slug string
$callback callable
$transient_time integer Expiration of transients in seconds
$lock_timeout integer How long (in seconds) to lock the transient to prevent race conditions
$force boolean Force callback to be executed when transient is locked
$enable_transients boolean Force callback to be executed when transient is locked

is_array_assoc() public static method

public static is_array_assoc ( array $arr ) : boolean
$arr array
return boolean

is_true() public static method

public static is_true ( mixed $value ) : boolean
$value mixed
return boolean

iseven() public static method

public static iseven ( integer $i ) : boolean
$i integer
return boolean

isodd() public static method

public static isodd ( integer $i ) : boolean
$i integer
return boolean

ob_function() public static method

Calls a function with an output buffer. This is useful if you have a function that outputs text that you want to capture and use within a twig template.
public static ob_function ( callback $function, array $args = [null] ) : string
$function callback
$args array
return string

osort() public static method

public static osort ( array &$array, string $prop ) : void
$array array
$prop string
return void

pluck() public static method

Plucks the values of a certain key from an array of objects
public static pluck ( array $array, string $key )
$array array
$key string

start_timer() public static method

For measuring time, this will start a timer
public static start_timer ( ) : float
return float

stop_timer() public static method

For stopping time and getting the data
public static stop_timer ( integer $start ) : string
$start integer
return string

transient() public static method

A utility for a one-stop shop for Transients
public static transient ( string $slug, callable $callback, integer $transient_time, integer $lock_timeout = 5, boolean $force = false ) : mixed
$slug string Unique identifier for transient
$callback callable Callback that generates the data that's to be cached
$transient_time integer (optional) Expiration of transients in seconds
$lock_timeout integer (optional) How long (in seconds) to lock the transient to prevent race conditions
$force boolean (optional) Force callback to be executed when transient is locked
return mixed

trim_words() public static method

See also: TextHelper::trim_words
Deprecation: since 1.2.0
public static trim_words ( string $text, integer $num_words = 55, string | null | false $more = null, string $allowed_tags = 'p a span b i br blockquote' ) : string
$text string
$num_words integer
$more string | null | false text to appear in "Read more...". Null to use default, false to hide
$allowed_tags string
return string

warn() public static method

public static warn ( string $message ) : boolean
$message string that you want to output
return boolean