本文整理汇总了PHP中get_404_template函数的典型用法代码示例。如果您正苦于以下问题:PHP get_404_template函数的具体用法?PHP get_404_template怎么用?PHP get_404_template使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_404_template函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWpTemplate
function getWpTemplate()
{
if (defined('WP_USE_THEMES') && WP_USE_THEMES) {
$template = false;
if (is_404() && ($template = get_404_template())) {
} elseif (is_search() && ($template = get_search_template())) {
} elseif (is_tax() && ($template = get_taxonomy_template())) {
} elseif (is_front_page() && ($template = get_front_page_template())) {
} elseif (is_home() && ($template = get_home_template())) {
} elseif (is_attachment() && ($template = get_attachment_template())) {
} elseif (is_single() && ($template = get_single_template())) {
} elseif (is_page() && ($template = get_page_template())) {
} elseif (is_category() && ($template = get_category_template())) {
} elseif (is_tag() && ($template = get_tag_template())) {
} elseif (is_author() && ($template = get_author_template())) {
} elseif (is_date() && ($template = get_date_template())) {
} elseif (is_archive() && ($template = get_archive_template())) {
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif (is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
return str_replace(ABSPATH, '', $template);
} else {
return null;
}
}
示例2: redirect_expired
function redirect_expired()
{
global $wp_query;
if (is_singular()) {
if ('expired' == $wp_query->post->post_status) {
if (function_exists('is_syndicated') and is_syndicated($wp_query->post->ID)) {
$source = get_syndication_feed_object($wp_query->post->ID);
$redirect_url = $source->setting('expired post redirect to', 'expired_post_redirect_to', NULL);
} else {
$redirect_url = get_option('feedwordpress_expired_post_redirect_to', NULL);
}
if (!is_null($redirect_url) and strlen(esc_url($redirect_url)) > 0 and 'none' != $redirect_url) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $redirect_url);
} else {
// Meh.
if (!($template = get_404_template())) {
$template = get_index_template();
}
if ($template = apply_filters('template_include', $template)) {
header("HTTP/1.1 410 Gone");
include $template;
}
}
exit;
}
}
}
示例3: throw404
/**
* Launch and display the 404 page depending upon the template
*
* @param void
* @return void
**/
public function throw404()
{
// Change WP Query
global $wp_query;
$wp_query->set_404();
status_header(404);
// Disable that pesky Admin Bar
add_filter('show_admin_bar', '__return_false', 900);
remove_action('admin_footer', 'wp_admin_bar_render', 10);
remove_action('wp_head', 'wp_admin_bar_header', 10);
remove_action('wp_head', '_admin_bar_bump_cb', 10);
wp_dequeue_script('admin-bar');
wp_dequeue_style('admin-bar');
// Template
$four_tpl = apply_filters('LD_404', get_404_template());
// Handle the admin bar
@define('APP_REQUEST', TRUE);
@define('DOING_AJAX', TRUE);
if (empty($four_tpl) or !file_exists($four_tpl)) {
// We're gonna try and get TwentyTen's one
$twenty_ten_tpl = apply_filters('LD_404_FALLBACK', WP_CONTENT_DIR . '/themes/twentyfourteen/404.php');
if (file_exists($twenty_ten_tpl)) {
require $twenty_ten_tpl;
} else {
wp_die('404 - File not found!', '', array('response' => 404));
}
} else {
// Their theme has a template!
require $four_tpl;
}
// Either way, it's gonna stop right here.
exit;
}
示例4: get_404_template
private static function get_404_template()
{
if (!($template = get_404_template())) {
$template = get_index_template();
}
return $template;
}
示例5: load_template
/**
* Copy-pasta of wp-includes/template-loader.php
*/
private function load_template()
{
do_action('template_redirect');
$template = false;
if (is_404() && ($template = get_404_template())) {
} elseif (is_search() && ($template = get_search_template())) {
} elseif (is_front_page() && ($template = get_front_page_template())) {
} elseif (is_home() && ($template = get_home_template())) {
} elseif (is_post_type_archive() && ($template = get_post_type_archive_template())) {
} elseif (is_tax() && ($template = get_taxonomy_template())) {
} elseif (is_attachment() && ($template = get_attachment_template())) {
remove_filter('the_content', 'prepend_attachment');
} elseif (is_single() && ($template = get_single_template())) {
} elseif (is_page() && ($template = get_page_template())) {
} elseif (is_category() && ($template = get_category_template())) {
} elseif (is_tag() && ($template = get_tag_template())) {
} elseif (is_author() && ($template = get_author_template())) {
} elseif (is_date() && ($template = get_date_template())) {
} elseif (is_archive() && ($template = get_archive_template())) {
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif (is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
/**
* Filter the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
if ($template = apply_filters('template_include', $template)) {
$template_contents = file_get_contents($template);
$included_header = $included_footer = false;
if (false !== stripos($template_contents, 'get_header();')) {
do_action('get_header', null);
locate_template('header.php', true, false);
$included_header = true;
}
include $template;
if (false !== stripos($template_contents, 'get_footer();')) {
do_action('get_footer', null);
locate_template('footer.php', true, false);
$included_footer = true;
}
if ($included_header && $included_footer) {
global $wp_scripts;
$wp_scripts->done = array();
}
}
return;
}
示例6: login_to_notfound
static function login_to_notfound()
{
if (isset($_REQUEST['logout'])) {
return;
}
if (preg_match('/wp-login.php/', $_SERVER['REQUEST_URI'])) {
if ($_REQUEST['action'] == 'register' || $_REQUEST['action'] == 'login') {
$template = get_404_template();
include $template;
exit;
}
}
}
示例7: init
/**
* Sets a 404 error for wp-login.php if it's disabled
*
* @since 6.3
* @access public
*/
public function init()
{
global $wp_query, $pagenow;
if ('wp-login.php' == $pagenow && $this->get_option('private_login')) {
$pagenow = 'index.php';
$wp_query->set_404();
status_header(404);
nocache_headers();
if (!($template = get_404_template())) {
$template = 'index.php';
}
include $template;
exit;
}
}
示例8: jr_security_check
/**
* Function to prevent visitors without admin permissions
* to access the wordpress backend. If you wish to permit
* others besides admins acces, change the user_level
* to a different number.
*
* http://codex.wordpress.org/Roles_and_Capabilities#level_8
*
* @global <type> $user_level
*
* in order to use this for wpmu, you need to follow the comment
* instructions below in all locations and make the changes
*/
function jr_security_check()
{
$jr_access_level = get_option('jr_admin_security');
if (!isset($jr_access_level) || $jr_access_level == '') {
$jr_access_level = 'read';
}
// if there's no value then give everyone access
if (!current_user_can($jr_access_level)) {
// comment out the above two lines and uncomment this line if you are using
// wpmu and want to block back office access to everyone except admins
// if (!is_site_admin()) {
status_header(404);
nocache_headers();
include get_404_template();
exit;
}
}
示例9: store_template
/**
* Include store template
*
* @param type $template
* @return string
*/
function store_template($template)
{
$store_name = get_query_var('store');
if (!empty($store_name)) {
$store_user = get_user_by('slug', $store_name);
// no user found
if (!$store_user) {
return get_404_template();
}
// check if the user is seller
if (!dokan_is_user_seller($store_user->ID)) {
return get_404_template();
}
$templates = array("store-{$store_name}.php", 'store.php');
return get_query_template('store', $templates);
}
return $template;
}
示例10: templateChooser
/**
* Pick the correct template to include
*
* @param string $template Path to template
*
* @return string Path to template
*/
public static function templateChooser($template)
{
$events = Tribe__Events__Main::instance();
do_action('tribe_tec_template_chooser', $template);
// no non-events need apply
if (!tribe_is_event_query()) {
return $template;
}
// if it's a single 404 event
if (is_single() && is_404()) {
return get_404_template();
}
if (!is_single() && !tribe_events_is_view_enabled($events->displaying) && 'day' != $events->displaying) {
return get_404_template();
}
// add the theme slug to the body class
add_filter('body_class', array(__CLASS__, 'theme_body_class'));
// add the template name to the body class
add_filter('body_class', array(__CLASS__, 'template_body_class'));
// user has selected a page/custom page template
if (tribe_get_option('tribeEventsTemplate', 'default') != '') {
if (!is_single() || !post_password_required()) {
add_action('loop_start', array(__CLASS__, 'setup_ecp_template'));
}
$template = locate_template(tribe_get_option('tribeEventsTemplate', 'default') == 'default' ? 'page.php' : tribe_get_option('tribeEventsTemplate', 'default'));
if ($template == '') {
$template = get_index_template();
}
// remove singular body class if sidebar-page.php
if ($template == get_stylesheet_directory() . '/sidebar-page.php') {
add_filter('body_class', array(__CLASS__, 'remove_singular_body_class'));
} else {
add_filter('body_class', array(__CLASS__, 'add_singular_body_class'));
}
} else {
$template = self::getTemplateHierarchy('default-template');
}
// if this is an oembed, override the wrapping template and use the embed template
if (Tribe__Templates::is_embed()) {
$template = self::getTemplateHierarchy('embed');
}
self::$template = $template;
return $template;
}
示例11: colabs_security_check
/**
* Function to prevent visitors without admin permissions
* to access the wordpress backend. If you wish to permit
* others besides admins acces, change the user_level
* to a different number.
*
* http://codex.wordpress.org/Roles_and_Capabilities#level_8
*
* @global <type> $user_level
*
* in order to use this for wpmu, you need to follow the comment
* instructions below in all locations and make the changes
*/
function colabs_security_check()
{
// secure the backend for non ajax calls
if (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) != 'admin-ajax.php') {
$colabs_access_level = get_option('colabs_admin_security');
}
if (!isset($colabs_access_level) || $colabs_access_level == '') {
$colabs_access_level = 'read';
}
// if there's no value then give everyone access
if (is_user_logged_in() && !current_user_can($colabs_access_level)) {
// comment out the above two lines and uncomment this line if you are using
// wpmu and want to block back office access to everyone except admins
// if (!is_site_admin()) {
status_header(404);
nocache_headers();
include get_404_template();
exit;
}
}
示例12: set_error_404
/**
* Load the 404 Not Found error page and display it (optional)
*
* @param bool $redirect Redirect browser to the page?
* @param bool $display Display the page?
* @since WP_Basic_Bootstrap 1.0
*/
function set_error_404($redirect = true, $display = false)
{
/* @var $wp_query \WP_Query */
global $wp_query;
$wp_query->set_404();
$status = basicbootstrap_get_status();
if ($redirect && $status != 404) {
wp_redirect(site_url('?error=404'));
} elseif ($display) {
status_header(404);
nocache_headers();
$tpl = get_404_template();
if (!empty($tpl)) {
include $tpl;
} else {
echo '<p>Page not found!</p>';
}
exit;
}
}
示例13: xtreme_get_template
function xtreme_get_template()
{
global $wp;
if (defined('WP_USE_THEMES') && constant('WP_USE_THEMES')) {
if (is_404() && ($template = get_404_template())) {
return redefine_pagenow($template);
} elseif (is_search() && ($template = get_search_template())) {
return redefine_pagenow($template);
} elseif (is_tax() && ($template = get_taxonomy_template())) {
return redefine_pagenow($template);
} elseif (is_front_page() && ($template = get_front_page_template())) {
return redefine_pagenow($template);
} elseif (is_home() && ($template = get_home_template())) {
return redefine_pagenow($template);
} elseif (is_attachment() && ($template = get_attachment_template())) {
return redefine_pagenow($template);
} elseif (is_single() && ($template = get_single_template())) {
return redefine_pagenow($template);
} elseif (is_page() && ($template = get_page_template())) {
return redefine_pagenow($template);
} elseif (is_category() && ($template = get_category_template())) {
return redefine_pagenow($template);
} elseif (is_tag() && ($template = get_tag_template())) {
return redefine_pagenow($template);
} elseif (is_author() && ($template = get_author_template())) {
return redefine_pagenow($template);
} elseif (is_date() && ($template = get_date_template())) {
return redefine_pagenow($template);
} elseif (is_archive() && ($template = get_archive_template())) {
return redefine_pagenow($template);
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
return redefine_pagenow($template);
} elseif (is_paged() && ($template = get_paged_template())) {
return redefine_pagenow($template);
} else {
$template = get_index_template();
return redefine_pagenow($template);
}
}
}
示例14: choose_template
/**
* Get the fork's parent post, set up a query, and load correct template.
*
* Duplicates the functionality of /wp-includes/template-loader.php and includes
* a lot of copypasta, but that's only to ensure that it follows the same logic.
*
*/
function choose_template()
{
$p = get_queried_object_id();
if (get_post_type($p) !== 'fork') {
return;
}
$pp = get_post($p)->post_parent;
$parent = get_post($pp);
if ($parent->post_type == 'page') {
$query = array('page_id' => $pp);
} else {
$query = array('p' => $pp);
}
$t = new WP_Query($query);
$template = false;
if ($t->is_404() && ($template = get_404_template())) {
} elseif ($t->is_search() && ($template = get_search_template())) {
} elseif ($t->is_tax() && ($template = get_taxonomy_template())) {
} elseif ($t->is_front_page() && ($template = get_front_page_template())) {
} elseif ($t->is_home() && ($template = get_home_template())) {
} elseif ($t->is_attachment() && ($template = get_attachment_template())) {
remove_filter('the_content', 'prepend_attachment');
} elseif ($t->is_single() && ($template = get_single_template())) {
} elseif ($t->is_page && ($template = get_page_template())) {
} elseif ($t->is_category() && ($template = get_category_template())) {
} elseif ($t->is_tag() && ($template = get_tag_template())) {
} elseif ($t->is_author() && ($template = get_author_template())) {
} elseif ($t->is_date() && ($template = get_date_template())) {
} elseif ($t->is_archive() && ($template = get_archive_template())) {
} elseif ($t->is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif ($t->is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
if ($template = apply_filters('template_include', $template)) {
include $template;
}
return;
}
示例15: check_template
function check_template()
{
if (is_404() && ($template = get_404_template())) {
$this->template = $template;
} elseif (is_search() && ($template = get_search_template())) {
$this->template = $template;
} elseif (is_tax() && ($template = get_taxonomy_template())) {
$this->template = $template;
} elseif (is_home() && ($template = get_home_template())) {
$this->template = $template;
} elseif (is_attachment() && ($template = get_attachment_template())) {
$this->template = $template;
} elseif (is_single() && ($template = get_single_template())) {
$this->template = $template;
} elseif (is_page() && ($template = get_page_template())) {
$this->template = $template;
} elseif (is_category() && ($template = get_category_template())) {
$this->template = $template;
} elseif (is_tag() && ($template = get_tag_template())) {
$this->template = $template;
} elseif (is_author() && ($template = get_author_template())) {
$this->template = $template;
} elseif (is_date() && ($template = get_date_template())) {
$this->template = $template;
} elseif (is_archive() && ($template = get_archive_template())) {
$this->template = $template;
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
$this->template = $template;
} elseif (is_paged() && ($template = get_paged_template())) {
$this->template = $template;
} else {
$this->template = function_exists('get_index_template') ? get_index_template() : TEMPLATEPATH . "/index.php";
}
$this->template = apply_filters('template_include', $this->template);
// Hook into the footer so we can echo the active template
add_action('wp_footer', array(&$this, 'show_template'), 100);
}