• Resolved alebec

    (@alebec)


    There is an php notice in this file

    function fca_qc_live_preview( $content ){
    	global $post;
    	if ( is_user_logged_in() && $post->post_type === 'fca_qc_quiz' && is_main_query() && !doing_action( 'wp_head' ) )  {
    		return $content . do_shortcode("[quiz-cat id='" . $post->ID . "']");
    	} else {
    		return $content;
    	}
    }

    Notice: Trying to get property ‘post_type’ of non-object

    can you please fix it ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support gavinohanlon

    (@gavinohanlon)

    Hi Alebec,

    Thanks for reaching out to us and bringing this to our attention.

    Could you let us know what you were trying to do when you found this error so we can replicate it?

    Looking forward to your response.

    All the best.

    Plugin Support gavinohanlon

    (@gavinohanlon)

    Hi Alebec,

    I am going to mark this as “resolved” but if you have any more issues, feel free to reach out to us again.

    All the best.

    @gavinohanlon it is not a good idea to mark an issue resolved while it is not.

    The notice says:

    > Trying to get property ‘post_type’ of non-object

    So it is clear that the $post global object is empty, and the piece of code that uses the variable is not defensive enough – it does not check if the $post is non-empty. You should add the check to the code and make it fail gracefully without notices if the $post global is empty.

    There is no need to reproduce this issue in order to fix it, as the reason that leads to the issue is seen in the code directly.

    Hope this helps,

    Anton

    Plugin Support gavinohanlon

    (@gavinohanlon)

    Hi Meglio,

    Thanks for contacting us about this topic.

    We will be looking to address this issue in our next release of Quiz Cat.

    All the best.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP notice in /includes/editor/editor.php:626’ is closed to new replies.