一些博主[@www.lajiz.cn]好不容易找到喜欢的Wordpress主题并且希望把主题最下方的版权链接去掉,原以为修改版权链接很容易做到,但在实际操作时确发现并不像自己想象的那么简单,直接修改footer.php文件后再打开网站发现出现下面的错误信息:
All the links in the footer should remain intact. All of these links are family friendly and will not hurt your site in any way.
其实Wordpress主题加密主要有两类方法:一种是直接代码直接被加密,另外一种是通过PHP语言的特性实现加密功能。学习本教程大家可以模仿修改本类主题。
这个是广告编辑地方
针对上述英文提示的代码加密修改方法如下:进入后台管理页面,打开你的主题,定位functions.php文件,搜索代码:
1 |
wp_initialize_the_theme |
第一步:找到下面的一段代码
1 |
if (! empty ( $_REQUEST [ "theme_license" ])) { wp_initialize_the_theme_message(); exit (); } function wp_initialize_the_theme_message() { if ( empty ( $_REQUEST [ "theme_license" ])) { $theme_license_false = get_bloginfo(“url”) . “/index.php?theme_license=true”; echo “”; exit (); } else { echo (“ |
2 |
3 |
All the links in the footer should remain intact. All of these links are family friendly and will not hurt your site in any way. |
4 |
5 |
”); } } |
删除如上该段代码,并在原来位置用如下代码填充代替
1 |
function wp_initialize_the_theme_message() { } |
第二步:继续向下找到该段代码
1 |
function wp_initialize_the_theme_finish() { $uri = strtolower ( $_SERVER [ "REQUEST_URI" ]); if (is_admin() || substr_count( $uri , “wp-admin”) > 0 || substr_count( $uri , “wp-login”) > 0 ) { /* */ } else { $l = ‘Designed by: Free SharePoint | Todays Current WordPress Themes Directory, Wicked Pittsburgh and WordPress Themes Free’; $f = dirname( __file__ ) . “/footer.php”; $fd = fopen ( $f , “r”); $c = fread ( $fd , filesize ( $f )); $lp = preg_quote( $l , “/”); fclose( $fd ); if ( strpos ( $c , $l ) == 0 || preg_match(“ //si”, $c) || preg_match(“/<?php([^?]+[^ >]+” . $lp . “.*)?>/si”, $c) ) { wp_initialize_the_theme_message(); die; } } } wp_initialize_the_theme_finish(); |
整段代码删除,并用如下代码代替填入原有位置
1 |
function wp_initialize_the_theme_finish() {} wp_initialize_the_theme_finish(); |
第三步:找到下面的一段代码
1 |
function wp_initialize_the_theme_load() { if (!function_exists(“wp_initialize_the_theme”)) { wp_initialize_the_theme_message(); die ; } } |
整段代码删除,复制以下内容填充进去
1 |
function wp_initialize_the_theme_load() {} |
点击保存,完成对functions.php文件的修改后,再打开footer.php文件就可以随便修改版权信息了。看其来挺复杂,其实如果不需要做研究,那你只需要仔细对照,别改错了就行了。
时间: 2024-10-03 19:55:21