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().

Arrays & Objects

Strings

Miscellaneous

Paths

WordPlate

Below you’ll find WordPlate specific helper functions.

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');

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');

// /var/www/public/wp-content/themes/twentyseventeen-child/components/article.php

stylesheet_url()

The stylesheet_url() function returns the stylesheet directory URI for the current theme/child theme.

$path = stylesheet_url();

$path = stylesheet_url('img/photo.jpg');

// http://example.com/wp-content/themes/twentyseventeen-child/img/photo.jpg

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');

// /var/www/public/wp-content/themes/twentyseventeen/components/article.php

template_url()

The template_url() function returns the the current theme directory URI or to the parent theme if a child theme is being used.

$path = template_url();

$path = template_url('img/photo.jpg');

// http://example.com/wp-content/themes/twentyseventeen/img/photo.jpg