- This topic has 6 replies, 3 voices, and was last updated 6 months, 3 weeks ago by
Tom.
-
AuthorPosts
-
August 14, 2020 at 10:01 am #1402987
Steven
Haven’t run into this before today. Not sure what changed. We did quite a bit of testing before, but it seems it might be related to previewing a post before it’s published.
Fatal error: Uncaught Error: syntax error, unexpected ‘s’ (T_STRING)
in /nas/content/live/bhamprod/wp-content/plugins/gp-premium/elements/class-hooks.php(196) : eval()’d code on line 3Call stack:
GeneratePress_Hook::execute_hook()
wp-includes/class-wp-hook.php:287
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:311
WP_Hook::do_action()
wp-includes/plugin.php:478
do_action()
wp-content/themes/generatepress/single.php:22
include()
wp-includes/template-loader.php:106
require_once()
wp-blog-header.php:19
require()
index.php:17August 14, 2020 at 10:03 am #1402990Leo
StaffCustomer SupportHi there,
Looks like there is a code error in one of the hook element.
Can you try disabling them first?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/August 14, 2020 at 11:38 am #1403126Steven
Thanks for the lead, Leo. We’ve narrowed it down to the following element:
Hook = generate_before_main_content
Execute shortcodes = selected
Execute PHP = selected<?php $start = '<div id="cob-breadcrumb-header" aria-label="You are here breadcrumb navigation"><i class="fas fa-home"></i> '; $breadcrumb = '(wpseo_breadcrumb) //placing parenthesis instead of brackets as support forum won't allow shortcodes'; $breadcrumb = htmlentities($breadcrumb); $end = '</div>'; if ( generate_show_title()) { echo $start . $breadcrumb . $end ; } ?>
When a post category includes an apostrophe (e.g. Mayor’s Office), the fatal error occurs. When there’s no apostrophe, the element works as expected. We tried adding the htmlentities to the $breadcrumb variable to try to deal with the apostrophe, but it didn’t seem to make a difference.
If we’re understanding the error message correctly, the following section is where it’s getting hung up in class-hooks.php:
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) { ob_start(); eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP. echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary. } else { echo $content; // phpcs:ignore -- Escaping not necessary. } }
Here’s a link to our dev site so you can continue to see the error since we need to remove the link originally added to this topic as it’s on our production site.
August 14, 2020 at 11:43 am #1403134Steven
Here’s an example of a post without the apostrophe in its category if that helps:
August 14, 2020 at 12:31 pm #1403173Tom
Lead DeveloperLead DeveloperTry this, instead:
<?php $start = '<div id="cob-breadcrumb-header" aria-label="You are here breadcrumb navigation"><i class="fas fa-home"></i> '; $end = '</div>'; if ( generate_show_title()) { echo $start . do_shortcode( '(wpseo_breadcrumb)' ) . $end ; //placing parenthesis instead of brackets as support forum won't allow shortcodes } ?>
Then un-check the Execute Shortcodes option.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 14, 2020 at 1:23 pm #1403254Steven
That did the trick – THANK YOU!
August 14, 2020 at 2:24 pm #1403307Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.