/** * Hijack `template_include` so that we can ensure a $theme variable is defined. * * @param string $template; * * @return static */ static function _template_include_999($template) { if (!$template) { $message = __('<p>No template file found. You may have deleted the current theme or renamed the theme directory?</p>' . '<p>If you are a site admin <a href="%s">click here</a> to verify and possibly correct.</p>', 'wplib'); echo sprintf($message, esc_url(site_url('/wp-admin/themes.php'))); } else { global $theme; /* * Make $theme available inside the template. */ $theme = WPLib::theme(); if (WPLib::use_template_global_vars()) { /** * For compatibility with WordPress templates we need to * extract all the global variables into the current scope. */ extract($GLOBALS, EXTR_SKIP); } include $template; } return false; }
/** * Hijack `template_include` so that we can ensure a $theme variable is defined. * * @param string $template; * * @return static */ static function _template_include_999($template) { if (!$template && !WPLib::is_production()) { $message = __('<p>No template file found. You may have deleted the current theme or renamed the theme directory?</p>' . '<p>If you are a site admin <a href="%s">click here</a> to verify and possibly correct.</p>', 'wplib'); /* * This use of wp-admin theme URL is only presented to help the user * when the site is misconfigured. However, ironically, some code * sniffers constantly flag it so it is easier to obscure it from * the sniffer than to have to constantly see it flagged. */ $admin_path = 'wp-admin'; echo sprintf($message, esc_url(site_url("/{$admin_path}/themes.php"))); } else { global $theme; /* * Make $theme available inside the template. */ $theme = WPLib::theme(); if (WPLib::use_template_global_vars()) { /* * For compatibility with WordPress templates we need to * extract all the global variables into the current scope just * like WordPress does when it calls a template. Ironically * some code sniffers constantly flag extract() so it is easier to * hide it than to have to constantly see it flagged. * * OTOH if you are using WPLib and you think we should do a direct call * to extract() here please add an issue so we can discuss the pros and * cons at https://github.com/wplib/wplib/issues */ $function = 'extract'; $function($GLOBALS, EXTR_SKIP); } include $template; } return false; }
/** * @param string $template * @param array|string $_template_vars */ function the_template($template, $_template_vars = array()) { WPLib::the_template($template, $_template_vars, WPLib::theme()); }
/** * @param array $args * */ function the_comment_list_html($args = array()) { wp_list_comments($args, WPLib::theme()->query()->comments); }
/** * @return int */ function number_of_comment_pages() { $theme = WPLib::theme(); if (!$theme->uses_paged_comments()) { $number = $this->has_comments() ? 1 : 0; } else { $number = $this->has_post() ? $theme->number_of_comment_pages() : 0; } return $number; }