解除媒体文件上传大小限制
默认情况下,刚搭建好的wordpress网站上传媒体文件都会有文件大小限制,默认为2M。
这个大小对于小的图片勉强够,但是对于视频和音频就完全不够了,因此肯定要修改放宽限制。
这个限制并不是网站后台限制的,而是php文件的配置决定的。
下面有两种方法,第一种是只修改当前wordpress的限制,第二种则是修改本机所有相关网络服务的限制。
1.添加php.ini
在网站根目录新建一个php.ini,添加以下内容。
upload_max_filesize = 128M post_max_size = 128M max_execution_time = 300
2.找到php.ini
这个配置文件可能在/etc/php.ini和/etc/php/7.2/apache2/php.ini等处,跟用到的apache版本有关。
使用vi打开后进行修改即可。
因为该配置文件中内容较多,可以在打开后在命令模式下输入/字符内容然后按下回车搜索,如果当前这个找到的不是,可以按n一个个向下搜索。
另外,修改完配置文件后记得重启apache服务才会生效。
整站一键变灰
在国难日期间,很多网站变成了灰色,包括所有的图片和外部广告等,这当然不是挨个修改的,因此研究了下一键实现整站变灰。
大致有以下两个方法:
在主题的functions.php添加如下代码
//网站变灰 function hui_head_css() { $styles = ""; $styles .= "html{overflow-y:scroll;filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter: grayscale(100%);}"; if ($styles) { echo "<style>" . $styles . "</style>"; } } add_action("wp_head", "hui_head_css");
主题的style.css或div.css文件或额外css等处添加如下代码
/*网站变灰*/ html { filter: grayscale(100%); -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter: url("data:image/svg+xml; utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(1); }
修改鼠标指针
同样是在主题的style.css或者额外css处添加代码
/**普通指针样式**/ body{cursor:url(https://www.yumefx.com/files/cursor.cur),default; } /**链接指针样式**/ a:hover{cursor:url(https://www.yumefx.com/files/cursor_linkselect.cur),pointer;}
鼠标指针可以自行搜索下载,需要cur格式的,并且上传到网站目录下。
添加代码后如果没有效果,可以清除一下浏览器缓存再打开网站即可。
隐藏登录页面
WordPress程序建网站的默认登录后台登陆地址为“域名/wp-admin/”,这样难免有被恶意登陆窃取网站资料的风险。
为了网站安全,可以通过以下方法修改Wordpress网站默认登录地址。
在主题的 functions.php 文件里加入 保护后台登陆的代码:
//保护后台登录 add_action('login_enqueue_scripts','login_protection'); function login_protection(){ if($_GET['word'] != 'admin')header('Location: https://www.yumefx.com/'); }
这样一来登陆界面的地址就变成了,https://www.yumefx.com/wp-login.php?word=admin。
如果还是用默认的https://www.yumefx.com/wp-admin或者https://www.yumefx.com/wp-login.php都会跳转到网站首页。
其中word和admin都可以修改成别的内容,所以不要试了,我用的肯定不是写出来的这个(笑)。
禁止评论中带链接
作为一个博客网站,难免会受到垃圾评论的骚扰,虽然开启了评论内容过滤,偶尔也会有漏网之鱼,特别是评论内容很随机,里面加上了超链接,或者评论人名字自带垃圾网站链接,甚至url栏本身就是垃圾网站的情况。
对于评论内容中的链接可以通过在主题的 functions.php 文件里加入以下代码,直接拒绝带链接评论的提交。
function wpzn_comment_post( $incoming_comment ) { $http = '/[href="|]/u'; if(preg_match($http, $incoming_comment['comment_content'])) { wp_die( "禁止发布带链接的评论!" ); } return( $incoming_comment ); } add_filter('preprocess_comment', 'wpzn_comment_post');
不过如果垃圾评论中有文本形式的链接地址,WordPress默认会自动将链接文本转为链接方便查看和点击,可以通过以下代码关闭此功能。。
remove_filter( 'comment_text', 'make_clickable', 9 );
而评论人名字自带的链接可以通过以下代码,将链接去除掉。
function disable_comment_author_links( $author_link ){ return strip_tags( $author_link ); } add_filter( 'get_comment_author_link', 'disable_comment_author_links' );
至于url栏则没有什么必要,直接在主题的comments.php中删除掉url栏的控件即可。
世间大多数人并不相信真实,
而是主动相信自己希望是真实的东西。
——村上春树


评论
335435 356870Perfectly composed content , thankyou for entropy. 653318
973664 398734Of course like your site but you want to check the spelling on several of your posts. Several of them are rife with spelling difficulties and I find it really bothersome to tell the truth nevertheless Ill undoubtedly come back once again. 466718
735831 996727I like this website quite considerably, Its a really nice situation to read and get information . 910379
223952 581116Some genuinely fascinating information, effectively written and broadly user pleasant. 435120
960713 988247Excellent artical, I unfortunately had some difficulties printing this artcle out, The print formating looks a bit screwed more than, something you might want to look into. 820819
390165 713395You created some decent points there. I looked online for the issue and identified a lot of people could go as well as utilizing your internet website. 164736
464490 19684This internet page is truly a walk-through its the internet you desired with this and didnt know who require to. Glimpse here, and you will surely discover it. 135445
150014 528371The next time I learn a weblog, I hope that it doesnt disappoint me as considerably as this 1. I mean, I do know it was my choice to read, nevertheless I in fact thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something which you could fix for those that werent too busy in search of attention. 773188