Changeset 2825011
- Timestamp:
- 11/28/2022 02:51:27 AM (21 months ago)
- Location:
- seo-simple-pack
- Files:
-
- 4 added
- 2 deleted
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
seo-simple-pack/tags/3.1.0/class/data.php
r2795972 r2825011 21 21 * DB[ssp_settings]用変数 22 22 */ 23 public static $settings = '';23 public static $settings = ; 24 24 25 25 /** 26 26 * DB[spp_ogp]用変数 27 27 */ 28 public static $ogp = '';28 public static $ogp = ; 29 29 30 30 /** … … 102 102 103 103 if ( false === $installed_version ) { 104 105 104 // インストール時に実行する処理 106 105 self::setup_at_installed(); 107 106 108 107 } elseif ( SSP_VERSION !== $installed_version ) { 109 110 // 更新時に実行する処理 111 self::setup_at_updated( $installed_version ); 112 } 113 114 // サイト基本情報取得 115 self::$site_title = esc_html( get_option( 'blogname' ) ); 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 } 108 // バージョン更新時に実行する処理 109 \LOOS\SSP\Update_Action::setup_at_updated( $installed_version ); 110 } 111 112 // データセット 113 self::setup_data(); 114 } 115 127 116 128 117 /** … … 131 120 public static function set_default() { 132 121 self::$default_settings = [ 133 'home_title' => '%_site_title_% %_sep_% %_tagline_%', 134 'home_desc' => '', 135 'home_keyword' => '', 136 'reuse_keyword' => '1', 137 'separator' => 'line', 138 'webmaster_bing' => '', 139 'webmaster_google' => '', 140 'webmaster_baidu' => '', 141 'webmaster_yandex' => '', 142 'google_analytics_type' => 'gtag', 143 'google_analytics_id' => '', 144 'post_noindex' => false, 145 'post_title' => '%_page_title_% %_sep_% %_site_title_%', 146 'post_desc' => '%_page_contents_%', 147 'page_noindex' => false, 148 'page_title' => '%_page_title_% %_sep_% %_site_title_%', 149 'page_desc' => '%_page_contents_%', 150 'attachment_disable' => true, 151 'attachment_noindex' => true, 152 'attachment_title' => '%_page_title_% %_sep_% %_site_title_%', 153 'attachment_desc' => '%_page_contents_%', 154 'cat_noindex' => false, 155 'cat_title' => '%_term_name_% %_sep_% %_site_title_%', 156 'cat_desc' => '%_term_description_%', 157 'tag_noindex' => false, 158 'tag_title' => '%_term_name_% %_sep_% %_site_title_%', 159 'tag_desc' => '%_term_description_%', 160 'post_format_disable' => false, 161 'post_format_noindex' => true, 162 'post_format_title' => '%_term_name_% %_sep_% %_site_title_%', 163 'post_format_desc' => '', 164 'author_disable' => false, 165 'author_noindex' => true, 166 'author_title' => '%_author_name_% %_sep_% %_site_title_%', 167 'author_desc' => sprintf( self::$texts['archive_desc'], '%_author_name_%' ), 168 'date_noindex' => true, 169 'date_title' => '%_date_% %_sep_% %_site_title_%', 170 'date_desc' => sprintf( self::$texts['archive_desc'], '%_date_%' ), 171 'pt_archive_noindex' => true, 172 'pt_archive_title' => '%_post_type_% %_sep_% %_site_title_%', 173 'pt_archive_desc' => sprintf( self::$texts['archive_desc'], '%_post_type_%' ), 174 '404_title' => '404: ' . __( 'Page not found', 'loos-ssp' ) . ' %_sep_% %_site_title_%', 175 'search_title' => __( 'Searched:', 'loos-ssp' ) . ' %_search_phrase_% %_sep_% %_site_title_%', 176 'feed_noindex' => false, 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, 177 168 ]; 178 169 … … 207 198 } 208 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 209 239 210 240 /** … … 219 249 update_option( self::DB_NAME['settings'], self::$default_settings ); 220 250 update_option( self::DB_NAME['ogp'], self::$default_ogp_settings ); 221 222 } 223 224 /** 225 * 更新時に実行する処理 226 */ 227 public static function setup_at_updated( $installed_version ) { 228 229 // 現在のバージョン番号を保存 230 update_option( self::DB_NAME['installed'], SSP_VERSION ); 231 232 // バージョンが上がった時だけの処理 233 // if (version_compare( SSP_VERSION, $installed_version, '>' ) ) {} 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 clean_meta() { 246 247 // 空のカスタムフィールドを削除 248 global $wpdb; 249 250 // phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery 251 foreach ( SSP_MetaBox::POST_META_KEYS as $key => $meta_key ) { 252 $wpdb->delete( $wpdb->postmeta, [ 253 'meta_key' => $meta_key, 254 'meta_value' => '', 255 ] ); 256 } 257 258 foreach ( SSP_MetaBox::TERM_META_KEYS as $key => $meta_key ) { 259 $wpdb->delete( $wpdb->termmeta, [ 260 'meta_key' => $meta_key, 261 'meta_value' => '', 262 ] ); 263 } 264 // phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery 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 ); 265 269 } 266 270 } -
seo-simple-pack/tags/3.1.0/class/output.php
r2795972 r2825011 1 1 <?php 2 3 4 2 5 class SSP_Output { 3 4 use \SSP\Output_Helper;5 6 6 7 /** … … 144 145 145 146 // Generate other ogp tags 146 self::$og_locale = apply_filters( 'ssp_output_og_locale', self::get_valid_og_locale() );147 self::$og_locale = apply_filters( 'ssp_output_og_locale', ::get_valid_og_locale() ); 147 148 self::$og_type = self::generate_og_type(); 148 149 self::$og_image = self::generate_og_image(); … … 559 560 560 561 $meta_canonical = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['canonical'], true ); 561 $canonical = $meta_canonical ?: get_permalink( );562 $canonical = $meta_canonical ?: get_permalink(); 562 563 break; 563 564 … … 700 701 */ 701 702 private static function output_codes() { 702 703 $settings = SSP_Data::$settings;704 705 703 // meta tags for webmaster tools 706 704 if ( is_front_page() ) { … … 712 710 ]; 713 711 foreach ( $webmaster_codes as $key => $name ) { 714 if ( $settings[ $key ] ) { 715 echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $settings[ $key ] ) . '">' . PHP_EOL; 712 $content = SSP_Data::get( 'settings', $key ); 713 if ( $content ) { 714 echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $content ) . '">' . PHP_EOL; 716 715 } 717 716 } 718 717 } 719 718 720 // google analytics code 721 if ( $settings['google_analytics_id'] ) { 722 723 $gaid = $settings['google_analytics_id']; 724 725 if ( 'gtag' === $settings['google_analytics_type'] ) { 726 727 self::echo_gtag( $gaid ); 728 729 } elseif ( 'analytics' === $settings['google_analytics_type'] ) { 730 731 self::echo_analytics( $gaid ); 732 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; 733 855 } 734 } 735 } 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 736 872 } -
seo-simple-pack/tags/3.1.0/inc/page_help.php
r2795972 r2825011 55 55 'label' => __( 'Search word', 'loos-ssp' ), 56 56 'for' => __( 'Search results', 'loos-ssp' ), 57 58 59 60 57 61 ], 58 62 ]; -
seo-simple-pack/tags/3.1.0/inc/tab/top_analytics.php
r2444192 r2825011 3 3 * Googleアナリティクス タブ 4 4 */ 5 6 7 8 9 10 11 12 13 14 15 5 16 self::output_section( __( 'Google Analytics settings', 'loos-ssp' ), [ 6 'google_analytics_type' => [ 7 'title' => __( 'Tracking code type', 'loos-ssp' ), 8 'type' => 'select', 9 'choices' => [ 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' ), 17 'google_g_id' => [ 18 'title' => __( '"Measurement ID" for GA4', 'loos-ssp' ), 19 'class' => '-wide', 20 'desc' => $gid_desc, 14 21 ], 15 'google_analytics_id' => [ 16 'title' => __( '"Tracking ID" or "Measurement ID"', 'loos-ssp' ), 17 'desc' => sprintf( 18 SSP_Data::$texts['input'], 19 __( 'Tracking ID (<code>UA-XXXX...</code>) or Measurement ID (<code>G-XXX...</code>)', 'loos-ssp' ) 20 ), 22 'google_ua_id' => [ 23 'title' => __( '"Tracking ID" for UA', 'loos-ssp' ), 24 'class' => '-wide', 25 'desc' => $uaid_desc, 21 26 ], 22 27 ] ); -
seo-simple-pack/tags/3.1.0/inc/tab/top_webmaster.php
r2444192 r2825011 16 16 ' : <code><meta name="' . $data[1] . '" content="<b>' . _x( 'Your code', 'input', 'loos-ssp' ) . '</b>"></code>'; 17 17 18 19 20 21 22 18 $section_args[ $key ] = [ 19 'title' => sprintf( __( 'Authentication code for %s', 'loos-ssp' ), $data[0] ), 20 'desc' => $desc, 21 'class' => '-wide -webmaster', 22 ]; 23 23 } 24 24 self::output_section( __( 'Webmaster Tools Certification Code', 'loos-ssp' ), $section_args ); -
seo-simple-pack/tags/3.1.0/readme.txt
r2795972 r2825011 5 5 Requires at least: 4.9 6 6 Tested up to: 6.0 7 Stable tag: 3. 0.07 Stable tag: 3..0 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 23 23 - You can easily set the Google Analytics measurement code and Webmaster Tools verification code. 24 24 25 Please see the following page for a detailed explanation of this plugin. (Written in Japanese.)26 27 URL: https://wemo.tech/167025 Please see the following page for a detailed explanation of this plugin. 26 27 URL: 28 28 29 29 … … 32 32 The source code of this plugin is available on Github. 33 33 34 URL: https://github.com/ddryo/SEO-SIMPLE-PACK34 URL: 35 35 36 36 … … 120 120 121 121 == Changelog == 122 123 124 125 126 122 127 123 128 = 3.0.0 = -
seo-simple-pack/tags/3.1.0/seo-simple-pack.php
r2795972 r2825011 4 4 * Plugin URI: https://wemo.tech/1670 5 5 * Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page. 6 * Version: 3. 0.06 * Version: 3..0 7 7 * Author: LOOS,Inc. 8 8 * Author URI: https://loos-web-studio.com/ … … 45 45 */ 46 46 require_once SSP_PATH . 'class/trait/field.php'; 47 require_once SSP_PATH . 'class/trait/output_helper.php';48 49 47 50 48 /** … … 53 51 require_once SSP_PATH . 'class/utility.php'; 54 52 require_once SSP_PATH . 'class/data.php'; 53 55 54 require_once SSP_PATH . 'class/hooks.php'; 56 55 require_once SSP_PATH . 'class/menu.php'; 57 56 require_once SSP_PATH . 'class/output.php'; 57 58 58 require_once SSP_PATH . 'class/metabox.php'; 59 59 require_once SSP_PATH . 'class/activate.php'; -
seo-simple-pack/trunk/class/data.php
r2795972 r2825011 21 21 * DB[ssp_settings]用変数 22 22 */ 23 public static $settings = '';23 public static $settings = ; 24 24 25 25 /** 26 26 * DB[spp_ogp]用変数 27 27 */ 28 public static $ogp = '';28 public static $ogp = ; 29 29 30 30 /** … … 102 102 103 103 if ( false === $installed_version ) { 104 105 104 // インストール時に実行する処理 106 105 self::setup_at_installed(); 107 106 108 107 } elseif ( SSP_VERSION !== $installed_version ) { 109 110 // 更新時に実行する処理 111 self::setup_at_updated( $installed_version ); 112 } 113 114 // サイト基本情報取得 115 self::$site_title = esc_html( get_option( 'blogname' ) ); 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 } 108 // バージョン更新時に実行する処理 109 \LOOS\SSP\Update_Action::setup_at_updated( $installed_version ); 110 } 111 112 // データセット 113 self::setup_data(); 114 } 115 127 116 128 117 /** … … 131 120 public static function set_default() { 132 121 self::$default_settings = [ 133 'home_title' => '%_site_title_% %_sep_% %_tagline_%', 134 'home_desc' => '', 135 'home_keyword' => '', 136 'reuse_keyword' => '1', 137 'separator' => 'line', 138 'webmaster_bing' => '', 139 'webmaster_google' => '', 140 'webmaster_baidu' => '', 141 'webmaster_yandex' => '', 142 'google_analytics_type' => 'gtag', 143 'google_analytics_id' => '', 144 'post_noindex' => false, 145 'post_title' => '%_page_title_% %_sep_% %_site_title_%', 146 'post_desc' => '%_page_contents_%', 147 'page_noindex' => false, 148 'page_title' => '%_page_title_% %_sep_% %_site_title_%', 149 'page_desc' => '%_page_contents_%', 150 'attachment_disable' => true, 151 'attachment_noindex' => true, 152 'attachment_title' => '%_page_title_% %_sep_% %_site_title_%', 153 'attachment_desc' => '%_page_contents_%', 154 'cat_noindex' => false, 155 'cat_title' => '%_term_name_% %_sep_% %_site_title_%', 156 'cat_desc' => '%_term_description_%', 157 'tag_noindex' => false, 158 'tag_title' => '%_term_name_% %_sep_% %_site_title_%', 159 'tag_desc' => '%_term_description_%', 160 'post_format_disable' => false, 161 'post_format_noindex' => true, 162 'post_format_title' => '%_term_name_% %_sep_% %_site_title_%', 163 'post_format_desc' => '', 164 'author_disable' => false, 165 'author_noindex' => true, 166 'author_title' => '%_author_name_% %_sep_% %_site_title_%', 167 'author_desc' => sprintf( self::$texts['archive_desc'], '%_author_name_%' ), 168 'date_noindex' => true, 169 'date_title' => '%_date_% %_sep_% %_site_title_%', 170 'date_desc' => sprintf( self::$texts['archive_desc'], '%_date_%' ), 171 'pt_archive_noindex' => true, 172 'pt_archive_title' => '%_post_type_% %_sep_% %_site_title_%', 173 'pt_archive_desc' => sprintf( self::$texts['archive_desc'], '%_post_type_%' ), 174 '404_title' => '404: ' . __( 'Page not found', 'loos-ssp' ) . ' %_sep_% %_site_title_%', 175 'search_title' => __( 'Searched:', 'loos-ssp' ) . ' %_search_phrase_% %_sep_% %_site_title_%', 176 'feed_noindex' => false, 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, 177 168 ]; 178 169 … … 207 198 } 208 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 209 239 210 240 /** … … 219 249 update_option( self::DB_NAME['settings'], self::$default_settings ); 220 250 update_option( self::DB_NAME['ogp'], self::$default_ogp_settings ); 221 222 } 223 224 /** 225 * 更新時に実行する処理 226 */ 227 public static function setup_at_updated( $installed_version ) { 228 229 // 現在のバージョン番号を保存 230 update_option( self::DB_NAME['installed'], SSP_VERSION ); 231 232 // バージョンが上がった時だけの処理 233 // if (version_compare( SSP_VERSION, $installed_version, '>' ) ) {} 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 clean_meta() { 246 247 // 空のカスタムフィールドを削除 248 global $wpdb; 249 250 // phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery 251 foreach ( SSP_MetaBox::POST_META_KEYS as $key => $meta_key ) { 252 $wpdb->delete( $wpdb->postmeta, [ 253 'meta_key' => $meta_key, 254 'meta_value' => '', 255 ] ); 256 } 257 258 foreach ( SSP_MetaBox::TERM_META_KEYS as $key => $meta_key ) { 259 $wpdb->delete( $wpdb->termmeta, [ 260 'meta_key' => $meta_key, 261 'meta_value' => '', 262 ] ); 263 } 264 // phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery 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 ); 265 269 } 266 270 } -
seo-simple-pack/trunk/class/output.php
r2795972 r2825011 1 1 <?php 2 3 4 2 5 class SSP_Output { 3 4 use \SSP\Output_Helper;5 6 6 7 /** … … 144 145 145 146 // Generate other ogp tags 146 self::$og_locale = apply_filters( 'ssp_output_og_locale', self::get_valid_og_locale() );147 self::$og_locale = apply_filters( 'ssp_output_og_locale', ::get_valid_og_locale() ); 147 148 self::$og_type = self::generate_og_type(); 148 149 self::$og_image = self::generate_og_image(); … … 559 560 560 561 $meta_canonical = get_post_meta( self::$obj->ID, SSP_MetaBox::POST_META_KEYS['canonical'], true ); 561 $canonical = $meta_canonical ?: get_permalink( );562 $canonical = $meta_canonical ?: get_permalink(); 562 563 break; 563 564 … … 700 701 */ 701 702 private static function output_codes() { 702 703 $settings = SSP_Data::$settings;704 705 703 // meta tags for webmaster tools 706 704 if ( is_front_page() ) { … … 712 710 ]; 713 711 foreach ( $webmaster_codes as $key => $name ) { 714 if ( $settings[ $key ] ) { 715 echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $settings[ $key ] ) . '">' . PHP_EOL; 712 $content = SSP_Data::get( 'settings', $key ); 713 if ( $content ) { 714 echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $content ) . '">' . PHP_EOL; 716 715 } 717 716 } 718 717 } 719 718 720 // google analytics code 721 if ( $settings['google_analytics_id'] ) { 722 723 $gaid = $settings['google_analytics_id']; 724 725 if ( 'gtag' === $settings['google_analytics_type'] ) { 726 727 self::echo_gtag( $gaid ); 728 729 } elseif ( 'analytics' === $settings['google_analytics_type'] ) { 730 731 self::echo_analytics( $gaid ); 732 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; 733 855 } 734 } 735 } 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 736 872 } -
seo-simple-pack/trunk/inc/page_help.php
r2795972 r2825011 55 55 'label' => __( 'Search word', 'loos-ssp' ), 56 56 'for' => __( 'Search results', 'loos-ssp' ), 57 58 59 60 57 61 ], 58 62 ]; -
seo-simple-pack/trunk/inc/tab/top_analytics.php
r2444192 r2825011 3 3 * Googleアナリティクス タブ 4 4 */ 5 6 7 8 9 10 11 12 13 14 15 5 16 self::output_section( __( 'Google Analytics settings', 'loos-ssp' ), [ 6 'google_analytics_type' => [ 7 'title' => __( 'Tracking code type', 'loos-ssp' ), 8 'type' => 'select', 9 'choices' => [ 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' ), 17 'google_g_id' => [ 18 'title' => __( '"Measurement ID" for GA4', 'loos-ssp' ), 19 'class' => '-wide', 20 'desc' => $gid_desc, 14 21 ], 15 'google_analytics_id' => [ 16 'title' => __( '"Tracking ID" or "Measurement ID"', 'loos-ssp' ), 17 'desc' => sprintf( 18 SSP_Data::$texts['input'], 19 __( 'Tracking ID (<code>UA-XXXX...</code>) or Measurement ID (<code>G-XXX...</code>)', 'loos-ssp' ) 20 ), 22 'google_ua_id' => [ 23 'title' => __( '"Tracking ID" for UA', 'loos-ssp' ), 24 'class' => '-wide', 25 'desc' => $uaid_desc, 21 26 ], 22 27 ] ); -
seo-simple-pack/trunk/inc/tab/top_webmaster.php
r2444192 r2825011 16 16 ' : <code><meta name="' . $data[1] . '" content="<b>' . _x( 'Your code', 'input', 'loos-ssp' ) . '</b>"></code>'; 17 17 18 19 20 21 22 18 $section_args[ $key ] = [ 19 'title' => sprintf( __( 'Authentication code for %s', 'loos-ssp' ), $data[0] ), 20 'desc' => $desc, 21 'class' => '-wide -webmaster', 22 ]; 23 23 } 24 24 self::output_section( __( 'Webmaster Tools Certification Code', 'loos-ssp' ), $section_args ); -
seo-simple-pack/trunk/readme.txt
r2795972 r2825011 5 5 Requires at least: 4.9 6 6 Tested up to: 6.0 7 Stable tag: 3. 0.07 Stable tag: 3..0 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 23 23 - You can easily set the Google Analytics measurement code and Webmaster Tools verification code. 24 24 25 Please see the following page for a detailed explanation of this plugin. (Written in Japanese.)26 27 URL: https://wemo.tech/167025 Please see the following page for a detailed explanation of this plugin. 26 27 URL: 28 28 29 29 … … 32 32 The source code of this plugin is available on Github. 33 33 34 URL: https://github.com/ddryo/SEO-SIMPLE-PACK34 URL: 35 35 36 36 … … 120 120 121 121 == Changelog == 122 123 124 125 126 122 127 123 128 = 3.0.0 = -
seo-simple-pack/trunk/seo-simple-pack.php
r2795972 r2825011 4 4 * Plugin URI: https://wemo.tech/1670 5 5 * Description: A very simple SEO plugin. You can easily set and customize meta tags and OGP tags for each page. 6 * Version: 3. 0.06 * Version: 3..0 7 7 * Author: LOOS,Inc. 8 8 * Author URI: https://loos-web-studio.com/ … … 45 45 */ 46 46 require_once SSP_PATH . 'class/trait/field.php'; 47 require_once SSP_PATH . 'class/trait/output_helper.php';48 49 47 50 48 /** … … 53 51 require_once SSP_PATH . 'class/utility.php'; 54 52 require_once SSP_PATH . 'class/data.php'; 53 55 54 require_once SSP_PATH . 'class/hooks.php'; 56 55 require_once SSP_PATH . 'class/menu.php'; 57 56 require_once SSP_PATH . 'class/output.php'; 57 58 58 require_once SSP_PATH . 'class/metabox.php'; 59 59 require_once SSP_PATH . 'class/activate.php';
Note: See TracChangeset
for help on using the changeset viewer.