-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
76 lines (59 loc) · 2.24 KB
/
functions.php
File metadata and controls
76 lines (59 loc) · 2.24 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
<?php
// Theme setup
function theme_setup() {
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
register_nav_menus(array(
'primary' => __('Primary Menu', 'THEMENAME'),
));
}
add_action('after_setup_theme', 'theme_setup');
// Enqueue styles and scripts
function theme_scripts() {
wp_enqueue_style('style', get_template_directory_uri() . '/assets/css/style.css');
wp_enqueue_script('scripts', get_template_directory_uri() . '/assets/js/scripts.js', array(), false, true);
}
add_action('wp_enqueue_scripts', 'theme_scripts');
// Disable Emoji support
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
// Disable Gutenberg Block Library CSS
function theme_remove_wp_block_library_css() {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('global-styles');
}
add_action('wp_enqueue_scripts', 'theme_remove_wp_block_library_css', 100);
// Disable Classic Theme Styles
function theme_remove_classic_theme_styles() {
wp_dequeue_style('classic-theme-styles');
}
add_action('wp_enqueue_scripts', 'theme_remove_classic_theme_styles', 100);
// Remove RSD link
remove_action('wp_head', 'rsd_link');
// Remove WordPress version meta tag
remove_action('wp_head', 'wp_generator');
// Load custom templates from the 'pages' folder
function theme_page_templates($template) {
global $post;
if ($post) {
$template_name = get_post_meta($post->ID, '_wp_page_template', true);
if ($template_name && $template_name !== 'default') {
$template_path = get_template_directory() . '/pages/' . $template_name;
if (file_exists($template_path)) {
return $template_path;
}
}
}
return $template;
}
add_filter('template_include', 'theme_page_templates');
// Helper function for directories
function images($path = '') {
return get_template_directory_uri() . '/media/images/' . ltrim($path, '/');
}