From f9fc31d8325b1fee386b6792d2c734bb540c0f03 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 23 May 2021 11:55:22 +0900 Subject: [PATCH] =?UTF-8?q?WP=20PLUGIN=20MTEE(Meta=20Tag=20etc=20Extend)?= =?UTF-8?q?=20=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E6=8A=95=E7=A8=BF?= =?UTF-8?q?=E3=82=A2=E3=83=BC=E3=82=AB=E3=82=A4=E3=83=96=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・カスタム投稿アーカイブのkeywords、description、noindex、nofollowを追加。 --- class/mtee-output.php | 16 ++++- template/pages.php | 148 ++++++++++++++++++++++++++++++------------ 2 files changed, 119 insertions(+), 45 deletions(-) diff --git a/class/mtee-output.php b/class/mtee-output.php index 8bfba48..e1c4d32 100644 --- a/class/mtee-output.php +++ b/class/mtee-output.php @@ -32,6 +32,8 @@ if (!class_exists('mtee_meta_output')) { $metas = array(); if (is_home() || is_front_page()) { $metas = $this->post_output_view_metas('top_page'); + } elseif (is_post_type_archive()) { + $metas = $this->post_output_view_metas('custom_post_archive'); } elseif (is_tax()) { $metas = $this->post_output_view_metas(get_queried_object()->taxonomy); } elseif (is_page() || is_single()) { @@ -65,6 +67,10 @@ if (!class_exists('mtee_meta_output')) { if ($type == 'top_page') { $meta_key_words = get_option('_mtee')['top_page']['keywords']; $meta_description = get_option('_mtee')['top_page']['description']; + } elseif ($type == 'custom_post_archive') { + $custom_post_name = get_post_type_object(get_post_type())->name; + $meta_key_words = get_option('_mtee')['custom_post'][$custom_post_name]['keywords']; + $meta_description = get_option('_mtee')['custom_post'][$custom_post_name]['description']; } elseif ($type == 'custom_tax' || $type == 'category' || $type == 'post_tag') { $queried_object = get_queried_object(); $meta_key_words = get_term_meta($queried_object->term_id, MTEE_NAME_KEYWORDS, true); @@ -148,7 +154,10 @@ if (!class_exists('mtee_meta_output')) { public function set_noindex_nofollow() { global $post; $type = ''; - if (is_category()) { + $id = null; + if (is_post_type_archive()) { + $type = 'custom_post_archive'; + } elseif (is_category()) { $id = get_query_var('cat'); $type = 'tax'; } elseif (is_tag()) { @@ -158,7 +167,6 @@ if (!class_exists('mtee_meta_output')) { $id = get_queried_object()->term_id; $type = 'tax'; } elseif (is_home() || is_front_page()) { - $id = null; $type = 'top_page'; } elseif (is_page() || is_single()) { $id = $post->ID; @@ -196,6 +204,10 @@ if (!class_exists('mtee_meta_output')) { if ($type == 'top_page') { $noindex = get_option('_mtee')['top_page']['noindex']; $nofollow = get_option('_mtee')['top_page']['nofollow']; + } elseif ($type == 'custom_post_archive') { + $custom_post_name = get_post_type_object(get_post_type())->name; + $noindex = get_option('_mtee')['custom_post'][$custom_post_name]['noindex']; + $nofollow = get_option('_mtee')['custom_post'][$custom_post_name]['nofollow']; } elseif ($type == 'posts') { $noindex = get_post_meta($id, MTEE_NAME_NOINDEX, true); $nofollow = get_post_meta($id, MTEE_NAME_NOFOLLOW, true); diff --git a/template/pages.php b/template/pages.php index b5f6e3a..6062105 100644 --- a/template/pages.php +++ b/template/pages.php @@ -1,4 +1,5 @@ register_target(); $opt = get_option('_mtee'); $keywords = $opt['top_page']['keywords'] ?? ''; $description = $opt['top_page']['description'] ?? ''; @@ -9,49 +10,110 @@ $nofollow = $opt['top_page']['nofollow'] ?? '0';

meta keyword, description / ページ設定

is_enable()): ?>
- - -
-

トップページ

- - - - - - - - - - - - - -
meta keywords -
キーワードはカンマ(,)区切りで入力してください -
meta description -
noindex nofollow -
- - -
-
-
-

-
+ + +

トップページ

+
+ + + + + + + + + + + + + +
meta keywords +
キーワードはカンマ(,)区切りで入力してください +
meta description +
noindex nofollow +
+ + +
+
+
+

+ 0): ?> +

カスタム投稿アーカイブ

+ + + +
+

+ label; ?> + () +

+ + + + + + + + + + + + + +
meta keywords +
キーワードはカンマ(,)区切りで入力してください +
meta description +
noindex nofollow +
+ + +
+
+
+

+ + +

全体設定を有効にしてください