-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
165 lines (143 loc) · 4.17 KB
/
Copy pathfunctions.php
File metadata and controls
165 lines (143 loc) · 4.17 KB
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
<?php
/**
* mobiki functions and definitions
*
* @package mobiki
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
// Theme Version
if (!defined('MOBIKI_THEME_VERSION')) {
define('MOBIKI_THEME_VERSION', wp_get_theme()->get('Version'));
}
if ( ! function_exists( 'mobiki_setup' ) ) :
/**
* テーマのセットアップ
*/
function mobiki_setup() {
// 翻訳ファイルの読み込み(6.6 未満に対応)
load_theme_textdomain( 'mobiki', get_template_directory() . '/languages' );
// エディタースタイルのサポート
add_theme_support('editor-styles');
add_editor_style(get_parent_theme_file_uri('assets/css/editor-style.css'));
// ブロックエディターのサポート
add_theme_support('wp-block-styles');
add_theme_support('block-patterns');
add_theme_support('block-templates');
add_theme_support('block-template-parts');
// タイトルタグのサポート
add_theme_support( 'title-tag' );
// アイキャッチ画像のサポート
add_theme_support( 'post-thumbnails' );
// HTML5のサポート
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
) );
// 投稿フォーマットのサポート
add_theme_support('post-formats', array(
'aside',
'audio',
'chat',
'gallery',
'image',
'link',
'quote',
'status',
'video'
));
// カスタムロゴのサポート
add_theme_support( 'custom-logo', array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
) );
// レスポンシブ埋め込みのサポート
add_theme_support( 'responsive-embeds' );
// ワイドアラインメントのサポート
add_theme_support( 'align-wide' );
}
endif;
add_action( 'after_setup_theme', 'mobiki_setup' );
/**
* スタイルとスクリプトの読み込み
*/
function mobiki_enqueue_scripts() {
// CSSの読み込み
wp_enqueue_style(
'mobiki-style',
get_stylesheet_uri(),
array(),
MOBIKI_THEME_VERSION
);
// メインスタイル
wp_enqueue_style(
'mobiki-original-style',
get_template_directory_uri() . '/assets/css/main.css',
array('mobiki-style'),
MOBIKI_THEME_VERSION
);
// メインスクリプト
wp_enqueue_script(
'mobiki-script',
get_template_directory_uri() . '/assets/js/main.js',
array(),
MOBIKI_THEME_VERSION,
true
);
}
add_action( 'wp_enqueue_scripts', 'mobiki_enqueue_scripts' );
/**
* エディタ用スタイルの読み込み(ブロックエディタ & フルサイトエディタ両対応)
*/
function mobiki_enqueue_editor_assets() {
// エディタ用スタイルを読み込み
if ( ! is_admin() ) {
return;
}
wp_enqueue_style(
'mobiki-editor-style',
get_template_directory_uri() . '/assets/css/editor-style.css',
array(),
MOBIKI_THEME_VERSION
);
}
add_action( 'enqueue_block_editor_assets', 'mobiki_enqueue_editor_assets' );
/**
* ブロックパターンカテゴリーの登録
*/
function mobiki_register_block_pattern_categories() {
register_block_pattern_category(
'mobiki-hero',
array( 'label' => __( 'Hero Section', 'mobiki' ) )
);
register_block_pattern_category(
'mobiki-sections',
array( 'label' => __( 'Sections', 'mobiki' ) )
);
}
add_action( 'init', 'mobiki_register_block_pattern_categories' );
/**
* 抜粋の長さを調整
*/
function mobiki_theme_excerpt_length($length)
{
return 60;
}
add_filter('excerpt_length', 'mobiki_theme_excerpt_length');
/**
* 抜粋の最後の文字を変更
*/
function mobiki_theme_excerpt_more($more)
{
return '...';
}
add_filter('excerpt_more', 'mobiki_theme_excerpt_more');