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;
         }
     }
 }
Ejemplo n.º 2
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;
    }
}
Ejemplo n.º 3
0
 private static function get_404_template()
 {
     if (!($template = get_404_template())) {
         $template = get_index_template();
     }
     return $template;
 }
 /**
  * Pick the correct template to include
  * @param string $template Path to template
  *
  * @return string Path to template
  */
 public static function templateChooser($template)
 {
     $events = TribeEvents::instance();
     do_action('tribe_tec_template_chooser', $template);
     // hijack this method right up front if it's a 404
     if (is_404() && $events->displaying == 'single-event' && apply_filters('tribe_events_templates_is_404', '__return_true')) {
         return get_404_template();
     }
     // no non-events need apply
     if (!in_array(get_query_var('post_type'), array(TribeEvents::POSTTYPE, TribeEvents::VENUE_POST_TYPE, TribeEvents::ORGANIZER_POST_TYPE)) && !is_tax(TribeEvents::TAXONOMY)) {
         return $template;
     }
     if (tribe_get_option('tribeEventsTemplate', 'default') == '') {
         return self::getTemplateHierarchy('default-template');
     } else {
         // add_filter( 'wp_title', array(__CLASS__, 'remove_default_title'), 1);
         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'));
         }
         return $template;
     }
 }
Ejemplo n.º 5
0
/**
 * Override WP's default index.php template.
 *
 * Because we don't really use index.php, this prevents searching for
 * templates multiple times when trying to load the default template.
 *
 * @since  1.0.0
 * @access public
 * @param  string $template
 * @return string $template
 */
function carelib_index_include($template)
{
    if (get_index_template() === $template) {
        return carelib_framework(apply_filters("{$GLOBALS['carelib_prefix']}_index_template", null));
    }
    return $template;
}
Ejemplo n.º 6
0
 public static function templateChooser($template)
 {
     $events = TribeEvents::instance();
     do_action('tribe_tec_template_chooser', $template);
     // no non-events need apply
     if (get_query_var('post_type') != TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && get_query_var('post_type') != TribeEvents::VENUE_POST_TYPE) {
         return $template;
     }
     //is_home fixer
     global $wp_query;
     $wp_query->is_home = false;
     if (tribe_get_option('tribeEventsTemplate', 'default') == '') {
         if (is_single() && !tribe_is_showing_all()) {
             return TribeEventsTemplates::getTemplateHierarchy('ecp-single-template');
         } else {
             return TribeEventsTemplates::getTemplateHierarchy('ecp-page-template');
         }
     } else {
         // we need to ensure that we always enter the loop, whether or not there are any events in the actual query
         self::spoofQuery();
         add_filter('wp_title', array(__CLASS__, 'remove_default_title'), 1);
         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'));
         }
         return $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;
 }
Ejemplo n.º 8
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;
 }
 /**
  * Pick the correct template to include
  * @param string $template Path to template
  *
  * @return string Path to template
  */
 public static function templateChooser($template)
 {
     $events = TribeEvents::instance();
     do_action('tribe_tec_template_chooser', $template);
     // hijack this method right up front if it's a 404
     if (is_404() && $events->displaying == 'single-event') {
         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'));
     // no non-events need apply
     // @todo check $wp_query->tribe_is_event_query instead?
     if (in_array(get_query_var('post_type'), array(TribeEvents::POSTTYPE, TribeEvents::VENUE_POST_TYPE, TribeEvents::ORGANIZER_POST_TYPE)) || is_tax(TribeEvents::TAXONOMY)) {
         // 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');
         }
     }
     self::$template = $template;
     return $template;
 }
Ejemplo n.º 11
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);
 }
function mfields_locate_custom_template()
{
    global $wp_post_types, $wp;
    if (is_404()) {
        if (array_key_exists($wp->request, $wp_post_types)) {
            $file = STYLESHEETPATH . '/' . $wp->request . '-multiple.php';
            $file = file_exists($file) ? $file : get_index_template();
            return $file;
        }
    }
    return false;
}
Ejemplo n.º 13
0
 /**
  * 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)) {
         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');
     }
     self::$template = $template;
     return $template;
 }
Ejemplo n.º 14
0
/**
 * Set the template to use, buffers the needed template parts
 * and resets post vars.
 *
 * @package WP Idea Stream
 * @subpackage core/template-loader
 *
 * @since 2.0.0
 *
 * @global $wp_query
 * @param  string $template name of the template to use
 * @uses   is_buddypress() to bail early if it's this plugin's territory
 * @uses   wp_idea_stream_get_idea_var() to get a globalized var
 * @uses   is_404() to check for a 404
 * @uses   get_query_template() to get a specific template
 * @uses   get_index_template() to get the index template
 * @uses   wp_idea_stream_set_idea_var() to set a globalized var
 * @uses   is_post_type_archive() to check if it's ideas post type archive
 * @uses   wp_idea_stream_get_post_type() to get ideas post type identifier
 * @uses   set_query_var() to get a query var
 * @uses   remove_all_filters() to remove all filters on a specific hook
 * @uses   wp_idea_stream_reset_post() to reset WordPress $post global and avoid notices
 * @uses   wp_idea_stream_reset_post_title() to reset the title depending on the context
 * @uses   wp_idea_stream_buffer_template_part() to buffer the content to display
 * @uses   wp_idea_stream_is_edit() to check if the idea is to be edited
 * @uses   wp_idea_stream_ideas_lock_idea() to check if the idea to edit is not currently edited by another user
 * @uses   wp_idea_stream_add_message() to give a user some feedback
 * @uses   wp_idea_stream_ideas_can_edit() to check current user can edit an idea
 * @uses   wp_safe_redirect() to safely redirect the user
 * @uses   wp_idea_stream_get_redirect_url() to get the default redirect url
 * @uses   wp_idea_stream_buffer_single_idea() to buffer the idea content to display
 * @uses   do_action() Calls 'wp_idea_stream_set_core_template' to perform actions once a core template is set
 *                     Calls 'wp_idea_stream_set_single_template' to perform actions relative to the single idea template
 *                     Calls 'wp_idea_stream_set_template' to perform actions when no template matched
 * @uses   apply_filters() Calls 'wp_idea_stream_template_args' to override template args in case of custom idea action
 *                         Calls 'wp_idea_stream_single_template_args' to override single template args
 * @return string $template.
 */
function wp_idea_stream_set_template($template = '')
{
    global $wp_query;
    /**
     * Bail if BuddyPress, we'll use its theme compatibility
     * feature.
     */
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $template;
    }
    if (wp_idea_stream_get_idea_var('is_ideastream') && !is_404()) {
        // Try to see if the theme has a specific template for WP Idea Stream
        $template = get_query_template('ideastream');
        if (empty($template)) {
            // else Try the page template
            $template = get_query_template('page', array('page.php'));
        }
        if (empty($template)) {
            // finally fall back to the index template
            $template = get_index_template();
        }
        // Define it into plugin's vars
        wp_idea_stream_set_idea_var('template_file', $template);
        /**
         * First get results of the main query if not on a single idea.
         * and build plugin's main_query var.
         */
        if (!wp_idea_stream_is_single_idea()) {
            wp_idea_stream_set_idea_var('main_query', array('ideas' => $wp_query->posts, 'total' => $wp_query->found_posts, 'query_vars' => array('author' => $wp_query->query_vars['author'], 'per_page' => $wp_query->query_vars['posts_per_page'], 'page' => !empty($wp_query->query_vars['paged']) ? $wp_query->query_vars['paged'] : 1, 'search' => $wp_query->query_vars['s'], 'exclude' => $wp_query->query_vars['post__not_in'], 'include' => $wp_query->query_vars['post__in'], 'orderby' => !empty($wp_query->query_vars['orderby']) ? $wp_query->query_vars['orderby'] : 'date', 'order' => $wp_query->query_vars['order'], 'meta_query' => $wp_query->meta_query->queries, 'tax_query' => $wp_query->tax_query->queries)));
            // Resetting the 's' query var now we got main query's result.
            set_query_var('s', '');
            // Init template args
            $template_args = array('post_title' => '', 'comment_status' => 'closed', 'is_archive' => true, 'is_tax' => false, 'template_slug' => 'archive', 'template_name' => '', 'context' => '');
            // Main plugin's archive page
            if (is_post_type_archive(wp_idea_stream_get_post_type())) {
                $template_args['context'] = 'archive';
            }
            // Category / tag archive pages
            if (wp_idea_stream_get_idea_var('is_category') || wp_idea_stream_get_idea_var('is_tag')) {
                $template_args['is_tax'] = true;
                $template_args['context'] = 'taxonomy';
            }
            // User's profile pages
            if (wp_idea_stream_get_idea_var('is_user')) {
                $template_args['template_slug'] = 'user';
                $template_args['template_name'] = 'profile';
                $template_args['context'] = 'user-profile';
            }
            if (wp_idea_stream_get_idea_var('is_action')) {
                $template_args['is_archive'] = false;
                // New idea form
                if (wp_idea_stream_is_addnew()) {
                    $template_args['template_slug'] = 'idea';
                    $template_args['template_name'] = 'form';
                    $template_args['context'] = 'new-idea';
                } else {
                    if (wp_idea_stream_is_signup()) {
                        $template_args['template_slug'] = 'signup';
                        $template_args['context'] = 'signup';
                        // Allow plugins to add custom action
                    } else {
                        if (has_filter('wp_idea_stream_template_args')) {
                            /**
                             * Custom action ?
                             *
                             * @param array $template_args the template arguments used to reset the post
                             */
                            $template_args = apply_filters('wp_idea_stream_template_args', $template_args);
                        }
                    }
                }
            }
            // Reset WordPress $post global.
            wp_idea_stream_reset_post(array('ID' => 0, 'post_title' => wp_idea_stream_reset_post_title($template_args['context']), 'post_author' => 0, 'post_date' => 0, 'post_type' => 'ideas', 'post_status' => 'publish', 'is_archive' => $template_args['is_archive'], 'comment_status' => $template_args['comment_status'], 'post_password' => false, 'is_tax' => $template_args['is_tax']));
            /**
             * Internally used to redirect to BuddyPress member's profile
             * if needed
             *
             * @param  string $context to help choosing the best template to use
             */
            do_action('wp_idea_stream_set_core_template', $template_args['context'], $template_args);
        } else {
            $query_loop = new stdClass();
            $query_loop->idea = $wp_query->post;
            // Should we use a custom template for single ideas ?
            $specific_single_template = get_query_template('single-ideastream');
            if (!empty($specific_single_template)) {
                $template = $specific_single_template;
            }
            // Populate the global query loop with current idea
            wp_idea_stream_set_idea_var('query_loop', $query_loop);
            // Add the id to globals
            wp_idea_stream_set_idea_var('single_idea_id', $wp_query->post->ID);
            // Are we editing an idea ?
            if (wp_idea_stream_is_edit()) {
                // Check if the idea is currently being edited by someone else
                $user_is_editing = wp_idea_stream_ideas_lock_idea($query_loop->idea->ID);
                if (!empty($user_is_editing)) {
                    wp_idea_stream_add_message(array('type' => 'info', 'content' => sprintf(__('The idea: "%s" is already being edited by another user.', 'wp-idea-stream'), $query_loop->idea->post_title)));
                    // Redirect the user
                    wp_safe_redirect(wp_idea_stream_get_redirect_url());
                    exit;
                }
                // Bail if user can't edit the idea
                if (!wp_idea_stream_ideas_can_edit($query_loop->idea)) {
                    wp_idea_stream_add_message(array('type' => 'error', 'content' => __('You are not allowed to edit this idea.', 'wp-idea-stream')));
                    // Redirect the user
                    wp_safe_redirect(wp_idea_stream_get_redirect_url());
                    exit;
                }
                // Inform the idea is to display in an edit form
                $query_loop->idea->is_edit = true;
                $template_args = array('template_slug' => 'idea', 'template_name' => 'form', 'context' => 'edit-idea');
                $single_args = array('ID' => 0, 'post_title' => wp_idea_stream_reset_post_title($template_args['context']), 'post_author' => 0, 'post_date' => 0, 'post_type' => 'ideas', 'post_status' => 'publish', 'is_archive' => false, 'comment_status' => false, 'post_password' => false);
                // Or simply viewing one ?
            } else {
                $template_args = array('context' => 'single-idea');
                $single_args = array('is_single' => true);
            }
            /**
             * @param array $single_args the single arguments used to reset the post
             */
            wp_idea_stream_reset_post(apply_filters('wp_idea_stream_single_template_args', $single_args));
            /**
             * Internally used to redirect to Buddypress Group's
             * single idea template if needed
             *
             * @param  WP_Post $query_loop->idea the idea to display
             */
            do_action('wp_idea_stream_set_single_template', $query_loop->idea, $template_args);
        }
    }
    /**
     * No IdeaStream template matched
     */
    do_action('wp_idea_stream_set_template');
    return $template;
}
Ejemplo n.º 15
0
function wpsc_all_products_on_page()
{
    if (is_404()) {
        return;
    }
    global $wp_query, $wpsc_query;
    do_action('wpsc_swap_the_template');
    $products_page_id = wpsc_get_the_post_id_by_shortcode('[productspage]');
    $term = get_query_var('wpsc_product_category');
    $tax_term = get_query_var('product_tag');
    $obj = $wp_query->get_queried_object();
    $id = isset($obj->ID) ? $obj->ID : null;
    if (get_query_var('post_type') == 'wpsc-product' || $term || $tax_term || $id == $products_page_id) {
        $templates = array();
        if ($term && !is_single()) {
            array_push($templates, "taxonomy-wpsc_product_category-{$term}.php", 'taxonomy-wpsc_product_category.php');
        }
        if ($tax_term && !is_single()) {
            array_push($templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php');
        }
        // Attempt to use the [productspage]'s custom page template as a higher priority than the normal page.php template
        if (false !== ($productspage_page_template = get_post_meta($products_page_id, '_wp_page_template', true))) {
            array_push($templates, $productspage_page_template);
        }
        array_push($templates, 'page.php', 'single.php');
        if (is_single()) {
            array_unshift($templates, 'single-wpsc-product.php');
        }
        // have to pass 'page' as the template type. This is lame, btw, and needs a rewrite in 4.0
        if (!($template = get_query_template('page', $templates))) {
            $template = get_index_template();
        }
        add_filter('thesis_custom_loop', 'wpsc_thesis_compat');
        include $template;
        exit;
    }
}
Ejemplo n.º 16
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;
     }
 }
Ejemplo n.º 17
0
 /**
  * Rewrite all scripts to index.php of the theme
  *
  * @param string $template Template that is being loaded.
  *
  * @return mixed
  */
 public static function template_include_override($template)
 {
     /**
      * Only apply if theme uses Stencil
      */
     $theme = Stencil_Environment::filter('require', false);
     if (false !== $theme) {
         /**
          * Make it optional with default disabled
          */
         $force = Stencil_Environment::filter('template_index_only', false);
         if ($force) {
             return get_index_template();
         }
     }
     return $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;
 }
Ejemplo n.º 19
0
    } 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)) {
        include $template;
    }
    return;
}
 static function aiowps_set_404()
 {
     global $wp_query;
     do_action('aiopws_before_set_404');
     //This hook is for themes which produce a fatal error when the rename login feature is enabled and someone visits "wp-admin" slug directly
     status_header(404);
     $wp_query->set_404();
     if ((($template = get_404_template()) || ($template = get_index_template())) && ($template = apply_filters('template_include', $template))) {
         include $template;
     }
     die;
 }
 static function aiowps_set_404()
 {
     global $wp_query;
     status_header(404);
     $wp_query->set_404();
     if ((($template = get_404_template()) || ($template = get_index_template())) && ($template = apply_filters('template_include', $template))) {
         include $template;
     }
     die;
 }
Ejemplo n.º 22
0
 function redirect_retired()
 {
     global $wp_query;
     if (is_singular()) {
         if ('fwpretired' == $wp_query->post->post_status) {
             do_action('feedwordpress_redirect_retired', $wp_query->post);
             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;
         }
     }
 }
Ejemplo n.º 23
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;
     }
 }
Ejemplo n.º 24
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;
 }
Ejemplo n.º 25
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;
 }
Ejemplo n.º 26
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;
}