-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
125 lines (88 loc) · 3.53 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
<?php
/* ------------------------------ CONSTANTS ------------------------------ */
// defines admin login names
define( 'ADMINS', array( 'digis', 'laita', 'webpunk' ) );
// defines current user's login name
$current_user = wp_get_current_user();
define( 'CURRENT_USER', $current_user->user_login );
/* ------------------------------ GENERAL ------------------------------ */
// custom settings for administration
require_once __DIR__ . '/inc/webpunk/admin.php';
// custom shortcodes
require_once __DIR__ . '/inc/webpunk/shortcodes.php';
// custom theme functions
require_once __DIR__ . '/inc/webpunk/theme.php';
// functions for Front-End
require_once __DIR__ . '/inc/webpunk/front-end.php';
/* ------------------------------ THEMES & BUILDERS ------------------------------ */
// general settings for blocks
//require_once __DIR__ . '/inc/webpunk/gutenberg.php';
// custom settings for Astra
require_once __DIR__ . '/inc/webpunk/astra.php';
/* ------------------------------ PLUGIN FUNCTIONS ------------------------------ */
/* --- RANK MATH --- */
// changes breadcrumbs template
if ( function_exists( 'rank_math_the_breadcrumbs' ) ) {
add_filter( 'rank_math/frontend/breadcrumb/args', function( $args ) {
$args = array(
'delimiter' => ' / ',
'wrap_before' => '<nav class="breadcrumbs" role="navigation" aria-label="Breadcrumbs navigation">',
'wrap_after' => '</nav>',
'before' => '',
'after' => '',
);
return $args;
});
}
/* --- WPML --- */
// checks if WPML plugin exist
function webpunk_is_wpml_active()
{
$is_wpml_active = class_exists( 'SitePress' );
$is_wpml_configured = apply_filters( 'wpml_setting', false, 'setup_complete' );
return ( $is_wpml_active && $is_wpml_configured );
}
// edits of WPML properties
if ( webpunk_is_wpml_active() ) {
// adds language code to body class
add_filter( 'body_class', 'webpunk_append_language_class' );
function webpunk_append_language_class( $classes ) {
$classes[] = "web-lang-" . esc_attr( apply_filters( 'wpml_current_language', NULL ) );
return $classes;
}
// removes WPML styles and scripts
define( 'ICL_DONT_LOAD_NAVIGATION_CSS', true );
define( 'ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true );
define( 'ICL_DONT_LOAD_LANGUAGES_JS', true );
// removes meta generator
remove_action( 'wp_head', array( $sitepress, 'meta_generator_tag' ) );
}
/* --- AUTO CLOUDINARY --- */
// checks if the Auto Cloudinary plugin exists
if ( function_exists( 'cloudinary_url' ) ) {
// adds specific parameters for cloudinary URLs
add_filter( 'cloudinary_default_args', function( $args ) {
$args['transform']['quality'] = 'auto:eco';
$args['transform']['fetch_format'] = 'auto';
return $args;
} );
// adds preconnect for cloudinary URL
add_action( 'wp_head', 'webpunk_dns_preconnect', 0 );
function webpunk_dns_preconnect() {
echo '<link href="https://res.cloudinary.com" rel="preconnect" crossorigin>';
}
}
/* --- NasWP Kit --- */
require_once "settings.php";
$naswp_settings = new NasWP_Settings();
require_once "classes/class-naswp-helpers.php";
$naswp_helpers = new NasWP_Helpers();
//$helpers->gtm('GTM-0');
$naswp_helpers->mimes($naswp_settings->mimes);
$naswp_helpers->lightbox();
$naswp_helpers->auto_async_js();
$naswp_helpers->file_names();
/* --- Hashlinks --- */
require_once __DIR__ . '/inc/lynt/hashlinks.php';
/* --- Author Box --- */
require_once __DIR__ . '/inc/lynt/author-box.php';