-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
127 lines (110 loc) · 3.14 KB
/
Copy pathfunctions.php
File metadata and controls
127 lines (110 loc) · 3.14 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* SystemPress Functions File
* @package SystemPress
* @author G.L. Walker
* @since 0.0.1
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*/
declare(strict_types=1);
// Exit if accessed directly.
defined('ABSPATH') || exit;
//define('SP_LOAD_BOOTSTRAP_STYLESHEETS', true);
//define('SP_LOAD_BOOTSTRAP_JAVASCRIPTS', true);
define('SYSTEMPRESS_DEBUG_ASSETS', false);
/**
* Ensure WordPress version is 6.7 or greater.
*/
function systempress_check_wp_version(): void
{
global $wp_version;
$required_wp_version = '6.7';
if (version_compare($wp_version, $required_wp_version, '<')) {
// Switch to default theme.
switch_theme(WP_DEFAULT_THEME);
// Display admin notice.
add_action('admin_notices', function () use ($required_wp_version): void {
?>
<div class="notice notice-error">
<p>
<?php
echo sprintf(
esc_html__('SystemPress requires WordPress version %s or greater. The theme has been deactivated.', 'systempress'),
esc_html($required_wp_version)
);
?>
</p>
</div>
<?php
});
// Stop further execution.
return;
}
}
add_action('after_switch_theme', 'systempress_check_wp_version');
/**
* Load SystemPress files dynamically.
*/
add_action('after_setup_theme', 'sp_load_files', 0);
function sp_load_files(): void
{
$includes_directory = get_template_directory() . '/inc/';
$files = [
'theme-functions',
'enqueue-assets',
'block-filters',
'block-replacements',
'block-styles',
'dynamic-assets',
'class-css',
'class-color-palette',
'css-output',
'carousel',
'dark-mode',
'off-canvas',
'search-modal',
'social-icon-filters',
];
foreach ($files as $file) {
$file_path = $includes_directory . $file . '.php';
if (file_exists($file_path)) {
require_once $file_path;
}
}
}
/**
* Example hook output.
*/
add_action('sp_hook_example', 'sp_hook_example_content', 10);
function sp_hook_example_content(): void
{
echo <<<HTML
<div class="card h-100 bg-primary">
<div class="card-body">
<h3 class="h5 card-title">Template Hooks</h3>
<p class="card-text">
SystemPress comes loaded with several action hooks strategically
placed throughout the theme.
</p>
<p class="card-text">
Use the block editor to add new hooks where you need by selecting
the SP Action Hook block.<br>
<strong>In fact</strong>, this card was added with a hook.
</p>
</div>
</div>
HTML;
}
/**
* Load development file.
*/
function sp_dev_file(): void
{
$dev_file = get_template_directory() . '/dev.php';
if (file_exists($dev_file)) {
require_once $dev_file;
}
}
if (defined('SYSTEMPRESS_DEBUG_ASSETS') && SYSTEMPRESS_DEBUG_ASSETS) {
add_action('after_setup_theme', 'sp_dev_file', 0);
}