Helpers

WordPlate includes a variety of “helper” PHP functions. You are free to use them in your own applications if you find them convenient.

WordPlate support both Laravel’s collections and helper methods. This means you can use great debugging methods such as dd() and string helpers like str_contains().

Available Methods

Below is a list of all supported helper methods.

Arrays Strings Miscellaneous Paths
array_add camel_case asset base_path
array_collapse class_basename collect mix
array_divide e dd stylesheet_path
array_dot ends_with dump template_path
array_except snake_case env  
array_first starts_with info  
array_flatten str_after value  
array_forget str_contains    
array_get str_finish    
array_has str_is    
array_last str_limit    
array_only str_plural    
array_pluck str_random    
array_prepend str_singular    
array_pull str_slug    
array_set studly_case    
array_sort title_case    
array_sort_recursive      
array_where      
head      
last      

base_path()

The base_path() function returns the fully qualified path to the project root. You may also use the base_path() function to generate a fully qualified path to a given file relative to the project root directory.

$path = base_path();

$path = base_path('vendor/bin');

info()

The info() function retrieves information about the current site. Shorthand for WordPress get_bloginfo() helper.

$url = info('url');

stylesheet_path()

The stylesheet_path() function returns the fully qualified path for the current/child theme directory.

$path = stylesheet_path();

$path = stylesheet_path('components/article.php');

template_path()

The template_path() function returns the fully qualified path to the current theme directory or to the parent theme if a child theme is being used.

$path = template_path();

$path = template_path('components/article.php');