SEO SIMPLE PACK - Version 1.1.0

Version Description

& apply_filters robots PHP5.6

Download this release

Release Info

Developer looswebstudio
Plugin Icon 128x128 SEO SIMPLE PACK
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.9 to 1.1.0

assets/css/ssp.css CHANGED
@@ -96,14 +96,38 @@
96
 
97
  #ssp_wrap.ssp_metabox > label{
98
  display: block;
99
- padding: 0 0 8px;
100
  font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
  #ssp_wrap.ssp_metabox .ssp_meta_inner{
103
  margin: 8px 0 40px;
104
  padding-left: 24px;
105
  }
106
-
 
 
 
 
 
 
 
107
 
108
  /* ssp form-table */
109
 
@@ -174,11 +198,16 @@
174
  }
175
 
176
  #ssp_wrap #media_preview {
177
- margin-bottom: 8px;
178
  }
179
  #ssp_wrap #media_preview img{
180
  width: 400px;
181
  }
 
 
 
 
 
182
  #ssp_wrap #media_btn {
183
  margin-right: 24px;
184
  }
96
 
97
  #ssp_wrap.ssp_metabox > label{
98
  display: block;
99
+ padding: 0 0 4px;
100
  font-weight: bold;
101
+ vertical-align: middle;
102
+ }
103
+
104
+ #ssp_wrap.ssp_metabox > label::before{
105
+ content: "";
106
+ display: inline-block;
107
+ width: 8px;
108
+ height: 16px;
109
+ border: solid 1px #c9d6a1;
110
+ box-shadow: inset -1px -1px 8px #fff;
111
+ background: #c9d6a1;
112
+ border-radius: 2px;
113
+ vertical-align: middle;
114
+ margin-right: 4px;
115
+ cursor: initial;
116
+ position: relative;
117
+ top: -1px;
118
  }
119
  #ssp_wrap.ssp_metabox .ssp_meta_inner{
120
  margin: 8px 0 40px;
121
  padding-left: 24px;
122
  }
123
+ #ssp_metabox h2{
124
+ font-size: 16px;
125
+ }
126
+ #ssp_metabox h2:first-letter{
127
+ font-size: 1.6em;
128
+ color: #b3c973;
129
+ letter-spacing: 1px;
130
+ }
131
 
132
  /* ssp form-table */
133
 
198
  }
199
 
200
  #ssp_wrap #media_preview {
201
+ margin-bottom: 24px;
202
  }
203
  #ssp_wrap #media_preview img{
204
  width: 400px;
205
  }
206
+ #ssp_wrap #media_preview .no_image{
207
+ width: 400px;
208
+ padding: 40px 40px;
209
+ border:dashed 1px #ccc;
210
+ }
211
  #ssp_wrap #media_btn {
212
  margin-right: 24px;
213
  }
class/ssp_activate.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SSP_Activate {
4
+
5
+ /**
6
+ * 外部からのインスタンス化を防ぐ
7
+ */
8
+ private function __construct() {}
9
+
10
+
11
+ /**
12
+ * プラグイン有効化時の処理
13
+ * Function for the plugin activated.
14
+ */
15
+ public static function plugin_activate() {
16
+
17
+ if ( get_option( SSP_Data::DB_NAME[ 'installed' ] ) === false ) {
18
+
19
+ //初回 or 再インストール時 : デフォルト設定取得
20
+ $SSP_settings = SSP_Data::DEFAULT_SETTINGS;
21
+ $SSP_ogp = SSP_Data::DEFAULT_OGP;
22
+
23
+ update_option( SSP_Data::DB_NAME[ 'installed' ], 1 );
24
+
25
+ } else {
26
+
27
+ //データが残っている場合 : 既存設定取得
28
+ $SSP_settings = get_option( SSP_Data::DB_NAME[ 'settings' ] );
29
+ $SSP_ogp = get_option( SSP_Data::DB_NAME[ 'ogp' ] );
30
+
31
+ }
32
+
33
+ //DB更新
34
+ update_option( SSP_Data::DB_NAME[ 'settings' ], $SSP_settings );
35
+ update_option( SSP_Data::DB_NAME[ 'ogp' ], $SSP_ogp );
36
+
37
+ }
38
+
39
+
40
+ /**
41
+ * プラグイン停止時の処理
42
+ * Function for the plugin deactivated.
43
+ */
44
+ public static function plugin_deactivate() {
45
+ }
46
+
47
+
48
+ /**
49
+ * プラグインアンインストール時の処理
50
+ * Function for the plugin uninstalled.
51
+ */
52
+ public static function plugin_uninstall() {
53
+ foreach ( SSP_Data::DB_NAME as $db_name ) {
54
+ delete_option( $db_name );
55
+ }
56
+ }
57
+
58
+
59
+
60
+ }
class/ssp_init.php CHANGED
@@ -7,6 +7,13 @@ class SSP_Init {
7
  */
8
  public function __construct() {
9
 
 
 
 
 
 
 
 
10
  $this->set_ssp_data();
11
  $this->set_hooks();
12
 
7
  */
8
  public function __construct() {
9
 
10
+ /**
11
+ * アクティベーションフック
12
+ */
13
+ register_activation_hook( SSP_FILE, ['SSP_Methods','plugin_activate'] );
14
+ register_deactivation_hook( SSP_FILE, ['SSP_Methods','plugin_deactivate'] );
15
+ register_uninstall_hook( SSP_FILE, ['SSP_Methods','plugin_uninstall'] );
16
+
17
  $this->set_ssp_data();
18
  $this->set_hooks();
19
 
class/ssp_menu.php CHANGED
@@ -12,8 +12,8 @@ class SSP_Menu {
12
  * トップレベルメニューの設定
13
  */
14
  const TOP_MENU = [
15
- 'page_title' => 'SIMPLE SEO', //ページのタイトルタグに表示されるテキスト
16
- 'menu_title' => 'SIMPLE SEO', //メニュータイトル
17
  'capability' => 'manage_options', //必要な権限
18
  'menu_slug' => 'ssp_main_setting', //このメニューを参照するスラッグ名
19
  'function' => ['SSP_Menu','ssp_top_menu'], //呼び出す関数名
12
  * トップレベルメニューの設定
13
  */
14
  const TOP_MENU = [
15
+ 'page_title' => 'SEO PACK', //ページのタイトルタグに表示されるテキスト
16
+ 'menu_title' => 'SEO PACK', //メニュータイトル
17
  'capability' => 'manage_options', //必要な権限
18
  'menu_slug' => 'ssp_main_setting', //このメニューを参照するスラッグ名
19
  'function' => ['SSP_Menu','ssp_top_menu'], //呼び出す関数名
class/ssp_metabox.php CHANGED
@@ -11,7 +11,8 @@ class SSP_MetaBox {
11
  * metabox names
12
  */
13
  const METANAME = [
14
- 'noindex' => 'ssp_meta_noindex',
 
15
  'description' => 'ssp_meta_description',
16
  'keyword' => 'ssp_meta_keyword',
17
  ];
@@ -22,15 +23,13 @@ class SSP_MetaBox {
22
  *
23
  */
24
  public static function add_ssp_metabox() {
25
- $args = ['public' => true, '_builtin' => false];
26
  $post_types = get_post_types( $args, 'names', 'and' );
27
- $taxonomies = get_taxonomies( $args, 'names', 'and' );
28
-
29
- $screens = array_merge( ['post','page'], $post_types );
30
 
31
  add_meta_box(
32
  'ssp_metabox', //メタボックスのID名(html)
33
- 'SEO設定', //メタボックスのタイトル
34
  ['SSP_MetaBox', 'ssp_metabox_callback'], //htmlを出力する関数名
35
  $screens, //表示する投稿タイプ
36
  'advanced', //表示場所 : 'normal', 'advanced', 'side'
@@ -47,40 +46,57 @@ class SSP_MetaBox {
47
  */
48
  public static function ssp_metabox_callback( $post ) {
49
 
50
- $val_noindex = get_post_meta( $post->ID, self::METANAME['noindex'], true );
 
51
  $val_description = get_post_meta( $post->ID, self::METANAME['description'], true );
52
- $val_keyword = get_post_meta( $post->ID, self::METANAME['keyword'], true );
53
-
54
- $cb = ($val_noindex === "1")
55
- ? '<input type="checkbox" name="" id="'.self::METANAME['noindex'].'" checked>'
56
- : '<input type="checkbox" name="" id="'.self::METANAME['noindex'].'">';
57
-
58
-
59
- echo '<div id="ssp_wrap" class="ssp_metabox">',
60
-
61
- '<label for="', self::METANAME['noindex'], '">インデックス設定を反転させる</label>',
62
- '<div class="ssp_meta_inner">',
63
- '<span>はい</span>',
64
- '<label class="switch_box" for="', self::METANAME['noindex'], '">',
65
- $cb, '<span class="slider round"></span>',
66
- '</label>',
67
- '<span>いいえ</span>',
68
- '<input type="hidden" name="', self::METANAME['noindex'], '" value="', $val_noindex, '">',
69
- '</div>',
70
-
71
- '<label for="', self::METANAME['description'], '">このページのディスクリプション</label>',
72
- '<div class="ssp_meta_inner">',
73
- '<textarea id="', self::METANAME['description'], '" name="', self::METANAME['description'], '">',
74
- esc_html( $val_description ),
75
- '</textarea>',
76
- '</div>',
77
-
78
- '<label for="', self::METANAME['keyword'], '">このページのキーワード</label>',
79
- '<div class="ssp_meta_inner">',
80
- '<input type="text" id="', self::METANAME['keyword'], '" name="', self::METANAME['keyword'], '" value="',esc_html( $val_keyword ),'">',
81
- '</div>',
82
- '</div>';
83
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  // nonceフィールド追加
85
  wp_nonce_field( SSP_Data::NOUNCE_ACTION, SSP_Data::NOUNCE_NAME );
86
  }
@@ -136,21 +152,24 @@ class SSP_MetaBox {
136
 
137
  // Make sure that it is set.
138
  // 保存したい情報が渡ってきているか確認
139
- if ( !isset( $_POST[self::METANAME['noindex']] ) ||
140
- !isset( $_POST[self::METANAME['description']] ) ||
141
- !isset( $_POST[self::METANAME['keyword']] ) ) {
 
142
  return;
143
  }
144
 
145
  // Sanitize user input.
146
  // 入力された値をサニタイズ
147
- $meta_noindex = sanitize_text_field( $_POST[self::METANAME['noindex']] );
 
148
  $meta_description = sanitize_text_field( $_POST[self::METANAME['description']] );
149
  $meta_keyword = sanitize_text_field( $_POST[self::METANAME['keyword']] );
150
 
151
  // Update the meta field in the database.
152
  // データベースのポストメタに値を保存
153
- update_post_meta( $post_id, self::METANAME['noindex'], $meta_noindex );
 
154
  update_post_meta( $post_id, self::METANAME['description'], $meta_description );
155
  update_post_meta( $post_id, self::METANAME['keyword'], $meta_keyword );
156
  }
11
  * metabox names
12
  */
13
  const METANAME = [
14
+ 'robots' => 'ssp_meta_robots',
15
+ 'title' => 'ssp_meta_title',
16
  'description' => 'ssp_meta_description',
17
  'keyword' => 'ssp_meta_keyword',
18
  ];
23
  *
24
  */
25
  public static function add_ssp_metabox() {
26
+ $args = ['public' => true, '_builtin' => false];
27
  $post_types = get_post_types( $args, 'names', 'and' );
28
+ $screens = array_merge( ['post','page'], $post_types );
 
 
29
 
30
  add_meta_box(
31
  'ssp_metabox', //メタボックスのID名(html)
32
+ 'SEO SIMPLE PACK 設定', //メタボックスのタイトル
33
  ['SSP_MetaBox', 'ssp_metabox_callback'], //htmlを出力する関数名
34
  $screens, //表示する投稿タイプ
35
  'advanced', //表示場所 : 'normal', 'advanced', 'side'
46
  */
47
  public static function ssp_metabox_callback( $post ) {
48
 
49
+ $val_robots = get_post_meta( $post->ID, self::METANAME['robots'], true );
50
+ $val_title = get_post_meta( $post->ID, self::METANAME['title'], true );
51
  $val_description = get_post_meta( $post->ID, self::METANAME['description'], true );
52
+ $val_keyword = get_post_meta( $post->ID, self::METANAME['keyword'], true );
53
+
54
+ $robots_arr = [
55
+ "index,follow",
56
+ "noindex,follow",
57
+ "index,nofollow",
58
+ "noindex,nofollow",
59
+ "noarchive"
60
+ ];
61
+ ?>
62
+ <div id="ssp_wrap" class="ssp_metabox">
63
+
64
+ <label for="<?=self::METANAME['robots']?>">このページのrobotsタグを上書きする</label>
65
+ <div class="ssp_meta_inner">
66
+ <select name="<?=self::METANAME['robots']?>" id="<?=self::METANAME['robots']?>">
67
+ <option value="">-- 上書きしない --</option>
68
+ <?php foreach ($robots_arr as $value) {
69
+ if ( $value === $val_robots ) {
70
+ echo '<option value="', $value ,'" selected>', $value ,'</option>';
71
+ } else {
72
+ echo '<option value="', $value ,'">', $value ,'</option>';
73
+ }
74
+ } ?>
75
+ </select>
76
+ </div>
77
+
78
+ <label for="<?=self::METANAME['title']?>">このページのタイトルタグを上書きする</label>
79
+ <div class="ssp_meta_inner">
80
+ <input type="text" id="<?=self::METANAME['title']?>" name="<?=self::METANAME['title']?>" value="<?=esc_html( $val_title)?>">
81
+ <p class="ssp_note">
82
+ <i>スニペットタグ( <code>%_site_title_%</code>など )が使用可能です。</i>
83
+ </p>
84
+ </div>
85
+
86
+ <label for="<?=self::METANAME['description']?>">このページのディスクリプション</label>
87
+ <div class="ssp_meta_inner">
88
+ <textarea id="<?=self::METANAME['description']?>" name="<?=self::METANAME['description']?>"><?=esc_html( $val_description )?></textarea>
89
+ <p class="ssp_note">
90
+ <i>空白の場合、コンテンツから自動でディスクリプションタグが生成されます。</i>
91
+ </p>
92
+ </div>
93
+
94
+ <label for="<?=self::METANAME['keyword']?>">このページのキーワード</label>
95
+ <div class="ssp_meta_inner">
96
+ <input type="text" id="<?=self::METANAME['keyword']?>" name="<?=self::METANAME['keyword']?>" value="<?=esc_html( $val_keyword )?>">
97
+ </div>
98
+ </div>
99
+ <?php
100
  // nonceフィールド追加
101
  wp_nonce_field( SSP_Data::NOUNCE_ACTION, SSP_Data::NOUNCE_NAME );
102
  }
152
 
153
  // Make sure that it is set.
154
  // 保存したい情報が渡ってきているか確認
155
+ if ( !isset( $_POST[self::METANAME['robots']] ) ||
156
+ !isset( $_POST[self::METANAME['title']] ) ||
157
+ !isset( $_POST[self::METANAME['description']] ) ||
158
+ !isset( $_POST[self::METANAME['keyword']] ) ) {
159
  return;
160
  }
161
 
162
  // Sanitize user input.
163
  // 入力された値をサニタイズ
164
+ $meta_robots = sanitize_text_field( $_POST[self::METANAME['robots']] );
165
+ $meta_title = sanitize_text_field( $_POST[self::METANAME['title']] );
166
  $meta_description = sanitize_text_field( $_POST[self::METANAME['description']] );
167
  $meta_keyword = sanitize_text_field( $_POST[self::METANAME['keyword']] );
168
 
169
  // Update the meta field in the database.
170
  // データベースのポストメタに値を保存
171
+ update_post_meta( $post_id, self::METANAME['robots'], $meta_robots );
172
+ update_post_meta( $post_id, self::METANAME['title'], $meta_title );
173
  update_post_meta( $post_id, self::METANAME['description'], $meta_description );
174
  update_post_meta( $post_id, self::METANAME['keyword'], $meta_keyword );
175
  }
class/ssp_methods.php CHANGED
@@ -20,54 +20,6 @@ class SSP_Methods {
20
  }
21
 
22
 
23
- /**
24
- * プラグイン有効化時の処理
25
- * Function for the plugin activated.
26
- */
27
- public static function plugin_activate() {
28
-
29
- if ( get_option( SSP_Data::DB_NAME[ 'installed' ] ) === false ) {
30
-
31
- //初回 or 再インストール時 : デフォルト設定取得
32
- $SSP_settings = SSP_Data::DEFAULT_SETTINGS;
33
- $SSP_ogp = SSP_Data::DEFAULT_OGP;
34
-
35
- update_option( SSP_Data::DB_NAME[ 'installed' ], 1 );
36
-
37
- } else {
38
-
39
- //データが残っている場合 : 既存設定取得
40
- $SSP_settings = get_option( SSP_Data::DB_NAME[ 'settings' ] );
41
- $SSP_ogp = get_option( SSP_Data::DB_NAME[ 'ogp' ] );
42
-
43
- }
44
-
45
- //DB更新
46
- update_option( SSP_Data::DB_NAME[ 'settings' ], $SSP_settings );
47
- update_option( SSP_Data::DB_NAME[ 'ogp' ], $SSP_ogp );
48
-
49
- }
50
-
51
-
52
- /**
53
- * プラグイン停止時の処理
54
- * Function for the plugin deactivated.
55
- */
56
- public static function plugin_deactivate() {
57
- }
58
-
59
-
60
- /**
61
- * プラグインアンインストール時の処理
62
- * Function for the plugin uninstalled.
63
- */
64
- public static function plugin_uninstall() {
65
- foreach ( SSP_Data::DB_NAME as $db_name ) {
66
- delete_option( $db_name );
67
- }
68
- }
69
-
70
-
71
  /**
72
  * カスタム投稿タイプ・タクソノミー用の設定を追加
73
  */
@@ -78,9 +30,9 @@ class SSP_Methods {
78
  }
79
 
80
  $added_new_data = false;
81
- $args = [ 'public' => true, '_builtin' => false ];
82
- $post_types = get_post_types( $args, 'names', 'and' );
83
- $taxonomies = get_taxonomies( $args, 'names', 'and' );
84
 
85
  //カスタム投稿 settings 追加
86
  foreach ( $post_types as $pt ) {
@@ -117,7 +69,7 @@ class SSP_Methods {
117
  public static function set_branch() {
118
 
119
  SSP_Branch::$is_ = [
120
- 'home' => is_home(),
121
  'front' => is_front_page(),
122
  'single' => is_single(),
123
  'page' => is_page(),
@@ -182,14 +134,17 @@ class SSP_Methods {
182
 
183
  if ( SSP_Branch::$is_['author'] && SSP_Data::$settings['author_disable'] ) {
184
  wp_safe_redirect($home);
 
185
  }
186
  if ( SSP_Branch::$is_['tax'] && SSP_Data::$settings['post_format_disable'] ) {
187
  if (get_queried_object()->taxonomy === 'post_format') {
188
  wp_safe_redirect($home);
 
189
  };
190
  }
191
  if ( SSP_Branch::$is_['attachment'] && SSP_Data::$settings['media_disable'] ) {
192
  wp_safe_redirect(get_post()->guid);
 
193
  }
194
  }
195
 
20
  }
21
 
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  /**
24
  * カスタム投稿タイプ・タクソノミー用の設定を追加
25
  */
30
  }
31
 
32
  $added_new_data = false;
33
+ $args = [ 'public' => true, '_builtin' => false ];
34
+ $post_types = get_post_types( $args, 'names', 'and' );
35
+ $taxonomies = get_taxonomies( $args, 'names', 'and' );
36
 
37
  //カスタム投稿 settings 追加
38
  foreach ( $post_types as $pt ) {
69
  public static function set_branch() {
70
 
71
  SSP_Branch::$is_ = [
72
+ 'home' => is_home() || is_front_page(),
73
  'front' => is_front_page(),
74
  'single' => is_single(),
75
  'page' => is_page(),
134
 
135
  if ( SSP_Branch::$is_['author'] && SSP_Data::$settings['author_disable'] ) {
136
  wp_safe_redirect($home);
137
+ exit;
138
  }
139
  if ( SSP_Branch::$is_['tax'] && SSP_Data::$settings['post_format_disable'] ) {
140
  if (get_queried_object()->taxonomy === 'post_format') {
141
  wp_safe_redirect($home);
142
+ exit;
143
  };
144
  }
145
  if ( SSP_Branch::$is_['attachment'] && SSP_Data::$settings['media_disable'] ) {
146
  wp_safe_redirect(get_post()->guid);
147
+ exit;
148
  }
149
  }
150
 
class/ssp_output.php CHANGED
@@ -41,7 +41,32 @@ class SSP_Output {
41
  /**
42
  * @var string The canonical holder.
43
  */
44
- private static $ogp_tags;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
 
47
  /**
@@ -50,9 +75,12 @@ class SSP_Output {
50
  */
51
  public static function main() {
52
 
53
- echo "\n<!-- SEO SIMPLE PACK ", SSP_VERSION, " -->\n";
54
  self::generate_metas();
 
 
 
55
  self::output_metas();
 
56
  self::output_codes();
57
  echo "<!-- / SEO SIMPLE PACK -->\n";
58
 
@@ -60,28 +88,26 @@ class SSP_Output {
60
 
61
 
62
  /**
63
- * Output the meta tags
64
  *
65
  */
66
  private static function generate_metas() {
67
 
68
- $is_ = SSP_Branch::$is_;
69
  self::$obj = get_queried_object();
70
- self::$title = self::generate_title( $is_ );
71
- self::$robots = self::generate_robots( $is_ );
72
- self::$keyword = self::generate_keyword( $is_ );
73
- self::$description = self::generate_description( $is_ );
74
- self::$canonical = self::generate_canonical($is_ );
75
- self::$ogp_tags = self::generate_ogp( $is_ );
76
 
77
  }
78
 
79
  /**
80
- * Output the meta tags
81
  */
82
  private static function output_metas() {
83
 
84
-
85
  if ( !empty( self::$title ) ) {
86
  echo '<title>', esc_html( self::$title ), '</title>', "\n";
87
  }
@@ -102,13 +128,61 @@ class SSP_Output {
102
  echo '<link rel="canonical" href="', esc_attr( self::$canonical ), '">', "\n";
103
  }
104
 
105
- if ( !empty( self::$ogp_tags ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
- echo self::$ogp_tags;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
 
109
  }
110
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
 
@@ -116,7 +190,7 @@ class SSP_Output {
116
  * Generate the title tag for the current page.
117
  *
118
  * @param array $is_ : Results of Conditional tags.
119
- * @return string : The title (escaped).
120
  */
121
  private static function generate_title( $is_ ) {
122
 
@@ -127,9 +201,13 @@ class SSP_Output {
127
  break;
128
 
129
  case $is_[ 'singular' ] :
130
-
131
- $pt = self::$obj->post_type;
132
- $title = SSP_Data::$settings[ $pt.'_title' ];
 
 
 
 
133
  break;
134
 
135
  case $is_[ 'category' ] :
@@ -179,7 +257,8 @@ class SSP_Output {
179
  }
180
 
181
  $title = self::replace_snippets( $title );
182
- return $title;
 
183
  }
184
 
185
  /**
@@ -191,80 +270,85 @@ class SSP_Output {
191
  private static function generate_robots( $is_ ) {
192
 
193
  switch ( true ) {
 
194
  case $is_[ 'home' ]:
195
 
196
- return "";
197
  break;
198
 
199
  case $is_[ 'singular' ] :
200
 
201
- $pt = self::$obj->post_type;
202
- $is_noindex = SSP_Data::$settings[ $pt.'_noindex' ];
203
- $metabox_robots = get_post_meta(self::$obj->ID, SSP_MetaBox::METANAME['noindex'], true);
204
-
205
- if ( $metabox_robots === "1" ) {
206
- $is_noindex = !$is_noindex; //noindex反転
 
207
  }
208
-
209
  break;
210
 
211
  case $is_[ 'category' ] :
212
 
213
- $is_noindex = SSP_Data::$settings[ 'cat_noindex' ];
 
214
  break;
215
 
216
  case $is_[ 'tag' ] :
217
 
218
- $is_noindex = SSP_Data::$settings[ 'tag_noindex' ];
 
219
  break;
220
 
221
  case $is_[ 'tax' ] :
222
 
223
  $term = self::$obj->taxonomy;
224
- $is_noindex = SSP_Data::$settings[ $term.'_noindex' ];
 
225
  break;
226
 
227
  case $is_[ 'pt_archive' ] :
228
 
229
- $is_noindex = SSP_Data::$settings[ 'pt_archive_noindex' ];
 
230
  break;
231
 
232
  case $is_[ 'author' ] :
233
 
234
- $is_noindex = SSP_Data::$settings[ 'author_noindex' ];
 
235
  break;
236
 
237
  case $is_[ 'date' ] :
238
 
239
- $is_noindex = SSP_Data::$settings[ 'date_noindex' ];
 
240
  break;
241
 
242
  case $is_[ 'search' ] :
243
 
244
- $is_noindex = true;
245
  break;
246
 
247
  case $is_[ '404' ] :
248
 
249
- $is_noindex = true;
250
  break;
251
 
252
  default :
253
- return "";
254
  break;
255
  }
256
- if ( $is_noindex ) {
257
- return 'noindex,follow';
258
- }
259
 
260
- return "";
 
261
  }
262
 
263
  /**
264
  * Generate the meta:keyword for the current page.
265
  *
266
  * @param array $is_ : Results of Conditional tags.
267
- * @return string : The meta:keyword (escaped).
268
  */
269
  private static function generate_keyword( $is_ ) {
270
 
@@ -279,7 +363,8 @@ class SSP_Output {
279
  }
280
 
281
  }
282
- return $keyword;
 
283
 
284
  }
285
 
@@ -289,7 +374,7 @@ class SSP_Output {
289
  *
290
 
291
  * @param array $is_ : Results of Conditional tags.
292
- * @return string : The meta:description (escaped).
293
  */
294
  private static function generate_description( $is_ ) {
295
 
@@ -308,39 +393,39 @@ class SSP_Output {
308
  $description = $metabox_desc;
309
  } else {
310
  $pt = self::$obj->post_type;
311
- $description = SSP_Data::$settings[ $pt.'_desc' ];
312
  }
313
  break;
314
 
315
  case $is_[ 'category' ] :
316
 
317
- $description = SSP_Data::$settings[ 'cat_desc' ];
318
  break;
319
 
320
  case $is_[ 'tag' ] :
321
 
322
- $description = SSP_Data::$settings[ 'tag_desc' ];
323
  break;
324
 
325
  case $is_[ 'tax' ] :
326
 
327
  $term = self::$obj->taxonomy;
328
- $description = SSP_Data::$settings[ $term.'_desc' ];
329
  break;
330
 
331
  case $is_[ 'pt_archive' ] :
332
 
333
- $description = SSP_Data::$settings[ 'pt_archive_desc' ];
334
  break;
335
 
336
  case $is_[ 'author' ] :
337
 
338
- $description = SSP_Data::$settings[ 'author_desc' ];
339
  break;
340
 
341
  case $is_[ 'date' ] :
342
 
343
- $description = SSP_Data::$settings[ 'date_desc' ];
344
  break;
345
 
346
  default :
@@ -349,81 +434,33 @@ class SSP_Output {
349
  }
350
 
351
  $description = self::replace_snippets( $description );
352
- return $description;
353
 
354
  }
355
 
356
 
357
  /**
358
- * Generate the og tags for the current page.
359
  *
360
- * @param array $is_ : Results of Conditional tags.
361
  * @return string : OGP tags.
362
  */
363
- private static function generate_ogp( $is_ ) {
364
-
365
- $og_locale = ( get_locale() === 'ja') ? 'ja_JP' : get_locale();
366
  $og_title = self::$title;
367
- $og_desc = self::$description;
368
- $og_url = self::$canonical;
369
- $og_type = 'website';
370
- $og_img = SSP_Data::$ogp[ 'og_image' ];
371
-
372
-
373
- if ( $is_[ 'singular' ] ) {
374
-
375
- $og_title = self::$obj->post_title;
376
- $og_type = 'article';
377
 
378
- if ( has_post_thumbnail( self::$obj->ID ) ) {
379
- //アイキャッチ画像のurlを取得
380
- $thumb_id = get_post_thumbnail_id( self::$obj->ID );
381
- $thumb_url = wp_get_attachment_image_src( $thumb_id, 'full' );
382
- $og_img = $thumb_url[0];
383
- }
384
-
385
- if( $is_['attachment'] ) {
386
- $og_img = self::$obj->guid;
387
- }
388
- }
389
  $ogp = "";
390
- $ogp .= '<meta property="og:locale" content="'.esc_attr( $og_locale ).'">'."\n";
391
- $ogp .= '<meta property="og:type" content="'.esc_attr( $og_type ).'">'."\n";
392
  $ogp .= '<meta property="og:title" content="'.esc_attr( $og_title ).'">'."\n";
393
  $ogp .= '<meta property="og:description" content="'.esc_attr( $og_desc ).'">'."\n";
394
  $ogp .= '<meta property="og:url" content="'.esc_attr( $og_url ).'">'."\n";
395
  $ogp .= '<meta property="og:site_name" content="'.esc_attr( SSP_Data::$site_title ).'">'."\n";
396
-
397
- if ($og_img) {
398
- $ogp .= '<meta property="og:image" content="'.esc_url( $og_img ).'">'."\n";
399
- }
400
-
401
- if ( SSP_Data::$ogp[ 'fb_active' ] ) {
402
-
403
- $appid = SSP_Data::$ogp[ 'fb_app_id' ];
404
- $admins = SSP_Data::$ogp[ 'fb_admins' ];
405
- $publisher = SSP_Data::$ogp[ 'fb_url' ];
406
 
407
- if( !empty( $appid )) {
408
- $ogp .= '<meta property="fb:app_id" content="'.esc_attr( $appid ).'">'."\n";
409
- }
410
- if ( !empty( $admins )) {
411
- $ogp .= '<meta property="fb:admins" content="'.esc_attr( $admins ).'">'."\n";
412
- }
413
- if ( $is_[ 'singular' ] && !empty( $publisher ) ) {
414
- $ogp .= '<meta property="article:publisher" content="'.esc_attr( $publisher ).'">'."\n";
415
- }
416
-
417
- }
418
- if ( SSP_Data::$ogp[ 'tw_active' ] ) {
419
-
420
- $tw_account = SSP_Data::$ogp[ 'tw_account' ];
421
-
422
- $ogp .= '<meta name="twitter:card" content="'.esc_attr( SSP_Data::$ogp[ 'tw_card' ] ).'">'."\n";
423
- if( !empty( $tw_account ) ) {
424
- $ogp .= '<meta name="twitter:site" content="'.esc_attr( $tw_account ).'">'."\n";
425
- }
426
- }
427
 
428
  return $ogp;
429
 
@@ -434,7 +471,7 @@ class SSP_Output {
434
  * Generate the canonical URL for the current page.
435
  *
436
  * @param array $is_ : Results of Conditional tags.
437
- * @return string : The canonical URL (escaped).
438
  */
439
  private static function generate_canonical( $is_ ) {
440
 
@@ -499,12 +536,302 @@ class SSP_Output {
499
  break;
500
  }
501
 
502
- return esc_url( $canonical );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  }
504
 
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  /**
507
  * Analytics and Webmaster code.
 
 
508
  */
509
  private static function output_codes() {
510
 
41
  /**
42
  * @var string The canonical holder.
43
  */
44
+ private static $og_tags;
45
+
46
+ /**
47
+ * @var string The og:locale holder.
48
+ */
49
+ private static $og_locale;
50
+
51
+ /**
52
+ * @var string The og:type holder.
53
+ */
54
+ private static $og_type;
55
+
56
+ /**
57
+ * @var string The og:image holder.
58
+ */
59
+ private static $og_image;
60
+
61
+ /**
62
+ * @var string The og:facebook holder.
63
+ */
64
+ private static $og_facebook;
65
+
66
+ /**
67
+ * @var string The og:twitter holder.
68
+ */
69
+ private static $og_twitter;
70
 
71
 
72
  /**
75
  */
76
  public static function main() {
77
 
 
78
  self::generate_metas();
79
+ self::generate_og_metas();
80
+
81
+ echo "\n<!-- SEO SIMPLE PACK ", SSP_VERSION, " -->\n";
82
  self::output_metas();
83
+ self::output_og_metas();
84
  self::output_codes();
85
  echo "<!-- / SEO SIMPLE PACK -->\n";
86
 
88
 
89
 
90
  /**
91
+ * Generate meta tags
92
  *
93
  */
94
  private static function generate_metas() {
95
 
 
96
  self::$obj = get_queried_object();
97
+ self::$title = self::generate_title( SSP_Branch::$is_ );
98
+ self::$robots = self::generate_robots( SSP_Branch::$is_ );
99
+ self::$keyword = self::generate_keyword( SSP_Branch::$is_ );
100
+ self::$description = self::generate_description( SSP_Branch::$is_ );
101
+ self::$canonical = self::generate_canonical(SSP_Branch::$is_ );
 
102
 
103
  }
104
 
105
  /**
106
+ * Output meta tags
107
  */
108
  private static function output_metas() {
109
 
110
+
111
  if ( !empty( self::$title ) ) {
112
  echo '<title>', esc_html( self::$title ), '</title>', "\n";
113
  }
128
  echo '<link rel="canonical" href="', esc_attr( self::$canonical ), '">', "\n";
129
  }
130
 
131
+ }
132
+
133
+
134
+ /**
135
+ * Generate ogp tags
136
+ *
137
+ */
138
+ private static function generate_og_metas() {
139
+
140
+ self::$og_locale = self::generate_og_locale();
141
+ self::$og_type = self::generate_og_type();
142
+ self::$og_image = self::generate_og_image();
143
+ self::$og_facebook = self::generate_og_facebook();
144
+ self::$og_twitter = self::generate_og_twitter();
145
+ self::$og_tags = self::generate_general_ogp( );
146
+
147
+ }
148
+
149
 
150
+ /**
151
+ * Output ogp tags
152
+ */
153
+ private static function output_og_metas() {
154
+
155
+ if ( !empty( self::$og_locale ) ) {
156
+
157
+ echo '<meta property="og:locale" content="'.esc_attr( self::$og_locale ).'">'."\n";
158
+
159
+ }
160
+
161
+ if ( !empty( self::$og_type ) ) {
162
+
163
+ echo '<meta property="og:type" content="'.esc_attr( self::$og_type ).'">'."\n";
164
+
165
+ }
166
 
167
+ if ( !empty( self::$og_image ) ) {
168
+ echo '<meta property="og:image" content="'.esc_url( self::$og_image ).'">'."\n";
169
  }
170
 
171
 
172
+ if ( !empty( self::$og_tags ) ) {
173
+
174
+ echo self::$og_tags;
175
+
176
+ }
177
+
178
+ if ( !empty( self::$og_facebook ) ) {
179
+ echo self::$og_facebook."\n";
180
+ }
181
+
182
+ if ( !empty( self::$og_twitter ) ) {
183
+ echo self::$og_twitter."\n";
184
+ }
185
+
186
  }
187
 
188
 
190
  * Generate the title tag for the current page.
191
  *
192
  * @param array $is_ : Results of Conditional tags.
193
+ * @return string : The title.
194
  */
195
  private static function generate_title( $is_ ) {
196
 
201
  break;
202
 
203
  case $is_[ 'singular' ] :
204
+ $metabox_title = get_post_meta(self::$obj->ID, SSP_MetaBox::METANAME['title'], true);
205
+ if ( $metabox_title ) {
206
+ $title = $metabox_title;
207
+ } else {
208
+ $pt = self::$obj->post_type;
209
+ $title = SSP_Data::$settings[ $pt.'_title' ];
210
+ }
211
  break;
212
 
213
  case $is_[ 'category' ] :
257
  }
258
 
259
  $title = self::replace_snippets( $title );
260
+
261
+ return apply_filters( 'ssp_output_title', $title );
262
  }
263
 
264
  /**
270
  private static function generate_robots( $is_ ) {
271
 
272
  switch ( true ) {
273
+
274
  case $is_[ 'home' ]:
275
 
276
+ $robots = "";
277
  break;
278
 
279
  case $is_[ 'singular' ] :
280
 
281
+ $metabox_robots = get_post_meta(self::$obj->ID, SSP_MetaBox::METANAME['robots'], true);
282
+ if ( $metabox_robots ) {
283
+ $robots = $metabox_robots;
284
+ } else {
285
+ $pt = self::$obj->post_type;
286
+ $is_noindex = SSP_Data::$settings[ $pt.'_noindex' ];
287
+ $robots = $is_noindex ? 'noindex,follow' : "";
288
  }
 
289
  break;
290
 
291
  case $is_[ 'category' ] :
292
 
293
+ $is_noindex = SSP_Data::$settings[ 'cat_noindex' ];
294
+ $robots = $is_noindex ? 'noindex,follow' : "";
295
  break;
296
 
297
  case $is_[ 'tag' ] :
298
 
299
+ $is_noindex = SSP_Data::$settings[ 'tag_noindex' ];
300
+ $robots = $is_noindex ? 'noindex,follow' : "";
301
  break;
302
 
303
  case $is_[ 'tax' ] :
304
 
305
  $term = self::$obj->taxonomy;
306
+ $is_noindex = SSP_Data::$settings[ $term.'_noindex' ];
307
+ $robots = $is_noindex ? 'noindex,follow' : "";
308
  break;
309
 
310
  case $is_[ 'pt_archive' ] :
311
 
312
+ $is_noindex = SSP_Data::$settings[ 'pt_archive_noindex' ];
313
+ $robots = $is_noindex ? 'noindex,follow' : "";
314
  break;
315
 
316
  case $is_[ 'author' ] :
317
 
318
+ $is_noindex = SSP_Data::$settings[ 'author_noindex' ];
319
+ $robots = $is_noindex ? 'noindex,follow' : "";
320
  break;
321
 
322
  case $is_[ 'date' ] :
323
 
324
+ $is_noindex = SSP_Data::$settings[ 'date_noindex' ];
325
+ $robots = $is_noindex ? 'noindex,follow' : "";
326
  break;
327
 
328
  case $is_[ 'search' ] :
329
 
330
+ $robots = 'noindex,follow';
331
  break;
332
 
333
  case $is_[ '404' ] :
334
 
335
+ $robots = 'noindex,follow';
336
  break;
337
 
338
  default :
339
+ $robots = "";
340
  break;
341
  }
 
 
 
342
 
343
+
344
+ return apply_filters( 'ssp_output_robots', $robots );
345
  }
346
 
347
  /**
348
  * Generate the meta:keyword for the current page.
349
  *
350
  * @param array $is_ : Results of Conditional tags.
351
+ * @return string : The meta:keyword.
352
  */
353
  private static function generate_keyword( $is_ ) {
354
 
363
  }
364
 
365
  }
366
+
367
+ return apply_filters( 'ssp_output_keyword', $keyword );
368
 
369
  }
370
 
374
  *
375
 
376
  * @param array $is_ : Results of Conditional tags.
377
+ * @return string : The meta:description.
378
  */
379
  private static function generate_description( $is_ ) {
380
 
393
  $description = $metabox_desc;
394
  } else {
395
  $pt = self::$obj->post_type;
396
+ $description = SSP_Data::$settings[ $pt.'_desc' ];
397
  }
398
  break;
399
 
400
  case $is_[ 'category' ] :
401
 
402
+ $description = SSP_Data::$settings[ 'cat_desc' ];
403
  break;
404
 
405
  case $is_[ 'tag' ] :
406
 
407
+ $description = SSP_Data::$settings[ 'tag_desc' ];
408
  break;
409
 
410
  case $is_[ 'tax' ] :
411
 
412
  $term = self::$obj->taxonomy;
413
+ $description = SSP_Data::$settings[ $term.'_desc' ];
414
  break;
415
 
416
  case $is_[ 'pt_archive' ] :
417
 
418
+ $description = SSP_Data::$settings[ 'pt_archive_desc' ];
419
  break;
420
 
421
  case $is_[ 'author' ] :
422
 
423
+ $description = SSP_Data::$settings[ 'author_desc' ];
424
  break;
425
 
426
  case $is_[ 'date' ] :
427
 
428
+ $description = SSP_Data::$settings[ 'date_desc' ];
429
  break;
430
 
431
  default :
434
  }
435
 
436
  $description = self::replace_snippets( $description );
437
+ return apply_filters( 'ssp_output_description', $description );
438
 
439
  }
440
 
441
 
442
  /**
443
+ * Generate the general ogp tags for the current page.
444
  *
 
445
  * @return string : OGP tags.
446
  */
447
+ private static function generate_general_ogp( ) {
448
+ //SSP_Branch::$is_
 
449
  $og_title = self::$title;
450
+ $og_desc = apply_filters('ssp_output_og_description', self::$description );
451
+ $og_url = apply_filters('ssp_output_og_url', self::$canonical );
 
 
 
 
 
 
 
 
452
 
453
+ // if ( $is_[ 'singular' ] ) //
454
+ // $og_title = self::$obj->post_title;
455
+ // }
 
 
 
 
 
 
 
 
456
  $ogp = "";
457
+
458
+
459
  $ogp .= '<meta property="og:title" content="'.esc_attr( $og_title ).'">'."\n";
460
  $ogp .= '<meta property="og:description" content="'.esc_attr( $og_desc ).'">'."\n";
461
  $ogp .= '<meta property="og:url" content="'.esc_attr( $og_url ).'">'."\n";
462
  $ogp .= '<meta property="og:site_name" content="'.esc_attr( SSP_Data::$site_title ).'">'."\n";
 
 
 
 
 
 
 
 
 
 
463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
 
465
  return $ogp;
466
 
471
  * Generate the canonical URL for the current page.
472
  *
473
  * @param array $is_ : Results of Conditional tags.
474
+ * @return string : The canonical URL.
475
  */
476
  private static function generate_canonical( $is_ ) {
477
 
536
  break;
537
  }
538
 
539
+ return apply_filters( 'ssp_output_canonical', $canonical );
540
+ }
541
+
542
+
543
+ /**
544
+ * Generate the og:type for the current page.
545
+ *
546
+ * @return string : The og:type.
547
+ */
548
+ private static function generate_og_type() {
549
+ $og_type = 'website';
550
+ if ( SSP_Branch::$is_[ 'singular' ] ) {
551
+ $og_type = 'article';
552
+ }
553
+ return apply_filters( 'ssp_output_og_type', $og_type );
554
+ }
555
+
556
+ /**
557
+ * Generate the og:image for the current page.
558
+ * 投稿ページ:アイキャッチ画像を優先し、なければデフォルトのOG:Image画像
559
+ * メディアページ:自身の画像URL
560
+ *
561
+ * @return string : The og:image url.
562
+ */
563
+ private static function generate_og_image() {
564
+ $og_image = SSP_Data::$ogp[ 'og_image' ];
565
+
566
+ if ( SSP_Branch::$is_[ 'singular' ] ) {
567
+
568
+ if ( has_post_thumbnail( self::$obj->ID ) ) {
569
+ $thumb_id = get_post_thumbnail_id( self::$obj->ID );
570
+ $thumb_url = wp_get_attachment_image_src( $thumb_id, 'full' );
571
+ $og_image = $thumb_url[0];
572
+ }
573
+
574
+ if( SSP_Branch::$is_['attachment'] ) {
575
+ $og_image = self::$obj->guid;
576
+ }
577
+ }
578
+ return apply_filters( 'ssp_output_og_image', $og_image );
579
  }
580
 
581
 
582
+ /**
583
+ * Generate the og:locale for the current page.
584
+ *
585
+ * @return string : The og:locale.
586
+ */
587
+ private static function generate_og_locale() {
588
+
589
+ $locale = get_locale();
590
+
591
+ // Catch some weird locales served out by WP that are not easily doubled up.
592
+ $fix_locales = array(
593
+ 'ca' => 'ca_ES',
594
+ 'en' => 'en_US',
595
+ 'el' => 'el_GR',
596
+ 'et' => 'et_EE',
597
+ 'ja' => 'ja_JP',
598
+ 'sq' => 'sq_AL',
599
+ 'uk' => 'uk_UA',
600
+ 'vi' => 'vi_VN',
601
+ 'zh' => 'zh_CN',
602
+ );
603
+
604
+ if ( isset( $fix_locales[ $locale ] ) ) {
605
+ $locale = $fix_locales[ $locale ];
606
+ }
607
+
608
+ // Convert locales like "es" to "es_ES", in case that works for the given locale (sometimes it does).
609
+ if ( strlen( $locale ) === 2 ) {
610
+ $locale = strtolower( $locale ) . '_' . strtoupper( $locale );
611
+ }
612
+
613
+ // These are the locales FB supports.
614
+ $fb_valid_fb_locales = array(
615
+ 'af_ZA', // Afrikaans.
616
+ 'ak_GH', // Akan.
617
+ 'am_ET', // Amharic.
618
+ 'ar_AR', // Arabic.
619
+ 'as_IN', // Assamese.
620
+ 'ay_BO', // Aymara.
621
+ 'az_AZ', // Azerbaijani.
622
+ 'be_BY', // Belarusian.
623
+ 'bg_BG', // Bulgarian.
624
+ 'bn_IN', // Bengali.
625
+ 'br_FR', // Breton.
626
+ 'bs_BA', // Bosnian.
627
+ 'ca_ES', // Catalan.
628
+ 'cb_IQ', // Sorani Kurdish.
629
+ 'ck_US', // Cherokee.
630
+ 'co_FR', // Corsican.
631
+ 'cs_CZ', // Czech.
632
+ 'cx_PH', // Cebuano.
633
+ 'cy_GB', // Welsh.
634
+ 'da_DK', // Danish.
635
+ 'de_DE', // German.
636
+ 'el_GR', // Greek.
637
+ 'en_GB', // English (UK).
638
+ 'en_IN', // English (India).
639
+ 'en_PI', // English (Pirate).
640
+ 'en_UD', // English (Upside Down).
641
+ 'en_US', // English (US).
642
+ 'eo_EO', // Esperanto.
643
+ 'es_CL', // Spanish (Chile).
644
+ 'es_CO', // Spanish (Colombia).
645
+ 'es_ES', // Spanish (Spain).
646
+ 'es_LA', // Spanish.
647
+ 'es_MX', // Spanish (Mexico).
648
+ 'es_VE', // Spanish (Venezuela).
649
+ 'et_EE', // Estonian.
650
+ 'eu_ES', // Basque.
651
+ 'fa_IR', // Persian.
652
+ 'fb_LT', // Leet Speak.
653
+ 'ff_NG', // Fulah.
654
+ 'fi_FI', // Finnish.
655
+ 'fo_FO', // Faroese.
656
+ 'fr_CA', // French (Canada).
657
+ 'fr_FR', // French (France).
658
+ 'fy_NL', // Frisian.
659
+ 'ga_IE', // Irish.
660
+ 'gl_ES', // Galician.
661
+ 'gn_PY', // Guarani.
662
+ 'gu_IN', // Gujarati.
663
+ 'gx_GR', // Classical Greek.
664
+ 'ha_NG', // Hausa.
665
+ 'he_IL', // Hebrew.
666
+ 'hi_IN', // Hindi.
667
+ 'hr_HR', // Croatian.
668
+ 'hu_HU', // Hungarian.
669
+ 'hy_AM', // Armenian.
670
+ 'id_ID', // Indonesian.
671
+ 'ig_NG', // Igbo.
672
+ 'is_IS', // Icelandic.
673
+ 'it_IT', // Italian.
674
+ 'ja_JP', // Japanese.
675
+ 'ja_KS', // Japanese (Kansai).
676
+ 'jv_ID', // Javanese.
677
+ 'ka_GE', // Georgian.
678
+ 'kk_KZ', // Kazakh.
679
+ 'km_KH', // Khmer.
680
+ 'kn_IN', // Kannada.
681
+ 'ko_KR', // Korean.
682
+ 'ku_TR', // Kurdish (Kurmanji).
683
+ 'ky_KG', // Kyrgyz.
684
+ 'la_VA', // Latin.
685
+ 'lg_UG', // Ganda.
686
+ 'li_NL', // Limburgish.
687
+ 'ln_CD', // Lingala.
688
+ 'lo_LA', // Lao.
689
+ 'lt_LT', // Lithuanian.
690
+ 'lv_LV', // Latvian.
691
+ 'mg_MG', // Malagasy.
692
+ 'mi_NZ', // Maori.
693
+ 'mk_MK', // Macedonian.
694
+ 'ml_IN', // Malayalam.
695
+ 'mn_MN', // Mongolian.
696
+ 'mr_IN', // Marathi.
697
+ 'ms_MY', // Malay.
698
+ 'mt_MT', // Maltese.
699
+ 'my_MM', // Burmese.
700
+ 'nb_NO', // Norwegian (bokmal).
701
+ 'nd_ZW', // Ndebele.
702
+ 'ne_NP', // Nepali.
703
+ 'nl_BE', // Dutch (Belgie).
704
+ 'nl_NL', // Dutch.
705
+ 'nn_NO', // Norwegian (nynorsk).
706
+ 'ny_MW', // Chewa.
707
+ 'or_IN', // Oriya.
708
+ 'pa_IN', // Punjabi.
709
+ 'pl_PL', // Polish.
710
+ 'ps_AF', // Pashto.
711
+ 'pt_BR', // Portuguese (Brazil).
712
+ 'pt_PT', // Portuguese (Portugal).
713
+ 'qu_PE', // Quechua.
714
+ 'rm_CH', // Romansh.
715
+ 'ro_RO', // Romanian.
716
+ 'ru_RU', // Russian.
717
+ 'rw_RW', // Kinyarwanda.
718
+ 'sa_IN', // Sanskrit.
719
+ 'sc_IT', // Sardinian.
720
+ 'se_NO', // Northern Sami.
721
+ 'si_LK', // Sinhala.
722
+ 'sk_SK', // Slovak.
723
+ 'sl_SI', // Slovenian.
724
+ 'sn_ZW', // Shona.
725
+ 'so_SO', // Somali.
726
+ 'sq_AL', // Albanian.
727
+ 'sr_RS', // Serbian.
728
+ 'sv_SE', // Swedish.
729
+ 'sw_KE', // Swahili.
730
+ 'sy_SY', // Syriac.
731
+ 'sz_PL', // Silesian.
732
+ 'ta_IN', // Tamil.
733
+ 'te_IN', // Telugu.
734
+ 'tg_TJ', // Tajik.
735
+ 'th_TH', // Thai.
736
+ 'tk_TM', // Turkmen.
737
+ 'tl_PH', // Filipino.
738
+ 'tl_ST', // Klingon.
739
+ 'tr_TR', // Turkish.
740
+ 'tt_RU', // Tatar.
741
+ 'tz_MA', // Tamazight.
742
+ 'uk_UA', // Ukrainian.
743
+ 'ur_PK', // Urdu.
744
+ 'uz_UZ', // Uzbek.
745
+ 'vi_VN', // Vietnamese.
746
+ 'wo_SN', // Wolof.
747
+ 'xh_ZA', // Xhosa.
748
+ 'yi_DE', // Yiddish.
749
+ 'yo_NG', // Yoruba.
750
+ 'zh_CN', // Simplified Chinese (China).
751
+ 'zh_HK', // Traditional Chinese (Hong Kong).
752
+ 'zh_TW', // Traditional Chinese (Taiwan).
753
+ 'zu_ZA', // Zulu.
754
+ 'zz_TR', // Zazaki.
755
+ );
756
+
757
+ // Check to see if the locale is a valid FB one, if not, use en_US as a fallback.
758
+ if ( ! in_array( $locale, $fb_valid_fb_locales, true ) ) {
759
+ $locale = strtolower( substr( $locale, 0, 2 ) ) . '_' . strtoupper( substr( $locale, 0, 2 ) );
760
+ if ( ! in_array( $locale, $fb_valid_fb_locales, true ) ) {
761
+ $locale = 'en_US';
762
+ }
763
+ }
764
+
765
+ return apply_filters( 'ssp_output_og_locale', $locale );
766
+
767
+ }
768
+
769
+ /**
770
+ * Generate the og tags for facebook. for the current page.
771
+ *
772
+ * @return string : The og tags for facebook.
773
+ */
774
+ private static function generate_og_facebook() {
775
+
776
+ if ( ! SSP_Data::$ogp[ 'fb_active' ] ) {
777
+ return "";
778
+ }
779
+
780
+ $og_fb = "";
781
+
782
+ $appid = apply_filters( 'ssp_output_fb_appid', SSP_Data::$ogp[ 'fb_app_id' ] );
783
+ $admins = apply_filters( 'ssp_output_fb_admins', SSP_Data::$ogp[ 'fb_admins' ] );
784
+ $publisher = apply_filters( 'ssp_output_fb_publisher', SSP_Data::$ogp[ 'fb_url' ] );
785
+
786
+ if( !empty( $appid )) {
787
+ $og_fb .= '<meta property="fb:app_id" content="'.esc_attr( $appid ).'">'."\n";
788
+ }
789
+ if ( !empty( $admins )) {
790
+ $og_fb .= '<meta property="fb:admins" content="'.esc_attr( $admins ).'">'."\n";
791
+ }
792
+ if ( !empty( $publisher ) && self::$og_type === "article") {
793
+ $og_fb .= '<meta property="article:publisher" content="'.esc_attr( $publisher ).'">'."\n";
794
+ }
795
+
796
+ return $og_fb;
797
+
798
+ }
799
+
800
+
801
+ /**
802
+ * Generate the og tags for twitter. for the current page.
803
+ *
804
+ * @return string : The og tags for twitter.
805
+ */
806
+ private static function generate_og_twitter() {
807
+
808
+ if ( ! SSP_Data::$ogp[ 'tw_active' ] ) {
809
+ return "";
810
+ }
811
+
812
+ $og_tw = "";
813
+
814
+ $tw_site = apply_filters( 'ssp_output_tw_site', SSP_Data::$ogp[ 'tw_account' ] );
815
+ $tw_card = apply_filters( 'ssp_output_tw_card', SSP_Data::$ogp[ 'tw_card' ] );
816
+
817
+ if( !empty( $tw_card ) ) {
818
+ $og_tw .= '<meta name="twitter:card" content="'.esc_attr( $tw_card ).'">'."\n";
819
+ }
820
+ if( !empty( $tw_site ) ) {
821
+ $og_tw .= '<meta name="twitter:site" content="'.esc_attr( $tw_site ).'">'."\n";
822
+ }
823
+
824
+ return $og_tw;
825
+ }
826
+
827
+
828
+
829
+
830
+
831
  /**
832
  * Analytics and Webmaster code.
833
+ *
834
+ * @return echo : code.
835
  */
836
  private static function output_codes() {
837
 
inc/parts/tab_ogp.php CHANGED
@@ -17,7 +17,7 @@
17
  if ( SSP_Data::$ogp['og_image'] ) {
18
  echo '<img src="', esc_url( SSP_Data::$ogp['og_image'] ), '" alt="preview">';
19
  } else {
20
- echo '<img src="', plugins_url( 'assets/img/noimg.gif', SSP_FILE ), '" alt="no image">';
21
  }
22
  ?>
23
  </div>
17
  if ( SSP_Data::$ogp['og_image'] ) {
18
  echo '<img src="', esc_url( SSP_Data::$ogp['og_image'] ), '" alt="preview">';
19
  } else {
20
+ echo '<div class="no_image">まだOGP画像が設定されていません。</div>';
21
  }
22
  ?>
23
  </div>
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: looswebstudio
3
  Donate link: https://loos-web-studio.com/
4
  Tags: SEO,meta,analytics,webmaster,simple,japan
5
  Requires at least: 4.6
6
- Tested up to: 4.9.7
7
- Stable tag: 1.0.9
8
- Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -14,17 +14,26 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
  == Description ==
15
 
16
  「SEO SIMPLE PACK」は、日本向けに作られたシンプルなSEOプラグインです。
17
- SEO対策に必須な `title`・`description`タグ や `meta`・`OGP`タグ を簡単に設定・カスタマイズすることができます。
18
 
19
- また、ウェブマスターツールやGoogleアナリティクスのコードも簡単に埋め込むことができます。
20
 
21
  当プラグインの詳細な説明については[ こちらのページ ](https://wemo.tech/1670)をご覧ください。
22
 
 
23
  = インストール・有効化したら =
24
  何もしなくても問題なく動作し、各ページに適切なタグが出力されます。
25
 
26
  しかし、最低でも**ホームのdescriptionタグ**用の設定(初期設定では「キャッチフレーズ」が適用されます)と、**OGP画像**の設定をすることを推奨します。
27
 
 
 
 
 
 
 
 
 
28
  = 初期設定について =
29
  重要なページについてのみ簡単に説明しておきます。詳しくは実際の設定画面をご確認ください。
30
 
@@ -37,25 +46,29 @@ SEO対策に必須な `title`・`description`タグ や `meta`・`OGP`タグ を
37
 
38
  *※「サイト名」および「キャッチフレーズ」とは、WordPressの標準設定の項目で入力している内容です。*
39
 
 
40
  = 設定の編集方法 =
41
  WordPress管理画面の左メニューに「SIMPLE SEO」という項目が追加されているので、クリックしてください。
42
  「一般設定」と「OGP設定」の2種類の管理画面にて、各種設定を行います。
43
 
 
44
  = 一般設定画面 =
45
  サイトの全体的な設定を行います。
46
  投稿ページ・タクソノミーページ・その他アーカイブページなど、各ページ種別ごとに設定が可能です。
47
  投稿ページに関しては、投稿ごとにカスタムフィールドが設置され、個別の設定が可能です。
48
 
 
49
  = OGP設定画面 =
50
  OGP画像の選択や、Facebook・Twitter用の設定をカスタマイズすることができます。
51
 
52
  *※投稿系ページのOGP画像は、アイキャッチ画像が優先されます。*
53
 
54
- = アナリティクスコード =
55
 
 
56
  トラッキングIDを入力している場合、Googleアナリティクスのトラッキングコードを自動挿入します。
57
  新しい`gtag.js`でのコードで埋め込むか、古い`analytics.js`によるコードで埋め込むかを選択できます。
58
 
 
59
  = 投稿・固定ページの個別設定 =
60
  投稿・固定ページ・カスタム投稿では、その投稿の編集ページ内にメタボックスが追加されており、個別で`description`や`robots`の内容を設定することができます。
61
 
@@ -76,9 +89,17 @@ OGP画像の選択や、Facebook・Twitter用の設定をカスタマイズす
76
  wp_head内( `_wp_render_title_tag` )で出力される`title`タグは削除するようにしていますが、`<head>`内に直接書き込んでいる場合は2重になってしまいます。
77
  手書きの`title`タグを削除してお使いください。
78
 
79
- = robotsタグの設定は詳しくできないの? =
 
 
 
 
 
 
 
 
80
 
81
- 現状は、シンプルに公開するかしないか、つまり、robotsタグを挿入せずに公開状態にするか、"noindex,follow"として非公開(インデックスさせない)状態にするかの2択となります。
82
 
83
 
84
  == Screenshots ==
@@ -88,6 +109,12 @@ wp_head内( `_wp_render_title_tag` )で出力される`title`タグは削除す
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
91
  = 1.0.9 =
92
  他プラグインに影響を与える致命的なバグを改善。その他管理画面の微調整、コードの改善
93
 
3
  Donate link: https://loos-web-studio.com/
4
  Tags: SEO,meta,analytics,webmaster,simple,japan
5
  Requires at least: 4.6
6
+ Tested up to: 4.9.8
7
+ Stable tag: 1.1.0
8
+ Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
14
  == Description ==
15
 
16
  「SEO SIMPLE PACK」は、日本向けに作られたシンプルなSEOプラグインです。
17
+ SEO対策に必須な `title`タグや`description`タグ、その他基本的な`meta`・`OGP`タグ を簡単に設定・カスタマイズすることができます。
18
 
19
+ また、ウェブマスターツールやGoogleアナリティクスのコードも、とても簡単に埋め込むことができます。
20
 
21
  当プラグインの詳細な説明については[ こちらのページ ](https://wemo.tech/1670)をご覧ください。
22
 
23
+
24
  = インストール・有効化したら =
25
  何もしなくても問題なく動作し、各ページに適切なタグが出力されます。
26
 
27
  しかし、最低でも**ホームのdescriptionタグ**用の設定(初期設定では「キャッチフレーズ」が適用されます)と、**OGP画像**の設定をすることを推奨します。
28
 
29
+
30
+ = 動作しない時は? =
31
+ 当プラグインはPHPバージョン5.6以降でのみ動作します。
32
+ ご使用のPHPバージョンをご確認ください。
33
+
34
+ *PHPバージョンが問題ないのに動かない場合、お手数ですが[ こちらのページ ](https://wemo.tech/1670)からコメントでお知らせください。*
35
+
36
+
37
  = 初期設定について =
38
  重要なページについてのみ簡単に説明しておきます。詳しくは実際の設定画面をご確認ください。
39
 
46
 
47
  *※「サイト名」および「キャッチフレーズ」とは、WordPressの標準設定の項目で入力している内容です。*
48
 
49
+
50
  = 設定の編集方法 =
51
  WordPress管理画面の左メニューに「SIMPLE SEO」という項目が追加されているので、クリックしてください。
52
  「一般設定」と「OGP設定」の2種類の管理画面にて、各種設定を行います。
53
 
54
+
55
  = 一般設定画面 =
56
  サイトの全体的な設定を行います。
57
  投稿ページ・タクソノミーページ・その他アーカイブページなど、各ページ種別ごとに設定が可能です。
58
  投稿ページに関しては、投稿ごとにカスタムフィールドが設置され、個別の設定が可能です。
59
 
60
+
61
  = OGP設定画面 =
62
  OGP画像の選択や、Facebook・Twitter用の設定をカスタマイズすることができます。
63
 
64
  *※投稿系ページのOGP画像は、アイキャッチ画像が優先されます。*
65
 
 
66
 
67
+ = アナリティクスコード =
68
  トラッキングIDを入力している場合、Googleアナリティクスのトラッキングコードを自動挿入します。
69
  新しい`gtag.js`でのコードで埋め込むか、古い`analytics.js`によるコードで埋め込むかを選択できます。
70
 
71
+
72
  = 投稿・固定ページの個別設定 =
73
  投稿・固定ページ・カスタム投稿では、その投稿の編集ページ内にメタボックスが追加されており、個別で`description`や`robots`の内容を設定することができます。
74
 
89
  wp_head内( `_wp_render_title_tag` )で出力される`title`タグは削除するようにしていますが、`<head>`内に直接書き込んでいる場合は2重になってしまいます。
90
  手書きの`title`タグを削除してお使いください。
91
 
92
+ = 特定のページで出力内容を上書きしたい =
93
+ 出力されるほとんどのタグの出力には`apply_filters`を使用していますので、`add_filter`で上書きが可能です。
94
+ 主なfilter名は以下の通りです。
95
+ ・'ssp_output_title'
96
+ ・'ssp_output_robots'
97
+ ・'ssp_output_description'
98
+ ・'ssp_output_canonical'
99
+ ・'ssp_output_keyword'
100
+ ・ and more...
101
 
102
+ 詳しくは[ こちらのページ ](https://wemo.tech/1670)でご覧ください。
103
 
104
 
105
  == Screenshots ==
109
 
110
  == Changelog ==
111
 
112
+ = 1.1.0 =
113
+ コードの改善 & 機能改善。
114
+ ・主なタグの出力に`apply_filters`を適用し、好きに出力内容を上書きできるようにしました。
115
+ ・個別ページで設定できるrobotsタグについて、より詳細に指定できるようになりました。
116
+ ・PHP5.6より低いバージョンで使用するとシンタックスエラーが出るため、バージョンに関するメッセージを出して動作させないようにしました。
117
+
118
  = 1.0.9 =
119
  他プラグインに影響を与える致命的なバグを改善。その他管理画面の微調整、コードの改善
120
 
seo-simple-pack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SEO SIMPLE PACK
4
  Plugin URI: https://wemo.tech/1670
5
  Description: シンプルなSEOプラグイン。ページ種別・投稿ごとにmetaタグやOGPタグを簡単に設定・カスタマイズできます。
6
- Version: 1.0.9
7
  Author: LOOS WEB STUDIO
8
  Author URI: https://loos-web-studio.com/
9
  License: GPL2
@@ -25,13 +25,32 @@ License: GPL2
25
  */
26
 
27
 
 
 
28
  /**
29
  * add_filterが使えなければ 403 エラーで返す
30
  */
31
  if ( ! function_exists( 'add_filter' ) ) {
32
  header( 'Status: 403 Forbidden' );
33
  header( 'HTTP/1.1 403 Forbidden' );
34
- exit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
37
 
@@ -39,7 +58,7 @@ if ( ! function_exists( 'add_filter' ) ) {
39
  * 定数宣言
40
  */
41
  if ( ! defined( 'SSP_VERSION' ) ) {
42
- define( 'SSP_VERSION', '1.0.9' );
43
  }
44
  if ( ! defined( 'SSP_FILE' ) ) {
45
  define( 'SSP_FILE', __FILE__ );
@@ -57,7 +76,6 @@ if ( ! defined( 'SSP_URL' ) ) {
57
 
58
  /**
59
  * CLASSファイルの読み込み
60
- * オートローダーはあとで考える
61
  */
62
  require_once SSP_PATH . 'class/ssp_data.php';
63
  require_once SSP_PATH . 'class/ssp_branch.php';
@@ -66,15 +84,14 @@ require_once SSP_PATH . 'class/ssp_menu.php';
66
  require_once SSP_PATH . 'class/ssp_methods.php';
67
  require_once SSP_PATH . 'class/ssp_output.php';
68
  require_once SSP_PATH . 'class/ssp_metabox.php';
69
-
70
 
71
  /**
72
  * アクティベーションフック
73
  */
74
- register_activation_hook( SSP_FILE, ['SSP_Methods','plugin_activate'] );
75
- register_deactivation_hook( SSP_FILE, ['SSP_Methods','plugin_deactivate'] );
76
- register_uninstall_hook( SSP_FILE, ['SSP_Methods','plugin_uninstall'] );
77
-
78
 
79
  /**
80
  * SSP Init
3
  Plugin Name: SEO SIMPLE PACK
4
  Plugin URI: https://wemo.tech/1670
5
  Description: シンプルなSEOプラグイン。ページ種別・投稿ごとにmetaタグやOGPタグを簡単に設定・カスタマイズできます。
6
+ Version: 1.1.0
7
  Author: LOOS WEB STUDIO
8
  Author URI: https://loos-web-studio.com/
9
  License: GPL2
25
  */
26
 
27
 
28
+
29
+
30
  /**
31
  * add_filterが使えなければ 403 エラーで返す
32
  */
33
  if ( ! function_exists( 'add_filter' ) ) {
34
  header( 'Status: 403 Forbidden' );
35
  header( 'HTTP/1.1 403 Forbidden' );
36
+ exit;
37
+ }
38
+
39
+ /**
40
+ * PHPバージョン5.6以上のみ使用可能の警告
41
+ */
42
+
43
+ $phpver = phpversion();
44
+ if ( (double) $phpver < 5.6 ) {
45
+ add_action( 'admin_notices', function() { ?>
46
+ <div class="notice notice-error is-dismissible">
47
+ <p>
48
+ <b>[ SEO SIMPLE PACK ]</b><br>
49
+ This Plugin is available in PHP since version 5.6 ! <br> (Your PHP is ver. <?php echo phpversion(); ?> )
50
+ </p>
51
+ </div> <?php
52
+ } );
53
+ return;
54
  }
55
 
56
 
58
  * 定数宣言
59
  */
60
  if ( ! defined( 'SSP_VERSION' ) ) {
61
+ define( 'SSP_VERSION', '1.1.0' );
62
  }
63
  if ( ! defined( 'SSP_FILE' ) ) {
64
  define( 'SSP_FILE', __FILE__ );
76
 
77
  /**
78
  * CLASSファイルの読み込み
 
79
  */
80
  require_once SSP_PATH . 'class/ssp_data.php';
81
  require_once SSP_PATH . 'class/ssp_branch.php';
84
  require_once SSP_PATH . 'class/ssp_methods.php';
85
  require_once SSP_PATH . 'class/ssp_output.php';
86
  require_once SSP_PATH . 'class/ssp_metabox.php';
87
+ require_once SSP_PATH . 'class/ssp_activate.php';
88
 
89
  /**
90
  * アクティベーションフック
91
  */
92
+ register_activation_hook( SSP_FILE, array('SSP_Activate', 'plugin_activate') );
93
+ register_deactivation_hook( SSP_FILE, array('SSP_Activate', 'plugin_deactivate') );
94
+ register_uninstall_hook( SSP_FILE, array('SSP_Activate', 'plugin_uninstall') );
 
95
 
96
  /**
97
  * SSP Init