Functions
get_primary_term¶
Returns the "primary" term, which means the first that is in the list. Respects term order.
« More »
dump¶
Takes all parameters and dumps them in a nice readable format. Unlike with xdebug var_dump or print_r,
flexbox shouldn't ruin the day.
« More »
register_strings¶
Registers Polylang strings. Must be called in admin.
« More »
env¶
Returns current env, defaulting to production if none set.
« More »
is_prod¶
Return wether env is production or not.
« More »
is_dev¶
Return wether env is development or not.
« More »
tag¶
Concats strings and arrays into one string. Useful for tags.
« More »
current_url¶
Return the current, full URL.
Because PHP is incompetent and unable to do so with a single server var.
« More »
slugify¶
Return string in slugish format. Useful for creating HTML ids and such.
« More »
enqueue¶
Replacement for wp_enqueue_script & wp_enqueue_style. Handles cachebusting hashes.
define('WPT_ENQUEUE_STRIP_PATH', '/data/wordpress/htdocs');
\rnb\core\enqueue(get_stylesheet_directory() . '/build/client.*.js');
« More »
init¶
Run wordpress-tools core operations.
« More »
image¶
Returns an image element.
Usage: <?=\rnb\media\image($image, 'your-size')?>
« More »
captioned_image¶
Returns an image element with captions.
« More »
get_image_data¶
Return all relevant data for an image as an array.
« More »
themeresource¶
Returns URl for local resource, relative to theme root.
Usage: <?=\rnb\media\themeresource($image, 'your-size')?>
« More »
inline_svg¶
Return an inline svg element, contained in a wrapper div.
« More »
output¶
Outputs a template. Templates are just functions that you can give parameters.
See sample_template() and sample_template_named_params().
« More »
to_string¶
Returns template output as string, and discards any return value.
« More »
load_glob¶
Load templates from dir using glob.
Usage: load_glob(dirname(__FILE__) . '/templates/*')
« More »
sample_template¶
Sample template for those unsure. This is the template init function, you
could use classes if you wanted. Usage:
<?=\rnb\template\get('\rnb\template\sample_template', ['Hello', 'world!']);
« More »
sample_template_named_params¶
Sample template using "named parameters". Usage:
<?=\rnb\template\get('\rnb\template\sample_template_named_params', [['title' => 'Hello world!']]);
« More »
list_all¶
Return list of files in path relative to current file.
« More »
date¶
Returns a <time> element containing the time. Pass falsy value to format to
exclude them from output.
« More »
term¶
Returns a <a> element containing the "primary" (first) term. Optionally pass
and ID or term object to retrieve that term as an element.
« More »
readmore¶
Returns a <a> element containing the permalink.
« More »
get¶
Prints a template. Templates can be just about anything, but they must have a
function with the name you use to print the template. See sample_template() and sample_template_named_params().
« More »
save¶
Return template instead of printing it. Uses get() internally.
« More »
get_excerpt¶
Return post excerpt. Tries to get a dedicated custom field first, then falls
back to native excerpt and finally gets a preview from content unless told not to.
« More »
get_preview¶
Get preview from the content. Stops at first paragraph.
« More »
excerpt¶
Return the excerpt as a template tag, using get_excerpt().
« More »
preview¶
Return a preview of the post as a template tag, using get_preview().
« More »
archive_link¶
Returns post type archive link, in a consistent way.
« More »
get_acf_option¶
Return a field from ACF options page using the current language.
You must construct your option pages like this:
Base: http://i.imgur.com/8ypMOjx.png
Actual options, do for every language: http://i.imgur.com/uwvsgMj.png
« More »