Version Description
html
=
Download this release
Release Info
Developer | frustigor |
Plugin | WP SEO TDK |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
WP SEO TDK/346/217/217/350/277/260/345/217/212/344/275/277/347/224/250/346/226/271/346/263/225.doc
ADDED
Binary file
|
readme.txt
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP SEO TDK ===
|
2 |
+
Contributors: frustigor
|
3 |
+
Donate link: http://www.utubon.com/donate
|
4 |
+
Tags:wordpress seo, title seo, description seo, keywords seo
|
5 |
+
Requires at least: 3.5.1
|
6 |
+
Tested up to: 4.1.1
|
7 |
+
Stable tag: trunk
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
WP SEO TDK是一款适合中国WordPress用户用来设置网站的SEO基本选项的插件,简单易懂,可以很快的设置网页的标题、关键词、描述。
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
WP SEO TDK是一款适合中国WordPress用户用来设置网站的SEO基本选项的插件,简单易懂,可以很快的设置网页的标题、关键词、描述。
|
16 |
+
传统的一些SEO插件设置复杂,很多功能过于繁复,导致网站的性能下降,而SEO TDK只用一个文件,完成网站的标题、关键词、描述的设置,非常适合中国站长的SEO设置习惯。
|
17 |
+
虽然,简单,却非常有效,它可以通过不超过10项设置就轻松完成网站的首页、分类列表页、标签列表页、文章内容页的TDK SEO优化。
|
18 |
+
具体的使用方法和设置后的效果都在插件附带的doc文档中有说明,也可以去 http://www.utubon.com/?p=1612 了解。
|
19 |
+
|
20 |
+
== Installation ==
|
21 |
+
|
22 |
+
1、把插件文件夹上传到/wp-content/plugins/目录<br />
|
23 |
+
2、在后台插件列表中激活它<br />
|
24 |
+
3、在“设置-SEO TDK”菜单中进行配置<br />
|
25 |
+
4、完成后即可
|
26 |
+
|
27 |
+
== Frequently Asked Questions ==
|
28 |
+
|
29 |
+
|
30 |
+
== Screenshots ==
|
31 |
+
|
32 |
+
|
33 |
+
== Changelog ==
|
34 |
+
|
35 |
+
= 1.0.1 =
|
36 |
+
去除标题、关键词、描述中的html标签。
|
37 |
+
|
38 |
+
== Upgrade Notice ==
|
39 |
+
|
40 |
+
= 1.0.1 =
|
41 |
+
去除标题、关键词、描述中的html标签。
|
wp-seo-tdk.php
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP SEO TDK
|
4 |
+
Plugin URI: http://www.utubon.com/?p=1612
|
5 |
+
Description: 为您提供一个通用的网页标题、关键词、描述方案,实现最基本的SEO TDK目的。
|
6 |
+
Version: 1.0.1
|
7 |
+
Author: 否子戈
|
8 |
+
Author URI: http://www.utubon.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
// 创建一个函数,用以清除描述文本中的换行、HTML标签等干扰信息,只留下文本
|
12 |
+
function wp_seo_tdk_clear_html_code($string){
|
13 |
+
$string=str_replace("\r\n",'',$string);//清除换行符
|
14 |
+
$string=str_replace("\n",'',$string);//清除换行符
|
15 |
+
$string=str_replace("\t",'',$string);//清除制表符
|
16 |
+
$pattern=array("/> *([^ ]*) *</","/[\s]+/","/<!--[^!]*-->/","/\" /","/ \"/","'/\*[^*]*\*/'","/\[(.*)\]/");
|
17 |
+
$replace=array(">\\1<"," ","","\"","\"","","");
|
18 |
+
return preg_replace($pattern,$replace,$string);
|
19 |
+
}
|
20 |
+
|
21 |
+
// 优化网页标题,对wp_title的输出格式进行变化
|
22 |
+
add_filter('wp_title','wp_seo_tdk_title',100);
|
23 |
+
function wp_seo_tdk_title($title){
|
24 |
+
global $page,$paged,$post;
|
25 |
+
|
26 |
+
$title = trim($title);
|
27 |
+
$seo_slip = __(get_option('seo_tdk_blog_slip'));
|
28 |
+
$blog_seo_title = __(get_option('seo_tdk_blog_title'));
|
29 |
+
$cat_seo_title_type = get_option('seo_tdk_cat_title_type');
|
30 |
+
$post_seo_title_type = get_option('seo_tdk_post_title_type');
|
31 |
+
if(!trim($seo_slip)){
|
32 |
+
$seo_slip = '_';
|
33 |
+
}
|
34 |
+
// 首页标题优化
|
35 |
+
if(is_home() || is_front_page()){
|
36 |
+
if($blog_seo_title){
|
37 |
+
$title = wp_seo_tdk_clear_html_code($blog_seo_title);
|
38 |
+
}else{
|
39 |
+
$title = get_bloginfo('name').$seo_slip.get_bloginfo('description');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
// 分类页标题
|
43 |
+
elseif(is_category()){
|
44 |
+
global $cat;
|
45 |
+
$cat_id = is_object($cat)?$cat->cat_ID:$cat;
|
46 |
+
$cat_title = single_cat_title('',false);
|
47 |
+
$cat_seo_title = __(wp_seo_tdk_get_term_meta($cat_id,'seo_title'));
|
48 |
+
$title = $cat_seo_title ? $cat_seo_title : $title;
|
49 |
+
if($cat_seo_title_type == 2){
|
50 |
+
$category = get_category($cat_id);
|
51 |
+
while($category->parent){
|
52 |
+
$category = get_category($category->parent);
|
53 |
+
$title .= $seo_slip.$category->cat_name;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
$title .= $seo_slip.get_bloginfo('name');
|
57 |
+
}
|
58 |
+
elseif(is_tag()){
|
59 |
+
global $wp_query;
|
60 |
+
$tag_id = $wp_query->queried_object->term_id;
|
61 |
+
$tag_name = $wp_query->queried_object->name;
|
62 |
+
$tag_seo_title = __(wp_seo_tdk_get_term_meta($tag_id,'seo_title'));
|
63 |
+
$title = $tag_seo_title?$tag_seo_title:$tag_name;
|
64 |
+
$title .= $seo_slip.get_bloginfo('name');
|
65 |
+
}
|
66 |
+
// 文章页的标题
|
67 |
+
elseif(is_singular()){
|
68 |
+
$title = __($post->post_title?$post->post_title:$post->post_date);
|
69 |
+
if($post_seo_title_type == 2){
|
70 |
+
$category = get_the_category();
|
71 |
+
$category = $category[0];
|
72 |
+
while($category->cat_ID){
|
73 |
+
$title .= $seo_slip.$category->cat_name;
|
74 |
+
$category = get_category($category->parent);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
$title .= $seo_slip.get_bloginfo('name');
|
78 |
+
}
|
79 |
+
elseif(is_feed()){
|
80 |
+
return $title;
|
81 |
+
}
|
82 |
+
// 其他情况
|
83 |
+
else{
|
84 |
+
$title .= $seo_slip.get_bloginfo('name');
|
85 |
+
}
|
86 |
+
if($paged >= 2 || $page >= 2){
|
87 |
+
$title .= $seo_slip.sprintf(__('第%s页'),max($paged,$page));
|
88 |
+
}
|
89 |
+
$title = wp_seo_tdk_clear_html_code($title);
|
90 |
+
return strip_tags($title);
|
91 |
+
}
|
92 |
+
// 网页关键字描述
|
93 |
+
function wp_seo_tdk_keywords(){
|
94 |
+
|
95 |
+
// 为了避免翻页带来的问题,把翻页以后的给屏蔽掉
|
96 |
+
if(is_paged()) return;
|
97 |
+
|
98 |
+
$keywords = '';
|
99 |
+
if(is_home() || is_front_page()){
|
100 |
+
$keywords = __(get_option('seo_tdk_blog_keywords'));
|
101 |
+
}
|
102 |
+
elseif(is_category()){
|
103 |
+
global $cat;
|
104 |
+
$cat_id = is_object($cat)?$cat->cat_ID:$cat;
|
105 |
+
$cat_keywords = __(wp_seo_tdk_get_term_meta($cat_id,'seo_keywords'));
|
106 |
+
if($cat_keywords){
|
107 |
+
$keywords = $cat_keywords;
|
108 |
+
}else{
|
109 |
+
$keywords = single_cat_title('',false);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
elseif(is_tag()){
|
113 |
+
global $wp_query;
|
114 |
+
$tag_id = $wp_query->queried_object->term_id;
|
115 |
+
$tag_keywords = __(wp_seo_tdk_get_term_meta($tag_id,'seo_keywords'));
|
116 |
+
if($tag_keywords){
|
117 |
+
$keywords = $tag_keywords;
|
118 |
+
}else{
|
119 |
+
$keywords = $wp_query->queried_object->name;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
elseif(is_singular()){
|
123 |
+
global $post;
|
124 |
+
// 第一种是使用标签
|
125 |
+
$tags = strip_tags(get_the_tag_list('',',',''));
|
126 |
+
// 第二种是使用自定义域的keywords
|
127 |
+
$metakeywords = __(trim(stripslashes(strip_tags(get_post_meta($post->ID,'keywords',true)))));
|
128 |
+
// 第三种是使用分类名称
|
129 |
+
$cats = '';
|
130 |
+
$categories = get_the_category();
|
131 |
+
foreach($categories as $category){
|
132 |
+
$cats .= ','.$category->cat_name;
|
133 |
+
}
|
134 |
+
// 当存在标签时,使用标签;当存在自定义keywords时,把它附加到标签上,如果没有标签,就使用自定义的keywords;如果这两者都不存在,就使用分类名称
|
135 |
+
if($tags && $metakeywords){
|
136 |
+
$keywords = $tags.','.$metakeywords;
|
137 |
+
}elseif($tags && !$metakeywords){
|
138 |
+
$keywords = $tags;
|
139 |
+
}elseif(!$tags && $metakeywords){
|
140 |
+
$keywords = $metakeywords;
|
141 |
+
}else{
|
142 |
+
$keywords = $post->post_title;
|
143 |
+
}
|
144 |
+
$keywords .= $cats;
|
145 |
+
$keywords = trim(str_replace('"','',$keywords));
|
146 |
+
$keywords = wp_seo_tdk_clear_html_code($keywords);
|
147 |
+
}
|
148 |
+
if($keywords)echo '<meta name="keywords" content="'.strip_tags($keywords).'" />'."\n";
|
149 |
+
}
|
150 |
+
// 网页描述
|
151 |
+
function wp_seo_tdk_description(){
|
152 |
+
|
153 |
+
// 为了避免翻页带来的问题,把翻页以后的给屏蔽掉
|
154 |
+
if(is_paged())return;
|
155 |
+
|
156 |
+
$description = '';
|
157 |
+
if(is_home() || is_front_page()){
|
158 |
+
$description = __(strip_tags(get_option('seo_tdk_blog_description')));
|
159 |
+
}
|
160 |
+
elseif(is_category()){
|
161 |
+
$description = __(strip_tags(category_description()));
|
162 |
+
}
|
163 |
+
elseif(is_tag()){
|
164 |
+
$description = __(strip_tags(tag_description()));
|
165 |
+
}
|
166 |
+
elseif(is_singular()){
|
167 |
+
global $post;
|
168 |
+
// 第一种是使用自定义域的
|
169 |
+
$description = __(strip_tags(get_post_meta($post->ID,'description',true)));
|
170 |
+
// 第二种是使用摘要
|
171 |
+
$excerpt = __(strip_tags($post->post_excerpt));
|
172 |
+
// 第三种是使用文章的前200字
|
173 |
+
$content = mb_strimwidth(__(strip_tags($post->post_content)),0,300,'...');
|
174 |
+
// 将三者结合起来
|
175 |
+
if($description == '')$description = $excerpt;
|
176 |
+
if($description == '')$description = $content;
|
177 |
+
$description = str_replace('"','',$description);
|
178 |
+
$description = wp_seo_tdk_clear_html_code(trim($description));
|
179 |
+
}
|
180 |
+
if($description)echo '<meta name="description" content="'.strip_tags($description).'" />'."\n";
|
181 |
+
}
|
182 |
+
// 将关键词和描述输出在wp_head区域
|
183 |
+
add_action('wp_head','add_wp_head_action_seo_tdk',0);
|
184 |
+
function add_wp_head_action_seo_tdk(){
|
185 |
+
wp_seo_tdk_keywords();
|
186 |
+
wp_seo_tdk_description();
|
187 |
+
}
|
188 |
+
|
189 |
+
// 创建后台设置页面
|
190 |
+
add_action('admin_menu','add_admin_options_submenu_seo_tdk');
|
191 |
+
function add_admin_options_submenu_seo_tdk(){
|
192 |
+
add_options_page('SEO Title Description Keywords Option','SEO TDK','edit_theme_options','seo_tdk','wp_seo_tdk_admin_setting');
|
193 |
+
}
|
194 |
+
add_action('admin_init','update_admin_options_submenu_seo_tdk');
|
195 |
+
function update_admin_options_submenu_seo_tdk(){
|
196 |
+
if(!empty($_POST) && $_POST['page'] == $_GET['page'] && $_POST['action'] == 'update_seo_tdk'){
|
197 |
+
check_admin_referer();
|
198 |
+
update_option('seo_tdk_blog_slip',$_POST['seo_tdk_blog_slip']);
|
199 |
+
update_option('seo_tdk_blog_title',$_POST['seo_tdk_blog_title']);
|
200 |
+
update_option('seo_tdk_blog_keywords',$_POST['seo_tdk_blog_keywords']);
|
201 |
+
update_option('seo_tdk_blog_description',$_POST['seo_tdk_blog_description']);
|
202 |
+
update_option('seo_tdk_cat_title_type',$_POST['seo_tdk_cat_title_type']);
|
203 |
+
update_option('seo_tdk_post_title_type',$_POST['seo_tdk_post_title_type']);
|
204 |
+
wp_redirect(admin_url('admin.php?page='.$_POST['page'].'&saved=true&time='.time()));
|
205 |
+
exit;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
function wp_seo_tdk_admin_setting(){
|
209 |
+
if(@$_GET['saved'] == 'true')echo '<div id="message" class="updated fade"><p><strong>更新成功!</strong></p></div>';
|
210 |
+
$seo_tdk_blog_slip = get_option('seo_tdk_blog_slip');
|
211 |
+
$seo_tdk_blog_title = get_option('seo_tdk_blog_title');
|
212 |
+
$seo_tdk_blog_keywords = get_option('seo_tdk_blog_keywords');
|
213 |
+
$seo_tdk_blog_description = get_option('seo_tdk_blog_description');
|
214 |
+
$seo_tdk_cat_title_type = get_option('seo_tdk_cat_title_type');
|
215 |
+
$seo_tdk_post_title_type = get_option('seo_tdk_post_title_type');
|
216 |
+
?>
|
217 |
+
<div class="wrap" id="seo-tdk-admin">
|
218 |
+
<h2>SEO Ttitle(标题) Description(网页描述) Keywords(网页关键词)设置</h2>
|
219 |
+
<p>
|
220 |
+
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
221 |
+
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-0625745788201806" data-ad-slot="7099159194"></ins>
|
222 |
+
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
223 |
+
</p>
|
224 |
+
<div class="metabox-holder">
|
225 |
+
<form method="post">
|
226 |
+
<div class="postbox">
|
227 |
+
<h3>全局设置</h3>
|
228 |
+
<div class="inside">
|
229 |
+
<p>间隔符:<input type="text" class="regular-text" style="width:60px;" name="seo_tdk_blog_slip" value="<?php echo $seo_tdk_blog_slip; ?>" /><br />
|
230 |
+
一般来说都从"-"、"_"、"|"中进行选择。注意,下面的演示中有的时候用_,有的时候用-,但实际效果还是根据这里的设置而定。</p>
|
231 |
+
</div>
|
232 |
+
</div>
|
233 |
+
<div class="postbox">
|
234 |
+
<h3>首页(blog)设置</h3>
|
235 |
+
<div class="inside">
|
236 |
+
<p>标题:<input type="text" class="regular-text" name="seo_tdk_blog_title" value="<?php echo $seo_tdk_blog_title; ?>" /></p>
|
237 |
+
<p>关键词:<input type="text" class="regular-text" name="seo_tdk_blog_keywords" value="<?php echo $seo_tdk_blog_keywords; ?>" /></p>
|
238 |
+
<p>网页描述:<br>
|
239 |
+
<textarea class="large-text" name="seo_tdk_blog_description"><?php echo $seo_tdk_blog_description; ?></textarea></p>
|
240 |
+
</div>
|
241 |
+
</div>
|
242 |
+
<div class="postbox">
|
243 |
+
<h3>分类(category)标签(tag)页设置</h3>
|
244 |
+
<div class="inside">
|
245 |
+
<p>标题格式:<select name="seo_tdk_cat_title_type">
|
246 |
+
<option value="1" <?php selected($seo_tdk_cat_title_type,1); ?>>分类名-博客名</option>
|
247 |
+
<option value="2" <?php selected($seo_tdk_cat_title_type,2); ?>>分类名-父分类-博客名</option>
|
248 |
+
</select></p>
|
249 |
+
</div>
|
250 |
+
<div class="inside">
|
251 |
+
<p>一般情况下,wp_title都会直接打印出分类名作为分类页的标题,本功能允许你设置自己的分类页标题。在编辑具体的分类页时可以看到category_meta字段,你可以填写对应的值。分类页的描述将直接采用分类描述。<br>
|
252 |
+
注意:这些meta值应该与你在这里填写的标题格式进行统筹规划。</p>
|
253 |
+
<p>例如,您在原本为“帆布鞋”的分类中填写了新的标题字段为“帆布鞋 凡客诚品”,那么在页面中将使用后面的代替前面的,如你的标题将变为“帆布鞋 凡客诚品-父分类-根分类-博客名”</p>
|
254 |
+
<p>分类页的关键词由category_meta_keywords确定,如果不填写,直接使用分类名。</p>
|
255 |
+
<p>分类页的描述由分类的描述确定。</p>
|
256 |
+
<p>因为标签没有父标签之说,所以这里的设置对标签无效。</p>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
<div class="postbox">
|
260 |
+
<h3>文章(post)页设置</h3>
|
261 |
+
<div class="inside">
|
262 |
+
<p>标题格式:<select name="seo_tdk_post_title_type">
|
263 |
+
<option value="1" <?php selected($seo_tdk_post_title_type,1); ?>>文章名-博客名</option>
|
264 |
+
<option value="2" <?php selected($seo_tdk_post_title_type,2); ?>>文章名-分类层级-博客名</option>
|
265 |
+
</select></p>
|
266 |
+
</div>
|
267 |
+
<div class="inside">
|
268 |
+
<p>文章页的重要性不必多说了吧!</p>
|
269 |
+
<p>文章页的关键词:首先使用文章标签作为关键词,接着你自己创建的keywords自定义栏目的值作为关键词,再接着使用文章名和分类名称作为关键词。本插件会同时使用它们,无论缺少谁都不会直接影响关键词的使用。</p>
|
270 |
+
<p>文章页的描述:首先使用文章自定义栏目description的值作为描述,如果没有的话,使用填写的文章摘要作为描述,如果还没有的话,摘取文章开头的150个字作为描述。注意,它们之间的选择是有先后顺序的,如果你同时填写了description自定义栏目和摘要,只会选择自定义栏目的值作为摘要。记住,你的文章开头150个字也很重要。</p>
|
271 |
+
</div>
|
272 |
+
</div>
|
273 |
+
<div class="postbox">
|
274 |
+
<h3>说明</h3>
|
275 |
+
<div class="inside">
|
276 |
+
<p>使用中的注意点,插件版本升级信息,或有什么问题,请到 http://www.utubon.com/?p=1612 了解或留言。</p>
|
277 |
+
<p>向插件作者捐赠:支付宝<code>476206120@qq.com</code>、财付通<code>476206120</code>、比特币<code>16tezAsqEZHhVz4xAmNAp8A5r7qMg1NG9P</code></p>
|
278 |
+
<p>如果你还想要更高级的功能,例如在后台写文章的时候增加选项,可以选择这篇文章只同步到上面配置的博客列表中的某一个或几个(非全部)的话,可以和我联系,获得更高级别的开发成果。476206120@qq.com <a href="http://www.utubon.com" target="_blank">乌徒帮</a></p>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
<p class="submit">
|
282 |
+
<button type="submit" class="button-primary">提交</button>
|
283 |
+
</p>
|
284 |
+
<input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" />
|
285 |
+
<input type="hidden" name="action" value="update_seo_tdk" />
|
286 |
+
<?php wp_nonce_field(); ?>
|
287 |
+
</form>
|
288 |
+
</div>
|
289 |
+
</div>
|
290 |
+
<?php
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
下方的代码用以实现term_meta
|
295 |
+
**/
|
296 |
+
|
297 |
+
add_action('category_add_form_fields','wp_seo_tdk_extra_term_fields');
|
298 |
+
add_action('edit_category_form_fields','wp_seo_tdk_extra_term_fields');
|
299 |
+
add_action('add_tag_form_fields','wp_seo_tdk_extra_term_fields');
|
300 |
+
add_action('edit_tag_form_fields','wp_seo_tdk_extra_term_fields');
|
301 |
+
function wp_seo_tdk_extra_term_fields($term){
|
302 |
+
$term_id = $term->term_id;
|
303 |
+
$term_seo_title = get_option("term_{$term_id}_meta_seo_title");
|
304 |
+
$term_seo_keywords = get_option("term_{$term_id}_meta_seo_keywords");
|
305 |
+
?>
|
306 |
+
<tr class="form-field">
|
307 |
+
<th scope="row" valign="top"><label for="term_seo_title">SEO标题</label></th>
|
308 |
+
<td><input type="text" name="term_meta_seo_title" id="term_seo_title" class="regular-text" value="<?php echo $term_seo_title ? $term_seo_title : ''; ?>"></td>
|
309 |
+
</tr>
|
310 |
+
<tr class="form-field">
|
311 |
+
<th scope="row" valign="top"><label for="term_seo_keywords">SEO关键词</label></th>
|
312 |
+
<td><input type="text" name="term_meta_seo_keywords" id="term_seo_keywords" class="regular-text" value="<?php echo $term_seo_keywords ? $term_seo_keywords : ''; ?>"></td>
|
313 |
+
</tr>
|
314 |
+
<?php
|
315 |
+
}
|
316 |
+
|
317 |
+
add_action('created_category','wp_seo_tdk_save_extra_term_fileds');
|
318 |
+
add_action('edited_category','wp_seo_tdk_save_extra_term_fileds');
|
319 |
+
add_action('created_post_tag','wp_seo_tdk_save_extra_term_fileds');
|
320 |
+
add_action('edited_post_tag','wp_seo_tdk_save_extra_term_fileds');
|
321 |
+
function wp_seo_tdk_save_extra_term_fileds($term_id){
|
322 |
+
update_option("term_{$term_id}_meta_seo_title",$_POST['term_meta_seo_title']);
|
323 |
+
update_option("term_{$term_id}_meta_seo_keywords",$_POST['term_meta_seo_keywords']);
|
324 |
+
}
|
325 |
+
|
326 |
+
function wp_seo_tdk_get_term_meta($term_id,$meta_key){
|
327 |
+
if(is_object($term_id))$term_id = $term_id->term_id;
|
328 |
+
$term_meta = get_option("term_{$term_id}_meta_{$meta_key}");
|
329 |
+
if($term_meta){
|
330 |
+
return $term_meta;
|
331 |
+
}else{
|
332 |
+
return null;
|
333 |
+
}
|
334 |
+
}
|