You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

83 lines
2.8 KiB

  1. <?php
  2. /**
  3. * Loads the correct template based on the visitor's url
  4. * @package WordPress
  5. */
  6. if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
  7. /**
  8. * Fires before determining which template to load.
  9. *
  10. * @since 1.5.0
  11. */
  12. do_action( 'template_redirect' );
  13. /**
  14. * Filters whether to allow 'HEAD' requests to generate content.
  15. *
  16. * Provides a significant performance bump by exiting before the page
  17. * content loads for 'HEAD' requests. See #14348.
  18. *
  19. * @since 3.5.0
  20. *
  21. * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
  22. */
  23. if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) )
  24. exit();
  25. // Process feeds and trackbacks even if not using themes.
  26. if ( is_robots() ) :
  27. /**
  28. * Fired when the template loader determines a robots.txt request.
  29. *
  30. * @since 2.1.0
  31. */
  32. do_action( 'do_robots' );
  33. return;
  34. elseif ( is_feed() ) :
  35. do_feed();
  36. return;
  37. elseif ( is_trackback() ) :
  38. include( ABSPATH . 'wp-trackback.php' );
  39. return;
  40. endif;
  41. if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
  42. $template = false;
  43. if ( is_embed() && $template = get_embed_template() ) :
  44. elseif ( is_404() && $template = get_404_template() ) :
  45. elseif ( is_search() && $template = get_search_template() ) :
  46. elseif ( is_front_page() && $template = get_front_page_template() ) :
  47. elseif ( is_home() && $template = get_home_template() ) :
  48. elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
  49. elseif ( is_tax() && $template = get_taxonomy_template() ) :
  50. elseif ( is_attachment() && $template = get_attachment_template() ) :
  51. remove_filter('the_content', 'prepend_attachment');
  52. elseif ( is_single() && $template = get_single_template() ) :
  53. elseif ( is_page() && $template = get_page_template() ) :
  54. elseif ( is_singular() && $template = get_singular_template() ) :
  55. elseif ( is_category() && $template = get_category_template() ) :
  56. elseif ( is_tag() && $template = get_tag_template() ) :
  57. elseif ( is_author() && $template = get_author_template() ) :
  58. elseif ( is_date() && $template = get_date_template() ) :
  59. elseif ( is_archive() && $template = get_archive_template() ) :
  60. else :
  61. $template = get_index_template();
  62. endif;
  63. /**
  64. * Filters the path of the current template before including it.
  65. *
  66. * @since 3.0.0
  67. *
  68. * @param string $template The path of the template to include.
  69. */
  70. if ( $template = apply_filters( 'template_include', $template ) ) {
  71. include( $template );
  72. } elseif ( current_user_can( 'switch_themes' ) ) {
  73. $theme = wp_get_theme();
  74. if ( $theme->errors() ) {
  75. wp_die( $theme->errors() );
  76. }
  77. }
  78. return;
  79. endif;