从WordPress中的自定义插件进行编辑函数.禁止某些核心功能的代码线



我是编码的新手,我只是接管了一个WordPress网站,开发人员在该网站上设置了自己的插件来编辑主题之外的function.php文件。似乎有一系列代码在WordPress中打破某些核心功能,例如:安装新插件失败,无法搜索主题,并且媒体库没有加载。但是,如果我停用了此插件,所有这些功能都重新栩栩如生,但是站点的某些部分布局中断而无需插件。那么谁能告诉我如何修复此代码?非常感谢您。

<?php
/* Your code goes below here. */
ob_start();
function check_user_logged_in(){
if ( is_user_logged_in() ) { ?>
<style  type="text/css" media="screen">
#theme-my-login-2 .widget-wrap .widget-title { display: block !important; }
</style>
<?php
}
else{ ?>
<style  type="text/css" media="screen">
table.sidebar_result{margin-top:-10px;}
</style>
<?php
}
}
// Something is wrong with this next line of code. Can't find new themes or install new plugins. When removed everthing works ok.
add_action('init', 'check_user_logged_in');
// Add Read More Link to Excerpts
add_filter('excerpt_more', 'get_read_more_link');
add_filter( 'the_content_more_link', 'get_read_more_link' );
function get_read_more_link() {
return '...&nbsp;<a href="' . get_permalink() . '">[Read&nbsp;More]</a>';
}
//* Display a custom favicon
add_filter( 'genesis_pre_load_favicon', 'sp_favicon_filter' );
function sp_favicon_filter( $favicon_url ) {
return 'http://winningsportsplays.com/wspwp/wp-content/favicon.ico';
}
/* Your code goes above here. */
?>

代码本身对我来说很好。我的猜测是,通过" init"初始化函数是在某种程度上引起与某些核心文件的冲突。

尝试更改此问题:

add_action('init', 'check_user_logged_in');

add_action('wp_head', 'check_user_logged_in');

看看是否解决了问题。

if (!is_admin()) {}添加到代码中似乎有效,但是正确吗?

ob_start();
function check_user_logged_in(){
**if (!is_admin()) {**
if ( is_user_logged_in() ) { ?>
<style  type="text/css" media="screen">
#theme-my-login-2 .widget-wrap .widget-title { display: block !important; }
</style>
<?php
}
else{ ?>
<style  type="text/css" media="screen">
table.sidebar_result{margin-top:-10px;}
</style>
<?php
}
**}**
}

最新更新