Exemplo n.º 1
0
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;
    }
}
Exemplo n.º 2
0
 public static function post($post_id)
 {
     wb_set('current_url', get_permalink($post_id));
     query_posts(array('p' => $post_id, 'post_type' => 'post'));
     the_post();
     $template = get_single_template();
     rewind_posts();
     wb_link_hack(true);
     include $template;
     wb_link_hack(false);
     wp_reset_query();
 }
 /**
  * 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;
 }
Exemplo n.º 4
0
 function xsbf_is_fullwidth()
 {
     /* for pages, check the page template */
     if (is_page() and (+is_page_template('page-fullpostsnoheader.php') or +is_page_template('page-fullwidth-noheader.php') or +is_page_template('page-fullwidth.php') or +is_page_template('page-fullwithposts.php') or +is_page_template('page-fullwithsubpages.php'))) {
         return true;
         /* for posts, check the single template */
     } elseif (is_single()) {
         $current_template = get_single_template();
         $fullwidth_template = get_query_template('single-fullwidth');
         if ($current_template and $current_template == $fullwidth_template) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 5
0
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);
        }
    }
}
 /**
  * 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;
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 public function templateLoad($defaultView = '')
 {
     global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
     $content = '';
     /**
      * Loads the correct template based on the visitor's url
      * @package WordPress
      */
     if (defined('WP_USE_THEMES') && WP_USE_THEMES) {
         do_action('template_redirect');
     }
     /**
      * Filter whether to allow 'HEAD' requests to generate content.
      *
      * Provides a significant performance bump by exiting before the page
      * content loads for 'HEAD' requests. See #14348.
      *
      * @since 3.5.0
      *
      * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
      */
     if ('HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters('exit_on_http_head', true)) {
         exit;
     }
     // Process feeds and trackbacks even if not using themes.
     if (is_robots()) {
         /**
          * Fired when the template loader determines a robots.txt request.
          *
          * @since 2.1.0
          */
         do_action('do_robots');
         return $content;
     } elseif (is_feed()) {
         do_feed();
         return $content;
     } elseif (is_trackback()) {
         include ABSPATH . 'wp-trackback.php';
         return $content;
     }
     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_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', $this->defaultView ?: $template)) {
             load_template($template, false);
         }
         return $content;
     }
 }
		include(ABSPATH . '/wp-feed.php');
		exit;
	} else if ( is_trackback() && empty($doing_trackback) ) {
		include(ABSPATH . '/wp-trackback.php');
		exit;
	} else if ( is_404() && get_404_template() ) {
		include(get_404_template());
		exit;
	} else if ( is_search() && get_search_template() ) {
		include(get_search_template());
		exit;
	} else if ( is_home() && get_home_template() ) {
		include(get_home_template());
		exit;
	} else if ( is_single() && get_single_template() ) {
		include(get_single_template());
		exit;
	} else if ( is_page() && get_page_template() ) {
		include(get_page_template());
		exit;
	} else if ( is_category() && get_category_template()) {
		include(get_category_template());
		exit;		
	} else if ( is_author() && get_author_template() ) {
		include(get_author_template());
		exit;
	} else if ( is_date() && get_date_template() ) {
		include(get_date_template());
		exit;
	} else if ( is_archive() && get_archive_template() ) {
		include(get_archive_template());
Exemplo n.º 10
0
 /**
  * @expectedDeprecated get_themes
  * @expectedDeprecated get_current_theme
  */
 function test_switch_theme()
 {
     $themes = get_themes();
     // Switch to each theme in sequence.
     // Do it twice to make sure we switch to the first theme, even if it's our starting theme.
     // Do it a third time to ensure switch_theme() works with one argument.
     for ($i = 0; $i < 3; $i++) {
         foreach ($themes as $name => $theme) {
             // switch to this theme
             if ($i === 2) {
                 switch_theme($theme['Template'], $theme['Stylesheet']);
             } else {
                 switch_theme($theme['Stylesheet']);
             }
             $this->assertEquals($name, get_current_theme());
             // make sure the various get_* functions return the correct values
             $this->assertEquals($theme['Template'], get_template());
             $this->assertEquals($theme['Stylesheet'], get_stylesheet());
             $root_fs = get_theme_root();
             $this->assertTrue(is_dir($root_fs));
             $root_uri = get_theme_root_uri();
             $this->assertTrue(!empty($root_uri));
             $this->assertEquals($root_fs . '/' . get_stylesheet(), get_stylesheet_directory());
             $this->assertEquals($root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri());
             $this->assertEquals($root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri());
             #				$this->assertEquals($root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri());
             $this->assertEquals($root_fs . '/' . get_template(), get_template_directory());
             $this->assertEquals($root_uri . '/' . get_template(), get_template_directory_uri());
             //get_query_template
             // template file that doesn't exist
             $this->assertEquals('', get_query_template(rand_str()));
             // template files that do exist
             //foreach ($theme['Template Files'] as $path) {
             //$file = basename($path, '.php');
             // FIXME: untestable because get_query_template uses TEMPLATEPATH
             //$this->assertEquals('', get_query_template($file));
             //}
             // these are kind of tautologies but at least exercise the code
             $this->assertEquals(get_404_template(), get_query_template('404'));
             $this->assertEquals(get_archive_template(), get_query_template('archive'));
             $this->assertEquals(get_author_template(), get_query_template('author'));
             $this->assertEquals(get_category_template(), get_query_template('category'));
             $this->assertEquals(get_date_template(), get_query_template('date'));
             $this->assertEquals(get_home_template(), get_query_template('home', array('home.php', 'index.php')));
             $this->assertEquals(get_page_template(), get_query_template('page'));
             $this->assertEquals(get_paged_template(), get_query_template('paged'));
             $this->assertEquals(get_search_template(), get_query_template('search'));
             $this->assertEquals(get_single_template(), get_query_template('single'));
             $this->assertEquals(get_attachment_template(), get_query_template('attachment'));
             // this one doesn't behave like the others
             if (get_query_template('comments-popup')) {
                 $this->assertEquals(get_comments_popup_template(), get_query_template('comments-popup'));
             } else {
                 $this->assertEquals(get_comments_popup_template(), ABSPATH . 'wp-includes/theme-compat/comments-popup.php');
             }
             $this->assertEquals(get_tag_template(), get_query_template('tag'));
             // nb: this probably doesn't run because WP_INSTALLING is defined
             $this->assertTrue(validate_current_theme());
         }
     }
 }
Exemplo n.º 11
0
/*
+----------------------------------------------------------------+
|																							|
|	WordPress 2.8 Plugin: WP-EMail 2.50										|
|	Copyright (c) 2009 Lester "GaMerZ" Chan									|
|																							|
|	File Written By:																	|
|	- Lester "GaMerZ" Chan															|
|	- http://lesterchan.net															|
|																							|
|	File Information:																	|
|	- E-Mail Post/Page To A Friend												|
|	- wp-content/plugins/wp-email/email-standalone.php					|
|																							|
+----------------------------------------------------------------+
*/
### Session Start
@session_start();
### Filters
add_filter('wp_title', 'email_pagetitle');
add_action('loop_start', 'email_addfilters');
### We Use Page Template
if (file_exists(TEMPLATEPATH . '/email.php')) {
    include TEMPLATEPATH . '/email.php';
} elseif (file_exists(TEMPLATEPATH . '/page.php')) {
    include get_page_template();
} elseif (file_exists(TEMPLATEPATH . '/single.php')) {
    include get_single_template();
} else {
    include TEMPLATEPATH . '/index.php';
}
		include(ABSPATH . 'wp-trackback.php');
		return;
	} else if ( is_404() && $template = get_404_template() ) {
		include($template);
		return;
	} else if ( is_search() && $template = get_search_template() ) {
		include($template);
		return;
	} else if ( is_home() && $template = get_home_template() ) {
		include($template);
		return;
	} else if ( is_attachment() && $template = get_attachment_template() ) {
		remove_filter('the_content', 'prepend_attachment');
		include($template);
		return;
	} else if ( is_single() && $template = get_single_template() ) {
		include($template);
		return;
	} else if ( is_page() && $template = get_page_template() ) {
		include($template);
		return;
	} else if ( is_category() && $template = get_category_template()) {
		include($template);
		return;
	} else if ( is_tag() && $template = get_tag_template()) {
		include($template);
		return;
	} else if ( is_tax() && $template = get_taxonomy_template()) {
		include($template);
		return;
	} else if ( is_author() && $template = get_author_template() ) {
Exemplo n.º 13
0
 public function render($request)
 {
     $this->parse($request);
     //add_filter('wp_title', array($this, 'get_title'));
     add_action('wp_footer', array($this, 'start_editor'), 999);
     load_template(get_single_template());
     die;
 }
 /**
  * HideMyWP::block_access()
  *
  * @return
  */
 function block_access()
 {
     global $wp_query, $current_user;
     $visitor = esc_attr(is_user_logged_in() ? $current_user->user_login : $_SERVER["REMOTE_ADDR"]);
     $url = esc_url('http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
     // $wp_query->set('page_id', 2);
     // $wp_query->query($wp_query->query_vars);
     if ($this->opt('spy_notifier')) {
         $body = "Hi-\nThis is %s plugin. We guess someone is researching about your WordPress site.\n\nHere is some more details:\nVisitor: %s\nURL: %s\nUser Agent: %s\n\nBest Regards,\n%s";
         $body = sprintf(__($body, self::slug), self::title, $visitor, $url, $_SERVER['HTTP_USER_AGENT'], self::title);
         $subject = sprintf(__('[%s] Someone is mousing!', self::slug), self::title);
         wp_mail(get_option('admin_email'), $subject, $body);
     }
     status_header(404);
     nocache_headers();
     $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
     $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
     foreach ((array) $headers as $name => $field_value) {
         @header("{$name}: {$field_value}");
     }
     //if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
     //	@header_remove( 'Last-Modified' );
     //wp-login.php wp-admin and direct .php access can not be implemented using 'wp' hook block_access can't work correctly with init hook so we use wp_remote_get to fix the problem
     if ($this->h->str_contains($_SERVER['PHP_SELF'], '/wp-admin/') || $this->h->ends_with($_SERVER['PHP_SELF'], '.php')) {
         $visitor = esc_attr(is_user_logged_in() ? $current_user->user_login : $_SERVER["REMOTE_ADDR"]);
         if ($this->opt('custom_404') && $this->opt('custom_404_page')) {
             wp_redirect(add_query_arg(array('by_user' => $visitor, 'ref_url' => urldecode($_SERVER["REQUEST_URI"])), get_permalink($this->opt('custom_404_page'))));
         } else {
             $response = @wp_remote_get(home_url('/nothing_404_404'));
             if (!is_wp_error($response)) {
                 echo $response['body'];
             } else {
                 wp_redirect(home_url('/404_Not_Found'));
             }
         }
     } else {
         if (get_404_template()) {
             require_once get_404_template();
         } else {
             require_once get_single_template();
         }
     }
     die;
 }
 /**
  * Returns current group
  *
  * @return string
  */
 function get_group()
 {
     static $group = null;
     if ($group === null) {
         switch (true) {
             case is_404() && ($template = get_404_template()):
             case is_search() && ($template = get_search_template()):
             case is_tax() && ($template = get_taxonomy_template()):
             case is_home() && ($template = get_home_template()):
             case is_attachment() && ($template = get_attachment_template()):
             case is_single() && ($template = get_single_template()):
             case is_page() && ($template = get_page_template()):
             case is_category() && ($template = get_category_template()):
             case is_tag() && ($template = get_tag_template()):
             case is_author() && ($template = get_author_template()):
             case is_date() && ($template = get_date_template()):
             case is_archive() && ($template = get_archive_template()):
             case is_comments_popup() && ($template = get_comments_popup_template()):
             case is_paged() && ($template = get_paged_template()):
                 $group = basename($template, '.php');
                 break;
             default:
                 $group = 'default';
                 break;
         }
     }
     return $group;
 }
Exemplo n.º 16
0
<?php

### Session Start
@session_start();
### Filters
add_action('wp_head', 'email_meta_nofollow');
add_filter('wp_title', 'email_pagetitle');
add_action('loop_start', 'email_addfilters');
add_filter('comments_open', '__return_false');
### We Use Page Template
if ($template = locate_template('email.php')) {
    include $template;
} elseif ($template = get_page_template()) {
    include $template;
} elseif ($template = get_single_template()) {
    include $template;
} elseif ($template = get_index_template()) {
    include $template;
}
 /**
  * @DEPRICATED
  */
 public function getDefaultTemplate($post)
 {
     if ($post->post_status == 'auto-draft') {
         return false;
     }
     $args = array('p' => $post->ID, 'post_type' => $post->post_type);
     if ($post->post_type == 'page') {
         $args = array('page_id' => $post->ID);
     }
     $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();
     }
     // wp_reset_query();
     if ($template && is_file($template)) {
         $template = basename($template);
     } else {
         $template = false;
     }
     return $template;
 }
Exemplo n.º 18
0
function wats_ticket_template_loader($template)
{
    global $wp_query, $wats_settings;
    if (is_singular() && wats_is_ticket($wp_query->post) == true) {
        if (wats_check_visibility_rights()) {
            if ($wats_settings['template_selector'] == 0) {
                if (get_single_template()) {
                    $template = str_replace('single-ticket', 'single', get_single_template());
                }
                add_filter('the_content', 'wats_single_ticket_content_filter', 10, 1);
            } else {
                if (file_exists(get_stylesheet_directory() . '/single-ticket.php')) {
                    $template = get_stylesheet_directory() . '/single-ticket.php';
                } else {
                    $template = WATS_THEME_PATH . '/single-ticket.php';
                }
            }
        } else {
            if (file_exists(get_stylesheet_directory() . '/ticket-access-denied.php')) {
                $template = get_stylesheet_directory() . '/ticket-access-denied.php';
            } else {
                $template = WATS_THEME_PATH . '/ticket-access-denied.php';
            }
        }
    }
    return $template;
}
Exemplo n.º 19
0
            }
            $diffSinglePostType = array_diff($customPostTypesWithPosts, $singlePostTypesFromFiles);
            if (!empty($diffSinglePostType)) {
                $post = get_posts(array('numberposts' => 1, 'post_type' => $diffSinglePostType[key($diffSinglePostType)]));
                $post = $post[0];
                $singleChilds['single-posttype'] = true;
            }
        }
    }
}
/*
 * Single
 */
foreach ($singleChilds as $key => $value) {
    if ($value) {
        $singleTemplate = get_single_template();
        if (!empty($singleTemplate)) {
            $singlePath = explode('/', $singleTemplate);
            $singleFile = end($singlePath);
            switch ($key) {
                case 'single-post':
                    $id = $lastPost->ID;
                    break;
                case 'single-posttype':
                    $id = $post->ID;
                    break;
            }
            showOption(get_permalink($id), $singleFile, null, false, false, 'Single');
        }
        break;
    }
 function block_access()
 {
     status_header(404);
     nocache_headers();
     $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
     $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
     foreach ((array) $headers as $name => $field_value) {
         @header("{$name}: {$field_value}");
     }
     //if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
     //	@header_remove( 'Last-Modified' );
     //wp-login.php wp-admin and direct .php access can not be implemented using 'wp' hook block_access can't work correctly with init hook so we use wp_remote_get to fix the problem
     if (is_admin()) {
         if ($this->opt('custom_404') && $this->opt('custom_404_page')) {
             wp_redirect(get_permalink($this->opt('custom_404_page')));
         } else {
             $response = @wp_remote_get(home_url('/nothing_404_404'));
             if (!is_wp_error($response)) {
                 echo $response['body'];
             } else {
                 wp_redirect(home_url('/404_Not_Found'));
             }
         }
     } else {
         if (get_404_template()) {
             require_once get_404_template();
         } else {
             require_once get_single_template();
         }
     }
     die;
 }
Exemplo n.º 21
0
 /**
  * Emits template loads to the console
  */
 public function wps_filter_template_include($template)
 {
     if (isset($this->options['no-templates'])) {
         return $template;
     }
     //
     // Try to work out what the template is
     //
     $want_template = '';
     $got_template = '';
     if (is_404()) {
         $want_template = '404';
     } elseif (is_search()) {
         $want_template = 'Search';
     } elseif (is_tax()) {
         $want_template = 'Taxonomy';
     } elseif (is_front_page()) {
         $want_template = 'Front page';
     } elseif (is_home()) {
         $want_template = 'Home';
     } elseif (is_attachment()) {
         $want_template = 'Attachment';
     } elseif (is_single()) {
         $want_template = 'Single';
     } elseif (is_page()) {
         $want_template = 'Page';
     } elseif (is_category()) {
         $want_template = 'Category';
     } elseif (is_tag()) {
         $want_template = 'Tag';
     } elseif (is_author()) {
         $want_template = 'Author';
     } elseif (is_date()) {
         $want_template = 'Date';
     } elseif (is_archive()) {
         $want_template = 'Archive';
     } elseif (is_comments_popup()) {
         $want_template = 'Comments popup';
     } elseif (is_paged()) {
         $want_template = 'Paged';
     }
     if ($template == get_404_template()) {
         $got_template = '404';
     } elseif ($template == get_search_template()) {
         $got_template = 'Search';
     } elseif ($template == get_taxonomy_template()) {
         $got_template = 'Taxonomy';
     } elseif ($template == get_front_page_template()) {
         $got_template = 'Front page';
     } elseif ($template == get_home_template()) {
         $got_template = 'Home';
     } elseif ($template == get_attachment_template()) {
         $got_template = 'Attachment';
     } elseif ($template == get_single_template()) {
         $got_template = 'Single';
     } elseif ($template == get_page_template()) {
         $got_template = 'Page';
     } elseif ($template == get_category_template()) {
         $got_template = 'Category';
     } elseif ($template == get_tag_template()) {
         $got_template = 'Tag';
     } elseif ($template == get_author_template()) {
         $got_template = 'Author';
     } elseif ($template == get_date_template()) {
         $got_template = 'Date';
     } elseif ($template == get_archive_template()) {
         $got_template = 'Archive';
     } elseif ($template == get_comments_popup_template()) {
         $got_template = 'Comments popup';
     } elseif ($template == get_paged_template()) {
         $got_template = 'Paged';
     } elseif ($template == get_index_template()) {
         $got_template = 'Index';
     } else {
         $got_template = 'Unknown';
     }
     $this->message(Colours::fg('yellow') . "Template load: " . Colours::off() . "wanted {$want_template}, got {$got_template} (" . str_replace($this->options['wp-root'] . "/wp-content/", '', $template) . ")");
     return $template;
 }
     include $template;
     return;
 } else {
     if (is_search() && ($template = get_search_template())) {
         include $template;
         return;
     } else {
         if (is_home() && ($template = get_home_template())) {
             include $template;
             return;
         } else {
             if (is_attachment() && ($template = get_attachment_template())) {
                 include $template;
                 return;
             } else {
                 if (is_single() && ($template = get_single_template())) {
                     if (is_attachment()) {
                         add_filter('the_content', 'prepend_attachment');
                     }
                     include $template;
                     return;
                 } else {
                     if (is_page() && ($template = get_page_template())) {
                         if (is_attachment()) {
                             add_filter('the_content', 'prepend_attachment');
                         }
                         include $template;
                         return;
                     } else {
                         if (is_category() && ($template = get_category_template())) {
                             include $template;
Exemplo n.º 23
0
 private function getContent()
 {
     $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())) {
         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();
     }
     if ($template = apply_filters('template_include', $template)) {
         ob_start();
         include $template;
         $contents = ob_get_contents();
         ob_end_clean();
         return $contents;
     } else {
         return;
     }
 }
Exemplo n.º 24
0
 /**
  * Returns current template
  *
  * @return string
  */
 function get_template()
 {
     static $template = null;
     if ($template === null) {
         switch (true) {
             case is_404() && ($template_file = get_404_template()):
             case is_search() && ($template_file = get_search_template()):
             case is_tax() && ($template_file = get_taxonomy_template()):
             case is_front_page() && function_exists('get_front_page_template') && ($template_file = get_front_page_template()):
             case is_home() && ($template_file = get_home_template()):
             case is_attachment() && ($template_file = get_attachment_template()):
             case is_single() && ($template_file = get_single_template()):
             case is_page() && ($template_file = get_page_template()):
             case is_category() && ($template_file = get_category_template()):
             case is_tag() && ($template_file = get_tag_template()):
             case is_author() && ($template_file = get_author_template()):
             case is_date() && ($template_file = get_date_template()):
             case is_archive() && ($template_file = get_archive_template()):
             case is_comments_popup() && ($template_file = get_comments_popup_template()):
             case is_paged() && ($template_file = get_paged_template()):
                 break;
             default:
                 if (function_exists('get_index_template')) {
                     $template_file = get_index_template();
                 } else {
                     $template_file = 'index.php';
                 }
                 break;
         }
         $template = basename($template_file, '.php');
     }
     return $template;
 }
Exemplo n.º 25
0
function paged_comments_alter_source()
{
    global $wpdb, $post, $comment;
    if (paged_comments()) {
        $file_contents = '';
        $template = '';
        if (is_single()) {
            $template = get_single_template();
        } else {
            if (is_page()) {
                $template = get_page_template();
            }
        }
        if ($template == '' && file_exists(TEMPLATEPATH . '/index.php')) {
            $template = TEMPLATEPATH . '/index.php';
        }
        if ($template) {
            // WP 1.5 doesn't use is_attachment()
            if (function_exists('is_attachment') && is_attachment()) {
                add_filter('the_content', 'prepend_attachment');
            }
            $file_contents = file_get_contents($template);
            // simple check: if call to paged_comments_template() exists, assume all is fine.
            // if it doesn't exist, replace comments_template() with paged_comments_template().
            if (strpos($file_contents, 'paged_comments_template()') === false) {
                extract($GLOBALS, EXTR_SKIP | EXTR_REFS);
                $inc_path = get_include_path();
                set_include_path($inc_path . PATH_SEPARATOR . TEMPLATEPATH);
                $file_contents = str_replace('comments_template()', 'paged_comments_template()', $file_contents);
                //$file_contents = str_replace('<'.'?php','<'.'?',$file_contents);
                eval('?' . '>' . trim($file_contents));
                // I don't think I should be using restore_include_path(), what if other
                // plugins also use set_include_path()? according to php.net
                // restore_include_path restores "back to its original master value as set in php.ini"
                set_include_path($inc_path);
                exit;
            }
        }
    }
}