2017-12-19 10 views
0

これはいくつかのバナーを削除する関数ですが、if(!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

関連する問題