Version Description
Download this release
Release Info
Developer | sakurainternet |
Plugin | TypeSquare Webfonts SAKURA for SAKURA Rental Server |
Version | 3.1.0 |
Comparing to | |
See all releases |
Code changes from version 3.0.0 to 3.1.0
- inc/admin-root.php +664 -635
- inc/assets/css/admin.css +0 -4
- inc/class/class.font.data.php +362 -334
- readme.txt +7 -4
- screenshot-1.jpg +0 -0
- ts-webfonts-for-sakura.php +365 -347
inc/admin-root.php
CHANGED
@@ -1,59 +1,66 @@
|
|
1 |
<?php
|
2 |
-
class TypeSquare_Admin_Root extends TypeSquare_Admin_Base
|
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 |
jQuery( document ).ready(function() {
|
58 |
window.onload = function () {
|
59 |
theme_preview_new();
|
@@ -96,171 +103,176 @@ jQuery( document ).ready(function() {
|
|
96 |
}
|
97 |
});
|
98 |
EOM;
|
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 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
264 |
name='{$name}'
|
265 |
id='{$id}'
|
266 |
value='{$value}'
|
@@ -269,247 +281,258 @@ EOM;
|
|
269 |
data-parsley-trigger='change'
|
270 |
class='regular-text code'
|
271 |
/>";
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
513 |
{$vars}
|
514 |
jQuery( document ).ready(function() {
|
515 |
jQuery( form_id ).submit(function() {
|
@@ -529,177 +552,183 @@ jQuery( document ).ready(function() {
|
|
529 |
});
|
530 |
});
|
531 |
EOM;
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
class TypeSquare_Admin_Root extends TypeSquare_Admin_Base
|
3 |
+
{
|
4 |
+
private static $instance;
|
5 |
+
private static $text_domain;
|
6 |
+
private function __construct()
|
7 |
+
{
|
8 |
+
}
|
9 |
+
|
10 |
+
|
11 |
+
public static function get_instance()
|
12 |
+
{
|
13 |
+
if (! isset(self::$instance)) {
|
14 |
+
$c = __CLASS__;
|
15 |
+
self::$instance = new $c();
|
16 |
+
}
|
17 |
+
return self::$instance;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function typesquare_post_metabox()
|
21 |
+
{
|
22 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
23 |
+
$param = $fonts->get_fonttheme_params();
|
24 |
+
if ('false' == $param['typesquare_themes']['show_post_form'] || ! $param['typesquare_themes']['show_post_form']) {
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
$post_type = array( 'post', 'page' );
|
28 |
+
foreach ($post_type as $type) {
|
29 |
+
add_meta_box('typesquare_post_metabox', __('TS Webfonts for SAKURA RS', self::$text_domain), array( $this, 'typesquare_post_metabox_inside' ), $type, 'advanced', 'low');
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
public function typesquare_post_metabox_inside()
|
34 |
+
{
|
35 |
+
$html = '';
|
36 |
+
$html .= '<p>'. __('この記事に適用するフォントを選択してください', self::$text_domain) . '</p>';
|
37 |
+
|
38 |
+
$html .= $this->_get_post_font_theme_selector();
|
39 |
+
$html .= '<input type="hidden" name="typesquare_nonce_postmeta" id="typesquare_nonce_postmeta" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
|
40 |
+
echo $html;
|
41 |
+
}
|
42 |
+
|
43 |
+
private function _get_post_font_theme_selector()
|
44 |
+
{
|
45 |
+
$html = '';
|
46 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
47 |
+
$all_font_theme = $fonts->load_all_font_data();
|
48 |
+
$selected_theme = $fonts->get_selected_post_fonttheme(get_the_ID());
|
49 |
+
$option = '';
|
50 |
+
$option .= "<option value='false'>テーマを設定しない</option>";
|
51 |
+
foreach ($all_font_theme as $key => $fonttheme) {
|
52 |
+
$fonttheme_name = $this->get_fonts_text($fonttheme['name']);
|
53 |
+
$font_text = $this->_get_fonttheme_text($fonttheme);
|
54 |
+
$selected = '';
|
55 |
+
if ($key === $selected_theme) {
|
56 |
+
$selected = 'selected';
|
57 |
+
}
|
58 |
+
$option .= "<option value='{$key}' {$selected}>";
|
59 |
+
$option .= "{$fonttheme_name} ( {$font_text} )";
|
60 |
+
$option .= '</option>';
|
61 |
+
}
|
62 |
+
$html .= '<h3>'. __('フォントテーマから選ぶ', self::$text_domain) . '</h3>';
|
63 |
+
$preview = <<<EOM
|
64 |
jQuery( document ).ready(function() {
|
65 |
window.onload = function () {
|
66 |
theme_preview_new();
|
103 |
}
|
104 |
});
|
105 |
EOM;
|
106 |
+
$html = '<script>';
|
107 |
+
$html .= $preview;
|
108 |
+
$html .= '</script>';
|
109 |
+
$html .= '<div id="choiceThemeNew">';
|
110 |
+
$html .= "<select name='typesquare_fonttheme[theme]' class='font_theme_select_pre_new'>{$option}</select>";
|
111 |
+
$html .= '<h3>プレビュー</h3>';
|
112 |
+
$html .= '<div><p class="title">見出し:<p class="pre_title"></p></p></div>';
|
113 |
+
$html .= '<div><p class="title">リード:<p class="pre_lead"></p></p></div>';
|
114 |
+
$html .= '<div><p class="title">本文:<p class="pre_body"></p></p></div>';
|
115 |
+
$html .= '<div><p class="title">太字:<p class="pre_bold"></p></p></div>';
|
116 |
+
$html .= '<input type="hidden" id="theme_preview" />';
|
117 |
+
foreach ($all_font_theme as $fonttheme_key => $fonttheme) {
|
118 |
+
$html .= "<input type='hidden' id='selected-get-{$fonttheme_key}' value='" . json_encode($fonttheme) . "'>";
|
119 |
+
}
|
120 |
+
$html .= '</div>';
|
121 |
+
return $html;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function typesquare_save_post($post_id)
|
125 |
+
{
|
126 |
+
if (! isset($_POST['typesquare_nonce_postmeta'])) {
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
//Verify
|
130 |
+
if (! wp_verify_nonce($_POST['typesquare_nonce_postmeta'], plugin_basename(__FILE__))) {
|
131 |
+
return $post_id;
|
132 |
+
}
|
133 |
+
// if auto save
|
134 |
+
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
135 |
+
return $post_id;
|
136 |
+
}
|
137 |
+
|
138 |
+
// permission check
|
139 |
+
if ('page' == $_POST['post_type']) {
|
140 |
+
if (! current_user_can('edit_page', $post_id)) {
|
141 |
+
return $post_id;
|
142 |
+
}
|
143 |
+
} else {
|
144 |
+
if (! current_user_can('edit_post', $post_id)) {
|
145 |
+
return $post_id;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
// save action
|
150 |
+
$fonttheme = $_POST['typesquare_fonttheme'];
|
151 |
+
$current_option = get_post_meta($post_id, 'typesquare_fonttheme');
|
152 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
153 |
+
if (isset($current_option[0])) {
|
154 |
+
$current = $current_option[0];
|
155 |
+
} else {
|
156 |
+
$current = $fonttheme;
|
157 |
+
}
|
158 |
+
$font['theme'] = esc_attr($fonttheme['theme']);
|
159 |
+
update_post_meta($post_id, 'typesquare_fonttheme', $font);
|
160 |
+
return $post_id;
|
161 |
+
}
|
162 |
+
|
163 |
+
private function get_fonts_text($fonts)
|
164 |
+
{
|
165 |
+
if (is_array($fonts)) {
|
166 |
+
$text_font = '';
|
167 |
+
foreach ($fonts as $key => $font) {
|
168 |
+
$text_font .= esc_attr($font);
|
169 |
+
if (count($fonts) - 1 > $key) {
|
170 |
+
$text_font .= ' + ';
|
171 |
+
}
|
172 |
+
}
|
173 |
+
} else {
|
174 |
+
$text_font = esc_attr($fonts);
|
175 |
+
}
|
176 |
+
return $text_font;
|
177 |
+
}
|
178 |
+
|
179 |
+
public function typesquare_admin_menu()
|
180 |
+
{
|
181 |
+
$param = $this->get_auth_params();
|
182 |
+
$option_name = 'typesquare_auth';
|
183 |
+
$nonce_key = TypeSquare_ST::OPTION_NAME;
|
184 |
+
$auth_param = $this->get_auth_params();
|
185 |
+
echo "<style type='text/css' rel='stylesheet'>";
|
186 |
+
echo "</style>";
|
187 |
+
echo "<div class='wrap'>";
|
188 |
+
echo '<h2>'. __('TS Webfonts for SAKURA RS', self::$text_domain). '</h2>';
|
189 |
+
do_action('typesquare_add_setting_before');
|
190 |
+
echo '<hr />';
|
191 |
+
echo '<span><h3 class="toggleText toggleAdvanced_font mTop20">'. __('投稿記事フォント設定', self::$text_domain). '<span class="advancedTriangle advancedTriangle_font">▼</span></h3></span>';
|
192 |
+
echo "<div class='ts-custome_form_font hidden'>";
|
193 |
+
echo $this->_get_post_font_form($auth_param);
|
194 |
+
echo '</div>';
|
195 |
+
echo '</div>';
|
196 |
+
|
197 |
+
echo '<hr/>';
|
198 |
+
echo '<span><h3 class="toggleText toggleAdvanced_site mTop20">'. __('サイトフォント設定', self::$text_domain). '<span class="advancedTriangle advancedTriangle_site">▼</span></h3></span>';
|
199 |
+
echo "<div class='ts-custome_form_site hidden'>";
|
200 |
+
echo $this->_get_site_font_form();
|
201 |
+
echo '</div>';
|
202 |
+
echo '<hr/>';
|
203 |
+
echo '<span><h3 class="toggleText toggleAdvanced_article mTop20">'. __('カスタムテーマ編集', self::$text_domain). '<span class="advancedTriangle advancedTriangle_article">▼</span></h3></span>';
|
204 |
+
echo "<div class='ts-custome_form_article hidden'>";
|
205 |
+
echo '<div class="ts-custum_block">';
|
206 |
+
echo $this->_get_font_theme_custom_form();
|
207 |
+
echo '</div>';
|
208 |
+
echo '</div>';
|
209 |
+
do_action('typesquare_add_setting_after');
|
210 |
+
}
|
211 |
+
|
212 |
+
private function _get_post_font_form($auth_param)
|
213 |
+
{
|
214 |
+
$html = "<form method='post' action=''>";
|
215 |
+
$html .= '<p>投稿記事に対するWebフォント適用方法を設定します。</p>';
|
216 |
+
$html .= '<div class="block_wrap">';
|
217 |
+
$html .= '<p class="block_title">'. __('投稿記事に適用するフォント設定', self::$text_domain). '</p>';
|
218 |
+
$html .= '<div class="label_wrapper">';
|
219 |
+
$html .= '<label class="custum_form_ladio"><input name="fontThemeUseType" type="radio" value="1">指定しない';
|
220 |
+
$html .= '<p class="setting_read">フォントテーマを適用しません。</p>';
|
221 |
+
$html .= '</label>';
|
222 |
+
$html .= '<label class="custum_form_ladio"><input name="fontThemeUseType" type="radio" value="2" class="radio_custum_font_theme">共通テーマ指定';
|
223 |
+
$html .= '<p class="setting_read">全ての投稿に設定したフォントテーマが適用されます。</p>';
|
224 |
+
$html .= '</label>';
|
225 |
+
$html .= $this->_get_font_theme_form();
|
226 |
+
$html .= '<label class="custum_form_ladio"><input name="fontThemeUseType" type="radio" value="3">個別テーマ指定';
|
227 |
+
$html .= '<p class="setting_read">投稿ごとに設定したフォントテーマが適用されます。</p>';
|
228 |
+
$html .= '</label>';
|
229 |
+
$html .= '<label class="custum_form_ladio"><input name="fontThemeUseType" type="radio" value="4">直接指定(上級者向け)';
|
230 |
+
$html .= '<p class="setting_read">CSSセレクターを指定して適用するウェブフォントを選べます。</p>';
|
231 |
+
$html .= '</label>';
|
232 |
+
$html .= $this->_get_font_target_form();
|
233 |
+
|
234 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
235 |
+
$fonttheme_params = $fonts->get_fonttheme_params();
|
236 |
+
|
237 |
+
if (empty($auth_param['typesquare_auth']['fontThemeUseType'])) {
|
238 |
+
if (empty($fonttheme_params['typesquare_themes']['font_theme']) || $fonttheme_params['typesquare_themes']['font_theme'] === "false") {
|
239 |
+
$html .= '<input type="hidden" id="activeAdvanced_theme" value="1">';
|
240 |
+
} else {
|
241 |
+
$html .= '<input type="hidden" id="activeAdvanced_theme" value="2">';
|
242 |
+
}
|
243 |
+
} else {
|
244 |
+
if (!empty($fonttheme_params['typesquare_themes']['font_theme']) && $auth_param['typesquare_auth']['fontThemeUseType'] === "1") {
|
245 |
+
$html .= '<input type="hidden" id="activeAdvanced_theme" value="2">';
|
246 |
+
} else {
|
247 |
+
$html .= '<input type="hidden" id="activeAdvanced_theme" value="' . $auth_param['typesquare_auth']['fontThemeUseType'] . '">';
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
$html .= '</div>';
|
252 |
+
$html .= '</div>';
|
253 |
+
$html .= get_submit_button(__('投稿フォント設定を保存する', self::$text_domain));
|
254 |
+
$html .= '</form>';
|
255 |
+
return $html;
|
256 |
+
}
|
257 |
+
|
258 |
+
private function _get_auth_form($auth_param)
|
259 |
+
{
|
260 |
+
$html = '';
|
261 |
+
$nonce_key = TypeSquare_ST::OPTION_NAME;
|
262 |
+
$html .= "<form method='post' action='' id='authForm'>";
|
263 |
+
$html .= wp_nonce_field($nonce_key, self::MENU_ID, true, false);
|
264 |
+
$html .= "<table class='widefat form-table'>";
|
265 |
+
$html .= '<tbody>';
|
266 |
+
$param = $this->get_auth_params();
|
267 |
+
$option_name = 'typesquare_auth';
|
268 |
+
foreach ($param['typesquare_auth_keys'] as $key => $title) {
|
269 |
+
$html .= "<tr><td>";
|
270 |
+
$name = "{$option_name}[{$key}]";
|
271 |
+
$type = 'hidden';
|
272 |
+
$name = esc_attr($name);
|
273 |
+
$id = esc_attr($key);
|
274 |
+
$value = "SAKURA";
|
275 |
+
$html .= "<input
|
276 |
name='{$name}'
|
277 |
id='{$id}'
|
278 |
value='{$value}'
|
281 |
data-parsley-trigger='change'
|
282 |
class='regular-text code'
|
283 |
/>";
|
284 |
+
$html .= '</td></tr>';
|
285 |
+
}
|
286 |
+
$html .= '</tbody>';
|
287 |
+
$html .= '</div>';
|
288 |
+
$html .= '</table>';
|
289 |
+
if ('' !== $auth_param['typesquare_auth']['typesquare_id']) {
|
290 |
+
$html .= '<div class="block_wrap">';
|
291 |
+
$html .= "<table class='widefat form-table'>";
|
292 |
+
$html .= '<tbody>';
|
293 |
+
$html .= $this->_get_font_fade_form();
|
294 |
+
$html .= $this->_get_auto_load_font_form();
|
295 |
+
$html .= $this->_get_apply_to_hidden_form();
|
296 |
+
$html .= $this->_get_apply_to_pseudo_form();
|
297 |
+
$html .= '</tbody>';
|
298 |
+
$html .= "</table>";
|
299 |
+
$html .= '</div>';
|
300 |
+
}
|
301 |
+
|
302 |
+
$html .= $this->_update_font_list_form();
|
303 |
+
$html .= get_submit_button(__('TypeSquare設定を保存する', self::$text_domain));
|
304 |
+
|
305 |
+
$html .= '</form>';
|
306 |
+
return $html;
|
307 |
+
}
|
308 |
+
|
309 |
+
private function _get_ad_area()
|
310 |
+
{
|
311 |
+
$html = '<script>';
|
312 |
+
$endpoint = path_join(TS_PLUGIN_URL, 'inc/font.json');
|
313 |
+
$html .= "var json_endpoint = '{$endpoint}';";
|
314 |
+
$html .= "var current_font = false;";
|
315 |
+
$html .= $script;
|
316 |
+
$html .= '</script>';
|
317 |
+
$html .= "<div class='ts-ad-area'>";
|
318 |
+
$messages[] = __('・ご利用にはTypeSquareの会員登録が必要です (<a href="https://typesquare.com">https://typesquare.com</a>)', self::$text_domain);
|
319 |
+
$messages[] = __('・利用プランによっては利用可能な書体数に上限がありますので、上限を超えて設定したフォントは配信されません。', self::$text_domain);
|
320 |
+
$messages[] = ' '. __('・無料プラン:1書体', self::$text_domain);
|
321 |
+
$messages[] = ' '. __('', self::$text_domain);
|
322 |
+
$messages[] = ' '. __('・スタンダードIプラン:3書体', self::$text_domain);
|
323 |
+
$html .= '<ul>';
|
324 |
+
$html .= '<li style="padding-bottom: 5px;"><span href="#" class="toggleLimit toggleText">' . __('ご利用上の注意', self::$text_domain). '</span><span class="textMute elimitTriangl" style="float: right;">▼</span></li>';
|
325 |
+
$html .= '<div id="ts-ad-area-messages" class="ts-hidden">';
|
326 |
+
foreach ($messages as $message) {
|
327 |
+
$html .= "<li>{$message}</li>";
|
328 |
+
}
|
329 |
+
$html .= "<p><a href='https://typesquare.com/ja/service/plan' target='_blank' class='button button-hero'>". __('→プランを見てみる', self::$text_domain) . '</a></p>';
|
330 |
+
$html .= '</div>';
|
331 |
+
$html .= '</ul>';
|
332 |
+
$html .= '</div>';
|
333 |
+
$html .= '<div class="mTop30">';
|
334 |
+
$html .= '<h3 class="mBottom10">'. __('ご利用方法', self::$text_domain). '</h3>';
|
335 |
+
$html .= '<div>'. __('TypeSquare Webfontsについての内容を説明しています', self::$text_domain). '</div>';
|
336 |
+
$html .= '<div>'. __('詳しくは', self::$text_domain). "<a href='https://blog.typesquare.com/archives/55354' target='_blank'>". __('こちら', self::$text_domain). '</a></div>';
|
337 |
+
$html .= '</div>';
|
338 |
+
|
339 |
+
return $html;
|
340 |
+
}
|
341 |
+
|
342 |
+
private function _get_font_fade_form()
|
343 |
+
{
|
344 |
+
$option_name = 'typesquare_fonttheme';
|
345 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
346 |
+
$param = $fonts->get_fonttheme_params();
|
347 |
+
$keys = $param['typesquare_themes_keys'];
|
348 |
+
$html = "<tr><th>{$keys['fade_in']}</th><td>";
|
349 |
+
$value = esc_attr($param['typesquare_themes']['fade_in']);
|
350 |
+
if ($value) {
|
351 |
+
$optional = 'checked';
|
352 |
+
}
|
353 |
+
|
354 |
+
$html .="<label class='switch__label' ><input name='{$option_name}[fade_in]'type='checkbox' class='switch__input' id='fade_in' value='1' ". checked($value, true, false). "/><span class='switch__content'></span><span class='switch__circle'></span></label><span>有効化する</span>";
|
355 |
+
$html .= '</td></tr>';
|
356 |
+
if ($value) {
|
357 |
+
$state = 'ts-table-low';
|
358 |
+
} else {
|
359 |
+
$state = 'hidden';
|
360 |
+
}
|
361 |
+
$html .= "<tr id='hidden_time' class='{$state}'><th>{$keys['fade_time']}</th><td>";
|
362 |
+
$value = esc_attr($param['typesquare_themes']['fade_time']);
|
363 |
+
$optional = "size='5' maxlength='5'";
|
364 |
+
$html .= "<input name='{$option_name}[fade_time]' type='text' id='fade_time' value='{$value}' class='code' {$optional}/>";
|
365 |
+
$html .= __('ミリ秒(0〜10000の整数)', self::$text_domain);
|
366 |
+
$html .= '</td></tr>';
|
367 |
+
|
368 |
+
return $html;
|
369 |
+
}
|
370 |
+
|
371 |
+
private function _get_font_theme_form()
|
372 |
+
{
|
373 |
+
$option_name = 'typesquare_fonttheme';
|
374 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
375 |
+
$param = $fonts->get_fonttheme_params();
|
376 |
+
$html = '';
|
377 |
+
$html .= wp_nonce_field('ts_update_font_settings', 'ts_update_font_settings', true, false);
|
378 |
+
$html .= '<div id="choiceTheme" class="font_custum_select">';
|
379 |
+
$html .= "<select name='{$option_name}[font_theme]' class='font_theme_select_pre'>";
|
380 |
+
$all_font_theme = $fonts->load_all_font_data();
|
381 |
+
foreach ($all_font_theme as $fonttheme_key => $fonttheme) {
|
382 |
+
$fonttheme_name = esc_attr($fonttheme['name']);
|
383 |
+
$font_text = $this->_get_fonttheme_text($fonttheme);
|
384 |
+
$selected = '';
|
385 |
+
if ($fonttheme_key == $param['typesquare_themes']['font_theme']) {
|
386 |
+
$selected = 'selected';
|
387 |
+
}
|
388 |
+
$html .= "<option value='{$fonttheme_key}' {$selected}>";
|
389 |
+
$html .= "{$fonttheme_name} ( {$font_text} )";
|
390 |
+
$html .= '</option>';
|
391 |
+
}
|
392 |
+
$html .= '</select>';
|
393 |
+
$html .= '<h3>プレビュー</h3>';
|
394 |
+
$html .= '<div><p class="title">見出し:<p class="pre_title"></p></p></div>';
|
395 |
+
$html .= '<div><p class="title">リード:<p class="pre_lead"></p></p></div>';
|
396 |
+
$html .= '<div><p class="title">本文:<p class="pre_body"></p></p></div>';
|
397 |
+
$html .= '<div><p class="title">太字:<p class="pre_bold"></p></p></div>';
|
398 |
+
$html .= '<input type="hidden" id="theme_preview" />';
|
399 |
+
foreach ($all_font_theme as $fonttheme_key => $fonttheme) {
|
400 |
+
$html .= "<input type='hidden' id='selected-get-{$fonttheme_key}' value='" . json_encode($fonttheme) . "'>";
|
401 |
+
}
|
402 |
+
$html .= wp_nonce_field('ts_update_font_settings', 'ts_update_font_settings', true, false);
|
403 |
+
|
404 |
+
$value = esc_attr($param['typesquare_themes']['show_post_form']) == "true" ? true : false;
|
405 |
+
$html .= '</div>';
|
406 |
+
$html .= '<input type="hidden" name="typesquare_nonce_postmeta" id="typesquare_nonce_postmeta" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
|
407 |
+
return $html;
|
408 |
+
}
|
409 |
+
|
410 |
+
private function _get_font_theme_custom_form()
|
411 |
+
{
|
412 |
+
$option_name = 'typesquare_fonttheme';
|
413 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
414 |
+
$param = $fonts->get_fonttheme_params();
|
415 |
+
if (isset($_POST['typesquare_fonttheme']['font_theme']) && $_POST['typesquare_fonttheme']['font_theme'] !== 'new') {
|
416 |
+
$param['typesquare_themes']['font_theme'] = $_POST['typesquare_fonttheme']['font_theme'];
|
417 |
+
}
|
418 |
+
$html = '';
|
419 |
+
$html .= "<form method='post' action='' id='custmeFontForm' class='b__font_theme_form'>";
|
420 |
+
$html .= '<p>お好きなフォントを組み合わせてテーマを作成できます。また、作成したテーマの編集ができます。</p>';
|
421 |
+
$html .= wp_nonce_field('ts_update_font_settings', 'ts_update_font_settings', true, false);
|
422 |
+
$html .= '<div class="font_custum_select">';
|
423 |
+
$html .= "<select id='fontThemeSelect' name='{$option_name}[font_theme]'>";
|
424 |
+
$html .= "<option value='new' selected>新しくテーマを作成する</option>";
|
425 |
+
$coustam_font_theme = $fonts->load_coustam_font_data();
|
426 |
+
if (!empty($coustam_font_theme)) {
|
427 |
+
foreach ($coustam_font_theme as $fonttheme_key => $fonttheme) {
|
428 |
+
$fonttheme_name = esc_attr($fonttheme['name']);
|
429 |
+
$font_text = $this->_get_fonttheme_text($fonttheme);
|
430 |
+
$selected = '';
|
431 |
+
$html .= "<option value='{$fonttheme_key}' {$selected}>";
|
432 |
+
$html .= "{$fonttheme_name} ( {$font_text} )";
|
433 |
+
$html .= '</option>';
|
434 |
+
}
|
435 |
+
}
|
436 |
+
$html .= '</select>';
|
437 |
+
if (!empty($coustam_font_theme)) {
|
438 |
+
foreach ($coustam_font_theme as $fonttheme_key => $fonttheme) {
|
439 |
+
$html .= "<input type='hidden' id='{$fonttheme_key}' value='" . json_encode($fonttheme) . "'>";
|
440 |
+
}
|
441 |
+
}
|
442 |
+
$html .= '</div>';
|
443 |
+
|
444 |
+
$html .= $this->_get_custome_font_theme_list_form();
|
445 |
+
$html .= "<table>";
|
446 |
+
$html .= "<th>";
|
447 |
+
$html .= get_submit_button(__('テーマを保存する', self::$text_domain), 'primary', 'fontThemeUpdateButton');
|
448 |
+
$html .= "</th>";
|
449 |
+
$html .= "<th>";
|
450 |
+
$style = array("style"=>"margin-top:15px; display:none;");
|
451 |
+
$html .= get_submit_button(__('テーマを削除する', self::$text_domain), 'delete', 'fontThemeDeleteButton', null, $style);
|
452 |
+
$html .= "</th>";
|
453 |
+
$html .= "</table>";
|
454 |
+
$html .= '<input type="hidden" name="typesquare_nonce_postmeta" id="typesquare_nonce_postmeta" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
|
455 |
+
$html .= '</form>';
|
456 |
+
return $html;
|
457 |
+
}
|
458 |
+
|
459 |
+
private function _get_custome_font_theme_list_form()
|
460 |
+
{
|
461 |
+
$html = '';
|
462 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='new' />";
|
463 |
+
$html .= '<input type="hidden" id="ts_custome_theme_id" name="typesquare_custom_theme[id]" value="' . uniqid() . '" />';
|
464 |
+
$html .= "<div id='customeFontThemeForm'>";
|
465 |
+
$html .= wp_nonce_field('ts_update_font_name_setting', 'ts_update_font_name_setting', true, false);
|
466 |
+
$html .= "<table class='widefat' style='border: 0px'>";
|
467 |
+
$html .= '<tbody>';
|
468 |
+
$html .= "<tr><th width='240px' style='padding-left:0;'>テーマタイトル</th><td>";
|
469 |
+
$html .= "<input type='hidden' id='current_custome_font_name' name='typesquare_custom_theme[name]' value=''/>";
|
470 |
+
$html .= "<input type='text' id='custome_font_name' name='typesquare_custom_theme[name]' value='' maxlength='16' style='width:50%;' required/>";
|
471 |
+
$html .= '</td></tr>';
|
472 |
+
$html .= $this->_get_site_font_form_tr("見出し", "", "typesquare_custom_theme[fonts][title][type]");
|
473 |
+
$html .= $this->_get_site_font_form_tr("リード", "", "typesquare_custom_theme[fonts][lead][type]");
|
474 |
+
$html .= $this->_get_site_font_form_tr("本文", "", "typesquare_custom_theme[fonts][text][type]");
|
475 |
+
$html .= $this->_get_site_font_form_tr("太字", "", "typesquare_custom_theme[fonts][bold][type]");
|
476 |
+
$html .= '</tbody>';
|
477 |
+
$html .= '</table>';
|
478 |
+
$html .= "<div id='ts-react-search-font'></div>";
|
479 |
+
$html .= "</div>";
|
480 |
+
$font_list = array();
|
481 |
+
$html .= $this->_get_script($font_list);
|
482 |
+
return $html;
|
483 |
+
}
|
484 |
+
|
485 |
+
private function _get_site_font_form()
|
486 |
+
{
|
487 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
488 |
+
$value = $fonts->get_site_font_setting();
|
489 |
+
$html = "<form method='post' action='' id='siteFontForm'>";
|
490 |
+
$html .= '<p>タイトルなど、ウェブサイト共通部分のフォント設定です</p>';
|
491 |
+
$html .= '<table class="widefat form-table">';
|
492 |
+
$html .= '<tbody>';
|
493 |
+
if (is_array($value)) {
|
494 |
+
$html .= $this->_get_site_font_form_tr("サイトタイトル", $value['title_fontname'], "title_fontname");
|
495 |
+
$html .= $this->_get_site_font_form_tr("サイトキャッチコピー", $value['catchcopy_fontname'], "catchcopy_fontname");
|
496 |
+
$html .= $this->_get_site_font_form_tr("ウィジェットタイトル", $value['widget_title_fontname'], "widget_title_fontname");
|
497 |
+
$html .= $this->_get_site_font_form_tr("ウィジェット", $value['widget_fontname'], "widget_fontname");
|
498 |
+
} else {
|
499 |
+
$html .= $this->_get_site_font_form_tr("サイトタイトル", "", "title_fontname");
|
500 |
+
$html .= $this->_get_site_font_form_tr("サイトキャッチコピー", "", "catchcopy_fontname");
|
501 |
+
$html .= $this->_get_site_font_form_tr("ウィジェットタイトル", "", "widget_title_fontname");
|
502 |
+
$html .= $this->_get_site_font_form_tr("ウィジェット", "", "widget_fontname");
|
503 |
+
}
|
504 |
+
$html .= '</tbody>';
|
505 |
+
$html .= "</table>";
|
506 |
+
$html .= get_submit_button(__('サイトフォント設定を保存する', self::$text_domain));
|
507 |
+
$html .= wp_nonce_field('ts_update_site_font_settings', 'ts_update_site_font_settings', true, false);
|
508 |
+
$html .= '</form>';
|
509 |
+
return $html;
|
510 |
+
}
|
511 |
+
|
512 |
+
private function _get_site_font_form_tr($title, $value, $input_name)
|
513 |
+
{
|
514 |
+
$html = "<tr><th style='padding-left:0;'><span>{$title}</span></th>";
|
515 |
+
$html .= '<td class="font_table_td">';
|
516 |
+
$html .= '<div class="w_font_select">';
|
517 |
+
$html .= "<input class='fontlist_input' autocomplete='off' value='{$value}' style='font-family: {$value}' placeholder='未設定'/>";
|
518 |
+
$html .= "<div class='w_fontlist b_def_fontlist'></div>";
|
519 |
+
$html .= "</div>";
|
520 |
+
$html .= "</td><input value='{$value}' type='hidden' name='{$input_name}' id='fontlist_select' class='fontlist_select'/></tr>";
|
521 |
+
return $html;
|
522 |
+
}
|
523 |
+
|
524 |
+
private function _get_script($font_list)
|
525 |
+
{
|
526 |
+
$vars = "var form_id = '#". self::MENU_FONTTHEME. "';";
|
527 |
+
$vars .= "var notify_text = '". __('フォントを1種類以上選択してください。', self::$text_domain). "';";
|
528 |
+
$vars .= "var unique_id ='". uniqid() ."';";
|
529 |
+
$options = get_option('typesquare_custom_theme');
|
530 |
+
$vars .= "var option_font_list = ". json_encode($options) .";";
|
531 |
+
$vars .= "var plugin_base = '".wp_create_nonce(plugin_basename(__FILE__))."';";
|
532 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
533 |
+
$all_font_theme = $fonts->load_all_font_data();
|
534 |
+
$vars .= 'var all_font_list = '. json_encode($all_font_theme) .';';
|
535 |
+
$script = <<<EOM
|
536 |
{$vars}
|
537 |
jQuery( document ).ready(function() {
|
538 |
jQuery( form_id ).submit(function() {
|
552 |
});
|
553 |
});
|
554 |
EOM;
|
555 |
+
$html = '<script>';
|
556 |
+
$endpoint = path_join(TS_PLUGIN_URL, 'inc/font.json');
|
557 |
+
$html .= "var json_endpoint = '{$endpoint}';";
|
558 |
+
if ($font_list) {
|
559 |
+
$html .= "var current_font = ". json_encode($font_list) .';';
|
560 |
+
} else {
|
561 |
+
$html .= "var current_font = false;";
|
562 |
+
}
|
563 |
+
$html .= $script;
|
564 |
+
$html .= '</script>';
|
565 |
+
return $html;
|
566 |
+
}
|
567 |
+
|
568 |
+
private function _get_fonttheme_text($fonttheme)
|
569 |
+
{
|
570 |
+
$font_text = '';
|
571 |
+
if (isset($fonttheme['fonts']['title'])) {
|
572 |
+
$font_text .= __('見出し:', self::$text_domain);
|
573 |
+
$font_text .= $this->get_fonts_text($fonttheme['fonts']['title']);
|
574 |
+
$font_text .= ',';
|
575 |
+
}
|
576 |
+
if (isset($fonttheme['fonts']['lead'])) {
|
577 |
+
$font_text .= __('リード:', self::$text_domain);
|
578 |
+
$font_text .= $this->get_fonts_text($fonttheme['fonts']['lead']);
|
579 |
+
$font_text .= ',';
|
580 |
+
}
|
581 |
+
if (isset($fonttheme['fonts']['content'])) {
|
582 |
+
$font_text .= __('本文:', self::$text_domain);
|
583 |
+
$font_text .= $this->get_fonts_text($fonttheme['fonts']['content']);
|
584 |
+
$font_text .= ',';
|
585 |
+
}
|
586 |
+
if (isset($fonttheme['fonts']['text'])) {
|
587 |
+
$font_text .= __('本文:', self::$text_domain);
|
588 |
+
$font_text .= $this->get_fonts_text($fonttheme['fonts']['text']);
|
589 |
+
$font_text .= ',';
|
590 |
+
}
|
591 |
+
if (isset($fonttheme['fonts']['bold'])) {
|
592 |
+
$font_text .= __('太字:', self::$text_domain);
|
593 |
+
$font_text .= $this->get_fonts_text($fonttheme['fonts']['bold']);
|
594 |
+
}
|
595 |
+
$font_text = rtrim($font_text, ',');
|
596 |
+
$font_text = str_replace(",", " / ", $font_text);
|
597 |
+
return $font_text;
|
598 |
+
}
|
599 |
+
|
600 |
+
private function _get_font_target_form()
|
601 |
+
{
|
602 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
603 |
+
$array_input = $fonts->get_font_pro_setting();
|
604 |
+
$html = "<div class='b__font_target_form'>";
|
605 |
+
$html .= "<table class='widefat form-table'>";
|
606 |
+
$html .= '<thead>';
|
607 |
+
$html .= "<tr><th style='width: 25%; padding-left: 45px;'>フォント選択</th><th style='width: 75%; padding-left: 14px;'>適用箇所(CSSセレクターで指定)</th></tr>";
|
608 |
+
$html .= '</thead>';
|
609 |
+
$html .= "<tbody class='cls_tb'>";
|
610 |
+
|
611 |
+
if (!empty($array_input)) {
|
612 |
+
$i = 0;
|
613 |
+
foreach ($array_input as $key => $value) {
|
614 |
+
$i++;
|
615 |
+
$html .= "<tr id='font_setting'><td>";
|
616 |
+
$html .= "<div class='cls_delete_btn cls_delete_btn_selected'>×</div>";
|
617 |
+
$html .= "<input id='fontlist_input' class='fontlist_input' autocomplete='off' value='{$value['fontlist_fontname']}' style='font-family: {$value['fontlist_fontname']}'/>";
|
618 |
+
$html .= "<div class='w_fontlist b_def_fontlist'></div>";
|
619 |
+
$html .= "</td>";
|
620 |
+
$html .= "<td class='add_class_td'><input type='text' class='class_input' value=''/><button type='button' id='add_box' class='add_box'>追加</button>";
|
621 |
+
|
622 |
+
$cls_name = $value['fontlist_cls'];
|
623 |
+
foreach ($cls_name as $cls_value) {
|
624 |
+
$html .= "<p class='add_class_label'>{$cls_value} ×";
|
625 |
+
$html .= "<input name='fontlist_cls{$i}[]' type='hidden' value='{$cls_value}' />";
|
626 |
+
$html .= "</p>";
|
627 |
+
};
|
628 |
+
|
629 |
+
$html .= "</td>";
|
630 |
+
$html .= "<input value='{$value['fontlist_fontname']}' type='hidden' name='fontlist_fontname{$i}' id='fontlist_select' class='fontlist_select'/>";
|
631 |
+
$html .= "</tr>";
|
632 |
+
};
|
633 |
+
} else {
|
634 |
+
$html .= "<tr id='font_setting'><td>";
|
635 |
+
$html .= "<div class='cls_delete_btn cls_delete_btn_selected'>×</div>";
|
636 |
+
$html .= "<input id='fontlist_input' class='fontlist_input' autocomplete='off' placeholder='未設定'>";
|
637 |
+
$html .= "<div class='w_fontlist'><ul class='font_select_menu'></ul></div>";
|
638 |
+
$html .= "</td>";
|
639 |
+
$html .= "<td class='add_class_td'><input type='text' class='class_input' value=''/><button type='button' id='add_box' class='add_box'>追加</button></td>";
|
640 |
+
$html .= "<input value='' type='hidden' name='fontlist_fontname1' id='fontlist_select' class='fontlist_select'/>";
|
641 |
+
$html .= "</tr>";
|
642 |
+
};
|
643 |
+
|
644 |
+
$html .= "<tr id='addbtn_tr'><td>";
|
645 |
+
$html .= "<button type='button' id='input_add_btn'>+</button>";
|
646 |
+
$html .= "</td></tr>";
|
647 |
+
$html .= '</tbody>';
|
648 |
+
$html .= '</table>';
|
649 |
+
$html .= '</div>';
|
650 |
+
$html .= wp_nonce_field('ts_update_font_pro_settings', 'ts_update_font_pro_settings', true, false);
|
651 |
+
return $html;
|
652 |
+
}
|
653 |
+
|
654 |
+
//フォント自動読み込み設定
|
655 |
+
private function _get_auto_load_font_form()
|
656 |
+
{
|
657 |
+
$option_name = 'typesquare_fonttheme';
|
658 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
659 |
+
$param = $fonts->get_fonttheme_params();
|
660 |
+
$keys = $param['typesquare_themes_keys'];
|
661 |
+
$html = "<tr><th>{$keys['auto_load_font']}</th><td>";
|
662 |
+
$value = esc_attr($param['typesquare_themes']['auto_load_font']);
|
663 |
+
if ($value) {
|
664 |
+
$optional = 'checked';
|
665 |
+
}
|
666 |
+
$html .="<label class='switch__label'><input name='{$option_name}[auto_load_font]'type='checkbox' class='switch__input' id='auto_load_font' value='1' ". checked($value, true, false). "/><span class='switch__content'></span><span class='switch__circle'></span></label><span>有効化する</span>";
|
667 |
+
$html .= '</td></tr>';
|
668 |
+
|
669 |
+
return $html;
|
670 |
+
}
|
671 |
+
|
672 |
+
// 疑似要素フォント読込
|
673 |
+
private function _get_apply_to_pseudo_form()
|
674 |
+
{
|
675 |
+
$option_name = 'typesquare_fonttheme';
|
676 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
677 |
+
$param = $fonts->get_fonttheme_params();
|
678 |
+
$keys = $param['typesquare_themes_keys'];
|
679 |
+
$html = "<tr><th>{$keys['apply_to_pseudo']}</th><td>";
|
680 |
+
$value = esc_attr($param['typesquare_themes']['apply_to_pseudo']);
|
681 |
+
if ($value) {
|
682 |
+
$optional = 'checked';
|
683 |
+
}
|
684 |
+
$html .="<label class='switch__label'><input name='{$option_name}[apply_to_pseudo]'type='checkbox' class='switch__input' id='apply_to_pseudo' value='1' ". checked($value, true, false). "/><span class='switch__content'></span><span class='switch__circle'></span></label><span>有効化する</span>";
|
685 |
+
$html .= '</td></tr>';
|
686 |
+
|
687 |
+
return $html;
|
688 |
+
}
|
689 |
+
|
690 |
+
// 非表示要素フォント読込
|
691 |
+
private function _get_apply_to_hidden_form()
|
692 |
+
{
|
693 |
+
$option_name = 'typesquare_fonttheme';
|
694 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
695 |
+
$param = $fonts->get_fonttheme_params();
|
696 |
+
$keys = $param['typesquare_themes_keys'];
|
697 |
+
$html = "<tr><th>{$keys['apply_to_hidden']}</th><td>";
|
698 |
+
$value = esc_attr($param['typesquare_themes']['apply_to_hidden']);
|
699 |
+
if ($value) {
|
700 |
+
$optional = 'checked';
|
701 |
+
}
|
702 |
+
$html .="<label class='switch__label'><input name='{$option_name}[apply_to_hidden]'type='checkbox' class='switch__input' id='apply_to_hidden' value='1' ". checked($value, true, false). "/><span class='switch__content'></span><span class='switch__circle'></span></label><span>有効化する</span>";
|
703 |
+
$html .= '</td></tr>';
|
704 |
+
|
705 |
+
return $html;
|
706 |
+
}
|
707 |
+
|
708 |
+
private function _update_font_list_form()
|
709 |
+
{
|
710 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
711 |
+
$font_file_path = path_join(TS_PLUGIN_PATH, 'inc/font.json');
|
712 |
+
$settings_timezone = get_option('timezone_string');
|
713 |
+
date_default_timezone_set($settings_timezone);
|
714 |
+
$param = date("y/m/d H:i:s", filemtime($font_file_path));
|
715 |
+
$html = '';
|
716 |
+
$html .= '<div class="block_wrap">';
|
717 |
+
$html .= '<div>';
|
718 |
+
$html .= '<h3 class="block_title">'. __('フォントリストの更新', self::$text_domain). '</h3>';
|
719 |
+
$html .= '</div>';
|
720 |
+
$html .= "<table class='widefat form-table'>";
|
721 |
+
$html .= '<thead>';
|
722 |
+
$html .= "<tr></tr>";
|
723 |
+
$html .= '</thead>';
|
724 |
+
$html .= "<tbody>";
|
725 |
+
$html .= "<tr><td style='width: 1%;' class='fontlist_update'>".get_submit_button(__('フォントリスト更新', self::$text_domain), null, 'updateFontListButton', null)."</td>";
|
726 |
+
$html .= "<td class='update_msg'>最終更新日: ".$param."</td></tr>";
|
727 |
+
$html .= '</tbody>';
|
728 |
+
$html .= '</table>';
|
729 |
+
$html .= '<input type="hidden" name="update_font_list" id="update_font_list" value="off" />';
|
730 |
+
$html .= wp_nonce_field('ts_update_font_list', 'ts_update_font_list', true, false);
|
731 |
+
$html .= '</div>';
|
732 |
+
return $html;
|
733 |
+
}
|
734 |
+
}
|
inc/assets/css/admin.css
CHANGED
@@ -192,10 +192,6 @@ color: #23282d;
|
|
192 |
bottom: 0;
|
193 |
}
|
194 |
|
195 |
-
.toplevel_page_typesquare-admin-menu li:nth-child(4) {
|
196 |
-
display: none;
|
197 |
-
}
|
198 |
-
|
199 |
.tableBorder {
|
200 |
border-top: 1px solid #ddd!important;
|
201 |
border-bottom: 1px solid #ddd!important;
|
192 |
bottom: 0;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
195 |
.tableBorder {
|
196 |
border-top: 1px solid #ddd!important;
|
197 |
border-bottom: 1px solid #ddd!important;
|
inc/class/class.font.data.php
CHANGED
@@ -1,345 +1,373 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
require_once(
|
4 |
-
class TypeSquare_ST_Fonts
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
$font_data = $font_theme->get_fonttheme();
|
23 |
-
if ($font_data['fonttheme']) {
|
24 |
return $font_data['fonttheme'];
|
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 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
if (isset($_POST["fontlist_fontname${i}"]) && !empty($_POST["fontlist_fontname${i}"] && !empty($_POST["fontlist_cls${i}"]))) {
|
327 |
array_push($options, array(
|
328 |
"fontlist_fontname" => $_POST["fontlist_fontname${i}"],
|
329 |
"fontlist_cls" => $_POST["fontlist_cls${i}"],
|
330 |
));
|
331 |
}
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
}
|
|
1 |
<?php
|
2 |
|
3 |
+
require_once(dirname(__FILE__).'/class.fonttheme.php');
|
4 |
+
class TypeSquare_ST_Fonts
|
5 |
+
{
|
6 |
+
private static $instance;
|
7 |
+
private static $text_domain;
|
8 |
+
|
9 |
+
private function __construct()
|
10 |
+
{
|
11 |
+
self::$text_domain = TypeSquare_ST::text_domain();
|
12 |
+
}
|
13 |
+
|
14 |
+
public static function get_instance()
|
15 |
+
{
|
16 |
+
if (! isset(self::$instance)) {
|
17 |
+
$c = __CLASS__;
|
18 |
+
self::$instance = new $c();
|
19 |
+
}
|
20 |
+
return self::$instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function load_all_font_data()
|
24 |
+
{
|
25 |
+
$font_theme = TypeSquare_ST_Fonttheme::get_instance();
|
26 |
$font_data = $font_theme->get_fonttheme();
|
27 |
+
if (isset($font_data['fonttheme'])) {
|
28 |
return $font_data['fonttheme'];
|
29 |
}
|
30 |
+
return $font_data;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function load_coustam_font_data()
|
34 |
+
{
|
35 |
+
$font_theme = TypeSquare_ST_Fonttheme::get_instance();
|
36 |
+
$font_data = $font_theme->get_custom_fonttheme();
|
37 |
+
return $font_data;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function load_font_data($theme = '')
|
41 |
+
{
|
42 |
+
if ('' === $theme || false == $theme || 'false' == $theme) {
|
43 |
+
$theme = $this->get_selected_fonttheme();
|
44 |
+
$theme = $theme['font_theme'];
|
45 |
+
if ('' === $theme || false == $theme || 'false' == $theme) {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
$font_data = $this->load_all_font_data();
|
50 |
+
if (isset($font_data[ $theme ])) {
|
51 |
+
return $font_data[ $theme ]['fonts'];
|
52 |
+
} else {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
public function get_selected_fonttheme()
|
58 |
+
{
|
59 |
+
$fonththeme = $this->get_fonttheme_params();
|
60 |
+
return $fonththeme['typesquare_themes'];
|
61 |
+
}
|
62 |
+
|
63 |
+
public function get_selected_post_fonttheme($post_id)
|
64 |
+
{
|
65 |
+
$meta = get_post_meta($post_id, 'typesquare_fonttheme', true);
|
66 |
+
if (isset($meta['theme'])) {
|
67 |
+
$theme = $meta['theme'];
|
68 |
+
} elseif (isset($meta['fonts'])) {
|
69 |
+
$theme = '';
|
70 |
+
} else {
|
71 |
+
$theme = $meta;
|
72 |
+
}
|
73 |
+
/*
|
74 |
+
if ( '' == $theme || 'false' == $theme ) {
|
75 |
+
$theme = $this->get_selected_fonttheme();
|
76 |
+
$theme = $theme['font_theme'];
|
77 |
+
}
|
78 |
+
*/
|
79 |
+
return $theme;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function get_fadein_time()
|
83 |
+
{
|
84 |
+
$param = $this->get_fonttheme_options();
|
85 |
+
if (isset($param['fade_in']) && $param['fade_in']) {
|
86 |
+
$fade_time = $param['fade_time'];
|
87 |
+
} else {
|
88 |
+
$fade_time = false;
|
89 |
+
}
|
90 |
+
return $fade_time;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function get_auto_load_font()
|
94 |
+
{
|
95 |
+
$param = $this->get_fonttheme_options();
|
96 |
+
if (isset($param['auto_load_font'])) {
|
97 |
+
$auto_load_font = $param['auto_load_font'];
|
98 |
+
} else {
|
99 |
+
$auto_load_font = false;
|
100 |
+
}
|
101 |
+
return $auto_load_font;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function get_apply_to_pseudo()
|
105 |
+
{
|
106 |
+
$param = $this->get_fonttheme_options();
|
107 |
+
if (isset($param['apply_to_pseudo'])) {
|
108 |
+
$apply_to_pseudo = $param['apply_to_pseudo'];
|
109 |
+
} else {
|
110 |
+
$apply_to_pseudo = false;
|
111 |
+
}
|
112 |
+
return $apply_to_pseudo;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
public function get_apply_to_hidden()
|
117 |
+
{
|
118 |
+
$param = $this->get_fonttheme_options();
|
119 |
+
if (isset($param['apply_to_hidden'])) {
|
120 |
+
$apply_to_hidden = $param['apply_to_hidden'];
|
121 |
+
} else {
|
122 |
+
$apply_to_hidden = false;
|
123 |
+
}
|
124 |
+
return $apply_to_hidden;
|
125 |
+
}
|
126 |
+
|
127 |
+
public function get_fonttheme_keys()
|
128 |
+
{
|
129 |
+
return array(
|
130 |
+
'font_theme' => __('フォントテーマ', self::$text_domain),
|
131 |
+
'title_target' => __('見出しタグ', self::$text_domain),
|
132 |
+
'lead_target' => __('リードタグ', self::$text_domain),
|
133 |
+
'text_target' => __('本文タグ', self::$text_domain),
|
134 |
+
'bold_target' => __('強調タグ', self::$text_domain),
|
135 |
+
'fade_in' => __('フェードイン', self::$text_domain),
|
136 |
+
'fade_time' => __('フェード時間', self::$text_domain),
|
137 |
+
'auto_load_font' => __('フォント自動読み込み', self::$text_domain),
|
138 |
+
'script_onload' => __('ロード時動作', self::$text_domain),
|
139 |
+
'apply_to_pseudo' => __('疑似要素フォント読込', self::$text_domain),
|
140 |
+
'apply_to_hidden' => __('非表示要素フォント読込', self::$text_domain),
|
141 |
+
'show_post_form' => __('記事ごとにフォントを設定', self::$text_domain),
|
142 |
+
);
|
143 |
+
}
|
144 |
+
|
145 |
+
public function get_fonttheme_options()
|
146 |
+
{
|
147 |
+
// タイトル
|
148 |
+
$title_base = "h1,h2,h3,h1:lang(ja),h2:lang(ja),h3:lang(ja),.entry-title:lang(ja)";
|
149 |
+
//$title_comment = "#comments h2.comments-title:lang(ja)";
|
150 |
+
//$title_comment_button = "#comments .comment-reply-link:lang(ja)";
|
151 |
+
// リード
|
152 |
+
$lead_base = "h4,h5,h6,h4:lang(ja),h5:lang(ja),h6:lang(ja)";
|
153 |
+
|
154 |
+
$lead_page_header = "div.entry-meta span:lang(ja)";
|
155 |
+
$lead_page_footer = "footer.entry-footer span:lang(ja)";
|
156 |
+
// テキスト
|
157 |
+
$text_base = ".hentry,.entry-content p,.post-inner.entry-content p";
|
158 |
+
$text_comment = "#comments div:lang(ja)";
|
159 |
+
// 強調
|
160 |
+
$bold_base = "strong,b";
|
161 |
+
$bold_comment = "#comments .comment-author .fn:lang(ja)";
|
162 |
+
|
163 |
+
$default_param = array(
|
164 |
+
'font_theme' => false,
|
165 |
+
'title_target' => "{$title_base}",
|
166 |
+
'lead_target' => "{$lead_base},{$lead_page_header},{$lead_page_footer}",
|
167 |
+
'text_target' => "{$text_base},{$text_comment}",
|
168 |
+
'bold_target' => "{$bold_base},{$bold_comment}",
|
169 |
+
'fade_in' => true,
|
170 |
+
'fade_time' => 0,
|
171 |
+
'auto_load_font' => false,
|
172 |
+
'script_onload' => false,
|
173 |
+
'apply_to_pseudo' => true,
|
174 |
+
'apply_to_hidden' => false,
|
175 |
+
'show_post_form' => false,
|
176 |
+
);
|
177 |
+
|
178 |
+
$option_name = 'typesquare_fonttheme';
|
179 |
+
$param = get_option($option_name);
|
180 |
+
|
181 |
+
if (isset($param['fonts'])) {
|
182 |
+
unset($param['fonts']);
|
183 |
+
}
|
184 |
+
if (! isset($param['show_post_form'])) {
|
185 |
+
$param['show_post_form'] = false;
|
186 |
+
}
|
187 |
+
if (! $param) {
|
188 |
+
$param = $default_param;
|
189 |
+
} else {
|
190 |
+
foreach ($default_param as $key => $value) {
|
191 |
+
if (! isset($param[ $key ])) {
|
192 |
+
$param[ $key ] = $value;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
// paramの中に選択したフォントのvalue値は入っている
|
197 |
+
return $param;
|
198 |
+
}
|
199 |
+
|
200 |
+
public function get_fonttheme_params()
|
201 |
+
{
|
202 |
+
$param['typesquare_themes'] = $this->get_fonttheme_options();
|
203 |
+
$param['typesquare_themes_keys'] = $this->get_fonttheme_keys();
|
204 |
+
return $param;
|
205 |
+
}
|
206 |
+
|
207 |
+
public function update_font_setting()
|
208 |
+
{
|
209 |
+
if (! isset($_POST['typesquare_custom_theme'])) {
|
210 |
+
return;
|
211 |
+
}
|
212 |
+
|
213 |
+
$options = get_option('typesquare_custom_theme');
|
214 |
+
$options = $this->parse_font_setting_param($options, $_POST['typesquare_custom_theme']);
|
215 |
+
|
216 |
+
if (isset($options['theme']['']['id'])) {
|
217 |
+
$this->update_font_theme_setting();
|
218 |
+
} else {
|
219 |
+
update_option('typesquare_custom_theme', $options);
|
220 |
+
}
|
221 |
+
$result = __('フォントテーマの設定に成功しました。', self::$text_domain);
|
222 |
+
$this->show_result($result);
|
223 |
+
}
|
224 |
+
|
225 |
+
public function delete_custom_theme()
|
226 |
+
{
|
227 |
+
if (! isset($_POST['typesquare_custom_theme'])) {
|
228 |
+
return;
|
229 |
+
}
|
230 |
+
$options = get_option('typesquare_custom_theme');
|
231 |
+
$id = $_POST['typesquare_custom_theme']['id'];
|
232 |
+
unset($options['theme'][ $id ]);
|
233 |
+
unset($options['fonts'][ $id ]);
|
234 |
+
update_option('typesquare_custom_theme', $options);
|
235 |
+
$result = __('フォントテーマの削除に成功しました。', self::$text_domain);
|
236 |
+
$this->show_result($result);
|
237 |
+
}
|
238 |
+
|
239 |
+
public function show_result($result)
|
240 |
+
{
|
241 |
+
$html = "<div class='notice updated'><ul>";
|
242 |
+
$html .= "<li>{$result}</li>";
|
243 |
+
$html .= '</ul></div>';
|
244 |
+
echo $html;
|
245 |
+
}
|
246 |
+
|
247 |
+
public function parse_font_setting_param($current, $param)
|
248 |
+
{
|
249 |
+
$name = esc_attr($param['name']);
|
250 |
+
$id = (string) esc_attr($param['id']);
|
251 |
+
$current['theme'][ $id ]['name'] = $name;
|
252 |
+
$current['theme'][ $id ]['id'] = $id;
|
253 |
+
foreach ($param['fonts'] as $type => $font) {
|
254 |
+
$type = esc_attr($type);
|
255 |
+
foreach ($font as $key => $value) {
|
256 |
+
if ('false' == $value) {
|
257 |
+
unset($current['theme'][ $id ]['fonts'][ $type ]);
|
258 |
+
unset($current['fonts'][ $id ][ $type ]);
|
259 |
+
continue;
|
260 |
+
}
|
261 |
+
$key = (string) esc_attr($key);
|
262 |
+
$current['fonts'][ $id ][ $type ][ $key ] = esc_attr($value);
|
263 |
+
$current['theme'][ $id ]['fonts'][ $type ] = esc_attr($value);
|
264 |
+
}
|
265 |
+
}
|
266 |
+
return $current;
|
267 |
+
}
|
268 |
+
|
269 |
+
public function update_typesquare_settings()
|
270 |
+
{
|
271 |
+
if (! isset($_POST['typesquare_fonttheme'])) {
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
$options = get_option('typesquare_fonttheme');
|
275 |
+
foreach ($_POST['typesquare_fonttheme'] as $key => $target) {
|
276 |
+
$key = esc_attr($key);
|
277 |
+
$options[ $key ] = esc_attr($target);
|
278 |
+
}
|
279 |
+
if (isset($_POST['typesquare_fonttheme']['fade_time'])) {
|
280 |
+
if (! isset($_POST['typesquare_fonttheme']['fade_in'])) {
|
281 |
+
$options['fade_in'] = false;
|
282 |
+
}
|
283 |
+
}
|
284 |
+
if (! isset($_POST['typesquare_fonttheme']['auto_load_font'])) {
|
285 |
+
$options['auto_load_font'] = false;
|
286 |
+
}
|
287 |
+
|
288 |
+
if (! isset($_POST['typesquare_fonttheme']['apply_to_pseudo'])) {
|
289 |
+
$options['apply_to_pseudo'] = false;
|
290 |
+
}
|
291 |
+
|
292 |
+
if (! isset($_POST['typesquare_fonttheme']['apply_to_hidden'])) {
|
293 |
+
$options['apply_to_hidden'] = false;
|
294 |
+
}
|
295 |
+
update_option('typesquare_fonttheme', $options);
|
296 |
+
}
|
297 |
+
|
298 |
+
public function disable_font_theme_setting()
|
299 |
+
{
|
300 |
+
if (! isset($_POST['typesquare_fonttheme'])) {
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
$options = get_option('typesquare_fonttheme');
|
304 |
+
$options['font_theme'] = false;
|
305 |
+
update_option('typesquare_fonttheme', $options);
|
306 |
+
}
|
307 |
+
|
308 |
+
public function update_font_theme_setting()
|
309 |
+
{
|
310 |
+
if (! isset($_POST['typesquare_fonttheme'])) {
|
311 |
+
return;
|
312 |
+
}
|
313 |
+
$options = get_option('typesquare_fonttheme');
|
314 |
+
foreach ($_POST['typesquare_fonttheme'] as $key => $target) {
|
315 |
+
$key = esc_attr($key);
|
316 |
+
$options[ $key ] = esc_attr($target);
|
317 |
+
}
|
318 |
+
update_option('typesquare_fonttheme', $options);
|
319 |
+
}
|
320 |
+
|
321 |
+
public function update_show_post_form($status)
|
322 |
+
{
|
323 |
+
$options = get_option('typesquare_fonttheme');
|
324 |
+
$options['show_post_form'] = $status;
|
325 |
+
update_option('typesquare_fonttheme', $options);
|
326 |
+
}
|
327 |
+
|
328 |
+
public function get_site_font_setting()
|
329 |
+
{
|
330 |
+
return get_option('typesquare_site_font_setting');
|
331 |
+
}
|
332 |
+
|
333 |
+
public function update_site_font_setting()
|
334 |
+
{
|
335 |
+
$options = array(
|
336 |
+
"title_fontname" => isset($_POST["title_fontname"]) ? $_POST["title_fontname"] : "",
|
337 |
+
"catchcopy_fontname" => isset($_POST["catchcopy_fontname"]) ? $_POST["catchcopy_fontname"] : "",
|
338 |
+
"widget_title_fontname" => isset($_POST["widget_title_fontname"]) ? $_POST["widget_title_fontname"] : "",
|
339 |
+
"widget_fontname" => isset($_POST["widget_fontname"]) ? $_POST["widget_fontname"] : "",
|
340 |
+
);
|
341 |
+
update_option('typesquare_site_font_setting', $options);
|
342 |
+
}
|
343 |
+
|
344 |
+
public function get_font_pro_setting()
|
345 |
+
{
|
346 |
+
return get_option('typesquare_pro_setting');
|
347 |
+
}
|
348 |
+
|
349 |
+
public function update_font_pro_setting()
|
350 |
+
{
|
351 |
+
$options = array();
|
352 |
+
for ($i=1; $i < 20; $i++) {
|
353 |
if (isset($_POST["fontlist_fontname${i}"]) && !empty($_POST["fontlist_fontname${i}"] && !empty($_POST["fontlist_cls${i}"]))) {
|
354 |
array_push($options, array(
|
355 |
"fontlist_fontname" => $_POST["fontlist_fontname${i}"],
|
356 |
"fontlist_cls" => $_POST["fontlist_cls${i}"],
|
357 |
));
|
358 |
}
|
359 |
+
}
|
360 |
+
update_option('typesquare_pro_setting', $options);
|
361 |
+
}
|
362 |
+
|
363 |
+
public function get_selected_font($type)
|
364 |
+
{
|
365 |
+
$font = false;
|
366 |
+
$param = $this->get_fonttheme_options();
|
367 |
+
if (! isset($param['fonts']) || ! isset($param['fonts'][ $type ])) {
|
368 |
+
return $font;
|
369 |
+
}
|
370 |
+
$font = $param['fonts'][ $type ]['font'];
|
371 |
+
return $font;
|
372 |
+
}
|
373 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: sakurainternet
|
|
3 |
Donate link:
|
4 |
Tags: font
|
5 |
Requires at least: 4.3.1
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -68,7 +68,7 @@ UD新ゴ R/UD新ゴ M/UD新ゴ コンデンス90 L/UD新ゴ コンデン
|
|
68 |
|
69 |
== Frequently asked questions ==
|
70 |
|
71 |
-
よくある質問については、さくらのレンタルサーバの[サポートサイト](https://help.sakura.ad.jp/
|
72 |
|
73 |
== Screenshots ==
|
74 |
1. screenshot-1.png
|
@@ -94,6 +94,9 @@ UD新ゴ R/UD新ゴ M/UD新ゴ コンデンス90 L/UD新ゴ コンデン
|
|
94 |
|
95 |
3.0.0:追加3書体を利用できる機能を追加し、ユーザビリティも改善いたしました
|
96 |
|
|
|
|
|
|
|
97 |
== Upgrade notice ==
|
98 |
|
99 |
-
== Arbitrary section 1 ==
|
3 |
Donate link:
|
4 |
Tags: font
|
5 |
Requires at least: 4.3.1
|
6 |
+
Tested up to: 5.8.0
|
7 |
+
Stable tag: 3.1.0
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
68 |
|
69 |
== Frequently asked questions ==
|
70 |
|
71 |
+
よくある質問については、さくらのレンタルサーバの[サポートサイト](https://help.sakura.ad.jp/360000210142/)をご確認ください。
|
72 |
|
73 |
== Screenshots ==
|
74 |
1. screenshot-1.png
|
94 |
|
95 |
3.0.0:追加3書体を利用できる機能を追加し、ユーザビリティも改善いたしました
|
96 |
|
97 |
+
3.1.0:PHP8に対応しました。リュウミンが選択できない場合があるバグを修正
|
98 |
+
|
99 |
+
|
100 |
== Upgrade notice ==
|
101 |
|
102 |
+
== Arbitrary section 1 ==
|
screenshot-1.jpg
DELETED
Binary file
|
ts-webfonts-for-sakura.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: TS Webfonts for SAKURA RS
|
4 |
-
Version: 3.
|
5 |
Description: さくらのレンタルサーバで株式会社モリサワ提供のWebフォント33書体が無料で利用できるプラグインです。
|
6 |
Author: SAKURA Internet Inc.
|
7 |
Author URI: http://www.sakura.ne.jp/
|
@@ -10,337 +10,357 @@ Text Domain: ts-webfonts-for-sakura
|
|
10 |
Domain Path: /languages
|
11 |
*/
|
12 |
|
13 |
-
require_once(
|
14 |
-
require_once(
|
15 |
-
require_once(
|
16 |
-
require_once(
|
17 |
-
define(
|
18 |
-
define(
|
19 |
$ts = TypeSquare_ST::get_instance();
|
20 |
$ts->add_hook();
|
21 |
$admin = TypeSquare_Admin::get_instance();
|
22 |
$admin->add_hook();
|
23 |
|
24 |
-
class TypeSquare_ST
|
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 |
-
$post_theme = $fonts->get_selected_post_fonttheme( get_the_ID() );
|
162 |
-
$post_theme = $fonts->load_font_data( $post_theme );
|
163 |
-
if ( $post_theme ) {
|
164 |
-
$use_font = $post_theme;
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
$style = $this->_get_font_styles( $use_font, $fonttheme );
|
169 |
-
}
|
170 |
-
|
171 |
-
if ( $style ) {
|
172 |
-
$html = "<style type='text/css'>{$style}</style>";
|
173 |
-
echo $html;
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
public function get_archive_font_styles( $query ) {
|
178 |
-
if ( is_admin() || ! $query->is_main_query() || is_singular() ) {
|
179 |
-
return;
|
180 |
-
}
|
181 |
-
$auth = TypeSquare_ST_Auth::get_instance();
|
182 |
-
$param = $auth->get_auth_status();
|
183 |
-
if ( '' === $param['typesquare_id'] ) {
|
184 |
-
return;
|
185 |
-
}
|
186 |
-
|
187 |
-
$fonts = TypeSquare_ST_Fonts::get_instance();
|
188 |
-
|
189 |
-
$this->styles = "";
|
190 |
-
$site_style = $this->_get_site_font_styles();
|
191 |
-
if (!empty($site_style)) {
|
192 |
-
$this->styles = "<style type='text/css'>{$site_style}</style>";
|
193 |
-
}
|
194 |
-
|
195 |
-
$fonttheme = $fonts->get_selected_fonttheme();
|
196 |
-
if ( ! isset( $fonttheme ) && ! $fonttheme ) {
|
197 |
-
return;
|
198 |
-
}
|
199 |
-
$font_param = $fonts->get_fonttheme_params();
|
200 |
-
$use_font = $fonts->load_font_data( $fonttheme['font_theme'] );
|
201 |
-
$font_pro_settings = $fonts->get_font_pro_setting();
|
202 |
if ($font_pro_settings && $param['fontThemeUseType'] == 4) {
|
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 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
// クラシックエディタにフォントリスト追加
|
@@ -354,24 +374,22 @@ class TypeSquare_ST {
|
|
354 |
// return $plugins;
|
355 |
// } );
|
356 |
|
357 |
-
add_filter(
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
}
|
376 |
-
|
377 |
-
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: TS Webfonts for SAKURA RS
|
4 |
+
Version: 3.1.0
|
5 |
Description: さくらのレンタルサーバで株式会社モリサワ提供のWebフォント33書体が無料で利用できるプラグインです。
|
6 |
Author: SAKURA Internet Inc.
|
7 |
Author URI: http://www.sakura.ne.jp/
|
10 |
Domain Path: /languages
|
11 |
*/
|
12 |
|
13 |
+
require_once(dirname(__FILE__).'/typesquare-admin.php');
|
14 |
+
require_once(dirname(__FILE__).'/inc/class/class.font.data.php');
|
15 |
+
require_once(dirname(__FILE__).'/inc/class/class.auth.php');
|
16 |
+
require_once(dirname(__FILE__).'/inc/class/class.api.php');
|
17 |
+
define('TS_PLUGIN_PATH', plugin_dir_path(__FILE__));
|
18 |
+
define('TS_PLUGIN_URL', plugin_dir_url(__FILE__));
|
19 |
$ts = TypeSquare_ST::get_instance();
|
20 |
$ts->add_hook();
|
21 |
$admin = TypeSquare_Admin::get_instance();
|
22 |
$admin->add_hook();
|
23 |
|
24 |
+
class TypeSquare_ST
|
25 |
+
{
|
26 |
+
private static $instance;
|
27 |
+
private $styles = false;
|
28 |
+
const OPTION_NAME = 'ts_settings';
|
29 |
+
private function __construct()
|
30 |
+
{
|
31 |
+
}
|
32 |
+
|
33 |
+
public static function get_instance()
|
34 |
+
{
|
35 |
+
if (! isset(self::$instance)) {
|
36 |
+
$c = __CLASS__;
|
37 |
+
self::$instance = new $c();
|
38 |
+
}
|
39 |
+
return self::$instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function add_hook()
|
43 |
+
{
|
44 |
+
add_action('wp_enqueue_scripts', array( $this, 'load_scripts' ), 0, 3);
|
45 |
+
add_action('wp_head', array( $this, 'load_font_styles' ));
|
46 |
+
add_action('pre_get_posts', array( $this, 'get_archive_font_styles' ));
|
47 |
+
}
|
48 |
+
|
49 |
+
public static function version()
|
50 |
+
{
|
51 |
+
static $version;
|
52 |
+
|
53 |
+
if (! $version) {
|
54 |
+
$data = get_file_data(__FILE__, array( 'version' => 'Version' ));
|
55 |
+
$version = $data['version'];
|
56 |
+
}
|
57 |
+
return $version;
|
58 |
+
}
|
59 |
+
|
60 |
+
public static function text_domain()
|
61 |
+
{
|
62 |
+
static $text_domain;
|
63 |
+
|
64 |
+
if (! $text_domain) {
|
65 |
+
$data = get_file_data(__FILE__, array( 'text_domain' => 'Text Domain' ));
|
66 |
+
$text_domain = $data['text_domain'];
|
67 |
+
}
|
68 |
+
return $text_domain;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function load_scripts()
|
72 |
+
{
|
73 |
+
$query = '';
|
74 |
+
$uid = str_replace('%', '%25', $this->get_user_id());
|
75 |
+
$version = $this->version();
|
76 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
77 |
+
$fade_in = $fonts->get_fadein_time();
|
78 |
+
$auto_load_font = $fonts->get_auto_load_font();
|
79 |
+
$apply_to_pseudo = $fonts->get_apply_to_pseudo();
|
80 |
+
$apply_to_hidden = $fonts->get_apply_to_hidden();
|
81 |
+
|
82 |
+
if (false !== $fade_in) {
|
83 |
+
$query .= "&fadein={$fade_in}";
|
84 |
+
} else {
|
85 |
+
$query .= "&fadein=-1";
|
86 |
+
}
|
87 |
+
|
88 |
+
if (false !== $auto_load_font) {
|
89 |
+
$query .= "&auto_load_font=true";
|
90 |
+
}
|
91 |
+
|
92 |
+
if (false === $apply_to_pseudo) {
|
93 |
+
$query .= "&apply_to_pseudo=false";
|
94 |
+
}
|
95 |
+
|
96 |
+
if (false !== $apply_to_hidden) {
|
97 |
+
$query .= "&apply_to_hidden=true";
|
98 |
+
}
|
99 |
+
|
100 |
+
if (false !== $uid) {
|
101 |
+
wp_register_script('typesquare_std', "//webfonts.sakura.ne.jp/js/sakurav3.js?$query", array( 'jquery' ), $version, false);
|
102 |
+
wp_enqueue_script('typesquare_std');
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
private function get_user_id()
|
107 |
+
{
|
108 |
+
$auth = TypeSquare_ST_Auth::get_instance();
|
109 |
+
$param = $auth->get_auth_status();
|
110 |
+
return $param['typesquare_id'];
|
111 |
+
}
|
112 |
+
|
113 |
+
private function get_fonts($type = false, $post_font_data = false, $fonts = false)
|
114 |
+
{
|
115 |
+
$font_class = TypeSquare_ST_Fonts::get_instance();
|
116 |
+
$selected_font = $font_class->get_selected_font($type);
|
117 |
+
|
118 |
+
if ($selected_font) {
|
119 |
+
$fonts = $selected_font;
|
120 |
+
}
|
121 |
+
if ($post_font_data) {
|
122 |
+
if (isset($post_font_data[ $type ])) {
|
123 |
+
$fonts = $post_font_data[ $type ]['font'];
|
124 |
+
}
|
125 |
+
}
|
126 |
+
if (is_array($fonts)) {
|
127 |
+
$text_font = '';
|
128 |
+
foreach ($fonts as $key => $font) {
|
129 |
+
$text_font .= '"'. esc_attr($font). '"';
|
130 |
+
if (count($fonts) - 1 > $key) {
|
131 |
+
$text_font .= ',';
|
132 |
+
}
|
133 |
+
}
|
134 |
+
} else {
|
135 |
+
$text_font = '"'. esc_attr($fonts). '"';
|
136 |
+
}
|
137 |
+
return $text_font;
|
138 |
+
}
|
139 |
+
|
140 |
+
public function load_font_styles()
|
141 |
+
{
|
142 |
+
if (is_archive() || is_home()) {
|
143 |
+
if ($this->styles) {
|
144 |
+
echo $this->styles;
|
145 |
+
}
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
$auth = TypeSquare_ST_Auth::get_instance();
|
149 |
+
$param = $auth->get_auth_status();
|
150 |
+
if ('' === $param['typesquare_id']) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
$site_style = $this->_get_site_font_styles();
|
155 |
+
if (!empty($site_style)) {
|
156 |
+
echo "<style type='text/css'>{$site_style}</style>\n";
|
157 |
+
}
|
158 |
+
|
159 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
160 |
+
$font_pro_settings = $fonts->get_font_pro_setting();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
if ($font_pro_settings && $param['fontThemeUseType'] == 4) {
|
162 |
+
$style = $this->_get_pro_font_styles($font_pro_settings);
|
163 |
+
} else {
|
164 |
+
$fonttheme = $fonts->get_selected_fonttheme();
|
165 |
+
if (! isset($fonttheme) && ! $fonttheme) {
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
$use_font = $fonts->load_font_data($fonttheme['font_theme']);
|
169 |
+
if (is_singular()) {
|
170 |
+
$param = $fonts->get_fonttheme_params();
|
171 |
+
if (isset($param['typesquare_themes']['show_post_form']) && 'false' != $param['typesquare_themes']['show_post_form']) {
|
172 |
+
$post_theme = $fonts->get_selected_post_fonttheme(get_the_ID());
|
173 |
+
$post_theme = $fonts->load_font_data($post_theme);
|
174 |
+
if ($post_theme) {
|
175 |
+
$use_font = $post_theme;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
$style = $this->_get_font_styles($use_font, $fonttheme);
|
180 |
+
}
|
181 |
+
|
182 |
+
if ($style) {
|
183 |
+
$html = "<style type='text/css'>{$style}</style>";
|
184 |
+
echo $html;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
public function get_archive_font_styles($query)
|
189 |
+
{
|
190 |
+
if (is_admin() || ! $query->is_main_query() || is_singular()) {
|
191 |
+
return;
|
192 |
+
}
|
193 |
+
$auth = TypeSquare_ST_Auth::get_instance();
|
194 |
+
$param = $auth->get_auth_status();
|
195 |
+
if ('' === $param['typesquare_id']) {
|
196 |
+
return;
|
197 |
+
}
|
198 |
+
|
199 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
200 |
+
|
201 |
+
$this->styles = "";
|
202 |
+
$site_style = $this->_get_site_font_styles();
|
203 |
+
if (!empty($site_style)) {
|
204 |
+
$this->styles = "<style type='text/css'>{$site_style}</style>";
|
205 |
+
}
|
206 |
+
|
207 |
+
$fonttheme = $fonts->get_selected_fonttheme();
|
208 |
+
if (! isset($fonttheme) && ! $fonttheme) {
|
209 |
+
return;
|
210 |
+
}
|
211 |
+
$font_param = $fonts->get_fonttheme_params();
|
212 |
+
$use_font = $fonts->load_font_data($fonttheme['font_theme']);
|
213 |
+
$font_pro_settings = $fonts->get_font_pro_setting();
|
214 |
+
if ($font_pro_settings && $param['fontThemeUseType'] == 4) {
|
215 |
+
$style = $this->_get_pro_font_styles($font_pro_settings);
|
216 |
+
$this->styles .= "<style type='text/css'>{$style}</style>";
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
|
220 |
+
if (! $query->query) {
|
221 |
+
$query->query = apply_filters('ts-default-query', array(
|
222 |
+
'post_type' => 'post',
|
223 |
+
));
|
224 |
+
}
|
225 |
+
|
226 |
+
$the_query = new WP_Query($query->query);
|
227 |
+
$style = "";
|
228 |
+
while ($the_query->have_posts()) : $the_query->the_post();
|
229 |
+
$id = get_the_ID();
|
230 |
+
if (isset($font_param['typesquare_themes']['show_post_form']) && 'false' != $font_param['typesquare_themes']['show_post_form']) {
|
231 |
+
$post_theme = $fonts->get_selected_post_fonttheme($id);
|
232 |
+
$post_theme = $fonts->load_font_data($post_theme);
|
233 |
+
if ($post_theme) {
|
234 |
+
$use_font = $post_theme;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
$style .= $this->_get_font_styles($use_font, $fonttheme, $id);
|
238 |
+
endwhile;
|
239 |
+
|
240 |
+
if ($style) {
|
241 |
+
$this->styles .= "<style type='text/css'>{$style}</style>";
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
private function _merge_post_id_to_target($post_key, $target_text)
|
246 |
+
{
|
247 |
+
$target_list = explode(',', $target_text);
|
248 |
+
$merged_target = false;
|
249 |
+
foreach ($target_list as $target) {
|
250 |
+
if ('.hentry' == $target) {
|
251 |
+
$merged_target .= "{$post_key}{$target},";
|
252 |
+
} else {
|
253 |
+
$merged_target .= "{$post_key} {$target},";
|
254 |
+
}
|
255 |
+
}
|
256 |
+
$merged_target = rtrim($merged_target, ',');
|
257 |
+
return $merged_target;
|
258 |
+
}
|
259 |
+
|
260 |
+
private function _get_font_styles($use_font, $fonttheme, $post_id = false, $post_font_data = false)
|
261 |
+
{
|
262 |
+
$style = '';
|
263 |
+
if ($post_id) {
|
264 |
+
$post_key = '#post-'. $post_id;
|
265 |
+
$title_target = $this->_merge_post_id_to_target($post_key, esc_attr($fonttheme['title_target']));
|
266 |
+
$lead_target = $this->_merge_post_id_to_target($post_key, esc_attr($fonttheme['lead_target']));
|
267 |
+
$text_target = $this->_merge_post_id_to_target($post_key, esc_attr($fonttheme['text_target']));
|
268 |
+
$bold_target = $this->_merge_post_id_to_target($post_key, esc_attr($fonttheme['bold_target']));
|
269 |
+
} else {
|
270 |
+
$title_target = esc_attr($fonttheme['title_target']);
|
271 |
+
$lead_target = esc_attr($fonttheme['lead_target']);
|
272 |
+
$text_target = esc_attr($fonttheme['text_target']);
|
273 |
+
$bold_target = esc_attr($fonttheme['bold_target']);
|
274 |
+
}
|
275 |
+
|
276 |
+
$title_font = $lead_font = $text_font = $bold_font = false;
|
277 |
+
if (isset($use_font['title'])) {
|
278 |
+
$title_font = $this->get_fonts('title', $post_font_data, $use_font['title']);
|
279 |
+
}
|
280 |
+
if (isset($use_font['lead'])) {
|
281 |
+
$lead_font = $this->get_fonts('lead', $post_font_data, $use_font['lead']);
|
282 |
+
}
|
283 |
+
if (! isset($use_font['content']) && isset($use_font['text'])) {
|
284 |
+
$use_font['content'] = $use_font['text'];
|
285 |
+
}
|
286 |
+
if (isset($use_font['content'])) {
|
287 |
+
$text_font = $this->get_fonts('text', $post_font_data, $use_font['content']);
|
288 |
+
}
|
289 |
+
if (isset($use_font['bold'])) {
|
290 |
+
$bold_font = $this->get_fonts('bold', $post_font_data, $use_font['bold']);
|
291 |
+
}
|
292 |
+
|
293 |
+
if ($title_target && $title_font) {
|
294 |
+
$style .= "{$title_target}{ font-family: {$title_font};}";
|
295 |
+
}
|
296 |
+
if ($lead_target && $lead_font) {
|
297 |
+
$style .= "{$lead_target}{ font-family: {$lead_font};}";
|
298 |
+
}
|
299 |
+
if ($text_target && $text_font) {
|
300 |
+
$style .= "{$text_target}{ font-family: {$text_font};}";
|
301 |
+
}
|
302 |
+
if ($bold_target && $bold_font) {
|
303 |
+
$style .= "{$bold_target}{ font-family: {$bold_font};}";
|
304 |
+
}
|
305 |
+
|
306 |
+
return $style;
|
307 |
+
}
|
308 |
+
|
309 |
+
private function _get_site_font_styles()
|
310 |
+
{
|
311 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
312 |
+
$site_font_settings = $fonts->get_site_font_setting();
|
313 |
+
$title_fontname = '';
|
314 |
+
$catchcopy_fontname = '';
|
315 |
+
$widget_title_fontname = '';
|
316 |
+
$widget_fontname = '';
|
317 |
+
if (is_array($site_font_settings)) {
|
318 |
+
$title_fontname = $site_font_settings['title_fontname'];
|
319 |
+
$catchcopy_fontname = $site_font_settings['catchcopy_fontname'];
|
320 |
+
$widget_title_fontname = $site_font_settings['widget_title_fontname'];
|
321 |
+
$widget_fontname = $site_font_settings['widget_fontname'];
|
322 |
+
}
|
323 |
+
$style = '';
|
324 |
+
if ($title_fontname) {
|
325 |
+
$title_target = ".site-branding .site-title a:lang(ja),.site-title";
|
326 |
+
$style .= "{$title_target}{ font-family: '{$title_fontname}';}";
|
327 |
+
}
|
328 |
+
if ($catchcopy_fontname) {
|
329 |
+
$catchcopy_target = ".site-description:lang(ja)";
|
330 |
+
$style .= "{$catchcopy_target}{ font-family: '{$catchcopy_fontname}';}";
|
331 |
+
}
|
332 |
+
if ($widget_title_fontname) {
|
333 |
+
$widget_title_target = "section.widget h2:lang(ja),.widget-title";
|
334 |
+
$style .= "{$widget_title_target}{ font-family: '{$widget_title_fontname}';}";
|
335 |
+
}
|
336 |
+
if ($widget_fontname) {
|
337 |
+
$widget_target = "section.widget ul li:lang(ja),.widget-content ul li";
|
338 |
+
$style .= "{$widget_target}{ font-family: '{$widget_fontname}';}";
|
339 |
+
}
|
340 |
+
|
341 |
+
return $style;
|
342 |
+
}
|
343 |
+
|
344 |
+
private function _get_pro_font_styles($font_pro_settings, $post_id = false)
|
345 |
+
{
|
346 |
+
$style = '';
|
347 |
+
foreach ($font_pro_settings as $font_pro_setting) {
|
348 |
+
foreach ($font_pro_setting['fontlist_cls'] as $fontlist_cls) {
|
349 |
+
$target = esc_attr($fontlist_cls);
|
350 |
+
if ($post_id) {
|
351 |
+
$post_key = '#post-'. $post_id;
|
352 |
+
if ('.hentry' == $target) {
|
353 |
+
$target = "{$post_key}{$target}";
|
354 |
+
} else {
|
355 |
+
$target = "{$post_key} {$target}";
|
356 |
+
}
|
357 |
+
}
|
358 |
+
$fontf_amily = $font_pro_setting['fontlist_fontname'];
|
359 |
+
$style .= "{$target}{ font-family: '{$fontf_amily}';}";
|
360 |
+
}
|
361 |
+
}
|
362 |
+
return $style;
|
363 |
+
}
|
364 |
}
|
365 |
|
366 |
// クラシックエディタにフォントリスト追加
|
374 |
// return $plugins;
|
375 |
// } );
|
376 |
|
377 |
+
add_filter('mce_buttons', function ($buttons) {
|
378 |
+
$auth = TypeSquare_ST_Auth::get_instance();
|
379 |
+
$param = $auth->get_auth_status();
|
380 |
+
if ('' !== $param['typesquare_id']) {
|
381 |
+
$buttons[] = 'fontfamily_button';
|
382 |
+
}
|
383 |
+
return $buttons;
|
384 |
+
});
|
385 |
+
|
386 |
+
register_uninstall_hook(__FILE__, 'ts_uninstall');
|
387 |
+
function ts_uninstall()
|
388 |
+
{
|
389 |
+
delete_option('typesquare_auth');
|
390 |
+
delete_option('typesquare_fonttheme');
|
391 |
+
delete_option('typesquare_custom_theme');
|
392 |
+
delete_option('typesquare_pro_setting');
|
393 |
+
delete_option('typesquare_site_font_setting');
|
394 |
+
return;
|
395 |
+
}
|
|
|
|