Custom widget HTML errors

Posted in: Newspaper
Post count: 3

Hi, I am using HTML widgets for PHP and this worked as a charm so far but since the last Newsletter Update it shows me errors in my code and it doesn’t let me save the widget.

Is there a way to disable this in Newspaper Theme pls? I know my code is ok!

  • This topic was modified 8 years by eklisiarh.
Post count: 22421

Hello,

I’m not sure what to disable. What is the code? what is the error? Please provide more details

Thank you!

Post count: 3

In the custom HTML widget I use PHP to fill the info from the forms. Here is what I do:

I add following code to the functions.php:

add_filter('widget_text','execute_php',100);
function execute_php($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
}

Than I use Advanced Custom Fields plugin to gather data in forms and I add these to HTML widget with this code:

<?php global $wp_query;
if(is_object($wp_query->queried_object) && $wp_query->queried_object->ID)
{
echo get_post_meta($wp_query->queried_object->ID, 'gtelefonnummer', true);
}
?>

My problem is: Since the last theme update I cannot save this code in HTML widget anymore because there are errors (which are not errors but PHP code).

So where I already saved this code everything works well but I cant save any new code because system doesn’t let me to do this. Here is screenshot:

Since widgets are theme related I presume you changed something so that I cant save this. Can this be disabled and how?

  • This reply was modified 8 years by eklisiarh.
  • This reply was modified 8 years by eklisiarh.
Post count: 3

Ok I solved this myself or to be precise: This is not a problem caused by Newspaper Theme but a new thing in WordPress 4.9. They decided to implement new code-checker which prevents any code with “errors” to be saved in widgets…

Anyway solution is installing Enhanced Text Widget, if someone else reads this.

  • This reply was modified 8 years by eklisiarh.
Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.