- This topic has 6 replies, 3 voices, and was last updated 3 years, 8 months ago by Tom.
-
AuthorPosts
-
August 14, 2020 at 10:01 am #1402987Steven
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 #1402990LeoStaffCustomer SupportHi there,
Looks like there is a code error in one of the hook element.
Can you try disabling them first?
August 14, 2020 at 11:38 am #1403126StevenThanks 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 #1403134StevenHere’s an example of a post without the apostrophe in its category if that helps:
August 14, 2020 at 12:31 pm #1403173TomLead 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.
August 14, 2020 at 1:23 pm #1403254StevenThat did the trick – THANK YOU!
August 14, 2020 at 2:24 pm #1403307TomLead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.