-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
121 lines (105 loc) · 3.9 KB
/
functions.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
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
<?php
/**
* Theme Name: Spokojna Głowa
* Author: Szymon Rączka
* Description: A minimalist WordPress theme designed for the Spokojna Głowa website.
* Version: 1.0
*/
// Remove unnecessary scripts and meta tags from wp_head
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
// Remove default WordPress styles
add_action( 'wp_print_styles', 'remove_block_css' );
function remove_block_css() {
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wp-block-library-css' );
}
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_classic_theme_styles' );
// Remove WordPress version numbers
add_filter('the_generator', 'remove_version');
function remove_version() {
return '';
}
add_filter('the_generator', 'remove_version_from_rss');
function remove_version_from_rss() {
return '';
}
add_filter('style_loader_src', 'remove_version_from_scripts_and_styles', 9999);
add_filter('script_loader_src', 'remove_version_from_scripts_and_styles', 9999);
function remove_version_from_scripts_and_styles($src) {
if (strpos($src, 'ver=')) {
$src = remove_query_arg('ver', $src);
}
return $src;
}
// Add custom styles
add_action('wp_enqueue_scripts', 'enqueue_my_style');
function enqueue_my_style() {
wp_enqueue_style('my-style', get_template_directory_uri() . '/style.css');
}
add_theme_support( 'title-tag' );
// Generate breadcrumb structured data
add_action('wp_head', 'generate_breadcrumb_structured_data');
function generate_breadcrumb_structured_data() {
// Get the post type
$post_type = get_post_type();
$post_type_object = !empty($post_type) ? get_post_type_object($post_type) : null;
$post_type_archive = !empty($post_type) ? get_post_type_archive_link($post_type) : '';
// Get the post title
$post_title = get_the_title();
// Get the post author
$author_id = get_the_author_meta('ID');
$author_name = get_the_author_meta('display_name');
$author_link = get_author_posts_url($author_id);
// Construct the breadcrumb
$breadcrumb = array(
"@context" => "https://schema.org",
"@type" => "BreadcrumbList",
"itemListElement" => array(
array(
"@type" => "ListItem",
"position" => 1,
"name" => "Spokojna Głowa",
"item" => get_home_url()
),
array(
"@type" => "ListItem",
"position" => 2,
"name" => $post_type_object ? $post_type_object->labels->name : '',
"item" => $post_type_archive
),
array(
"@type" => "ListItem",
"position" => 3,
"name" => $author_name,
"item" => $author_link
),
array(
"@type" => "ListItem",
"position" => 4,
"name" => $post_title,
"item" => get_permalink()
)
)
);
// Encode the breadcrumb in JSON-LD format
$breadcrumb_json = json_encode($breadcrumb);
// Output the breadcrumb structured data
echo '<script type="application/ld+json">' . $breadcrumb_json . '</script>';
}
// Change author base
add_action('init', 'custom_author_base');
function custom_author_base() {
global $wp_rewrite;
$author_slug = 'autorzy'; // change 'profile' to whatever you want the slug to be
$wp_rewrite->author_base = $author_slug;
}