• Hi Will – thank you so much for your plugin! And your work in supporting it. Very grateful.

    I tried a simple include:
    [insert_php] include(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”); [/insert_php]

    this is insertphp01.php:
    <div class=”quote”>Need some guidance? Download right now: Top Ten Tips for Optimum Health on a Raw Plant Diet.</div>

    and I get this error message:

    Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/eatsprou/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 1

    Warning: include(http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php): failed to open stream: no suitable wrapper could be found in /home/eatsprou/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 1

    Warning: include(): Failed opening ‘http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php’ for inclusion (include_path=’.:/usr/local/php56/pear’) in /home/eatsprou/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 1

    I tried this:

    [insert_php]
    $string = “PHP code to test”;
    echo $string;
    [/insert_php]

    and it works, displays in browser window as the words: PHP code to test

    Any ideas why my include does not work? It’s the only reason I need to use php, is so that I need alter just one file (the include) when I want the text on every post to change.

    thank you! – Val

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Val,

    It looks like the PHP configuration doesn’t have URL include wrappers enabled. Info:

    http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-include

    If the content you’re pulling in has no PHP code and won’t have PHP code in the future, then my Insert Here plugin from
    http://www.willmaster.com/software/WPplugins/insert-here-wordpress-plugin.php
    could be used.

    But if the pulled-in content does or might in the future have PHP code:

    If the include file is on the same domain, this might work:

    /* Forum may break the line, but needs to be all one line. */
    include("{$_SERVER['DOCUMENT_ROOT']}/wp-content/themes/1green/1cde/insertphp01.php”);

    On the other hand, if it has PHP code and you must use a URL to obtain the file (like if it’s from a different domain), then you might put a separate PHP script on your server, something like this:

    <?php
    echo include(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”);
    ?>

    And insert it into your post or page using Insert PHP and

    /* Forum may break the line, but needs to be all one line. */
    include("{$_SERVER['DOCUMENT_ROOT']}/directory/script.php”);

    Have a wonderful rest of the weekend.

    Will

    Oops, sorry, that second example won’t work.

    You could try

    <?php
    echo file_get_contents_(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”);
    ?>

    If that won’t work, then perhaps use cURL.

    Will

    Thread Starter valarcher

    (@valarcher)

    Hi Will –

    > It looks like the PHP configuration doesn’t have URL include wrappers enabled

    thank you! I’ll ask tech support if they can do that because I don’t have a php.ini in my root

    I tried these two:

    [insert_php]
    echo file_get_contents_(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”);
    [/insert_php]

    [insert_php]
    echo include(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”);
    [/insert_php]

    and get a single error message:

    Parse error: syntax error, unexpected ‘:’ in /home/eatsprou/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 2

    What I’d really love to do is use shortcodes, but the plugin everyone recommends – Global Content Blocks plug-in – is no longer available.

    I’m looking at these pages:
    http://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/
    http://pastie.org/9454401
    http://www.problogdesign.com/wordpress/working-with-wordpress-shortcodes/

    but don’t know enough about php to write the function that will display the contents of “insertphp01.php” when I enter [shortcode-name] into the post.

    Do you perhaps know how to do this?

    thanks million, Val

    OK, looks like the echo file_get_contents(…) won’t work for you.

    If you’re only wanting to insert the content of
    http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php
    then you can use the Insert Here plugin I linked to previously. With the plugin installed and activated, this will pull in the content:

    
    [insert_here url="http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php"]
    

    Will

    • This reply was modified 9 years, 4 months ago by WillBontrager.
    Thread Starter valarcher

    (@valarcher)

    Hi Will – insert_here works beautifully, thank you! I’ll paypal a donation. It’s not huge (I live in Africa) but my philosophy is anything is better than nothing!

    Could I just copy the contents of “insert_here.php” into my functions.php file so I know it will never break? I’m scared if you ever stop updating it, then I’ll be in big trouble down the road because I’m adding it twice over inside every single post!

    As it stands now, will it work with all future updates of wp?

    The readme.txt says it must be a “publicly-accessible URL” but my /1cde folder is a 403 but it’s working anyway!

    I really appreciate your help, many thanks – Val

    Val, I intend to keep Insert Here working on future versions of WP as they come out. But I can’t guarantee it will work with all future updates because I don’t control the development of WordPress. They could stick something in there that jinxes the whole thing. It’s unlikely, but still not something I can say won’t happen.

    Yes, if you want to port the plugin code to your functions.php file, you’re free to do so. As a point of info, if the plugin doesn’t work then the code in function.php probably won’t, either.

    Will

    Thread Starter valarcher

    (@valarcher)

    thank you! I inserted it into functions.php ’cause I figure it may be speedier than using a plugin :

    Meanwhile for insert_php I tried creating a php.ini in root with this one line (as per my web host tech support’s advice):

    allow_url_include = On

    and now when I test this:

    [insert_php] include(“http://greensmoothie.com/wp-content/themes/1green/1cde/insertphp01.php”); [/insert_php]

    I get this error message:

    Parse error: syntax error, unexpected ‘:’ in C:\wamp\wwwgn\wp-content\plugins\insert-php\insert_php.php(48) : eval()’d code on line 1

    I no longer need insert_php but I thought I’d pass the error message on 🙂

    That’s pretty cool you can update php.ini with a file in your root.

    There’s something in the code, either in the include() line or in the content of insertphp01.php that is throwing the error.

    When you have a few minutes, try this and see if you still get the error:

    [insert_php]
    include( $_SERVER["DOCUMENT_ROOT"] . "/wp-content/themes/1green/1cde/insertphp01.php" );
    [/insert_php]

    Just for curiosity.

    If still the same error message, then there is likely to be something in insertphp01.php. Otherwise, there is likely to be something in the include() function call itself when it contains a URL.

    Error messages mean there’s something somewhere. But this isn’t urgent, as you don’t need to use the plugin for your implementation.

    Will
    P.S. Thank you for the donation. Much appreciated!

    • This reply was modified 9 years, 4 months ago by WillBontrager.
    Thread Starter valarcher

    (@valarcher)

    Nope, this is the new error msg:

    Warning: include(C:/wamp/www/wp-content/themes/1green/1cde/insertphp01.php): failed to open stream: No such file or directory in C:\wamp\wwwgn\wp-content\plugins\insert-php\insert_php.php(48) : eval()’d code on line 2

    This is insertphp01.php
    <div class=”quote”>Need some guidance? Download right now: Top Ten Tips for Optimum Health on a Raw Plant Diet — by famous raw vegan nutritionists.</div>

    css:
    .quote {font:italic bold 1.05em/1.5 “Lucida Sans”,Verdana,sans-serif; color:green; margin:20px 60px}

    ah well, Will, let’s just give up at this point! I need to move on… gosh I didn’t think you’d notice my little contribution 🙂 Thank you for insert_here!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Include with insert_php’ is closed to new replies.