php helper for including a partial

When I prototype in PHP, I use this small helper function to include a partial and to import┬ásome variables. /** * Helper * @param string $tpl * @param array $vars * @return void */ function tplinclude($tpl, array $vars = []) { extract($vars); include $tpl; } Example: <html> <body> <?php tplinclude(‘article.php’, Read more…

wordpress php helper

Helper for including theme assets, stylesheets or javascript files: function theme_asset($filename) { return get_stylesheet_directory_uri() . ‘/’ . $filename; } function theme_css($filename) { $filename = theme_asset($filename); return “<link href='{$filename}’ rel=’stylesheet’ type=’text/css’>”; } function theme_js($filename) { $filename = theme_asset($filename); return “<script type=’text/javascript’ src='{$filename}’></script>”; }