[英]Differences with WordPress function.php and footer custom linking?
[英]Editing function.php from a custom plugin in WordPress. Line of code prohibiting certain core functions?
我对编码还很陌生,我刚刚接管了WordPress网站,开发人员在该网站上设置了自己的插件来编辑主题之外的functions.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 '... <a href="' . get_permalink() . '">[Read 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
}
**}**
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.