來源于:
http://blog.pureisle.net/archives/378.html
http://zmingcx.com/wordpress-theme-very-useful-development-techniques.html
本文的目標讀者是WordPress 主題開發者,需要懂一些基本的PHP知識。另外,下文提到的所有代碼都必須添加到functions. php文件里面。
WordPress主題一般有一系列的php文件和一個style. css文件,而其中功能最為強大的文件則是functions. php。WordPress 有非常多的常用函數,你可以通過添加和刪除一些函數來增加WordPress主題的功能,而不需要修改任何的主題文件。
1,添加Google Analytics 統計
只需要把下面的代碼添加到functions. php文件里面——注意把里面的中文部分替換成你的Google 統計代碼,然后你就不用擔心了。
<?php
add_action('wp_footer',?'add_googleanalytics');
function add_googleanalytics()?{??>
//?把Google?統計代碼復制到這里
<?php?}??>
2,給WordPress 博客添加一個 Favicon 圖標。
每一個博客都應該有一個獨一無二的標志,你可以通過添加代碼到header.php來實現。當然,你也可以通過添加代碼到functions.php來實現。添加完下面的代碼后,只需要把Favicon.ico文件上傳到網站根目錄即可。
//?add?a?favicon?to?your
function blog_favicon()?{
echo '<link?rel="Shortcut?Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
}
add_action('wp_head',?'blog_favicon');
3,移除WordPress版本號。
WordPress有新版本出來后,總會在后臺提示管理員進行升級。但假如你是給客戶制作網站,而他們又不想升級的話,最好的辦法就是從WordPress 頭部、RSS里面以及其他任何地方移除版本的信息。
function wpbeginner_remove_version()?{
return '';
}
add_filter('the_generator',?'wpbeginner_remove_version');
4,給WordPress控制面板添加自定義logo
用WordPress給客戶制作網站,如果給WordPress的控制面板后臺添加一個自定義logo,則會讓網站顯的專業很多。要做到這一點,你只需要把代碼添加到functions.php即可。
//hook?the?administrative?header?output
add_action('admin_head',?'my_custom_logo');
function my_custom_logo()?{
echo '
<style?type="text/css">
#header-logo?{?background-image:?url('.get_bloginfo('template_directory').'/images/custom-logo.gif)?!important;?}
</style>
';
}
5,改變WordPress后臺控制面板底部信息
如上所述,如果不想讓客戶知道網站是由WordPress制作,則可以修改WordPress控制面板底部的信息,只需要把下面的代碼添加到 functions.php文件即可。
function remove_footer_admin?()?{
echo 'Fueled?by?<a?href="http://www.wordpress.org" target="_blank">WordPress</a>?|?Designed?by?<a?href="http://www.uzzz.net" target="_blank">Uzzz?Productions</a>?|?WordPress?Tutorials:?<a?href="http://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';
}
add_filter('admin_footer_text',?'remove_footer_admin');
注:代碼里面的html部分可以修改。
6,自定義WordPress控制面板模塊
一些WordPress插件會在控制面板那里添加一些模塊來顯示相應的信息,作為一個WordPress模板設計者,你也可以通過修改functions.php文件來實現這個功能。注意替換里面的相應信息。
add_action('wp_dashboard_setup',?'my_custom_dashboard_widgets');
function my_custom_dashboard_widgets()?{
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget',?'Theme?Support',?'custom_dashboard_help');
}
function custom_dashboard_help()?{
echo '<p>Welcome?to?Custom?Blog?Theme!?Need?help??Contact?the?developer?<a?href="mailto:yourusername@gmail.com">here</a>.?For?WordPress?Tutorials?visit:?<a? target="_blank">WPBeginner</a></p>';
}
7,改變默認的 Gravatar 頭像
WordPress程序默認的 Gravatar 頭像很不咋地,而且到處都是千篇一律的默認頭像一點都無法體現獨特性。你可以把以下代碼添加到functions.php文件里面,然后記得把自定義的 Gravatar 頭像上傳到WordPress模板的images文件夾。
add_filter(?'avatar_defaults',?'newgravatar'?);
function newgravatar?($avatar_defaults)?{
$myavatar =?get_bloginfo('template_directory')?.?'/images/gravatar.gif';
$avatar_defaults[$myavatar]?= "WPBeginner";
return $avatar_defaults;
}
8,讓WordPress底部的版權時間顯示的更生動
很多網站的版權時間都顯示的是建站時的年份,有些則是顯示當下的年份。事實上,這兩種方式都不是太好。
最好的方式是顯示從網站建設之初的年份到目前的年份位置,類似? 2006 – 2010這種顯示方式。
這種效果通過以下的代碼可以實現。添加完下面的代碼后,系統會自動抓取發布第一篇文章的年份以及最新一篇文章的年份,并把它顯示出來。
function comicpress_copyright()?{
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt))?AS?firstdate,
YEAR(max(post_date_gmt))?AS?lastdate
FROM
$wpdb->posts
WHERE
post_status?=?'publish'
");
$output = '';
if($copyright_dates)?{
$copyright = "©?" . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate?!= $copyright_dates[0]->lastdate)?{
$copyright .=?'-'?. $copyright_dates[0]->lastdate;
}
$output = $copyright;
}
return $output;
}
把上面的代碼添加到了functions.php文件里面后,還需要在 footer.php 任何你想顯示版權時間的地方加上如下代碼:
<?php echo comicpress_copyright();??>
9,給讀者投稿文章添加姓名/來源
如果你的博客接受讀者的投稿,想在該篇文章出現投稿者的姓名,同時又不想通過添加作者的這種繁瑣而麻煩的方式來操作,則可以使用下面的代碼。使用下面的代碼后,只需要在撰寫文章的時候在自定義區域填上投稿者的姓名即可。系統會自動將發布者的名稱換成投稿者的名稱。
這個代碼對接受讀者投稿較多的網站,或者是資訊型的網站非常有用(利用它來顯示來源)。
add_filter(?'the_author',?'guest_author_name'?);
add_filter(?'get_the_author_display_name',?'guest_author_name'?);
function guest_author_name( $name )?{
global $post;
$author =?get_post_meta( $post->ID,?'guest-author',?true?);
if ( $author )
$name = $author;
return $name;
}
10,啟用文章縮略圖功能
從WordPress2.9版本開始,可以給模板添加文章縮略圖功能。操作方法很簡單,只需要把下面的代碼添加到functions.php里面。
add_theme_support(?'post-thumbnails'?);
然后在要顯示縮略圖的地方放置下面的代碼即可。
<?php?the_post_thumbnail();??>
11,自定義WordPress 3.0 版本導航欄
WordPress 3.0 增加了一個功能,可以讓WordPress模板開發者自定義導航菜單。如果你想給用戶一個導航欄的選擇權,只需要把下面的代碼加入到 functions.php 文件里面。
add_theme_support(?'nav-menus'?);
之后把下面的代碼復制到你想出新的地方:
<?php?wp_nav_menu( array(?'sort_column'?=>?'menu_order',?'container_class'?=>?'menu-header'?)?);??>
12,移除WordPress默認的個人資料選項
如果你客戶的想讓用戶可以自行添加個人資料,那么需要讓這個選項更簡單。其中一個方法就是移除部分選項,AIM, Yahoo IM 和 Jabber 之類的東東。
add_filter('user_contactmethods','hide_profile_fields',10,1);
function hide_profile_fields( $contactmethods )?{
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
return $contactmethods;
}
13,添加作者個人資料選項
如果你想更充分的展示作者的個人資料,那么你可以添加一些更個性化的資料選項,例如添加twitter 和 facebook賬號等。下面的代碼就是添加twitter 和 facebook賬號用的。當然,你可以把里面的內容替換成其他任何你想展示的資料。這個對多博客作者尤其有用。
function my_new_contactmethods( $contactmethods )?{
//?Add?Twitter
$contactmethods['twitter']?=?'Twitter';
//add?Facebook
$contactmethods['facebook']?=?'Facebook';
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
添加完是上面的代碼后,你需要在author.php文件里面添加如下的代碼:
<?php echo $curauth->twitter;??>
注意:改代碼僅在WordPress2.9以上的版本起作用。
14,添加側邊欄小模塊。
這是目前用的最多的技巧之一,很多WordPress模板開發者都已經知道,并且在用了。
if (?function_exists('register_sidebar')?)
register_sidebar(array('name'=>'MiddleSidebar',
'before_widget'?=>?'<li class="widget">',
'after_widget'?=>?'</li>',
'before_title'?=>?'<h2 class="widgettitle">',
'after_title'?=>?'</h3>',
));
register_sidebar(array('name'=>'FooterSidebar',
'before_widget'?=>?'<li class="widget">',
'after_widget'?=>?'</li>',
'before_title'?=>?'<h2 class="widgettitle">',
'after_title'?=>?'</h3>',
));
上面的代碼可以增加兩個側邊欄的小模塊。以此類推,你可以添加無限多側邊欄的小模塊。添加完上面的代碼后,你需要把下面的代碼添加到你要出現這邊小模塊的地方。
<?php if (?!function_exists('dynamic_sidebar')?||?!dynamic_sidebar('MiddleSidebar')?)?:??>
<!–Default?sidebar?info?goes?here–>
<?php endif;??>
注意:側邊欄并不一定需要出現在sidebar.php文件里面。
15,優化Wordpress 博客的RSS
如何在RSS里面加入版權鏈接?如何在RSS加入廣告?針對國內互聯網的現狀,在RSS里面加入版權尤為重要,廣告倒是次要的。
除了插件(Better Feed)以外,可以采用以下的方法來實現。
function wpbeginner_postrss($content)?{
if(is_feed()){
$content =?'This?post?was?written?by?Syed?Balkhi?'.$content.'Check?out?WPBeginner';
}
return $content;
}
add_filter('the_excerpt_rss',?'wpbeginner_postrss');
add_filter('the_content',?'wpbeginner_postrss');
16,給RSS添加縮略圖
縮略圖一般是在正常的博客頁面上用來起到美化界面的作用。當然,如果需要的話,也可以給RSS內容增加一個縮略圖。要做到這一點,只需要在functions.php 里面加入如下代碼:
function rss_post_thumbnail($content)?{
global $post;
if(has_post_thumbnail($post->ID))?{
$content =?'<p>'?.?get_the_post_thumbnail($post->ID)?.
'</p>'?.?get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss',?'rss_post_thumbnail');
add_filter('the_content_feed',?'rss_post_thumbnail');
17,開啟WordPress評論嵌套功能。
評論嵌套功能是WordPress自身帶有的最好功能之一,只可惜很多WordPress模板都不支持。很多文章都有提到過修改的方法,但一般都涉 及到修改comments文件和header文件。事實上,通過修改functions.php文件來修改是最簡便的,而且一勞永逸。
//?enable?threaded?comments
function enable_threaded_comments(){
if (!is_admin())?{
if (is_singular()?AND?comments_open()?AND?(get_option('thread_comments')?==?1))
wp_enqueue_script('comment-reply');
}
}
add_action('get_header',?'enable_threaded_comments');
18,移除WordPress登陸面板的錯誤提示
當你輸入的密碼或者用戶名錯誤的時候,WordPress登陸界面會給出相應的提示。但如果碰到黑客的話,這些提示反而給了他們更好的提示,讓他們更容易破解用戶名和密碼。因此,處于安全性考慮,移除WordPress登陸面板的錯誤提示是非常必要的。
- add_filter('login_errors',create_function('$a', "return?null;"));
19,關閉WordPress的搜索功能
當把WordPress當做CMS系統來使用的時候,WordPress自帶的搜索功能實用性就不是太強了。一來增加數據庫查詢次數,二來Google 自定義搜索會是更好的替代。因此,你只需要通過以下的代碼就可以關閉WordPress的搜索功能。
function fb_filter_query( $query, $error =?true?)?{
if (?is_search()?)?{
$query->is_search?=?false;
$query->query_vars[s]?=?false;
$query->query[s]?=?false;
//?to?error
if ( $error ==?true?)
$query->is_404?=?true;
}
}
add_action(?'parse_query',?'fb_filter_query'?);
add_filter(?'get_search_form',?create_function(?'$a', "return?null;" )?);
20,啟用WordPress簡碼功能
Google AdSense 算是博客的標配之一了,很多CMS經常會在模板選項里面預置Google AdSense的廣告位。假如你的模板不支持,你可以通過以下的方法來解決:
function showads()?{
return '<div?id="adsense"><script?type="text/javascript"><!–
google_ad_client?= "pub-XXXXXXXXXXXXXX";
google_ad_slot?= "4668915978";
google_ad_width?=?468;
google_ad_height?=?60;
//–>
</script>
<script?type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>';
}
add_shortcode('adsense',?'showads');
21,不通過.htaccess將rss地址唯一化
WordPress本身提供好幾個不同版本的rss地址,加入你又使用了FeedBurner或者feedsky的話,RSS地址就會更多。太多的RSS容易分流訂閱客戶,而且也不利于品牌推廣。
一般的修改方法是通過更改.htaccess來進行,此外,還可以通過以下的代碼來實現。
function custom_feed_link($output, $feed)?{
$feed_url =?'http://feeds.feedburner.com/wpbeginner';
$feed_array = array('rss'?=> $feed_url,?'rss2'?=> $feed_url,?'atom'?=> $feed_url,?'rdf'?=> $feed_url,?'comments_rss2'?=> '');
$feed_array[$feed]?= $feed_url;
$output = $feed_array[$feed];
return $output;
}
function other_feed_links($link)?{
$link =?'http://feeds.feedburner.com/wpbeginner';
return $link;
}
//Add?our?functions?to?the?specific?filters
add_filter('feed_link','custom_feed_link',?1,?2);
add_filter('category_feed_link',?'other_feed_links');
add_filter('author_feed_link',?'other_feed_links');
add_filter('tag_feed_link','other_feed_links');
add_filter('search_feed_link','other_feed_links');
22,啟用paypal 捐贈簡碼
當你寫完一篇以后,可以在文章里面插入paypal 捐贈按鈕,方便讀者捐贈。以下的代碼可以讓你非常輕松的做到這一點。
function donate_shortcode( $atts )?{
extract(shortcode_atts(array(
'text'?=>?'Make?a?donation',
'account'?=>?'REPLACE?ME',
'for'?=> '',
), $atts));
global $post;
if (!$for) $for = str_replace("?","?",$post->post_title);
return '<a class="donateLink" .$account.'&item_name=Donation?for?'.$for.'">'.$text.'</a>';
}
add_shortcode('donate',?'donate_shortcode');
23,設定文章從發布到出現在RSS中的時間長短
通過RSS訂閱來閱讀博文的朋友可能都會有這個體驗:經常發現RSS中的文字或者細節有錯誤,而返回到頁面的時候卻發現錯誤已經沒有了。這種情況最有可能是因為
RSS最大的好處是快捷、直接,但這個最大的好處有時候對作者來說卻會引發某些尷尬。所以,有時候有必要讓文章發布后到讀者從RSS中按到有一個小小的時間差,方便作者排查某些問題。以下的代碼可以做到以下幾點:
function publish_later_on_feed($where)?{
global $wpdb;
if (?is_feed()?)?{
//?timestamp?in?WP-format
$now = gmdate(‘Y-m-d?H:i:s’);
//?value?for?wait;?+?device
$wait =?‘10′; //?integer
//?http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device =?‘MINUTE’; //MINUTE,?HOUR,?DAY,?WEEK,?MONTH,?YEAR
//?add?SQL-sytax?to?default?$where
$where .=?”?AND?TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt,?‘$now’)?> $wait “;
}
return $where;
}
add_filter(‘posts_where’,?‘publish_later_on_feed’);
這段代碼設置的時間是10分鐘,你可以把10改成任何你想要的時間。
24,自定義摘要輸出時的符號
一般設定自動摘要輸出,你會經常在WordPress博客的首頁看到“[...]”這樣的符號。為了界面的美觀,或者是個性化的需要,你可以把這個默認的符號改變為其他的符號。而以下的代碼就是為了實現這個而寫:
//?custom?excerpt?ellipses?for?2.9
function custom_excerpt_more($more)?{
return '…';
}
add_filter('excerpt_more',?'custom_excerpt_more');
/*?custom?excerpt?ellipses?for?2.8-
function?custom_excerpt_more($excerpt)?{
return?str_replace('[...]',?'…',?$excerpt);
}
add_filter('wp_trim_excerpt',?'custom_excerpt_more');
*/
25,自定義摘要輸出的文字長度
假如你比較懶,不想在撰寫文章的時候每篇文章都輸入摘要,就可以讓系統自動截取一定長度的文字來作為摘要輸出。下面的代碼默認是100個字節,也就是50個漢字。你可以把數值修改成符合你需要的數字。
function new_excerpt_length($length)?{
return 100;
}
add_filter('excerpt_length',?'new_excerpt_length');
26,顯示精確評論數
WordPress默認是把trackbacks 和 pings 都算作評論的,因此當你設置不顯示trackbacks 和 ping的時候,評論數看起來總是不對頭。以下的代碼則以讓WordPress只計算評論的數量,而不把trackbacks 和 pings也計算進去。
add_filter('get_comments_number',?'comment_count',?0);
function comment_count( $count )?{
if (?!?is_admin()?)?{
global $id;
$comments_by_type =?&separate_comments(get_comments('status=approve&post_id='?. $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
27,取消RSS輸出
對于某些博客而言,或者因為被太多人采集了,或者因為不想讓別人通過RSS訂閱,想取消RSS輸出。WordPress默認是沒有這個功能的,但你可以通過以下的代碼來取消RSS輸出。
function fb_disable_feed()?{
wp_die(?__('No?feed?available,please?visit?our?<a?href="'.?get_bloginfo('url')?.'">homepage</a>!')?);
}
add_action('do_feed',?'fb_disable_feed',?1);
add_action('do_feed_rdf',?'fb_disable_feed',?1);
add_action('do_feed_rss',?'fb_disable_feed',?1);
add_action('do_feed_rss2',?'fb_disable_feed',?1);
add_action('do_feed_atom',?'fb_disable_feed',?1);
28,顯示Twitter 的訂閱數以及其他資料
Twitter系統以及很多第三方的客戶端都可以讓你在WordPress博客的側邊欄暫時Twitter的訂閱數以及一些其他的資料。這種做法往往很多時候都沒辦法跟博客已有的界面結合的很好。而以下的代碼則可以讓你自定義Twitter 在博客上的顯示外觀。
function rarst_twitter_user( $username, $field, $display =?false?)?{
$interval =?3600;
$cache =?get_option('rarst_twitter_user');
$url =?'http://api.twitter.com/1/users/show.json?screen_name='.urlencode($username);
if (?false?== $cache )
$cache = array();
//?if?first?time?request?add?placeholder?and?force?update
if (?!isset( $cache[$username][$field]?)?)?{
$cache[$username][$field]?=?NULL;
$cache[$username]['lastcheck']?=?0;
}
//?if?outdated
if( $cache[$username]['lastcheck']?<?(time()-$interval)?)?{
//?holds?decoded?JSON?data?in?memory
static $memorycache;
if (?isset($memorycache[$username])?)?{
$data = $memorycache[$username];
}
else {
$result =?wp_remote_retrieve_body(wp_remote_request($url));
$data =?json_decode( $result );
if ( is_object($data)?)
$memorycache[$username]?= $data;
}
if ( is_object($data)?)?{
//?update?all?fields,?known?to?be?requested
foreach ($cache[$username] as $key => $value)
if(?isset($data->$key)?)
$cache[$username][$key]?= $data->$key;
$cache[$username]['lastcheck']?=?time();
}
else {
$cache[$username]['lastcheck']?=?time()+60;
}
update_option(?'rarst_twitter_user', $cache );
}
if (?false?!= $display )
echo $cache[$username][$field];
return $cache[$username][$field];
}
把上面的代碼復制到 functions.php后,再把下面代碼復制到你想出現的地方即可。
Then place the following code where you want to display the count in your theme file:
echo rarst_twitter_user('wpbeginner',?'name').'?has?'.
rarst_twitter_user('wpbeginner',?'followers_count').'?followers?after?'.
rarst_twitter_user('wpbeginner',?'statuses_count').'?updates.';
29,彩色標簽云
把代碼復制到 functions.php后,原本單色的標簽云,會變成多彩的.
//彩色標簽云
function colorCloud($text)?{
$text =?preg_replace_callback('|<a?(.+?)>|i',?'colorCloudCallback', $text);
return $text;
}
function colorCloudCallback($matches)?{
$text = $matches[1];
$color = dechex(rand(0,16777215));
$pattern =?'/style=(\'|\")(.*)(\'|\")/i';
$text?=?preg_replace($pattern,?"style=\"color:#{$color};$2;\"", $text);
return "<a?$text>";
}
add_filter('wp_tag_cloud',?'colorCloud',?1);
30,評論回應郵件通知
一般該功能都通過插件實現,把代碼復制到 functions.php后,會在評論部分自動插入可選擇的評論回應郵件通知功能.
//?評論回應郵件通知
function comment_mail_notify($comment_id)?{
$admin_notify =?'1'; //?admin?要不要收回復通知?(?'1'=要?;?'0'=不要?)
$admin_email =?get_bloginfo?('admin_email'); //?$admin_email?可改為你指定的?e-mail.
$comment =?get_comment($comment_id);
$comment_author_email =?trim($comment->comment_author_email);
$parent_id = $comment->comment_parent?? $comment->comment_parent?: '';
global $wpdb;
if ($wpdb->query("Describe?{$wpdb->comments}?comment_mail_notify")?== '')
$wpdb->query("ALTER?TABLE?{$wpdb->comments}?ADD?COLUMN?comment_mail_notify?TINYINT?NOT?NULL?DEFAULT?0;");
if (($comment_author_email != $admin_email &&?isset($_POST['comment_mail_notify']))?||?($comment_author_email == $admin_email && $admin_notify ==?'1'))
$wpdb->query("UPDATE?{$wpdb->comments}?SET?comment_mail_notify='1'?WHERE?comment_ID='$comment_id'");
$notify = $parent_id ??get_comment($parent_id)->comment_mail_notify?:?'0';
$spam_confirmed = $comment->comment_approved;
if ($parent_id != '' && $spam_confirmed !=?'spam'?&& $notify ==?'1')?{
$wp_email =?'no-reply@'?.?preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); //?e-mail?發出點,?no-reply?可改為可用的?e-mail.
$to =?trim(get_comment($parent_id)->comment_author_email);
$subject =?'您在?['?.?get_option("blogname")?.?']?的留言有了回應';
$message =?'
<div?style="background-color:#eef2fa;?border:1px?solid?#d8e3e8;?color:#111;?padding:0?15px;?-moz-border-radius:5px;?-webkit-border-radius:5px;?-khtml-border-radius:5px;">
<p>'?.?trim(get_comment($parent_id)->comment_author)?.?',?您好!</p>
<p>您曾在《'?.?get_the_title($comment->comment_post_ID)?.?'》的留言:<br?/>'
.?trim(get_comment($parent_id)->comment_content)?.?'</p>
<p>'?.?trim($comment->comment_author)?.?'?給您的回應:<br?/>'
.?trim($comment->comment_content)?.?'<br?/></p>
<p>您可以點擊?<a?href="'?.?htmlspecialchars(get_comment_link($parent_id))?.?'">查看回應完整內容</a></p>
<p>歡迎您再度光臨?<a?href="'?.?get_option('home')?.?'">'?.?get_option('blogname')?.?'</a></p>
<p>(此郵件由系統自動發出,請勿回復.)</p>
</div>';
$from = "From:?\"" .?get_option('blogname')?. "\"?<$wp_email>";
$headers = "$from\nContent-Type:?text/html;?charset=" .?get_option('blog_charset')?. "\n";
wp_mail( $to, $subject, $message, $headers );
//echo?'mail?to?',?$to,?'<br/>?'?,?$subject,?$message;?//?for?testing
}
}
add_action('comment_post',?'comment_mail_notify');
//?自動勾選
function add_checkbox()?{
echo '<input?type="checkbox" name="comment_mail_notify" id="comment_mail_notify" value="comment_mail_notify" checked="checked" style="margin-left:0px;" /><label for="comment_mail_notify">有人回復時郵件通知我</label>';
}
add_action('comment_form',?'add_checkbox');
?
?
?