2017-12-19 2 views
0

이것은 일부 배너를 제거하는 함수입니다. 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; 
} 
+0

문제는이 라인이 "만일 (!와 in_array ($ current_screen-> post_type, $ post_types)) {" – Ranjit

+0

문제는 무엇인가? 몇 가지 시도했지만 오류가있어 – viscosho

+0

$ current_screen-> post_type 및 $ post_types 모두 인쇄 해 볼 수 있습니까? 문제를 볼 수 있습니다. 비 객체에서 데이터를 가져 오려고했습니다. – Ranjit

답변

0

아래 링크를 확인하고 코드를 변경하십시오.

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

<?php 

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


?> 
+0

그런 변수를 정의하면 내 사이트가 손상됩니다. – viscosho

+0

var_dump ($ current_screen)를 실행하고 결과를 확인하십시오. –

+0

나는 약간의 NULL을 얻는다. – viscosho

관련 문제