• Hi there

    I have been using PHP Code For Posts plugin for a long time with no issue to add custom code, including some to get external RSS content.

    The last week or 2, I had diverse issues on the shared host, one being a false version of PHP (5.2) being used, instead of the one set in the Cpanel (5.4), leading to some issues, like the Cloudflare plugin not getting re-enabled since it only works with 5.3 & above. I had had it working before, with 5.4, but some issues led to disabling it, but could NOT re-enable it again after a few days.

    This was corrected yesterday. I have noted however that custom PHP scripts embedded in text in spite of the above plugin are no longer being executed.

    I even changed to another PHP Code Widget. The issue is not PHP not working in general as WordPress would not work. One of the custom RSS scripts, though, if I load it directly outside WordPress, works.

    Within wordpress, even a simple script like <? echo "Hello"; ?> will not work.

    Since I have not changed anything on the site, i.e. same custom php scripts + plugins, apart from trying out the new PHP plugin, may be some problem (on server, some PHP setting change?) related to the PHP versions reported above are making WordPress PHP plugins allowing using custom code not to work.

    How could this be solved? What does WordPress require, apart from such plugins like PHP Code For Posts & PHP Code Widget to allow using custom PHP code in posts? In case it’s serverside, i need to know what to tell the shared host support fellows to get back.

    Thank you in advance

Viewing 15 replies - 1 through 15 (of 16 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Is this a caching issue?
    Echoing does work in WordPress, but a more obvious way of debugging is to use “var_dump” and “exit”.

    Thread Starter xprt007

    (@xprt007)

    Hi

    Thank you for the quick response.
    Actually that echoing example was just one I used here. The scripts mostly are of this nature "<? include "http://www.xx.com/abc/single.php"; ?>" and have worked with no issue for over 2 years … until the other day.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    What about this:

    <?php include "http://www.xx.com/abc/single.php"; ?>

    Thread Starter xprt007

    (@xprt007)

    Hi

    Unfortunately, it makes no difference.
    The content is supposed to go below “[Français | Español | Português]” at http://bit.ly/1UzgNsg, but gets completely ignored.
    Same on separate site sharing same account. As said, outside WordPress “http://www.bcd.com/abc/single.php&#8221; loads …

    🙁

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The include might be a complicated example, maybe it’s best to first get that echo working.

    Does this work:

    <?php echo 'foo' ?>

    If not, where are you putting this code and where are you looking in the browser?

    Thread Starter xprt007

    (@xprt007)

    At that bit.ly link above is now "<php? echo "http://www.abc.com/bcd/single.php"; ?>"
    but it seems it gets ignored.

    Actually as mentioned, the exact code has worked with no issue up to about 2, 3 days ago for over 2 years & I used it even on a Drupal site for a longer time. It is yesterday that I noted the RSS content was missing & there was instead some errors related to Timezone offset, or something like that. I corrected them by moving from custom php.ini to the default provided by shared host – although before diverse server issues started, there was no problem with it.

    So now as you see, no errors, but no custom PHP content.
    Enabling debug in WP_config, shows no errors.

    I think these Host guys have messed up some server settings of late, may be affecting this function, but without knowing what it is, it is hard to deal with them.

    The content is normally printed between those languages & that colored image link on that page & that is where the code has always been.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Oh are you putting PHP inside the Text editor? Your above PHP is inside that Bit.ly page, it’s just not parsed:

    <php? echo "http://www.habarisearch.com/giveaway/single.php"; ?>

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Actually as mentioned, the exact code has worked with no issue up to about 2, 3 days ago for over 2 years

    Yes, but that’s not going to help anyone debug the issue.

    Thread Starter xprt007

    (@xprt007)

    Hi

    The plugin “PHP Code For Posts” which I have always used, as much as I know enables PHP code placed in the text editor (not under Visual mode)
    such as <php? echo "http://www.habarisearch.com/giveaway/single.php"; ?> to get executed …

    Today, I tried “PHP Code Widget”, currently enabled … and described by the developer as follows:

    The normal Text widget allows you to insert arbitrary Text and/or HTML code. This allows that too, but also parses any PHP code in the text widget and executes it.
    This can make it easier to migrate to a widget-based theme. However, this plugin should not be used long term, as anybody with access to edit the widgets on your site will be able to execute arbitrary PHP code.
    All PHP code must be enclosed in the standard php opening and closing tags ( <?php and ?> ) for it to be recognized and executed.

    Regards

    Thread Starter xprt007

    (@xprt007)

    That code above normally prints this content http://bit.ly/1USDK9f as said between those languages & that colorful image at bottom of page & appears as any other page content.

    The fact that it is not be executed/parsed(?) is because those 2 plugins are for some reason not working.

    That’s why there is a problem …

    Note that the opening PHP tag in this code isn’t actually written correctly:

    <php? echo "http://www.habarisearch.com/giveaway/single.php"; ?>

    The code should look like this instead :

    <?php echo "http://www.habarisearch.com/giveaway/single.php"; ?>

    IOW, the ? belongs before php not after it; so you’ll want to correct that before doing any further troubleshooting here.

    Thread Starter xprt007

    (@xprt007)

    Hi

    OK, you are right BUT that was just a typing mistake.
    The real code that has worked on 3, 4 sites, Drupal & WordPress for years looks like this:

    <? include "http://www.aabc.com/def/single.php"; ?>

    I otherwise learnt a while back that “<php?” or “<?” does basically the same thing & I have never had a problem with it.

    <?php include "http://www.aabc.com/def/single.php"; ?> … makes no difference in this case .. just tested it.

    Thread Starter xprt007

    (@xprt007)

    The problem is not with the syntax, but something that was changed on the server as said above, but without knowing exactly what, it is impossible to convince the website host, whose support I have just had a useless discussion with.

    This started a few days ago, when because of other unrelated issues, i had deactivated the Cloudflare plugin, which had worked with no problem for a year, leading to lots of 524, 503, 500, 404 errors making the sites hardly accessible for about 2 weeks. The problem went away as suddenly as it camem or it appears so, about 4 days ago.

    I then wanted to reactivate cloudflare plugin back, but could not giving off some error. The specific error, though according to Cloudflare only comes if one has PHP versions older than 5.3, yet in my case I had upgraded to 5.4 a year or so back and that was also shown in the Cpanel.

    After the statement from Cloudflare, I put a phpinfo() script on the site & to my horror, it had PHP version 5.2… That’s something the webhost support could not deny & after fumbling with settings for a while, they seem to have dealt with the contradiction getting the server to deliver the real PHP version 5.4.
    Promptly, I could activate Cloudflare plugin.

    However, I discovered later those memntioned pages, using php scripts embedded in code were no longer working on 2 separate sites.

    That’s why I am almost certain whatever they did is behind this, because I had never had this problem before & those pages, which are visited everyday by many folks have never failed to deliver.

    The JustHost.com, apparently outsourced support is however completely useless if it comes to such things as they see everything working on their servers & often quickly come to tell one to contact “developers” or plugin vendors or other such nonsense when the problems are on their servers. With the PHP Version issue, they could not deny, because they saw the settings in my Cpanel & yet phpinfo() was showing 5.2.

    If I knew what was the issue preventing “PHP Code For Posts” or “PHP Code Widget” or whatever from getting that PHP code placed in posts/page content from getting executed, I would be in better position to confront the virtual support fellows at JustHost.

    And just to confirm: On the Options tab of the “PHP Code for Posts” plugin’s settings screen, both of the two “Parse inline plugin shortcode tags” settings are still CHECKED?

    Assuming that they are, then perhaps the problem here is that your host has disabled the eval function (which both of these plugins rely on to work properly) for security reasons. If you still have that phpinfo() script file on your server, check it to see if there’s any value shown for the disable_functions directive in the Core section.

    Thread Starter xprt007

    (@xprt007)

    Hi there

    disable_functions shows no value for both local & master value on a phpinfo() page. ….

    Just as I was checking on what you say, I switched back to “PHP Code for Posts” and discovered it is now working as http://bit.ly/1UzgNsg shows.
    It seems these JH support clowns changed something in the last couple of hours after this & similar page on another site suddenly started working again, having stopped doing so 2 days ago.

    I have no other way to call these guys as I have been in a state of war with them, because of frequent & diverse issues like unexplained timeouts, 524, 503, 4o4 etc errors, whereas copies of the same sites function flawlessly on other servers. One can almost be sure to be told each time to optimize the site, contact plugin vendors or developers, just like one of them was telling me again today.

    I hope I can have some respite now, but with JustHost of nowadays, that is expecting too much..

    Thank you all for your help. 🙂

    Regards

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘What could prevent PHP scripts from working in WordPress?’ is closed to new replies.