質問編集履歴

1

使いたいphpの内容を追加

2019/02/02 02:33

投稿

emiemiemi
emiemiemi

スコア18

test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,263 @@
33
33
  初心者ですみません。
34
34
 
35
35
  よろしくお願いします。
36
+
37
+
38
+
39
+ 「accordion-menu.php」の中の内容はこちらです。
40
+
41
+ モバイル表示のとき、メニューボタンをおすと、スライドしてメニュー内容がでてくるというものを使いたいです。
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ ```php
52
+
53
+ <?php
54
+
55
+ if( wp_is_mobile() || trim($GLOBALS['stdata16']) === ''){ //PCで切り替え表示にチェックがある場合は表示しない
56
+
57
+ if ( trim( $GLOBALS["stdata80"] ) === '' ) { //スライドメニューを非表示
58
+
59
+ //追加メニューテキスト
60
+
61
+ if ( trim( $GLOBALS["stdata82"] ) !== '' ) {
62
+
63
+ $menutext = '<span class="op-text">' . esc_html( $GLOBALS["stdata82"] ) . '</span>';
64
+
65
+ } else {
66
+
67
+ $menutext = '';
68
+
69
+ }
70
+
71
+ if ( trim( $GLOBALS["stdata84"] ) !== '' ) {
72
+
73
+ $menutext2 = '<span class="op-text">' . esc_html( $GLOBALS["stdata84"] ) . '</span>';
74
+
75
+ } else {
76
+
77
+ $menutext2 = '';
78
+
79
+ }
80
+
81
+ //リンク先
82
+
83
+ if ( trim( $GLOBALS["stdata85"] ) !== '' ) {
84
+
85
+ $menuurl = esc_url( $GLOBALS["stdata85"] );
86
+
87
+ } else {
88
+
89
+ $menuurl = '#';
90
+
91
+ }
92
+
93
+ if ( trim( $GLOBALS["stdata86"] ) !== '' ) {
94
+
95
+ $menuurl2 = esc_url( $GLOBALS["stdata86"] );
96
+
97
+ } else {
98
+
99
+ $menuurl2 = '#';
100
+
101
+ }
102
+
103
+ //Webフォント
104
+
105
+ if ( trim( $GLOBALS["stdata81"] ) !== '' ) {
106
+
107
+ $web_icon = esc_attr( $GLOBALS["stdata81"] );
108
+
109
+ $menuicon = '<i class="fa ' . $web_icon . '" aria-hidden="true"></i>';
110
+
111
+ } else {
112
+
113
+ $menuicon = '';
114
+
115
+ }
116
+
117
+ if ( trim( $GLOBALS["stdata83"] ) !== '' ) {
118
+
119
+ $web_icon2 = esc_attr( $GLOBALS["stdata83"] );
120
+
121
+ $menuicon2 = '<i class="fa ' . $web_icon2 . '" aria-hidden="true"></i>';
122
+
123
+ } else {
124
+
125
+ $menuicon2 = '';
126
+
127
+ }
128
+
129
+ $has_text = ( isset( $GLOBALS['stdata374'] ) && $GLOBALS['stdata374'] === 'yes' ) // スライドメニューに文字追加
130
+
131
+ ?>
132
+
133
+ <nav id="s-navi" class="pcnone">
134
+
135
+ <dl class="acordion">
136
+
137
+ <dt class="trigger">
138
+
139
+ <p class="acordion_button"><span class="op<?php if ( $has_text ): ?> has-text<?php endif; ?>"><i class="fa <?php st_svg_close_class(); ?>"></i></span></p>
140
+
141
+ <?php if ( st_is_mobile() && st_mobilelogo_on() ): //スマホ・タブレット表示時にモバイル用ロゴ及びタイトルの使用 ?>
142
+
143
+
144
+
145
+ <?php if ( is_front_page() ) { ?>
146
+
147
+ <h1 id="st-mobile-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
148
+
149
+ <?php if ( get_option( 'st_mobile_logo' ) ): //ロゴ画像がある時 ?>
150
+
151
+ <img alt="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( get_option( 'st_mobile_logo' ) ); ?>" >
152
+
153
+ <?php else: //ロゴ画像が無い時 ?>
154
+
155
+ <?php echo esc_attr( wp_trim_words( get_bloginfo( 'name' ), 20, '...' ) ); ?>
156
+
157
+ <?php endif; ?>
158
+
159
+ </a></h1>
160
+
161
+ <?php } else { ?>
162
+
163
+ <p id="st-mobile-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
164
+
165
+ <?php if ( get_option( 'st_mobile_logo' ) ): //ロゴ画像がある時 ?>
166
+
167
+ <img alt="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( get_option( 'st_mobile_logo' ) ); ?>" >
168
+
169
+ <?php else: //ロゴ画像が無い時 ?>
170
+
171
+ <?php echo esc_attr( wp_trim_words( get_bloginfo( 'name' ), 20, '...' ) ); ?>
172
+
173
+ <?php endif; ?>
174
+
175
+ </a></p>
176
+
177
+ <?php } ?>
178
+
179
+
180
+
181
+ <?php else: //モバイル用ロゴ画像が無い時 ?>
182
+
183
+
184
+
185
+ <!-- 追加メニュー -->
186
+
187
+ <?php if ( ( trim( $GLOBALS["stdata81"] ) !== '' ) || ( trim( $GLOBALS["stdata82"] ) !== '' ) ) { ?>
188
+
189
+ <p class="acordion_extra_1"><a href="<?php echo $menuurl ?>"><span class="op-st"><?php echo $menuicon; ?><?php echo $menutext ?></span></a></p>
190
+
191
+ <?php } else { } ?>
192
+
193
+
194
+
195
+ <!-- 追加メニュー2 -->
196
+
197
+ <?php if ( ( trim( $GLOBALS["stdata83"] ) !== '' ) || ( trim( $GLOBALS["stdata84"] ) !== '' ) ) { ?>
198
+
199
+ <p class="acordion_extra_2"><a href="<?php echo $menuurl2 ?>"><span class="op-st2"><?php echo $menuicon2; ?><?php echo $menutext2 ?></span></a></p>
200
+
201
+ <?php } else { } ?>
202
+
203
+
204
+
205
+ <?php endif; ?>
206
+
207
+ </dt>
208
+
209
+
210
+
211
+ <dd class="acordion_tree">
212
+
213
+ <div class="acordion_tree_content">
214
+
215
+
216
+
217
+ <?php if ( is_active_sidebar( 25 ) ) { ?>
218
+
219
+ <div class="st-ac-box">
220
+
221
+ <?php if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 25 ) ) : else : //サイドウイジェット読み込み ?>
222
+
223
+ <?php endif; ?>
224
+
225
+ </div>
226
+
227
+ <?php } ?>
228
+
229
+
230
+
231
+
232
+
233
+ <?php
234
+
235
+ if ( has_nav_menu( 'smartphone-menu' ) ) :
236
+
237
+ $defaults = array(
238
+
239
+ 'theme_location' => 'smartphone-menu',
240
+
241
+ 'link_before' => '<span class="menu-item-label">',
242
+
243
+ 'link_after' => '</span>',
244
+
245
+ );
246
+
247
+ else :
248
+
249
+ $defaults = array(
250
+
251
+ 'theme_location' => 'primary-menu',
252
+
253
+ 'link_before' => '<span class="menu-item-label">',
254
+
255
+ 'link_after' => '</span>',
256
+
257
+ );
258
+
259
+ endif;?>
260
+
261
+ <?php wp_nav_menu( $defaults ); ?>
262
+
263
+ <div class="clear"></div>
264
+
265
+
266
+
267
+ <?php if ( is_active_sidebar( 27 ) ) { ?>
268
+
269
+ <div class="st-ac-box st-ac-box-bottom">
270
+
271
+ <?php if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 27 ) ) : else : //サイドウイジェット読み込み ?>
272
+
273
+ <?php endif; ?>
274
+
275
+ </div>
276
+
277
+ <?php } ?>
278
+
279
+
280
+
281
+ </div>
282
+
283
+ </dd>
284
+
285
+ </dl>
286
+
287
+ </nav>
288
+
289
+ <?php
290
+
291
+ }
292
+
293
+ }
294
+
295
+ ```