Support » Plugin: Shortcode Exec PHP » Top plug. UI/Settings took a while to understand.

  • Love it, it works. I am now passing shortcode attributes through to PHP variables.

    It took me a while to figure it out. Perhaps the config page could have a small example and explanation. i.e. set attribute, set up variable array (with default values) in php code to receive the variable, and finally use the variable in a short php script.

    Anyway. Keep up the good work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @square_eyes, do you have a short example you could post? Would help a lot of us, I bet! 🙂

    OK well this plugin is quite powerful, so this may not suit all scenarios. However, I would add something like this to get people started…

    :::: Shortcode – Put this in your page/post ::::

    Shortcode Example 1. Defaults

    [myphpscriptnamehere] – Calls ‘myphpscriptnamehere’ as configured in Exec PHP. Any variables in the script will parse as defaults (set in the PHP script below).

    Shortcode Example 2. Two Attributes Parsed as Variables

    [myphpscriptnamehere name="John" location="Earth"] – Shortcode includes two example attributes which we will parse as variables.

    :::: Settings and PHP Code ::::

    WordPress Admin -> Tools -> Exec PHP -> Scroll down to Shortcodes. Add your PHP, name the script ‘myphpscriptnamehere’ from above and click Add. Remember to add your PHP code, without the <?php and ?> tags.

    Example PHP Script (Works with both above)

    extract(shortcode_atts(array('name' => 'No Name', //Notes: Listens for 'name' attribute, and adds 'No Name' as default.
    			     'location' => 'Somewhere', //Notes: Listens for 'location' attribute, and adds 'Somewhere' as default.
    ), $atts));
    echo ('Hello ').$name.(' from ').$location; //Notes: When run on a page load our little app spits out the defaults, or attributes, based on the shortcode you used.

    Output when page/post is loaded…

    Example 1.
    Hello No Name from Somewhere

    Example 2.
    Hello John from Earth

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Top plug. UI/Settings took a while to understand.’ is closed to new replies.