WP PLUGIN MTEE(Meta Tag etc Extend) トップページ設定追加

・トップページのkeywords、descriptionを追加。
・配列表記をarray()に修正
This commit is contained in:
2021-05-22 10:14:38 +09:00
parent 8593a303e6
commit 48ff68bb01
6 changed files with 428 additions and 299 deletions
+183 -171
View File
@@ -1,202 +1,214 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'mtee_meta_output' ) ) {
if (!class_exists('mtee_meta_output')) {
/**
* HTML出力
* 設定が有効でキーワード・ディスクリプションのカスタムフィールドに登録があればそれを出力する。
* 登録が無い場合は、デフォルトのキーワード・ディスクリプションを出力する。
* Class mtee_meta_output
*
*/
class mtee_meta_output {
/**
* HTML出力
* 設定が有効でキーワード・ディスクリプションのカスタムフィールドに登録があればそれを出力する。
* 登録が無い場合は、デフォルトのキーワード・ディスクリプションを出力する。
* Class mtee_meta_output
*
*/
class mtee_meta_output {
private $site_name;
private $description;
private $site_name;
private $description;
public function __construct() {
$this->site_name = get_bloginfo( 'name' );
$this->description = $this->site_name . MTEE_META_DESC_PARTICLE;
add_action( 'wp_head', array( $this, 'post_output_add_metas' ) );
add_action( 'wp_head', array( $this, 'set_noindex_nofollow' ) );
}
public function __construct() {
$this->site_name = get_bloginfo('name');
$this->description = $this->site_name . MTEE_META_DESC_PARTICLE;
add_action('wp_head', array($this, 'post_output_add_metas'));
add_action('wp_head', array($this, 'set_noindex_nofollow'));
}
//--------------------------------------------------------------------
// meta keywords & meta description
//--------------------------------------------------------------------
public function post_output_add_metas() {
$metas = [];
if ( is_tax() ) {
$metas = $this->post_output_view_metas( get_queried_object()->taxonomy );
} elseif ( is_page() || is_single() ) {
$metas = $this->post_output_view_metas( get_post_type() );
} elseif ( is_category() ) {
$metas = $this->post_output_view_metas( 'category' );
} elseif ( is_tag() ) {
$metas = $this->post_output_view_metas( 'post_tag' );
}
if ( count( $metas ) == 0 ) {
$metas = $this->create_default_keywords_description();
}
echo implode( PHP_EOL, $metas ) . PHP_EOL;
}
//--------------------------------------------------------------------
// meta keywords & meta description
//--------------------------------------------------------------------
public function post_output_add_metas() {
$metas = array();
if (is_home() || is_front_page()) {
$metas = $this->post_output_view_metas('top_page');
} elseif (is_tax()) {
$metas = $this->post_output_view_metas(get_queried_object()->taxonomy);
} elseif (is_page() || is_single()) {
$metas = $this->post_output_view_metas(get_post_type());
} elseif (is_category()) {
$metas = $this->post_output_view_metas('category');
} elseif (is_tag()) {
$metas = $this->post_output_view_metas('post_tag');
}
if (count($metas) == 0) {
$metas = $this->create_default_keywords_description();
}
private function post_output_view_metas( $type ): array {
$targets = get_option( '_mtee' );
if ( isset( $targets['custom_posts'] ) && array_key_exists( $type, $targets['custom_posts'] ) ) {
$type = 'custom_post';
} elseif ( isset( $targets['taxonomies'] ) && array_key_exists( $type, $targets['taxonomies'] ) ) {
$type = 'custom_tax';
}
echo implode(PHP_EOL, $metas) . PHP_EOL;
}
$meta_data = $this->post_output_get_meta_data( $type );
private function post_output_view_metas($type): array {
$targets = get_option('_mtee');
if (isset($targets['custom_posts']) && array_key_exists($type, $targets['custom_posts'])) {
$type = 'custom_post';
} elseif (isset($targets['taxonomies']) && array_key_exists($type, $targets['taxonomies'])) {
$type = 'custom_tax';
}
return $this->create_meta_tags( $meta_data );
}
$meta_data = $this->post_output_get_meta_data($type);
return $this->create_meta_tags($meta_data);
}
private function post_output_get_meta_data( $type ): array {
global $post;
if ( $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 );
$meta_description = get_term_meta( $queried_object->term_id, MTEE_NAME_DESCRIPTION, true );
} else {
$meta_key_words = get_post_meta( $post->ID, MTEE_NAME_KEYWORDS, true );
$meta_description = get_post_meta( $post->ID, MTEE_NAME_DESCRIPTION, true );
}
private function post_output_get_meta_data($type): array {
global $post;
if ($type == 'top_page') {
$meta_key_words = get_option('_mtee')['top_page']['keywords'];
$meta_description = get_option('_mtee')['top_page']['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);
$meta_description = get_term_meta($queried_object->term_id, MTEE_NAME_DESCRIPTION, true);
} else {
$meta_key_words = get_post_meta($post->ID, MTEE_NAME_KEYWORDS, true);
$meta_description = get_post_meta($post->ID, MTEE_NAME_DESCRIPTION, true);
}
return [
MTEE_NAME_KEYWORDS => $meta_key_words,
MTEE_NAME_DESCRIPTION => $meta_description,
];
}
return array(
MTEE_NAME_KEYWORDS => $meta_key_words,
MTEE_NAME_DESCRIPTION => $meta_description,
);
}
private function create_meta_tags( $meta_data ): array {
$metas = [];
if ( ! empty( $meta_data[ MTEE_NAME_KEYWORDS ] ) ) {
$metas[] = str_replace( '##KEYWORDS##', $meta_data[ MTEE_NAME_KEYWORDS ], '<meta name="keywords" content="##KEYWORDS##" />' );
}
if ( ! empty( $meta_data[ MTEE_NAME_DESCRIPTION ] ) ) {
$metas[] = str_replace( '##DISCRIPTION##', $meta_data[ MTEE_NAME_DESCRIPTION ], '<meta name="description" content="##DISCRIPTION##" />' );
}
private function create_meta_tags($meta_data): array {
$metas = array();
if (!empty($meta_data[MTEE_NAME_KEYWORDS])) {
$metas[] = str_replace('##KEYWORDS##', $meta_data[MTEE_NAME_KEYWORDS], '<meta name="keywords" content="##KEYWORDS##" />');
}
if (!empty($meta_data[MTEE_NAME_DESCRIPTION])) {
$metas[] = str_replace('##DISCRIPTION##', $meta_data[MTEE_NAME_DESCRIPTION], '<meta name="description" content="##DISCRIPTION##" />');
}
return $metas;
}
return $metas;
}
public function create_default_keywords_description(): array {
$keywords[] = $this->site_name; //サイトタイトル
if (!empty(get_bloginfo('description'))) {
$keywords[] = get_bloginfo('description'); //サイトタイトル
}
public function create_default_keywords_description(): array {
$keywords[] = $this->site_name; //サイトタイトル
if ( ! empty( get_bloginfo( 'description' ) ) ) {
$keywords[] = get_bloginfo( 'description' ); //サイトタイトル
}
$this->createKeywords($keywords);
$this->createDescription();
$this->createKeywords( $keywords );
$this->createDescription();
$meta_data = array(
MTEE_NAME_KEYWORDS => implode(',', array_reverse($keywords)),
MTEE_NAME_DESCRIPTION => $this->description,
);
$meta_data = [
MTEE_NAME_KEYWORDS => implode( ',', array_reverse( $keywords ) ),
MTEE_NAME_DESCRIPTION => $this->description,
];
return $this->create_meta_tags($meta_data);
}
return $this->create_meta_tags( $meta_data );
}
private function createKeywords(&$keywords) {
if (is_category() || is_tag()) {
$keywords[] = single_cat_title('', false);
} elseif (is_tax()) {
$keywords[] = single_term_title('', false);
} elseif (is_post_type_archive()) {
$keywords[] = post_type_archive_title('', false);
} else {
$keywords[] = get_the_title();
}
}
private function createKeywords( &$keywords ) {
if ( is_category() || is_tag() ) {
$keywords[] = single_cat_title( '', false );
} elseif ( is_tax() ) {
$keywords[] = single_term_title( '', false );
} elseif ( is_post_type_archive() ) {
$keywords[] = post_type_archive_title( '', false );
} else {
$keywords[] = get_the_title();
}
}
private function createDescription() {
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);
} elseif (is_category()) { //カテゴリー
$replacement = array(single_cat_title('', false), MTEE_META_DESC_ARCHIVE_BASE);
} elseif (is_tag()) { //タグ
$replacement = array(single_tag_title('', false), MTEE_META_DESC_ARCHIVE_BASE);
} elseif (is_tax()) { //タクソノミー
$replacement = array(single_term_title('', false), MTEE_META_DESC_ARCHIVE_BASE);
} elseif (is_post_type_archive()) { //カスタム投稿のアーカイブ
$replacement = array(post_type_archive_title('', false), MTEE_META_DESC_ARCHIVE_BASE);
}
private function createDescription() {
if ( is_home() || is_front_page() ) { //ページ
$this->description .= MTEE_META_DESC_TOP_BASE;
}
if (isset($replacement)) {
$search = array('<###>', '<%%%>');
$description_noun = MTEE_META_DESC_BEFORE_BRACKETS . '<###>' . MTEE_META_DESC_AFTER_BRACKETS . '<%%%>';
$this->description .= str_replace($search, $replacement, $description_noun);
}
}
if ( is_page() || is_single() ) { //ページ
$replacement = array( get_the_title(), MTEE_META_DESC_SINGLE_BASE );
} elseif ( is_category() ) { //カテゴリー
$replacement = array( single_cat_title( '', false ), MTEE_META_DESC_ARCHIVE_BASE );
} elseif ( is_tag() ) { //タグ
$replacement = array( single_tag_title( '', false ), MTEE_META_DESC_ARCHIVE_BASE );
} elseif ( is_tax() ) { //タクソノミー
$replacement = array( single_term_title( '', false ), MTEE_META_DESC_ARCHIVE_BASE );
} elseif ( is_post_type_archive() ) { //カスタム投稿のアーカイブ
$replacement = array( post_type_archive_title( '', false ), MTEE_META_DESC_ARCHIVE_BASE );
}
//--------------------------------------------------------------------
// noindex, nofollow
//--------------------------------------------------------------------
public function set_noindex_nofollow() {
global $post;
$type = '';
if (is_category()) {
$id = get_query_var('cat');
$type = 'tax';
} elseif (is_tag()) {
$id = get_query_var('tag_id');
$type = 'tax';
} elseif (is_tax()) {
$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;
$type = 'posts';
}
if ( isset( $replacement ) ) {
$search = array( '<###>', '<%%%>' );
$description_noun = MTEE_META_DESC_BEFORE_BRACKETS . '<###>' . MTEE_META_DESC_AFTER_BRACKETS . '<%%%>';
$this->description .= str_replace( $search, $replacement, $description_noun );
}
}
echo $this->get_noindex_nofollow_data($id, $type);
//--------------------------------------------------------------------
// noindex, nofollow
//--------------------------------------------------------------------
public function set_noindex_nofollow() {
global $post;
$type = '';
if ( is_category() ) {
$id = get_query_var( 'cat' );
$type = 'tax';
} elseif ( is_tag() ) {
$id = get_query_var( 'tag_id' );
$type = 'tax';
} elseif ( is_tax() ) {
$id = get_queried_object()->term_id;
$type = 'tax';
} elseif ( is_home() || is_front_page() || is_page() || is_single() ) {
$id = $post->ID;
$type = 'posts';
}
}
echo $this->get_noindex_nofollow_data( $id, $type );
private function get_noindex_nofollow_data($id, $type) {
if (empty($type)) {
return;
}
}
$status = $this->get_noindex_nofollow_stauts($type, $id);
private function get_noindex_nofollow_data( $id, $type ) {
if ( empty( $type ) ) {
return;
}
$status = $this->get_noindex_nofollow_stauts( $type, $id );
if ( $status['noindex'] == '0' && $status['nofollow'] == '0' ) {
return;
}
if ( $status['noindex'] == '1' && $status['nofollow'] == '1' ) {
return '<meta name="robots" content="noindex,nofollow" />';
}
if ( $status['noindex'] == '1' && $status['nofollow'] == '0' ) {
return '<meta name="robots" content="noindex,follow" />';
}
if ( $status['noindex'] == '0' && $status['nofollow'] == '1' ) {
return '<meta name="robots" content="index,nofollow" />';
}
}
if ($status['noindex'] == '0' && $status['nofollow'] == '0') {
return;
}
if ($status['noindex'] == '1' && $status['nofollow'] == '1') {
return '<meta name="robots" content="noindex,nofollow" />';
}
if ($status['noindex'] == '1' && $status['nofollow'] == '0') {
return '<meta name="robots" content="noindex,follow" />';
}
if ($status['noindex'] == '0' && $status['nofollow'] == '1') {
return '<meta name="robots" content="index,nofollow" />';
}
}
private function get_noindex_nofollow_stauts( $type, $id ) {
if ( $type == 'posts' ) {
$noindex = get_post_meta( $id, MTEE_NAME_NOINDEX, true );
$nofollow = get_post_meta( $id, MTEE_NAME_NOFOLLOW, true );
} elseif ( $type == 'tax' ) {
$noindex = get_term_meta( $id, MTEE_NAME_NOINDEX, true );
$nofollow = get_term_meta( $id, MTEE_NAME_NOFOLLOW, true );
}
private function get_noindex_nofollow_stauts($type, $id): array {
$noindex = 0;
$nofollow = 0;
if ($type == 'top_page') {
$noindex = get_option('_mtee')['top_page']['noindex'];
$nofollow = get_option('_mtee')['top_page']['nofollow'];
} elseif ($type == 'posts') {
$noindex = get_post_meta($id, MTEE_NAME_NOINDEX, true);
$nofollow = get_post_meta($id, MTEE_NAME_NOFOLLOW, true);
} elseif ($type == 'tax') {
$noindex = get_term_meta($id, MTEE_NAME_NOINDEX, true);
$nofollow = get_term_meta($id, MTEE_NAME_NOFOLLOW, true);
}
return array(
'noindex' => $noindex,
'nofollow' => $nofollow,
);
}
return array(
'noindex' => $noindex,
'nofollow' => $nofollow,
);
}
}
}
}
+132 -96
View File
@@ -1,121 +1,157 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
if ( ! class_exists( 'MTEE' ) ) {
if (!class_exists('MTEE')) {
/**
* 基本設定
* キーワード、ディスクリプションのメタボックス有効・無効の設定
* Class MTEE
*/
class MTEE {
/**
* 基本設定
* キーワード、ディスクリプションのメタボックス有効・無効の設定
* Class MTEE
*/
class MTEE {
public function __construct() {
add_action( 'admin_menu', array( $this, 'add_pages' ) );
}
public function __construct() {
add_action('admin_menu', array($this, 'add_pages'));
}
public function add_pages() {
add_menu_page(
'Meta Tag etc Extend',
'MTEE',
'manage_options',
'mtee',
array( $this, 'show_option_page' ),
''
);
}
public function add_pages() {
add_menu_page(
'Meta Tag etc Extend',
'MTEE',
'manage_options',
'mtee',
array($this, 'show_option_page'),
''
);
public function show_option_page() {
//$_POST['_mtee'])があったら保存
if ( isset( $_POST['_mtee'] ) ) {
check_admin_referer( 'check_options' );
$opt = $_POST['_mtee'];
update_option( '_mtee', $opt );
require_once MTEE_TEMPLATE_DIR . 'success.php';
}
require_once MTEE_TEMPLATE_DIR . 'top.php';
}
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 static function register_target(): array {
$custom_posts = get_post_types( array( 'public' => true, '_builtin' => false ) );
$taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
public function show_option_page() {
//$_POST['_mtee'])があったら保存
if (isset($_POST['_mtee'])) {
check_admin_referer('check_options');
$opt = $_POST['_mtee'];
update_option('_mtee', $opt);
require_once MTEE_TEMPLATE_DIR . 'success.php';
}
require_once MTEE_TEMPLATE_DIR . 'index.php';
}
return [
'custom_posts' => $custom_posts,
'taxonomies' => $taxonomies,
];
}
public function pages_setting() {
//$_POST['_mtee'])があったら保存
if (isset($_POST['_mtee'])) {
check_admin_referer('check_options');
$opt = $_POST['_mtee'];
update_option('_mtee', $opt);
require_once MTEE_TEMPLATE_DIR . 'success.php';
}
require_once MTEE_TEMPLATE_DIR . 'pages.php';
}
public function get_options() {
return get_option( '_mtee' );
}
public static function register_target(): array {
$custom_posts = get_post_types(array('public' => true, '_builtin' => false));
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
public function is_enable(): bool {
if ( $this->get_options()['enabled'] == 1 ) {
return true;
}
return [
'custom_posts' => $custom_posts,
'taxonomies' => $taxonomies,
];
}
return false;
}
public function get_options() {
return get_option('_mtee');
}
public function is_wp_ver_disable(): bool {
if ( $this->get_options()['wp_ver_disabled'] == 1 ) {
return true;
}
public function is_enable(): bool {
if (isset($this->get_options()['enabled'])
&& $this->get_options()['enabled'] == 1) {
return true;
}
return false;
}
return false;
}
public function is_asset_ver_disable(): bool {
if ( $this->get_options()['asset_ver_disabled'] == 1 ) {
return true;
}
public function is_wp_ver_disable(): bool {
if (isset($this->get_options()['wp_ver_disabled'])
&& $this->get_options()['wp_ver_disabled'] == 1) {
return true;
}
return false;
}
return false;
}
public function is_noindex_nofollow_disable(): bool {
if ( $this->get_options()['noindex_nofollow'] == '1' ) {
return true;
}
public function is_asset_ver_disable(): bool {
if (isset($this->get_options()['asset_ver_disabled'])
&& $this->get_options()['asset_ver_disabled'] == 1) {
return true;
}
return false;
}
return false;
}
public function get_key_desc_status(): int {
if ( isset( $this->get_options()['enabled'] ) && $this->get_options()['enabled'] == '1' ) {
return 1;
} else {
return 0;
}
}
public function is_noindex_nofollow_disable(): bool {
if (isset($this->get_options()['noindex_nofollow'])
&& $this->get_options()['noindex_nofollow'] == '1') {
return true;
}
public function get_wp_ver_disabled(): int {
if ( isset( $this->get_options()['wp_ver_disabled'] ) && $this->get_options()['wp_ver_disabled'] == '1' ) {
return 1;
} else {
return 0;
}
}
return false;
}
public function get_asset_ver_disabled(): int {
if ( isset( $this->get_options()['asset_ver_disabled'] ) && $this->get_options()['asset_ver_disabled'] == '1' ) {
return 1;
} else {
return 0;
}
}
public function get_key_desc_status(): int {
if (isset($this->get_options()['enabled'])
&& $this->get_options()['enabled'] == '1') {
return 1;
} else {
return 0;
}
}
public function get_noindex_nofollow(): int {
if ( isset( $this->get_options()['noindex_nofollow'] ) && $this->get_options()['noindex_nofollow'] == '1' ) {
return 1;
} else {
return 0;
}
}
public function get_wp_ver_disabled(): int {
if (isset($this->get_options()['wp_ver_disabled'])
&& $this->get_options()['wp_ver_disabled'] == '1') {
return 1;
} else {
return 0;
}
}
}
public function get_asset_ver_disabled(): int {
if (isset($this->get_options()['asset_ver_disabled'])
&& $this->get_options()['asset_ver_disabled'] == '1') {
return 1;
} else {
return 0;
}
}
public function get_noindex_nofollow(): int {
if (isset($this->get_options()['noindex_nofollow'])
&& $this->get_options()['noindex_nofollow'] == '1') {
return 1;
} else {
return 0;
}
}
}
}
+5
View File
@@ -41,4 +41,9 @@ h2 {
.meta_noindex_nofollow_box label {
width: 8em;
}
.top_page_keywords,
.top_page_description {
width: 95%;
}
+14
View File
@@ -6,6 +6,20 @@ Author: Nob Kim
Version: 1.0
*/
/*
Todo:meta keywords & description
・デスクリプションの雛形登録
・カスタム投稿アーカイブページ追加
Todo:OGPタグ
・OGPタグを追加する
<各OGP画像の保存>
・投稿のOGP用画像 => post_meta
・各タクソノミーのOGP画像 => term_meta
・トップ、カスタム投稿アーカイブ => wp_options
*/
include_once 'config.php';
include_once MTEE_CLASS_DIR . 'mtee.php';
+33 -32
View File
@@ -1,90 +1,91 @@
<?php
$register_targets = MTEE::register_target();
$opt = get_option( '_mtee' );
$enabled = $this->get_key_desc_status();
$wp_ver_disabled = $this->get_wp_ver_disabled();
$register_targets = MTEE::register_target();
$opt = get_option('_mtee');
$enabled = $this->get_key_desc_status();
$wp_ver_disabled = $this->get_wp_ver_disabled();
$asset_ver_disabled = $this->get_asset_ver_disabled();
$noindex_nofollow = $this->get_noindex_nofollow();
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br/></div>
<h2>meta keyword, description / バージョン情報 設定</h2>
<form action="" method="post">
<?php wp_nonce_field( 'check_options' ); ?>
<?php wp_nonce_field('check_options'); ?>
<div class="mtee-form-box">
<h3>キーワード・ディスクリプション</h3>
<label>
<input type="hidden" name="_mtee[enabled]" value="0">
<input type="checkbox" name="_mtee[enabled]" <?php checked( $enabled, 1 ); ?>
<input type="checkbox" name="_mtee[enabled]" <?php checked($enabled, 1); ?>
value="1">有効
</label>
</div>
<?php if ( count( $register_targets['custom_posts'] ) > 0 || count( $register_targets['taxonomies'] ) > 0 ): ?>
<?php if (count($register_targets['custom_posts']) > 0 || count($register_targets['taxonomies']) > 0): ?>
<table class="mtee-setting-tbl">
<?php if ( count( $register_targets['custom_posts'] ) > 0 ): ?>
<?php if (count($register_targets['custom_posts']) > 0): ?>
<tr>
<th>カスタム投稿</th>
<td>
<ul>
<?php foreach ( $register_targets['custom_posts'] as $custom_post ) : ?>
<?php foreach ($register_targets['custom_posts'] as $custom_post) : ?>
<?php $custom_post_check = $opt['custom_posts'][$custom_post] ?? 0; ?>
<li>
<label>
<input type="hidden" name="_mtee[custom_posts][<?php echo $custom_post; ?>]"
value="0">
<input type="checkbox"
name="_mtee[custom_posts][<?php echo $custom_post; ?>]"
<?php checked( $opt['custom_posts'][ $custom_post ], 1 ); ?>
<?php checked($custom_post_check, 1); ?>
value="1">
<?php echo $custom_post . '' . get_post_type_object( $custom_post )->label . ''; ?>
<?php echo $custom_post . '' . get_post_type_object($custom_post)->label . ''; ?>
</label>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php endif; ?>
<?php if ( count( $register_targets['taxonomies'] ) > 0 ): ?>
<?php endif; ?>
<?php if (count($register_targets['taxonomies']) > 0): ?>
<tr>
<th>カスタム分類</th>
<td>
<ul>
<?php foreach ( $register_targets['taxonomies'] as $taxonomy ) : ?>
<?php foreach ($register_targets['taxonomies'] as $taxonomy) : ?>
<li>
<?php $taxonomy_check = $opt['taxonomies'][$taxonomy] ?? 0; ?>
<label>
<input type="hidden"
name="_mtee[taxonomies][<?php echo $taxonomy; ?>]" value="0">
<input type="checkbox"
name="_mtee[taxonomies][<?php echo $taxonomy; ?>]"
<?php checked( $opt['taxonomies'][ $taxonomy ], 1 ); ?>
<?php checked($taxonomy_check, 1); ?>
value="1">
<?php echo $taxonomy . '' . get_taxonomy( $taxonomy )->label . ''; ?>
<?php echo $taxonomy . '' . get_taxonomy($taxonomy)->label . ''; ?>
</label>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
</table>
<?php endif; ?>
<?php endif; ?>
<aside class="mtee-example">
<h4>keywordsの初期表示</h4>
<ul>
<li>[各ページ、カテゴリー、タグ等のタイトル],<?php
if ( ! empty( get_bloginfo( 'description' ) ) ) {
echo get_bloginfo( 'description' ) . ',';
}
echo get_bloginfo( 'name' );
?>
if (!empty(get_bloginfo('description'))) {
echo get_bloginfo('description') . ',';
}
echo get_bloginfo('name');
?>
</li>
</ul>
<h4>descriptionの初期表示</h4>
<ul>
<li>トップページ:<?php echo get_bloginfo( 'name' ); ?>
<li>トップページ:<?php echo get_bloginfo('name'); ?>
<?php echo MTEE_META_DESC_TOP_BASE; ?></li>
<li>ページ/投稿:<?php echo get_bloginfo( 'name' ); ?>
<li>ページ/投稿:<?php echo get_bloginfo('name'); ?>
[ページタイトル]<?php echo MTEE_META_DESC_SINGLE_BASE; ?></li>
<li>カテゴリー/タグ等アーカイブ:<?php echo get_bloginfo( 'name' ); ?>
<li>カテゴリー/タグ等アーカイブ:<?php echo get_bloginfo('name'); ?>
[カテゴリー/タグ等タイトル]<?php echo MTEE_META_DESC_SINGLE_BASE; ?></li>
</ul>
</aside>
@@ -93,7 +94,7 @@ $noindex_nofollow = $this->get_noindex_nofollow();
<label>
<input type="hidden" name="_mtee[noindex_nofollow]" value="0">
<input type="checkbox"
name="_mtee[noindex_nofollow]" <?php checked( $noindex_nofollow, 1 ); ?>
name="_mtee[noindex_nofollow]" <?php checked($noindex_nofollow, 1); ?>
value="1">有効
</label>
</div>
@@ -102,7 +103,7 @@ $noindex_nofollow = $this->get_noindex_nofollow();
<label>
<input type="hidden" name="_mtee[wp_ver_disabled]" value="0">
<input type="checkbox"
name="_mtee[wp_ver_disabled]" <?php checked( $wp_ver_disabled, 1 ); ?>
name="_mtee[wp_ver_disabled]" <?php checked($wp_ver_disabled, 1); ?>
value="1">削除
</label>
</div>
@@ -111,7 +112,7 @@ $noindex_nofollow = $this->get_noindex_nofollow();
<label>
<input type="hidden" name="_mtee[asset_ver_disabled]" value="0">
<input type="checkbox"
name="_mtee[asset_ver_disabled]" <?php checked( $asset_ver_disabled, 1 ); ?>
name="_mtee[asset_ver_disabled]" <?php checked($asset_ver_disabled, 1); ?>
value="1">削除
</label>
</div>
+61
View File
@@ -0,0 +1,61 @@
<?php
$register_targets = MTEE::register_target();
$opt = get_option('_mtee');
//var_dump($opt['top_page']);
$keywords = $opt['top_page']['keywords'] ?? '';
$description = $opt['top_page']['description'] ?? '';
$noindex = $opt['top_page']['noindex'] ?? '0';
$nofollow = $opt['top_page']['nofollow'] ?? '0';
?>
<div class="wrap">
<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>
<!-- /.wrap -->
<?php else: ?>
<h3>全体設定を有効にしてください</h3>
<?php endif; ?>
</div>