解除媒体文件上传大小限制
默认情况下,刚搭建好的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栏的控件即可。
世间大多数人并不相信真实,
而是主动相信自己希望是真实的东西。
——村上春树
评论
491665 995764I believe other web site proprietors need to take this internet web site as an example , quite clean and amazing user genial style . 489552
893321 380643Thank you for sharing with us, I conceive this web site actually stands out : D. 730111
865380 376906I found your weblog internet site on google and check a few of your early posts. Continue to preserve up the superb operate. I just further up your RSS feed to my MSN News Reader. Looking for forward to studying extra from you in a whilst! 287193
170236 132294I need to test with you here. Which is not 1 thing I normally do! I enjoy studying a submit that will make people think. Also, thanks for allowing me to comment! 261398
191233 611873I like this weblog extremely much, Its a rattling good billet to read and locate information . 725428
781856 231007What might you suggest in regards to your put up that you made some days ago? Any sure? 527821
658822 78934The site loading speed is amazing. 486428
842895 965370Excellent website, determined several something totally new! Subscribed RSS for later, aspire to see much more updates exactly like it. 609193