-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
142 lines (136 loc) · 5.49 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
add_action('after_setup_theme', 'blankslate_setup');
function blankslate_setup()
{
load_theme_textdomain('blankslate', get_template_directory() . '/languages');
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('responsive-embeds');
add_theme_support('automatic-feed-links');
add_theme_support('html5', ['navigation-widgets','comment-list']);
add_theme_support('woocommerce');
global $content_width;
if (!isset($content_width)) {
$content_width = 1920;
}
register_nav_menus(['main-menu' => esc_html__('Main Menu', 'blankslate'), 'mobile-menu' => esc_html__('Mobile Menu', 'blankslate')]);
}
add_action('admin_notices', 'blankslate_notice');
function blankslate_notice()
{
$user_id = get_current_user_id();
$admin_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$param = (count($_GET)) ? '&' : '?';
if (!get_user_meta($user_id, 'blankslate_notice_dismissed_8') && current_user_can('manage_options')) {
echo '<div class="notice notice-info"><p><a href="' . esc_url($admin_url), esc_html($param) . 'dismiss" class="alignright" style="text-decoration:none"><big>' . esc_html__('Ⓧ', 'blankslate') . '</big></a>' . wp_kses_post(__('<big><strong>📝 Thank you for using BlankSlate!</strong></big>', 'blankslate')) . '<br /><br /><a href="https://wordpress.org/support/theme/blankslate/reviews/#new-post" class="button-primary" target="_blank">' . esc_html__('Review', 'blankslate') . '</a> <a href="https://github.com/tidythemes/blankslate/issues" class="button-primary" target="_blank">' . esc_html__('Feature Requests & Support', 'blankslate') . '</a> <a href="https://calmestghost.com/donate" class="button-primary" target="_blank">' . esc_html__('Donate', 'blankslate') . '</a></p></div>';
}
}
add_action('admin_init', 'blankslate_notice_dismissed');
function blankslate_notice_dismissed()
{
$user_id = get_current_user_id();
if (isset($_GET['dismiss'])) {
add_user_meta($user_id, 'blankslate_notice_dismissed_8', 'true', true);
}
}
add_action('wp_enqueue_scripts', 'blankslate_enqueue');
function blankslate_enqueue()
{
wp_enqueue_style('style', get_template_directory_uri() . '/assets/css/styles.css');
/**If you have some custom JavaScript and it to /assets/dev/app.js and uncomment the lines below */
// wp_enqueue_script('index', get_template_directory_uri() . '/assets/js/app.js', '', false, true);
// wp_enqueue_script('jquery');
}
add_filter('document_title_separator', 'blankslate_document_title_separator');
function blankslate_document_title_separator($sep)
{
$sep = esc_html('|');
return $sep;
}
add_filter('the_title', 'blankslate_title');
function blankslate_title($title)
{
if ($title == '') {
return esc_html('...');
} else {
return wp_kses_post($title);
}
}
function blankslate_schema_type()
{
$schema = 'https://schema.org/';
if (is_single()) {
$type = 'Article';
} elseif (is_author()) {
$type = 'ProfilePage';
} elseif (is_search()) {
$type = 'SearchResultsPage';
} else {
$type = 'WebPage';
}
echo 'itemscope itemtype="' . esc_url($schema) . esc_attr($type) . '"';
}
add_filter('nav_menu_link_attributes', 'blankslate_schema_url', 10);
function blankslate_schema_url($atts)
{
$atts['itemprop'] = 'url';
return $atts;
}
if (!function_exists('blankslate_wp_body_open')) {
function blankslate_wp_body_open()
{
do_action('wp_body_open');
}
}
add_action('wp_body_open', 'blankslate_skip_link', 5);
function blankslate_skip_link()
{
echo '<a href="#content" class="skip-link screen-reader-text">' . esc_html__('Skip to the content', 'blankslate') . '</a>';
}
add_filter('the_content_more_link', 'blankslate_read_more_link');
function blankslate_read_more_link()
{
if (!is_admin()) {
return ' <a href="' . esc_url(get_permalink()) . '" class="more-link">' . sprintf(__('...%s', 'blankslate'), '<span class="screen-reader-text"> ' . esc_html(get_the_title()) . '</span>') . '</a>';
}
}
add_filter('excerpt_more', 'blankslate_excerpt_read_more_link');
function blankslate_excerpt_read_more_link($more)
{
if (!is_admin()) {
global $post;
return ' <a href="' . esc_url(get_permalink($post->ID)) . '" class="more-link">' . sprintf(__('...%s', 'blankslate'), '<span class="screen-reader-text"> ' . esc_html(get_the_title()) . '</span>') . '</a>';
}
}
add_filter('big_image_size_threshold', '__return_false');
add_filter('intermediate_image_sizes_advanced', 'blankslate_image_insert_override');
function blankslate_image_insert_override($sizes)
{
unset($sizes['medium_large']);
unset($sizes['1536x1536']);
unset($sizes['2048x2048']);
return $sizes;
}
add_action('widgets_init', 'blankslate_widgets_init');
function blankslate_widgets_init()
{
register_sidebar([
'name' => esc_html__('Sidebar Widget Area', 'blankslate'),
'id' => 'primary-widget-area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
]);
}
add_action('comment_form_before', 'blankslate_enqueue_comment_reply_script');
function blankslate_enqueue_comment_reply_script()
{
if (get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
/*
* Custom Functions.
*/
get_template_part('/inc/custom-functions');