Version Description
- Added
'ssp_replace_snippet_{snippet_name}'
hook. (You can now define custom snippets) - Changed some snippet names. (The previous snippet name also works.)
- Changed settings for Post Format archives to only show when Post Format support is enabled.
- Refactored the code.
Download this release
Release Info
Developer | looswebstudio |
Plugin | SEO SIMPLE PACK |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.1 to 3.0.0
- class/data.php +3 -3
- class/hooks.php +2 -1
- class/output.php +135 -202
- class/trait/field.php +68 -59
- class/trait/output_helper.php +102 -91
- dist/css/ssp.css +1 -1
- inc/page_help.php +69 -23
- inc/tab/top_taxonomy.php +28 -25
- readme.txt +7 -2
- seo-simple-pack.php +1 -1
- src/scss/inc/_help.scss +29 -4
class/data.php
CHANGED
@@ -152,14 +152,14 @@ class SSP_Data {
|
|
152 |
'attachment_title' => '%_page_title_% %_sep_% %_site_title_%',
|
153 |
'attachment_desc' => '%_page_contents_%',
|
154 |
'cat_noindex' => false,
|
155 |
-
'cat_title' => '%
|
156 |
'cat_desc' => '%_term_description_%',
|
157 |
'tag_noindex' => false,
|
158 |
-
'tag_title' => '%
|
159 |
'tag_desc' => '%_term_description_%',
|
160 |
'post_format_disable' => false,
|
161 |
'post_format_noindex' => true,
|
162 |
-
'post_format_title' => '%
|
163 |
'post_format_desc' => '',
|
164 |
'author_disable' => false,
|
165 |
'author_noindex' => true,
|
152 |
'attachment_title' => '%_page_title_% %_sep_% %_site_title_%',
|
153 |
'attachment_desc' => '%_page_contents_%',
|
154 |
'cat_noindex' => false,
|
155 |
+
'cat_title' => '%_term_name_% %_sep_% %_site_title_%',
|
156 |
'cat_desc' => '%_term_description_%',
|
157 |
'tag_noindex' => false,
|
158 |
+
'tag_title' => '%_term_name_% %_sep_% %_site_title_%',
|
159 |
'tag_desc' => '%_term_description_%',
|
160 |
'post_format_disable' => false,
|
161 |
'post_format_noindex' => true,
|
162 |
+
'post_format_title' => '%_term_name_% %_sep_% %_site_title_%',
|
163 |
'post_format_desc' => '',
|
164 |
'author_disable' => false,
|
165 |
'author_noindex' => true,
|
class/hooks.php
CHANGED
@@ -146,7 +146,8 @@ class SSP_Hooks {
|
|
146 |
|
147 |
// check: /type/aside
|
148 |
if ( is_tax() && SSP_Data::$settings['post_format_disable'] ) {
|
149 |
-
|
|
|
150 |
wp_safe_redirect( $home );
|
151 |
exit;
|
152 |
};
|
146 |
|
147 |
// check: /type/aside
|
148 |
if ( is_tax() && SSP_Data::$settings['post_format_disable'] ) {
|
149 |
+
$obj = get_queried_object();
|
150 |
+
if ( isset( $obj->taxonomy ) && 'post_format' === $obj->taxonomy ) {
|
151 |
wp_safe_redirect( $home );
|
152 |
exit;
|
153 |
};
|
class/output.php
CHANGED
@@ -9,65 +9,48 @@ class SSP_Output {
|
|
9 |
private function __construct() {}
|
10 |
|
11 |
/**
|
12 |
-
* @var object The current
|
13 |
*/
|
14 |
private static $obj;
|
15 |
|
16 |
/**
|
17 |
-
* @var
|
18 |
*/
|
19 |
-
private static $
|
20 |
|
21 |
/**
|
22 |
-
* @var string The
|
23 |
*/
|
|
|
24 |
private static $description;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @var string The Description holder.
|
28 |
-
*/
|
29 |
private static $robots;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var string The Description holder.
|
33 |
-
*/
|
34 |
private static $keyword;
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var string The canonical holder.
|
39 |
-
*/
|
40 |
private static $canonical;
|
41 |
|
42 |
/**
|
43 |
-
* @var string The
|
44 |
*/
|
45 |
private static $og_tags;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var string The og:locale holder.
|
49 |
-
*/
|
50 |
private static $og_locale;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @var string The og:type holder.
|
54 |
-
*/
|
55 |
private static $og_type;
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @var string The og:image holder.
|
59 |
-
*/
|
60 |
private static $og_image;
|
|
|
|
|
|
|
|
|
61 |
|
62 |
/**
|
63 |
-
* @var string The
|
64 |
*/
|
65 |
-
private static $
|
|
|
|
|
66 |
|
67 |
/**
|
68 |
-
* @var string The
|
69 |
*/
|
70 |
-
private static $
|
|
|
71 |
|
72 |
|
73 |
/**
|
@@ -77,8 +60,9 @@ class SSP_Output {
|
|
77 |
add_action( 'wp_head', [ 'SSP_Output', 'main' ], 5 );
|
78 |
}
|
79 |
|
|
|
80 |
/**
|
81 |
-
*
|
82 |
*/
|
83 |
public static function get_meta_data( $key = '' ) {
|
84 |
if ( '' !== $key ) {
|
@@ -89,6 +73,16 @@ class SSP_Output {
|
|
89 |
}
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
/**
|
93 |
* トップページのデータだけを取得する
|
94 |
* (テーマや外部プラグインから構造化データ生成に使用できるようにするためのもの)
|
@@ -102,7 +96,7 @@ class SSP_Output {
|
|
102 |
} elseif ( 'description' === $target ) {
|
103 |
$return = $settings['home_desc'];
|
104 |
}
|
105 |
-
return self::replace_snippets( $return );
|
106 |
}
|
107 |
|
108 |
|
@@ -110,6 +104,8 @@ class SSP_Output {
|
|
110 |
* Genarate and output meta tags for current page.
|
111 |
*/
|
112 |
public static function main() {
|
|
|
|
|
113 |
|
114 |
// Genarate
|
115 |
self::generate_meta_tags();
|
@@ -121,7 +117,6 @@ class SSP_Output {
|
|
121 |
self::output_ogp_tags();
|
122 |
self::output_codes();
|
123 |
echo '<!-- / SEO SIMPLE PACK -->' . PHP_EOL . PHP_EOL;
|
124 |
-
|
125 |
}
|
126 |
|
127 |
|
@@ -129,16 +124,42 @@ class SSP_Output {
|
|
129 |
* Generate meta tags
|
130 |
*/
|
131 |
private static function generate_meta_tags() {
|
132 |
-
|
133 |
-
self::$obj = get_queried_object();
|
134 |
self::$title = self::generate_title();
|
135 |
self::$robots = self::generate_robots();
|
136 |
self::$keyword = self::generate_keyword();
|
137 |
self::$description = self::generate_description();
|
138 |
self::$canonical = self::generate_canonical();
|
|
|
|
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
|
|
|
142 |
/**
|
143 |
* Output meta tags
|
144 |
*/
|
@@ -163,22 +184,6 @@ class SSP_Output {
|
|
163 |
if ( ! empty( self::$canonical ) ) {
|
164 |
echo '<link rel="canonical" href="' . esc_attr( self::$canonical ) . '">' . PHP_EOL;
|
165 |
}
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Generate ogp tags
|
172 |
-
*/
|
173 |
-
private static function generate_ogp_tags() {
|
174 |
-
|
175 |
-
self::$og_locale = self::generate_og_locale();
|
176 |
-
self::$og_type = self::generate_og_type();
|
177 |
-
self::$og_image = self::generate_og_image();
|
178 |
-
self::$og_tags = self::generate_general_ogp();
|
179 |
-
self::$og_facebook = self::generate_og_facebook();
|
180 |
-
self::$og_twitter = self::generate_og_twitter();
|
181 |
-
|
182 |
}
|
183 |
|
184 |
|
@@ -187,30 +192,46 @@ class SSP_Output {
|
|
187 |
*/
|
188 |
private static function output_ogp_tags() {
|
189 |
|
190 |
-
if (
|
191 |
echo '<meta property="og:locale" content="' . esc_attr( self::$og_locale ) . '">' . PHP_EOL;
|
192 |
}
|
193 |
-
|
194 |
-
|
|
|
|
|
195 |
echo '<meta property="og:image" content="' . esc_url( self::$og_image ) . '">' . PHP_EOL;
|
196 |
}
|
197 |
-
|
198 |
-
|
199 |
-
echo self::$og_tags; // phpcs:ignore
|
200 |
}
|
201 |
-
|
202 |
-
|
203 |
-
echo '<meta property="og:type" content="' . esc_attr( self::$og_type ) . '">' . PHP_EOL;
|
204 |
}
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
208 |
}
|
209 |
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
|
@@ -225,6 +246,7 @@ class SSP_Output {
|
|
225 |
|
226 |
// default
|
227 |
$title = SSP_Data::$site_title;
|
|
|
228 |
switch ( true ) {
|
229 |
|
230 |
case is_front_page():
|
@@ -249,6 +271,10 @@ class SSP_Output {
|
|
249 |
$title = $settings['search_title'];
|
250 |
break;
|
251 |
|
|
|
|
|
|
|
|
|
252 |
case is_category():
|
253 |
if ( ! isset( self::$obj->term_id ) ) break;
|
254 |
|
@@ -271,10 +297,6 @@ class SSP_Output {
|
|
271 |
$title = $meta_title ?: $settings[ $term . '_title' ];
|
272 |
break;
|
273 |
|
274 |
-
case is_post_type_archive():
|
275 |
-
$title = $settings['pt_archive_title'];
|
276 |
-
break;
|
277 |
-
|
278 |
case is_author():
|
279 |
$title = $settings['author_title'];
|
280 |
break;
|
@@ -291,7 +313,7 @@ class SSP_Output {
|
|
291 |
break;
|
292 |
}
|
293 |
|
294 |
-
$title = wp_strip_all_tags( self::replace_snippets( $title ) );
|
295 |
return apply_filters( 'ssp_output_title', $title );
|
296 |
}
|
297 |
|
@@ -337,6 +359,11 @@ class SSP_Output {
|
|
337 |
$robots = 'noindex';
|
338 |
break;
|
339 |
|
|
|
|
|
|
|
|
|
|
|
340 |
case is_category():
|
341 |
if ( ! isset( self::$obj->term_id ) ) break;
|
342 |
|
@@ -377,11 +404,6 @@ class SSP_Output {
|
|
377 |
}
|
378 |
break;
|
379 |
|
380 |
-
case is_post_type_archive():
|
381 |
-
$is_noindex = $settings['pt_archive_noindex'];
|
382 |
-
$robots = $is_noindex ? 'noindex' : '';
|
383 |
-
break;
|
384 |
-
|
385 |
case is_author():
|
386 |
$is_noindex = $settings['author_noindex'];
|
387 |
$robots = $is_noindex ? 'noindex' : '';
|
@@ -416,11 +438,9 @@ class SSP_Output {
|
|
416 |
if ( is_front_page() ) {
|
417 |
$keyword = SSP_Data::$settings['home_keyword'];
|
418 |
} else {
|
419 |
-
if (
|
420 |
-
|
421 |
// メタボックスが入力されていれば上書きする
|
422 |
-
$
|
423 |
-
$meta_keyword = get_post_meta( $the_id, SSP_MetaBox::POST_META_KEYS['keyword'], true );
|
424 |
if ( $meta_keyword ) {
|
425 |
$keyword = $meta_keyword;
|
426 |
}
|
@@ -473,6 +493,10 @@ class SSP_Output {
|
|
473 |
case is_search():
|
474 |
break;
|
475 |
|
|
|
|
|
|
|
|
|
476 |
case is_category():
|
477 |
if ( ! isset( self::$obj->term_id ) ) break;
|
478 |
|
@@ -494,10 +518,6 @@ class SSP_Output {
|
|
494 |
$description = $meta_description ?: $settings[ self::$obj->taxonomy . '_desc' ];
|
495 |
break;
|
496 |
|
497 |
-
case is_post_type_archive():
|
498 |
-
$description = $settings['pt_archive_desc'];
|
499 |
-
break;
|
500 |
-
|
501 |
case is_author():
|
502 |
$description = $settings['author_desc'];
|
503 |
break;
|
@@ -510,35 +530,12 @@ class SSP_Output {
|
|
510 |
break;
|
511 |
}
|
512 |
|
513 |
-
$description = self::replace_snippets( $description );
|
514 |
return apply_filters( 'ssp_output_description', $description );
|
515 |
|
516 |
}
|
517 |
|
518 |
|
519 |
-
/**
|
520 |
-
* Generate the general ogp tags for the current page.
|
521 |
-
*
|
522 |
-
* @return string : OGP tags.
|
523 |
-
*/
|
524 |
-
private static function generate_general_ogp() {
|
525 |
-
|
526 |
-
$og_title = apply_filters( 'ssp_output_og_title', self::$title );
|
527 |
-
$og_desc = apply_filters( 'ssp_output_og_description', self::$description );
|
528 |
-
$og_url = apply_filters( 'ssp_output_og_url', self::$canonical );
|
529 |
-
$og_site_name = apply_filters( 'ssp_output_og_site_name', SSP_Data::$site_title );
|
530 |
-
|
531 |
-
$ogp = '';
|
532 |
-
$ogp .= '<meta property="og:title" content="' . esc_attr( $og_title ) . '">' . PHP_EOL;
|
533 |
-
$ogp .= '<meta property="og:description" content="' . esc_attr( $og_desc ) . '">' . PHP_EOL;
|
534 |
-
$ogp .= '<meta property="og:url" content="' . esc_attr( $og_url ) . '">' . PHP_EOL;
|
535 |
-
$ogp .= '<meta property="og:site_name" content="' . esc_attr( $og_site_name ) . '">' . PHP_EOL;
|
536 |
-
|
537 |
-
return $ogp;
|
538 |
-
|
539 |
-
}
|
540 |
-
|
541 |
-
|
542 |
/**
|
543 |
* Generate the canonical URL for the current page.
|
544 |
*
|
@@ -552,21 +549,15 @@ class SSP_Output {
|
|
552 |
switch ( true ) {
|
553 |
|
554 |
case is_front_page():
|
|
|
555 |
$canonical = home_url( '/' );
|
556 |
break;
|
557 |
|
|
|
558 |
case is_home():
|
559 |
-
|
560 |
-
if ( ! $home_id ) {
|
561 |
-
$canonical = home_url( '/' );
|
562 |
-
} else {
|
563 |
-
$canonical = get_permalink( $home_id ) ?: '';
|
564 |
-
}
|
565 |
-
break;
|
566 |
|
567 |
-
|
568 |
-
$the_id = isset( self::$obj->ID ) ? self::$obj->ID : 0;
|
569 |
-
$meta_canonical = get_post_meta( $the_id, SSP_MetaBox::POST_META_KEYS['canonical'], true );
|
570 |
$canonical = $meta_canonical ?: get_permalink();
|
571 |
break;
|
572 |
|
@@ -574,6 +565,14 @@ class SSP_Output {
|
|
574 |
$canonical = get_search_link();
|
575 |
break;
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
case is_tax() || is_tag() || is_category():
|
578 |
$term = self::$obj;
|
579 |
if ( ! isset( $term->term_id ) ) break;
|
@@ -587,12 +586,6 @@ class SSP_Output {
|
|
587 |
}
|
588 |
break;
|
589 |
|
590 |
-
case is_post_type_archive():
|
591 |
-
$post_type = get_query_var( 'post_type' );
|
592 |
-
$post_type = ( is_array( $post_type ) ) ? reset( $post_type ) : $post_type;
|
593 |
-
$canonical = get_post_type_archive_link( $post_type );
|
594 |
-
break;
|
595 |
-
|
596 |
case is_author():
|
597 |
$canonical = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
|
598 |
break;
|
@@ -646,18 +639,24 @@ class SSP_Output {
|
|
646 |
*/
|
647 |
private static function generate_og_image() {
|
648 |
|
649 |
-
$
|
650 |
|
651 |
// default
|
652 |
-
$og_image = $
|
653 |
|
654 |
switch ( true ) {
|
|
|
|
|
|
|
|
|
655 |
case is_attachment():
|
656 |
if ( ! isset( self::$obj->guid ) ) break;
|
657 |
-
|
658 |
-
$og_image = self::$obj->guid ?: $basic_ogimg;
|
659 |
break;
|
660 |
-
|
|
|
|
|
|
|
661 |
if ( ! isset( self::$obj->ID ) ) break;
|
662 |
|
663 |
$the_id = self::$obj->ID; // 投稿ID
|
@@ -670,23 +669,22 @@ class SSP_Output {
|
|
670 |
$thumb_id = get_post_thumbnail_id( $the_id );
|
671 |
$thumb_src = wp_get_attachment_image_src( $thumb_id, 'full' );
|
672 |
if ( $thumb_src ) {
|
673 |
-
$og_image = $thumb_src[0] ?: $
|
674 |
break;
|
675 |
}
|
676 |
}
|
677 |
-
|
678 |
-
// metaもアイキャッチもない時
|
679 |
-
$og_image = $basic_ogimg;
|
680 |
break;
|
681 |
|
682 |
case is_search():
|
|
|
683 |
break;
|
684 |
|
|
|
685 |
case is_tax() || is_tag() || is_category():
|
686 |
if ( ! isset( self::$obj->term_id ) ) break;
|
687 |
|
688 |
$meta_image = get_term_meta( self::$obj->term_id, SSP_MetaBox::TERM_META_KEYS['image'], true );
|
689 |
-
$og_image = $meta_image ?: $
|
690 |
break;
|
691 |
|
692 |
default:
|
@@ -697,71 +695,6 @@ class SSP_Output {
|
|
697 |
}
|
698 |
|
699 |
|
700 |
-
/**
|
701 |
-
* Generate the og:locale for the current page.
|
702 |
-
*
|
703 |
-
* @return string : The og:locale.
|
704 |
-
*/
|
705 |
-
private static function generate_og_locale() {
|
706 |
-
|
707 |
-
$locale = self::get_valid_og_locale();
|
708 |
-
return apply_filters( 'ssp_output_og_locale', $locale );
|
709 |
-
|
710 |
-
}
|
711 |
-
|
712 |
-
/**
|
713 |
-
* Generate the og tags for facebook. for the current page.
|
714 |
-
*
|
715 |
-
* @return string : The og tags for facebook.
|
716 |
-
*/
|
717 |
-
private static function generate_og_facebook() {
|
718 |
-
|
719 |
-
if ( ! SSP_Data::$ogp['fb_active'] ) return '';
|
720 |
-
|
721 |
-
$appid = apply_filters( 'ssp_output_fb_appid', SSP_Data::$ogp['fb_app_id'] );
|
722 |
-
$admins = apply_filters( 'ssp_output_fb_admins', SSP_Data::$ogp['fb_admins'] );
|
723 |
-
$publisher = apply_filters( 'ssp_output_fb_publisher', SSP_Data::$ogp['fb_url'] );
|
724 |
-
|
725 |
-
$og_fb = '';
|
726 |
-
if ( ! empty( $appid ) ) {
|
727 |
-
$og_fb .= '<meta property="fb:app_id" content="' . esc_attr( $appid ) . '">' . PHP_EOL;
|
728 |
-
}
|
729 |
-
if ( ! empty( $admins ) ) {
|
730 |
-
$og_fb .= '<meta property="fb:admins" content="' . esc_attr( $admins ) . '">' . PHP_EOL;
|
731 |
-
}
|
732 |
-
if ( ! empty( $publisher ) && 'article' === self::$og_type ) {
|
733 |
-
$og_fb .= '<meta property="article:publisher" content="' . esc_attr( $publisher ) . '">' . PHP_EOL;
|
734 |
-
}
|
735 |
-
|
736 |
-
return $og_fb;
|
737 |
-
|
738 |
-
}
|
739 |
-
|
740 |
-
|
741 |
-
/**
|
742 |
-
* Generate the og tags for twitter. for the current page.
|
743 |
-
*
|
744 |
-
* @return string : The og tags for twitter.
|
745 |
-
*/
|
746 |
-
private static function generate_og_twitter() {
|
747 |
-
|
748 |
-
if ( ! SSP_Data::$ogp['tw_active'] ) return '';
|
749 |
-
|
750 |
-
$tw_site = apply_filters( 'ssp_output_tw_site', SSP_Data::$ogp['tw_account'] );
|
751 |
-
$tw_card = apply_filters( 'ssp_output_tw_card', SSP_Data::$ogp['tw_card'] );
|
752 |
-
|
753 |
-
$og_tw = '';
|
754 |
-
if ( ! empty( $tw_card ) ) {
|
755 |
-
$og_tw .= '<meta name="twitter:card" content="' . esc_attr( $tw_card ) . '">' . PHP_EOL;
|
756 |
-
}
|
757 |
-
if ( ! empty( $tw_site ) ) {
|
758 |
-
$og_tw .= '<meta name="twitter:site" content="' . esc_attr( $tw_site ) . '">' . PHP_EOL;
|
759 |
-
}
|
760 |
-
|
761 |
-
return $og_tw;
|
762 |
-
}
|
763 |
-
|
764 |
-
|
765 |
/**
|
766 |
* Analytics and Webmaster code.
|
767 |
*/
|
9 |
private function __construct() {}
|
10 |
|
11 |
/**
|
12 |
+
* @var object The current query object.
|
13 |
*/
|
14 |
private static $obj;
|
15 |
|
16 |
/**
|
17 |
+
* @var object The type of current query object.
|
18 |
*/
|
19 |
+
private static $obj_type;
|
20 |
|
21 |
/**
|
22 |
+
* @var string The meta data holders.
|
23 |
*/
|
24 |
+
private static $title;
|
25 |
private static $description;
|
|
|
|
|
|
|
|
|
26 |
private static $robots;
|
|
|
|
|
|
|
|
|
27 |
private static $keyword;
|
|
|
|
|
|
|
|
|
|
|
28 |
private static $canonical;
|
29 |
|
30 |
/**
|
31 |
+
* @var string The ogp data holders.
|
32 |
*/
|
33 |
private static $og_tags;
|
|
|
|
|
|
|
|
|
34 |
private static $og_locale;
|
|
|
|
|
|
|
|
|
35 |
private static $og_type;
|
|
|
|
|
|
|
|
|
36 |
private static $og_image;
|
37 |
+
private static $og_title;
|
38 |
+
private static $og_desc;
|
39 |
+
private static $og_url;
|
40 |
+
private static $og_site_name;
|
41 |
|
42 |
/**
|
43 |
+
* @var string The ogp data holders for facebook.
|
44 |
*/
|
45 |
+
private static $fb_app_id;
|
46 |
+
private static $fb_admins;
|
47 |
+
private static $fb_url;
|
48 |
|
49 |
/**
|
50 |
+
* @var string The ogp data holders for twitter.
|
51 |
*/
|
52 |
+
private static $tw_card;
|
53 |
+
private static $tw_site;
|
54 |
|
55 |
|
56 |
/**
|
60 |
add_action( 'wp_head', [ 'SSP_Output', 'main' ], 5 );
|
61 |
}
|
62 |
|
63 |
+
|
64 |
/**
|
65 |
+
* get method
|
66 |
*/
|
67 |
public static function get_meta_data( $key = '' ) {
|
68 |
if ( '' !== $key ) {
|
73 |
}
|
74 |
|
75 |
|
76 |
+
/**
|
77 |
+
* $obj がどのクラスのオブジェクトかをチェック
|
78 |
+
*/
|
79 |
+
public static function get_obj_type( $obj ) {
|
80 |
+
if ( ! $obj || ! is_object( $obj ) ) return;
|
81 |
+
|
82 |
+
return get_class( $obj );
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
/**
|
87 |
* トップページのデータだけを取得する
|
88 |
* (テーマや外部プラグインから構造化データ生成に使用できるようにするためのもの)
|
96 |
} elseif ( 'description' === $target ) {
|
97 |
$return = $settings['home_desc'];
|
98 |
}
|
99 |
+
return self::replace_snippets( $return, $target );
|
100 |
}
|
101 |
|
102 |
|
104 |
* Genarate and output meta tags for current page.
|
105 |
*/
|
106 |
public static function main() {
|
107 |
+
self::$obj = get_queried_object();
|
108 |
+
self::$obj_type = self::get_obj_type( self::$obj );
|
109 |
|
110 |
// Genarate
|
111 |
self::generate_meta_tags();
|
117 |
self::output_ogp_tags();
|
118 |
self::output_codes();
|
119 |
echo '<!-- / SEO SIMPLE PACK -->' . PHP_EOL . PHP_EOL;
|
|
|
120 |
}
|
121 |
|
122 |
|
124 |
* Generate meta tags
|
125 |
*/
|
126 |
private static function generate_meta_tags() {
|
|
|
|
|
127 |
self::$title = self::generate_title();
|
128 |
self::$robots = self::generate_robots();
|
129 |
self::$keyword = self::generate_keyword();
|
130 |
self::$description = self::generate_description();
|
131 |
self::$canonical = self::generate_canonical();
|
132 |
+
}
|
133 |
+
|
134 |
|
135 |
+
/**
|
136 |
+
* Generate ogp tags
|
137 |
+
*/
|
138 |
+
private static function generate_ogp_tags() {
|
139 |
+
// Reuse meta tags
|
140 |
+
self::$og_title = apply_filters( 'ssp_output_og_title', self::$title );
|
141 |
+
self::$og_desc = apply_filters( 'ssp_output_og_description', self::$description );
|
142 |
+
self::$og_url = apply_filters( 'ssp_output_og_url', self::$canonical );
|
143 |
+
self::$og_site_name = apply_filters( 'ssp_output_og_site_name', SSP_Data::$site_title );
|
144 |
+
|
145 |
+
// Generate other ogp tags
|
146 |
+
self::$og_locale = apply_filters( 'ssp_output_og_locale', self::get_valid_og_locale() );
|
147 |
+
self::$og_type = self::generate_og_type();
|
148 |
+
self::$og_image = self::generate_og_image();
|
149 |
+
|
150 |
+
// Generate SNS ogp tags
|
151 |
+
if ( SSP_Data::$ogp['fb_active'] ) {
|
152 |
+
self::$fb_app_id = apply_filters( 'ssp_output_fb_appid', SSP_Data::$ogp['fb_app_id'] );
|
153 |
+
self::$fb_admins = apply_filters( 'ssp_output_fb_admins', SSP_Data::$ogp['fb_admins'] );
|
154 |
+
self::$fb_url = apply_filters( 'ssp_output_fb_publisher', SSP_Data::$ogp['fb_url'] );
|
155 |
+
}
|
156 |
+
if ( SSP_Data::$ogp['tw_active'] ) {
|
157 |
+
self::$tw_card = apply_filters( 'ssp_output_tw_card', SSP_Data::$ogp['tw_card'] );
|
158 |
+
self::$tw_site = apply_filters( 'ssp_output_tw_site', SSP_Data::$ogp['tw_account'] );
|
159 |
+
}
|
160 |
}
|
161 |
|
162 |
+
|
163 |
/**
|
164 |
* Output meta tags
|
165 |
*/
|
184 |
if ( ! empty( self::$canonical ) ) {
|
185 |
echo '<link rel="canonical" href="' . esc_attr( self::$canonical ) . '">' . PHP_EOL;
|
186 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
188 |
|
189 |
|
192 |
*/
|
193 |
private static function output_ogp_tags() {
|
194 |
|
195 |
+
if ( self::$og_locale ) {
|
196 |
echo '<meta property="og:locale" content="' . esc_attr( self::$og_locale ) . '">' . PHP_EOL;
|
197 |
}
|
198 |
+
if ( self::$og_type ) {
|
199 |
+
echo '<meta property="og:type" content="' . esc_attr( self::$og_type ) . '">' . PHP_EOL;
|
200 |
+
}
|
201 |
+
if ( self::$og_image ) {
|
202 |
echo '<meta property="og:image" content="' . esc_url( self::$og_image ) . '">' . PHP_EOL;
|
203 |
}
|
204 |
+
if ( self::$og_title ) {
|
205 |
+
echo '<meta property="og:title" content="' . esc_attr( self::$og_title ) . '">' . PHP_EOL;
|
|
|
206 |
}
|
207 |
+
if ( self::$og_desc ) {
|
208 |
+
echo '<meta property="og:description" content="' . esc_attr( self::$og_desc ) . '">' . PHP_EOL;
|
|
|
209 |
}
|
210 |
+
if ( self::$og_url ) {
|
211 |
+
echo '<meta property="og:url" content="' . esc_attr( self::$og_url ) . '">' . PHP_EOL;
|
212 |
+
}
|
213 |
+
if ( self::$og_site_name ) {
|
214 |
+
echo '<meta property="og:site_name" content="' . esc_attr( self::$og_site_name ) . '">' . PHP_EOL;
|
215 |
}
|
216 |
|
217 |
+
// for Facebook
|
218 |
+
if ( self::$fb_app_id ) {
|
219 |
+
echo '<meta property="fb:app_id" content="' . esc_attr( self::$fb_app_id ) . '">' . PHP_EOL;
|
220 |
+
}
|
221 |
+
if ( self::$fb_admins ) {
|
222 |
+
echo '<meta property="fb:admins" content="' . esc_attr( self::$fb_admins ) . '">' . PHP_EOL;
|
223 |
+
}
|
224 |
+
if ( self::$fb_url && 'article' === self::$og_type ) {
|
225 |
+
echo '<meta property="article:publisher" content="' . esc_attr( self::$fb_url ) . '">' . PHP_EOL;
|
226 |
}
|
227 |
|
228 |
+
// for Twitter
|
229 |
+
if ( self::$tw_card ) {
|
230 |
+
echo '<meta name="twitter:card" content="' . esc_attr( self::$tw_card ) . '">' . PHP_EOL;
|
231 |
+
}
|
232 |
+
if ( self::$tw_site ) {
|
233 |
+
echo '<meta name="twitter:site" content="' . esc_attr( self::$tw_site ) . '">' . PHP_EOL;
|
234 |
+
}
|
235 |
}
|
236 |
|
237 |
|
246 |
|
247 |
// default
|
248 |
$title = SSP_Data::$site_title;
|
249 |
+
|
250 |
switch ( true ) {
|
251 |
|
252 |
case is_front_page():
|
271 |
$title = $settings['search_title'];
|
272 |
break;
|
273 |
|
274 |
+
case is_post_type_archive():
|
275 |
+
$title = $settings['pt_archive_title'];
|
276 |
+
break;
|
277 |
+
|
278 |
case is_category():
|
279 |
if ( ! isset( self::$obj->term_id ) ) break;
|
280 |
|
297 |
$title = $meta_title ?: $settings[ $term . '_title' ];
|
298 |
break;
|
299 |
|
|
|
|
|
|
|
|
|
300 |
case is_author():
|
301 |
$title = $settings['author_title'];
|
302 |
break;
|
313 |
break;
|
314 |
}
|
315 |
|
316 |
+
$title = wp_strip_all_tags( self::replace_snippets( $title, 'title' ) );
|
317 |
return apply_filters( 'ssp_output_title', $title );
|
318 |
}
|
319 |
|
359 |
$robots = 'noindex';
|
360 |
break;
|
361 |
|
362 |
+
case is_post_type_archive():
|
363 |
+
$is_noindex = $settings['pt_archive_noindex'];
|
364 |
+
$robots = $is_noindex ? 'noindex' : '';
|
365 |
+
break;
|
366 |
+
|
367 |
case is_category():
|
368 |
if ( ! isset( self::$obj->term_id ) ) break;
|
369 |
|
404 |
}
|
405 |
break;
|
406 |
|
|
|
|
|
|
|
|
|
|
|
407 |
case is_author():
|
408 |
$is_noindex = $settings['author_noindex'];
|
409 |
$robots = $is_noindex ? 'noindex' : '';
|
438 |
if ( is_front_page() ) {
|
439 |
$keyword = SSP_Data::$settings['home_keyword'];
|
440 |
} else {
|
441 |
+
if ( 'WP_Post' === self::$obj_type && isset( self::$obj->ID ) ) {
|
|
|
442 |
// メタボックスが入力されていれば上書きする
|
443 |
+
$meta_keyword = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['keyword'], true );
|
|
|
444 |
if ( $meta_keyword ) {
|
445 |
$keyword = $meta_keyword;
|
446 |
}
|
493 |
case is_search():
|
494 |
break;
|
495 |
|
496 |
+
case is_post_type_archive():
|
497 |
+
$description = $settings['pt_archive_desc'];
|
498 |
+
break;
|
499 |
+
|
500 |
case is_category():
|
501 |
if ( ! isset( self::$obj->term_id ) ) break;
|
502 |
|
518 |
$description = $meta_description ?: $settings[ self::$obj->taxonomy . '_desc' ];
|
519 |
break;
|
520 |
|
|
|
|
|
|
|
|
|
521 |
case is_author():
|
522 |
$description = $settings['author_desc'];
|
523 |
break;
|
530 |
break;
|
531 |
}
|
532 |
|
533 |
+
$description = self::replace_snippets( $description, 'description' );
|
534 |
return apply_filters( 'ssp_output_description', $description );
|
535 |
|
536 |
}
|
537 |
|
538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
/**
|
540 |
* Generate the canonical URL for the current page.
|
541 |
*
|
549 |
switch ( true ) {
|
550 |
|
551 |
case is_front_page():
|
552 |
+
case is_home() && null === self::$obj: // 「投稿ページ」しか設定されていないときのトップ
|
553 |
$canonical = home_url( '/' );
|
554 |
break;
|
555 |
|
556 |
+
case is_singular():
|
557 |
case is_home():
|
558 |
+
if ( ! isset( self::$obj->ID ) ) break;
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
|
560 |
+
$meta_canonical = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['canonical'], true );
|
|
|
|
|
561 |
$canonical = $meta_canonical ?: get_permalink();
|
562 |
break;
|
563 |
|
565 |
$canonical = get_search_link();
|
566 |
break;
|
567 |
|
568 |
+
case is_post_type_archive():
|
569 |
+
$post_type = get_query_var( 'post_type' );
|
570 |
+
if ( $post_type ) {
|
571 |
+
$post_type = ( is_array( $post_type ) ) ? reset( $post_type ) : $post_type;
|
572 |
+
$canonical = get_post_type_archive_link( $post_type );
|
573 |
+
}
|
574 |
+
break;
|
575 |
+
|
576 |
case is_tax() || is_tag() || is_category():
|
577 |
$term = self::$obj;
|
578 |
if ( ! isset( $term->term_id ) ) break;
|
586 |
}
|
587 |
break;
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
case is_author():
|
590 |
$canonical = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
|
591 |
break;
|
639 |
*/
|
640 |
private static function generate_og_image() {
|
641 |
|
642 |
+
$site_ogimg = SSP_Data::$ogp['og_image'];
|
643 |
|
644 |
// default
|
645 |
+
$og_image = $site_ogimg;
|
646 |
|
647 |
switch ( true ) {
|
648 |
+
case is_front_page():
|
649 |
+
case is_home() && null === self::$obj:
|
650 |
+
break;
|
651 |
+
|
652 |
case is_attachment():
|
653 |
if ( ! isset( self::$obj->guid ) ) break;
|
654 |
+
$og_image = self::$obj->guid ?: $site_ogimg;
|
|
|
655 |
break;
|
656 |
+
|
657 |
+
// 投稿・固定ページ
|
658 |
+
case is_singular():
|
659 |
+
case is_home():
|
660 |
if ( ! isset( self::$obj->ID ) ) break;
|
661 |
|
662 |
$the_id = self::$obj->ID; // 投稿ID
|
669 |
$thumb_id = get_post_thumbnail_id( $the_id );
|
670 |
$thumb_src = wp_get_attachment_image_src( $thumb_id, 'full' );
|
671 |
if ( $thumb_src ) {
|
672 |
+
$og_image = $thumb_src[0] ?: $site_ogimg;
|
673 |
break;
|
674 |
}
|
675 |
}
|
|
|
|
|
|
|
676 |
break;
|
677 |
|
678 |
case is_search():
|
679 |
+
case is_post_type_archive():
|
680 |
break;
|
681 |
|
682 |
+
// ターム系
|
683 |
case is_tax() || is_tag() || is_category():
|
684 |
if ( ! isset( self::$obj->term_id ) ) break;
|
685 |
|
686 |
$meta_image = get_term_meta( self::$obj->term_id, SSP_MetaBox::TERM_META_KEYS['image'], true );
|
687 |
+
$og_image = $meta_image ?: $site_ogimg;
|
688 |
break;
|
689 |
|
690 |
default:
|
695 |
}
|
696 |
|
697 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
/**
|
699 |
* Analytics and Webmaster code.
|
700 |
*/
|
class/trait/field.php
CHANGED
@@ -42,38 +42,55 @@ trait Field {
|
|
42 |
}
|
43 |
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* 各設定項目を出力する
|
47 |
*/
|
48 |
-
public static function output_field( $
|
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 |
<div class="ssp-field"<?=$add_data?>>
|
75 |
<?php if ( $args['title'] ) : ?>
|
76 |
-
<label for="<?=esc_attr( $
|
77 |
<?=esc_html( $args['title'] ) ?>
|
78 |
</label>
|
79 |
<?php endif; ?>
|
@@ -83,7 +100,7 @@ trait Field {
|
|
83 |
if ( $args['item'] ) :
|
84 |
echo $args['item'];
|
85 |
else :
|
86 |
-
self::the_setting_field( $
|
87 |
endif;
|
88 |
?>
|
89 |
</div>
|
@@ -96,7 +113,7 @@ trait Field {
|
|
96 |
<?=esc_html__( 'Preview', 'loos-ssp' )?> :
|
97 |
</span>
|
98 |
<div class="ssp-field__preview__content">
|
99 |
-
<?=wp_kses_post( self::replace_snippets_forpv( $
|
100 |
</div>
|
101 |
<a href="<?=esc_url( admin_url( 'admin.php?page=ssp_help' ) )?>" target="_blank" title="<?=esc_html__( 'About available snippet tags', 'loos-ssp' )?>" class="ssp-helpButton">?</a>
|
102 |
</div>
|
@@ -106,40 +123,41 @@ trait Field {
|
|
106 |
<?php
|
107 |
}
|
108 |
|
|
|
109 |
/**
|
110 |
* 設定フィールドを取得
|
111 |
*/
|
112 |
-
public static function the_setting_field( $
|
113 |
|
114 |
$type = $args['type'];
|
115 |
|
116 |
if ( 'text' === $type ) {
|
117 |
|
118 |
-
self::text_input( $
|
119 |
|
120 |
} elseif ( 'checkbox' === $type ) {
|
121 |
|
122 |
-
self::checkbox( $
|
123 |
|
124 |
} elseif ( 'switch' === $type ) {
|
125 |
|
126 |
-
self::switch_box( $
|
127 |
|
128 |
} elseif ( 'select' === $type ) {
|
129 |
|
130 |
-
self::select_box( $
|
131 |
|
132 |
} if ( 'radio_btn' === $type ) {
|
133 |
|
134 |
-
self::radio_btns( $
|
135 |
|
136 |
} if ( 'media' === $type ) {
|
137 |
|
138 |
-
self::media_btns( $
|
139 |
|
140 |
} elseif ( 'textarea' === $type ) {
|
141 |
|
142 |
-
self::textarea( $
|
143 |
|
144 |
}
|
145 |
}
|
@@ -148,16 +166,16 @@ trait Field {
|
|
148 |
/**
|
149 |
* text_input
|
150 |
*/
|
151 |
-
public static function text_input( $name, $
|
152 |
-
echo '<input type="text" name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '" value="' . esc_attr( $
|
153 |
}
|
154 |
|
155 |
|
156 |
/**
|
157 |
* textarea
|
158 |
*/
|
159 |
-
public static function textarea( $name, $
|
160 |
-
echo '<textarea name="' . esc_attr( $name ) . '" rows="' . esc_attr( $rows ) . '">' . esc_html( $
|
161 |
}
|
162 |
|
163 |
|
@@ -196,11 +214,11 @@ trait Field {
|
|
196 |
/**
|
197 |
* select_box
|
198 |
*/
|
199 |
-
public static function select_box( $name, $
|
200 |
|
201 |
echo '<select name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '">';
|
202 |
foreach ( $choices as $key => $label ) {
|
203 |
-
$selected = ( $key === $
|
204 |
echo '<option value="' . esc_attr( $key ) . '" ' . $selected . '>' . esc_html( $label ) . '</option>';
|
205 |
}
|
206 |
echo '</select>';
|
@@ -210,11 +228,11 @@ trait Field {
|
|
210 |
/**
|
211 |
* radio_btns
|
212 |
*/
|
213 |
-
public static function radio_btns( $name, $
|
214 |
|
215 |
foreach ( $choices as $key => $label ) {
|
216 |
|
217 |
-
$checked = ( $key === $
|
218 |
$radio_key = 'radio-' . $name . '-' . $key;
|
219 |
|
220 |
echo '<input type="radio" class="ssp-field__radioInput"' .
|
@@ -229,13 +247,13 @@ trait Field {
|
|
229 |
/**
|
230 |
* 画像アップロード
|
231 |
*/
|
232 |
-
public static function media_btns( $name = '', $
|
233 |
?>
|
234 |
<div class="ssp-media">
|
235 |
-
<input type="hidden" id="src_<?=esc_attr( $name )?>" name="<?=esc_attr( $name )?>" value="<?=esc_attr( $
|
236 |
-
<?php if ( $
|
237 |
<div id="preview_<?=esc_attr( $name )?>" class="ssp-media__preview">
|
238 |
-
<img src="<?=esc_url( $
|
239 |
</div>
|
240 |
<?php else : ?>
|
241 |
<div id="preview_<?=esc_attr( $name )?>" class="ssp-media__preview"></div>
|
@@ -260,32 +278,23 @@ trait Field {
|
|
260 |
* プレビュー機能用のスニペット変換
|
261 |
*/
|
262 |
public static function replace_snippets_forpv( $str ) {
|
263 |
-
|
264 |
$str = str_replace( '%_site_title_%', '<span>' . \SSP_Data::$site_title . '</span>', $str );
|
265 |
-
$str = str_replace( '%_phrase_%', '<span>' . \SSP_Data::$site_catch_phrase . '</span>', $str );
|
266 |
$str = str_replace( '%_tagline_%', '<span>' . \SSP_Data::$site_catch_phrase . '</span>', $str );
|
267 |
-
$str = str_replace( '%
|
268 |
$str = str_replace( '%_page_title_%', '<span>' . __( 'Post title', 'loos-ssp' ) . '</span>', $str );
|
269 |
-
$str = str_replace( '%
|
270 |
-
$str = str_replace( '%_tag_name_%', '<span>' . __( 'Tag name', 'loos-ssp' ) . '</span>', $str );
|
271 |
$str = str_replace( '%_term_name_%', '<span>' . __( 'Term name', 'loos-ssp' ) . '</span>', $str );
|
|
|
272 |
$str = str_replace( '%_tax_name_%', '<span>' . __( 'Taxonomy name', 'loos-ssp' ) . '</span>', $str );
|
273 |
$str = str_replace( '%_author_name_%', '<span>' . __( 'Author name', 'loos-ssp' ) . '</span>', $str );
|
274 |
$str = str_replace( '%_search_phrase_%', '<span>' . __( 'Search word', 'loos-ssp' ) . '</span>', $str );
|
275 |
$str = str_replace( '%_post_type_%', '<span>' . __( 'Post type name', 'loos-ssp' ) . '</span>', $str );
|
276 |
-
$str = str_replace( '%_page_contents_%', '<span>' . __( 'Page content', 'loos-ssp' ) . '</span>', $str );
|
277 |
$str = str_replace( '%_date_%', '<span>' . __( 'Date', 'loos-ssp' ) . '</span>', $str );
|
278 |
-
$str = str_replace( '%_format_name_%', '<span>' . __( 'Post format name', 'loos-ssp' ) . '</span>', $str );
|
279 |
-
$str = str_replace( '%_term_description_%', '<span>' . __( 'Term description', 'loos-ssp' ) . '</span>', $str );
|
280 |
-
|
281 |
if ( strpos( $str, '%_sep_%' ) !== false ) {
|
282 |
-
|
283 |
$sep_key = \SSP_Data::$settings['separator'];
|
284 |
$sep_val = \SSP_Data::SEPARATORS[ $sep_key ];
|
285 |
$str = str_replace( '%_sep_%', '<span>' . $sep_val . '</span>', $str );
|
286 |
-
|
287 |
}
|
288 |
-
|
289 |
return $str;
|
290 |
}
|
291 |
}
|
42 |
}
|
43 |
|
44 |
|
45 |
+
/**
|
46 |
+
* 旧スニペット名を置換
|
47 |
+
*/
|
48 |
+
public static function replace_old_snipets( $str ) {
|
49 |
+
// 旧スニペット名を置換
|
50 |
+
$str = str_replace( '%_cat_name_%', '%_term_name_%', $str );
|
51 |
+
$str = str_replace( '%_tag_name_%', '%_term_name_%', $str );
|
52 |
+
$str = str_replace( '%_format_name_%', '%_term_name_%', $str );
|
53 |
+
$str = str_replace( '%_phrase_%', '%_tagline_%', $str );
|
54 |
+
$str = str_replace( '%_description_%', '%_front_description_%', $str );
|
55 |
+
|
56 |
+
return $str;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
/**
|
61 |
* 各設定項目を出力する
|
62 |
*/
|
63 |
+
public static function output_field( $field_name, $args, $field_value ) {
|
64 |
+
|
65 |
+
$args = array_merge( [
|
66 |
+
'title' => '',
|
67 |
+
'reqired' => false,
|
68 |
+
'class' => '',
|
69 |
+
'type' => 'text',
|
70 |
+
'preview' => false,
|
71 |
+
'desc' => '',
|
72 |
+
'choices' => [],
|
73 |
+
'label' => '',
|
74 |
+
'item' => '',
|
75 |
+
], $args );
|
76 |
+
|
77 |
+
$field_value = self::replace_old_snipets( $field_value );
|
78 |
+
|
79 |
+
$add_data = '';
|
80 |
+
if ( strpos( $field_name, '_disable' ) !== false ) {
|
81 |
+
$add_data = ' data-disable="' . esc_attr( (int) $field_value ) . '"';
|
82 |
+
} elseif ( strpos( $field_name, 'tw_active' ) !== false || strpos( $field_name, 'fb_active' ) !== false ) {
|
83 |
+
$add_data = ' data-active="' . esc_attr( (int) $field_value ) . '"';
|
84 |
+
}
|
85 |
+
|
86 |
+
// if ( $args['reqired'] ) {
|
87 |
+
// $table_title .= '<span class="required">*</span>';
|
88 |
+
// }
|
89 |
|
90 |
?>
|
91 |
<div class="ssp-field"<?=$add_data?>>
|
92 |
<?php if ( $args['title'] ) : ?>
|
93 |
+
<label for="<?=esc_attr( $field_name )?>" class="ssp-field__title">
|
94 |
<?=esc_html( $args['title'] ) ?>
|
95 |
</label>
|
96 |
<?php endif; ?>
|
100 |
if ( $args['item'] ) :
|
101 |
echo $args['item'];
|
102 |
else :
|
103 |
+
self::the_setting_field( $field_name, $field_value, $args );
|
104 |
endif;
|
105 |
?>
|
106 |
</div>
|
113 |
<?=esc_html__( 'Preview', 'loos-ssp' )?> :
|
114 |
</span>
|
115 |
<div class="ssp-field__preview__content">
|
116 |
+
<?=wp_kses_post( self::replace_snippets_forpv( $field_value ) )?>
|
117 |
</div>
|
118 |
<a href="<?=esc_url( admin_url( 'admin.php?page=ssp_help' ) )?>" target="_blank" title="<?=esc_html__( 'About available snippet tags', 'loos-ssp' )?>" class="ssp-helpButton">?</a>
|
119 |
</div>
|
123 |
<?php
|
124 |
}
|
125 |
|
126 |
+
|
127 |
/**
|
128 |
* 設定フィールドを取得
|
129 |
*/
|
130 |
+
public static function the_setting_field( $field_name, $field_value, $args ) {
|
131 |
|
132 |
$type = $args['type'];
|
133 |
|
134 |
if ( 'text' === $type ) {
|
135 |
|
136 |
+
self::text_input( $field_name, $field_value );
|
137 |
|
138 |
} elseif ( 'checkbox' === $type ) {
|
139 |
|
140 |
+
self::checkbox( $field_name, $field_value, $args['label'] );
|
141 |
|
142 |
} elseif ( 'switch' === $type ) {
|
143 |
|
144 |
+
self::switch_box( $field_name, $field_value );
|
145 |
|
146 |
} elseif ( 'select' === $type ) {
|
147 |
|
148 |
+
self::select_box( $field_name, $field_value, $args['choices'] );
|
149 |
|
150 |
} if ( 'radio_btn' === $type ) {
|
151 |
|
152 |
+
self::radio_btns( $field_name, $field_value, $args['choices'] );
|
153 |
|
154 |
} if ( 'media' === $type ) {
|
155 |
|
156 |
+
self::media_btns( $field_name, $field_value );
|
157 |
|
158 |
} elseif ( 'textarea' === $type ) {
|
159 |
|
160 |
+
self::textarea( $field_name, $field_value );
|
161 |
|
162 |
}
|
163 |
}
|
166 |
/**
|
167 |
* text_input
|
168 |
*/
|
169 |
+
public static function text_input( $name, $value ) {
|
170 |
+
echo '<input type="text" name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '" value="' . esc_attr( $value ) . '">';
|
171 |
}
|
172 |
|
173 |
|
174 |
/**
|
175 |
* textarea
|
176 |
*/
|
177 |
+
public static function textarea( $name, $value, $rows = '4' ) {
|
178 |
+
echo '<textarea name="' . esc_attr( $name ) . '" rows="' . esc_attr( $rows ) . '">' . esc_html( $value ) . '</textarea>';
|
179 |
}
|
180 |
|
181 |
|
214 |
/**
|
215 |
* select_box
|
216 |
*/
|
217 |
+
public static function select_box( $name, $value, $choices ) {
|
218 |
|
219 |
echo '<select name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '">';
|
220 |
foreach ( $choices as $key => $label ) {
|
221 |
+
$selected = ( $key === $value ) ? 'selected' : '';
|
222 |
echo '<option value="' . esc_attr( $key ) . '" ' . $selected . '>' . esc_html( $label ) . '</option>';
|
223 |
}
|
224 |
echo '</select>';
|
228 |
/**
|
229 |
* radio_btns
|
230 |
*/
|
231 |
+
public static function radio_btns( $name, $value, $choices ) {
|
232 |
|
233 |
foreach ( $choices as $key => $label ) {
|
234 |
|
235 |
+
$checked = ( $key === $value ) ? 'checked' : '';
|
236 |
$radio_key = 'radio-' . $name . '-' . $key;
|
237 |
|
238 |
echo '<input type="radio" class="ssp-field__radioInput"' .
|
247 |
/**
|
248 |
* 画像アップロード
|
249 |
*/
|
250 |
+
public static function media_btns( $name = '', $value = '' ) {
|
251 |
?>
|
252 |
<div class="ssp-media">
|
253 |
+
<input type="hidden" id="src_<?=esc_attr( $name )?>" name="<?=esc_attr( $name )?>" value="<?=esc_attr( $value )?>" />
|
254 |
+
<?php if ( $value ) : ?>
|
255 |
<div id="preview_<?=esc_attr( $name )?>" class="ssp-media__preview">
|
256 |
+
<img src="<?=esc_url( $value )?>" alt="">
|
257 |
</div>
|
258 |
<?php else : ?>
|
259 |
<div id="preview_<?=esc_attr( $name )?>" class="ssp-media__preview"></div>
|
278 |
* プレビュー機能用のスニペット変換
|
279 |
*/
|
280 |
public static function replace_snippets_forpv( $str ) {
|
|
|
281 |
$str = str_replace( '%_site_title_%', '<span>' . \SSP_Data::$site_title . '</span>', $str );
|
|
|
282 |
$str = str_replace( '%_tagline_%', '<span>' . \SSP_Data::$site_catch_phrase . '</span>', $str );
|
283 |
+
$str = str_replace( '%_front_description_%', '<span>' . __( 'Front description', 'loos-ssp' ) . '</span>', $str );
|
284 |
$str = str_replace( '%_page_title_%', '<span>' . __( 'Post title', 'loos-ssp' ) . '</span>', $str );
|
285 |
+
$str = str_replace( '%_page_contents_%', '<span>' . __( 'Page content', 'loos-ssp' ) . '</span>', $str );
|
|
|
286 |
$str = str_replace( '%_term_name_%', '<span>' . __( 'Term name', 'loos-ssp' ) . '</span>', $str );
|
287 |
+
$str = str_replace( '%_term_description_%', '<span>' . __( 'Term description', 'loos-ssp' ) . '</span>', $str );
|
288 |
$str = str_replace( '%_tax_name_%', '<span>' . __( 'Taxonomy name', 'loos-ssp' ) . '</span>', $str );
|
289 |
$str = str_replace( '%_author_name_%', '<span>' . __( 'Author name', 'loos-ssp' ) . '</span>', $str );
|
290 |
$str = str_replace( '%_search_phrase_%', '<span>' . __( 'Search word', 'loos-ssp' ) . '</span>', $str );
|
291 |
$str = str_replace( '%_post_type_%', '<span>' . __( 'Post type name', 'loos-ssp' ) . '</span>', $str );
|
|
|
292 |
$str = str_replace( '%_date_%', '<span>' . __( 'Date', 'loos-ssp' ) . '</span>', $str );
|
|
|
|
|
|
|
293 |
if ( strpos( $str, '%_sep_%' ) !== false ) {
|
|
|
294 |
$sep_key = \SSP_Data::$settings['separator'];
|
295 |
$sep_val = \SSP_Data::SEPARATORS[ $sep_key ];
|
296 |
$str = str_replace( '%_sep_%', '<span>' . $sep_val . '</span>', $str );
|
|
|
297 |
}
|
|
|
298 |
return $str;
|
299 |
}
|
300 |
}
|
class/trait/output_helper.php
CHANGED
@@ -227,100 +227,111 @@ trait Output_Helper {
|
|
227 |
/**
|
228 |
* Replace snippets
|
229 |
*/
|
230 |
-
private static function replace_snippets( $str ) {
|
231 |
-
|
232 |
-
$obj
|
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 |
-
$sep_key = \SSP_Data::$settings['separator'];
|
319 |
-
$sep_val = \SSP_Data::SEPARATORS[ $sep_key ];
|
320 |
-
$str = str_replace( '%_sep_%', $sep_val, $str );
|
321 |
-
|
322 |
-
}
|
323 |
|
|
|
324 |
return $str;
|
325 |
}
|
326 |
|
227 |
/**
|
228 |
* Replace snippets
|
229 |
*/
|
230 |
+
private static function replace_snippets( $str, $context = '' ) {
|
231 |
+
|
232 |
+
$obj = \SSP_Output::$obj;
|
233 |
+
$obj_type = \SSP_Output::$obj_type;
|
234 |
+
|
235 |
+
// get snippets
|
236 |
+
$snipets = preg_match_all( '/%_([^%]+)_%/', $str, $matched, PREG_SET_ORDER );
|
237 |
+
if ( ! $snipets ) return $str;
|
238 |
+
|
239 |
+
// replace each snippets
|
240 |
+
foreach ( $matched as $snipet ) {
|
241 |
+
$snipet_tag = $snipet[0];
|
242 |
+
$snipet_name = $snipet[1];
|
243 |
+
$replace = '';
|
244 |
+
switch ( $snipet_tag ) {
|
245 |
+
case '%_site_title_%':
|
246 |
+
$replace = \SSP_Data::$site_title;
|
247 |
+
break;
|
248 |
+
case '%_phrase_%': // old
|
249 |
+
case '%_tagline_%':
|
250 |
+
$replace = \SSP_Data::$site_catch_phrase;
|
251 |
+
break;
|
252 |
+
case '%_description_%': // old
|
253 |
+
case '%_front_description_%':
|
254 |
+
$replace = \SSP_Data::$settings['home_desc'];
|
255 |
+
break;
|
256 |
+
case '%_search_phrase_%':
|
257 |
+
$replace = get_search_query();
|
258 |
+
break;
|
259 |
+
case '%_post_type_%':
|
260 |
+
$replace = post_type_archive_title( '', false );
|
261 |
+
break;
|
262 |
+
case '%_page_title_%':
|
263 |
+
// is_home() を考慮して get_the_title() ではなく single_post_title()
|
264 |
+
$replace = single_post_title( '', false );
|
265 |
+
break;
|
266 |
+
case '%_page_contents_%':
|
267 |
+
if ( 'WP_Post' === $obj_type ) {
|
268 |
+
$word_count = apply_filters( 'ssp_description_word_count', 120 );
|
269 |
+
$content = wp_strip_all_tags( strip_shortcodes( $obj->post_content ), true ); // 改行なども削除
|
270 |
+
$replace = mb_substr( $content, 0, $word_count );
|
271 |
+
}
|
272 |
+
break;
|
273 |
+
case '%_term_name_%':
|
274 |
+
case '%_cat_name_%': // old
|
275 |
+
case '%_tag_name_%': // old
|
276 |
+
case '%_format_name_%': // old
|
277 |
+
if ( 'WP_Term' === $obj_type ) {
|
278 |
+
$replace = $obj->name;
|
279 |
+
}
|
280 |
+
break;
|
281 |
+
case '%_term_description_%':
|
282 |
+
if ( 'WP_Term' === $obj_type ) {
|
283 |
+
$replace = wp_strip_all_tags( strip_shortcodes( $obj->description ), true ); // 改行なども削除
|
284 |
+
}
|
285 |
+
break;
|
286 |
+
case '%_tax_name_%':
|
287 |
+
if ( 'WP_Term' === $obj_type && isset( $obj->taxonomy ) ) {
|
288 |
+
$taxonomy_slug = $obj->taxonomy;
|
289 |
+
$taxonomy_data = get_taxonomy( $taxonomy_slug );
|
290 |
+
$replace = ( $taxonomy_data ) ? $taxonomy_data->label : '';
|
291 |
+
}
|
292 |
+
break;
|
293 |
+
case '%_author_name_%':
|
294 |
+
if ( is_author() && 'WP_User' === $obj_type ) {
|
295 |
+
$replace = get_user_meta( $obj->ID, 'nickname', true );
|
296 |
+
}
|
297 |
+
break;
|
298 |
+
case '%_sep_%':
|
299 |
+
// 区切り文字の置換
|
300 |
+
$replace = \SSP_Data::SEPARATORS[ \SSP_Data::$settings['separator'] ];
|
301 |
+
break;
|
302 |
+
case '%_date_%':
|
303 |
+
$year = get_query_var( 'year' );
|
304 |
+
$monthnum = get_query_var( 'monthnum' );
|
305 |
+
$day = get_query_var( 'day' );
|
306 |
+
|
307 |
+
$month = '';
|
308 |
+
if ( $monthnum ) {
|
309 |
+
global $wp_locale;
|
310 |
+
$month = $wp_locale->get_month( $monthnum );
|
311 |
+
}
|
312 |
+
|
313 |
+
if ( is_day() ) {
|
314 |
+
$replace = sprintf( _x( '%2$s %3$s, %1$s', 'date', 'loos-ssp' ), $year, $month, $day ); // phpcs:ignore
|
315 |
+
} elseif ( is_month() ) {
|
316 |
+
$replace = sprintf( _x( '%2$s %1$s', 'date', 'loos-ssp' ), $year, $month ); // phpcs:ignore
|
317 |
+
} elseif ( is_year() ) {
|
318 |
+
$replace = sprintf( _x( '%s', 'date', 'loos-ssp' ), $year ); // phpcs:ignore
|
319 |
+
}
|
320 |
+
|
321 |
+
break;
|
322 |
+
default:
|
323 |
+
// その他、SSP側で用意していないスニペットがある時、フィルターで置換できるようにする
|
324 |
+
$filter_name = "ssp_replace_snippet_$snipet_name";
|
325 |
+
if ( has_filter( $filter_name ) ) {
|
326 |
+
$replace = apply_filters( $filter_name, '', $context );
|
327 |
+
}
|
328 |
+
break;
|
329 |
}
|
|
|
330 |
|
331 |
+
$str = str_replace( $snipet_tag, $replace, $str );
|
332 |
+
} // end foreach
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
+
$str = trim( $str );
|
335 |
return $str;
|
336 |
}
|
337 |
|
dist/css/ssp.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ssp-field+.ssp-field{margin-top:40px}.ssp-field[data-disable="1"]~.ssp-field{display:none}.ssp-field[data-active="0"]~.ssp-field{opacity:.5;pointer-events:none}.ssp-field input[type=text],.ssp-field textarea{width:100%;padding:4px 8px}.ssp-field .hide{display:none}.ssp-field code{margin:0;padding:2px 6px;font-size:inherit;font-style:normal;background:#eee}.ssp-field__body{padding-left:8px}.ssp-field__title{display:block;margin-bottom:16px;padding-left:8px;font-weight:700;font-size:14px;border-left:2px solid #87ab87}.ssp-field__desc{color:#666;font-size:13px;font-style:italic}.ssp-field__item.-radio_btn{display:flex;flex-wrap:wrap}.ssp-field__item.-radio_btn .ssp-field__radioInput{display:none}.ssp-field__item.-radio_btn .ssp-field__radioLabel{width:40px;height:40px;margin:4px;padding:0;line-height:34px;text-align:center;vertical-align:middle;background:#fcfcfc;border:1px solid #ccc;box-shadow:inset 0 0 2px #fff}.ssp-field__item.-radio_btn :checked+.ssp-field__radioLabel{border:2px solid #eba170}.ssp-helpTable{width:100%;max-width:
|
1 |
+
.ssp-field+.ssp-field{margin-top:40px}.ssp-field[data-disable="1"]~.ssp-field{display:none}.ssp-field[data-active="0"]~.ssp-field{opacity:.5;pointer-events:none}.ssp-field input[type=text],.ssp-field textarea{width:100%;padding:4px 8px}.ssp-field .hide{display:none}.ssp-field code{margin:0;padding:2px 6px;font-size:inherit;font-style:normal;background:#eee}.ssp-field__body{padding-left:8px}.ssp-field__title{display:block;margin-bottom:16px;padding-left:8px;font-weight:700;font-size:14px;border-left:2px solid #87ab87}.ssp-field__desc{color:#666;font-size:13px;font-style:italic}.ssp-field__item.-radio_btn{display:flex;flex-wrap:wrap}.ssp-field__item.-radio_btn .ssp-field__radioInput{display:none}.ssp-field__item.-radio_btn .ssp-field__radioLabel{width:40px;height:40px;margin:4px;padding:0;line-height:34px;text-align:center;vertical-align:middle;background:#fcfcfc;border:1px solid #ccc;box-shadow:inset 0 0 2px #fff}.ssp-field__item.-radio_btn :checked+.ssp-field__radioLabel{border:2px solid #eba170}.ssp-helpTable{width:100%;max-width:600px;margin:0 0 24px;border-spacing:2px 0}.ssp-helpTable thead th{background:#efefef}.ssp-helpTable td,.ssp-helpTable th{padding:8px;text-align:left}.ssp-helpTable tbody>tr:first-child td{border-top:1px solid #efefef}.ssp-helpTable tbody td{border-bottom:1px solid #efefef}.ssp-helpTable thead:after{display:block;width:100%;height:8px;content:""}.ssp-helpTable code{margin:0 1px;padding:2px 4px;line-height:1;background:#eeefef;border-radius:2px}.ssp-field__preview{display:flex;flex-wrap:wrap;align-items:center;width:100%;padding:4px;font-size:13px}.ssp-field__preview__label{margin-left:4px}.ssp-field__preview__content{display:inline-block;margin-left:8px;padding:12px;background:#ececec;border-radius:3px;box-shadow:inset 0 0 4px #ddd}.ssp-field__preview__content span{margin:0 2px;padding:4px 8px;color:#fff;background:#87ab87;border-radius:4px}.ssp-helpButton{display:inline-block;width:22px;height:22px;margin-left:12px;padding:0;color:#fff!important;font-weight:700;font-size:12px;line-height:22px;text-align:center;text-decoration:none;vertical-align:middle;background:#87ab87;border-radius:50%;box-shadow:inset 0 0 4px rgba(50,50,50,.15);transition:transform .25s}.ssp-helpButton:hover{transform:scale(1.1)}.ssp-page .ssp-page__tabs{padding-bottom:6px;overflow-y:auto}.ssp-page .nav-tab-wrapper{display:flex;border-bottom:1px solid #ddd}.ssp-page .nav-tab{background:rgba(0,0,0,.05);border:none;border-radius:2px 2px 0 0;cursor:pointer}.ssp-page .nav-tab.act_,.ssp-page .nav-tab:hover{color:#000;background:#fdfdfd}.ssp-page .tab-contents{display:none;margin-bottom:1em;padding:16px}.ssp-page .tab-contents.act_{display:block}.ssp_switch{position:relative;display:inline-block;width:48px;height:24px;margin:0 8px}.ssp_switch input{display:none}.ssp_switch__slider{position:absolute;top:0;right:0;bottom:0;left:0;background-color:#ccc;box-shadow:0 0 0 2px #fff,0 0 0 3px #ddd;cursor:pointer;transition:.4s}.ssp_switch__slider:before{position:absolute;right:28px;bottom:4px;width:16px;height:16px;background-color:#fff;transition:.4s;content:""}input:checked+.ssp_switch__slider{background-color:#2196f3}input:checked+.ssp_switch__slider:before{right:4px}.ssp_switch__slider.-round{border-radius:34px}.ssp_switch__slider.-round:before{border-radius:50%}#wpcontent{padding:0 20px!important}.ssp-page{margin-top:1em;padding:8px;font-size:14px}.ssp-page,.ssp-page *{box-sizing:border-box}.ssp-page .form-table,.ssp-page .form-table p,.ssp-page .form-table td,.ssp-page .form-table th,.ssp-page input{font-size:inherit!important}.ssp-page .ssp-page__savedMessage{margin:24px 0}h1.ssp-page__title{font-weight:700;line-height:1.5}.ssp-page__section+.ssp-page__section{margin-top:48px}.ssp-page__section__title{position:relative;padding:8px 0 8px 16px;line-height:1.5;letter-spacing:.5px}.ssp-page__section__title:before{position:absolute;top:50%;left:0;z-index:-1;display:block;width:40px;height:40px;background-image:linear-gradient(-45deg,transparent 25%,#87ab87 0,#87ab87 50%,transparent 0,transparent 75%,#87ab87 0,#87ab87);background-size:6px 6px;border-radius:50%;transform:translateY(-50%);opacity:.4;content:""}.ssp-page__section__body{padding:24px;background:#fff;border-radius:4px;box-shadow:0 2px 4px rgba(0,0,0,.05),0 4px 8px -4px rgba(0,0,0,.1)}.ssp-page__note{padding-left:4px;font-style:italic}textarea[name=home_desc]{max-width:1000px;height:12em}[name=home_keyword]{max-width:1000px}.-webmaster input{max-width:800px}.-webmaster code b{margin:0 2px;padding:2px 4px;color:#fff;font-weight:400;font-size:.9em;background:#87ab87;border-radius:4px}.ssp-field__body{display:flex}@media screen and (max-width:782px){.ssp-field__preview{font-size:12px}.ssp-field__preview__label{display:none}.ssp-field__preview__content{padding:8px}.ssp-helpButton{margin-left:12px}.ssp-page .tab-contents{padding:0}#wpcontent{padding:0 16px!important}.ssp-page{margin-right:0!important;padding:0}.ssp-page__section__body{padding:16px}.ssp-field__body{flex-direction:column}.ssp-field__body .ssp-field__item{order:0}.ssp-field__body .ssp-field__desc{order:2}.ssp-field__body .ssp-field__preview{order:1}}@media screen and (min-width:783px){.ssp-field__body{flex-wrap:wrap;justify-content:space-between}.ssp-field__body .ssp-field__item{width:40%}.ssp-field__body .ssp-field__desc{width:57%}.ssp-field__body.-wide .ssp-field__desc,.ssp-field__body.-wide .ssp-field__item{width:100%}.ssp-field__body.-mt-shorten{margin-top:-24px}}
|
inc/page_help.php
CHANGED
@@ -2,24 +2,59 @@
|
|
2 |
/**
|
3 |
* Help page
|
4 |
*/
|
5 |
-
$
|
6 |
-
'site_title'
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
'
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
'
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
'
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
];
|
24 |
|
25 |
?>
|
@@ -43,14 +78,25 @@ $tags = [
|
|
43 |
<th>
|
44 |
<?=esc_html__( 'Contents to be expanded', 'loos-ssp' )?>
|
45 |
</th>
|
|
|
|
|
|
|
46 |
</tr>
|
47 |
</thead>
|
48 |
<tbody>
|
49 |
-
<?php
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</tbody>
|
55 |
</table>
|
56 |
|
2 |
/**
|
3 |
* Help page
|
4 |
*/
|
5 |
+
$SNIPPET_TAGS = [
|
6 |
+
'site_title' => [
|
7 |
+
'label' => __( 'Site title', 'loos-ssp' ),
|
8 |
+
'for' => __( 'All pages', 'loos-ssp' ),
|
9 |
+
],
|
10 |
+
'tagline' => [
|
11 |
+
'label' => __( 'Site catchphrase', 'loos-ssp' ),
|
12 |
+
'for' => __( 'All pages', 'loos-ssp' ),
|
13 |
+
],
|
14 |
+
'front_description' => [
|
15 |
+
'label' => __( 'Front description', 'loos-ssp' ),
|
16 |
+
'for' => __( 'All pages', 'loos-ssp' ),
|
17 |
+
],
|
18 |
+
'sep' => [
|
19 |
+
'label' => __( 'Delimiter', 'loos-ssp' ),
|
20 |
+
'for' => __( 'All pages', 'loos-ssp' ),
|
21 |
+
],
|
22 |
+
'page_title' => [
|
23 |
+
'label' => __( 'Post title', 'loos-ssp' ),
|
24 |
+
'for' => __( 'Posts and Pages', 'loos-ssp' ),
|
25 |
+
],
|
26 |
+
'page_contents' => [
|
27 |
+
'label' => __( 'Page content', 'loos-ssp' ),
|
28 |
+
'for' => __( 'Posts and Pages', 'loos-ssp' ),
|
29 |
+
],
|
30 |
+
'term_name' => [
|
31 |
+
'label' => __( 'Term name', 'loos-ssp' ),
|
32 |
+
'for' => __( 'Term archives', 'loos-ssp' ),
|
33 |
+
],
|
34 |
+
'term_description' => [
|
35 |
+
'label' => __( 'Term description', 'loos-ssp' ),
|
36 |
+
'for' => __( 'Term archives', 'loos-ssp' ),
|
37 |
+
],
|
38 |
+
'tax_name' => [
|
39 |
+
'label' => __( 'Taxonomy name', 'loos-ssp' ),
|
40 |
+
'for' => __( 'Taxonomy archives', 'loos-ssp' ),
|
41 |
+
],
|
42 |
+
'post_type' => [
|
43 |
+
'label' => __( 'Post type name', 'loos-ssp' ),
|
44 |
+
'for' => __( 'Post Type archives', 'loos-ssp' ),
|
45 |
+
],
|
46 |
+
'date' => [
|
47 |
+
'label' => __( 'The date that is searching in the date archive', 'loos-ssp' ),
|
48 |
+
'for' => __( 'Date archives', 'loos-ssp' ),
|
49 |
+
],
|
50 |
+
'author_name' => [
|
51 |
+
'label' => __( 'Author name', 'loos-ssp' ),
|
52 |
+
'for' => __( 'Author archives', 'loos-ssp' ),
|
53 |
+
],
|
54 |
+
'search_phrase' => [
|
55 |
+
'label' => __( 'Search word', 'loos-ssp' ),
|
56 |
+
'for' => __( 'Search results', 'loos-ssp' ),
|
57 |
+
],
|
58 |
];
|
59 |
|
60 |
?>
|
78 |
<th>
|
79 |
<?=esc_html__( 'Contents to be expanded', 'loos-ssp' )?>
|
80 |
</th>
|
81 |
+
<th>
|
82 |
+
<?=esc_html__( 'Available page', 'loos-ssp' )?>
|
83 |
+
</th>
|
84 |
</tr>
|
85 |
</thead>
|
86 |
<tbody>
|
87 |
+
<?php foreach ( $SNIPPET_TAGS as $name => $data ) : ?>
|
88 |
+
<tr>
|
89 |
+
<td>
|
90 |
+
<code>%_<?=esc_html( $name )?>_%</code>
|
91 |
+
</td>
|
92 |
+
<td>
|
93 |
+
<?=esc_html( $data['label'] )?>
|
94 |
+
</td>
|
95 |
+
<td>
|
96 |
+
<?=esc_html( $data['for'] )?>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<?php endforeach; ?>
|
100 |
</tbody>
|
101 |
</table>
|
102 |
|
inc/tab/top_taxonomy.php
CHANGED
@@ -83,28 +83,31 @@ foreach ( SSP_Data::$custom_taxonomies as $tax_name => $tax_label ) {
|
|
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 |
-
] )
|
|
|
|
|
|
83 |
|
84 |
|
85 |
// 投稿フォーマット
|
86 |
+
$supported_formats = get_theme_support( 'post-formats' );
|
87 |
+
if ( ! empty( $supported_formats ) ) {
|
88 |
+
$tax_title = __( 'Post Format', 'loos-ssp' );
|
89 |
+
$quoted_title = sprintf( SSP_Data::$texts['quoted_archive_title'], $tax_title );
|
90 |
+
self::output_section( $tax_title, [
|
91 |
+
'post_format_disable' => [
|
92 |
+
'title' => sprintf( SSP_Data::$texts['nouse'], $quoted_title ),
|
93 |
+
'type' => 'switch',
|
94 |
+
'desc' => sprintf( __( 'If you select "Yes", you will be redirected to the Home even if you access %s.', 'loos-ssp' ), $quoted_title ),
|
95 |
+
],
|
96 |
+
'post_format_noindex' => [
|
97 |
+
'title' => sprintf( SSP_Data::$texts['noindex'], $quoted_title ),
|
98 |
+
'type' => 'switch',
|
99 |
+
'desc' => SSP_Data::$texts['noindex_help'],
|
100 |
+
],
|
101 |
+
'post_format_title' => [
|
102 |
+
'title' => SSP_Data::$texts['title_tag'],
|
103 |
+
'preview' => true,
|
104 |
+
'desc' => sprintf( SSP_Data::$texts['default_output'], $quoted_title, '<code><title></code>' ),
|
105 |
+
],
|
106 |
+
'post_format_desc' => [
|
107 |
+
'title' => SSP_Data::$texts['description_tag'],
|
108 |
+
'class' => 'sep',
|
109 |
+
'preview' => true,
|
110 |
+
'desc' => sprintf( SSP_Data::$texts['default_output'], $quoted_title, '<code>meta:description</code>' ),
|
111 |
+
],
|
112 |
+
] );
|
113 |
+
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://loos-web-studio.com/
|
|
4 |
Tags: SEO, meta, analytics, wsebmaster, simple, japan, meta tag
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
-
Stable tag:
|
8 |
Requires PHP: 7.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -61,7 +61,6 @@ The following items can be set individually for Posts / Pages and Term pages suc
|
|
61 |
- "meta og:image" tag
|
62 |
|
63 |
|
64 |
-
|
65 |
### About initial settings
|
66 |
|
67 |
Here are some default settings when you haven't changed the settings.
|
@@ -121,6 +120,12 @@ The following hooks are available.
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
= 2.5.1 =
|
125 |
- Replaced do_shortcode() with strip_shortcodes() when generating descriptions.
|
126 |
|
4 |
Tags: SEO, meta, analytics, wsebmaster, simple, japan, meta tag
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
+
Stable tag: 3.0.0
|
8 |
Requires PHP: 7.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
61 |
- "meta og:image" tag
|
62 |
|
63 |
|
|
|
64 |
### About initial settings
|
65 |
|
66 |
Here are some default settings when you haven't changed the settings.
|
120 |
|
121 |
== Changelog ==
|
122 |
|
123 |
+
= 3.0.0 =
|
124 |
+
- Added `'ssp_replace_snippet_{snippet_name}'` hook. (You can now define custom snippets)
|
125 |
+
- Changed some snippet names. (The previous snippet name also works.)
|
126 |
+
- Changed settings for Post Format archives to only show when Post Format support is enabled.
|
127 |
+
- Refactored the code.
|
128 |
+
|
129 |
= 2.5.1 =
|
130 |
- Replaced do_shortcode() with strip_shortcodes() when generating descriptions.
|
131 |
|
seo-simple-pack.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: SEO SIMPLE PACK
|
4 |
* Plugin URI: https://wemo.tech/1670
|
5 |
* Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page.
|
6 |
-
* Version:
|
7 |
* Author: LOOS,Inc.
|
8 |
* Author URI: https://loos-web-studio.com/
|
9 |
* License: GPL2 or later
|
3 |
* Plugin Name: SEO SIMPLE PACK
|
4 |
* Plugin URI: https://wemo.tech/1670
|
5 |
* Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page.
|
6 |
+
* Version: 3.0.0
|
7 |
* Author: LOOS,Inc.
|
8 |
* Author URI: https://loos-web-studio.com/
|
9 |
* License: GPL2 or later
|
src/scss/inc/_help.scss
CHANGED
@@ -2,17 +2,42 @@
|
|
2 |
/* help ページ */
|
3 |
.ssp-helpTable {
|
4 |
width: 100%;
|
5 |
-
max-width:
|
6 |
margin: 0 0 24px;
|
|
|
7 |
// background: #fff;
|
8 |
|
9 |
-
thead {
|
10 |
-
background: #
|
11 |
}
|
12 |
|
13 |
td,
|
14 |
th {
|
15 |
-
padding:
|
16 |
text-align: left;
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
2 |
/* help ページ */
|
3 |
.ssp-helpTable {
|
4 |
width: 100%;
|
5 |
+
max-width: 600px;
|
6 |
margin: 0 0 24px;
|
7 |
+
border-spacing: 2px 0;
|
8 |
// background: #fff;
|
9 |
|
10 |
+
thead th {
|
11 |
+
background: #efefef;
|
12 |
}
|
13 |
|
14 |
td,
|
15 |
th {
|
16 |
+
padding: 8px 8px;
|
17 |
text-align: left;
|
18 |
}
|
19 |
+
|
20 |
+
tbody > tr:first-child td {
|
21 |
+
border-top: 1px solid #efefef;
|
22 |
+
}
|
23 |
+
|
24 |
+
tbody td {
|
25 |
+
border-bottom: 1px solid #efefef;
|
26 |
+
}
|
27 |
+
|
28 |
+
thead::after {
|
29 |
+
display: block;
|
30 |
+
width: 100%;
|
31 |
+
height: 8px;
|
32 |
+
// padding: 4px 0;
|
33 |
+
content: "";
|
34 |
+
}
|
35 |
+
|
36 |
+
code {
|
37 |
+
margin: 0 1px;
|
38 |
+
padding: 2px 4px;
|
39 |
+
line-height: 1;
|
40 |
+
background: #eeefef;
|
41 |
+
border-radius: 2px;
|
42 |
+
}
|
43 |
}
|