弦子
Just do IT..

Wordpress Useful Code Script

1. 隐藏页面Wordpress版本号, 在主题functions.php文件添加:

// 隐藏版本号
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');

2. 主题评论添加 Ctrl+Enter 快捷键发表评论. 在 comments.php 中找到以下代码(也就是表单的 textarea):

<textarea name="comment" id="comment" cols="125" rows="12"tabindex="4"></textarea>

修改为:

<textarea name=”comment” id=”comment” cols=”125″ rows=”12″ tabindex=”4″ onkeydown=”if(event.ctrlKey&&event.keyCode==13){document.getElementById(‘submit’).click();return false};”></textarea>

另外一种办法是, 在comments.php的</form>后面添加以下代码:

<script type="text/javascript" language="javascript">
document.getElementById("comment").onkeydown = function (moz_ev)
        {
                var ev = null;
                if (window.event){
                        ev = window.event;
                }else{
                        ev = moz_ev;
                }
                if (ev != null && ev.ctrlKey && ev.keyCode == 13)
                {
                        document.getElementById("submit").click();
                }
        }
</script>
/* 关闭自动保存和修订版本 */
remove_action('pre_post_update', 'wp_save_post_revision' );
add_action('wp_print_scripts', 'disable_autosave' );
function disable_autosave() { wp_deregister_script('autosave'); }
  //禁用l10n.js
  wp_deregister_script('l10n');
  //移除管理员工具条(或:后台也有设置项)
  remove_action('init','wp_admin_bar_init');
  //禁用自动保存草稿
  wp_deregister_script('autosave');
  //禁用修改历史记录
  remove_action('pre_post_update','wp_save_post_revision');
  //禁止在head泄露wordpress版本号
  remove_action('wp_head','wp_generator');
  //移除head中的rel="EditURI"
  remove_action('wp_head','rsd_link');
  //移除head中的rel="wlwmanifest"
  remove_action('wp_head','wlwmanifest_link');

  //rsd_link移除XML-RPC
  remove_action('wp_head','rsd_link');
// 移除Private title 字样
function the_title_trim($title) {

	$title = attribute_escape($title);

	$findthese = array(
		'#Protected:#',
		'#Private:#'
	);

	$replacewith = array(
		'', // What to replace "Protected:" with
		'' // What to replace "Private:" with
	);

	$title = preg_replace($findthese, $replacewith, $title);
	return $title;
}
add_filter('the_title', 'the_title_trim');

禁用WordPress图片压缩功能: 在主题 functions.php 文件中添加下面的代码即可解决.

<?php
add_filter('jpeg_quality', function($arg){return 100;});
?>

待续…

赞(0)
未经允许不得转载:英文 SEO & SEM Journal » Wordpress Useful Code Script
分享到: 更多 (0)

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    😆 保留这个版本号在系统代码吧不更好?据说wp天生对gg友好!有这个号在里面是不是可以让gg更容易认出是什么cms吧?

    mark13年前 (2011-06-21)回复
    • Google知道的, 她懂的, 呵呵, 隐藏版本号也就是个人喜好去了, 呵呵 🙂

      Shieh13年前 (2011-06-21)回复