diff --git a/class/mtee-output.php b/class/mtee-output.php index e1c4d32..e58b13d 100644 --- a/class/mtee-output.php +++ b/class/mtee-output.php @@ -31,22 +31,24 @@ if (!class_exists('mtee_meta_output')) { public function post_output_add_metas() { $metas = array(); if (is_home() || is_front_page()) { - $metas = $this->post_output_view_metas('top_page'); + $type = 'top_page'; } elseif (is_post_type_archive()) { - $metas = $this->post_output_view_metas('custom_post_archive'); + $type = 'custom_post_archive'; } elseif (is_tax()) { - $metas = $this->post_output_view_metas(get_queried_object()->taxonomy); + $type = get_queried_object()->taxonomy; } elseif (is_page() || is_single()) { - $metas = $this->post_output_view_metas(get_post_type()); + $type = get_post_type(); } elseif (is_category()) { - $metas = $this->post_output_view_metas('category'); + $type = 'category'; } elseif (is_tag()) { - $metas = $this->post_output_view_metas('post_tag'); + $type = 'post_tag'; + } + if (isset($type)) { + $metas = $this->post_output_view_metas($type); } if (count($metas) == 0) { $metas = $this->create_default_keywords_description(); } - echo implode(PHP_EOL, $metas) . PHP_EOL; } @@ -81,7 +83,7 @@ if (!class_exists('mtee_meta_output')) { } return array( - MTEE_NAME_KEYWORDS => $meta_key_words, + MTEE_NAME_KEYWORDS => str_replace('、', ',', $meta_key_words), MTEE_NAME_DESCRIPTION => $meta_description, ); } @@ -127,27 +129,54 @@ if (!class_exists('mtee_meta_output')) { } private function createDescription() { + $type = ''; + $title = ''; + $suffix_text = MTEE_META_DESC_ARCHIVE_BASE; + if (is_home() || is_front_page()) { //ページ $this->description .= MTEE_META_DESC_TOP_BASE; } elseif (is_page() || is_single()) { //ページ - $replacement = array(get_the_title(), MTEE_META_DESC_SINGLE_BASE); + $type = 'page'; + $title = get_the_title(); + $suffix_text = MTEE_META_DESC_SINGLE_BASE; } elseif (is_category()) { //カテゴリー - $replacement = array(single_cat_title('', false), MTEE_META_DESC_ARCHIVE_BASE); + $type = 'category'; + $title = single_cat_title('', false); } elseif (is_tag()) { //タグ - $replacement = array(single_tag_title('', false), MTEE_META_DESC_ARCHIVE_BASE); + $type = 'tag'; + $title = single_tag_title('', false); } elseif (is_tax()) { //タクソノミー - $replacement = array(single_term_title('', false), MTEE_META_DESC_ARCHIVE_BASE); + $type = 'tax'; + $title = single_term_title('', false); } elseif (is_post_type_archive()) { //カスタム投稿のアーカイブ - $replacement = array(post_type_archive_title('', false), MTEE_META_DESC_ARCHIVE_BASE); + $type = 'custom_post'; + $title = post_type_archive_title('', false); } - if (isset($replacement)) { + $replacement = $this->cnv_custom_template($type, $title, $suffix_text); + + if (isset($replacement['org'])) { $search = array('<###>', '<%%%>'); $description_noun = MTEE_META_DESC_BEFORE_BRACKETS . '<###>' . MTEE_META_DESC_AFTER_BRACKETS . '<%%%>'; $this->description .= str_replace($search, $replacement, $description_noun); } } + private function cnv_custom_template($type, $title, $suffix_text) { + if ($type == 'custom_post') { + return array('org' => array(post_type_archive_title('', false), $suffix_text)); + } + + $template = get_option('_mtee')['description_tmp']; + if (isset($template[$type]) && !empty($template[$type])) { + $search = array('##title##', '##site_name##'); + $replacement = array($title, get_bloginfo('name')); + $this->description = str_replace($search, $replacement, $template[$type]); + } else { + return array('org' => array($title, $suffix_text)); + } + } + //-------------------------------------------------------------------- // noindex, nofollow //-------------------------------------------------------------------- diff --git a/class/mtee.php b/class/mtee.php index 13eb56d..023b9f8 100644 --- a/class/mtee.php +++ b/class/mtee.php @@ -26,23 +26,6 @@ if (!class_exists('MTEE')) { array($this, 'show_option_page'), '' ); - - add_submenu_page( - 'mtee', // parent_slug - 'Settings', // page_title - '全体設定', // menu_title - 'administrator', // capability - 'mtee', // menu_slug - array($this, 'show_option_page') // function - ); - add_submenu_page( - 'mtee', // parent_slug - 'Pages setting', // page_title - 'ページ設定', // menu_title - 'administrator', // capability - 'page_setting', // menu_slug - array($this, 'pages_setting') // function - ); } public function show_option_page() { diff --git a/config.php b/config.php index cbf0b4c..029ff39 100644 --- a/config.php +++ b/config.php @@ -1,15 +1,15 @@ get_options(); // 設定が有効の場合は、各フォームや出力用のクラスを有効にする -if ( $mtee->is_enable() ) { - require_once MTEE_CLASS_DIR . 'mtee-tax-setting.php'; - require_once MTEE_CLASS_DIR . 'mtee-post-setting.php'; - require_once MTEE_CLASS_DIR . 'mtee-output.php'; - new mtee_tax_setting( $options ); - new mtee_post_setting( $options ); - new mtee_meta_output; +if ($mtee->is_enable()) { + require_once MTEE_CLASS_DIR . 'mtee-tax-setting.php'; + require_once MTEE_CLASS_DIR . 'mtee-post-setting.php'; + require_once MTEE_CLASS_DIR . 'mtee-output.php'; + new mtee_tax_setting($options); + new mtee_post_setting($options); + new mtee_meta_output; } -if ( $mtee->is_noindex_nofollow_disable() ) { - require_once MTEE_CLASS_DIR . 'mtee-noindexnofollow-setting.php'; - new mtee_noindexnofolow_setting( $options ); +if ($mtee->is_noindex_nofollow_disable()) { + require_once MTEE_CLASS_DIR . 'mtee-noindexnofollow-setting.php'; + new mtee_noindexnofolow_setting($options); } -if ( $mtee->is_wp_ver_disable() || $mtee->is_asset_ver_disable() ) { - require_once MTEE_CLASS_DIR . 'mtee-version-setting.php'; - new mtee_version_setting( $options ); +if ($mtee->is_wp_ver_disable() || $mtee->is_asset_ver_disable()) { + require_once MTEE_CLASS_DIR . 'mtee-version-setting.php'; + new mtee_version_setting($options); } diff --git a/template/index.php b/template/index.php index 50adc3e..f121bad 100644 --- a/template/index.php +++ b/template/index.php @@ -8,115 +8,265 @@ $noindex_nofollow = $this->get_noindex_nofollow(); ?>

meta keyword, description / バージョン情報 設定

+
-
-

キーワード・ディスクリプション

- +
+
+

キーワード・ディスクリプション

+ +
+ 0 || count($register_targets['taxonomies']) > 0): ?> + + 0): ?> + + + + + + 0): ?> + + + + + +
カスタム投稿 +
    + + +
  • + +
  • + +
+
カスタム分類 +
    + +
  • + + +
  • + +
+
+ + +
+

meta description テンプレート設定

+

個別設定していない投稿やカテゴリー等は、このテンプレートを適用します。

+ +
+
ページ/投稿
+
+ +
カテゴリー
+
+ +
+
タグ
+
+ +
+
カスタム分類
+
+ +
+
+
    +
  • ##site_name##:サイト名(
  • +
  • ##title##:出力対象(投稿、ページ、カテゴリー等)毎のタイトル
  • +
+
+
+

個別設定 NOINDEX/NOFOLLOW

+ +
+
+

WordPressバージョン情報

+ +
+
+

CSS / JSバージョン情報

+ +
+

- 0 || count($register_targets['taxonomies']) > 0): ?> - - 0): ?> - - - + +
カスタム投稿 -
    - - -
  • - -
  • - -
+
+

トップページ

+ +
+ + + + - - 0): ?> - - + + + + + + + +
meta keywords +
キーワードはカンマ(,)区切りで入力してください
カスタム分類
meta description +
noindex nofollow -
    - -
  • - +
    + + +
    +
+
+ 0): ?> +

カスタム投稿アーカイブ

+ + + +
+

+ label; ?> + () +

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

個別設定 NOINDEX/NOFOLLOW

- + +
+
+
+ + +

-
-

WordPressバージョン情報

- -
-
-

CSS / JSバージョン情報

- -
-

\ No newline at end of file diff --git a/template/pages.php b/template/pages.php deleted file mode 100644 index 6062105..0000000 --- a/template/pages.php +++ /dev/null @@ -1,121 +0,0 @@ -register_target(); -$opt = get_option('_mtee'); -$keywords = $opt['top_page']['keywords'] ?? ''; -$description = $opt['top_page']['description'] ?? ''; -$noindex = $opt['top_page']['noindex'] ?? '0'; -$nofollow = $opt['top_page']['nofollow'] ?? '0'; -?> -
-

meta keyword, description / ページ設定

- is_enable()): ?> -
- - -

トップページ

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

- 0): ?> -

カスタム投稿アーカイブ

- - - -
-

- label; ?> - () -

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

- -
- - - -

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

- -
\ No newline at end of file