-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
130 lines (96 loc) · 3.76 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
<?php // start every pure php file
// CSS JS
require_once( __DIR__ . '/functions-files/css-js.php');
// Google font
require_once( __DIR__ . '/functions-files/google-font.php');
// Math2IT custom settings
require_once( __DIR__ . '/functions-files/math2it-setting.php');
// Custom menu theme
require_once( __DIR__ . '/functions-files/menu.php');
// Navigation
require_once( __DIR__ . '/functions-files/nav.php');
// Quick edit post meta field
require_once( __DIR__ . '/functions-files/quick-edit.php');
// Gutenberg
// require_once( __DIR__ . '/functions-files/gutenberg.php');
// wordpress title
add_theme_support( 'title-tag' );
add_filter( 'document_title_separator', 'cyb_document_title_separator' );
function cyb_document_title_separator( $sep ) {
$sep = "|";
return $sep;
}
// Support Featured Images
add_theme_support( 'post-thumbnails' );
update_option( 'thumbnail_size_w', 150 );
update_option( 'thumbnail_size_h', 150 );
update_option( 'medium_size_w', 400 );
update_option( 'medium_size_h', 400 );
update_option( 'medium_large_size_w', 800 );
update_option( 'medium_large_size_h', 800 );
update_option( 'large_size_w', 1366 );
update_option( 'large_size_h', 1366 );
// remove p tag from category description
remove_filter('term_description','wpautop');
// css admin page
function admin_panel_css() {
wp_enqueue_style( 'style', get_template_directory_uri() . '/style_admin.css' );
}
add_action( 'admin_head', 'admin_panel_css' );
// Support svg image
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
// support wide image
function writy_setup() {
add_theme_support( 'align-wide' );
}
add_action( 'after_setup_theme', 'writy_setup' );
// comments
// ------------------------------------------------
// function wpbeginner_comment_text_before($arg) {
// $arg['comment_notes_before'] = "<p class='comment-policy'>We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our <a href='http://www.example.com/comment-policy-page/'>comment policy</a>.</p>";
// return $arg;
// }
// add_filter('comment_form_defaults', 'wpbeginner_comment_text_before');
// // move comment field to bottom
// function wpb_move_comment_field_to_bottom( $fields ) {
// $comment_field = $fields['comment'];
// unset( $fields['comment'] );
// $fields['comment'] = $comment_field;
// return $fields;
// }
// add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom');
// // remove website field
// function wpbeginner_remove_comment_url($arg) {
// $arg['url'] = '';
// return $arg;
// }
// add_filter('comment_form_default_fields', 'wpbeginner_remove_comment_url');
// category and tag have the same template
// ------------------------------------------------
add_filter( 'category_template', 'category_and_cat_template' );
add_filter( 'tag_template', 'category_and_cat_template' );
function category_and_cat_template( $template ) {
if ((is_category() and (!is_category('book')) and (!is_category('tool'))) or (is_tag())) {
$template = locate_template( 'cat-tag-layout.php' );
}
return $template;
}
// change the lenght of an excerpt
function wpdocs_custom_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
function wpdocs_excerpt_more( $more ) {
return '';
}
add_filter( 'excerpt_more', 'wpdocs_excerpt_more' );
// ------------------------------------------------
// PLUGINS
// ------------------------------------------------
require_once( __DIR__ . '/plugins/custom-gutenberg-button/my-custom-format.php');