-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnamespace.php
87 lines (71 loc) · 1.6 KB
/
namespace.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Figuren_Theater Routes.
*
* @package figuren-theater/ft-routes
*/
namespace Figuren_Theater\Routes;
use Altis;
use function add_action;
use function apply_filters;
/**
* Register module.
*/
function register() {
$default_settings = [
'enabled' => true, // Needs to be set.
];
$options = [
'defaults' => $default_settings,
];
Altis\register_module(
'routes',
DIRECTORY,
'Routes',
$options,
__NAMESPACE__ . '\\bootstrap'
);
}
/**
* Bootstrap module, when enabled.
*/
function bootstrap() {
add_action( 'init', __NAMESPACE__ . '\\set_rewrite_bases', 0 );
// Plugins.
Mercator\bootstrap();
// Best practices.
Disable_Public_JSON_REST_API\bootstrap();
// Network_Site_Url_Fix\bootstrap(); // DISABLED for being done by the .htaccess.
Noblogredirect_Fix\bootstrap();
Virtual_Uploads\bootstrap();
}
/**
* [set_rewrite_base description]
*
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*/
function set_rewrite_bases() : void {
/**
* Replace default rewrite bases esp. for german-speaking websites.
*
* @param array<string, string> Rewrite key and human-readable rewrite replacement.
*/
$ft_rr = apply_filters(
__NAMESPACE__ . '\\rewrite_bases',
[
'author_base' => 'von',
'search_base' => 'suche',
'pagination_base' => 'seite',
'comments_base' => 'kommentare',
'comments_pagination_base' => 'kommentar-seite',
]
);
array_map(
function( $rr_prop, $ft_rr_value ) : void {
global $wp_rewrite;
$wp_rewrite->$rr_prop = $ft_rr_value;
},
array_keys( $ft_rr ),
$ft_rr
);
}