-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
234 lines (179 loc) · 6.83 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
require_once('inc/bs4navwalker.php');
require_once('inc/ozel-sidebar.php');
require_once('framework/cs-framework.php');
if ( ! function_exists( 'pincode_setup' ) ) :
function pincode_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
*/
/* Pinegrow generated Load Text Domain Begin */
load_theme_textdomain( 'pincode', get_template_directory() . '/languages' );
/* Pinegrow generated Load Text Domain End */
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 825, 510, true );
// Add menus.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'pincode' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/*
* Enable support for Post Formats.
*/
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
) );
}
endif; // pincode_setup
add_action( 'after_setup_theme', 'pincode_setup' );
if ( ! function_exists( 'pincode_init' ) ) :
function pincode_init() {
// Use categories and tags with attachments
register_taxonomy_for_object_type( 'category', 'attachment' );
register_taxonomy_for_object_type( 'post_tag', 'attachment' );
/*
* Register custom post types. You can also move this code to a plugin.
*/
/* Pinegrow generated Custom Post Types Begin */
/* Pinegrow generated Custom Post Types End */
/*
* Register custom taxonomies. You can also move this code to a plugin.
*/
/* Pinegrow generated Taxonomies Begin */
/* Pinegrow generated Taxonomies End */
}
endif; // pincode_setup
add_action( 'init', 'pincode_init' );
if ( ! function_exists( 'pincode_widgets_init' ) ) :
function pincode_widgets_init() {
/*
* Register widget areas.
*/
/* Pinegrow generated Register Sidebars Begin */
/* Pinegrow generated Register Sidebars End */
}
add_action( 'widgets_init', 'pincode_widgets_init' );
endif;// pincode_widgets_init
if ( ! function_exists( 'pincode_customize_register' ) ) :
function pincode_customize_register( $wp_customize ) {
// Do stuff with $wp_customize, the WP_Customize_Manager object.
/* Pinegrow generated Customizer Controls Begin */
/* Pinegrow generated Customizer Controls End */
}
add_action( 'customize_register', 'pincode_customize_register' );
endif;// pincode_customize_register
if ( ! function_exists( 'pincode_enqueue_scripts' ) ) :
function pincode_enqueue_scripts() {
/* Pinegrow generated Enqueue Scripts Begin */
wp_deregister_script( 'jqueryslim' );
wp_enqueue_script( 'jqueryslim', get_template_directory_uri() . '/js/jquery-3.3.1.slim.min.js', false, null, true);
wp_deregister_script( 'popper' );
wp_enqueue_script( 'popper', get_template_directory_uri() . '/js/popper.min.js', false, null, true);
wp_deregister_script( 'bootstrap' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', false, null, true);
wp_deregister_script( 'main' );
wp_enqueue_script( 'main', get_template_directory_uri() . '/js/main.js', false, null, true);
/* Pinegrow generated Enqueue Scripts End */
/* Pinegrow generated Enqueue Styles Begin */
wp_deregister_style( 'bootstrap' );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css.php', false, null, 'all');
wp_deregister_style( 'style' );
wp_enqueue_style( 'style', get_template_directory_uri() . '/css/style.css.php', false, null, 'all');
wp_deregister_style( 'all' );
wp_enqueue_style( 'all', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', false, null, 'all');
/* Pinegrow generated Enqueue Styles End */
}
add_action( 'wp_enqueue_scripts', 'pincode_enqueue_scripts' );
add_filter('style_loader_tag', 'pincode_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'pincode_remove_type_attr', 10, 2);
function pincode_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
endif;
function pgwp_sanitize_placeholder($input) { return $input; }
/*
* Resource files included by Pinegrow.
*/
/* Pinegrow generated Include Resources Begin */
/* Pinegrow generated Include Resources End */
/**
* Disable the emoji's
*/
function 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', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
/**
* Filter function used to remove the tinymce emoji plugin.
*
* @param array $plugins
* @return array Difference betwen the two arrays
*/
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
function pincode_image($field){
echo wp_get_attachment_image_src(cs_get_option($field),'full')[0];
}
function pincode_value($field){
echo cs_get_option($field);
}
function pincode_values($field){
cs_get_option($field);
}
add_filter( 'excerpt_length', 'pincode_excerpt_length', 999 );
function pincode_excerpt_length( $length ) {
return 10;
}
function pincode_excerpt( $limit ) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;
}
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).'...';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/[.+]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
?>