获取此错误“尝试获取非对象的属性”的函数

问题描述 投票:0回答:1

这是删除一些横幅的功能,我知道错误发生在if(!in_array($ current_screen-> post_type,$ post_types)),但我不知道要正确修复它。

function lsx_tec_disable_lsx_banner( $disabled ) {
    global $current_screen;
    $post_types = apply_filters( 'tribe_is_post_type_screen_post_types', Tribe__Main::get_post_types() );
    if ( ! in_array( $current_screen->post_type, $post_types ) ) {
        $disabled = true;
    }
    if ( is_null( $id ) && false !== strpos( $current_screen->id, 'tribe' ) ) 
    {
        $disabled = true;
    }
    if ( is_single() && tribe_is_event() ) {
        $disabled = true;
    }
    return $disabled;
}
php wordpress function object plugins
1个回答
0
投票

请检查以下链接并更改您的代码。

https://codex.wordpress.org/Function_Reference/get_current_screen

<?php

    $current_screen = get_current_screen(); // use this instead of global $current_screen;


?>
© www.soinside.com 2019 - 2024. All rights reserved.