I am using this plugin on multiple sites and for some reason on 2 of the sites I’m now getting an error: Connection timed out in /srv/htdocs/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 3
and
PHP Warning: Trying to access array offset on false in /srv/htdocs/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 8
The plugin then prevents any page using its shortcode from loading. I tried disabling “Enabling automatic exception handling for PHP snippets” but that had no effect.
]]>We have a lot of snippets.
I know one has an error, but how do I find out which snippet is the one with the problem?
[16-Jun-2024 09:21:42 UTC] PHP Warning: ?Undefined variable $correct_score in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(100) : eval()’d code on line 17
I have no idea which snippet has $correct_score.
]]>Hello
I’d be grateful if anyone has a solution to the following email I received about a fatal error with the plugin please.
WordPress has a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.
In this case, WordPress caught an error with one of your plugins, Insert PHP Code Snippet.
WordPress version 6.5.3
Current plugin: Insert PHP Code Snippet (version 1.3.5)
PHP version 8.1.28 Error Details
An error of type E_PARSE was caused in line 8 of the file …/public_html/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(100) : eval()’d code. Error message: syntax error, unexpected token “||”
Thank you for your time.
Regards, Ash Whitney
I am working on a multisite. The plugin is working fine on all 4 initial sites for 2 years now.
Now I have to add another site (language) and there the plugin fails to add PHP Code Snippets.
After creating a new PHP Code Snippet, the green bar appears with the message: “PHP Snippet successfully added” but nothing shows up in the listing of the snippets. Even with the most simple calls like ‘get_the_date();’.
I’m basicaly copying the working snippets from one of the other sites in the multisite network, so an error in the creation of the snippets should not be the problem.
Also the search for a tracking name returns no results.
When trying to print HTML it adds <br> on every line jump.
So having this in PHP Code Snippets:
echo '
<li>
<a href="">
Test
</a>
</li>
';
Will result in this:
<a href="">
<br>
Test
<br>
</a>
How can we avoid it?
]]>I just bought and upgraded to the pro version because I need the line numbers and color-parser, but line-wrap is not working in the editor so long lines force the entire snippet editor page incredibly wide, wider than my 4k screen. A: this needs fixing in your plugin. B: where do I add line wrap to the css or the code for a quick fix… I have a lot of work to do today.
]]>“Keep it simple stupid” is a rule to live by. But who doesn’t love some extras sometimes? No complaints here – but I do have ideas to push this great plugin to another level and maybe others have some too so chime in.
Line numbers… line numbers that line up with error log messages… color parsing… point to external script file so I could work with my favorite code editor… easy way to change default editing window size…
Never mind, I just noticed there’s a “fully featured” version for $20 so I’ll get that. It just looked like a random ad at the bottom of the page so I ignored it.
]]>The file ‘….\wp-content\plugins\insert-php-code-snippet’ gives a persistend warning ‘Warning: Attempt to read property “ID” on null in /customers/5/3/b/bijbelngt.nl/httpd.www/wordpress/wp-content/plugins/insert-php-code-snippet/xyz-functions.php on line 76′. How can I suppress that warning? Or how can I correct that problem?
]]>Hello!
Sometimes I get this error:
E_ERROR was caused by line 3 of the file /wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()’d code. Error: Cannot redeclare getWaterLevel() (previously declared in /wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()’d code:3)
Here is the code I try to insert:
<?php
function getWaterLevel($data, $stationName) {
foreach ($data as $entry) {
if ($entry->Station == $stationName) {
return $entry->{'Water Level (cm)'};
}
}
return null;
}
// The URL containing the JSON data
$url = "https://example.com/water_data.json";
// Use file_get_contents to fetch the contents of the URL
$response = file_get_contents($url);
// Check if the request was successful
if ($response !== false) {
// Use json_decode to parse the JSON data into a PHP object
$data = json_decode($response);
if ($data !== null) {
// Test the function
$stationName = "SomeStation";
$waterLevel = getWaterLevel($data, $stationName);
// Print the result
echo $waterLevel;
} else {
// Print an error if the JSON could not be parsed
echo "Error: Could not parse JSON data.";
}
} else {
// Print an error if the request was unsuccessful
echo "Error: Could not fetch data from the URL.";
}
?>
What could cause this?
I have to delete the autosaved version in wp_post table in order to be able to open and edit the page!
Kind Regards!
No data is returned on my posts/pages with ACF custom fields and WP code snippets after php 7.4. No error is thrown it just stops working starting with 8.0. Other than that everything functions. Any suggestions?
]]>I’m getting this error while using the plugin with latest WordPress version and PHP 8.2.x:
PHP Warning: Attempt to read property “ID” on null in /home/mmcedizioni.it/public_html/wp-content/plugins/insert-php-code-snippet/xyz-functions.php on line 76
Is this plugin still maintained? if yes, can you please fix this?
]]>Hello, 2 years without update ! Is this plugin abandoned ?
]]>I implemented “php” code in page using [/shortcode]
i broke down my code to a minimum.
Issue: as soon i insert data the the field “name” and i submit the form the target page will not be found, as long the field remains empty, submitting will be successfully
<?php
?>
<form action="" method="post">
<input type="text" name="name">
<input type="submit" value="Formular absenden">
</form>
</body>
</html>
]]>
Hi there
I have been using this wonderful script for a number of years, actually with no problem to insert some 2, 3 php scripts in some pages to pull some content from external sites.
I have just noted the pages with it have the error message
“There has been a critical error on this website.”
and almost all the page content does not load, with a skeleton of the theme and upper menu and in some cases just the WordPress error text on a white page, no theme loaded. All other site pages, as you will note load normally, including those generated by some plugins, which is probably in case the problem has been there for long why I did not notice it. I have no idea what could be triggering it.
I have WordPress and all plugins always automatically updated and so everything is. Theme: Spacious. I tried other themes, twentythirteen & fifteen, but it made no difference.
In the Plugin settings, if I preview any of the snippets, such as:
<?php
include($_SERVER['DOCUMENT_ROOT']."/giveaway/single.php");
I get the same error “There has been a critical error on this website.“
What could be causing this? Actually some of the sites most visited pages have this script and so I request you to help me solve the problem as soon as possible, for which I would be very grateful.
Kind regards
]]>Is this plugin version 1.3.3 is compatible with wordpress version 6.0.3 and 6.0.5? With wordpress version 6.0.5, we encountered the CPU utilization reaches to 90% and more if this plugin is enabled
]]>Hi all,
my code snippets are suddenly not replaced anymore since 2 days, on all of my websites. The strange thing is that no updates were done, so I’m afraid it’s a server-related issue.
So, my question is which change can trigger this. No error is appearing, the “Snippet-token” is just not replaced by the related code.
I already opened a ticket at the hosting-company.
]]>I’m trying to call a woocommerce hook via add_action. This code works like a charm if inserted directly into functions.php. However, it doesn’t execute if used within XYZ PHP.
Any recommendations for a pretty unexpirienced PHP beginner as why this is the case? Do I have to put the shortcode calling this at a particular part of the frontend in order for it to work? Does add_action not work at all with XYZ? Thank you!
]]>add_action(‘woocommerce_after_shop_loop_item_title’, ‘display_artist_link_grid’, 9 );
function display_artist_link_grid() {
$artist_link = get_field(‘artist_link’);
if ($artist_link) {
$title = $artist_link[‘title’];
$url = $artist_link[‘url’];
echo ‘‘ . esc_html($title) . ‘‘;
}
}
I am getting an error when trying to add the “use” statement when working with namespaces. I have a file, snippet.php, that contains:
<?php
namespace Foo;
class Bar
{
public function __construct()
{
echo "This is Foo\Bar::__construct().<br/>\n";
}
}
Then in XYZ PHP Code, I create a snippet like this:
<?php
ini_set('display_errors', 1);
include_once "/home/[username]/public_html/snippet.php";
$bar = new Foo\Bar();
This works. However, when I attempt to add a “use” statement in the snippet code instead of the Foo prefix:
<?php
ini_set('display_errors', 1);
require_once("/home/[username]/public_html/snippet.php");
use Foo\Bar;
$bar = new Bar();
Then I get an “unexpected token” error:
Parse error: syntax error, unexpected token “use” in /home/[username]/public_html/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()’d code on line 4
There has been a critical error on this website.
Does anyone know what the issue here is? Is there some conflict with this plugin and “use” statements? Can you use “use” statements with this plugin?
I have WordPress 6.1.1, and PHP Code Snippet 1.3.3.
]]>Hello! I am new here. This shows up on my published site, would like to remove it. Thank you
Warning: usort() expects parameter 2 to be a valid callback, function ‘date_compare’ not found or invalid function name in?/home/customer/www/uhwa.org/public_html/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()’d code?on line?8
]]>Good morning,
on the Cloudways server I unfortunately get the following error. How can I fix?
PHP Warning: Undefined property: SoapFault::$AuthCookie in /home/933587.cloudwaysapps.com/ktuaskymfa/pub…………lic_html/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.php(268) : eval()’d code on line 6′, referer: https://wordpress-933587-3243427.cloudwaysapps.com/wp-admin/admin.php?page=wpcode-snippet-manager&snippet_id=10
]]>I’m getting an error message “Trying to get property ‘ID’ of non-object” for plugins/insert-php-code-snippet/xyz-functions.php on line 76.
Please tell me why this error and how to fix it?
WordPress 6.1.1
PHP 7.4 (ea-php74)
I need help.
When I clicked the plugin, I received below error message:
“There has been a critical error on this website. Please check your site admin email inbox for instructions.”
WordPress version: 6.1
This happened after I updated my WordPress. The plugin crashed right after the update, does it not support the latest version of the WordPress?
]]>I am having trouble concatenating multiple calls for custom fields into a line of text. I can only get one instance per line to work correctly.
Here is my working code:
<?php
echo '<div class="wp-block-buttons"><div class="wp-block-button has-custom-width wp-block-button__width-100 is-style-secondary">
<a class="wp-block-button__link" href="';
echo the_field('download_link').'" rel="noopener" target="_blank">Download ';
echo the_title().' Faceset</a></div></div>';
As you can see I’ve broken it into multiple echo statements. When I use more than one ‘.’ in a line then the block does not display. I’ve tried using a variable or escaping with {} but it just renders the function as text. In my testing it seems to be a problem with any line that has a leading ‘.’. In my example I only use a trailing ‘.’ and the block renders correctly.
How can I concatenate this statement into a single line? Is my format incorrect or is it a plugin issue?
]]>description and sort
It would be convenient to be able to register a description in the script list. Because I have a lot of code.
Also, it would be helpful if you could group or sort
]]>This would be very useful to make everything easier for the client to edit, if it were possible to define by ROLE.
thxxx
]]>Hi,
I installed the plugin and it runs fine with PHP 7.4. But not working when I switched to PHP 8.0
Can you tell me how this plugin works with PHP 8.0??
Or I have to search for another plugin??
It’s urgent!!!
Thanks
Manpreet
Firstly, I don’t code. I’m using Elementor and Woocommerce and I wanted to place product dimensions on a product single template the way I wanted, not the way the editors allowed me to.
I found this simple code snippet, added it to functions.php, then pasted the function name with the php tags into plugin’s shortcode editor, then added the shortcode to the Elementor shortcode widget and hit update.
Everything looks great, the dimensions are displayed on the front-end, but when I reload the product single template in Elementor, it gives me an “error 500”. On the debug page it says this:
Fatal error: Uncaught Error: Call to a member function has_dimensions() on null
If I use the shortcode in Gutenberg, the same error occurs.
I’ve used your plugin with a standard Woocommerce function “<?php woocommerce_breadcrumb(); ?>” and it works perfectly, without any errors.
What am I doing wrong?
Here’s the code that is used for the shortcode:
function show_dimensions() {
global $product;
$dimensions = $product->get_dimensions();
if ( ! empty( $dimensions ) ) {
echo '<div class="dimensions"><b>Height:</b> ' . $product->get_height() . get_option( 'woocommerce_dimension_unit' );
echo '<br><b>Width:</b> ' . $product->get_width() . get_option( 'woocommerce_dimension_unit' );
echo '<br><b>Length:</b> ' . $product->get_length() . get_option( 'woocommerce_dimension_unit' );
echo '</div>';
}
}
]]>
I have an index.php that we have to put in a normal page of wordpress.
Someone can help me with this?.
My idea was, with this plugin, insert de index.php with a shortcode in the normal page. But, something is wrong with that.
]]>I exported the plugin from the live site, so I can keep a local backup, but I’m getting errors on all of the pages where I’m using the plugin. Can you help with this, please?
Warning: Undefined variable $post in C:\xampp\htdocs\testsite\wp-content\plugins\insert-php-code-snippet\shortcode-handler.php(99) : eval()’d code on line 1
Warning: Attempt to read property “ID” on null in C:\xampp\htdocs\testsite\wp-content\plugins\insert-php-code-snippet\shortcode-handler.php(99) : eval()’d code on line 1
]]>The plugin is giving me this warning message, one for every code snippet that I have.
“Warning: Attempt to read property “ID” on null in C:\Software\WampServer\www\Wordpress\wp-content\plugins\insert-php-code-snippet\xyz-functions.php on line 76″
The site and the snippets are working fine, but I am no longer able to use the “preview page” functionality that the plugin includes.
I installed Composer and then had this issue, but I don’t think that it is the problem because it saved in a different location and uninstalling Composer and restarting WAMP did not fix the issue.
]]>