-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
204 lines (174 loc) · 4.88 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
/**
* wtsp functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package wtsp
*/
function register_my_session(){
if( !session_id() ) {
session_start();
}
}
add_action('init', 'register_my_session');
if ( ! function_exists( 'wtsp_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function wtsp_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on wtsp, use a find and replace
* to change 'wtsp' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'wtsp', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5',[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
]);
}
endif;
add_action( 'after_setup_theme', 'wtsp_setup' );
// Function to change email address
function wpb_sender_email( $original_email_address ) {
return 'no-reply@wordpress.test';
}
add_filter( 'wp_mail_from', 'wpb_sender_email' );
// Function to change sender name
function wpb_sender_name( $original_email_from ) {
return get_bloginfo('name'); //ex. 'Wordpress Test';
}
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );
/* Add the default style and some other */
add_action( 'wp_enqueue_scripts', 'wtsp_my_styles_method');
function wtsp_my_styles_method() {
wp_enqueue_style(
'style',
get_stylesheet_uri()
);
wp_enqueue_style(
'fontawesome',
'https://use.fontawesome.com/releases/v5.12.0/css/all.css',
[ ],
'5.12.0'
);
wp_enqueue_style(
'icons',
get_template_directory_uri() . '/dist/icons/icons.css',
['style'],
'20200126'
);
wp_enqueue_style(
'slick-carousel',
'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.css',
[ ],
'1.9.0'
);
wp_enqueue_style(
'slick-carousel-theme',
'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css',
['slick-carousel'],
'1.9.0'
);
wp_enqueue_style(
'animate-css',
'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css',
[],
'4.0.0'
);
wp_enqueue_style(
'main',
get_template_directory_uri() . '/dist/styles/main.css',
['style', 'fontawesome', 'icons'],
'20200126'
);
}
/* Add some js scripts */
add_action( 'wp_enqueue_scripts', 'wtsp_my_scripts_method');
function wtsp_my_scripts_method() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'lodash' );
wp_enqueue_script(
'popper.js',
'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js',
[ ],
'1.14.7',
true
);
wp_enqueue_script(
'bootstrap',
'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js',
['jquery', 'popper.js'],
'4.3.1',
true
);
wp_enqueue_script(
'slick',
'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js',
['jquery'],
'1.9.0',
true
);
wp_enqueue_script(
'main',
get_template_directory_uri() . '/dist/scripts/main.js',
['jquery', 'bootstrap', 'slick'],
'20200126',
true
);
}
/* Enamble custom thumbnail sizes */
if ( function_exists( 'add_image_size' ) ) {
add_image_size( '1920', 1920 );
add_image_size( '800x600', 800, 600, true );
}
/* Customize the excerpt lenght */
add_filter( 'excerpt_more', 'wtsp_new_excerpt_more' );
function wtsp_new_excerpt_more( $more ) {
return '…';
}
/* Enable custom menu */
add_action( 'init', 'wtsp_register_my_menu' );
function wtsp_register_my_menu( ) {
register_nav_menu( 'mainmenu', 'Main menu of the theme');
register_nav_menu( 'footermenu', 'Footer menu of the theme');
}
function wtsp_content_width() {
$GLOBALS['content_width'] = apply_filters( 'wtsp_content_width', 1200 );
}
add_action( 'after_setup_theme', 'wtsp_content_width', 0 );
/* Title Tag */
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function wtsp_render_title() { ?>
<title><?php wp_title( '-', true, 'right' ); ?></title>
<?php }
add_action( 'wp_head', 'wtsp_render_title' );
}