0

I have a wp plugin that I am using to inject the php file for the cookie banner along with the styling. It has been working up until recently not sure if this has been a persistant bug however it is no longer adding the html to the footer. It is however still adding the styling etc.

The function I have used to insert the html from a secondary php file in the plugin directory is as follows:

function cookie_callback()
{
    $asubHTML = file_get_contents(plugins_url('/views/cookie-banner.php', __FILE__));
    echo $asubHTML;
}
add_action('wp_footer', 'cookie_callback');

Could someone assist on this issue as I am a little miffed as to why its suddenly broken.

Loading the html directly in the footer works perfectly but I would want to decouple the inline html from the site outside of the plugin ideally.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
xDE4DSH0Tx
  • 33
  • 4
  • Replace the echo with `var_dump($asubHTML);`, and see what that gets you. If you don't see any output from this anywhere, then likely your function did not get called to begin with. If it shows false or an empty string, then your `file_get_contents` call likely failed. Have you enabled WP debug mode already? – CBroe May 26 '23 at 07:06
  • Just enabled debug and seeing these errors now in relation to the file_get_contents : file_get_contents($filename = 'https://customer-marketing-dev.local/wp-content/plugins/cookie-consent-banner/views/cookie-banner.php') /Users/Ruairi/Local Sites/customer-marketing-dev/app/public/wp-content/plugins/cookie-consent-banner/cookie-consent-banner.php:33 PHP Warning: file_get_contents(): Failed to enable crypto in /Users/Ruairi/Local Sites/customer-marketing-dev/app/public/wp-content/plugins/cookie-consent-banner/cookie-consent-banner.php on line 33 – xDE4DSH0Tx May 26 '23 at 08:36
  • [OPENSSL file_get_contents(): Failed to enable crypto](https://stackoverflow.com/q/14078182/1427878) – CBroe May 26 '23 at 08:44

0 Answers0