Compare commits
22 Commits
1925d320ee
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 36650effe1 | |||
| e8f4c139e4 | |||
| 55a8368fec | |||
| dcf7e015a7 | |||
| 937d33817a | |||
| 2eea8e3cae | |||
| e502ea6dce | |||
| 1c1d97cedf | |||
| da6cc8f734 | |||
| 60192377db | |||
| d7826ef2be | |||
| 187f1af050 | |||
| b4f43215ba | |||
| 8c39e705e8 | |||
| 2a28508124 | |||
| 0a00caef21 | |||
| 68b0326e63 | |||
| 59c03d527c | |||
| 0bc4ee1d23 | |||
| c7f4e41e1c | |||
| e2d31cec85 | |||
| 151026ef87 |
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'mtee_post_setting' ) ) {
|
||||
|
||||
/**
|
||||
* ページ、投稿、カスタム投稿の設定フォーム
|
||||
* Class amd_post_setting
|
||||
*/
|
||||
class mtee_post_setting {
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct( $options ) {
|
||||
$this->options = $options;
|
||||
if ( $this->options['enabled'] == 1 ) {
|
||||
add_action( 'admin_menu', array( $this, 'add_meta_fields' ) );
|
||||
add_action( 'save_post', array( $this, 'save_meta_fields' ) );
|
||||
}
|
||||
}
|
||||
|
||||
public function add_meta_fields() {
|
||||
//add_meta_box(表示される入力ボックスのHTMLのID, ラベル, 表示する内容を作成する関数名, 投稿タイプ, 表示方法)
|
||||
$default_built_ins = array(
|
||||
'posts' => array( 'page', 'post', ),
|
||||
);
|
||||
|
||||
foreach ( $default_built_ins['posts'] as $built_in ) {
|
||||
add_meta_box( 'meta_setting', 'meta設定', array( $this, 'insert_meta_fields' ), $built_in, 'normal' );
|
||||
}
|
||||
|
||||
if ( isset( $this->options['custom_posts'] ) ) {
|
||||
foreach ( $this->options['custom_posts'] as $custom_post => $post_chk ) {
|
||||
if ( $post_chk == 1 ) {
|
||||
add_meta_box( 'meta_setting', 'meta設定', array(
|
||||
$this,
|
||||
'insert_meta_fields'
|
||||
), $custom_post, 'normal' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// カスタムフィールドの入力エリア
|
||||
public function insert_meta_fields() {
|
||||
global $post;
|
||||
echo '<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">meta keywords</label>
|
||||
<div><input style="width:100%" type="text" name="' . MTEE_NAME_KEYWORDS . '" value="' . get_post_meta( $post->ID, MTEE_NAME_KEYWORDS, true ) . '" />
|
||||
</div>';
|
||||
echo '<label style="font-weight: bold; display: block">meta description</label>
|
||||
<div><input style="width:100%" type="text" name="' . MTEE_NAME_DESCRIPTION . '" value="' . get_post_meta( $post->ID, MTEE_NAME_DESCRIPTION, true ) . '" />
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields( $post_id ) {
|
||||
if ( ! empty( $_POST[ MTEE_NAME_KEYWORDS ] ) ) { //meta_keywordsが入力されている場合
|
||||
update_post_meta( $post_id, MTEE_NAME_KEYWORDS, $_POST[ MTEE_NAME_KEYWORDS ] ); //値を保存
|
||||
} else { //未入力の場合は値を削除
|
||||
delete_post_meta( $post_id, MTEE_NAME_KEYWORDS );
|
||||
}
|
||||
if ( ! empty( $_POST[ MTEE_NAME_DESCRIPTION ] ) ) {
|
||||
update_post_meta( $post_id, MTEE_NAME_DESCRIPTION, $_POST[ MTEE_NAME_DESCRIPTION ] );
|
||||
} else {
|
||||
delete_post_meta( $post_id, MTEE_NAME_DESCRIPTION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'mtee_tax_setting' ) ) {
|
||||
|
||||
/**
|
||||
* カテゴリー、タグ、カスタム分類の設定フォーム
|
||||
* Class amd_tax_setting
|
||||
*/
|
||||
class mtee_tax_setting {
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct( $options ) {
|
||||
$this->options = $options;
|
||||
$this->set_fields();
|
||||
add_action( 'create_term', array( $this, 'save_terms' ) ); //新規追加用フック
|
||||
add_action( 'edit_terms', array( $this, 'save_terms' ) ); //編集ページ用フック
|
||||
}
|
||||
|
||||
public function set_fields() {
|
||||
$built_ins = array(
|
||||
'term' => array( 'category', 'post_tag' ),
|
||||
);
|
||||
|
||||
foreach ( $built_ins['term'] as $built_in ) {
|
||||
add_action( $built_in . '_add_form_fields', array( $this, 'insert_term_meta_add_fields' ) );
|
||||
add_action( $built_in . '_edit_form_fields', array( $this, 'insert_term_meta_edit_fields' ) );
|
||||
}
|
||||
|
||||
if ( isset( $this->options['taxonomies'] ) ) {
|
||||
foreach ( $this->options['taxonomies'] as $tax_key => $tax_chk ) {
|
||||
if ( $tax_chk == 1 ) {
|
||||
add_action( $tax_key . '_add_form_fields', array( $this, 'insert_term_meta_add_fields' ) );
|
||||
add_action( $tax_key . '_edit_form_fields', array( $this, 'insert_term_meta_edit_fields' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insert_term_meta_add_fields( $tag ) {
|
||||
$key_value = '';
|
||||
$desc_value = '';
|
||||
if ( isset( $tag->term_id ) ) {
|
||||
$key_value = get_term_meta( $tag->term_id, MTEE_NAME_KEYWORDS, true );
|
||||
$desc_value = get_term_meta( $tag->term_id, MTEE_MTEE_NAME_DESCRIPTION, true );
|
||||
}
|
||||
echo '
|
||||
<div class="form-field">
|
||||
meta keywords<br>
|
||||
<input type="text" name="' . MTEE_NAME_KEYWORDS . '" value="' . $key_value . '" class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
meta description<br>
|
||||
<input type="text" name="' . MTEE_NAME_DESCRIPTION . '" value="' . $desc_value . '" class="tax-meta-field" />
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
function insert_term_meta_edit_fields( $tag ) {
|
||||
$key_value = '';
|
||||
$desc_value = '';
|
||||
if ( isset( $tag->term_id ) ) {
|
||||
$key_value = get_term_meta( $tag->term_id, MTEE_NAME_KEYWORDS, true );
|
||||
$desc_value = get_term_meta( $tag->term_id, MTEE_NAME_DESCRIPTION, true );
|
||||
}
|
||||
echo '
|
||||
<tr class="form-field">
|
||||
<th scope="row">meta keywords</th>
|
||||
<td><input type="text" name="' . MTEE_NAME_KEYWORDS . '" value="' . $key_value . '" class="tax-meta-field" /></td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th>meta description</th>
|
||||
<td><input type="text" name="' . MTEE_NAME_DESCRIPTION . '" value="' . $desc_value . '" class="tax-meta-field" /></td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
|
||||
function save_terms( $term_id ) {
|
||||
if ( array_key_exists( MTEE_NAME_KEYWORDS, $_POST ) ) {
|
||||
update_term_meta( $term_id, MTEE_NAME_KEYWORDS, $_POST[ MTEE_NAME_KEYWORDS ] );
|
||||
}
|
||||
if ( array_key_exists( MTEE_NAME_DESCRIPTION, $_POST ) ) {
|
||||
update_term_meta( $term_id, MTEE_NAME_DESCRIPTION, $_POST[ MTEE_NAME_DESCRIPTION ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'mtee_version_setting' ) ) {
|
||||
|
||||
class mtee_version_setting {
|
||||
private $options;
|
||||
|
||||
public function __construct( $options ) {
|
||||
$this->options = $options;
|
||||
$this->change_wp_version_view();
|
||||
$this->change_asset_version_view();
|
||||
}
|
||||
|
||||
public function change_wp_version_view() {
|
||||
if ( $this->options['wp_ver_disabled'] == 1 ) {
|
||||
remove_action( 'wp_head', 'wp_generator' );
|
||||
}
|
||||
}
|
||||
|
||||
public function change_asset_version_view() {
|
||||
if ( $this->options['asset_ver_disabled'] == 1 ) {
|
||||
add_action( 'wp_default_scripts', array( $this, 'remove_src_wp_ver' ) );
|
||||
add_action( 'wp_default_styles', array( $this, 'remove_src_wp_ver' ) );
|
||||
}
|
||||
}
|
||||
|
||||
function remove_src_wp_ver( $dep ) {
|
||||
$dep->default_version = '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+24
-15
@@ -13,6 +13,8 @@ if (!class_exists('MTEE')) {
|
||||
*/
|
||||
class MTEE {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
public function __construct() {
|
||||
add_action('admin_menu', array($this, 'add_pages'));
|
||||
}
|
||||
@@ -32,22 +34,11 @@ if (!class_exists('MTEE')) {
|
||||
//$_POST['_mtee'])があったら保存
|
||||
if (isset($_POST['_mtee'])) {
|
||||
check_admin_referer('check_options');
|
||||
$opt = $_POST['_mtee'];
|
||||
$opt = $this->get_post_sanitize_data('_mtee', 'array');
|
||||
update_option('_mtee', $opt);
|
||||
require_once MTEE_TEMPLATE_DIR . 'success.php';
|
||||
require_once MTEE_CONFIG::MTEE_TEMPLATE_DIR . 'success.php';
|
||||
}
|
||||
require_once MTEE_TEMPLATE_DIR . 'index.php';
|
||||
}
|
||||
|
||||
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';
|
||||
require_once MTEE_CONFIG::MTEE_TEMPLATE_DIR . 'index.php';
|
||||
}
|
||||
|
||||
public static function register_target(): array {
|
||||
@@ -74,7 +65,7 @@ if (!class_exists('MTEE')) {
|
||||
|
||||
public function is_disable($type): bool {
|
||||
if (isset($this->get_options()[$type])
|
||||
&& $this->get_options()['asset_ver_disabled'] == 1) {
|
||||
&& $this->get_options()[$type] == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,5 +80,23 @@ if (!class_exists('MTEE')) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_ogp_img($type, $subtype = '') {
|
||||
if (empty($subtype)) {
|
||||
if (isset(get_option('_mtee')[$type]['ogp_img'])) {
|
||||
$id = get_option('_mtee')[$type]['ogp_img'];
|
||||
}
|
||||
}
|
||||
if (!empty($subtype)) {
|
||||
if (isset(get_option('_mtee')[$type][$subtype]['ogp_img'])) {
|
||||
$id = get_option('_mtee')[$type][$subtype]['ogp_img'];
|
||||
}
|
||||
}
|
||||
if (!empty($id)) {
|
||||
return '<img src="' . esc_html(wp_get_attachment_image_src($id, 'thumbnail')[0]) . '">';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ if (!class_exists('mtee_canonical_setting')) {
|
||||
*/
|
||||
class mtee_canonical_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
@@ -33,31 +35,19 @@ if (!class_exists('mtee_canonical_setting')) {
|
||||
//-------------------------------------------------------------------------------------------
|
||||
public function add_meta_fields() {
|
||||
//add_meta_box(表示される入力ボックスのHTMLのID, ラベル, 表示する内容を作成する関数名, 投稿タイプ, 表示方法)
|
||||
$default_built_ins = array(
|
||||
'posts' => array('page', 'post',),
|
||||
);
|
||||
$custom_posts = array_values(get_post_types(array('public' => true, '_builtin' => false)));
|
||||
$target_posts = array_merge(array('page', 'post',), $custom_posts);
|
||||
|
||||
foreach ($default_built_ins['posts'] as $built_in) {
|
||||
foreach ($target_posts as $target_post) {
|
||||
add_meta_box(
|
||||
'canonical_setting',
|
||||
'Canonical設定',
|
||||
array($this, 'insert_meta_fields'),
|
||||
$built_in,
|
||||
'normal'
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->options['custom_posts'])) {
|
||||
foreach ($this->options['custom_posts'] as $custom_post => $post_chk) {
|
||||
if ($post_chk == 1) {
|
||||
add_meta_box(
|
||||
'canonical_setting',
|
||||
'Canonical設定',
|
||||
array($this, 'insert_meta_fields'),
|
||||
$custom_post, 'normal'
|
||||
);
|
||||
}
|
||||
}
|
||||
array(
|
||||
$this,
|
||||
'insert_meta_fields'
|
||||
),
|
||||
$target_post,
|
||||
'normal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,20 +55,27 @@ if (!class_exists('mtee_canonical_setting')) {
|
||||
public function insert_meta_fields() {
|
||||
global $post;
|
||||
echo '<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">Canonical URL</label>
|
||||
<label class="block_bold">Canonical URL</label>
|
||||
<div>
|
||||
<input style="width:100%" type="text" name="' . MTEE_CANONICAL_URL . '" value="' . get_post_meta($post->ID, MTEE_CANONICAL_URL, true) . '"/>
|
||||
<input class="width_100" type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_CANONICAL_URL) . '"
|
||||
value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_CANONICAL_URL, true)) . '"
|
||||
placeholder="' . esc_attr($this->set_default_post_canonical_url($post->ID)) . '" />
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields($post_id) {
|
||||
if (!empty($_POST[MTEE_CANONICAL_URL])) { //meta_keywordsが入力されている場合
|
||||
update_post_meta($post_id, MTEE_CANONICAL_URL, $_POST[MTEE_CANONICAL_URL]); //値を保存
|
||||
} else { //未入力の場合は値を削除
|
||||
delete_post_meta($post_id, MTEE_CANONICAL_URL);
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_CANONICAL_URL);
|
||||
}
|
||||
|
||||
public function set_default_post_canonical_url($id) {
|
||||
$canonical = get_permalink($id);
|
||||
global $page, $paged;
|
||||
if ($paged >= 2 || $page >= 2) {
|
||||
$canonical .= 'page/' . max($paged, $page) . '/';
|
||||
}
|
||||
return $canonical;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
@@ -104,33 +101,59 @@ if (!class_exists('mtee_canonical_setting')) {
|
||||
}
|
||||
|
||||
public function add_tax_term_fields($tag) {
|
||||
$form = '<div class="form-field">Canonical URL<br>##CONTENTS##</div>';
|
||||
|
||||
echo $this->insert_term_meta_fields($tag, $form);
|
||||
$canonical_url = $this->create_canonical_url($tag);
|
||||
$placeholder = $this->create_placeholder($tag, $canonical_url);
|
||||
echo '<div class="form-field">Canonical URL<br>';
|
||||
echo '<input type="text"
|
||||
name="' . esc_attr(MTEE_CONFIG::MTEE_CANONICAL_URL) . '"
|
||||
value="' . esc_attr($canonical_url) . '"
|
||||
placeholder="' . esc_attr($placeholder) . '" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function edit_tax_term_fields($tag) {
|
||||
$form = '<tr class="form-field">
|
||||
<th scope="row">Canonical URL</th>
|
||||
<td>##CONTENTS##</td>
|
||||
$canonical_url = $this->create_canonical_url($tag);
|
||||
$placeholder = $this->create_placeholder($tag, $canonical_url);
|
||||
echo '<tr class="form-field">
|
||||
<th scope="row">Canonical URL</th>
|
||||
<td>';
|
||||
echo '<input type="text"
|
||||
name="' . esc_attr(MTEE_CONFIG::MTEE_CANONICAL_URL) . '"
|
||||
value="' . esc_attr($canonical_url) . '"
|
||||
placeholder="' . esc_attr($placeholder) . '" />';
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
||||
echo $this->insert_term_meta_fields($tag, $form);
|
||||
}
|
||||
|
||||
public function insert_term_meta_fields($tag, $form) {
|
||||
private function create_canonical_url($tag) {
|
||||
$canonical_url = '';
|
||||
if (isset($tag->term_id)) {
|
||||
$canonical_url = get_term_meta($tag->term_id, MTEE_CANONICAL_URL, true);
|
||||
$canonical_url = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_CANONICAL_URL, true);
|
||||
}
|
||||
$add_meta = '<input type="text" name="' . MTEE_CANONICAL_URL . '" value="' . $canonical_url . '"/>';
|
||||
return str_replace('##CONTENTS##', $add_meta, $form);
|
||||
return $canonical_url;
|
||||
}
|
||||
|
||||
private function create_placeholder($tag, $canonical_url) {
|
||||
$placeholder = '';
|
||||
if (isset($tag->term_id) && empty($canonical_url)) {
|
||||
$placeholder = $this->set_default_tax_canonical_url($tag->term_id, $tag->taxonomy);
|
||||
}
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
private function set_default_tax_canonical_url($id, $taxonomy) {
|
||||
if ($taxonomy == 'category') {
|
||||
$placeholder = get_category_link($id);
|
||||
} elseif ($taxonomy == 'post_tag') {
|
||||
$placeholder = get_tag_link($id);
|
||||
} else {
|
||||
$placeholder = get_term_link((int)$id);
|
||||
}
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
public function save_terms($term_id) {
|
||||
if (array_key_exists(MTEE_CANONICAL_URL, $_POST)) {
|
||||
update_term_meta($term_id, MTEE_CANONICAL_URL, $_POST[MTEE_CANONICAL_URL]);
|
||||
}
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_CANONICAL_URL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
$type = 'posts';
|
||||
}
|
||||
|
||||
echo $this->get_canonical_data($id, $type);
|
||||
echo '<link rel="canonical" href="' . esc_html($this->get_canonical_data($id, $type)) . '">' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
@@ -61,10 +61,7 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
} elseif ($type == 'tax') {
|
||||
$canonical = $this->set_tax_canonical($id);
|
||||
}
|
||||
|
||||
if ($canonical) {
|
||||
return '<link rel="canonical" href="' . $canonical . '">' . PHP_EOL;
|
||||
}
|
||||
return $canonical;
|
||||
}
|
||||
|
||||
public function set_top_page_canonical() {
|
||||
@@ -85,7 +82,7 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
}
|
||||
|
||||
public function set_post_canonical($id) {
|
||||
$canonical = get_post_meta($id, MTEE_CANONICAL_URL, true);
|
||||
$canonical = get_post_meta($id, MTEE_CONFIG::MTEE_CANONICAL_URL, true);
|
||||
if (empty($canonical)) {
|
||||
$canonical = get_permalink($id);
|
||||
global $page, $paged;
|
||||
@@ -97,7 +94,7 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
}
|
||||
|
||||
public function set_category_canonical($id) {
|
||||
$canonical = get_term_meta($id, MTEE_CANONICAL_URL, true);
|
||||
$canonical = get_term_meta($id, MTEE_CONFIG::MTEE_CANONICAL_URL, true);
|
||||
if (empty($canonical)) {
|
||||
$canonical = get_category_link($id);
|
||||
}
|
||||
@@ -105,7 +102,7 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
}
|
||||
|
||||
public function set_tag_canonical($id) {
|
||||
$canonical = get_term_meta($id, MTEE_CANONICAL_URL, true);
|
||||
$canonical = get_term_meta($id, MTEE_CONFIG::MTEE_CANONICAL_URL, true);
|
||||
if (empty($canonical)) {
|
||||
$canonical = get_tag_link($id);
|
||||
}
|
||||
@@ -113,9 +110,9 @@ if (!class_exists('mtee_meta_output_canonical')) {
|
||||
}
|
||||
|
||||
public function set_tax_canonical($id) {
|
||||
$canonical = get_term_meta($id, MTEE_CANONICAL_URL, true);
|
||||
$canonical = get_term_meta($id, MTEE_CONFIG::MTEE_CANONICAL_URL, true);
|
||||
if (empty($canonical)) {
|
||||
$canonical = get_term_link($id);
|
||||
$canonical = get_term_link((int)$id);
|
||||
}
|
||||
return $canonical;
|
||||
}
|
||||
@@ -6,22 +6,33 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
|
||||
include MTEE_CONFIG::MTEE_TRAIT_DIR . 'mtee_meta_desc_trait.php';
|
||||
|
||||
class mtee_meta_output_keydesc {
|
||||
|
||||
use mtee_meta_desc_trait;
|
||||
|
||||
private $site_name;
|
||||
private $description;
|
||||
private $metas = array();
|
||||
|
||||
public function __construct() {
|
||||
$this->site_name = get_bloginfo('name');
|
||||
$this->description = $this->site_name . MTEE_META_DESC_PARTICLE;
|
||||
$this->description = $this->site_name . MTEE_CONFIG::MTEE_META_DESC_PARTICLE;
|
||||
add_action('wp_head', array($this, 'post_output_add_metas'));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// meta keywords & meta description
|
||||
//--------------------------------------------------------------------
|
||||
public function post_output_add_metas() {
|
||||
$metas = array();
|
||||
$this->create_post_output_add_metas();
|
||||
if (isset($this->metas[MTEE_CONFIG::MTEE_NAME_KEYWORDS])) {
|
||||
echo '<meta name="keywords" content="' . esc_attr($this->metas[MTEE_CONFIG::MTEE_NAME_KEYWORDS]) . '" />';
|
||||
}
|
||||
if (isset($this->metas[MTEE_CONFIG::MTEE_NAME_DESCRIPTION])) {
|
||||
echo '<meta name="description" content="' . esc_attr($this->metas[MTEE_CONFIG::MTEE_NAME_DESCRIPTION]) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
public function create_post_output_add_metas() {
|
||||
if (is_home() || is_front_page()) {
|
||||
$type = 'top_page';
|
||||
} elseif (is_post_type_archive()) {
|
||||
@@ -36,97 +47,51 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
$type = 'post_tag';
|
||||
}
|
||||
if (isset($type)) {
|
||||
$metas = $this->post_output_view_metas($type);
|
||||
$this->post_output_view_metas($type);
|
||||
}
|
||||
if (count($metas) == 0) {
|
||||
$metas = $this->create_default_keywords_description();
|
||||
if (count($this->metas) == 0) {
|
||||
$this->create_default_keywords_description();
|
||||
}
|
||||
echo implode(PHP_EOL, $metas) . PHP_EOL;
|
||||
}
|
||||
|
||||
public function post_output_view_metas($type): array {
|
||||
public function post_output_view_metas($type) {
|
||||
$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';
|
||||
}
|
||||
|
||||
$meta_data = $this->post_output_get_meta_data($type);
|
||||
return $this->create_meta_tags($meta_data);
|
||||
$this->metas = array(
|
||||
MTEE_CONFIG::MTEE_NAME_KEYWORDS => str_replace('、', ',', $this->post_output_get_meta_keywords($type)),
|
||||
MTEE_CONFIG::MTEE_NAME_DESCRIPTION => $this->post_output_get_meta_desc($type),
|
||||
);
|
||||
}
|
||||
|
||||
public function post_output_get_meta_data($type): array {
|
||||
public function post_output_get_meta_keywords($type) {
|
||||
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_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);
|
||||
$meta_description = get_term_meta($queried_object->term_id, MTEE_NAME_DESCRIPTION, true);
|
||||
$meta_key_words = get_term_meta($queried_object->term_id, MTEE_CONFIG::MTEE_NAME_KEYWORDS, 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);
|
||||
$meta_key_words = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_KEYWORDS, true);
|
||||
}
|
||||
return $meta_key_words;
|
||||
}
|
||||
|
||||
return array(
|
||||
MTEE_NAME_KEYWORDS => str_replace('、', ',', $meta_key_words),
|
||||
MTEE_NAME_DESCRIPTION => $meta_description,
|
||||
public function create_default_keywords_description() {
|
||||
$this->description .= $this->create_default_description();
|
||||
$this->metas = array(
|
||||
MTEE_CONFIG::MTEE_NAME_KEYWORDS => implode(',', $this->create_default_keywords()),
|
||||
MTEE_CONFIG::MTEE_NAME_DESCRIPTION => $this->description,
|
||||
);
|
||||
}
|
||||
|
||||
public function create_default_keywords_description(): array {
|
||||
$keywords = $this->create_default_keywords();
|
||||
$this->create_default_description();
|
||||
$meta_data = array(
|
||||
MTEE_NAME_KEYWORDS => implode(',', $keywords),
|
||||
MTEE_NAME_DESCRIPTION => $this->description,
|
||||
);
|
||||
|
||||
return $this->create_meta_tags($meta_data);
|
||||
}
|
||||
|
||||
public function create_default_description() {
|
||||
$type = '';
|
||||
$title = '';
|
||||
$suffix_text = MTEE_META_DESC_ARCHIVE_BASE;
|
||||
|
||||
if (is_home() || is_front_page()) { //ページ
|
||||
$this->description .= MTEE_META_DESC_TOP_BASE;
|
||||
return;
|
||||
} elseif (is_page() || is_single()) { //ページ
|
||||
$type = 'page';
|
||||
$title = get_the_title();
|
||||
$suffix_text = MTEE_META_DESC_SINGLE_BASE;
|
||||
} elseif (is_category()) { //カテゴリー
|
||||
$type = 'category';
|
||||
$title = single_cat_title('', false);
|
||||
} elseif (is_tag()) { //タグ
|
||||
$type = 'tag';
|
||||
$title = single_tag_title('', false);
|
||||
} elseif (is_tax()) { //タクソノミー
|
||||
$type = 'tax';
|
||||
$title = single_term_title('', false);
|
||||
} elseif (is_post_type_archive()) { //カスタム投稿のアーカイブ
|
||||
$type = 'custom_post';
|
||||
$title = post_type_archive_title('', false);
|
||||
}
|
||||
|
||||
$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['org'], $description_noun);
|
||||
}
|
||||
}
|
||||
|
||||
public function create_default_keywords() {
|
||||
public function create_default_keywords(): array {
|
||||
$type = '';
|
||||
$title = '';
|
||||
if (is_category()) {
|
||||
@@ -158,7 +123,7 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
|
||||
}
|
||||
|
||||
public function get_keywords_data($type, $keyword) {
|
||||
public function get_keywords_data($type, $keyword): array {
|
||||
$keywords = array();
|
||||
$keywords[] = $this->site_name; //サイトタイトル
|
||||
if (!empty(get_bloginfo('description'))) {
|
||||
@@ -172,7 +137,7 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
return array_reverse($keywords);
|
||||
}
|
||||
|
||||
public function get_custom_template_keywords_data($custom_keywords_temp, $type, $title) {
|
||||
public function get_custom_template_keywords_data($custom_keywords_temp, $type, $title): array {
|
||||
$targets = explode(',', $custom_keywords_temp[$type]);
|
||||
$keywords = array();
|
||||
foreach ($targets as $target) {
|
||||
@@ -244,30 +209,14 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
|
||||
public 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_CONFIG::MTEE_NAME_KEYWORDS])) {
|
||||
$metas[MTEE_CONFIG::MTEE_NAME_KEYWORDS] = str_replace('##KEYWORDS##', $meta_data[MTEE_CONFIG::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##" />');
|
||||
if (!empty($meta_data[MTEE_CONFIG::MTEE_NAME_DESCRIPTION])) {
|
||||
$metas[MTEE_CONFIG::MTEE_NAME_DESCRIPTION] = str_replace('##DISCRIPTION##', $meta_data[MTEE_CONFIG::MTEE_NAME_DESCRIPTION], '<meta name="description" content="##DISCRIPTION##" />');
|
||||
}
|
||||
return $metas;
|
||||
}
|
||||
|
||||
public 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##', '##site_description##');
|
||||
$replacement = array($title, get_bloginfo('name'), get_bloginfo('description'));
|
||||
$this->description = str_replace($search, $replacement, $template[$type]);
|
||||
} else {
|
||||
return array('org' => array($title, $suffix_text));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ if (!class_exists('mtee_meta_output_noindexnofollow')) {
|
||||
$type = 'posts';
|
||||
}
|
||||
|
||||
echo $this->get_noindex_nofollow_data($id, $type);
|
||||
$this->get_noindex_nofollow_data($id, $type);
|
||||
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ if (!class_exists('mtee_meta_output_noindexnofollow')) {
|
||||
return;
|
||||
}
|
||||
if ($status['noindex'] == '1' && $status['nofollow'] == '1') {
|
||||
return '<meta name="robots" content="noindex,nofollow" />';
|
||||
echo '<meta name="robots" content="noindex,nofollow" />';
|
||||
}
|
||||
if ($status['noindex'] == '1' && $status['nofollow'] == '0') {
|
||||
return '<meta name="robots" content="noindex,follow" />';
|
||||
echo '<meta name="robots" content="noindex,follow" />';
|
||||
}
|
||||
if ($status['noindex'] == '0' && $status['nofollow'] == '1') {
|
||||
return '<meta name="robots" content="index,nofollow" />';
|
||||
echo '<meta name="robots" content="index,nofollow" />';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ if (!class_exists('mtee_meta_output_noindexnofollow')) {
|
||||
$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);
|
||||
$noindex = get_post_meta($id, MTEE_CONFIG::MTEE_NAME_NOINDEX, true);
|
||||
$nofollow = get_post_meta($id, MTEE_CONFIG::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);
|
||||
$noindex = get_term_meta($id, MTEE_CONFIG::MTEE_NAME_NOINDEX, true);
|
||||
$nofollow = get_term_meta($id, MTEE_CONFIG::MTEE_NAME_NOFOLLOW, true);
|
||||
}
|
||||
|
||||
return array(
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_meta_output_ogp')) {
|
||||
|
||||
class mtee_meta_output_ogp {
|
||||
|
||||
use mtee_meta_desc_trait;
|
||||
|
||||
public $site_name = '';
|
||||
public $ogp_type = '';
|
||||
public $ogp_description = '';
|
||||
public $ogp_title = '';
|
||||
public $ogp_url = '';
|
||||
public $ogp_img = '';
|
||||
|
||||
public function __construct() {
|
||||
$this->site_name = get_bloginfo('name');
|
||||
//GOPのプレフィックスを出力する
|
||||
add_filter('language_attributes', array($this, 'add_html_ogp_prefix'));
|
||||
add_action('wp_head', array($this, 'create_ogp_tag'));
|
||||
}
|
||||
|
||||
/**
|
||||
* GOPのプレフィックスを設定する
|
||||
* @param $output
|
||||
* @return string
|
||||
*/
|
||||
public function add_html_ogp_prefix($output): string {
|
||||
$output .= $this->create_ogp_prefix();
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function create_ogp_prefix(): string {
|
||||
return ' prefix="og: https://ogp.me/ns#"';
|
||||
}
|
||||
|
||||
public function create_ogp_tag() {
|
||||
$this->create_ogp_type();
|
||||
$this->create_ogp_title();
|
||||
$this->create_ogp_description();
|
||||
$this->create_ogp_image();
|
||||
$this->create_ogp_url();
|
||||
$this->set_ogp_tag();
|
||||
}
|
||||
|
||||
|
||||
public function set_ogp_tag() {
|
||||
echo '<meta property="og:title" content="' . esc_attr($this->ogp_title) . '" />' . PHP_EOL;
|
||||
echo '<meta property="og:description" content="' . esc_attr($this->ogp_description) . '" />' . PHP_EOL;
|
||||
echo '<meta property="og:type" content="' . esc_attr($this->ogp_type) . '" />' . PHP_EOL;
|
||||
echo '<meta property="og:url" content="' . esc_attr($this->ogp_url) . '" />' . PHP_EOL;
|
||||
if (!empty($this->ogp_img)) {
|
||||
echo '<meta property="og:image" content="' . esc_attr($this->ogp_img) . '" />' . PHP_EOL;
|
||||
}
|
||||
echo '<meta property="og:site_name" content="' . esc_attr($this->site_name) . '" />' . PHP_EOL;
|
||||
// $tags .= '<meta name="twitter:card" content="summary_large_image" />' . PHP_EOL;
|
||||
// $tags .= '<meta name="twitter:site" content="ツイッターのアカウント名" />' . PHP_EOL;
|
||||
echo '<meta property="og:locale" content="' . esc_attr($this->get_ogp_locale()) . '" />' . PHP_EOL;
|
||||
}
|
||||
|
||||
public function get_ogp_locale(): string {
|
||||
$locale = get_locale();
|
||||
if (strlen($locale) == 2) {
|
||||
if ($locale === "ja")
|
||||
return "ja_JP";
|
||||
else
|
||||
return strtolower($locale) . '_' . strtoupper($locale);
|
||||
}
|
||||
}
|
||||
|
||||
public function create_ogp_type() {
|
||||
if (is_home() || is_front_page()) {
|
||||
$this->ogp_type = 'website';
|
||||
} else {
|
||||
$this->ogp_type = 'article';
|
||||
}
|
||||
}
|
||||
|
||||
public function create_ogp_title() {
|
||||
global $post;
|
||||
if (is_home() || is_front_page()) {
|
||||
$this->ogp_title = get_option('_mtee')['top_page']['ogp_title'];
|
||||
} elseif (is_post_type_archive()) {
|
||||
$custom_post_name = get_post_type_object(get_post_type())->name;
|
||||
$this->ogp_title = get_option('_mtee')['custom_post'][$custom_post_name]['ogp_title'];
|
||||
} elseif (is_category() || is_tag() || is_tax()) {
|
||||
$queried_object = get_queried_object();
|
||||
$this->ogp_title = get_term_meta($queried_object->term_id, MTEE_CONFIG::MTEE_OGP_TITLE, true);
|
||||
} elseif (is_page() || is_single()) {
|
||||
$this->ogp_title = get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_TITLE, true);
|
||||
}
|
||||
if (empty($this->ogp_title)) {
|
||||
$this->create_default_title();
|
||||
}
|
||||
}
|
||||
|
||||
public function create_default_title() {
|
||||
if (is_category()) {
|
||||
$this->ogp_title = single_cat_title('', false);
|
||||
} elseif (is_tag()) {
|
||||
$this->ogp_title = single_cat_title('', false);
|
||||
} elseif (is_tax()) {
|
||||
$this->ogp_title = single_term_title('', false);
|
||||
} elseif (is_post_type_archive()) {
|
||||
$this->ogp_title = post_type_archive_title('', false);
|
||||
} elseif (is_single() || is_page()) {
|
||||
$this->ogp_title = get_the_title();
|
||||
} elseif (is_home() || is_front_page()) {
|
||||
$this->ogp_title = $this->site_name;
|
||||
}
|
||||
}
|
||||
|
||||
public function create_ogp_description() {
|
||||
$this->create_input_description();
|
||||
if (empty($this->ogp_description)) {
|
||||
$this->set_default_description();
|
||||
}
|
||||
}
|
||||
|
||||
public function create_input_description() {
|
||||
global $post;
|
||||
if (is_home() || is_front_page()) {
|
||||
$this->ogp_description = get_option('_mtee')['top_page']['ogp_description'];
|
||||
} elseif (is_post_type_archive()) {
|
||||
$custom_post_name = get_post_type_object(get_post_type())->name;
|
||||
$this->ogp_description = get_option('_mtee')['custom_post'][$custom_post_name]['ogp_description'];
|
||||
} elseif (is_category() || is_tag() || is_tax()) {
|
||||
$queried_object = get_queried_object();
|
||||
$this->ogp_description = get_term_meta($queried_object->term_id, MTEE_CONFIG::MTEE_OGP_DESC, true);
|
||||
} elseif (is_page() || is_single()) {
|
||||
$this->ogp_description = get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_DESC, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function set_default_description() {
|
||||
$this->ogp_description = $this->site_name . MTEE_CONFIG::MTEE_META_DESC_PARTICLE;
|
||||
$type = '';
|
||||
$ogp_desc = '';
|
||||
|
||||
if (is_home() || is_front_page()) {
|
||||
$type = 'top_page';
|
||||
} elseif (is_post_type_archive()) {
|
||||
$type = 'custom_post_archive';
|
||||
} elseif (is_tax()) {
|
||||
$type = get_queried_object()->taxonomy;
|
||||
} elseif (is_page() || is_single()) {
|
||||
$type = get_post_type();
|
||||
} elseif (is_category()) {
|
||||
$type = 'category';
|
||||
} elseif (is_tag()) {
|
||||
$type = 'post_tag';
|
||||
}
|
||||
|
||||
$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';
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
$this->ogp_description .= $this->post_output_get_meta_desc($type);
|
||||
}
|
||||
|
||||
if (empty($ogp_desc)) {
|
||||
$this->ogp_description .= $this->create_default_description();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function create_ogp_url() {
|
||||
global $post;
|
||||
if (is_category()) {
|
||||
$this->ogp_url = get_category_link(get_query_var('cat'));
|
||||
} elseif (is_tag()) {
|
||||
$this->ogp_url = get_tag_link(get_query_var('tag_id'));
|
||||
} elseif (is_tax()) {
|
||||
$this->ogp_url = get_term_link((int)get_queried_object()->term_id);
|
||||
} elseif (is_post_type_archive()) {
|
||||
$custom_post_name = get_post_type_object(get_post_type())->name;
|
||||
$this->ogp_url = get_post_type_archive_link($custom_post_name);
|
||||
} elseif (is_single() || is_page()) {
|
||||
$this->ogp_url = get_permalink($post->ID);
|
||||
global $page, $paged;
|
||||
if ($paged >= 2 || $page >= 2) {
|
||||
$this->ogp_url .= 'page/' . max($paged, $page) . '/';
|
||||
}
|
||||
} elseif (is_home() || is_front_page()) {
|
||||
$this->ogp_url = get_bloginfo('url');
|
||||
}
|
||||
}
|
||||
|
||||
public function create_ogp_image() {
|
||||
global $post;
|
||||
if (is_post_type_archive()) {
|
||||
$this->set_custom_post_archive_ogp_img();
|
||||
} elseif (is_category()) {
|
||||
$this->set_category_ogp_img(get_query_var('cat'));
|
||||
} elseif (is_tag()) {
|
||||
$this->set_tag_ogp_img(get_query_var('tag_id'));
|
||||
} elseif (is_tax()) {
|
||||
$this->set_tax_ogp_img(get_queried_object()->term_id);
|
||||
} elseif (is_home() || is_front_page()) {
|
||||
$this->set_top_page_ogp_img();
|
||||
} elseif (is_page() || is_single()) {
|
||||
$this->set_post_ogp_img($post->ID);
|
||||
}
|
||||
}
|
||||
|
||||
public function set_top_page_ogp_img() {
|
||||
$id = get_option('_mtee')['top_page']['ogp_img'];
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function set_custom_post_archive_ogp_img() {
|
||||
$custom_post_name = get_post_type_object(get_post_type())->name;
|
||||
$id = get_option('_mtee')['custom_post'][$custom_post_name]['ogp_img'];
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function set_post_ogp_img($id) {
|
||||
$id = get_post_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function set_category_ogp_img($id) {
|
||||
$id = get_term_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function set_tag_ogp_img($id) {
|
||||
$id = get_term_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function set_tax_ogp_img($id) {
|
||||
$id = get_term_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
$this->get_thumbnail($id);
|
||||
}
|
||||
|
||||
public function get_thumbnail($id) {
|
||||
if (!empty($id)) {
|
||||
$this->ogp_img = wp_get_attachment_url($id);
|
||||
} elseif (has_post_thumbnail($id)) {
|
||||
$this->ogp_img = wp_get_attachment_url(get_post_thumbnail_id($id));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ if (!class_exists('mtee_noindexnofolow_setting')) {
|
||||
*/
|
||||
class mtee_noindexnofolow_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
public function __construct($options) {
|
||||
//posts
|
||||
add_action('admin_menu', array($this, 'add_meta_fields'));
|
||||
@@ -45,30 +47,28 @@ if (!class_exists('mtee_noindexnofolow_setting')) {
|
||||
// カスタムフィールドの入力エリア
|
||||
public function insert_meta_fields() {
|
||||
global $post;
|
||||
$noindex_value = get_post_meta($post->ID, MTEE_NAME_NOINDEX, true);
|
||||
$nofollow_value = get_post_meta($post->ID, MTEE_NAME_NOFOLLOW, true);
|
||||
$noindex_value = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_NOINDEX, true);
|
||||
$nofollow_value = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_NOFOLLOW, true);
|
||||
echo '
|
||||
<div class="meta_noindex_nofollow_box">
|
||||
<div>
|
||||
<label style="font-weight: bold;">noindex</label>
|
||||
<input type="hidden" name="' . MTEE_NAME_NOINDEX . '" value="0" />
|
||||
<input type="checkbox" name="' . MTEE_NAME_NOINDEX . '" value="1"';
|
||||
checked($noindex_value, 1);
|
||||
echo ' /></div>
|
||||
<div>
|
||||
<label style="font-weight: bold;">nofollow</label>
|
||||
<input type="hidden" name="' . MTEE_NAME_NOFOLLOW . '" value="0" />
|
||||
<input type="checkbox" name="' . MTEE_NAME_NOFOLLOW . '" value="1"';
|
||||
checked($nofollow_value, 1);
|
||||
echo '. />
|
||||
<div>
|
||||
<label style="font-weight: bold;">noindex</label>
|
||||
<input type="hidden" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOINDEX) . '" value="0" />
|
||||
<input type="checkbox" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOINDEX) . '" value="1" />
|
||||
</div>
|
||||
<div>
|
||||
<label style="font-weight: bold;">nofollow</label>
|
||||
<input type="hidden" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOFOLLOW) . '" value="0" />
|
||||
<input type="checkbox" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOFOLLOW) . '" value="1"' . checked(esc_attr($nofollow_value), 1) . ' />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields($post_id) {
|
||||
update_post_meta($post_id, MTEE_NAME_NOINDEX, $_POST[MTEE_NAME_NOINDEX] ?? '');
|
||||
update_post_meta($post_id, MTEE_NAME_NOFOLLOW, $_POST[MTEE_NAME_NOFOLLOW] ?? '');
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_NAME_NOINDEX);
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_NAME_NOFOLLOW);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
@@ -93,42 +93,50 @@ if (!class_exists('mtee_noindexnofolow_setting')) {
|
||||
}
|
||||
|
||||
public function add_tax_term_fields($tag) {
|
||||
$form = '<div class="meta_noindex_nofollow_outer">##CONTENTS##</div>';
|
||||
|
||||
echo $this->insert_term_meta_fields($tag, $form);
|
||||
?>
|
||||
<div class="meta_noindex_nofollow_outer">
|
||||
<?php
|
||||
$this->insert_term_meta_fields($tag);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function edit_tax_term_fields($tag) {
|
||||
$form = '<tr class="form-field">
|
||||
<th scope="row">noindex / nofollow</th>
|
||||
<td>##CONTENTS##</td>
|
||||
</tr>';
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row">noindex / nofollow</th>
|
||||
|
||||
echo $this->insert_term_meta_fields($tag, $form);
|
||||
<td>
|
||||
<?php
|
||||
$this->insert_term_meta_fields($tag);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function insert_term_meta_fields($tag, $form) {
|
||||
private function insert_term_meta_fields($tag) {
|
||||
$noindex_value = '';
|
||||
$nofollow_value = '';
|
||||
if (isset($tag->term_id)) {
|
||||
$noindex_value = get_term_meta($tag->term_id, MTEE_NAME_NOINDEX, true);
|
||||
$nofollow_value = get_term_meta($tag->term_id, MTEE_NAME_NOFOLLOW, true);
|
||||
$noindex_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_NAME_NOINDEX, true);
|
||||
$nofollow_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_NAME_NOFOLLOW, true);
|
||||
}
|
||||
$add_meta = '
|
||||
echo '
|
||||
<div class="meta_noindex_nofollow_box">
|
||||
<label>
|
||||
<input type="hidden" name="' . MTEE_NAME_NOINDEX . '" value="0" />
|
||||
<input type="checkbox" name="' . MTEE_NAME_NOINDEX . '" value="1" ' . self::create_checked(1, $noindex_value) . ' />
|
||||
noindex
|
||||
</label>
|
||||
<label>
|
||||
<input type="hidden" name="' . MTEE_NAME_NOFOLLOW . '" value="0" />
|
||||
<input type="checkbox" name="' . MTEE_NAME_NOFOLLOW . '" value="1" ' . self::create_checked(1, $nofollow_value) . ' />
|
||||
nofollow
|
||||
</label>
|
||||
</div>';
|
||||
|
||||
return str_replace('##CONTENTS##', $add_meta, $form);
|
||||
<label>
|
||||
<input type="hidden" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOINDEX) . '" value="0" />
|
||||
<input type="checkbox" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOINDEX) . '" value="1" ' . esc_attr(self::create_checked(1, $noindex_value)) . ' />
|
||||
noindex
|
||||
</label>
|
||||
<label>
|
||||
<input type="hidden" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOFOLLOW) . '" value="0" />
|
||||
<input type="checkbox" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_NOFOLLOW) . '" value="1" ' . esc_attr(self::create_checked(1, $nofollow_value)) . ' />
|
||||
nofollow
|
||||
</label>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
@@ -141,12 +149,8 @@ nofollow
|
||||
}
|
||||
|
||||
public function save_terms($term_id) {
|
||||
if (array_key_exists(MTEE_NAME_NOINDEX, $_POST)) {
|
||||
update_term_meta($term_id, MTEE_NAME_NOINDEX, $_POST[MTEE_NAME_NOINDEX]);
|
||||
}
|
||||
if (array_key_exists(MTEE_NAME_NOFOLLOW, $_POST)) {
|
||||
update_term_meta($term_id, MTEE_NAME_NOFOLLOW, $_POST[MTEE_NAME_NOFOLLOW]);
|
||||
}
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_NOINDEX);
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_NOFOLLOW);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_ogp_post_setting')) {
|
||||
|
||||
/**
|
||||
* Class mtee_ogp_post_setting
|
||||
*/
|
||||
class mtee_ogp_post_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
$this->options = $options;
|
||||
add_action('admin_menu', array($this, 'add_meta_fields'));
|
||||
add_action('save_post', array($this, 'save_meta_fields'));
|
||||
add_action('wp_enqueue_scripts', array($this, 'my_media_script'));
|
||||
}
|
||||
|
||||
function my_media_script() {
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
//add_meta_box(表示される入力ボックスのHTMLのID, ラベル, 表示する内容を作成する関数名, 投稿タイプ, 表示方法)
|
||||
public function add_meta_fields() {
|
||||
$custom_posts = array_values(get_post_types(array('public' => true, '_builtin' => false)));
|
||||
$target_posts = array_merge(array('page', 'post',), $custom_posts);
|
||||
foreach ($target_posts as $target_post) {
|
||||
add_meta_box(
|
||||
'ogp_setting',
|
||||
'OGP設定',
|
||||
array(
|
||||
$this,
|
||||
'insert_meta_fields'),
|
||||
$target_post,
|
||||
'normal'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// カスタムフィールドの入力エリア
|
||||
public function insert_meta_fields() {
|
||||
global $post;
|
||||
echo '<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">title</label>
|
||||
<div>
|
||||
<input style="width:100%" type="text"
|
||||
name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_TITLE) . '"
|
||||
value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_TITLE, true)) . '"
|
||||
placeholder="' . esc_attr($this->set_default_ogp_title()) . '"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">description</label>
|
||||
<div>
|
||||
<input style="width:100%" type="text"
|
||||
name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_DESC) . '"
|
||||
value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_DESC, true)) . '"
|
||||
placeholder="' . esc_attr($this->set_default_ogp_desc()) . '"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">image</label>
|
||||
<div>
|
||||
<input class="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" type="hidden" value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_IMG, true)) . '" />
|
||||
<input type="button" class="select_ogp_img" name="select_ogp_img" value="選択" />
|
||||
<input type="button" class="clear_ogp_img" name="clear_ogp_img" value="クリア" />
|
||||
<div class="ogp_media">' . $this->set_ogp_thumb($post->ID) . '</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>';
|
||||
}
|
||||
|
||||
public function set_default_ogp_title() {
|
||||
return get_the_title();
|
||||
}
|
||||
|
||||
public function set_default_ogp_desc(): string {
|
||||
return get_bloginfo('name') . 'の' . $this->set_default_ogp_title() . 'です。';
|
||||
}
|
||||
|
||||
public function set_ogp_thumb($id): string {
|
||||
$ogp_thumb = get_post_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
if (!empty($ogp_thumb)) {
|
||||
return '<img src="' . esc_html(wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0]) . '">';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields($post_id) {
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_OGP_TITLE);
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_OGP_DESC);
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_OGP_IMG);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_ogp_tax_setting')) {
|
||||
|
||||
/**
|
||||
* Class mtee_tax_setting
|
||||
*/
|
||||
class mtee_ogp_tax_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
$this->options = $options;
|
||||
$this->set_fields();
|
||||
add_action('create_term', array($this, 'save_terms')); //新規追加用フック
|
||||
add_action('edit_terms', array($this, 'save_terms')); //編集ページ用フック
|
||||
add_action('wp_enqueue_scripts', array($this, 'my_media_script'));
|
||||
}
|
||||
|
||||
function my_media_script() {
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
public function set_fields() {
|
||||
$taxs = $this->set_tax_types();
|
||||
foreach ($taxs as $tax) {
|
||||
add_action($tax . '_add_form_fields', array($this, 'insert_term_meta_add_fields'));
|
||||
add_action($tax . '_edit_form_fields', array($this, 'insert_term_meta_edit_fields'));
|
||||
}
|
||||
}
|
||||
|
||||
public function set_tax_types(): array {
|
||||
$custom_tax = get_taxonomies(array('public' => true, '_builtin' => false));
|
||||
$tax_array = array_merge(array('category', 'post_tag'), $custom_tax);
|
||||
$add_tax = filter_input(INPUT_GET, 'taxonomy');
|
||||
|
||||
if (!empty($add_tax)) {
|
||||
return array_merge($tax_array, array($add_tax));
|
||||
}
|
||||
return $tax_array;
|
||||
}
|
||||
|
||||
function insert_term_meta_add_fields($tag) {
|
||||
$input_values = $this->set_input_values($tag);
|
||||
echo '
|
||||
<div class="form-field">
|
||||
OGP title<br>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_TITLE) . '"
|
||||
value=""
|
||||
placeholder="' . esc_attr($input_values['title_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
OGP description<br>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_DESC) . '"
|
||||
value=""
|
||||
placeholder="' . esc_attr($input_values['desc_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
image<br>
|
||||
<input class="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" type="hidden" value="" />
|
||||
<input type="button" class="select_ogp_img" name="select_ogp_img" value="選択" />
|
||||
<input type="button" class="clear_ogp_img" name="clear_ogp_img" value="クリア" />
|
||||
<div class="ogp_media"></div>
|
||||
<script>
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
function insert_term_meta_edit_fields($tag) {
|
||||
$input_values = $this->set_input_values($tag);
|
||||
echo '
|
||||
<tr class="form-field">
|
||||
<th scope="row">OGP</th>
|
||||
<td>
|
||||
<label class="mtee-label">title:</label>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_TITLE) . '"
|
||||
value="' . esc_attr($input_values['title']) . '"
|
||||
placeholder="' . esc_attr($input_values['title_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
|
||||
<label class="mtee-label">description:</label>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_DESC) . '"
|
||||
value="' . esc_attr($input_values['desc']) . '"
|
||||
placeholder="' . esc_attr($input_values['desc_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
<label class="mtee-label">image:</label>
|
||||
<input class="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . '" type="hidden" value="' . esc_attr(get_post_meta($tag->term_id, MTEE_CONFIG::MTEE_OGP_IMG, true)) . '" />
|
||||
<input type="button" class="select_ogp_img" name="select_ogp_img" value="選択" />
|
||||
<input type="button" class="clear_ogp_img" name="clear_ogp_img" value="クリア" />
|
||||
<div class="ogp_media">' . $this->set_ogp_thumb($tag->term_id) . '</div>
|
||||
<script>
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
function set_input_values($tag): array {
|
||||
$title_value = '';
|
||||
$desc_value = '';
|
||||
$title_placeholder = '';
|
||||
$desc_placeholder = '';
|
||||
if (isset($tag->term_id)) {
|
||||
$title_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_OGP_TITLE, true);
|
||||
$desc_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_OGP_DESC, true);
|
||||
$title_placeholder = $this->set_default_title($tag);
|
||||
$desc_placeholder = $this->set_default_description($title_placeholder);
|
||||
}
|
||||
return array(
|
||||
'title' => $title_value,
|
||||
'desc' => $desc_value,
|
||||
'title_pl' => $title_placeholder,
|
||||
'desc_pl' => $desc_placeholder,
|
||||
);
|
||||
}
|
||||
|
||||
public function set_default_title($tag) {
|
||||
return $tag->name;
|
||||
}
|
||||
|
||||
public function set_default_description($title): string {
|
||||
return get_bloginfo('name') . 'の' . $title . 'です。';
|
||||
}
|
||||
|
||||
public function set_ogp_thumb($id): string {
|
||||
$ogp_thumb = get_post_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
if (!empty($ogp_thumb)) {
|
||||
return '<img src="' . esc_html(wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0]) . '">';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function save_terms($term_id) {
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_OGP_TITLE);
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_OGP_DESC);
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_OGP_IMG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_post_setting')) {
|
||||
|
||||
/**
|
||||
* Class mtee_post_setting
|
||||
*/
|
||||
class mtee_post_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
$this->options = $options;
|
||||
if ($this->options['enabled'] == 1) {
|
||||
add_action('admin_menu', array($this, 'add_meta_fields'));
|
||||
add_action('save_post', array($this, 'save_meta_fields'));
|
||||
}
|
||||
}
|
||||
|
||||
public function add_meta_fields() {
|
||||
//add_meta_box(表示される入力ボックスのHTMLのID, ラベル, 表示する内容を作成する関数名, 投稿タイプ, 表示方法)
|
||||
$target_posts = $this->get_all_post_type();
|
||||
foreach ($target_posts as $target_post) {
|
||||
add_meta_box(
|
||||
'meta_setting',
|
||||
'meta設定',
|
||||
array(
|
||||
$this,
|
||||
'insert_meta_fields'),
|
||||
$target_post,
|
||||
'normal'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_all_post_type(): array {
|
||||
$custom_posts = array_values(get_post_types(array('public' => true, '_builtin' => false)));
|
||||
return array_merge(array('page', 'post',), $custom_posts);
|
||||
}
|
||||
|
||||
// カスタムフィールドの入力エリア
|
||||
public function insert_meta_fields() {
|
||||
global $post;
|
||||
echo '<div class="meta_key_desc_box">
|
||||
<label style="font-weight: bold; display: block">meta keywords</label>
|
||||
<div><input style="width:100%" type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_KEYWORDS) . '"
|
||||
value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_KEYWORDS, true)) . '"
|
||||
placeholder="' . esc_attr($this->set_default_keywords()) . '"/>
|
||||
</div>';
|
||||
echo '<label style="font-weight: bold; display: block">meta description</label>
|
||||
<div><input style="width:100%" type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_DESCRIPTION) . '"
|
||||
value="' . esc_attr(get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true)) . '"
|
||||
placeholder="' . esc_attr($this->set_default_description()) . '"/>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields($post_id) {
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_NAME_KEYWORDS);
|
||||
$this->save_post_meta($post_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION);
|
||||
}
|
||||
|
||||
public function set_default_keywords() {
|
||||
global $post_type;
|
||||
if ($post_type == 'page') {
|
||||
if (!empty($this->options['keywords_tmp']['page'])) {
|
||||
return $this->options['keywords_tmp']['page'];
|
||||
}
|
||||
return '##title##,##description##,##site_name##';
|
||||
} else {
|
||||
if (!empty($this->options['keywords_tmp']['post'])) {
|
||||
return $this->options['keywords_tmp']['post'];
|
||||
}
|
||||
return '##title##,##category##,##tag##,##custom_tax##,##description##,##site_name##';
|
||||
}
|
||||
}
|
||||
|
||||
public function set_default_description() {
|
||||
if (!empty($this->options['description_tmp']['page'])) {
|
||||
return $this->options['description_tmp']['page'];
|
||||
}
|
||||
return '##site_name##の' . MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS . '##title##' . MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS . MTEE_CONFIG::MTEE_META_DESC_SINGLE_BASE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_tax_setting')) {
|
||||
|
||||
/**
|
||||
* Class mtee_tax_setting
|
||||
*/
|
||||
class mtee_tax_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
$this->options = $options;
|
||||
$this->set_fields();
|
||||
add_action('create_term', array($this, 'save_terms')); //新規追加用フック
|
||||
add_action('edit_terms', array($this, 'save_terms')); //編集ページ用フック
|
||||
}
|
||||
|
||||
public function set_fields() {
|
||||
$taxs = $this->set_tax_types();
|
||||
foreach ($taxs as $tax) {
|
||||
add_action($tax . '_add_form_fields', array($this, 'insert_term_meta_add_fields'));
|
||||
add_action($tax . '_edit_form_fields', array($this, 'insert_term_meta_edit_fields'));
|
||||
}
|
||||
}
|
||||
|
||||
public function set_tax_types(): array {
|
||||
$custom_tax = get_taxonomies(array('public' => true, '_builtin' => false));
|
||||
$tax_array = array_merge(array('category', 'post_tag'), $custom_tax);
|
||||
$add_tax = filter_input(INPUT_GET, 'taxonomy');
|
||||
|
||||
if (!empty($add_tax)) {
|
||||
return array_merge($tax_array, array($add_tax));
|
||||
}
|
||||
return $tax_array;
|
||||
}
|
||||
|
||||
function insert_term_meta_add_fields($tag) {
|
||||
$input_values = $this->set_input_values($tag);
|
||||
echo '
|
||||
<div class="form-field">
|
||||
meta keywords<br>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_KEYWORDS) . '"
|
||||
value="' . esc_attr($input_values['keywords']) . '"
|
||||
placeholder="' . esc_attr($input_values['keyword_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
meta description<br>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_DESCRIPTION) . '"
|
||||
value="' . esc_attr($input_values['desc']) . '"
|
||||
placeholder="' . esc_attr($input_values['desc_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
function insert_term_meta_edit_fields($tag) {
|
||||
$input_values = $this->set_input_values($tag);
|
||||
echo '
|
||||
<tr class="form-field">
|
||||
<th scope="row">meta keywords<br>meta description</th>
|
||||
<td>
|
||||
<label class="mtee-label">meta keywords:</label>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_KEYWORDS) . '"
|
||||
value="' . esc_attr($input_values['keywords']) . '"
|
||||
placeholder="' . esc_attr($input_values['keyword_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
<label class="mtee-label">meta description:</label>
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_NAME_DESCRIPTION) . '"
|
||||
value="' . esc_attr($input_values['desc']) . '"
|
||||
placeholder="' . esc_attr($input_values['desc_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
function set_input_values($tag): array {
|
||||
$key_value = '';
|
||||
$desc_value = '';
|
||||
$keyword_placeholder = '';
|
||||
$desc_placeholder = '';
|
||||
if (isset($tag->term_id)) {
|
||||
$key_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_NAME_KEYWORDS, true);
|
||||
$desc_value = get_term_meta($tag->term_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true);
|
||||
$keyword_placeholder = $this->set_default_keywords($tag);
|
||||
$desc_placeholder = $this->set_default_description($tag);
|
||||
}
|
||||
return array(
|
||||
'keywords' => $key_value,
|
||||
'desc' => $desc_value,
|
||||
'keyword_pl' => $keyword_placeholder,
|
||||
'desc_pl' => $desc_placeholder,
|
||||
);
|
||||
}
|
||||
|
||||
public function set_default_keywords($tag) {
|
||||
if ($tag->taxonomy == 'category') {
|
||||
$keywords = $this->options['keywords_tmp']['category'];
|
||||
} elseif ($tag->taxonomy == 'post_tag') {
|
||||
$keywords = $this->options['keywords_tmp']['tag'];
|
||||
} else {
|
||||
$keywords = $this->options['keywords_tmp']['tax'];
|
||||
}
|
||||
if (empty($keywords)) {
|
||||
$keywords = '##title##,##description##,##site_name##';
|
||||
}
|
||||
return $keywords;
|
||||
}
|
||||
|
||||
public function set_default_description($tag) {
|
||||
if ($tag->taxonomy == 'category') {
|
||||
$description = $this->options['description_tmp']['category'];
|
||||
} elseif ($tag->taxonomy == 'post_tag') {
|
||||
$description = $this->options['description_tmp']['tag'];
|
||||
} else {
|
||||
$description = $this->options['description_tmp']['tax'];
|
||||
}
|
||||
if (empty($description)) {
|
||||
$description = '##site_name##の' . MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS . '##title##' . MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS . MTEE_CONFIG::MTEE_META_DESC_SINGLE_BASE;
|
||||
}
|
||||
return $description;
|
||||
}
|
||||
|
||||
function save_terms($term_id) {
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_KEYWORDS);
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('mtee_version_setting')) {
|
||||
|
||||
class mtee_version_setting {
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
$this->options = $options;
|
||||
$this->disabled_wp_version_view();
|
||||
$this->disabled_asset_version_view();
|
||||
$this->disabled_emoji();
|
||||
$this->disabled_rss_feed();
|
||||
}
|
||||
|
||||
public function disabled_wp_version_view() {
|
||||
if ($this->options['wp_ver_disabled'] == 1) {
|
||||
remove_action('wp_head', 'wp_generator');
|
||||
}
|
||||
}
|
||||
|
||||
public function disabled_asset_version_view() {
|
||||
if ($this->options['asset_ver_disabled'] == 1) {
|
||||
add_action('wp_default_scripts', array($this, 'remove_src_wp_ver'));
|
||||
add_action('wp_default_styles', array($this, 'remove_src_wp_ver'));
|
||||
}
|
||||
}
|
||||
|
||||
public function remove_src_wp_ver($dep) {
|
||||
$dep->default_version = '';
|
||||
}
|
||||
|
||||
public function disabled_emoji() {
|
||||
if ($this->options['emoji_disabled'] == 1) {
|
||||
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
||||
remove_action('wp_print_styles', 'print_emoji_styles');
|
||||
}
|
||||
}
|
||||
|
||||
public function disabled_rss_feed() {
|
||||
if ($this->options['rss_disabled'] == 1) {
|
||||
//RSS Feedを停止
|
||||
remove_action('do_feed_rdf', 'do_feed_rdf');
|
||||
remove_action('do_feed_rss', 'do_feed_rss');
|
||||
remove_action('do_feed_rss2', 'do_feed_rss2');
|
||||
remove_action('do_feed_atom', 'do_feed_atom');
|
||||
//RSSリンクを無効化
|
||||
remove_action('wp_head', 'feed_links', 2);
|
||||
remove_action('wp_head', 'feed_links_extra', 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
const MTEE_CLASS_DIR = __DIR__ . '/class/';
|
||||
const MTEE_TRAIT_DIR = __DIR__ . '/trait/';
|
||||
const MTEE_TEMPLATE_DIR = __DIR__ . '/template/';
|
||||
const MTEE_NAME_KEYWORDS = 'mtee_meta_keywords';
|
||||
const MTEE_NAME_DESCRIPTION = 'mtee_meta_description';
|
||||
const MTEE_NAME_NOINDEX = '_mtee_robots_noindex';
|
||||
const MTEE_NAME_NOFOLLOW = '_mtee_robots_nofollow';
|
||||
const MTEE_CANONICAL_URL = 'mtee_canonical_url';
|
||||
|
||||
const MTEE_META_DESC_TOP_BASE = 'トップページです。';
|
||||
const MTEE_META_DESC_SINGLE_BASE = 'ページです。';
|
||||
const MTEE_META_DESC_ARCHIVE_BASE = '一覧ページです。';
|
||||
const MTEE_META_DESC_PARTICLE = 'の';
|
||||
const MTEE_META_DESC_BEFORE_BRACKETS = '「';
|
||||
const MTEE_META_DESC_AFTER_BRACKETS = '」';
|
||||
@@ -116,6 +116,24 @@ h2 {
|
||||
color: #f35;
|
||||
}
|
||||
|
||||
label.mtee-label {
|
||||
display: block;
|
||||
margin: .5em 0 0;
|
||||
}
|
||||
|
||||
.ogp_media {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.width_100{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block_bold {
|
||||
font-weight: bold;
|
||||
display: block
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.mtee_description_tmp_list {
|
||||
display: block;
|
||||
|
||||
+92
-9
@@ -1,20 +1,103 @@
|
||||
jQuery(function ($) {
|
||||
|
||||
nab_menu();
|
||||
media_uploader();
|
||||
|
||||
function nab_menu() {
|
||||
let menu_list = $('.mtee_tab_menu li');
|
||||
let content_box = $('.mtee_tab_box');
|
||||
menu_list.on('click', function () {
|
||||
if (!$(this).hasClass('en')) {
|
||||
let index = $(this).index();
|
||||
$('.mtee_tab_menu li').removeClass('en');
|
||||
$(this).addClass('en');
|
||||
content_box.hide();
|
||||
$('.mtee_tab_box:eq(' + index + ')').show();
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
click_menu();
|
||||
|
||||
function init() {
|
||||
let current_nav = $('#mtee_set_nav').val();
|
||||
let current_index = menu_list.index($('#' + current_nav));
|
||||
|
||||
$('.mtee_tab_menu li').removeClass('en');
|
||||
$('#' + current_nav).addClass('en');
|
||||
|
||||
content_box.hide();
|
||||
$('.mtee_tab_box:eq(' + current_index + ')').show();
|
||||
}
|
||||
|
||||
function click_menu() {
|
||||
menu_list.on('click', function () {
|
||||
if (!$(this).hasClass('en')) {
|
||||
let index = $(this).index();
|
||||
$('.mtee_tab_menu li').removeClass('en');
|
||||
$(this).addClass('en');
|
||||
content_box.hide();
|
||||
$('#mtee_set_nav').val($(this).attr('id'));
|
||||
$('.mtee_tab_box:eq(' + index + ')').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function media_uploader() {
|
||||
|
||||
// let custom_uploader;
|
||||
// let thumb = $('.ogp_media');
|
||||
let select_ogp = $('.select_ogp_img');
|
||||
let clear_ogp = $('.clear_ogp_img');
|
||||
let set_media = [];
|
||||
|
||||
select_ogp.click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let media_index = $('.select_ogp_img').index(this);
|
||||
|
||||
if (set_media[media_index]) {
|
||||
set_media[media_index].open();
|
||||
return;
|
||||
}
|
||||
|
||||
set_media[media_index] = build_media();
|
||||
|
||||
set_media[media_index].on("select", function () {
|
||||
let images = set_media[media_index].state().get("selection");
|
||||
let thumb = $('.ogp_media:eq(' + media_index + ')');
|
||||
/* file の中に選択された画像の各種情報が入っている */
|
||||
images.each(function (file) {
|
||||
/* テキストフォームと表示されたサムネイル画像があればクリア */
|
||||
$('.' + ogp_img_name + ':eq(' + media_index + ')').val('');
|
||||
thumb.empty();
|
||||
/* テキストフォームに画像の ID を表示 */
|
||||
$('.' + ogp_img_name + ':eq(' + media_index + ')').val(file.id);
|
||||
/* プレビュー用に選択されたサムネイル画像を表示 */
|
||||
thumb.append('<img src="' + file.attributes.sizes.thumbnail.url + '" />');
|
||||
});
|
||||
});
|
||||
|
||||
set_media[media_index].open();
|
||||
|
||||
});
|
||||
|
||||
/* クリアボタンを押した時の処理 */
|
||||
clear_ogp.click(function () {
|
||||
let clear_index = $('.clear_ogp_img').index(this);
|
||||
let thumb = $('.ogp_media:eq(' + clear_index + ')');
|
||||
$('.' + ogp_img_name + ':eq(' + clear_index + ')').val('');
|
||||
thumb.empty();
|
||||
});
|
||||
|
||||
function build_media() {
|
||||
return wp.media({
|
||||
title: "画像を選択",
|
||||
/* ライブラリの一覧は画像のみにする */
|
||||
library: {
|
||||
type: "image"
|
||||
},
|
||||
button: {
|
||||
text: "画像選択"
|
||||
},
|
||||
/* 選択できる画像は 1 つだけにする */
|
||||
multiple: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
+39
-22
@@ -8,21 +8,26 @@ Version: 1.0
|
||||
|
||||
/*
|
||||
Todo:OGPタグ
|
||||
・OGPタグを追加する
|
||||
<各OGP画像の保存>
|
||||
・投稿のOGP用画像 => post_meta
|
||||
・各タクソノミーのOGP画像 => term_meta
|
||||
・トップ、カスタム投稿アーカイブ => wp_options
|
||||
画像出力
|
||||
|
||||
facebook
|
||||
<meta property="fb:app_id" content="[FacebookアプリのID]" />
|
||||
|
||||
Twitter
|
||||
|
||||
*/
|
||||
|
||||
include_once 'config.php';
|
||||
include_once MTEE_CLASS_DIR . 'mtee.php';
|
||||
include_once __DIR__ . '/mtee_config.php';
|
||||
include_once MTEE_CONFIG::MTEE_TRAIT_DIR . 'mtee_utils.php';
|
||||
include_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee.php';
|
||||
|
||||
//admin css/js setting
|
||||
add_action('admin_enqueue_scripts', function () {
|
||||
$plugin_url = plugin_dir_url(__FILE__);
|
||||
wp_enqueue_style('mtee_style', $plugin_url . 'css/mtee.css');
|
||||
wp_enqueue_script('mtee_js', $plugin_url . 'js/mtee.js', 'jquery');
|
||||
//メディアアップローダー
|
||||
wp_enqueue_media();
|
||||
});
|
||||
|
||||
$mtee = new MTEE;
|
||||
@@ -30,43 +35,55 @@ $options = $mtee->get_options();
|
||||
|
||||
// enabled my meta keywords, description
|
||||
if ($mtee->is_enable('enabled')) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee-tax-setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee-post-setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee_meta_output_keydesc.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_tax_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_post_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_meta_output_keydesc.php';
|
||||
new mtee_tax_setting($options);
|
||||
new mtee_post_setting($options);
|
||||
new mtee_meta_output_keydesc;
|
||||
new mtee_meta_output_keydesc();
|
||||
}
|
||||
|
||||
// enabled my canonical. caution : default canonical delete
|
||||
if ($mtee->is_enable('canonical_setting')) {
|
||||
remove_action('wp_head', 'rel_canonical');
|
||||
require_once MTEE_CLASS_DIR . 'mtee-canonical-setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee-output-canonical.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_canonical_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_meta_output_canonical.php';
|
||||
new mtee_canonical_setting($options);
|
||||
new mtee_meta_output_canonical();
|
||||
}
|
||||
|
||||
// enabled my OGP tag
|
||||
if ($mtee->is_enable('ogp_setting')) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee-ogp-setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee-output-ogp.php';
|
||||
new mtee_ogp_setting();
|
||||
include MTEE_CONFIG::MTEE_TRAIT_DIR . 'mtee_meta_desc_trait.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_ogp_tax_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_ogp_post_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_meta_output_ogp.php';
|
||||
new mtee_ogp_tax_setting($options);
|
||||
new mtee_ogp_post_setting($options);
|
||||
new mtee_meta_output_ogp();
|
||||
}
|
||||
|
||||
//enabled my noindex, nofollow
|
||||
if ($mtee->is_enable('noindex_nofollow')) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee-noindexnofollow-setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee-output-noindexnofollow.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_noindexnofolow_setting.php';
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_meta_output_noindexnofollow.php';
|
||||
new mtee_noindexnofolow_setting($options);
|
||||
new mtee_meta_output_noindexnofollow();
|
||||
}
|
||||
|
||||
//disabled WP version, WP JS/CSS version
|
||||
if ($mtee->is_disable('asset_ver_disabled') || $mtee->is_disable('asset_ver_disabled')) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee-version-setting.php';
|
||||
new mtee_version_setting($options);
|
||||
//disabled WP version, WP JS/CSS version, Emoji, RSS Feed
|
||||
$disabled_checks = array(
|
||||
'asset_ver_disabled',
|
||||
'asset_ver_disabled',
|
||||
'emoji_disabled',
|
||||
'rss_disabled'
|
||||
);
|
||||
foreach ($disabled_checks as $disabled_check) {
|
||||
if ($mtee->is_disable($disabled_check)) {
|
||||
require_once MTEE_CONFIG::MTEE_CLASS_DIR . 'mtee_version_setting.php';
|
||||
new mtee_version_setting($options);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!class_exists('MTEE_CONFIG')) {
|
||||
|
||||
class MTEE_CONFIG {
|
||||
|
||||
const MTEE_CLASS_DIR = __DIR__ . '/class/';
|
||||
const MTEE_TRAIT_DIR = __DIR__ . '/trait/';
|
||||
const MTEE_TEMPLATE_DIR = __DIR__ . '/template/';
|
||||
const MTEE_NAME_KEYWORDS = 'mtee_meta_keywords';
|
||||
const MTEE_NAME_DESCRIPTION = 'mtee_meta_description';
|
||||
const MTEE_NAME_NOINDEX = '_mtee_robots_noindex';
|
||||
const MTEE_NAME_NOFOLLOW = '_mtee_robots_nofollow';
|
||||
const MTEE_CANONICAL_URL = 'mtee_canonical_url';
|
||||
const MTEE_OGP_TITLE = '_mtee_ogp_title';
|
||||
const MTEE_OGP_DESC = '_mtee_ogp_desc';
|
||||
const MTEE_OGP_IMG = '_mtee_ogp_img';
|
||||
|
||||
const MTEE_META_DESC_TOP_BASE = 'トップページです。';
|
||||
const MTEE_META_DESC_SINGLE_BASE = 'ページです。';
|
||||
const MTEE_META_DESC_ARCHIVE_BASE = '一覧ページです。';
|
||||
const MTEE_META_DESC_PARTICLE = 'の';
|
||||
const MTEE_META_DESC_BEFORE_BRACKETS = '「';
|
||||
const MTEE_META_DESC_AFTER_BRACKETS = '」';
|
||||
|
||||
}
|
||||
}
|
||||
+81
-276
@@ -1,126 +1,64 @@
|
||||
<?php
|
||||
<?php /** @noinspection ALL */
|
||||
$register_targets = MTEE::register_target();
|
||||
$opt = get_option('_mtee');
|
||||
$enabled = $this->get_key_setting('enabled');
|
||||
$noindex_nofollow = $this->get_key_setting('noindex_nofollow');
|
||||
$ogp_setting = $this->get_key_setting('ogp_setting');
|
||||
$canonical_setting = $this->get_key_setting('canonical_setting');
|
||||
$wp_ver_disabled = $this->get_key_setting('wp_ver_disabled');
|
||||
$asset_ver_disabled = $this->get_key_setting('asset_ver_disabled');
|
||||
$opt = get_option( '_mtee' );
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2>meta keyword, description / バージョン情報 設定</h2>
|
||||
<nav class="mtee_tab_menu">
|
||||
<ul>
|
||||
<li class="en">全体設定</li>
|
||||
<li>ページ設定</li>
|
||||
<li id="nav_metas" class="en">メタキーワード・ディスクリプション</li>
|
||||
<li id="nav_ogp">OGP</li>
|
||||
<li id="nav_noindex">noindex/nofollow</li>
|
||||
<li id="nav_canonical">Canonical</li>
|
||||
<li id="nav_version">バージョン情報等</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<form action="" method="post">
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<?php wp_nonce_field( 'check_options' ); ?>
|
||||
<input type="hidden" id="mtee_set_nav" name="mtee_set_nav"
|
||||
value="<?php echo esc_attr( $_POST['mtee_set_nav'] ?? 'nav_metas' ); ?>">
|
||||
<div class="mtee_tab_box">
|
||||
<div class="mtee-form-box">
|
||||
<h2>キーワード・ディスクリプション</h2>
|
||||
<h2>メタキーワード・ディスクリプション</h2>
|
||||
<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( $this->get_key_setting( 'enabled' ), 1 ); ?>
|
||||
value="1">有効
|
||||
</label>
|
||||
</div>
|
||||
<?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): ?>
|
||||
<tr>
|
||||
<th>カスタム投稿</th>
|
||||
<td>
|
||||
<ul>
|
||||
<?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($custom_post_check, 1); ?>
|
||||
value="1">
|
||||
<?php echo $custom_post . '(' . get_post_type_object($custom_post)->label . ')'; ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if (count($register_targets['taxonomies']) > 0): ?>
|
||||
<tr>
|
||||
<th>カスタム分類</th>
|
||||
<td>
|
||||
<ul>
|
||||
<?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($taxonomy_check, 1); ?>
|
||||
value="1">
|
||||
<?php echo $taxonomy . '(' . get_taxonomy($taxonomy)->label . ')'; ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>meta keywords テンプレート設定
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
<h3>meta keywords テンプレート設定</h3>
|
||||
<p>個別設定していない投稿やカテゴリー等は、このテンプレートを適用します。</p>
|
||||
<?php
|
||||
$post_meta_keywords_tmp = get_option('_mtee')['keywords_tmp']['post'] ?? '';
|
||||
$page_meta_keywords_tmp = get_option('_mtee')['keywords_tmp']['page'] ?? '';
|
||||
$cat_meta_keywords_tmp = get_option('_mtee')['keywords_tmp']['category'] ?? '';
|
||||
$tag_meta_keywords_tmp = get_option('_mtee')['keywords_tmp']['tag'] ?? '';
|
||||
$tax_meta_keywords_tmp = get_option('_mtee')['keywords_tmp']['tax'] ?? '';
|
||||
?>
|
||||
<dl class="mtee_description_tmp_list">
|
||||
<dt>投稿</dt>
|
||||
<dd>
|
||||
<input class="mtee_keywords_tmp" type="text" name="_mtee[keywords_tmp][post]"
|
||||
value="<?php echo $post_meta_keywords_tmp; ?>"
|
||||
value="<?php echo esc_attr( $opt['keywords_tmp']['post'] ?? '' ); ?>"
|
||||
placeholder="##title##,##category##,##tag##,##custom_tax##,##description##,##site_name##"
|
||||
</dd>
|
||||
<dt>ページ</dt>
|
||||
<dd>
|
||||
<input class="mtee_keywords_tmp" type="text" name="_mtee[keywords_tmp][page]"
|
||||
value="<?php echo $page_meta_keywords_tmp; ?>"
|
||||
value="<?php echo esc_attr( $opt['keywords_tmp']['page'] ?? '' ); ?>"
|
||||
placeholder="##title##,##description##,##site_name##"
|
||||
</dd>
|
||||
<dt>カテゴリー</dt>
|
||||
<dd>
|
||||
<input class="mtee_keywords_tmp" type="text" name="_mtee[keywords_tmp][category]"
|
||||
value="<?php echo $cat_meta_keywords_tmp; ?>"
|
||||
value="<?php echo esc_attr( $opt['keywords_tmp']['category'] ?? '' ); ?>"
|
||||
placeholder="##title##,##description##,##site_name##">
|
||||
</dd>
|
||||
<dt>タグ</dt>
|
||||
<dd>
|
||||
<input class="mtee_keywords_tmp" type="text" name="_mtee[keywords_tmp][tag]"
|
||||
value="<?php echo $tag_meta_keywords_tmp; ?>"
|
||||
value="<?php echo esc_attr( $opt['keywords_tmp']['tag'] ?? '' ); ?>"
|
||||
placeholder="##title##,##description##,##site_name##">
|
||||
</dd>
|
||||
<dt>カスタム分類</dt>
|
||||
<dd>
|
||||
<input class="mtee_keywords_tmp" type="text" name="_mtee[keywords_tmp][tax]"
|
||||
value="<?php echo $tax_meta_keywords_tmp; ?>"
|
||||
value="<?php echo esc_attr( $opt['keywords_tmp']['tax'] ?? '' ); ?>"
|
||||
placeholder="##title##,##description##,##site_name##">
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -128,8 +66,8 @@ $asset_ver_disabled = $this->get_key_setting('asset_ver_disabled');
|
||||
<li><b>共通</b>
|
||||
<ul>
|
||||
<li>##title##:投稿、ページ、カテゴリー等のタイトル</li>
|
||||
<li>##site_name##:サイト名(<?php echo get_bloginfo('name'); ?>)</li>
|
||||
<li>##site_description##:サイトの説明(<?php echo get_bloginfo('description'); ?>)</li>
|
||||
<li>##site_name##:サイト名(<?php echo get_bloginfo( 'name' ); ?>)</li>
|
||||
<li>##site_description##:サイトの説明(<?php echo get_bloginfo( 'description' ); ?>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b>投稿</b>
|
||||
@@ -142,84 +80,97 @@ $asset_ver_disabled = $this->get_key_setting('asset_ver_disabled');
|
||||
</ul>
|
||||
</div>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>meta description テンプレート設定
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></h3>
|
||||
<h3>meta description テンプレート設定</h3>
|
||||
<p>個別設定していない投稿やカテゴリー等は、このテンプレートを適用します。</p>
|
||||
<?php
|
||||
$page_meta_desc_tmp = get_option('_mtee')['description_tmp']['page'] ?? '';
|
||||
$cat_meta_desc_tmp = get_option('_mtee')['description_tmp']['category'] ?? '';
|
||||
$tag_meta_desc_tmp = get_option('_mtee')['description_tmp']['tag'] ?? '';
|
||||
$tax_meta_desc_tmp = get_option('_mtee')['description_tmp']['tax'] ?? '';
|
||||
?>
|
||||
<dl class="mtee_description_tmp_list">
|
||||
<dt>ページ/投稿</dt>
|
||||
<dd>
|
||||
<input class="mtee_description_tmp" type="text" name="_mtee[description_tmp][page]"
|
||||
value="<?php echo $page_meta_desc_tmp; ?>"
|
||||
placeholder="##site_name##の<?php echo MTEE_META_DESC_BEFORE_BRACKETS; ?>##title##<?php echo MTEE_META_DESC_AFTER_BRACKETS; ?><?php echo MTEE_META_DESC_SINGLE_BASE; ?>"
|
||||
value="<?php echo esc_attr( $opt['description_tmp']['page'] ?? '' ); ?>"
|
||||
placeholder="##site_name##の<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS ); ?>##title##<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS ); ?><?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_SINGLE_BASE ); ?>"
|
||||
</dd>
|
||||
<dt>カテゴリー</dt>
|
||||
<dd>
|
||||
<input class="mtee_description_tmp" type="text" name="_mtee[description_tmp][category]"
|
||||
value="<?php echo $cat_meta_desc_tmp; ?>"
|
||||
placeholder="##site_name##の<?php echo MTEE_META_DESC_BEFORE_BRACKETS; ?>##title##<?php echo MTEE_META_DESC_AFTER_BRACKETS; ?><?php echo MTEE_META_DESC_ARCHIVE_BASE; ?>">
|
||||
value="<?php echo esc_attr( $opt['description_tmp']['category'] ?? '' ); ?>"
|
||||
placeholder="##site_name##の<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS ); ?>##title##<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS ); ?><?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE ); ?>">
|
||||
</dd>
|
||||
<dt>タグ</dt>
|
||||
<dd>
|
||||
<input class="mtee_description_tmp" type="text" name="_mtee[description_tmp][tag]"
|
||||
value="<?php echo $tag_meta_desc_tmp; ?>"
|
||||
placeholder="##site_name##の<?php echo MTEE_META_DESC_BEFORE_BRACKETS; ?>##title##<?php echo MTEE_META_DESC_AFTER_BRACKETS; ?><?php echo MTEE_META_DESC_ARCHIVE_BASE; ?>">
|
||||
value="<?php echo esc_attr( $opt['description_tmp']['tag'] ?? '' ); ?>"
|
||||
placeholder="##site_name##の<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS ); ?>##title##<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS ); ?><?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE ); ?>">
|
||||
</dd>
|
||||
<dt>カスタム分類</dt>
|
||||
<dd>
|
||||
<input class="mtee_description_tmp" type="text" name="_mtee[description_tmp][tax]"
|
||||
value="<?php echo $tax_meta_desc_tmp; ?>"
|
||||
placeholder="##site_name##の<?php echo MTEE_META_DESC_BEFORE_BRACKETS; ?>##title##<?php echo MTEE_META_DESC_AFTER_BRACKETS; ?><?php echo MTEE_META_DESC_ARCHIVE_BASE; ?>">
|
||||
value="<?php echo esc_attr( $opt['description_tmp']['tax'] ?? '' ); ?>"
|
||||
placeholder="##site_name##の<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS ); ?>##title##<?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS ); ?><?php echo esc_attr( MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE ); ?>">
|
||||
</dd>
|
||||
</dl>
|
||||
<ul>
|
||||
<li>##site_name##:サイト名(<?php echo get_bloginfo('name'); ?>)</li>
|
||||
<li>##site_description##:サイトの説明(<?php echo get_bloginfo('description'); ?>)</li>
|
||||
<li>##site_name##:サイト名(<?php bloginfo( 'name' ); ?>)</li>
|
||||
<li>##site_description##:サイトの説明(<?php bloginfo( 'description' ); ?>)</li>
|
||||
<li>##title##:投稿、ページ、カテゴリー等のタイトル</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>個別設定 NOINDEX/NOFOLLOW</h3>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[noindex_nofollow]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[noindex_nofollow]" <?php checked($noindex_nofollow, 1); ?>
|
||||
value="1">有効
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>OGPタグ出力</h3>
|
||||
<?php include 'pages_meta.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<div class="mtee-form-box">
|
||||
<h2>OGP</h2>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[ogp_setting]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[ogp_setting]" <?php checked($ogp_setting, 1); ?>
|
||||
value="1">有効
|
||||
name="_mtee[ogp_setting]" <?php checked( $this->get_key_setting( 'ogp_setting' ), 1 ); ?>
|
||||
value="1">有効(デフォルトのog:descriptionはmeta descriptionになります)
|
||||
</label>
|
||||
</div>
|
||||
<?php include 'pages_ogp.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<h2>noindex/nofollow</h2>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[noindex_nofollow]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[noindex_nofollow]" <?php checked( $this->get_key_setting( 'noindex_nofollow' ), 1 ); ?>
|
||||
value="1">有効
|
||||
</label>
|
||||
<?php include 'pages_noindexnofollow.php'; ?>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>Canonical URL 出力</h3>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[canonical_setting]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[canonical_setting]" <?php checked($canonical_setting, 1); ?>
|
||||
name="_mtee[canonical_setting]" <?php checked( $this->get_key_setting( 'canonical_setting' ), 1 ); ?>
|
||||
value="1">有効
|
||||
</label>
|
||||
</div>
|
||||
<?php include 'pages_canonical.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<h2>バージョン情報等</h2>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>RSS</h3>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[rss_disabled]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[rss_disabled]" <?php checked( $this->get_key_setting( 'rss_disabled' ), 1 ); ?>
|
||||
value="1">出力しない
|
||||
</label>
|
||||
</div>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>WordPressバージョン情報</h3>
|
||||
<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); ?>
|
||||
value="1">削除
|
||||
name="_mtee[wp_ver_disabled]" <?php checked( $this->get_key_setting( 'wp_ver_disabled' ), 1 ); ?>
|
||||
value="1">表示しない
|
||||
</label>
|
||||
</div>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
@@ -227,165 +178,19 @@ $asset_ver_disabled = $this->get_key_setting('asset_ver_disabled');
|
||||
<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); ?>
|
||||
value="1">削除
|
||||
name="_mtee[asset_ver_disabled]" <?php checked( $this->get_key_setting( 'asset_ver_disabled' ), 1 ); ?>
|
||||
value="1">表示しない
|
||||
</label>
|
||||
</div>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<h2 class="mtee_page_title">トップページ</h2>
|
||||
<?php
|
||||
$keywords = $opt['top_page']['keywords'] ?? '';
|
||||
$description = $opt['top_page']['description'] ?? '';
|
||||
$noindex = $opt['top_page']['noindex'] ?? '0';
|
||||
$nofollow = $opt['top_page']['nofollow'] ?? '0';
|
||||
$canonical_url = $opt['top_page']['canonical'] ?? '';
|
||||
?>
|
||||
<div class="mtee-form-box">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>meta keywords
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td><input class="top_page_keywords" type="text" name="_mtee[top_page][keywords]"
|
||||
value="<?php echo $keywords; ?>" placeholder="キーワード1,キーワード2,キーワード3">
|
||||
<br>キーワードはカンマ(,)区切りで入力してください
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>meta description
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td><input class="top_page_description" type="text" name="_mtee[top_page][description]"
|
||||
value="<?php echo $description; ?>"
|
||||
placeholder="<?php echo get_bloginfo('name'); ?>の<?php echo MTEE_META_DESC_TOP_BASE; ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>noindex nofollow
|
||||
<?php if (!$this->is_enable('noindex_nofollow')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
<tr valign="top">
|
||||
<th>Canonical URL
|
||||
<?php if (!$this->is_enable('canonical_setting')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[top_page][canonical]"
|
||||
value="<?php echo $canonical_url; ?>"
|
||||
placeholder="<?php echo get_bloginfo('url'); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<h3>絵文字</h3>
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[emoji_disabled]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[emoji_disabled]" <?php checked( $this->get_key_setting( 'emoji_disabled' ), 1 ); ?>
|
||||
value="1">表示しない
|
||||
</label>
|
||||
</div>
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['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';
|
||||
$canonical_url = $opt['custom_post'][$custom_post]['canonical'] ?? '0';
|
||||
?>
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<div class="mtee-form-box">
|
||||
<h3 class="mtee_page_archive_title">
|
||||
<?php echo get_post_type_object($custom_post)->label; ?>
|
||||
(<?php echo $custom_post; ?>)
|
||||
</h3>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>meta keywords
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></th>
|
||||
<td><input class="top_page_keywords" type="text"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][keywords]"
|
||||
value="<?php echo $keywords; ?>" placeholder="キーワード1,キーワード2,キーワード3">
|
||||
<br>キーワードはカンマ(,)区切りで入力してください
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>meta description
|
||||
<?php if (!$this->is_enable('enabled')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][description]"
|
||||
value="<?php echo $description; ?>"
|
||||
placeholder="<?php echo get_bloginfo('name'); ?>の[カスタム投稿ラベル]<?php echo MTEE_META_DESC_ARCHIVE_BASE; ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>noindex nofollow
|
||||
<?php if (!$this->is_enable('noindex_nofollow')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></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>
|
||||
<tr valign="top">
|
||||
<th>Canonical URL
|
||||
<?php if (!$this->is_enable('canonical_setting')): ?>
|
||||
<span class="disabled_status">※現在無効です</span>
|
||||
<?php endif; ?></th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][canonical]"
|
||||
value="<?php echo $canonical_url; ?>"
|
||||
placeholder="<?php echo get_post_type_archive_link($custom_post); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<div class="mtee-form-box">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>Canonical URL</th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[top_page][canonical]"
|
||||
value="<?php echo esc_attr($opt['top_page']['canonical'] ?? ''); ?>"
|
||||
placeholder="<?php bloginfo('url'); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<div class="mtee-form-box">
|
||||
<h3 class="mtee_page_archive_title">
|
||||
<?php echo esc_html(get_post_type_object($custom_post)->label); ?>
|
||||
(<?php echo esc_html($custom_post); ?>)
|
||||
</h3>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>Canonical URL</th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][canonical]"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['canonical'] ?? ''); ?>"
|
||||
placeholder="<?php echo esc_attr(get_post_type_archive_link($custom_post)); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</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 esc_html($opt['top_page']['keywords'] ?? ''); ?>"
|
||||
placeholder="キーワード1,キーワード2,キーワード3">
|
||||
<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 esc_html($opt['top_page']['description'] ?? ''); ?>"
|
||||
placeholder="<?php echo get_bloginfo('name'); ?>の<?php echo MTEE_CONFIG::MTEE_META_DESC_TOP_BASE; ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<div class="mtee-form-box">
|
||||
<h3 class="mtee_page_archive_title">
|
||||
<?php echo esc_html(get_post_type_object($custom_post)->label); ?>
|
||||
(<?php echo esc_html($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 esc_attr($custom_post); ?>][keywords]"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['keywords'] ?? ''); ?>"
|
||||
placeholder="キーワード1,キーワード2,キーワード3">
|
||||
<br>キーワードはカンマ(,)区切りで入力してください
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>meta description</th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][description]"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['description'] ?? ''); ?>"
|
||||
placeholder="<?php bloginfo('name'); ?>の[カスタム投稿ラベル]<?php echo esc_attr(MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<?php
|
||||
$noindex = $opt['top_page']['noindex'] ?? '0';
|
||||
$nofollow = $opt['top_page']['nofollow'] ?? '0';
|
||||
?>
|
||||
<div class="mtee-form-box">
|
||||
<table class="form-table">
|
||||
<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>
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php
|
||||
$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 class="mtee_page_archive_title">
|
||||
<?php echo esc_html(get_post_type_object($custom_post)->label); ?>
|
||||
(<?php echo esc_html($custom_post); ?>)
|
||||
</h3>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>noindex nofollow</th>
|
||||
<td>
|
||||
<div class="meta_noindex_nofollow_box">
|
||||
<label>
|
||||
<input type="hidden"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][noindex]"
|
||||
value="0"/>
|
||||
<input type="checkbox"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][noindex]" <?php checked($noindex, 1); ?>
|
||||
value="1"/>
|
||||
noindex
|
||||
</label>
|
||||
<label>
|
||||
<input type="hidden"
|
||||
name="_mtee[custom_post][<?php echo esc_html($custom_post); ?>][nofollow]"
|
||||
value="0"/>
|
||||
<input type="checkbox"
|
||||
name="_mtee[custom_post][<?php echo esc_html($custom_post); ?>][nofollow]" <?php checked($nofollow, 1); ?>
|
||||
value="1"/>
|
||||
nofollow
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
@@ -0,0 +1,72 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<div class="mtee-form-box">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>OGP title</th>
|
||||
<td><input class="top_page_keywords" type="text" name="_mtee[top_page][ogp_title]"
|
||||
value="<?php echo esc_attr($opt['top_page']['ogp_title'] ?? ''); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>OGP description</th>
|
||||
<td><input class="top_page_description" type="text" name="_mtee[top_page][ogp_description]"
|
||||
value="<?php echo esc_attr($opt['top_page']['ogp_description'] ?? ''); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>OGP Image</th>
|
||||
<td>
|
||||
<input class="<?php echo esc_attr(MTEE_CONFIG::MTEE_OGP_IMG); ?>" name="_mtee[top_page][ogp_img]"
|
||||
type="hidden"
|
||||
value="<?php echo esc_attr($opt['top_page']['ogp_img'] ?? ''); ?>"/>
|
||||
<input type="button" class="select_ogp_img" name="select_ogp_img" value="選択"/>
|
||||
<input type="button" class="clear_ogp_img" name="clear_ogp_img" value="クリア"/>
|
||||
<div class="ogp_media"><?php echo $this->get_ogp_img('top_page'); ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<div class="mtee-form-box">
|
||||
<h3 class="mtee_page_archive_title">
|
||||
<?php echo esc_html(get_post_type_object($custom_post)->label); ?>
|
||||
(<?php echo esc_html($custom_post); ?>)
|
||||
</h3>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>OGP title</th>
|
||||
<td><input class="top_page_keywords" type="text"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][ogp_title]"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['ogp_title'] ?? ''); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>OGP description</th>
|
||||
<td><input class="top_page_description" type="text"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][ogp_description]"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['ogp_description'] ?? ''); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th>OGP Image</th>
|
||||
<td>
|
||||
<input class="<?php echo esc_attr(MTEE_CONFIG::MTEE_OGP_IMG); ?>"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][ogp_img]"
|
||||
type="hidden"
|
||||
value="<?php echo esc_attr($opt['custom_post'][$custom_post]['ogp_img'] ?? ''); ?>"/>
|
||||
<input type="button" class="select_ogp_img" name="select_ogp_img" value="選択"/>
|
||||
<input type="button" class="clear_ogp_img" name="clear_ogp_img" value="クリア"/>
|
||||
<div class="ogp_media"><?php echo $this->get_ogp_img('custom_post', $custom_post); ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
var ogp_img_name = "<?php echo esc_attr(MTEE_CONFIG::MTEE_OGP_IMG); ?>"
|
||||
</script>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<div class="updated fade"><p><strong>設定を保存しました</strong></p></div>
|
||||
<div id="settings_updated" class="updated notice is-dismissible"><p><strong>設定を保存しました</strong></p></div>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if (!trait_exists('mtee_meta_desc_trait')) {
|
||||
|
||||
trait mtee_meta_desc_trait {
|
||||
|
||||
public function post_output_get_meta_desc($type) {
|
||||
global $post;
|
||||
if ($type == 'top_page') {
|
||||
$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_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_description = get_term_meta($queried_object->term_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true);
|
||||
} else {
|
||||
$meta_description = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true);
|
||||
}
|
||||
return $meta_description;
|
||||
}
|
||||
|
||||
public function create_default_description() {
|
||||
$type = '';
|
||||
$title = '';
|
||||
$suffix_text = MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE;
|
||||
|
||||
if (is_home() || is_front_page()) { //ページ
|
||||
return MTEE_CONFIG::MTEE_META_DESC_TOP_BASE;
|
||||
} elseif (is_page() || is_single()) { //ページ
|
||||
$type = 'page';
|
||||
$title = get_the_title();
|
||||
$suffix_text = MTEE_CONFIG::MTEE_META_DESC_SINGLE_BASE;
|
||||
} elseif (is_category()) { //カテゴリー
|
||||
$type = 'category';
|
||||
$title = single_cat_title('', false);
|
||||
} elseif (is_tag()) { //タグ
|
||||
$type = 'tag';
|
||||
$title = single_tag_title('', false);
|
||||
} elseif (is_tax()) { //タクソノミー
|
||||
$type = 'tax';
|
||||
$title = single_term_title('', false);
|
||||
} elseif (is_post_type_archive()) { //カスタム投稿のアーカイブ
|
||||
$type = 'custom_post';
|
||||
$title = post_type_archive_title('', false);
|
||||
}
|
||||
|
||||
$replacement = $this->cnv_custom_template($type, $title, $suffix_text);
|
||||
|
||||
if (isset($replacement['org'])) {
|
||||
$search = array('<###>', '<%%%>');
|
||||
$description_noun = MTEE_CONFIG::MTEE_META_DESC_BEFORE_BRACKETS . '<###>' . MTEE_CONFIG::MTEE_META_DESC_AFTER_BRACKETS . '<%%%>';
|
||||
return str_replace($search, $replacement['org'], $description_noun);
|
||||
} else {
|
||||
return $replacement;
|
||||
}
|
||||
}
|
||||
|
||||
public 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##', '##site_description##');
|
||||
$replacement = array($title, get_bloginfo('name'), get_bloginfo('description'));
|
||||
return str_replace($search, $replacement, $template[$type]);
|
||||
} else {
|
||||
return array('org' => array($title, $suffix_text));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} // Exit if accessed directly
|
||||
|
||||
if ( ! trait_exists( 'mtee_utils' ) ) {
|
||||
|
||||
trait mtee_utils {
|
||||
|
||||
public function get_post_sanitize_data( $var_name, $type = 'str' ) {
|
||||
if ( $type == 'str' ) {
|
||||
return filter_input( INPUT_POST, $var_name, FILTER_DEFAULT );
|
||||
}
|
||||
if ( $type == 'array' ) {
|
||||
return filter_input( INPUT_POST, $var_name, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function save_post_meta( $post_id, $var_name ) {
|
||||
if ( ! empty( $_POST[ $var_name ] ) ) {
|
||||
update_post_meta( $post_id, $var_name, $this->get_post_sanitize_data( $var_name ) ); //値を保存
|
||||
} else { //未入力の場合は値を削除
|
||||
delete_post_meta( $post_id, $var_name );
|
||||
}
|
||||
}
|
||||
|
||||
public function save_term_meta( $term_id, $var_name ) {
|
||||
if ( array_key_exists( $var_name, $_POST ) ) {
|
||||
update_term_meta( $term_id, $var_name, $this->get_post_sanitize_data( $var_name ) );
|
||||
} else { //未入力の場合は値を削除
|
||||
delete_term_meta( $term_id, $var_name );
|
||||
}
|
||||
}
|
||||
|
||||
public function set_escape_str( $base, $param, $type ) {
|
||||
return esc_html( $base[ $param ][ $type ] ?? '' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user