WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode Exec PHP
[resolved] doesn't work (10 posts)

  1. gopanthers
    Member
    Posted 2 years ago #

    doesn't work at all. Even the default test code gives parse error.

    http://wordpress.org/extend/plugins/shortcode-exec-php/

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    Could you please post the error message?

  3. gopanthers
    Member
    Posted 2 years ago #

    I didn't realize I had tried this plugin before but I just reinstalled it again. Same results so I came here for support and found my own post. (This time I'm checkmarking the 'notify me of follow-up posts')

    This plugin sounds like a perfect solution for my needs, where I'd like to keep the php code out of the pages themselves because other, less-experienced editors could mess it up.

    When I click the test button (and when I add the test shortcode on a page) I get the following message:

    [php_test]="
    <b>Parse error</b>: syntax error, unexpected '<' in <b>/home/xxxmyaccountxxx/public_html/xxxmydomainxxx/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(1069) : eval()'d code</b> on line <b>1</b>
    "

  4. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    This message means that there is a syntax error in your shortcode definition.

    I can help you with this, but you'll have to post the shortcode definition.

  5. gopanthers
    Member
    Posted 2 years ago #

    This is all straight out of the box. At first the shortcode said [test] but thought that may conflict with something so I changed it to [php_test]. In both cases it didn't work.

    As for the code being executed, it is exactly the default.

    <?

    <p style="text-align: center;">test</p>

    ?>

    I haven't touched any settings.

  6. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    That is not the example code out of the box and it is indeed wrong.
    Try it like this:

    ?>
    <p style="text-align: center;">test</p>
    <?php
  7. gopanthers
    Member
    Posted 2 years ago #

    Thanks for the help. All I see different is the ?> and <?php being reversed but I tried it anyway and go the same error code. So I then decided to change the code to be executed to nothing other than <b>test</b> and still got the same results. Must not be a problem with the php code trying to be executed by the shortcode.

    `[test3]="
    <b>Parse error</b>: syntax error, unexpected $end in <b>/home/xxxxx/public_html/xxxxx.net/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(1069) : eval()'d code</b> on line <b>1</b>
    "'

  8. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    It is definitely a problem with the shortcode (because eval()'d code on line 1).

    And <b>test</b> is not PHP but HTML, so you must use the closing PHP tag and after it the PHP opening tag again.

    Try this to see that it works:

    echo 'Test';

    (no PHP opening and closing tags, because this is PHP code).

    This plugin is not meant for HTML (although it is possible to a certain extend).

  9. gopanthers
    Member
    Posted 2 years ago #

    Hey, that one worked!!! Thanks!!!

    So I'll have to test later with the code I really want to use, but it seems that the <? and ?> are not necessary for the php code itself? (The default test code that was there did have those characters at the top and bottom so I assumed they needed to be there. If that's not normal than I wonder how that happened on two different fresh install.)

    And if my code has non-php elements in it, I suppose I should just go through the effort of changing it to php standards, right?

    Thanks again.

  10. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    So I'll have to test later with the code I really want to use, but it seems that the <? and ?> are not necessary for the php code itself?

    No, these are not necessary.

    The default test code that was there did have those characters at the top and bottom so I assumed they needed to be there. If that's not normal than I wonder how that happened on two different fresh install

    The default test code does not contain PHP starting and ending tags.

    The default test code is:

    extract(shortcode_atts(array('arg' => 'default'), $atts));
    echo "Hello world!" . PHP_EOL;
    echo "Arg=" . $arg . PHP_EOL;
    echo "Content=" . $content . PHP_EOL;

    And if my code has non-php elements in it, I suppose I should just go through the effort of changing it to php standards, right?

    Yes, or use PHP closing and opening tags for HTML code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic