本文整理汇总了PHP中load_template函数的典型用法代码示例。如果您正苦于以下问题:PHP load_template函数的具体用法?PHP load_template怎么用?PHP load_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_template函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cps_ban_check
function cps_ban_check()
{
if (!is_user_logged_in()) {
return;
}
global $current_user;
if (is_multisite()) {
if (empty($current_user->roles)) {
load_template(dirname(__FILE__) . '/wp_ban_cps_ms_alert.php');
}
foreach ($current_user->roles as $role) {
if ($role == 'banned') {
load_template(dirname(__FILE__) . '/wp_ban_cps_ms_alert.php');
}
}
} else {
foreach ($current_user->roles as $role) {
if ($role == 'banned') {
wp_clear_auth_cookie();
do_action('wp_logout');
wp_redirect(home_url());
exit;
}
}
}
}
示例2: render_template
/**
* Locates and renders the album based on the template
* Will look in the following locations
* wp-content/themes/{child-theme}/foogallery/album-{template}.php
* wp-content/themes/{theme}/foogallery/album-{template}.php
* wp-content/plugins/foogallery/templates/album-{template}.php
*
* @param $args array Arguments passed in from the shortcode
*/
public function render_template($args)
{
//do some work before we locate the template
global $current_foogallery_album;
global $current_foogallery_album_arguments;
global $current_foogallery_album_template;
//set the arguments
$current_foogallery_album_arguments = $args;
//load our album
$current_foogallery_album = $this->find_album($args);
if (false === $current_foogallery_album) {
_e('Could not load the album!', 'foogallery');
return;
}
//find the gallery template we will use to render the gallery
$current_foogallery_album_template = $this->get_arg($args, 'template', $current_foogallery_album->album_template);
//set a default if we have no gallery template
if (empty($current_foogallery_album_template)) {
$current_foogallery_album_template = foogallery_get_default('album_template');
}
//if we still have not default, then use the first one we can find
if (empty($current_foogallery_album_template)) {
$available_templates = foogallery_album_templates();
$current_foogallery_album_template = $available_templates[0]['slug'];
}
//check if we have any galleries
if (!$current_foogallery_album->has_galleries()) {
//no galleries!
do_action("foogallery_album_template_no_galleries-({$current_foogallery_album_template})", $current_foogallery_album);
} else {
//create locator instance
$instance_name = FOOGALLERY_SLUG . '_album_templates';
$loader = new Foo_Plugin_File_Locator_v1($instance_name, FOOGALLERY_FILE, 'templates', FOOGALLERY_SLUG);
//allow extensions to very easily add pickup locations for their files
$this->add_extension_pickup_locations($loader, apply_filters($instance_name . '_files', array()));
if (false !== ($template_location = $loader->locate_file("album-{$current_foogallery_album_template}.php"))) {
//we have found a template!
do_action('foogallery_located_album_template', $current_foogallery_album);
do_action("foogallery_located_album_template-{$current_foogallery_album_template}", $current_foogallery_album);
//try to include some JS
if (false !== ($js_location = $loader->locate_file("album-{$current_foogallery_album_template}.js"))) {
wp_enqueue_script("foogallery-album-template-{$current_foogallery_album_template}", $js_location['url']);
}
//try to include some CSS
if (false !== ($css_location = $loader->locate_file("album-{$current_foogallery_album_template}.css"))) {
wp_enqueue_style("foogallery-album-template-{$current_foogallery_album_template}", $css_location['url']);
}
//finally include the actual php template!
if ($template_location) {
load_template($template_location['path'], false);
}
//we have loaded all files, now let extensions do some stuff
do_action("foogallery_loaded_album_template", $current_foogallery_album);
do_action("foogallery_loaded_album_template-({$current_foogallery_album_template})", $current_foogallery_album);
} else {
//we could not find a template!
_e('No album template found!', 'foogallery');
}
}
}
示例3: issues_handler
static function issues_handler()
{
if (strtok($_SERVER["REQUEST_URI"], '?') == '/issues') {
load_template(plugin_dir_path(__FILE__) . 'page-issues.php');
exit;
}
}
示例4: nimbus_cotizador
function nimbus_cotizador($atts, $content)
{
extract($atts);
set_query_var('success', $action);
$template = locate_template("/templates/quote.php");
load_template($template);
}
示例5: popmake_locate_template
/**
* Retrieve the name of the highest priority template file that exists.
*/
function popmake_locate_template($template_names, $load = false, $require_once = true)
{
// No file found yet
$located = false;
// Try to find a template file
foreach ((array) $template_names as $template_name) {
// Continue if template is empty
if (empty($template_name)) {
continue;
}
// Trim off any slashes from the template name
$template_name = ltrim($template_name, '/');
// try locating this template file by looping through the template paths
foreach (popmake_get_theme_template_paths() as $template_path) {
if (file_exists($template_path . $template_name)) {
$located = $template_path . $template_name;
break;
}
}
if ($located) {
break;
}
}
if (true == $load && !empty($located)) {
load_template($located, $require_once);
}
return $located;
}
示例6: search_handler
static function search_handler()
{
if (strtok($_SERVER["REQUEST_URI"], '?') == '/search') {
load_template(plugin_dir_path(__FILE__) . 'page-search.php');
exit;
}
if (strtok($_SERVER["REQUEST_URI"], '?') == '/search-request') {
$search_options = array('s' => $_GET['s'], 'post_type' => 'post');
if ($_GET['cat']) {
$search_options['cat'] = get_category_by_slug($_GET['cat'])->term_id;
}
if ($_GET['author']) {
$search_options['author_name'] = $_GET['author'];
}
$search_options['paged'] = $_GET['page'] ? $_GET['page'] : 1;
$search_options['posts_per_page'] = 3;
$searched_posts = new WP_Query($search_options);
$show_more_link = $searched_posts->max_num_pages > $search_options['paged'];
if ($search_options['paged'] > 1) {
include 'search-more.php';
} else {
include 'search.php';
}
exit;
}
}
示例7: pn_get_template_part
/**
* Load template files of the plugin also include a filter pn_get_template_part<br>
* Based on WooCommerce function<br>
*
* @package Plugin_Name
* @author Mte90 <mte90net@gmail.com>
* @license GPL-2.0+
* @copyright 2014-2015
* @since 1.0.0
*/
function pn_get_template_part($slug, $name = '', $include = true)
{
$template = '';
$path = plugin_dir_path(realpath(dirname(__FILE__))) . 'templates/';
$plugin = Plugin_Name::get_instance();
$plugin_slug = $plugin->get_plugin_slug() . '/';
// Look in yourtheme/slug-name.php and yourtheme/plugin-name/slug-name.php
if ($name) {
$template = locate_template(array("{$slug}-{$name}.php", $plugin_slug . "{$slug}-{$name}.php"));
} else {
$template = locate_template(array("{$slug}.php", $plugin_slug . "{$slug}.php"));
}
// Get default slug-name.php
if (!$template && $name && file_exists($path . "{$slug}-{$name}.php")) {
$template = $path . "{$slug}-{$name}.php";
}
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php
if (!$template) {
$template = locate_template(array("{$slug}.php", $plugin_slug . "{$slug}.php"));
}
// Allow 3rd party plugin filter template file from their plugin
$template = apply_filters('pn_get_template_part', $template, $slug, $name);
if ($template && $include === true) {
load_template($template, false);
} else {
if ($template && $include === false) {
return $template;
}
}
}
示例8: locate_template
public function locate_template($template_names, $load = false, $require_once = true)
{
// No file found yet
$located = false;
// Traverse through template files
foreach ((array) $template_names as $template_name) {
// Continue if template is empty
if (empty($template_name)) {
continue;
}
$template_name = ltrim($template_name, '/');
// Check templates for frontend section
if (file_exists(trailingslashit(upme_path) . 'templates/cards/' . $template_name)) {
$located = trailingslashit(upme_path) . 'templates/cards/' . $template_name;
break;
// Check templates for admin section
} elseif (file_exists(trailingslashit(upme_path) . 'admin/templates/' . $template_name)) {
$located = trailingslashit(upme_path) . 'admin/templates/' . $template_name;
break;
} else {
/* Enable additional template locations using filters for addons */
$template_locations = apply_filters('upme_template_loader_locations', array());
foreach ($template_locations as $location) {
if (file_exists($location . $template_name)) {
$located = $location . $template_name;
break;
}
}
}
}
if (true == $load && !empty($located)) {
load_template($located, $require_once);
}
return $located;
}
示例9: eo_locate_template
/**
* Retrieve the name of the highest priority template file that exists.
*
* Searches the child theme first, then the parent theme before checking the plug-in templates folder.
* So parent themes can override the default plug-in templates, and child themes can over-ride both.
*
* Behaves almost identically to `{@see locate_template()}`
*
* @since 1.7
*
* @param string|array $template_names Template file(s) to search for, in order.
* @param bool $load If true the template file will be loaded if it is found.
* @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
* @return string The template filename if one is located.
*/
function eo_locate_template($template_names, $load = false, $require_once = true)
{
$located = '';
$template_dir = get_stylesheet_directory();
//child theme
$parent_template_dir = get_template_directory();
//parent theme
$stack = apply_filters('eventorganiser_template_stack', array($template_dir, $parent_template_dir, EVENT_ORGANISER_DIR . 'templates'));
$stack = array_unique($stack);
foreach ((array) $template_names as $template_name) {
if (!$template_name) {
continue;
}
foreach ($stack as $template_stack) {
if (file_exists(trailingslashit($template_stack) . $template_name)) {
$located = trailingslashit($template_stack) . $template_name;
break;
}
}
}
if ($load && '' != $located) {
load_template($located, $require_once);
}
return $located;
}
示例10: loading_classes
/**
* The callback function used by spl_autoload_register
* @param $class_name string - The class name
*/
private function loading_classes($class_name)
{
$path_regex = 'td';
// foreach regex path, the class name is verified for a start matching
if (strpos($class_name, $path_regex) !== false and strpos($class_name, $path_regex) === 0) {
$class_settings = td_api_base::get_by_id($class_name);
if (!empty($class_settings)) {
if (array_key_exists('file', $class_settings)) {
$class_file_path = $class_settings['file'];
if (isset($class_file_path) and !empty($class_file_path)) {
// set the autoloaded key for that component
td_api_base::_debug_set_class_is_autoloaded($class_name);
// if ($class_name == 'td_page_views') {
// print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4)); //return only 4 call stack frames
// die;
// }
// require_once($class_file_path); - we need to use load_template to make our single_templates work like wordpress
// with load_template we prepare the globals ($post etc for the files)
// we should not use the global $post or any other globals in our classes without explicit declaration
load_template($class_file_path, true);
}
} else {
td_util::error(__FILE__, "Missing parameter: 'file'");
}
}
}
}
示例11: gerenciar_auditoria
public function gerenciar_auditoria()
{
$this->load->library('table');
//vai carregar o modulo usuarios e mostrar a tela de recuperação de senha
set_tema('headerinc', load_css('dataTables.bootstrap.min'), FALSE);
set_tema('headerinc', load_css('responsive.bootstrap.min'), FALSE);
set_tema('headerinc', load_css('ionicons.min', 'css/ionicons/css'), FALSE);
set_tema('footerinc', load_js('jquery.dataTables'), FALSE);
set_tema('footerinc', load_js('dataTables.bootstrap.min'), FALSE);
set_tema('footerinc', load_js('dataTables.responsive.min'), FALSE);
set_tema('footerinc', load_js('table-manage-responsive-auditoria.min'), FALSE);
set_tema('footerinc', load_js('tooltip'), FALSE);
set_tema('footerinc', '<script>
$(document).ready(function() {
App.init();
TableManageResponsive.init();
$(\'[data-toggle="tooltip"]\').tooltip();
});
</script>', FALSE);
set_tema('titulo', 'Registros da Auditoria');
set_tema('conteudo', load_modulo('auditoria', 'gerenciar_auditoria'));
set_tema('rodape', '');
//vai substituir o rodape padrao
load_template();
}
示例12: bppp_locate_template
function bppp_locate_template($template_names, $load = false, $require_once = false)
{
$located = '';
foreach ((array) $template_names as $template_name) {
if (!$template_name) {
continue;
}
if (file_exists(STYLESHEETPATH . '/' . $template_name)) {
$located = STYLESHEETPATH . '/' . $template_name;
break;
} else {
if (file_exists(TEMPLATEPATH . '/' . $template_name)) {
$located = TEMPLATEPATH . '/' . $template_name;
break;
} else {
if (file_exists(BuddyPress_Profile_Progression()->templates_dir . $template_name)) {
$located = BuddyPress_Profile_Progression()->templates_dir . $template_name;
break;
}
}
}
}
if ($load && '' != $located) {
load_template($located, $require_once);
}
return $located;
}
开发者ID:NitinPrakash,项目名称:buddypress-force-profile-completion,代码行数:27,代码来源:buddypress_force_profile_completion_template.php
示例13: pronamic_framework_shortcode_edit_post_form
/**
* Pronamic framework edit post
*/
function pronamic_framework_shortcode_edit_post_form($atts, $content = null)
{
$result = '';
if (is_user_logged_in()) {
$post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT);
// Post
$post = get_post($post_id);
$post_type = get_post_type($post_id);
$post_type_object = get_post_type_object($post_type);
if ($post_type_object) {
if (current_user_can($post_type_object->cap->edit_posts, $post_id)) {
// Query start
global $wp_query;
$query = array('p' => $post_id, 'post_type' => 'any');
$original_query = $wp_query;
$wp_query = null;
$wp_query = new WP_Query($query);
// Template
ob_start();
$template = plugin_dir_path(Pronamic_Framework::$file) . '/templates/edit-post-form.php';
load_template($template, false);
$result = ob_get_clean();
// Query end
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();
}
}
}
return $result;
}
示例14: note_get_template_part
/**
* This function locates and loads templates based on arguments. Optionally an array of data can be passed
* that will be extract()ed and the template will have access to the $data. If data is passed, WordPress
* global variables can be included as well. The template file can also be required once if necessary.
*
* Verify if the file exists in the theme first, then load the plugin template if necessary as a fallback.
*/
function note_get_template_part($slug, $name = '', $data = array(), $wp_globals = false, $require_once = false)
{
// note_get_template_part filter
$template = apply_filters('note_get_template_part', note_locate_template_part($slug, $name), $slug, $name);
// Finally, if we have a template, lets load it
if ($template) {
// If data was passed we have to require() the files
if (is_array($data) && !empty($data)) {
$data = apply_filters('note_get_template_part_data', $data, $slug, $name);
// WordPress Globals
if ($wp_globals) {
global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
}
// Extract the data for use in the template
extract($data, EXTR_SKIP);
// Skip collisions
unset($data);
// We don't need the $data var anymore
// Require Once
if ($require_once) {
require_once $template;
} else {
require $template;
}
} else {
load_template($template, $require_once);
}
}
}
示例15: vermensagem
public function vermensagem()
{
esta_logado();
set_tema('titulo', 'Visualizar Mensagens');
set_tema('conteudo', load_modulo('contatos', 'vermensagem'));
load_template();
}