- This topic has 19 replies, 3 voices, and was last updated 3 years, 1 month ago by
Tom.
-
AuthorPosts
-
December 2, 2019 at 9:06 pm #1090915
Kim
Hi there, I just saw in the log that we get a bunch of those notices:
[03-Dec-2019 05:01:43 UTC] PHP Notice: Trying to get property ‘ID’ of non-object in /home/wp/disk/wordpress/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()’d code on line 2
[03-Dec-2019 05:01:43 UTC] PHP Notice: Undefined variable: post in /home/wp/disk/wordpress/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()’d code on line 2Is this something to worry about? Anything I can do?
Many thanks in advance!
December 3, 2019 at 2:52 am #1091270David
StaffCustomer SupportHi there,
do you have any PHP functions in the GP Hooks Element?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 3, 2019 at 11:10 am #1092134Kim
Yes, I do. I think the issue is coming from this one:
<div class="wpsp-related-posts grid-container"> <h3>Das könnte Sie auch interessieren</h3> <?php if ( is_single() ) { $cats = get_the_category(); $cat = $cats[0]; } else { $cat = get_category( get_query_var( 'cat' ) ); } $cat_slug = $cat->slug; $list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' ); wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' ); ?> </div>
I use it to show related posts at the single blog pages. It’s from the forum.
December 3, 2019 at 11:13 am #1092139Kim
…or this one:
<?php $terms = get_the_terms( $post->ID, 'product_cat' ); if ( $terms && ! is_wp_error( $terms ) ) : if ( ! empty( $terms ) ) { echo '<span class="woo-custom-category">' . $terms[0]->name . '</span>'; }?> <?php endif;?>
It’s used to display the Categories of a product on archive pages.
December 3, 2019 at 1:46 pm #1092308David
StaffCustomer SupportI would think the second one is the issue – simplest way is to Quick Edit the element and Save as Draft and see if the notice disappears.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 3, 2019 at 8:02 pm #1092546Kim
Yes, the second one is causing the issue. Do you have any clue what could be the reason? It’s from this post:
https://generatepress.com/forums/topic/woocommerce-display-category-name-above-product-titel/
December 4, 2019 at 10:13 am #1093464David
StaffCustomer SupportCan you try changing this line:
if ( ! empty( $terms ) ) {
for:
if ( isset( $terms ) ) {
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 5, 2019 at 8:10 pm #1095316Kim
Hi David, unfortunately this doesn’t solve the issue. Do you have another idea?
December 6, 2019 at 9:58 am #1096146Tom
Lead DeveloperLead DeveloperCan you try replacing this:
wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' );
With this:
if ( is_object( $list ) ) { wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' ); }
I’m not seeing a
$post
variable (as per the second notice) – maybe a different hook?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 6, 2019 at 10:20 am #1096200Kim
Hi Tom, I’ve tested again and it is definitely coming from this one:
<?php $terms = get_the_terms( $post->ID, 'product_cat' ); if ( $terms && ! is_wp_error( $terms ) ) : if ( isset( $terms ) ) { echo '<span class="woo-custom-category">' . $terms[0]->name . '</span>'; }?> <?php endif;?>
December 6, 2019 at 8:05 pm #1096590Tom
Lead DeveloperLead DeveloperSo there you’re using
$post
, but it’s not defined.You can do this instead:
<?php $terms = get_the_terms( get_the_ID(), 'product_cat' ); if ( $terms && ! is_wp_error( $terms ) ) : if ( isset( $terms ) ) { echo '<span class="woo-custom-category">' . $terms[0]->name . '</span>'; }?> <?php endif;?>
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 7, 2019 at 4:12 am #1096801Kim
Thank very much your for the fix 🙂
December 7, 2019 at 4:17 am #1096804Kim
Sorry for asking again. This is another issue I just saw:
PHP message: PHP Warning: array_key_exists() expects parameter 2 to be array, bool given in /home/wp/disk/wordpress/wp-content/plugins/gp-premium/typography/functions/migration.php on line 170
Is it Theme-related or a Hosting issue?
Best regards!
December 7, 2019 at 9:38 am #1097164Tom
Lead DeveloperLead DeveloperHmm, I’m assuming it’s a hosting issue as no one else is experiencing that issue. Parameter 2 in that case should definitely be an array.
Are you using the
generate_number_of_fonts
anywhere?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 7, 2019 at 12:03 pm #1097249Kim
No, actually this one is not in use
-
AuthorPosts
- You must be logged in to reply to this topic.