Compare commits

..

2 Commits

2 changed files with 119 additions and 45 deletions
+14 -2
View File
@@ -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);
+105 -43
View File
@@ -1,4 +1,5 @@
<?php
$register_target = $this->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';
<h2>meta keyword, description / ページ設定</h2>
<?php if ($this->is_enable()): ?>
<form action="" method="post">
<?php wp_nonce_field('check_options'); ?>
<input type="hidden" name="_mtee[enabled]" value="1">
<div class="mtee-form-box">
<h3>トップページ</h3>
<table class="form-table">
<tr valign="top">
<th>meta keywords</th>
<td><input class="top_page_keywords" type="text" name="_mtee[top_page][keywords]"
value="<?php echo $keywords; ?>">
<br>キーワードはカンマ(,)区切りで入力してください
</td>
</tr>
<tr valign="top">
<th>meta description</th>
<td><input class="top_page_description" type="text" name="_mtee[top_page][description]"
value="<?php echo $description; ?>">
</td>
</tr>
<tr valign="top">
<th>noindex nofollow</th>
<td>
<div class="meta_noindex_nofollow_box">
<label>
<input type="hidden" name="_mtee[top_page][noindex]" value="0"/>
<input type="checkbox"
name="_mtee[top_page][noindex]" <?php checked($noindex, 1); ?>
value="1"/>
noindex
</label>
<label>
<input type="hidden" name="_mtee[top_page][nofollow]" value="0"/>
<input type="checkbox"
name="_mtee[top_page][nofollow]" <?php checked($nofollow, 1); ?>
value="1"/>
nofollow
</label>
</div>
</td>
</tr>
</table>
</div>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
</form>
<?php wp_nonce_field('check_options'); ?>
<input type="hidden" name="_mtee[enabled]" value="1">
<h2>トップページ</h2>
<div class="mtee-form-box">
<table class="form-table">
<tr valign="top">
<th>meta keywords</th>
<td><input class="top_page_keywords" type="text" name="_mtee[top_page][keywords]"
value="<?php echo $keywords; ?>">
<br>キーワードはカンマ(,)区切りで入力してください
</td>
</tr>
<tr valign="top">
<th>meta description</th>
<td><input class="top_page_description" type="text" name="_mtee[top_page][description]"
value="<?php echo $description; ?>">
</td>
</tr>
<tr valign="top">
<th>noindex nofollow</th>
<td>
<div class="meta_noindex_nofollow_box">
<label>
<input type="hidden" name="_mtee[top_page][noindex]" value="0"/>
<input type="checkbox"
name="_mtee[top_page][noindex]" <?php checked($noindex, 1); ?>
value="1"/>
noindex
</label>
<label>
<input type="hidden" name="_mtee[top_page][nofollow]" value="0"/>
<input type="checkbox"
name="_mtee[top_page][nofollow]" <?php checked($nofollow, 1); ?>
value="1"/>
nofollow
</label>
</div>
</td>
</tr>
</table>
</div>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
<?php if (count($register_target['custom_posts']) > 0): ?>
<h2>カスタム投稿アーカイブ</h2>
<?php foreach ($register_target['custom_posts'] as $custom_post): ?>
<?php
$keywords = $opt['custom_post'][$custom_post]['keywords'] ?? '';
$description = $opt['custom_post'][$custom_post]['description'] ?? '';
$noindex = $opt['custom_post'][$custom_post]['noindex'] ?? '0';
$nofollow = $opt['custom_post'][$custom_post]['nofollow'] ?? '0';
?>
<?php wp_nonce_field('check_options'); ?>
<div class="mtee-form-box">
<h3>
<?php echo get_post_type_object($custom_post)->label; ?>
<?php echo $custom_post; ?>
</h3>
<table class="form-table">
<tr valign="top">
<th>meta keywords</th>
<td><input class="top_page_keywords" type="text"
name="_mtee[custom_post][<?php echo $custom_post; ?>][keywords]"
value="<?php echo $keywords; ?>">
<br>キーワードはカンマ(,)区切りで入力してください
</td>
</tr>
<tr valign="top">
<th>meta description</th>
<td><input class="top_page_description" type="text"
name="_mtee[custom_post][<?php echo $custom_post; ?>][description]"
value="<?php echo $description; ?>">
</td>
</tr>
<tr valign="top">
<th>noindex nofollow</th>
<td>
<div class="meta_noindex_nofollow_box">
<label>
<input type="hidden"
name="_mtee[custom_post][<?php echo $custom_post; ?>][noindex]"
value="0"/>
<input type="checkbox"
name="_mtee[custom_post][<?php echo $custom_post; ?>][noindex]" <?php checked($noindex, 1); ?>
value="1"/>
noindex
</label>
<label>
<input type="hidden"
name="_mtee[custom_post][<?php echo $custom_post; ?>][nofollow]"
value="0"/>
<input type="checkbox"
name="_mtee[custom_post][<?php echo $custom_post; ?>][nofollow]" <?php checked($nofollow, 1); ?>
value="1"/>
nofollow
</label>
</div>
</td>
</tr>
</table>
</div>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
<?php endforeach; ?>
</form>
<?php endif; ?>
<!-- /.wrap -->
<?php else: ?>
<h3>全体設定を有効にしてください</h3>