Wordless
Stop writing themes like it's 1998.
Functions
Helpers Functions

All the helpers functions in Wordless. More...

Functions

 AcfGutenbergBlockHelper::create_acf_block (string $block_name, array $params)
 Creates and registers ACF Gutenberg block. More...
 
 AssetTagHelper::get_asset_version_string ()
 Return the theme version, based on prederence set in Wordless config file. More...
 
 AssetTagHelper::asset_version ($source)
 Appends version information to asset source. More...
 
 AssetTagHelper::audio_tag ($source, $attributes=array())
 Builds a valid <audio /> HTML tag. More...
 
 AssetTagHelper::auto_discovery_link_tag ($model_or_url="posts", $type="rss", $additional_options=NULL)
 Builds a valid <link /> HTML tag to a feed (rss or atom). More...
 
 AssetTagHelper::favicon_link_tag ($source="favicon.ico", $attributes=NULL)
 Builds a valid <link /> HTML tag to a favicon. More...
 
 AssetTagHelper::get_feed_url ($model, $type="rss")
 Returns a WP valid feed, depending on the type or feed requested and of the content for which the feed is created. More...
 
 AssetTagHelper::image_tag ($source, $attributes=NULL)
 Builds a valid <img /> HTML tag. More...
 
 AssetTagHelper::video_tag ($sources, $attributes=NULL)
 Builds a valid <video /> HTML tag. More...
 
 AssetTagHelper::stylesheet_link_tag ()
 Returns a stylesheet link tag for the sources specified as arguments. More...
 
 AssetTagHelper::javascript_include_tag ()
 Returns an HTML script tag for each of the sources provided as arguments. More...
 
 ConditionalHelper::is_subpage ($id=NULL)
 Check if the page is a subpage and return the parent post ID if true. More...
 
 ConditionalHelper::is_page_wpml ( $page_title=array())
 Check if is a page when WPML is in use; takes in consideration all the translations. More...
 
 DateHelper::distance_of_time_in_words ($from_time, $to_time, $include_seconds=false)
 Returns a user-friendly string representation of a time distance. More...
 
 DateHelper::get_the_time_ago ($granularity=1)
 Returns a 'time ago' string based on the creation time of the current post. More...
 
 DateHelper::time_tag ($date_or_time=NULL, $text=NULL, $attributes=array())
 Builds a valid <time /> HTML tag. More...
 
 DateHelper::time_ago_in_words ($from_time, $include_seconds=false)
 Like distance_of_time_in_words() but with fixed value of $to_time. More...
 
 FakerHelper::placeholder_image ($width, $height, $options=array())
 Generate a placeholder image. More...
 
 FakerHelper::placeholder_text ($count, $options=array())
 Generate placeholder text. More...
 
 DebugHelper::dump ($var)
 Prints the specified variable already formatted in <pre></pre> tags. More...
 
 MediaHelper::detect_user_agent ()
 Includes a PHP class to detect mobile devices and user agent details. More...
 
 MediaHelper::get_post_attachments ($post_id)
 Get the attached files in specified post. More...
 
 MediaHelper::get_current_post_attachments ()
 Get the attached files in current post. More...
 
 MediaHelper::resize_image ($src, $width, $height)
 Resizes the specified image to the specified dimensions. More...
 
 ModelHelper::new_post_type ($name, $supports=array("title", "editor"), $options=array())
 Creates a new post type. More...
 
 ModelHelper::new_taxonomy ($name, $post_types, $options=array())
 Create a new taxonomy. More...
 
 NumberHelper::number_to_currency ($number, $options=array())
 Translates number to currency. More...
 
 QueryHelper::latest_posts_of_type ($type, $limit=-1, $order='date', $ord='DESC')
 Get last posts of specified type. More...
 
 QueryHelper::latest_post_of_type ($type, $order='date')
 Get the last post of the specified type. More...
 
 QueryHelper::latest_posts_of_category ($category, $limit, $offset=0, $post_type='post', $taxonomy='category', $order='date', $ord='DESC')
 Get last posts of specified category. More...
 
 QueryHelper::latest_post_of_category ($category, $post_type='post', $taxonomy='category')
 Get the last post of the specified category. More...
 
 QueryHelper::is_post_type ($type)
 Check if post type is the one specified. More...
 
 QueryHelper::get_the_first_categories_except ($limit, $except)
 Get the first categories, except one. More...
 
 QueryHelper::get_page_id_by_title ($title)
 Returns the page ID from page title. More...
 
 QueryHelper::get_category_id_by_name ($cat_name, $taxonomy='category')
 Returns the category ID from the category name. More...
 
 QueryHelper::get_category_link_by_name ($cat_name, $taxonomy='category')
 Returns a link to the specified category. More...
 
 QueryHelper::get_the_filtered_content ()
 Returns the content of the current post. More...
 
 QueryHelper::get_post_type_singular_name ()
 Returns the post type (always singular). More...
 
 QueryHelper::get_page_title ($prefix="", $separator="")
 Returns the page title. More...
 
 TextHelper::pluralize ($string)
 Attempts to pluralize the specified text. More...
 
 TextHelper::reset_cycle ($name="default")
 Reset the cycle pointer. More...
 
 TextHelper::truncate ($text, $options=array())
 Truncate the text to the specified length. More...
 
 TextHelper::capitalize ($text)
 Returns a string with the first character of each word capitalized. More...
 
 TextHelper::titleize ($text)
 Capitalizes the first letter of every word. More...
 
 TextHelper::is_valid_url ($url)
 Check if the string passed as parameter is a valid URL. More...
 
 ThemeHelper::get_theme_name ()
 Returns the folder theme name based on the theme path. More...
 
 ThemeHelper::get_theme_path ()
 Returns the absolute path to the current theme. More...
 
 ThemeHelper::get_theme_version ()
 Returns the version of the the current theme. More...
 
 UrlHelper::arg ($index=NULL)
 Returns URL arguments. More...
 
 UrlHelper::asset_url ($path)
 Returns the URL path to the spcified folder in the assets directory. More...
 
 UrlHelper::image_url ($path)
 Returns the URL path to the specified folder in the images directory. More...
 
 UrlHelper::stylesheet_url ($path)
 Returns the URL path to the specified folder in the stylesheet directory. More...
 
 UrlHelper::javascript_url ($path)
 Returns the URL path to the specified folder in the javascript directory. More...
 
 UrlHelper::is_absolute_url ($url)
 Check if an URL is absolute or not URL are considered absolute if they begin with a protocol specification (https|https in this case) or with the double slash (//) to take advantage of the protocol relative URL (http://paulirish.com/2010/the-protocol-relative-url/) More...
 
 UrlHelper::is_root_relative_url ($url)
 Check if an URL is root relative URL are considered root relative if they are not absolute but begin with a /. More...
 
 UrlHelper::is_relative_url ($url)
 Check if an URL is relative URL are considered relative if they are not absolute and don't begin with a /. More...
 

Detailed Description

All the helpers functions in Wordless.

Function Documentation

◆ arg()

UrlHelper::arg (   $index = NULL)

Returns URL arguments.

Parameters
int$index(optional) The number (counting from zero) of the argument in the list. If is not specified all arguments will be returned as an array.
Returns
array|mixed If $index was specified returns the relative URL argument, elsewhere returns an array with all available URL arguments.

◆ asset_url()

UrlHelper::asset_url (   $path)

Returns the URL path to the spcified folder in the assets directory.

Parameters
string$pathThe path inside the {theme}/assets/ folder.
Returns
string The complete URL path to the specified folder.

◆ asset_version()

AssetTagHelper::asset_version (   $source)

Appends version information to asset source.

Parameters
string$sourceThe path to the asset source.
Returns
string The path to the asset source with version information appended to the query string.

◆ audio_tag()

AssetTagHelper::audio_tag (   $source,
  $attributes = array() 
)

Builds a valid <audio /> HTML tag.

Parameters
string$sourceThe path to the audio source.
array$attributes(optional) An array of HTML attributes to be added to the rendered tag.
Returns
string A valid <audio /> HTML tag.

◆ auto_discovery_link_tag()

AssetTagHelper::auto_discovery_link_tag (   $model_or_url = "posts",
  $type = "rss",
  $additional_options = NULL 
)

Builds a valid <link /> HTML tag to a feed (rss or atom).

Returns a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed. The type can either be rss (default) or atom. You can modify the LINK tag itself in $tag_options.

Parameters
string$model_or_url(optional) The source of the feed. Can be a custom URL, posts or comments. In the latter case, the source will be returned by AssetTagHelper::get_feed_url() Defaults to posts.
string$type(optional) The type of the feed. Could be rss or atom. Defaults to rss.
array$tag_options(optional) An array of HTML attributes to be added to the rendered tag.
Returns
string A valid <link /> HTML tag to a feed (rss or atom).
See also
AssetTagHelper::get_feed_url()
TagHelper::content_tag()

◆ capitalize()

TextHelper::capitalize (   $text)

Returns a string with the first character of each word capitalized.

Parameters
string$textThe text to be capitalized.
Returns
string The capitalized text.

◆ create_acf_block()

AcfGutenbergBlockHelper::create_acf_block ( string  $block_name,
array  $params 
)

Creates and registers ACF Gutenberg block.

Parameters
string$block_nameThe name of the block.
array$paramsThe array of block specific params that will override the defaults.

◆ detect_user_agent()

MediaHelper::detect_user_agent ( )

Includes a PHP class to detect mobile devices and user agent details.

$detect = detect_user_agent()
$detect->isMobile()
Returns
object
See also
https://github.com/serbanghita/Mobile-Detect
Note
Using Mobile Detect - Version 2.5.2 - commit b5b8992dbe

◆ distance_of_time_in_words()

DateHelper::distance_of_time_in_words (   $from_time,
  $to_time,
  $include_seconds = false 
)

Returns a user-friendly string representation of a time distance.

Given 2 timestamps, return a readable representation for their distance, link "1 minute" or "about an hour", etc.

Author
: James Rose
Parameters
int$from_timeThe timestamp for the initial time.
int$to_time(optional) The timestamp for the end time.
boolean$include_seconds(optional) TRUE if you want to take in account also seconds in the time distance ( must be set if you want information about a time distance shorter than a minute ).
Returns
string A string representing the time distance.

◆ dump()

DebugHelper::dump (   $var)

Prints the specified variable already formatted in <pre></pre> tags.

Parameters
string$varThe variable to be printed

◆ favicon_link_tag()

AssetTagHelper::favicon_link_tag (   $source = "favicon.ico",
  $attributes = NULL 
)

Builds a valid <link /> HTML tag to a favicon.

Parameters
string$source(optional) The path to the favicon file. Must be a valid path to an .ico file.
array$attributes(optional) An array of HTML attributes to be added to the rendered tag.
Returns
string A valid <link /> HTML tag to a favicon.
See also
TagHelper::content_tag()

◆ get_asset_version_string()

AssetTagHelper::get_asset_version_string ( )
protected

Return the theme version, based on prederence set in Wordless config file.

Returns
string The assets version string

◆ get_category_id_by_name()

QueryHelper::get_category_id_by_name (   $cat_name,
  $taxonomy = 'category' 
)

Returns the category ID from the category name.

Parameters
string$cat_nameThe name of the category
string$taxonomy(optional) The taxonomy at which the category belongs to.
Returns
int The ID of the category

◆ get_category_link_by_name()

QueryHelper::get_category_link_by_name (   $cat_name,
  $taxonomy = 'category' 
)

Returns a link to the specified category.

Parameters
string$cat_nameThe name of the category.
string$taxonomy(optional) The taxonomy at which the category belongs to
Returns
int A link to the category.

◆ get_current_post_attachments()

MediaHelper::get_current_post_attachments ( )

Get the attached files in current post.

Returns
array List of post attachment objects.

◆ get_feed_url()

AssetTagHelper::get_feed_url (   $model,
  $type = "rss" 
)

Returns a WP valid feed, depending on the type or feed requested and of the content for which the feed is created.

Post's feeds are different from comment's feeds, this function return the correct feed (rss/atom) for the specified content.

Parameters
string$modelReturn the correct feed type, depending on content type. Can be posts or comments.
string$typeThe type of the feed. Can be rdf, rss1, rss092, rss, rss2.
See also
https://codex.wordpress.org/Function_Reference/bloginfo

◆ get_page_id_by_title()

QueryHelper::get_page_id_by_title (   $title)

Returns the page ID from page title.

Parameters
string$title
Returns
int The ID of the page

◆ get_page_title()

QueryHelper::get_page_title (   $prefix = "",
  $separator = "" 
)

Returns the page title.

Parameters
string$prefix(optional) A string to be prefixed to the current page title.
string$separator(optional) A string to separate prefix and current page title.
Returns
string The page title

◆ get_post_attachments()

MediaHelper::get_post_attachments (   $post_id)

Get the attached files in specified post.

Parameters
int$post_idThe ID of the post of which we need to retrieve attachments.
Returns
array List of post attachment objects.

◆ get_post_type_singular_name()

QueryHelper::get_post_type_singular_name ( )

Returns the post type (always singular).

Returns
string The post name.

◆ get_the_filtered_content()

QueryHelper::get_the_filtered_content ( )

Returns the content of the current post.

Must be called within The Loop.

Returns
string The content of the current post.

◆ get_the_first_categories_except()

QueryHelper::get_the_first_categories_except (   $limit,
  $except 
)

Get the first categories, except one.

Parameters
int$limitThe max number of categories to be retrieved.
string$exceptThe name of the category to exclude.
Returns
string A comma separated list of categories or an empty link if no category can be found.

◆ get_the_time_ago()

DateHelper::get_the_time_ago (   $granularity = 1)

Returns a 'time ago' string based on the creation time of the current post.

For more details on how this function works please check the get_the_date() WordPress documentation.

Parameters
int$granularity(optional)
Returns
string A string representation of the time elapsed since the creation of the current post.
See also
https://codex.wordpress.org/Function_Reference/get_the_date
Code Doubt:
I didn't get the use of $granularity!

◆ get_theme_name()

ThemeHelper::get_theme_name ( )

Returns the folder theme name based on the theme path.

The function use the whole theme path to get only the folder name of the current theme.

Returns
string The folder name for the current theme.

◆ get_theme_path()

ThemeHelper::get_theme_path ( )

Returns the absolute path to the current theme.

Path without trailing slash.

Returns
string The absolute path to the current theme.

◆ get_theme_version()

ThemeHelper::get_theme_version ( )

Returns the version of the the current theme.

Returns
string The version of the current theme.

◆ image_tag()

AssetTagHelper::image_tag (   $source,
  $attributes = NULL 
)

Builds a valid <img /> HTML tag.

Parameters
string$sourceThe source path to the image.
string | array$attributes(optional) A single HTML attribute or an array of HTML attributes to be added to the rendered tag.
Returns
string A valid <img /> HTML tag.
See also
TagHelper::content_tag()

◆ image_url()

UrlHelper::image_url (   $path)

Returns the URL path to the specified folder in the images directory.

Parameters
string$pathThe path inside the {theme}/assets/images/ folder.
Returns
string The complete URL path to the specified folder.

◆ is_absolute_url()

UrlHelper::is_absolute_url (   $url)

Check if an URL is absolute or not URL are considered absolute if they begin with a protocol specification (https|https in this case) or with the double slash (//) to take advantage of the protocol relative URL (http://paulirish.com/2010/the-protocol-relative-url/)

Parameters
string$urlThe url to check.
Returns
boolean Either true if the URL is absolute or false if it is not.

◆ is_page_wpml()

ConditionalHelper::is_page_wpml (   $page_title = array())

Check if is a page when WPML is in use; takes in consideration all the translations.

Parameters
string | array$page_titleThe page title as string, or multiple page titles as an array.
Returns
boolean TRUE if is a page or a tranlated page or FALSE
Warning
Page title is not page slug nor page ID :)

◆ is_post_type()

QueryHelper::is_post_type (   $type)

Check if post type is the one specified.

Parameters
string$typeType of the post to be compared.
Returns
boolean TRUE if the post type of the global $post var is equal to the one passed as argument, FALSE otherwise.

◆ is_relative_url()

UrlHelper::is_relative_url (   $url)

Check if an URL is relative URL are considered relative if they are not absolute and don't begin with a /.

Parameters
string$urlThe url to check.
Returns
boolean Either true if the URL is relative or false if it is not.

◆ is_root_relative_url()

UrlHelper::is_root_relative_url (   $url)

Check if an URL is root relative URL are considered root relative if they are not absolute but begin with a /.

Parameters
string$urlThe url to check.
Returns
boolean Either true if the URL is root relative or false if it is not.

◆ is_subpage()

ConditionalHelper::is_subpage (   $id = NULL)

Check if the page is a subpage and return the parent post ID if true.

Parameters
int$id(optional) If you pass an ID to the function, will check if the current page is subpage of the specified parent page.
Returns
int|bool Return the parent post if present or FALSE

◆ is_valid_url()

TextHelper::is_valid_url (   $url)

Check if the string passed as parameter is a valid URL.

NO SANITAZE IS PERFORMED on the URL! URL like this: http://example.com/"><script>alert(document.cookie)</script> DO PASS validation (syntactically are valid URLs).

Parameters
string$urlA URL to be validated.
Returns
bool Return TRUE if the URL is valid, FALSE otherwise.

◆ javascript_include_tag()

AssetTagHelper::javascript_include_tag ( )

Returns an HTML script tag for each of the sources provided as arguments.

Sources may be paths to JavaScript files. Relative paths are assumed to be relative to assets/javascripts. When passing paths, the ".js" extension is optional. If the last argument is an array, it will be used as tag attributes.

Returns
string A valid <script /> HTML tag.
See also
TagHelper::content_tag()

◆ javascript_url()

UrlHelper::javascript_url (   $path)

Returns the URL path to the specified folder in the javascript directory.

Parameters
string$pathThe path inside the {theme}/assets/javascript/ folder.
Returns
string The complete URL path to the specified folder.

◆ latest_post_of_category()

QueryHelper::latest_post_of_category (   $category,
  $post_type = 'post',
  $taxonomy = 'category' 
)

Get the last post of the specified category.

Parameters
string$categorySee QueryHelper::latest_posts_of_category().
string$post_typeSee QueryHelper::latest_posts_of_category().
string$taxonomy(optional) See QueryHelper::latest_posts_of_category().
Returns
?? Last post of the selected category ordered.

◆ latest_post_of_type()

QueryHelper::latest_post_of_type (   $type,
  $order = 'date' 
)

Get the last post of the specified type.

Parameters
string$typeSee QueryHelper::latest_posts_of_type().
string$order(optional) See QueryHelper::latest_posts_of_type().
Returns
?? Last post of the selected type ordered.

◆ latest_posts_of_category()

QueryHelper::latest_posts_of_category (   $category,
  $limit,
  $offset = 0,
  $post_type = 'post',
  $taxonomy = 'category',
  $order = 'date',
  $ord = 'DESC' 
)

Get last posts of specified category.

Parameters
string$categoryName of the category used to filter posts.
int$limitMaximum number of post to be retrieved.
int$offset(optional) Number of post to skip while retrieveing results.
string$post_type(optional) Filter results by post type.
string$taxonomy(optional) Taxonomy to query to retrieve posts.
string$order(optional) The order in which sort the post retrieved. See WP docs for list of available values.
string$ord(optional) Can be ASC for ascending or DESC for descending.
Returns
array Last posts of the selected category ordered.
See also
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

◆ latest_posts_of_type()

QueryHelper::latest_posts_of_type (   $type,
  $limit = -1,
  $order = 'date',
  $ord = 'DESC' 
)

Get last posts of specified type.

Parameters
string$typePost type used to filter result posts.
int$limit(optional) Maximum number of post to be retrieved.
string$order(optional) The order in which sort the post retrieved. See WP docs for list of available values.
string$ord(optional) Can be ASC for ascending or DESC for descending.
Returns
array Last posts of the selected type ordered.
See also
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

◆ new_post_type()

ModelHelper::new_post_type (   $name,
  $supports = array("title", "editor"),
  $options = array() 
)

Creates a new post type.

This function use the WP APIs and functions to register a new post type.

Parameters
string | array$nameThe name of the new post type (will appear in the backend). If the name is a sting, the plural will be evaluated by the system; if is an array, must contains the singular and the plural versions of the name. Ex:
$name = array(
"singular" => 'My custom post type',
"plural" => 'My custom post types'
);
array$supports(optional) Extra fields added to this post type. Default fields (the fields you can find in page/post type) are added by default.
array$options(optional) An optional array to override default options passed to register_post_type().

◆ new_taxonomy()

ModelHelper::new_taxonomy (   $name,
  $post_types,
  $options = array() 
)

Create a new taxonomy.

Parameters
string$nameThe name of the taxonomy.
array | string$post_typesName of the object type for the taxonomy object. Object-types can be built-in objects (see below) or any custom post type that may be registered.
array$options(optional) An optional array to override default options passed to register_taxonomy().

◆ number_to_currency()

NumberHelper::number_to_currency (   $number,
  $options = array() 
)

Translates number to currency.

Parameters
integer$numberThe number to translate
array$options(optional) Associative array. Accepts keys: 'format' (defaults to un), 'unit'.

◆ placeholder_image()

FakerHelper::placeholder_image (   $width,
  $height,
  $options = array() 
)

Generate a placeholder image.

Using the specified sevice provide a placeholder image.

Placeholder Services available are described here placeholders.

To implement your service please check the Placeholder Services.

Parameters
int$widthThe width of the placeholder image.
int$heightThe height of the placeholder image.
array$options(optional) An option array to be passed to the PHP Class handling the placeholder service. See the placeholder service docs for details.
Returns
string The URL of the placeholder image generated with the specified service.

◆ placeholder_text()

FakerHelper::placeholder_text (   $count,
  $options = array() 
)

Generate placeholder text.

Using the famous Lorem Ipsum base text, generate a dummy text based on specified options.

Parameters
int$countThe length in words of the dummy text.
array$options(optional) An array of options to manage text generation. Options available are:
  • html: wheter to build HTML content or plain content. Default to false.
  • lorem: if the text must start with "Lorem ipsum..." or not. Default to true.
Returns
string The generated dummy text.

◆ pluralize()

TextHelper::pluralize (   $string)

Attempts to pluralize the specified text.

Parameters
string$stringThe string to be pluralized.
Returns
mixed The current data in the iteration.

◆ reset_cycle()

TextHelper::reset_cycle (   $name = "default")

Reset the cycle pointer.

Parameters
string$name(optional) The specified name of the cycle to reset.

◆ resize_image()

MediaHelper::resize_image (   $src,
  $width,
  $height 
)

Resizes the specified image to the specified dimensions.

The crop will be centered relative to the image.

Parameters
string$srcThe path to the image to be resized
int$widthThe width at which the image will be cropped
int$heightThe height at which the image will be cropped
Returns
string The valid URL to the image

Cropped images are stored in template tmp folder.

◆ stylesheet_link_tag()

AssetTagHelper::stylesheet_link_tag ( )

Returns a stylesheet link tag for the sources specified as arguments.

If you don’t specify an extension, ".css" will be appended automatically. Relative paths are assumed to be relative to assets/javascripts. If the last argument is an array, it will be used as tag attributes.

Returns
string A valid <link /> HTML tag.
See also
TagHelper::content_tag()

◆ stylesheet_url()

UrlHelper::stylesheet_url (   $path)

Returns the URL path to the specified folder in the stylesheet directory.

Parameters
string$pathThe path inside the {theme}/assets/stylesheet/ folder.
Returns
string The complete URL path to the specified folder.

◆ time_ago_in_words()

DateHelper::time_ago_in_words (   $from_time,
  $include_seconds = false 
)

Like distance_of_time_in_words() but with fixed value of $to_time.

This functions is a shorthand for distance_of_time_in_words($from_time, time(), $include_seconds).

See also
distance_of_time_in_words()

◆ time_tag()

DateHelper::time_tag (   $date_or_time = NULL,
  $text = NULL,
  $attributes = array() 
)

Builds a valid <time /> HTML tag.

Parameters
string$date_or_time(optional) A valid timestamp representing a valid date or time objects. If no timestamp is passed, use the current date with the DATE_W3C PHP predefined DateTime constant as date description.
string$text(optional) The text of the time HTML tag.
array$attributes(optional) An array of HTML attributes to be added to the rendered tag.
Returns
string A valid HTML <time /> tag.
See also
TagHelper::content_tag()

◆ titleize()

TextHelper::titleize (   $text)

Capitalizes the first letter of every word.

Parameters
string$textThe text to be capitalized.
Returns
string The text with every word capitalized.

◆ truncate()

TextHelper::truncate (   $text,
  $options = array() 
)

Truncate the text to the specified length.

Parameters
string$textThe text to be truncated.
array$options(optional) An array with options to be passed to the function. Available options:
  • length (default 30): the length at which truncate the text
  • omission (default '...'): the suffix string to be added to the truncate text
  • word_count (default FALSE): if is TRUE the lenght value count words else if is FALSE count chars
  • separator (default FALSE): the separator string used to trim the argument
  • html (default FALSE): set if you want to preserve html in string. If is set to false remove ALL HTML tags.
  • allowed_tags (default array('b', 'i', 'em', 'strong')): if html is TRUE preserve the allowed tags. If this param is set to 'all' leave untouched the string.
Returns
string The truncated text.

◆ video_tag()

AssetTagHelper::video_tag (   $sources,
  $attributes = NULL 
)

Builds a valid <video /> HTML tag.

Parameters
string | array$sourcesIf sources is a string, a single video tag will be returned. If sources is an array, a video tag with nested source tags for each source will be returned.
array$attributes(optional) An array of HTML attributes to be added to the rendered tag.
Returns
string A valid <video /> HTML tag.
See also
TagHelper::content_tag()
Todo:
Is possible to use only one return, editing slightly the logic
MediaHelper\detect_user_agent
detect_user_agent()
Includes a PHP class to detect mobile devices and user agent details.
Definition: media_helper.php:27