-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
170 lines (151 loc) · 5.72 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* Theme functions and definitions.
*
* @package HelloIVY
*/
defined( 'ABSPATH') or die('not allowed to access this file' );
/**
* includes here
*/
require_once( get_stylesheet_directory() . '/inc/shortcodes.php' );
require_once( get_stylesheet_directory() . '/inc/utils.php' );
/**
* constant variables here ...
*/
define(
'IVY_STRINGS',
array(
'lang' => 'de',
'online' => 'online',
'onsite' => 'vor Ort',
'current' => 'aktuell',
'upcoming' => 'kommende',
'today' => 'heute',
'noresult' => 'Kein Resultat',
)
);
/**
* enqueues here...
*/
/**
* Load hello child theme css and scripts
* @return void
*/
function ivy_hello_enqueue_scripts()
{
// child theme style.css
wp_enqueue_style( 'ivy-hello-child-style', get_stylesheet_uri(), array( 'ht-theme-style', 'ht-kb' ), filemtime( get_stylesheet_directory() . '/style.css' ), 'all');
// custom registers
wp_register_style( 'ivy-hello-spilde-css', get_stylesheet_directory_uri() . '/node_modules/@splidejs/splide/dist/css/themes/splide-skyblue.min.css' );
wp_register_script( 'ivy-hello-spilde-js', get_stylesheet_directory_uri() . '/node_modules/@splidejs/splide/dist/js/splide.min.js' );
$shortcode_agenda_css_src = '/assets/shortcode-agenda.css';
$shortcode_agenda_js_src = '/assets/shortcode-agenda.js';
wp_register_style( 'ivy-shortcode-agenda-css', get_stylesheet_directory_uri() . $shortcode_agenda_css_src, array(), filemtime( get_stylesheet_directory() . $shortcode_agenda_css_src ), 'all' );
wp_register_script( 'ivy-shortcode-agenda-js', get_stylesheet_directory_uri() . $shortcode_agenda_js_src, array(), filemtime( get_stylesheet_directory() . $shortcode_agenda_js_src ), true );
wp_register_style( 'ivy-sidebar-agenda.css', get_stylesheet_directory_uri() . '/assets/sidebar-agenda.css', array(), filemtime(get_stylesheet_directory() . '/assets/sidebar-agenda.css' ) );
wp_register_script( 'ivy-sidebar-agenda.js', get_stylesheet_directory_uri() . '/assets/sidebar-agenda.js', array(), filemtime(get_stylesheet_directory() . '/assets/sidebar-agenda.js' ), true );
// custom enqueues
if( strpos( $_SERVER['REQUEST_URI'], '/termine-seminare/' ) !== false || strpos( $_SERVER['REQUEST_URI'], '/termine-seminare/kommende/' ) !== false ){ // enqueue for agenda page
wp_enqueue_style( 'ivy-sidebar-agenda.css' );
wp_enqueue_script( 'ivy-sidebar-agenda.js' );
// pass variable from php to js
// wp_localize_script('sidebar-agenda.js', 'WPVARS', array( 'siteurl' => site_url(), 'href' => home_url( $wp->request ) ));
}
global $post;
if( has_shortcode( $post->post_content, 'sd-widget-agenda' ) ){ // enqueue for shortcode [sd-widget-agenda]
wp_enqueue_style( 'ivy-hello-spilde-css' );
wp_enqueue_script( 'ivy-hello-spilde-js' );
wp_enqueue_style( 'ivy-shortcode-agenda-css' );
wp_enqueue_script( 'ivy-shortcode-agenda-js' );
}
}
add_action( 'wp_enqueue_scripts', 'ivy_hello_enqueue_scripts', 20 );
// enable support shortcodes in widgets
add_filter( 'widget_text', 'shortcode_unautop' );
add_filter( 'widget_text', 'do_shortcode' );
add_action( 'widgets_init', 'ivy_register_custom_sidebar' );
// override for agenda page
$lang_code = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '';
if( $lang_code === IVY_STRINGS['lang'] ) {
add_filter('template_include', 'ivy_override_template', 20);
add_filter('template_include', 'ivy_override_query', 20);
}
/**
* Start - Optimization part
*/
/**
* Disable the emoji library from WordPress
* @return void
*/
function hello_sd_disable_emojis()
{
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
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' );
add_filter( 'tiny_mce_plugins', 'hello_sd_disable_emojis_tinymce' );
add_filter( 'wp_resource_hints', 'hello_sd_disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'hello_sd_disable_emojis' );
/**
* Filter function used to remove the tinymce emoji plugin.
*
* @param array $plugins
* @return array Difference between the two arrays
*/
function hello_sd_disable_emojis_tinymce( $plugins )
{
if (is_array( $plugins )) {
return array_diff($plugins, array( 'wpemoji' ));
} else {
return array();
}
}
/**
* Remove emoji CDN hostname from DNS pre-fetching hints.
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed for.
* @return array Difference between the two arrays.
*/
function hello_sd_disable_emojis_remove_dns_prefetch( $urls, $relation_type )
{
if ( 'dns-prefetch' == $relation_type ) {
/** This filter is documented in wp-includes/formatting.php */
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
}
return $urls;
}
/**
* Disable xmlrpc.php
*/
add_filter( 'xmlrpc_enabled', '__return_false' );
/**
* Start - Custom functions by alexis
*/
function hello_ivy_disable_page_title( $return )
{
return false;
}
add_filter( 'hello_elementor_page_title', 'hello_ivy_disable_page_title' );
// if (function_exists( "register_sidebar" )) {
// register_sidebar();
// }
function hello_ivy_js_before_do_header()
{
echo '<div class="site-container">';
}
add_action( 'elementor/theme/before_do_header', 'hello_ivy_js_before_do_header' );
function hello_ivy_js_after_do_footer()
{
echo '</div><!-- .site-container -->';
}
add_action( 'elementor/theme/after_do_footer', 'hello_ivy_js_after_do_footer' );
/**
* End - Custom functions by alexis
*/