Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | function auto_load_next_post_template_redirect() { |
||
27 | global $wp_query; |
||
28 | |||
29 | // if this is not a request for partial or a singular object then bail |
||
30 | if ( ! isset($wp_query->query_vars['partial']) || ! is_singular()) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Load the template file from theme if one exists. |
||
36 | * If theme does not have a template file, load default from the plugin. |
||
37 | */ |
||
38 | $template_path = get_stylesheet_directory().'/'.AUTO_LOAD_NEXT_POST_TEMPLATE_PATH; |
||
39 | $default_path = AUTO_LOAD_NEXT_POST_FILE_PATH; |
||
40 | |||
41 | if (file_exists($template_path.'content-partial.php')) { |
||
42 | include($template_path.'content-partial.php'); |
||
43 | } else if (file_exists($default_path.'/template/content-partial.php')) { |
||
44 | include($default_path.'/template/content-partial.php'); |
||
45 | } |
||
46 | |||
47 | exit; |
||
48 | } |
||
49 | add_action('template_redirect', 'auto_load_next_post_template_redirect'); |
||
50 |