include_once file to wp_footer – not working

I’m working on a plugin that detects adblock users and puts up an ad wall (I’m sure you hate me now and don’t want this thing to work). Everything is going fine except my attempt to include an external file with some DIVs to the end of the body section with wp_footer. Anyway, here’s the code:

        my plugin info

function adsense_unblock_divs() {
    $asubHTML = "plugins_url('/html/adunblock.html',__FILE__ ))";
    echo include_once('$asubHTML');
add_action('wp_footer', 'adsense_unblock_divs');

   function adsense_unblock() {
wp_register_style('adunblock_CSS', plugins_url('/css/adunblock.css',__FILE__ ));
wp_register_script( 'adunblock_JS', plugins_url('/js/adunblock.js',__FILE__ ), array('jquery'));
    add_action('wp_enqueue_scripts', "adsense_unblock");

    /* Settings Page */

add_action( 'admin_menu', 'adsense_unblock_menu' );

function adsense_unblock_menu() {
    add_options_page( 'AdSense Unblocker Settings', 'AdSense Unblocker', 'manage_options', 'ADSU-123', 'adsense_unblock_options' );

function adsense_unblock_options() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    echo include_once('adsense_unblock_settings.php');


The very first function (“adsense_unblock_divs()”) is the issue here, it throws up these errors when the page loads:

Warning: include_once($asubHTML): failed to open stream: No such file or directory in /home/jtbennett1851/public_html/cheetos/wp-content/plugins/adsenseunblock/adsense_unblock.php on line 12

Warning: include_once(): Failed opening '$asubHTML' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/jtbennett1851/public_html/cheetos/wp-content/plugins/adsenseunblock/adsense_unblock.php on line 12

I’ve tried a couple different ways but simply couldn’t get it to work. The file definitely exists in the specified directory – I’m sure I’m doing something stupid here, but I can’t figure it out.

Hopefully someone will spot it easily and be kind enough to point it out!

Read more here: include_once file to wp_footer – not working

Leave a Reply

Your email address will not be published. Required fields are marked *