-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
168 lines (150 loc) · 4.89 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
<?php
function or_setup()
{
add_theme_support("post-thumbnails");
add_theme_support("menus");
register_sidebar([
"name" => "サイドバー",
"id" => "main-sidebar",
]);
}
add_action("after_setup_theme", "or_setup");
include "inc/customizer.php";
include "inc/toc.php";
// SVG対応
function custom_mime_types($mimes)
{
$mimes["svg"] = "image/svg+xml";
return $mimes;
}
add_filter("upload_mimes", "custom_mime_types");
function or_customize_controls_enqueue_scripts()
{
wp_enqueue_script(
"or-theme-customize",
get_template_directory_uri() . "/js/control.js",
[],
filemtime(get_template_directory() . "/js/control.js"),
true
);
wp_enqueue_style(
"or-theme-customize-css",
get_template_directory_uri() . "/css/customizer.css"
);
}
add_action(
"customize_controls_enqueue_scripts",
"or_customize_controls_enqueue_scripts"
);
add_theme_support("custom-logo");
require "lib/update-checker/plugin-update-checker.php";
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
$myUpdateChecker = PucFactory::buildUpdateChecker(
"https://opr.wmsci.com/version.json",
__FILE__,
"Operandi"
);
function prism()
{
wp_enqueue_style(
"prism-style",
get_template_directory_uri() . "/css/prism.css"
);
wp_enqueue_script(
"prism-script",
get_template_directory_uri() . "/js/prism.js"
);
}
if (get_theme_mod("or_main_design_prismjs")):
add_action("wp_enqueue_scripts", "prism");
endif;
function change_excerpt_length($length)
{
return get_theme_mod("or_main_design_excerpt_num") ?: 50;
}
add_filter("excerpt_length", "change_excerpt_length", 999);
function change_excerpt_more($more)
{
return get_theme_mod("or_main_design_excerpt_text") ?: "...";
}
add_filter("excerpt_more", "change_excerpt_more");
function or_register_block()
{
$registerBlocks = ["/blocks/linkcard", "/blocks/alert"];
function or_register_block_loop($BlockDir)
{
$blockType = basename($BlockDir);
wp_register_script(
$blockType,
get_template_directory_uri() . $BlockDir . "/block.js",
["wp-blocks", "wp-element"],
"1.0.0",
true
);
wp_enqueue_style(
$blockType,
get_template_directory_uri() . $BlockDir . "/style.css",
[],
"1.0.0"
);
include substr($BlockDir, 1, strlen($BlockDir) - 1) . "/index.php";
}
$blockRegister = "or_register_block_loop";
foreach ($registerBlocks as $value) {
$blockRegister($value);
}
}
add_action("init", "or_register_block");
function custom_user_meta($wb)
{
$wb["github"] = __("Github URL", "text_domain");
$wb["telegram"] = __("Telegram URL", "text_domain");
$wb["youtube"] = __("Youtube URL", "text_domain");
$wb["discord"] = __("Discord URL", "text_domain");
$wb["soundcloud"] = __("Soundcloud URL", "text_domain");
return $wb;
}
add_filter("user_contactmethods", "custom_user_meta");
add_filter('get_the_archive_title_prefix','__return_false');
if ( !function_exists( 'comment_custom_callback' ) ):
function comment_custom_callback($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf( __( '%s <span class="says">says:</span>' ),
sprintf( '<cite class="fn">%s</cite>', get_comment_author_link( $comment ) )
); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' );
?>
</div>
<div class="comment-content">
<?php comment_text($comment, array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) )); ?>
</div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
endif;