Compare commits
8 Commits
da6cc8f734
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 36650effe1 | |||
| e8f4c139e4 | |||
| 55a8368fec | |||
| dcf7e015a7 | |||
| 937d33817a | |||
| 2eea8e3cae | |||
| e502ea6dce | |||
| 1c1d97cedf |
+6
-4
@@ -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,11 +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';
|
||||
require_once MTEE_CONFIG::MTEE_TEMPLATE_DIR . 'index.php';
|
||||
}
|
||||
|
||||
public static function register_target(): array {
|
||||
@@ -91,7 +93,7 @@ if (!class_exists('MTEE')) {
|
||||
}
|
||||
}
|
||||
if (!empty($id)) {
|
||||
return '<img src="' . wp_get_attachment_image_src($id, 'thumbnail')[0] . '">';
|
||||
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) {
|
||||
@@ -53,22 +55,18 @@ 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) . '"
|
||||
placeholder="' . $this->set_default_post_canonical_url($post->ID) . '" />
|
||||
<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) {
|
||||
@@ -103,35 +101,47 @@ placeholder="' . $this->set_default_post_canonical_url($post->ID) . '" />
|
||||
}
|
||||
|
||||
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 = '';
|
||||
$placeholder = '';
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
$add_meta = '<input type="text" name="' . MTEE_CANONICAL_URL . '" value="' . $canonical_url . '"
|
||||
placeholder="' . $placeholder . '" />';
|
||||
return str_replace('##CONTENTS##', $add_meta, $form);
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
public function set_default_tax_canonical_url($id, $taxonomy) {
|
||||
private function set_default_tax_canonical_url($id, $taxonomy) {
|
||||
if ($taxonomy == 'category') {
|
||||
$placeholder = get_category_link($id);
|
||||
} elseif ($taxonomy == 'post_tag') {
|
||||
@@ -143,9 +153,7 @@ placeholder="' . $this->set_default_post_canonical_url($post->ID) . '" />
|
||||
}
|
||||
|
||||
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,7 +110,7 @@ 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((int)$id);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
|
||||
include MTEE_TRAIT_DIR . 'mtee_meta_desc_trait.php';
|
||||
include MTEE_CONFIG::MTEE_TRAIT_DIR . 'mtee_meta_desc_trait.php';
|
||||
|
||||
class mtee_meta_output_keydesc {
|
||||
|
||||
@@ -18,13 +18,18 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
public function post_output_add_metas() {
|
||||
$this->create_post_output_add_metas();
|
||||
echo implode(PHP_EOL, $this->metas) . PHP_EOL;
|
||||
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() {
|
||||
@@ -42,25 +47,24 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
$type = 'post_tag';
|
||||
}
|
||||
if (isset($type)) {
|
||||
$this->metas = $this->post_output_view_metas($type);
|
||||
$this->post_output_view_metas($type);
|
||||
}
|
||||
if (count($this->metas) == 0) {
|
||||
$this->metas = $this->create_default_keywords_description();
|
||||
$this->create_default_keywords_description();
|
||||
}
|
||||
}
|
||||
|
||||
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 = array(
|
||||
MTEE_NAME_KEYWORDS => str_replace('、', ',', $this->post_output_get_meta_keywords($type)),
|
||||
MTEE_NAME_DESCRIPTION => $this->post_output_get_meta_desc($type),
|
||||
$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),
|
||||
);
|
||||
return $this->create_meta_tags($meta_data);
|
||||
}
|
||||
|
||||
public function post_output_get_meta_keywords($type) {
|
||||
@@ -72,20 +76,19 @@ if (!class_exists('mtee_meta_output_keydesc')) {
|
||||
$meta_key_words = get_option('_mtee')['custom_post'][$custom_post_name]['keywords'];
|
||||
} 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_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_key_words = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_KEYWORDS, true);
|
||||
}
|
||||
return $meta_key_words;
|
||||
}
|
||||
|
||||
public function create_default_keywords_description(): array {
|
||||
public function create_default_keywords_description() {
|
||||
$this->description .= $this->create_default_description();
|
||||
$meta_data = array(
|
||||
MTEE_NAME_KEYWORDS => implode(',', $this->create_default_keywords()),
|
||||
MTEE_NAME_DESCRIPTION => $this->description,
|
||||
$this->metas = array(
|
||||
MTEE_CONFIG::MTEE_NAME_KEYWORDS => implode(',', $this->create_default_keywords()),
|
||||
MTEE_CONFIG::MTEE_NAME_DESCRIPTION => $this->description,
|
||||
);
|
||||
return $this->create_meta_tags($meta_data);
|
||||
}
|
||||
|
||||
public function create_default_keywords(): array {
|
||||
@@ -206,11 +209,11 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -44,23 +44,22 @@ if (!class_exists('mtee_meta_output_ogp')) {
|
||||
$this->create_ogp_description();
|
||||
$this->create_ogp_image();
|
||||
$this->create_ogp_url();
|
||||
echo $this->set_ogp_tag();
|
||||
$this->set_ogp_tag();
|
||||
}
|
||||
|
||||
|
||||
public function set_ogp_tag() {
|
||||
$tags = '<meta property="og:title" content="' . $this->ogp_title . '" />' . PHP_EOL;
|
||||
$tags .= '<meta property="og:description" content="' . $this->ogp_description . '" />' . PHP_EOL;
|
||||
$tags .= '<meta property="og:type" content="' . $this->ogp_type . '" />' . PHP_EOL;
|
||||
$tags .= '<meta property="og:url" content="' . $this->ogp_url . '" />' . PHP_EOL;
|
||||
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)) {
|
||||
$tags .= '<meta property="og:image" content="' . $this->ogp_img . '" />' . PHP_EOL;
|
||||
echo '<meta property="og:image" content="' . esc_attr($this->ogp_img) . '" />' . PHP_EOL;
|
||||
}
|
||||
$tags .= '<meta property="og:site_name" content="' . $this->site_name . '" />' . 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;
|
||||
$tags .= '<meta property="og:locale" content="' . $this->get_ogp_locale() . '" />' . "\n";
|
||||
return $tags;
|
||||
echo '<meta property="og:locale" content="' . esc_attr($this->get_ogp_locale()) . '" />' . PHP_EOL;
|
||||
}
|
||||
|
||||
public function get_ogp_locale(): string {
|
||||
@@ -90,9 +89,9 @@ if (!class_exists('mtee_meta_output_ogp')) {
|
||||
$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_OGP_TITLE, true);
|
||||
$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_OGP_TITLE, true);
|
||||
$this->ogp_title = get_post_meta($post->ID, MTEE_CONFIG::MTEE_OGP_TITLE, true);
|
||||
}
|
||||
if (empty($this->ogp_title)) {
|
||||
$this->create_default_title();
|
||||
@@ -131,14 +130,14 @@ if (!class_exists('mtee_meta_output_ogp')) {
|
||||
$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_OGP_DESC, true);
|
||||
$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_OGP_DESC, true);
|
||||
$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_META_DESC_PARTICLE;
|
||||
$this->ogp_description = $this->site_name . MTEE_CONFIG::MTEE_META_DESC_PARTICLE;
|
||||
$type = '';
|
||||
$ogp_desc = '';
|
||||
|
||||
@@ -224,22 +223,22 @@ if (!class_exists('mtee_meta_output_ogp')) {
|
||||
}
|
||||
|
||||
public function set_post_ogp_img($id) {
|
||||
$id = get_post_meta($id, MTEE_OGP_IMG, true);
|
||||
$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_OGP_IMG, true);
|
||||
$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_OGP_IMG, true);
|
||||
$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_OGP_IMG, true);
|
||||
$id = get_term_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
$this->get_thumbnail($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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ if (!class_exists('mtee_ogp_post_setting')) {
|
||||
*/
|
||||
class mtee_ogp_post_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
@@ -47,31 +49,31 @@ if (!class_exists('mtee_ogp_post_setting')) {
|
||||
<label style="font-weight: bold; display: block">title</label>
|
||||
<div>
|
||||
<input style="width:100%" type="text"
|
||||
name="' . MTEE_OGP_TITLE . '"
|
||||
value="' . get_post_meta($post->ID, MTEE_OGP_TITLE, true) . '"
|
||||
placeholder="' . $this->set_default_ogp_title() . '"/>
|
||||
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="' . MTEE_OGP_DESC . '"
|
||||
value="' . get_post_meta($post->ID, MTEE_OGP_DESC, true) . '"
|
||||
placeholder="' . $this->set_default_ogp_desc() . '"/>
|
||||
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="' . MTEE_OGP_IMG . '" name="' . MTEE_OGP_IMG . '" type="hidden" value="' . get_post_meta($post->ID, MTEE_OGP_IMG, true) . '" />
|
||||
<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 = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>';
|
||||
}
|
||||
|
||||
@@ -84,30 +86,19 @@ var ogp_img_name = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
}
|
||||
|
||||
public function set_ogp_thumb($id): string {
|
||||
$ogp_thumb = get_post_meta($id, MTEE_OGP_IMG, true);
|
||||
$ogp_thumb = get_post_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
if (!empty($ogp_thumb)) {
|
||||
return '<img src="' . wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0] . '">';
|
||||
return '<img src="' . esc_html(wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0]) . '">';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// カスタムフィールドの値を保存
|
||||
public function save_meta_fields($post_id) {
|
||||
if (!empty($_POST[MTEE_OGP_TITLE])) { //meta_keywordsが入力されている場合
|
||||
update_post_meta($post_id, MTEE_OGP_TITLE, $_POST[MTEE_OGP_TITLE]); //値を保存
|
||||
} else { //未入力の場合は値を削除
|
||||
delete_post_meta($post_id, MTEE_OGP_TITLE);
|
||||
}
|
||||
if (!empty($_POST[MTEE_OGP_DESC])) {
|
||||
update_post_meta($post_id, MTEE_OGP_DESC, $_POST[MTEE_OGP_DESC]);
|
||||
} else {
|
||||
delete_post_meta($post_id, MTEE_OGP_DESC);
|
||||
}
|
||||
if (!empty($_POST[MTEE_OGP_IMG])) {
|
||||
update_post_meta($post_id, MTEE_OGP_IMG, $_POST[MTEE_OGP_IMG]);
|
||||
} else {
|
||||
delete_post_meta($post_id, MTEE_OGP_IMG);
|
||||
}
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ if (!class_exists('mtee_ogp_tax_setting')) {
|
||||
*/
|
||||
class mtee_ogp_tax_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
@@ -48,26 +50,26 @@ if (!class_exists('mtee_ogp_tax_setting')) {
|
||||
echo '
|
||||
<div class="form-field">
|
||||
OGP title<br>
|
||||
<input type="text" name="' . MTEE_OGP_TITLE . '"
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_TITLE) . '"
|
||||
value=""
|
||||
placeholder="' . $input_values['title_pl'] . '"
|
||||
placeholder="' . esc_attr($input_values['title_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
OGP description<br>
|
||||
<input type="text" name="' . MTEE_OGP_DESC . '"
|
||||
<input type="text" name="' . esc_attr(MTEE_CONFIG::MTEE_OGP_DESC) . '"
|
||||
value=""
|
||||
placeholder="' . $input_values['desc_pl'] . '"
|
||||
placeholder="' . esc_attr($input_values['desc_pl']) . '"
|
||||
class="tax-meta-field" />
|
||||
</div>
|
||||
<div class="form-field">
|
||||
image<br>
|
||||
<input class="' . MTEE_OGP_IMG . '" name="' . MTEE_OGP_IMG . '" type="hidden" value="" />
|
||||
<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 = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>
|
||||
</div>
|
||||
';
|
||||
@@ -80,23 +82,23 @@ var ogp_img_name = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
<th scope="row">OGP</th>
|
||||
<td>
|
||||
<label class="mtee-label">title:</label>
|
||||
<input type="text" name="' . MTEE_OGP_TITLE . '"
|
||||
value="' . $input_values['title'] . '"
|
||||
placeholder="' . $input_values['title_pl'] . '"
|
||||
<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="' . MTEE_OGP_DESC . '"
|
||||
value="' . $input_values['desc'] . '"
|
||||
placeholder="' . $input_values['desc_pl'] . '"
|
||||
<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="' . MTEE_OGP_IMG . '" name="' . MTEE_OGP_IMG . '" type="hidden" value="' . get_post_meta($tag->term_id, MTEE_OGP_IMG, true) . '" />
|
||||
<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 = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
var ogp_img_name = ' . "'" . esc_attr(MTEE_CONFIG::MTEE_OGP_IMG) . "'" . '
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -109,8 +111,8 @@ var ogp_img_name = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
$title_placeholder = '';
|
||||
$desc_placeholder = '';
|
||||
if (isset($tag->term_id)) {
|
||||
$title_value = get_term_meta($tag->term_id, MTEE_OGP_TITLE, true);
|
||||
$desc_value = get_term_meta($tag->term_id, MTEE_OGP_DESC, true);
|
||||
$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);
|
||||
}
|
||||
@@ -131,26 +133,17 @@ var ogp_img_name = ' . "'" . MTEE_OGP_IMG . "'" . '
|
||||
}
|
||||
|
||||
public function set_ogp_thumb($id): string {
|
||||
$ogp_thumb = get_post_meta($id, MTEE_OGP_IMG, true);
|
||||
$ogp_thumb = get_post_meta($id, MTEE_CONFIG::MTEE_OGP_IMG, true);
|
||||
if (!empty($ogp_thumb)) {
|
||||
return '<img src="' . wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0] . '">';
|
||||
return '<img src="' . esc_html(wp_get_attachment_image_src($ogp_thumb, 'thumbnail')[0]) . '">';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function save_terms($term_id) {
|
||||
if (array_key_exists(MTEE_OGP_TITLE, $_POST)) {
|
||||
update_term_meta($term_id, MTEE_OGP_TITLE, $_POST[MTEE_OGP_TITLE]);
|
||||
}
|
||||
if (array_key_exists(MTEE_OGP_DESC, $_POST)) {
|
||||
update_term_meta($term_id, MTEE_OGP_DESC, $_POST[MTEE_OGP_DESC]);
|
||||
}
|
||||
if (!empty($_POST[MTEE_OGP_IMG])) {
|
||||
update_post_meta($term_id, MTEE_OGP_IMG, $_POST[MTEE_OGP_IMG]);
|
||||
} else {
|
||||
delete_post_meta($term_id, MTEE_OGP_IMG);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-17
@@ -10,6 +10,8 @@ if (!class_exists('mtee_post_setting')) {
|
||||
*/
|
||||
class mtee_post_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
@@ -46,30 +48,22 @@ if (!class_exists('mtee_post_setting')) {
|
||||
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) . '"
|
||||
placeholder="' . $this->set_default_keywords() . '"/>
|
||||
<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="' . MTEE_NAME_DESCRIPTION . '"
|
||||
value="' . get_post_meta($post->ID, MTEE_NAME_DESCRIPTION, true) . '"
|
||||
placeholder="' . $this->set_default_description() . '"/>
|
||||
<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) {
|
||||
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);
|
||||
}
|
||||
$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() {
|
||||
@@ -91,7 +85,7 @@ placeholder="' . $this->set_default_description() . '"/>
|
||||
if (!empty($this->options['description_tmp']['page'])) {
|
||||
return $this->options['description_tmp']['page'];
|
||||
}
|
||||
return '##site_name##の' . MTEE_META_DESC_BEFORE_BRACKETS . '##title##' . MTEE_META_DESC_AFTER_BRACKETS . MTEE_META_DESC_SINGLE_BASE;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-21
@@ -10,6 +10,8 @@ if (!class_exists('mtee_tax_setting')) {
|
||||
*/
|
||||
class mtee_tax_setting {
|
||||
|
||||
use mtee_utils;
|
||||
|
||||
private $options;
|
||||
|
||||
public function __construct($options) {
|
||||
@@ -43,16 +45,16 @@ if (!class_exists('mtee_tax_setting')) {
|
||||
echo '
|
||||
<div class="form-field">
|
||||
meta keywords<br>
|
||||
<input type="text" name="' . MTEE_NAME_KEYWORDS . '"
|
||||
value="' . $input_values['keywords'] . '"
|
||||
placeholder="' . $input_values['keyword_pl'] . '"
|
||||
<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="' . MTEE_NAME_DESCRIPTION . '"
|
||||
value="' . $input_values['desc'] . '"
|
||||
placeholder="' . $input_values['desc_pl'] . '"
|
||||
<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>
|
||||
';
|
||||
@@ -65,14 +67,14 @@ class="tax-meta-field" />
|
||||
<th scope="row">meta keywords<br>meta description</th>
|
||||
<td>
|
||||
<label class="mtee-label">meta keywords:</label>
|
||||
<input type="text" name="' . MTEE_NAME_KEYWORDS . '"
|
||||
value="' . $input_values['keywords'] . '"
|
||||
placeholder="' . $input_values['keyword_pl'] . '"
|
||||
<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="' . MTEE_NAME_DESCRIPTION . '"
|
||||
value="' . $input_values['desc'] . '"
|
||||
placeholder="' . $input_values['desc_pl'] . '"
|
||||
<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>
|
||||
@@ -85,8 +87,8 @@ class="tax-meta-field" />
|
||||
$keyword_placeholder = '';
|
||||
$desc_placeholder = '';
|
||||
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);
|
||||
$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);
|
||||
}
|
||||
@@ -121,18 +123,14 @@ class="tax-meta-field" />
|
||||
$description = $this->options['description_tmp']['tax'];
|
||||
}
|
||||
if (empty($description)) {
|
||||
$description = '##site_name##の' . MTEE_META_DESC_BEFORE_BRACKETS . '##title##' . MTEE_META_DESC_AFTER_BRACKETS . MTEE_META_DESC_SINGLE_BASE;
|
||||
$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) {
|
||||
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]);
|
||||
}
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_KEYWORDS);
|
||||
$this->save_term_meta($term_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-20
@@ -1,20 +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_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 = '」';
|
||||
@@ -125,6 +125,15 @@ label.mtee-label {
|
||||
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;
|
||||
|
||||
+15
-15
@@ -17,8 +17,9 @@ 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 () {
|
||||
@@ -27,7 +28,6 @@ add_action('admin_enqueue_scripts', function () {
|
||||
wp_enqueue_script('mtee_js', $plugin_url . 'js/mtee.js', 'jquery');
|
||||
//メディアアップローダー
|
||||
wp_enqueue_media();
|
||||
|
||||
});
|
||||
|
||||
$mtee = new MTEE;
|
||||
@@ -35,9 +35,9 @@ $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();
|
||||
@@ -46,18 +46,18 @@ if ($mtee->is_enable('enabled')) {
|
||||
// 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_meta_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')) {
|
||||
include MTEE_TRAIT_DIR . 'mtee_meta_desc_trait.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee_ogp_tax_setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee_ogp_post_setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee_meta_output_ogp.php';
|
||||
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();
|
||||
@@ -65,8 +65,8 @@ if ($mtee->is_enable('ogp_setting')) {
|
||||
|
||||
//enabled my noindex, nofollow
|
||||
if ($mtee->is_enable('noindex_nofollow')) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee_noindexnofolow_setting.php';
|
||||
require_once MTEE_CLASS_DIR . 'mtee_meta_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();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ $disabled_checks = array(
|
||||
);
|
||||
foreach ($disabled_checks as $disabled_check) {
|
||||
if ($mtee->is_disable($disabled_check)) {
|
||||
require_once MTEE_CLASS_DIR . 'mtee_version_setting.php';
|
||||
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 = '」';
|
||||
|
||||
}
|
||||
}
|
||||
+37
-66
@@ -1,15 +1,6 @@
|
||||
<?php
|
||||
<?php /** @noinspection ALL */
|
||||
$register_targets = MTEE::register_target();
|
||||
$opt = get_option('_mtee');
|
||||
$mtee_set_nav = $_POST['mtee_set_nav'] ?? 'nav_metas';
|
||||
$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');
|
||||
$emoji_disabled = $this->get_key_setting('emoji_disabled');
|
||||
$rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
$opt = get_option( '_mtee' );
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2>meta keyword, description / バージョン情報 設定</h2>
|
||||
@@ -23,56 +14,51 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
</ul>
|
||||
</nav>
|
||||
<form action="" method="post">
|
||||
<?php wp_nonce_field('check_options'); ?>
|
||||
<input type="hidden" id="mtee_set_nav" name="mtee_set_nav" value="<?php echo $mtee_set_nav; ?>">
|
||||
<?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>
|
||||
<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>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<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>
|
||||
@@ -80,8 +66,8 @@ $rss_disabled = $this->get_key_setting('rss_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>
|
||||
@@ -96,45 +82,39 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
<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>
|
||||
<?php include 'pages_meta.php'; ?>
|
||||
<?php include 'pages_meta.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
@@ -143,11 +123,11 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[ogp_setting]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[ogp_setting]" <?php checked($ogp_setting, 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'; ?>
|
||||
<?php include 'pages_ogp.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
@@ -155,10 +135,10 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[noindex_nofollow]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[noindex_nofollow]" <?php checked($noindex_nofollow, 1); ?>
|
||||
name="_mtee[noindex_nofollow]" <?php checked( $this->get_key_setting( 'noindex_nofollow' ), 1 ); ?>
|
||||
value="1">有効
|
||||
</label>
|
||||
<?php include 'pages_noindexnofollow.php'; ?>
|
||||
<?php include 'pages_noindexnofollow.php'; ?>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
@@ -166,11 +146,11 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<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'; ?>
|
||||
<?php include 'pages_canonical.php'; ?>
|
||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||
</div>
|
||||
<div class="mtee_tab_box">
|
||||
@@ -180,26 +160,17 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[rss_disabled]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[rss_disabled]" <?php checked($rss_disabled, 1); ?>
|
||||
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>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); ?>
|
||||
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">
|
||||
@@ -207,8 +178,8 @@ $rss_disabled = $this->get_key_setting('rss_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>
|
||||
<div class="mtee-form-box mtee_box_border">
|
||||
@@ -216,7 +187,7 @@ $rss_disabled = $this->get_key_setting('rss_disabled');
|
||||
<label>
|
||||
<input type="hidden" name="_mtee[emoji_disabled]" value="0">
|
||||
<input type="checkbox"
|
||||
name="_mtee[emoji_disabled]" <?php checked($emoji_disabled, 1); ?>
|
||||
name="_mtee[emoji_disabled]" <?php checked( $this->get_key_setting( 'emoji_disabled' ), 1 ); ?>
|
||||
value="1">表示しない
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<?php
|
||||
$canonical_url = $opt['top_page']['canonical'] ?? '';
|
||||
?>
|
||||
<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 $canonical_url; ?>"
|
||||
placeholder="<?php echo get_bloginfo('url'); ?>">
|
||||
value="<?php echo esc_attr($opt['top_page']['canonical'] ?? ''); ?>"
|
||||
placeholder="<?php bloginfo('url'); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -17,22 +14,19 @@ $canonical_url = $opt['top_page']['canonical'] ?? '';
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php
|
||||
$canonical_url = $opt['custom_post'][$custom_post]['canonical'] ?? '';
|
||||
?>
|
||||
<?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; ?>)
|
||||
<?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 $custom_post; ?>][canonical]"
|
||||
value="<?php echo $canonical_url; ?>"
|
||||
placeholder="<?php echo get_post_type_archive_link($custom_post); ?>">
|
||||
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>
|
||||
|
||||
+12
-18
@@ -1,22 +1,19 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<?php
|
||||
$keywords = $opt['top_page']['keywords'] ?? '';
|
||||
$description = $opt['top_page']['description'] ?? '';
|
||||
?>
|
||||
<div class="mtee-form-box">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th>meta keywords</th>
|
||||
<td><input class="top_page_keywords" type="text" name="_mtee[top_page][keywords]"
|
||||
value="<?php echo $keywords; ?>" placeholder="キーワード1,キーワード2,キーワード3">
|
||||
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 $description; ?>"
|
||||
placeholder="<?php echo get_bloginfo('name'); ?>の<?php echo MTEE_META_DESC_TOP_BASE; ?>">
|
||||
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>
|
||||
@@ -24,31 +21,28 @@ $description = $opt['top_page']['description'] ?? '';
|
||||
<?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'] ?? '';
|
||||
?>
|
||||
<?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; ?>)
|
||||
<?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 $custom_post; ?>][keywords]"
|
||||
value="<?php echo $keywords; ?>" placeholder="キーワード1,キーワード2,キーワード3">
|
||||
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 $custom_post; ?>][description]"
|
||||
value="<?php echo $description; ?>"
|
||||
placeholder="<?php echo get_bloginfo('name'); ?>の[カスタム投稿ラベル]<?php echo MTEE_META_DESC_ARCHIVE_BASE; ?>">
|
||||
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>
|
||||
|
||||
@@ -38,8 +38,8 @@ $nofollow = $opt['top_page']['nofollow'] ?? '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; ?>)
|
||||
<?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">
|
||||
@@ -48,19 +48,19 @@ $nofollow = $opt['top_page']['nofollow'] ?? '0';
|
||||
<div class="meta_noindex_nofollow_box">
|
||||
<label>
|
||||
<input type="hidden"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][noindex]"
|
||||
name="_mtee[custom_post][<?php echo esc_attr($custom_post); ?>][noindex]"
|
||||
value="0"/>
|
||||
<input type="checkbox"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][noindex]" <?php checked($noindex, 1); ?>
|
||||
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 $custom_post; ?>][nofollow]"
|
||||
name="_mtee[custom_post][<?php echo esc_html($custom_post); ?>][nofollow]"
|
||||
value="0"/>
|
||||
<input type="checkbox"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][nofollow]" <?php checked($nofollow, 1); ?>
|
||||
name="_mtee[custom_post][<?php echo esc_html($custom_post); ?>][nofollow]" <?php checked($nofollow, 1); ?>
|
||||
value="1"/>
|
||||
nofollow
|
||||
</label>
|
||||
|
||||
+15
-24
@@ -1,28 +1,24 @@
|
||||
<h2 class="mtee_page_title mtee_box_border">トップページ</h2>
|
||||
<?php
|
||||
$ogp_title = $opt['top_page']['ogp_title'] ?? '';
|
||||
$ogp_description = $opt['top_page']['ogp_description'] ?? '';
|
||||
$ogp_img = $opt['top_page']['ogp_img'] ?? '';
|
||||
?>
|
||||
<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 $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 $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 MTEE_OGP_IMG; ?>" name="_mtee[top_page][ogp_img]" type="hidden"
|
||||
value="<?php echo $ogp_img; ?>"/>
|
||||
<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>
|
||||
@@ -33,39 +29,34 @@ $ogp_img = $opt['top_page']['ogp_img'] ?? '';
|
||||
<?php if (count($register_targets['custom_posts']) > 0): ?>
|
||||
<h2 class="mtee_page_title">カスタム投稿アーカイブ</h2>
|
||||
<?php foreach ($register_targets['custom_posts'] as $custom_post): ?>
|
||||
<?php
|
||||
$ogp_title = $opt['custom_post'][$custom_post]['ogp_title'] ?? '';
|
||||
$ogp_description = $opt['custom_post'][$custom_post]['ogp_description'] ?? '';
|
||||
$ogp_img = $opt['custom_post'][$custom_post]['ogp_img'] ?? '';
|
||||
?>
|
||||
<?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; ?>)
|
||||
<?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 $custom_post; ?>][ogp_title]"
|
||||
value="<?php echo $ogp_title; ?>">
|
||||
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 $custom_post; ?>][ogp_description]"
|
||||
value="<?php echo $ogp_description; ?>">
|
||||
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 MTEE_OGP_IMG; ?>"
|
||||
name="_mtee[custom_post][<?php echo $custom_post; ?>][ogp_img]"
|
||||
<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 $ogp_img; ?>"/>
|
||||
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>
|
||||
@@ -76,6 +67,6 @@ $ogp_img = $opt['top_page']['ogp_img'] ?? '';
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
var ogp_img_name = "<?php echo MTEE_OGP_IMG; ?>"
|
||||
var ogp_img_name = "<?php echo esc_attr(MTEE_CONFIG::MTEE_OGP_IMG); ?>"
|
||||
</script>
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ if (!trait_exists('mtee_meta_desc_trait')) {
|
||||
$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_NAME_DESCRIPTION, true);
|
||||
$meta_description = get_term_meta($queried_object->term_id, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true);
|
||||
} else {
|
||||
$meta_description = get_post_meta($post->ID, MTEE_NAME_DESCRIPTION, true);
|
||||
$meta_description = get_post_meta($post->ID, MTEE_CONFIG::MTEE_NAME_DESCRIPTION, true);
|
||||
}
|
||||
return $meta_description;
|
||||
}
|
||||
@@ -26,14 +26,14 @@ if (!trait_exists('mtee_meta_desc_trait')) {
|
||||
public function create_default_description() {
|
||||
$type = '';
|
||||
$title = '';
|
||||
$suffix_text = MTEE_META_DESC_ARCHIVE_BASE;
|
||||
$suffix_text = MTEE_CONFIG::MTEE_META_DESC_ARCHIVE_BASE;
|
||||
|
||||
if (is_home() || is_front_page()) { //ページ
|
||||
return MTEE_META_DESC_TOP_BASE;
|
||||
return MTEE_CONFIG::MTEE_META_DESC_TOP_BASE;
|
||||
} elseif (is_page() || is_single()) { //ページ
|
||||
$type = 'page';
|
||||
$title = get_the_title();
|
||||
$suffix_text = MTEE_META_DESC_SINGLE_BASE;
|
||||
$suffix_text = MTEE_CONFIG::MTEE_META_DESC_SINGLE_BASE;
|
||||
} elseif (is_category()) { //カテゴリー
|
||||
$type = 'category';
|
||||
$title = single_cat_title('', false);
|
||||
@@ -52,7 +52,7 @@ if (!trait_exists('mtee_meta_desc_trait')) {
|
||||
|
||||
if (isset($replacement['org'])) {
|
||||
$search = array('<###>', '<%%%>');
|
||||
$description_noun = MTEE_META_DESC_BEFORE_BRACKETS . '<###>' . MTEE_META_DESC_AFTER_BRACKETS . '<%%%>';
|
||||
$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;
|
||||
|
||||
@@ -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