Version Description
- For Google Analytics, both GA4 and UA can now be set.
- Fixed a bug that prevented page numbers from being displayed in the title tag.
- Fixed a bug regarding canonical for the Page specified in the "Posts page".
Download this release
Release Info
| Developer | looswebstudio |
| Plugin | |
| Version | 3.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 3.0.0 to 3.1.0
- class/data.php +101 -97
- class/output.php +152 -16
- class/{trait/output_helper.php → output_helper.php} +75 -123
- class/update_action.php +80 -0
- inc/page_help.php +4 -0
- inc/tab/top_analytics.php +19 -14
- inc/tab/top_webmaster.php +5 -5
- readme.txt +9 -4
- seo-simple-pack.php +3 -3
class/data.php
CHANGED
|
@@ -20,12 +20,12 @@ class SSP_Data {
|
|
| 20 |
/**
|
| 21 |
* DB[ssp_settings]用変数
|
| 22 |
*/
|
| 23 |
-
public static $settings =
|
| 24 |
|
| 25 |
/**
|
| 26 |
* DB[spp_ogp]用変数
|
| 27 |
*/
|
| 28 |
-
public static $ogp =
|
| 29 |
|
| 30 |
/**
|
| 31 |
* サイト基本情報
|
|
@@ -101,79 +101,70 @@ class SSP_Data {
|
|
| 101 |
$installed_version = get_option( self::DB_NAME['installed'] );
|
| 102 |
|
| 103 |
if ( false === $installed_version ) {
|
| 104 |
-
|
| 105 |
// インストール時に実行する処理
|
| 106 |
self::setup_at_installed();
|
| 107 |
|
| 108 |
} elseif ( SSP_VERSION !== $installed_version ) {
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
self::setup_at_updated( $installed_version );
|
| 112 |
}
|
| 113 |
|
| 114 |
-
//
|
| 115 |
-
self
|
| 116 |
-
self::$site_catch_phrase = esc_html( get_option( 'blogdescription' ) );
|
| 117 |
-
|
| 118 |
-
// 一般設定データ
|
| 119 |
-
$saved_settings = get_option( self::DB_NAME['settings'] ) ?: [];
|
| 120 |
-
self::$settings = array_merge( self::$default_settings, $saved_settings );
|
| 121 |
-
|
| 122 |
-
// OGP設定
|
| 123 |
-
$saved_ogp_settings = get_option( self::DB_NAME['ogp'] ) ?: [];
|
| 124 |
-
self::$ogp = array_merge( self::$default_ogp_settings, $saved_ogp_settings );
|
| 125 |
-
|
| 126 |
}
|
| 127 |
|
|
|
|
| 128 |
/**
|
| 129 |
* デフォルト値をセット
|
| 130 |
*/
|
| 131 |
public static function set_default() {
|
| 132 |
self::$default_settings = [
|
| 133 |
-
'home_title'
|
| 134 |
-
'home_desc'
|
| 135 |
-
'home_keyword'
|
| 136 |
-
'reuse_keyword'
|
| 137 |
-
'separator'
|
| 138 |
-
'webmaster_bing'
|
| 139 |
-
'webmaster_google'
|
| 140 |
-
'webmaster_baidu'
|
| 141 |
-
'webmaster_yandex'
|
| 142 |
-
'google_analytics_type'
|
| 143 |
-
'google_analytics_id'
|
| 144 |
-
'
|
| 145 |
-
'
|
| 146 |
-
'
|
| 147 |
-
'
|
| 148 |
-
'
|
| 149 |
-
'
|
| 150 |
-
'
|
| 151 |
-
'
|
| 152 |
-
'
|
| 153 |
-
'
|
| 154 |
-
'
|
| 155 |
-
'
|
| 156 |
-
'
|
| 157 |
-
'
|
| 158 |
-
'
|
| 159 |
-
'
|
| 160 |
-
'
|
| 161 |
-
'
|
| 162 |
-
'
|
| 163 |
-
'
|
| 164 |
-
'
|
| 165 |
-
'
|
| 166 |
-
'
|
| 167 |
-
'
|
| 168 |
-
'
|
| 169 |
-
'
|
| 170 |
-
'
|
| 171 |
-
'
|
| 172 |
-
'
|
| 173 |
-
'
|
| 174 |
-
'
|
| 175 |
-
'
|
| 176 |
-
'
|
|
|
|
|
|
|
| 177 |
];
|
| 178 |
|
| 179 |
self::$default_ogp_settings = [
|
|
@@ -206,61 +197,74 @@ class SSP_Data {
|
|
| 206 |
];
|
| 207 |
}
|
| 208 |
|
| 209 |
-
|
| 210 |
/**
|
| 211 |
-
*
|
| 212 |
*/
|
| 213 |
-
public static function
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
-
// デフォルト設定を保存
|
| 219 |
-
update_option( self::DB_NAME['settings'], self::$default_settings );
|
| 220 |
-
update_option( self::DB_NAME['ogp'], self::$default_ogp_settings );
|
| 221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
|
|
|
|
| 224 |
/**
|
| 225 |
-
*
|
| 226 |
*/
|
| 227 |
-
public static function
|
| 228 |
|
| 229 |
-
// 現在のバージョン番号を保存
|
| 230 |
update_option( self::DB_NAME['installed'], SSP_VERSION );
|
|
|
|
| 231 |
|
| 232 |
-
//
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
// 特定のバージョンより古いとこからアップデートされた時に処理する
|
| 236 |
-
if ( version_compare( $installed_version, '2.2.7', '<=' ) ) {
|
| 237 |
-
self::clean_meta();
|
| 238 |
-
}
|
| 239 |
}
|
| 240 |
|
| 241 |
|
| 242 |
/**
|
| 243 |
-
*
|
|
|
|
| 244 |
*/
|
| 245 |
-
public static function
|
| 246 |
|
| 247 |
-
|
| 248 |
-
|
| 249 |
|
| 250 |
-
//
|
| 251 |
-
foreach (
|
| 252 |
-
$
|
| 253 |
-
'meta_key' => $meta_key,
|
| 254 |
-
'meta_value' => '',
|
| 255 |
-
] );
|
| 256 |
}
|
| 257 |
|
| 258 |
-
|
| 259 |
-
$wpdb->delete( $wpdb->termmeta, [
|
| 260 |
-
'meta_key' => $meta_key,
|
| 261 |
-
'meta_value' => '',
|
| 262 |
-
] );
|
| 263 |
-
}
|
| 264 |
-
// phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery
|
| 265 |
}
|
| 266 |
}
|
| 20 |
/**
|
| 21 |
* DB[ssp_settings]用変数
|
| 22 |
*/
|
| 23 |
+
public static $settings = null;
|
| 24 |
|
| 25 |
/**
|
| 26 |
* DB[spp_ogp]用変数
|
| 27 |
*/
|
| 28 |
+
public static $ogp = null;
|
| 29 |
|
| 30 |
/**
|
| 31 |
* サイト基本情報
|
| 101 |
$installed_version = get_option( self::DB_NAME['installed'] );
|
| 102 |
|
| 103 |
if ( false === $installed_version ) {
|
|
|
|
| 104 |
// インストール時に実行する処理
|
| 105 |
self::setup_at_installed();
|
| 106 |
|
| 107 |
} elseif ( SSP_VERSION !== $installed_version ) {
|
| 108 |
+
// バージョン更新時に実行する処理
|
| 109 |
+
\LOOS\SSP\Update_Action::setup_at_updated( $installed_version );
|
|
|
|
| 110 |
}
|
| 111 |
|
| 112 |
+
// データセット
|
| 113 |
+
self::setup_data();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
+
|
| 117 |
/**
|
| 118 |
* デフォルト値をセット
|
| 119 |
*/
|
| 120 |
public static function set_default() {
|
| 121 |
self::$default_settings = [
|
| 122 |
+
'home_title' => '%_site_title_% %_sep_% %_tagline_%',
|
| 123 |
+
'home_desc' => '',
|
| 124 |
+
'home_keyword' => '',
|
| 125 |
+
'reuse_keyword' => '1',
|
| 126 |
+
'separator' => 'line',
|
| 127 |
+
'webmaster_bing' => '',
|
| 128 |
+
'webmaster_google' => '',
|
| 129 |
+
'webmaster_baidu' => '',
|
| 130 |
+
'webmaster_yandex' => '',
|
| 131 |
+
// 'google_analytics_type' => 'gtag',
|
| 132 |
+
// 'google_analytics_id' => '',
|
| 133 |
+
'google_g_id' => '',
|
| 134 |
+
'google_ua_id' => '',
|
| 135 |
+
'post_noindex' => false,
|
| 136 |
+
'post_title' => '%_page_title_% %_sep_% %_site_title_%',
|
| 137 |
+
'post_desc' => '%_page_contents_%',
|
| 138 |
+
'page_noindex' => false,
|
| 139 |
+
'page_title' => '%_page_title_% %_sep_% %_site_title_%',
|
| 140 |
+
'page_desc' => '%_page_contents_%',
|
| 141 |
+
'attachment_disable' => true,
|
| 142 |
+
'attachment_noindex' => true,
|
| 143 |
+
'attachment_title' => '%_page_title_% %_sep_% %_site_title_%',
|
| 144 |
+
'attachment_desc' => '%_page_contents_%',
|
| 145 |
+
'cat_noindex' => false,
|
| 146 |
+
'cat_title' => '%_term_name_% %_sep_% %_site_title_%',
|
| 147 |
+
'cat_desc' => '%_term_description_%',
|
| 148 |
+
'tag_noindex' => false,
|
| 149 |
+
'tag_title' => '%_term_name_% %_sep_% %_site_title_%',
|
| 150 |
+
'tag_desc' => '%_term_description_%',
|
| 151 |
+
'post_format_disable' => false,
|
| 152 |
+
'post_format_noindex' => true,
|
| 153 |
+
'post_format_title' => '%_term_name_% %_sep_% %_site_title_%',
|
| 154 |
+
'post_format_desc' => '',
|
| 155 |
+
'author_disable' => false,
|
| 156 |
+
'author_noindex' => true,
|
| 157 |
+
'author_title' => '%_author_name_% %_sep_% %_site_title_%',
|
| 158 |
+
'author_desc' => sprintf( self::$texts['archive_desc'], '%_author_name_%' ),
|
| 159 |
+
'date_noindex' => true,
|
| 160 |
+
'date_title' => '%_date_% %_sep_% %_site_title_%',
|
| 161 |
+
'date_desc' => sprintf( self::$texts['archive_desc'], '%_date_%' ),
|
| 162 |
+
'pt_archive_noindex' => true,
|
| 163 |
+
'pt_archive_title' => '%_post_type_% %_sep_% %_site_title_%',
|
| 164 |
+
'pt_archive_desc' => sprintf( self::$texts['archive_desc'], '%_post_type_%' ),
|
| 165 |
+
'404_title' => '404: ' . __( 'Page not found', 'loos-ssp' ) . ' %_sep_% %_site_title_%',
|
| 166 |
+
'search_title' => __( 'Searched:', 'loos-ssp' ) . ' %_search_phrase_% %_sep_% %_site_title_%',
|
| 167 |
+
'feed_noindex' => false,
|
| 168 |
];
|
| 169 |
|
| 170 |
self::$default_ogp_settings = [
|
| 197 |
];
|
| 198 |
}
|
| 199 |
|
|
|
|
| 200 |
/**
|
| 201 |
+
* データを変数にセット
|
| 202 |
*/
|
| 203 |
+
public static function setup_data() {
|
| 204 |
+
// サイト基本情報取得
|
| 205 |
+
self::$site_title = get_option( 'blogname' );
|
| 206 |
+
self::$site_catch_phrase = get_option( 'blogdescription' );
|
| 207 |
|
| 208 |
+
// 一般設定データ
|
| 209 |
+
$saved_settings = get_option( self::DB_NAME['settings'] ) ?: [];
|
| 210 |
+
self::$settings = $saved_settings;
|
| 211 |
+
// self::$settings = array_merge( self::$default_settings, $saved_settings );
|
| 212 |
+
|
| 213 |
+
// OGP設定
|
| 214 |
+
$saved_ogp_settings = get_option( self::DB_NAME['ogp'] ) ?: [];
|
| 215 |
+
self::$ogp = $saved_ogp_settings;
|
| 216 |
+
// self::$ogp = array_merge( self::$default_ogp_settings, $saved_ogp_settings );
|
| 217 |
+
}
|
| 218 |
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
+
/**
|
| 221 |
+
* 設定値の取得
|
| 222 |
+
*/
|
| 223 |
+
public static function get( $db_name, $key ) {
|
| 224 |
+
if ( 'settings' === $db_name ) {
|
| 225 |
+
$data = self::$settings;
|
| 226 |
+
} elseif ( 'ogp' === $db_name ) {
|
| 227 |
+
$data = self::$ogp;
|
| 228 |
+
} else {
|
| 229 |
+
return;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
if ( isset( $data[ $key ] ) ) {
|
| 233 |
+
return $data[ $key ];
|
| 234 |
+
} else {
|
| 235 |
+
return false;
|
| 236 |
+
}
|
| 237 |
}
|
| 238 |
|
| 239 |
+
|
| 240 |
/**
|
| 241 |
+
* インストール時に実行する処理
|
| 242 |
*/
|
| 243 |
+
public static function setup_at_installed() {
|
| 244 |
|
|
|
|
| 245 |
update_option( self::DB_NAME['installed'], SSP_VERSION );
|
| 246 |
+
// update_option( SSP_Data::DB_NAME[ 'notification' ], 'hide' );
|
| 247 |
|
| 248 |
+
// デフォルト設定を保存
|
| 249 |
+
update_option( self::DB_NAME['settings'], self::$default_settings );
|
| 250 |
+
update_option( self::DB_NAME['ogp'], self::$default_ogp_settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
}
|
| 252 |
|
| 253 |
|
| 254 |
/**
|
| 255 |
+
* 設定保存時の処理ではなく、コードによる更新
|
| 256 |
+
* $db_name: 'settings' or 'ogp'
|
| 257 |
*/
|
| 258 |
+
public static function update_data( $db_name, $new_data, $delete_data = [] ) {
|
| 259 |
|
| 260 |
+
$now_data = get_option( self::DB_NAME[ $db_name ] ) ?: [];
|
| 261 |
+
$new_data = array_merge( $now_data, $new_data );
|
| 262 |
|
| 263 |
+
// 不要になったデータを削除
|
| 264 |
+
foreach ( $delete_data as $key ) {
|
| 265 |
+
if ( isset( $new_data[ $key ] ) ) unset( $new_data[ $key ] );
|
|
|
|
|
|
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
+
update_option( self::DB_NAME[ $db_name ], $new_data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
}
|
| 270 |
}
|
class/output.php
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
<?php
|
| 2 |
-
class SSP_Output {
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* 外部からのインスタンス化を防ぐ
|
|
@@ -143,7 +144,7 @@ class SSP_Output {
|
|
| 143 |
self::$og_site_name = apply_filters( 'ssp_output_og_site_name', SSP_Data::$site_title );
|
| 144 |
|
| 145 |
// Generate other ogp tags
|
| 146 |
-
self::$og_locale = apply_filters( 'ssp_output_og_locale',
|
| 147 |
self::$og_type = self::generate_og_type();
|
| 148 |
self::$og_image = self::generate_og_image();
|
| 149 |
|
|
@@ -558,7 +559,7 @@ class SSP_Output {
|
|
| 558 |
if ( ! isset( self::$obj->ID ) ) break;
|
| 559 |
|
| 560 |
$meta_canonical = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['canonical'], true );
|
| 561 |
-
$canonical = $meta_canonical ?: get_permalink();
|
| 562 |
break;
|
| 563 |
|
| 564 |
case is_search():
|
|
@@ -699,9 +700,6 @@ class SSP_Output {
|
|
| 699 |
* Analytics and Webmaster code.
|
| 700 |
*/
|
| 701 |
private static function output_codes() {
|
| 702 |
-
|
| 703 |
-
$settings = SSP_Data::$settings;
|
| 704 |
-
|
| 705 |
// meta tags for webmaster tools
|
| 706 |
if ( is_front_page() ) {
|
| 707 |
$webmaster_codes = [
|
|
@@ -711,26 +709,164 @@ class SSP_Output {
|
|
| 711 |
'webmaster_yandex' => 'yandex-verification',
|
| 712 |
];
|
| 713 |
foreach ( $webmaster_codes as $key => $name ) {
|
| 714 |
-
|
| 715 |
-
|
|
|
|
| 716 |
}
|
| 717 |
}
|
| 718 |
}
|
| 719 |
|
| 720 |
-
//
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
| 722 |
|
| 723 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
|
| 725 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 726 |
|
| 727 |
-
self::echo_gtag( $gaid );
|
| 728 |
|
| 729 |
-
|
|
|
|
|
|
|
|
|
|
| 730 |
|
| 731 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 732 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 735 |
}
|
|
|
|
| 736 |
}
|
| 1 |
<?php
|
|
|
|
| 2 |
|
| 3 |
+
use \LOOS\SSP\Output_Helper;
|
| 4 |
+
|
| 5 |
+
class SSP_Output {
|
| 6 |
|
| 7 |
/**
|
| 8 |
* 外部からのインスタンス化を防ぐ
|
| 144 |
self::$og_site_name = apply_filters( 'ssp_output_og_site_name', SSP_Data::$site_title );
|
| 145 |
|
| 146 |
// Generate other ogp tags
|
| 147 |
+
self::$og_locale = apply_filters( 'ssp_output_og_locale', Output_Helper::get_valid_og_locale() );
|
| 148 |
self::$og_type = self::generate_og_type();
|
| 149 |
self::$og_image = self::generate_og_image();
|
| 150 |
|
| 559 |
if ( ! isset( self::$obj->ID ) ) break;
|
| 560 |
|
| 561 |
$meta_canonical = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['canonical'], true );
|
| 562 |
+
$canonical = $meta_canonical ?: get_permalink( self::$obj->ID );
|
| 563 |
break;
|
| 564 |
|
| 565 |
case is_search():
|
| 700 |
* Analytics and Webmaster code.
|
| 701 |
*/
|
| 702 |
private static function output_codes() {
|
|
|
|
|
|
|
|
|
|
| 703 |
// meta tags for webmaster tools
|
| 704 |
if ( is_front_page() ) {
|
| 705 |
$webmaster_codes = [
|
| 709 |
'webmaster_yandex' => 'yandex-verification',
|
| 710 |
];
|
| 711 |
foreach ( $webmaster_codes as $key => $name ) {
|
| 712 |
+
$content = SSP_Data::get( 'settings', $key );
|
| 713 |
+
if ( $content ) {
|
| 714 |
+
echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $content ) . '">' . PHP_EOL;
|
| 715 |
}
|
| 716 |
}
|
| 717 |
}
|
| 718 |
|
| 719 |
+
// Google analytics - GA4
|
| 720 |
+
$g_id = SSP_Data::get( 'settings', 'google_g_id' );
|
| 721 |
+
if ( $g_id ) {
|
| 722 |
+
Output_Helper::output_gtag( $g_id );
|
| 723 |
+
}
|
| 724 |
|
| 725 |
+
// Google analytics - UA
|
| 726 |
+
$ua_id = SSP_Data::get( 'settings', 'google_ua_id' );
|
| 727 |
+
if ( $ua_id ) {
|
| 728 |
+
Output_Helper::output_uatag( $ua_id );
|
| 729 |
+
}
|
| 730 |
|
| 731 |
+
// アップデート時に無事にデータ移行できてれば不要だが、念の為残す ?
|
| 732 |
+
// $ga_id = SSP_Data::get( 'settings', 'google_analytics_id' );
|
| 733 |
+
// if ( $ga_id ) {
|
| 734 |
+
// $ga_type = SSP_Data::get( 'settings', 'google_analytics_type' );
|
| 735 |
+
// if ( 'gtag' === $ga_type ) {
|
| 736 |
+
// Output_Helper::output_gtag( $ga_id );
|
| 737 |
+
// } elseif ( 'analytics' === $ga_type ) {
|
| 738 |
+
// Output_Helper::output_uatag( $ga_id );
|
| 739 |
+
// }
|
| 740 |
+
// }
|
| 741 |
+
}
|
| 742 |
|
|
|
|
| 743 |
|
| 744 |
+
/**
|
| 745 |
+
* Replace snippets
|
| 746 |
+
*/
|
| 747 |
+
public static function replace_snippets( $str, $context = '' ) {
|
| 748 |
|
| 749 |
+
$obj = self::$obj;
|
| 750 |
+
$obj_type = self::$obj_type;
|
| 751 |
+
$separator = \SSP_Data::SEPARATORS[ \SSP_Data::$settings['separator'] ];
|
| 752 |
+
|
| 753 |
+
// タイトルにページ数を追加する ( %_page_% の位置が明示的に示されていなければ )
|
| 754 |
+
if ( 'title' === $context && false === strpos( $str, '%_page_%' ) ) {
|
| 755 |
+
$str = Output_Helper::add_page_num_to_title( $str, $separator );
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
// get snippets
|
| 759 |
+
$snipets = preg_match_all( '/%_([^%]+)_%/', $str, $matched, PREG_SET_ORDER );
|
| 760 |
+
if ( ! $snipets ) return $str;
|
| 761 |
+
|
| 762 |
+
// replace each snippets
|
| 763 |
+
foreach ( $matched as $snipet ) {
|
| 764 |
+
$snipet_tag = $snipet[0];
|
| 765 |
+
$snipet_name = $snipet[1];
|
| 766 |
+
$replace = '';
|
| 767 |
+
switch ( $snipet_tag ) {
|
| 768 |
+
case '%_site_title_%':
|
| 769 |
+
$replace = \SSP_Data::$site_title;
|
| 770 |
+
break;
|
| 771 |
+
case '%_phrase_%': // old
|
| 772 |
+
case '%_tagline_%':
|
| 773 |
+
$replace = \SSP_Data::$site_catch_phrase;
|
| 774 |
+
break;
|
| 775 |
+
case '%_description_%': // old
|
| 776 |
+
case '%_front_description_%':
|
| 777 |
+
$replace = \SSP_Data::$settings['home_desc'];
|
| 778 |
+
break;
|
| 779 |
+
case '%_search_phrase_%':
|
| 780 |
+
$replace = get_search_query();
|
| 781 |
+
break;
|
| 782 |
+
case '%_post_type_%':
|
| 783 |
+
$replace = post_type_archive_title( '', false );
|
| 784 |
+
break;
|
| 785 |
+
case '%_page_title_%':
|
| 786 |
+
// is_home() を考慮して get_the_title() ではなく single_post_title()
|
| 787 |
+
$replace = single_post_title( '', false );
|
| 788 |
+
break;
|
| 789 |
+
case '%_page_contents_%':
|
| 790 |
+
if ( 'WP_Post' === $obj_type ) {
|
| 791 |
+
$word_count = apply_filters( 'ssp_description_word_count', 120 );
|
| 792 |
+
$content = wp_strip_all_tags( strip_shortcodes( $obj->post_content ), true ); // 改行なども削除
|
| 793 |
+
$replace = mb_substr( $content, 0, $word_count );
|
| 794 |
+
}
|
| 795 |
+
break;
|
| 796 |
+
case '%_term_name_%':
|
| 797 |
+
case '%_cat_name_%': // old
|
| 798 |
+
case '%_tag_name_%': // old
|
| 799 |
+
case '%_format_name_%': // old
|
| 800 |
+
if ( 'WP_Term' === $obj_type ) {
|
| 801 |
+
$replace = $obj->name;
|
| 802 |
+
}
|
| 803 |
+
break;
|
| 804 |
+
case '%_term_description_%':
|
| 805 |
+
if ( 'WP_Term' === $obj_type ) {
|
| 806 |
+
$replace = wp_strip_all_tags( strip_shortcodes( $obj->description ), true ); // 改行なども削除
|
| 807 |
+
}
|
| 808 |
+
break;
|
| 809 |
+
case '%_tax_name_%':
|
| 810 |
+
if ( 'WP_Term' === $obj_type && isset( $obj->taxonomy ) ) {
|
| 811 |
+
$taxonomy_slug = $obj->taxonomy;
|
| 812 |
+
$taxonomy_data = get_taxonomy( $taxonomy_slug );
|
| 813 |
+
$replace = ( $taxonomy_data ) ? $taxonomy_data->label : '';
|
| 814 |
+
}
|
| 815 |
+
break;
|
| 816 |
+
case '%_author_name_%':
|
| 817 |
+
if ( is_author() && 'WP_User' === $obj_type ) {
|
| 818 |
+
$replace = get_user_meta( $obj->ID, 'nickname', true );
|
| 819 |
+
}
|
| 820 |
+
break;
|
| 821 |
+
case '%_sep_%':
|
| 822 |
+
// 区切り文字の置換
|
| 823 |
+
$replace = $separator;
|
| 824 |
+
break;
|
| 825 |
+
case '%_date_%':
|
| 826 |
+
$year = get_query_var( 'year' );
|
| 827 |
+
$monthnum = get_query_var( 'monthnum' );
|
| 828 |
+
$day = get_query_var( 'day' );
|
| 829 |
+
|
| 830 |
+
$month = '';
|
| 831 |
+
if ( $monthnum ) {
|
| 832 |
+
global $wp_locale;
|
| 833 |
+
$month = $wp_locale->get_month( $monthnum );
|
| 834 |
+
}
|
| 835 |
|
| 836 |
+
if ( is_day() ) {
|
| 837 |
+
$replace = sprintf( _x( '%2$s %3$s, %1$s', 'date', 'loos-ssp' ), $year, $month, $day ); // phpcs:ignore
|
| 838 |
+
} elseif ( is_month() ) {
|
| 839 |
+
$replace = sprintf( _x( '%2$s %1$s', 'date', 'loos-ssp' ), $year, $month ); // phpcs:ignore
|
| 840 |
+
} elseif ( is_year() ) {
|
| 841 |
+
$replace = sprintf( _x( '%s', 'date', 'loos-ssp' ), $year ); // phpcs:ignore
|
| 842 |
+
}
|
| 843 |
+
break;
|
| 844 |
+
case '%_page_%':
|
| 845 |
+
$page = Output_Helper::get_paged_text();
|
| 846 |
+
$replace = $page ? "$separator $page" : '';
|
| 847 |
+
break;
|
| 848 |
+
default:
|
| 849 |
+
// その他、SSP側で用意していないスニペットがある時、フィルターで置換できるようにする
|
| 850 |
+
$filter_name = "ssp_replace_snippet_$snipet_name";
|
| 851 |
+
if ( has_filter( $filter_name ) ) {
|
| 852 |
+
$replace = apply_filters( $filter_name, '', $context );
|
| 853 |
+
}
|
| 854 |
+
break;
|
| 855 |
}
|
| 856 |
+
|
| 857 |
+
$str = str_replace( $snipet_tag, $replace, $str );
|
| 858 |
+
} // end foreach
|
| 859 |
+
|
| 860 |
+
// 区切り文字が続いてしまう場合は削除
|
| 861 |
+
if ( 'title' === $context ) {
|
| 862 |
+
$str = str_replace( "$separator $separator", $separator, $str );
|
| 863 |
}
|
| 864 |
+
|
| 865 |
+
// 空白が続いてる場合は1つに
|
| 866 |
+
// $str = str_replace( ' ', ' ', $str );
|
| 867 |
+
|
| 868 |
+
$str = trim( $str );
|
| 869 |
+
return $str;
|
| 870 |
}
|
| 871 |
+
|
| 872 |
}
|
class/{trait/output_helper.php → output_helper.php}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* SSP_Output
|
| 4 |
*/
|
| 5 |
-
namespace SSP;
|
| 6 |
|
| 7 |
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
|
|
|
|
| 8 |
|
| 9 |
-
trait Output_Helper {
|
| 10 |
|
| 11 |
/**
|
| 12 |
* gtagコード出力
|
| 13 |
*/
|
| 14 |
-
public static function
|
| 15 |
-
?>
|
| 16 |
<!-- Google Analytics (gtag.js) -->
|
| 17 |
<script async src="https://www.googletagmanager.com/gtag/js?id=<?=esc_attr( $gaid )?>"></script>
|
| 18 |
<script>
|
|
@@ -21,15 +21,14 @@ trait Output_Helper {
|
|
| 21 |
gtag("js", new Date());
|
| 22 |
gtag("config", "<?=esc_attr( $gaid )?>");
|
| 23 |
</script>
|
| 24 |
-
<?php
|
| 25 |
}
|
| 26 |
|
| 27 |
-
|
| 28 |
/**
|
| 29 |
* 旧アナリティクスコード出力
|
| 30 |
*/
|
| 31 |
-
public static function
|
| 32 |
-
?>
|
| 33 |
<!-- Google Analytics -->
|
| 34 |
<script>
|
| 35 |
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
|
|
@@ -39,7 +38,73 @@ trait Output_Helper {
|
|
| 39 |
ga("create", "<?=esc_attr( $gaid )?>", "auto");
|
| 40 |
ga("send", "pageview");
|
| 41 |
</script>
|
| 42 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
|
|
@@ -222,117 +287,4 @@ trait Output_Helper {
|
|
| 222 |
|
| 223 |
return $locale;
|
| 224 |
}
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
/**
|
| 228 |
-
* Replace snippets
|
| 229 |
-
*/
|
| 230 |
-
private static function replace_snippets( $str, $context = '' ) {
|
| 231 |
-
|
| 232 |
-
$obj = \SSP_Output::$obj;
|
| 233 |
-
$obj_type = \SSP_Output::$obj_type;
|
| 234 |
-
|
| 235 |
-
// get snippets
|
| 236 |
-
$snipets = preg_match_all( '/%_([^%]+)_%/', $str, $matched, PREG_SET_ORDER );
|
| 237 |
-
if ( ! $snipets ) return $str;
|
| 238 |
-
|
| 239 |
-
// replace each snippets
|
| 240 |
-
foreach ( $matched as $snipet ) {
|
| 241 |
-
$snipet_tag = $snipet[0];
|
| 242 |
-
$snipet_name = $snipet[1];
|
| 243 |
-
$replace = '';
|
| 244 |
-
switch ( $snipet_tag ) {
|
| 245 |
-
case '%_site_title_%':
|
| 246 |
-
$replace = \SSP_Data::$site_title;
|
| 247 |
-
break;
|
| 248 |
-
case '%_phrase_%': // old
|
| 249 |
-
case '%_tagline_%':
|
| 250 |
-
$replace = \SSP_Data::$site_catch_phrase;
|
| 251 |
-
break;
|
| 252 |
-
case '%_description_%': // old
|
| 253 |
-
case '%_front_description_%':
|
| 254 |
-
$replace = \SSP_Data::$settings['home_desc'];
|
| 255 |
-
break;
|
| 256 |
-
case '%_search_phrase_%':
|
| 257 |
-
$replace = get_search_query();
|
| 258 |
-
break;
|
| 259 |
-
case '%_post_type_%':
|
| 260 |
-
$replace = post_type_archive_title( '', false );
|
| 261 |
-
break;
|
| 262 |
-
case '%_page_title_%':
|
| 263 |
-
// is_home() を考慮して get_the_title() ではなく single_post_title()
|
| 264 |
-
$replace = single_post_title( '', false );
|
| 265 |
-
break;
|
| 266 |
-
case '%_page_contents_%':
|
| 267 |
-
if ( 'WP_Post' === $obj_type ) {
|
| 268 |
-
$word_count = apply_filters( 'ssp_description_word_count', 120 );
|
| 269 |
-
$content = wp_strip_all_tags( strip_shortcodes( $obj->post_content ), true ); // 改行なども削除
|
| 270 |
-
$replace = mb_substr( $content, 0, $word_count );
|
| 271 |
-
}
|
| 272 |
-
break;
|
| 273 |
-
case '%_term_name_%':
|
| 274 |
-
case '%_cat_name_%': // old
|
| 275 |
-
case '%_tag_name_%': // old
|
| 276 |
-
case '%_format_name_%': // old
|
| 277 |
-
if ( 'WP_Term' === $obj_type ) {
|
| 278 |
-
$replace = $obj->name;
|
| 279 |
-
}
|
| 280 |
-
break;
|
| 281 |
-
case '%_term_description_%':
|
| 282 |
-
if ( 'WP_Term' === $obj_type ) {
|
| 283 |
-
$replace = wp_strip_all_tags( strip_shortcodes( $obj->description ), true ); // 改行なども削除
|
| 284 |
-
}
|
| 285 |
-
break;
|
| 286 |
-
case '%_tax_name_%':
|
| 287 |
-
if ( 'WP_Term' === $obj_type && isset( $obj->taxonomy ) ) {
|
| 288 |
-
$taxonomy_slug = $obj->taxonomy;
|
| 289 |
-
$taxonomy_data = get_taxonomy( $taxonomy_slug );
|
| 290 |
-
$replace = ( $taxonomy_data ) ? $taxonomy_data->label : '';
|
| 291 |
-
}
|
| 292 |
-
break;
|
| 293 |
-
case '%_author_name_%':
|
| 294 |
-
if ( is_author() && 'WP_User' === $obj_type ) {
|
| 295 |
-
$replace = get_user_meta( $obj->ID, 'nickname', true );
|
| 296 |
-
}
|
| 297 |
-
break;
|
| 298 |
-
case '%_sep_%':
|
| 299 |
-
// 区切り文字の置換
|
| 300 |
-
$replace = \SSP_Data::SEPARATORS[ \SSP_Data::$settings['separator'] ];
|
| 301 |
-
break;
|
| 302 |
-
case '%_date_%':
|
| 303 |
-
$year = get_query_var( 'year' );
|
| 304 |
-
$monthnum = get_query_var( 'monthnum' );
|
| 305 |
-
$day = get_query_var( 'day' );
|
| 306 |
-
|
| 307 |
-
$month = '';
|
| 308 |
-
if ( $monthnum ) {
|
| 309 |
-
global $wp_locale;
|
| 310 |
-
$month = $wp_locale->get_month( $monthnum );
|
| 311 |
-
}
|
| 312 |
-
|
| 313 |
-
if ( is_day() ) {
|
| 314 |
-
$replace = sprintf( _x( '%2$s %3$s, %1$s', 'date', 'loos-ssp' ), $year, $month, $day ); // phpcs:ignore
|
| 315 |
-
} elseif ( is_month() ) {
|
| 316 |
-
$replace = sprintf( _x( '%2$s %1$s', 'date', 'loos-ssp' ), $year, $month ); // phpcs:ignore
|
| 317 |
-
} elseif ( is_year() ) {
|
| 318 |
-
$replace = sprintf( _x( '%s', 'date', 'loos-ssp' ), $year ); // phpcs:ignore
|
| 319 |
-
}
|
| 320 |
-
|
| 321 |
-
break;
|
| 322 |
-
default:
|
| 323 |
-
// その他、SSP側で用意していないスニペットがある時、フィルターで置換できるようにする
|
| 324 |
-
$filter_name = "ssp_replace_snippet_$snipet_name";
|
| 325 |
-
if ( has_filter( $filter_name ) ) {
|
| 326 |
-
$replace = apply_filters( $filter_name, '', $context );
|
| 327 |
-
}
|
| 328 |
-
break;
|
| 329 |
-
}
|
| 330 |
-
|
| 331 |
-
$str = str_replace( $snipet_tag, $replace, $str );
|
| 332 |
-
} // end foreach
|
| 333 |
-
|
| 334 |
-
$str = trim( $str );
|
| 335 |
-
return $str;
|
| 336 |
-
}
|
| 337 |
-
|
| 338 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* SSP_Output用のヘルパークラス
|
| 4 |
*/
|
| 5 |
+
namespace LOOS\SSP;
|
| 6 |
|
| 7 |
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
|
| 8 |
+
class Output_Helper {
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
/**
|
| 12 |
* gtagコード出力
|
| 13 |
*/
|
| 14 |
+
public static function output_gtag( $gaid ) {
|
| 15 |
+
?>
|
| 16 |
<!-- Google Analytics (gtag.js) -->
|
| 17 |
<script async src="https://www.googletagmanager.com/gtag/js?id=<?=esc_attr( $gaid )?>"></script>
|
| 18 |
<script>
|
| 21 |
gtag("js", new Date());
|
| 22 |
gtag("config", "<?=esc_attr( $gaid )?>");
|
| 23 |
</script>
|
| 24 |
+
<?php
|
| 25 |
}
|
| 26 |
|
|
|
|
| 27 |
/**
|
| 28 |
* 旧アナリティクスコード出力
|
| 29 |
*/
|
| 30 |
+
public static function output_uatag( $gaid ) {
|
| 31 |
+
?>
|
| 32 |
<!-- Google Analytics -->
|
| 33 |
<script>
|
| 34 |
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
|
| 38 |
ga("create", "<?=esc_attr( $gaid )?>", "auto");
|
| 39 |
ga("send", "pageview");
|
| 40 |
</script>
|
| 41 |
+
<?php
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* page を自動付与
|
| 46 |
+
*/
|
| 47 |
+
public static function add_page_num_to_title( $str, $sep ) {
|
| 48 |
+
$paged = self::get_paged_text() ?: '';
|
| 49 |
+
if ( ! $paged ) return $str;
|
| 50 |
+
|
| 51 |
+
if ( strpos( $str, '%_site_title_%' ) ) {
|
| 52 |
+
// サイトタイトルが先頭以外の場所にある時の前にページ数を表示
|
| 53 |
+
return str_replace( '%_site_title_%', "$paged $sep %_site_title_%", $str );
|
| 54 |
+
} else {
|
| 55 |
+
// サイトタイトルがなければ最後に追加
|
| 56 |
+
return $str . " $sep $paged";
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* get_paged_text
|
| 62 |
+
*/
|
| 63 |
+
public static function get_paged_text() {
|
| 64 |
+
|
| 65 |
+
$nums = self::get_pagenumbers();
|
| 66 |
+
if ( ! $nums ) {
|
| 67 |
+
return '';
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/* translators: 1: current page number, 2: total number of pages. */
|
| 71 |
+
return sprintf( __( 'Page %1$d of %2$d', 'loos-ssp' ), $nums['now'], $nums['max'] );
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
private static function get_pagenumbers() {
|
| 75 |
+
global $wp_query;
|
| 76 |
+
$max_num_pages = 1;
|
| 77 |
+
$now_page_num = 1;
|
| 78 |
+
|
| 79 |
+
// アーカイブにしか効かない
|
| 80 |
+
// $is_paged = $wp_query->is_paged();
|
| 81 |
+
// if ( ! $is_paged ) return false;
|
| 82 |
+
|
| 83 |
+
// 現在のページ番号
|
| 84 |
+
$now_page_num = is_singular() ? get_query_var( 'page' ) : get_query_var( 'paged' );
|
| 85 |
+
if ( 0 === $now_page_num || '' === $now_page_num ) {
|
| 86 |
+
$now_page_num = 1;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// 1ページ目の時
|
| 90 |
+
if ( $now_page_num < 2 ) {
|
| 91 |
+
return false;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
global $post;
|
| 95 |
+
|
| 96 |
+
// 最大のページ番号
|
| 97 |
+
if ( is_singular() && isset( $post->post_content ) ) {
|
| 98 |
+
// 改ページタグをカウント
|
| 99 |
+
$max_num_pages = ( substr_count( $post->post_content, '<!--nextpage-->' ) + 1 );
|
| 100 |
+
} elseif ( ! is_singular() && ! empty( $wp_query->max_num_pages ) ) {
|
| 101 |
+
$max_num_pages = $wp_query->max_num_pages;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
return [
|
| 105 |
+
'now' => $now_page_num,
|
| 106 |
+
'max' => $max_num_pages,
|
| 107 |
+
];
|
| 108 |
}
|
| 109 |
|
| 110 |
|
| 287 |
|
| 288 |
return $locale;
|
| 289 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
}
|
class/update_action.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace LOOS\SSP;
|
| 3 |
+
|
| 4 |
+
class Update_Action extends \SSP_Data {
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* 外部からのインスタンス化を防ぐ
|
| 8 |
+
*/
|
| 9 |
+
private function __construct() {}
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* 更新時に実行する処理
|
| 14 |
+
*/
|
| 15 |
+
public static function setup_at_updated( $installed_version ) {
|
| 16 |
+
// メンバ変数に予めデータセット
|
| 17 |
+
self::setup_data();
|
| 18 |
+
|
| 19 |
+
// 現在のバージョン番号を保存
|
| 20 |
+
update_option( self::DB_NAME['installed'], SSP_VERSION );
|
| 21 |
+
|
| 22 |
+
// バージョンが上がった時だけの処理
|
| 23 |
+
// if (version_compare( SSP_VERSION, $installed_version, '>' ) ) {}
|
| 24 |
+
|
| 25 |
+
// 特定のバージョンより古いとこからアップデートされた時に処理する
|
| 26 |
+
if ( version_compare( $installed_version, '2.2.7', '<=' ) ) {
|
| 27 |
+
self::clean_meta();
|
| 28 |
+
}
|
| 29 |
+
if ( version_compare( $installed_version, '3.0.0', '<=' ) ) {
|
| 30 |
+
self::migrate_ga_data();
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* 不要なメタを削除
|
| 37 |
+
*/
|
| 38 |
+
public static function clean_meta() {
|
| 39 |
+
|
| 40 |
+
// 空のカスタムフィールドを削除
|
| 41 |
+
global $wpdb;
|
| 42 |
+
|
| 43 |
+
// phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery
|
| 44 |
+
foreach ( SSP_MetaBox::POST_META_KEYS as $key => $meta_key ) {
|
| 45 |
+
$wpdb->delete( $wpdb->postmeta, [
|
| 46 |
+
'meta_key' => $meta_key,
|
| 47 |
+
'meta_value' => '',
|
| 48 |
+
] );
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
foreach ( SSP_MetaBox::TERM_META_KEYS as $key => $meta_key ) {
|
| 52 |
+
$wpdb->delete( $wpdb->termmeta, [
|
| 53 |
+
'meta_key' => $meta_key,
|
| 54 |
+
'meta_value' => '',
|
| 55 |
+
] );
|
| 56 |
+
}
|
| 57 |
+
// phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* アナリティクスをUA,GA4両方出力できるように変更するためのデータ置換
|
| 63 |
+
*/
|
| 64 |
+
public static function migrate_ga_data() {
|
| 65 |
+
$old_type = self::get( 'settings', 'google_analytics_type' );
|
| 66 |
+
$old_code = self::get( 'settings', 'google_analytics_id' );
|
| 67 |
+
|
| 68 |
+
if ( ! $old_type || ! $old_code ) return;
|
| 69 |
+
|
| 70 |
+
if ( 'gtag' === $old_type ) {
|
| 71 |
+
$new_code_key = 'google_g_id';
|
| 72 |
+
} elseif ( 'analytics' === $old_type ) {
|
| 73 |
+
$new_code_key = 'google_ua_id';
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
self::update_data( 'settings', [
|
| 77 |
+
"$new_code_key" => $old_code,
|
| 78 |
+
], [ 'google_analytics_type', 'google_analytics_id' ]);
|
| 79 |
+
}
|
| 80 |
+
}
|
inc/page_help.php
CHANGED
|
@@ -55,6 +55,10 @@ $SNIPPET_TAGS = [
|
|
| 55 |
'label' => __( 'Search word', 'loos-ssp' ),
|
| 56 |
'for' => __( 'Search results', 'loos-ssp' ),
|
| 57 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
];
|
| 59 |
|
| 60 |
?>
|
| 55 |
'label' => __( 'Search word', 'loos-ssp' ),
|
| 56 |
'for' => __( 'Search results', 'loos-ssp' ),
|
| 57 |
],
|
| 58 |
+
'page' => [
|
| 59 |
+
'label' => __( 'Number of pages', 'loos-ssp' ),
|
| 60 |
+
'for' => __( 'All pages', 'loos-ssp' ),
|
| 61 |
+
],
|
| 62 |
];
|
| 63 |
|
| 64 |
?>
|
inc/tab/top_analytics.php
CHANGED
|
@@ -2,21 +2,26 @@
|
|
| 2 |
/**
|
| 3 |
* Googleアナリティクス タブ
|
| 4 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
self::output_section( __( 'Google Analytics settings', 'loos-ssp' ), [
|
| 6 |
-
'
|
| 7 |
-
'title'
|
| 8 |
-
'
|
| 9 |
-
'
|
| 10 |
-
'gtag' => __( 'gtag.js', 'loos-ssp' ),
|
| 11 |
-
'analytics' => __( 'analytics.js', 'loos-ssp' ),
|
| 12 |
-
],
|
| 13 |
-
'desc' => '※ ' . __( '<code>gtag.js</code> is recommended unless you have a specific reason.', 'loos-ssp' ),
|
| 14 |
],
|
| 15 |
-
'
|
| 16 |
-
'title' => __( '"Tracking ID"
|
| 17 |
-
'
|
| 18 |
-
|
| 19 |
-
__( 'Tracking ID (<code>UA-XXXX...</code>) or Measurement ID (<code>G-XXX...</code>)', 'loos-ssp' )
|
| 20 |
-
),
|
| 21 |
],
|
| 22 |
] );
|
| 2 |
/**
|
| 3 |
* Googleアナリティクス タブ
|
| 4 |
*/
|
| 5 |
+
$gid_desc = sprintf( SSP_Data::$texts['input'], __( 'Measurement ID (<code>G-XXXX...</code>)', 'loos-ssp' ) ) .
|
| 6 |
+
'(' . __( 'Please include <code>G-</code>.', 'loos-ssp' ) . ')';
|
| 7 |
+
|
| 8 |
+
$uaid_desc = sprintf( SSP_Data::$texts['input'], __( 'Tracking ID (<code>UA-XXXX...</code>)', 'loos-ssp' ) ) .
|
| 9 |
+
'(' . __( 'Please include <code>UA-</code>.', 'loos-ssp' ) . ')' .
|
| 10 |
+
'<br>' . __( 'Note: The UA will be discontinued on July 1, 2023.', 'loos-ssp' );
|
| 11 |
+
|
| 12 |
+
if ( 'ja' === get_locale() ) {
|
| 13 |
+
$gid_desc .= '<br>「測定ID」は、Googleアナリティクスの「管理」(画面左下の歯車アイコン)→ プロパティ列の「データストリーム」→ ストリーム名を選択することで確認できます。';
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
self::output_section( __( 'Google Analytics settings', 'loos-ssp' ), [
|
| 17 |
+
'google_g_id' => [
|
| 18 |
+
'title' => __( '"Measurement ID" for GA4', 'loos-ssp' ),
|
| 19 |
+
'class' => '-wide',
|
| 20 |
+
'desc' => $gid_desc,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
],
|
| 22 |
+
'google_ua_id' => [
|
| 23 |
+
'title' => __( '"Tracking ID" for UA', 'loos-ssp' ),
|
| 24 |
+
'class' => '-wide',
|
| 25 |
+
'desc' => $uaid_desc,
|
|
|
|
|
|
|
| 26 |
],
|
| 27 |
] );
|
inc/tab/top_webmaster.php
CHANGED
|
@@ -15,10 +15,10 @@ foreach ( $settings as $key => $data ) {
|
|
| 15 |
$desc = __( 'Output code ', 'loos-ssp' ) .
|
| 16 |
' : <code><meta name="' . $data[1] . '" content="<b>' . _x( 'Your code', 'input', 'loos-ssp' ) . '</b>"></code>';
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
}
|
| 24 |
self::output_section( __( 'Webmaster Tools Certification Code', 'loos-ssp' ), $section_args );
|
| 15 |
$desc = __( 'Output code ', 'loos-ssp' ) .
|
| 16 |
' : <code><meta name="' . $data[1] . '" content="<b>' . _x( 'Your code', 'input', 'loos-ssp' ) . '</b>"></code>';
|
| 17 |
|
| 18 |
+
$section_args[ $key ] = [
|
| 19 |
+
'title' => sprintf( __( 'Authentication code for %s', 'loos-ssp' ), $data[0] ),
|
| 20 |
+
'desc' => $desc,
|
| 21 |
+
'class' => '-wide -webmaster',
|
| 22 |
+
];
|
| 23 |
}
|
| 24 |
self::output_section( __( 'Webmaster Tools Certification Code', 'loos-ssp' ), $section_args );
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://loos-web-studio.com/
|
|
| 4 |
Tags: SEO, meta, analytics, wsebmaster, simple, japan, meta tag
|
| 5 |
Requires at least: 4.9
|
| 6 |
Tested up to: 6.0
|
| 7 |
-
Stable tag: 3.
|
| 8 |
Requires PHP: 7.0
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -22,16 +22,16 @@ This is a very simple SEO plugin. You can easily set and customize meta tags and
|
|
| 22 |
- The output content of each meta tag can also be rewritten with a hook.
|
| 23 |
- You can easily set the Google Analytics measurement code and Webmaster Tools verification code.
|
| 24 |
|
| 25 |
-
Please see the following page for a detailed explanation of this plugin.
|
| 26 |
|
| 27 |
-
URL: https://
|
| 28 |
|
| 29 |
|
| 30 |
### Source code
|
| 31 |
|
| 32 |
The source code of this plugin is available on Github.
|
| 33 |
|
| 34 |
-
URL: https://github.com/ddryo/SEO-SIMPLE-PACK
|
| 35 |
|
| 36 |
|
| 37 |
### How to use
|
|
@@ -119,6 +119,11 @@ The following hooks are available.
|
|
| 119 |
|
| 120 |
|
| 121 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
= 3.0.0 =
|
| 124 |
- Added `'ssp_replace_snippet_{snippet_name}'` hook. (You can now define custom snippets)
|
| 4 |
Tags: SEO, meta, analytics, wsebmaster, simple, japan, meta tag
|
| 5 |
Requires at least: 4.9
|
| 6 |
Tested up to: 6.0
|
| 7 |
+
Stable tag: 3.1.0
|
| 8 |
Requires PHP: 7.0
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
| 22 |
- The output content of each meta tag can also be rewritten with a hook.
|
| 23 |
- You can easily set the Google Analytics measurement code and Webmaster Tools verification code.
|
| 24 |
|
| 25 |
+
Please see the following page for a detailed explanation of this plugin.
|
| 26 |
|
| 27 |
+
URL: [https://loos.co.jp/en/documents/seo-simple-pack/](https://loos.co.jp/en/documents/seo-simple-pack/)
|
| 28 |
|
| 29 |
|
| 30 |
### Source code
|
| 31 |
|
| 32 |
The source code of this plugin is available on Github.
|
| 33 |
|
| 34 |
+
URL: [https://github.com/ddryo/SEO-SIMPLE-PACK](https://github.com/ddryo/SEO-SIMPLE-PACK)
|
| 35 |
|
| 36 |
|
| 37 |
### How to use
|
| 119 |
|
| 120 |
|
| 121 |
== Changelog ==
|
| 122 |
+
|
| 123 |
+
= 3.1.0 =
|
| 124 |
+
- For Google Analytics, both GA4 and UA can now be set.
|
| 125 |
+
- Fixed a bug that prevented page numbers from being displayed in the title tag.
|
| 126 |
+
- Fixed a bug regarding canonical for the Page specified in the "Posts page".
|
| 127 |
|
| 128 |
= 3.0.0 =
|
| 129 |
- Added `'ssp_replace_snippet_{snippet_name}'` hook. (You can now define custom snippets)
|
seo-simple-pack.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: SEO SIMPLE PACK
|
| 4 |
* Plugin URI: https://wemo.tech/1670
|
| 5 |
* Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page.
|
| 6 |
-
* Version: 3.
|
| 7 |
* Author: LOOS,Inc.
|
| 8 |
* Author URI: https://loos-web-studio.com/
|
| 9 |
* License: GPL2 or later
|
|
@@ -44,17 +44,17 @@ if ( 'ja' === determine_locale() ) {
|
|
| 44 |
* Reading trait files
|
| 45 |
*/
|
| 46 |
require_once SSP_PATH . 'class/trait/field.php';
|
| 47 |
-
require_once SSP_PATH . 'class/trait/output_helper.php';
|
| 48 |
-
|
| 49 |
|
| 50 |
/**
|
| 51 |
* Reading class files
|
| 52 |
*/
|
| 53 |
require_once SSP_PATH . 'class/utility.php';
|
| 54 |
require_once SSP_PATH . 'class/data.php';
|
|
|
|
| 55 |
require_once SSP_PATH . 'class/hooks.php';
|
| 56 |
require_once SSP_PATH . 'class/menu.php';
|
| 57 |
require_once SSP_PATH . 'class/output.php';
|
|
|
|
| 58 |
require_once SSP_PATH . 'class/metabox.php';
|
| 59 |
require_once SSP_PATH . 'class/activate.php';
|
| 60 |
|
| 3 |
* Plugin Name: SEO SIMPLE PACK
|
| 4 |
* Plugin URI: https://wemo.tech/1670
|
| 5 |
* Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page.
|
| 6 |
+
* Version: 3.1.0
|
| 7 |
* Author: LOOS,Inc.
|
| 8 |
* Author URI: https://loos-web-studio.com/
|
| 9 |
* License: GPL2 or later
|
| 44 |
* Reading trait files
|
| 45 |
*/
|
| 46 |
require_once SSP_PATH . 'class/trait/field.php';
|
|
|
|
|
|
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Reading class files
|
| 50 |
*/
|
| 51 |
require_once SSP_PATH . 'class/utility.php';
|
| 52 |
require_once SSP_PATH . 'class/data.php';
|
| 53 |
+
require_once SSP_PATH . 'class/update_action.php';
|
| 54 |
require_once SSP_PATH . 'class/hooks.php';
|
| 55 |
require_once SSP_PATH . 'class/menu.php';
|
| 56 |
require_once SSP_PATH . 'class/output.php';
|
| 57 |
+
require_once SSP_PATH . 'class/output_helper.php';
|
| 58 |
require_once SSP_PATH . 'class/metabox.php';
|
| 59 |
require_once SSP_PATH . 'class/activate.php';
|
| 60 |
|
