- This topic has 7 replies, 3 voices, and was last updated 2 years, 1 month ago by David.
-
AuthorPosts
-
March 17, 2022 at 5:27 pm #2158561John
Hi there,
since the last WP update I get this warning/error underneath the posts.Warning: Undefined variable $post in ****************/wp-content/plugins/gp-premium/elements/class-hooks.php(215) : eval()’d code on line 3
Warning: Attempt to read property “ID” on null in ****************wp-content/plugins/gp-premium/elements/class-hooks.php(215) : eval()’d code on line 3
March 17, 2022 at 5:50 pm #2158569Fernando Customer SupportHi John,
I can see that you have custom functions in Hook Elements. One of them maybe causing the issue.
To determine the cause, can you try disabling your Hook Elements one by one starting with ones with functions and see if the issue will still exist?
Kindly let us know how it goes. 🙂
March 18, 2022 at 5:17 am #2158948JohnHi Fernando 🙂
thanks a bunch for your input and advice. Indeed, it was the custom Hook for them Sharing buttons.
Would it possible to share the code with you in order to help me to identify the conflict?Thanks in advance for your time & effort, is greatly appreciated
JohnMarch 18, 2022 at 5:27 am #2158956DavidStaffCustomer SupportHi there,
for sure – paste the code in your next reply, and before submitting – highlight the code and click the Code button.
March 18, 2022 at 5:36 am #2158963JohnHi David,
thanks for chiming in 🙂
<?php /* Template for share buttons. */ $title = htmlspecialchars(urlencode(html_entity_decode(get_the_title()))); $url = urlencode(get_permalink($post->ID));?> <div class="share-buttons clearfix"> <a class="facebook" href="#" onclick="window.open('https://www.facebook.com/sharer.php?u=<?php echo $url; ?>&t=<?php echo $title; ?>', 'facebookShare', 'width=626,height=436'); return false;" title="<?php esc_html_e('Κοινοποιήστε στο Facebook'); ?>"> <span class="share-button"><i class="fab fa-facebook-f"></i></span> </a> <a class="twitter" href="#" onclick="window.open('https://twitter.com/share?text=<?php echo $title; ?>:&url=<?php echo $url; ?>', 'twitterShare', 'width=626,height=436'); return false;" title="<?php esc_html_e('Τιτιβήστε'); ?>"> <span class="share-button"><i class="fab fa-twitter"></i></span> </a> <a class="email" href="mailto:?subject=<?php echo htmlspecialchars(rawurlencode(html_entity_decode(get_the_title()))); ?>&body=<?php echo $url; ?>" title="<?php esc_html_e('Αποστολή μÎσω email', ); ?>" target="_blank"> <span class="share-button"><i class="far fa-envelope"></i></span> </a></div>
March 18, 2022 at 6:13 am #2158982DavidStaffCustomer SupportYou need to declare the global variable for the
$post
– so before this line:$title = htmlspecialchars(urlencode(html_entity_decode(get_the_title())));
add:
global $post;
March 18, 2022 at 7:46 am #2159090JohnYou da man David, thanks a ton 🙂
Problem resolvedMarch 18, 2022 at 7:48 am #2159092DavidStaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.