Completed
Pull Request — master (#191)
by
unknown
03:36
created

disallowRobots()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * Loads the `basestyle.php` template on route /BaseStyle/ to render base style markup for proper base styling.
5
 */
6
7
namespace Flynt\BaseStyle;
8
9
add_filter('init', 'Flynt\BaseStyle\registerRewriteRule');
10
add_filter('template_include', 'Flynt\BaseStyle\templateInclude');
11
12
const ROUTENAME = 'BaseStyle';
13
14
function registerRewriteRule()
15
{
16
    $routeName = ROUTENAME;
17
18
    add_rewrite_rule("{$routeName}/?$", "index.php?{$routeName}", "top");
19
    add_rewrite_tag("%{$routeName}%", "([^&]+)");
20
}
21
22
function templateInclude($template)
23
{
24
    global $wp_query;
25
26
    if (isset($wp_query->query_vars[ROUTENAME])) {
27
        add_action('wp_head', 'wp_no_robots');
28
        return get_template_directory() . '/basestyle.php';
29
    }
30
31
    return $template;
32
}
33