Issues (76)

inc/baseStyle.php (1 issue)

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 setDocumentTitle()
23
{
24
    // prevent yoast overwriting the title
25
    add_filter('pre_get_document_title', function ($title) {
0 ignored issues
show
The parameter $title is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    add_filter('pre_get_document_title', function (/** @scrutinizer ignore-unused */ $title) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
        return '';
27
    }, 99);
28
29
    // set custom title and keep the default separator and site name
30
    add_filter('document_title_parts', function ($title) {
31
        $title['title'] = 'Base Style';
32
        return $title;
33
    }, 99);
34
}
35
36
function templateInclude($template)
37
{
38
    global $wp_query;
39
40
    if (isset($wp_query->query_vars[ROUTENAME])) {
41
        setDocumentTitle();
42
        add_filter('wp_robots', 'wp_robots_no_robots');
43
        return get_template_directory() . '/basestyle.php';
44
    }
45
46
    return $template;
47
}
48