0

I am working with a third party API for events, the results of the GET request I've written are rendered/displayed at this URL (inside the SDK folder):

https://example.com/skiddle-php-sdk-master/demo/result.php

I need to embed these results into specific pages dynamically, so I've used a PHP shortcode embed plugin to allow me to echo the file contents onto the page. I have tested this using:

<?php
echo "hello world";
?>

And this displays correctly when using the shortcode. So I have the results of the GET request in the results.php file and the ability to embed PHP directly in the page using a shortcode (rather than creating/editing templates in multiple places).

I am now trying to use: echo file_get_contents or include to render the results.php file onto the page using the following code:

<?php
echo file_get_contents("/skiddle-php-sdk-master/demo/result.php");
?>

But I get a file path warning:

Warning: file_get_contents(/skiddle-php-sdk-master/demo/result.php): failed to open stream: No such file or directory in /home/customer/www/example.com/public_html/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(97) : eval()'d code on line 2

I believe this indicates that for some reason the shortcode plugin is expecting the results.php file to be inside the subdirectory of the plugin which it isn't and shouldn't be for obvious reasons.

I've tried things like this:

/../../skiddle-php-sdk-master/demo/result.php

to no avail. Can anyone help me to understand how I can return the content of results.php using this process?

1
  • 2
    That plugin should be considered dangerous and a dead end, anything that lets you enter and store PHP via WP Admin into the database or write to arbitrary files is a major security risk. Instead you should register shortcodes the normal way and upload the PHP file, either by modifying your themes functions.php or by turning it into a plugin ( aka put a comment at the top of the file with the plugin name and drop it in the plugins folder)
    – Tom J Nowell
    Jan 9, 2022 at 3:39

1 Answer 1

0

Apparently single quotes are a thing in this scenario, this now returns the results.php file contents:

<?php
echo include('skiddle-php-sdk-master/demo/result.php');
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.