• Resolved abstractic

    (@abstractic)


    Hi,

    I get an error message on my home page that says:

    Notice: Trying to get property of non-object in /Library/WebServer/Documents/wordpress/wp-includes/comment-template.php on line 932

    I located the error to your plugin and the function comments_open(), which you check in two places, one when you add CSS files and one when you add JavaScript files.

    if ( comments_open() && is_singular() && ( $options['comments'] != '0') && !is_null($options['comments']) ) {
                    $this->add_styles();
                }
    
    if ( comments_open() && is_singular() && ( $options['comments'] != '0') && !is_null($options['comments']) ) {
                    $this->add_scripts();
                }

    I suspect that the error is caused because you are trying check for comments on the home page, which do not use comments in this case.

    Here are some details that might be useful for you:

    PHP 5.3.2
    WordPress 3.7.1
    BBPress 2.5.1

    Thanks

    https://www.ads-software.com/plugins/basic-comment-quicktags/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I just tested on 3.7.1 with PHP 5.3 without errors. Then I added in bbPress and it still worked as expected.

    The way the comments check works is that if there are no comments the code isn’t called. What you’re seeing implies that one is not even able to check for comments at all on a page that has none, which would be illogical ?? (Also some front pages do have comments (like p2 blogs)).

    Are those really all your plugins?

    What’s your theme?

    Did you check the boxes to show the code on WP? (To be honest, I should just remove it for the bbPress options, since that’s built in there now…)

    Thread Starter abstractic

    (@abstractic)

    I had a closer look at your code and I can’t really see anything wrong with it, but I can see an error in the WordPress code on the line which generates the error.

    $open = ( ‘open’ == $_post->comment_status );

    They don’t even check if the comment status is set, before they are trying to use it? In my case the post ID is empty, so it returns nothing, because it is on the home page and I have nothing on the home page, except some custom widgets.

    I built my own theme and in this case I use a child theme for the bbPress plugin and the only plugins that are active right now, is bbPress and Basic Comment Quicktags. To note is that the normal comments option is not even activated, only the option for bbPress comments, but works nicely with both, so no comments there.

    I really like your plugin and I use it for my bbPress solution, just because it is neat, clean and it doesn’t bloat the source code with a lot of unnecessary inline JavaScript and other bad things like adding a stylesheet file in BODY source ??

    Thanks anyway.

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    bbPress, FWIW, has it’s own quicktags built in (and on by default). I just updated my plugin to check for that better (if you have their fancy comments on, mine is disabled).

    $open = ( 'open' == $_post->comment_status );

    That’s not wrong… And your post ID being empty shouldn’t matter, because my code won’t get called on a non-static front page. Go look at ipstenu.org – I have BQQ on and the plugin is NOT active on my normal front page.

    What theme are you using here?

    Thread Starter abstractic

    (@abstractic)

    I got rid of this error on my home page, but recently discovered the same error on my 404 page, so I managed to track down what causes the error.

    Both the home page and the 404 page are not a singular page, and in my case and in probably many other cases these two pages have neither blog posts or a singular post visible as a part of its content, so there’s not a post ID available and therefore the generated error.

    If you swap the attributes in your if statement, the error goes away “comments_open() && is_singular()“, like this “is_singular() && comments_open()“, and that might help removing this error in a case similar to mine.

    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    That doesn’t make sense, since it’s an AND check. So either way, it’s always checking both. Or should be. Unless it’s saying “oh this failed, so will that, I’ll skip it….”

    Which I suppose would happen but is weird. The bool check should fail, since if there’s no page ID there are no comments, so that would be a false.

    (Also never seen the error on my own sites with debugging on and the default themes. What theme is this?)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to get property of non-object’ is closed to new replies.