Additional Functions
Functions the template adds, in include/functions.php and include/acf.php.
Assets
loadScript
loadScript(string $name, string $path, array $dependencies = [], ?string $version = null, array|bool $args = []): void
A wrapper of wp_enqueue_script(). A relative $path is resolved from the theme directory. When $version is empty, the version from config.php is used.
$args is the $args of wp_enqueue_script() (e.g. ['strategy' => 'defer']); true / false is treated as the in-footer flag. Call it before get_header(). See Loading assets.
loadStyle
loadStyle(string $name, string $path, array $dependencies = [], ?string $version = null): void
A wrapper of wp_enqueue_style(). $path and $version work the same way as in loadScript().
get_asset_url
get_asset_url(string $path, ?string $version = null): string
Returns the escaped URL of a file in the theme with ?v={version} added. When $version is empty, the version from config.php is used.
the_asset_url
the_asset_url(string $path, ?string $version = null): void
Prints the result of get_asset_url().
get_file_version
get_file_version(): string
Returns the version number added to the asset URLs. Defined in config.php; raise it when you release changes to the assets.
Custom fields
These work the same way when the custom field plugin is inactive: they return nothing instead of failing.
_get_field / _the_field
_get_field(string $selector, mixed $post_id = false, bool $format_value = true): mixed
_the_field(string $selector, mixed $post_id = false, bool $format_value = true): void
Safe versions of get_field() and the_field().
the_simple_field
the_simple_field(string $key, mixed $post = null, string $default = ''): void
Prints a field's value escaped, with line breaks converted to <br>. Prints $default when the value is empty.
YouTube
get_youtube_url(string $key, mixed $post = null): ?string
get_youtube_id(string $key, mixed $post = null): ?string
get_youtube_loop(string $key, mixed $post = null): ?string
Read an oEmbed field holding a YouTube video and return its embed URL, its video ID, or its embed URL with the loop parameters added. the_youtube_url() and the_youtube_loop() print the result.
Others
get_page_slug
get_page_slug(int|WP_Post|null $page_id = null): string
Returns the page's slug joined with its parents' slugs by -. For /company/access/ it returns company-access, and on the front page index. Use it to name the Project class of the page.
is_new
is_new(int|WP_Post|null $post = null, int $gap = 2): bool
Returns whether the post was published within $gap days. Without $post, the current post in the loop is checked.
is_mobile
is_mobile(): bool
Returns whether the user agent is a smartphone (iPad is not included). Use media queries for layout; use this only when the output itself must differ.
remove_line_break
remove_line_break(string $text): string
Removes the line breaks, and the spaces at the start and end of each line.
get_setting_files
get_setting_files(string $dir): string[]
Returns the PHP files in settings/{$dir}/, skipping those whose names start with _. Used to load a directory of definitions in include/.
Shortcode
include_template
[include_template slug="templates/contact-banner"]
Shows a template part inside the content, using get_template_part(). See Components.