Home Forums Weaver Xtreme Theme PHP and require_once

Viewing 16 posts - 1 through 16 (of 18 total)
  • Author
    Posts
  • #71020
    cynical
    Participant

    I’m on a “forced march” to switch from a php plugin to Weaver (a Weaver warning, that I did not capture, flashed on the screen this morning right before the old php plugin failed.

    It appears Weaver is choking on the first line, which is a require_once statement.

    ERROR STACK:

    <b>Fatal error</b>: Uncaught Error: syntax error, unexpected ‘<‘, expecting end of file
    in <b>/homepages/37/d146050845/htdocs/cynical-wp/wp-content/plugins/weaver-xtreme-plus/includes/weaver_xplus_shortcodes.php(690) : eval()’d code</b> on line <b>1</b>

    Call stack:

    weaverxplus_php_do_eval()
    wp-content/plugins/weaver-xtreme-plus/includes/weaver_xplus_shortcodes.php:704

    weaverxplus_php_shortcode()
    wp-includes/shortcodes.php:356

    do_shortcode_tag()

    preg_replace_callback()
    wp-includes/shortcodes.php:228

    do_shortcode()
    wp-includes/class-wp-hook.php:307

    WP_Hook::apply_filters()
    wp-includes/plugin.php:191

    apply_filters()
    wp-includes/post-template.php:253

    the_content()
    wp-content/themes/weaver-xtreme/paget-raw.php:29

    include()
    wp-includes/template-loader.php:106

    require_once()
    wp-blog-header.php:19

    require()
    index.php:17

    INSERTED CODE:

    [php]
    require_once ‘php/glob.php’;
    $link = opendb(‘online’);
    $word = get_random_def($link);
    [/php]
    <script>
    function myFunction() {
    location.reload();
    }
    </script>

    [insert_php]echo $word;[/insert_php]
    (refresh for another random word)

    [php]
    display_defs($link,$word);
    display_quotes($link,$word);
    [/php]

    #71021
    cynical
    Participant

    UPDATE #1: Despite being in raw mode, I can at least get execution if I collapse all the PHP code to a single line. The documentation makes me think multiple lines in text view should be executable.

     

    Down until I hear back.

    #71022
    Weaver
    Keymaster

    First of all, the ERROR STACK message indicates the error is in the PHP code you are trying to execute. It is NOT an error in any Weaver Xtreme Plus code. Note the eval()’d code part of the message. That means the error is in that code. The problem is in the eval()’d code.

    If the code you supplied in the INSERTED CODE section is what you are trying, then there are a couple of problematic things.

    First, your example has incorrect single-quotation marks – they are forward/backward sinlgle quotes – but this is likely a copy/paste issue with the way this forum handles quotes.

    But the require_once ‘php/glob.php’; seems a bit questionable. The path to php/glob.php needs to be more complete. As it stands, it is dependent on the directory wp-content/plugins/weaver-xtreme-plus/includes, where weaver_xplus_shortcodes.php is located. So you should have a complete path to where the php/glob.php is found. And since the error output says the error was on line 1, that is the require_once.

    I also don’ think that inserting a block of <script> code in the middle of page/post content will work as intended. WP will not emit <script> code directly- it would be escaped (e.g.: &lt;script&gt;).

     

    #71023
    cynical
    Participant

    Thanks, but let me rewind this a bit:

    1. Site was working yesterday. No inserted PHP code changes at all.
    2. I updated the site to WP 6.01 yesterday morning, site worked all day using the old plugin (the older Woody code snippets (PHP snippets | Insert PHP).
    3. Did a refresh this morning (while half asleep) and there was a Weaver warning message which I did not carefully read, but which mentioned something about upgrades (sorry I didn’t think to capture that, but I was just refreshing the page).
    4. Site when dead.

    Putting the site back like it was (not raw page, and the Woody [insert_php] code, the php is not being processed, as if something in the Weaver warning/update/whatever, had added a filter.

    So it might be a good starting point to determine what that Weaver message of this morning was. Do you have a way I can spelunk that? Any logs within Xtreme that captures such?

    #71025
    Weaver
    Keymaster

    WordPress, plugins, and themes do not normally generate logs.

    Depending on your host and how it is set up, there might be general PHP logging. This will ususally be a file with some name like php_logs unde a logging directory setup by the host.

    Again, it is unlikely that this is a Weaver or Weaver Plus error. You should direct your efforts into any code or shortodes you are using in your content.

    Also, WP sites rarely go dead. Be sure to set WP_DEBUG to true in your wp-config.php file. That allows display of PHP error messags on site.

    Then, even a blank site page can have information. Use “Show Page Source” which often displays incmoplete HTML that can show exactly where generated HTML output stops.

    #71026
    cynical
    Participant

    Thanks.

    1. Were it not for the Weaver pop-up warning that I brushed past this morning while refreshing the screen, I wouldn’t bother you. But that is the primary clue from between last night (A-OK) and today (PHP not executing).
    2. I have the site back to where it was this morning, and …
      1. The PHP is still not executing using the old plugin, but the embedded code rendered as text
      2. When using the Weaver [php][/php] codes instead, we get a “critical error” (see below)

    So, let me ask the question another way: with a site being update to WP 6x, does Weaver produce any type of warning pop-ups, and if so, can you give me all of them so I can see if any look familiar to what I saw today?

    Here are two links, one to the page using the pluggin that worked before the Weaver warning pop-up of this morhing (https://www.cynical.ws/wb-plugin/) and what happens when I use the Weaver [php] shortcode (https://www.cynical.ws/wb-weaver/).

     

    #71027
    scrambler
    Moderator

    Have you  tried to do a full reset of WordPress and Weaver installation in case something became corrupted.

    • Remove the problematic code
    • Save all weaver settings
    • Download a copy of all weaver settings for good measure
    • Switch to a different theme like 2021
    • Deactivate and delete ALL weaver theme and plugins
    • Redo the latest WordPress Update
    • Reinstall weaver Xtreme from WordPress.org and activate
    • Reinstall Xtreme theme support plugin from wordpress.ord and activate
    • Download a fresh copy of the Xtreme plus plugin from your weaver account, install and activate
    • Reinstall other weaver plugins if any from wordpress.org and activate

    At this point everything should be back to what it was and you can try adding the code again

    #71028
    cynical
    Participant

    Before you read what follows, please answer the question I posed “So, let me ask the question another way: with a site being update to WP 6x, does Weaver produce any type of warning pop-ups, and if so, can you give me all of them so I can see if any look familiar to what I saw today?”

    This is important because the pop-up warning I received this morning during a screen refresh mentioned “Weaver”, “Xtreme” and “update”. Since the site was health on a screen refresh last night, but bombs today after that popup, something associated with Weaver Xtreme occured. Your answer to the question above is important.

    ————————

    I’ll give the refresh a try, likely tomorrow. Please keep the ticket open.

    I just activated 2021. The old PHP plugin still generated plain text (interesting), but of course the Weaver [php] did too since Weaver was not active.

     

    #71029
    Weaver
    Keymaster

    Weaver does NOT have any special error codes.

    Did you set WP_DEBUG to true?

    Did you receive an email to your admin account?

    Please read this page: https://www.ecommerceceo.com/wordpress-critical-error/

    And if your first post had accurate info, then I stand by my first suggestion:

    But the require_once ‘php/glob.php’; seems a bit questionable. The path to php/glob.php needs to be more complete. As it stands, it is dependent on the directory wp-content/plugins/weaver-xtreme-plus/includes, where weaver_xplus_shortcodes.php is located. So you should have a complete path to where the php/glob.php is found. And since the error output says the error was on line 1, that is the require_once.

    If you don’t completely understand what that last paragraph said and means, then there was something else going on with the previous [insert_php] shortcode plugin that you are missing.

    Actually, that whole set of code in the [include_php] does not look as if it will work. There seems to be something missing. In a standard WP page/post, there would not be access to php/glob.php, nor opendb, nor display_murphys. Where are the definitions of those files and functions supposed to be coming from? You must answer that question before anything else.

    FOLLOW UP: I looked at the page source for the example with the code output of your old PHP short code, and there is absolutely no place that the PHP code in your example could possibly work with Weavers [php] short code. Perhaps the previous short code had some settings that automatically included the requierd PHP files. Like for example, just exactly is function display_murphys() defined? Has to be done somewhere. Where? How is it included? Do you have a child theme?

    Trust me, this is your problem. You can’t arbitrarily call a PHP function such as display_murphys without somehow defining it and including the php source code.

    That bad reauire_once could easily cause the php error, and if you don’t have the WP_DEBUG values set correctly as described in the above link, then we can’t get anywhere on this issue.

    #71030
    cynical
    Participant

    Still waiting for tomorrow to run down your checklist, but for now did a little experiment:

    1. New page.
    2. Only two lines are below.
    3. The function testit was added to the require_once file and does the same echo statement
    4. Both execute

    So,  the production file in require_once, which has been untouched since March (IIRC) is loading fine providing the embedded code between [php][/php] is on one line, and yes, the page set to the raw template.

    But notice the warning being produced by WP file. To make sure this wasn’t from my code, I created a new file for require_once that only had the testit line (e.g., for foreach statements to be found) and the error persists.

    So, at very least, we have one Xtreme issues: it does not parse milti-line PHP code sets as documented on the Weaver Xtreme Plus Administration page.

    But I suspect it may be causing this warning as well.

    [php]require_once ‘php/glob.php’;testit;[/php]
    [php]echo ‘<h2>This is the embedded h2 tag</h2>’[/php]

    OUTPUT

    #71031
    Weaver
    Keymaster

    OK, and apologies: there does seem to be an issue with multi-line php scripts. Don’t know when that got in there, and I don’t have any quick solution.

    There must have been some changes in the underlying mechanism Weaver’s [php] handler uses. I searched for alternate PHP code plugins, and it seems that some previous plugins that used to be there that were similar to Weaver’s [php] are no longer available.

    There seem to be a couple other plugins that support PHP code by requiring adding snippets to a separate admin interface, and then specifying a snippet reference rather than actual PHP code in the page/post. There also is a PHP plugin that provides a new block for the block editor.

    (See next post regrading retraction. Multiline requires classic editor Text view PLUS Raw per page setting.)

    But there is an easy work around that is easier to maintain for now. Rather than try to make a long single line string, simply add multiple lines wrapped by the [php]//code[/php]:

    [php]echo "THIS IS GENERATED BY A PHP ECHO";[/php]
    [php]echo "2. THIS IS GENERATED BY A PHP ECHO";[/php]
    [php]echo "3. THIS IS GENERATED BY A PHP ECHO";[/php]
    
    

    At this point, I would highly recommend trying one of the other PHP plugins, perhaps

    Insert PHP Code Snippet

    BUT, as I’ve said all along, you still have to have valid PHP code. And the code you have with [php]require_once ‘php/glob.php’;[/php] will still fail because of what I previously explained. The error message you got was still caused by the require_once which needs a full path to where ever the glob.php file is.

    #71032
    Weaver
    Keymaster

    Sorry again, I must retract what I said about multiple line [php] scripts. I had forgotten to make my test page use the per-page RAW option. After checking that option, the [php] multiline example worked as expected.

    If you really need a multiline [php] example not on a RAW page, you can actually define one using the [shortcoder] Plus option. You can use a [php] multiline example there. Same reason the other PHP plugins require defining the code in an admin page.

    From the [php] documentation:

    Important note: If your php code spans multiple lines (i.e., you use the Enter key), then you must use the HTML editor view, and check the Raw HTML per page option in the page/post editor screen. Short PHP snippets on just one line will work from either the HTML or Visual editors.

    Just might be easier to use the snippet plugin I provided previously.

    #71033
    cynical
    Participant
    1. The code anchored by “require_once ‘glob.php’ has been in production since March.
    2. The functions you asked about (opendb, display_murphys) are all in glob.php (‘glob’ is shorthand for global).
    3. The PHP execution plugin, that was working before the Weaver pop-up warning, did handle loading via require_once, and well as preserving variables between [insert_php][/insert_php] calls.
      1. I take it from your comments above that this is not possible using Weavers [php][/php]? If so, then I’m going to be sunk for a long time (harsh given I spent a few months porting the old raw HTML site to WP.
    4. The multiline issue … requires classic editor Text … I’m not quite certain we have the same definition here, but I tried it setting page template to raw and edit everything in text view. Didn’t change anything. The php plugin I was using before did not have that requirement though.
    5. I have 440 lines of code in glob.php, so shifting over to snippets is not possible. Hence, we need to pursue what the Weave/Xtreme/warning pop-up was about. That is the one event between the site working fine and not working.

    REPEATING (3rd time):

    “So, let me ask the question another way: with a site being update to WP 6x, does Weaver produce any type of warning pop-ups, and if so, can you give me all of them so I can see if any look familiar to what I saw today?”

    This is important because the pop-up warning I received this morning during a screen refresh mentioned “Weaver”, “Xtreme” and “update”. Since the site was health on a screen refresh last night, but bombs today after that popup, something associated with Weaver Xtreme occured. Your answer to the question above is important.

    #71034
    cynical
    Participant

    Started looking at you “update” list, noticed there was a newer version of Weaver Xtreme Plus. But updating it produced the following error:

    “Update failed: Download failed. Unauthorized”

    #71035
    scrambler
    Moderator

    I think you need to do the full reset of the install…

    #71036
    cynical
    Participant

    Oddly, when I deactivated the Weaver plugin, then reactivated it, it was the new version.

     

Viewing 16 posts - 1 through 16 (of 18 total)
  • You must be logged in to reply to this topic.