Trying to get property ‘comment_ID’ of non-object
-
When posting a comment as a guest, the following warning appears. It seems that display_attachment filter is applied for both new comments before saving to the DB during a POST request and for existing ones via GET.
<code>Notice: Trying to get property 'comment_ID' of non-object in /var/www/html/wp-includes/comment-template.php on line 677 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 577 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 578 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 579 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/pluggable.php on line 1340 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/pluggable.php on line 1343
Hacky solution for init_hooks():
if ( $_SERVER['REQUEST_METHOD'] === 'GET' ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); if ( $this->is_attachment_displayed() ) { add_filter( 'comment_text', array( $this, 'display_attachment' ) ); } if ( $this->get_option( 'autoembed_links' ) && ! is_admin() ) { add_filter( 'comment_text', array( $this, 'autoembed_links' ), 5 ); } }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Trying to get property ‘comment_ID’ of non-object’ is closed to new replies.