WordPress.org

Ready to get started?Download WordPress

Forums

Post Snippets
[resolved] [closed] Problem with defaults (8 posts)

  1. menathor
    Member
    Posted 1 year ago #

    First up, awesome plugin!

    Only problem is I'm having problems with the insertion of defaults. The variables work fine when they're defined in the shortcode, however when they aren't defined the defaults aren't passed through. I'm using version 2.0 of the plugin with the latest version of wordpress and the weaver II pro (theme).

    Here's an example:

    Snippet name (shortcode): fbcomments
    variables: url=http://www.xxx.com
    snippet: <div class="fb-comments" data-href="{url}" data-num-posts="10" data-width="470" data-colorscheme="dark"></div>

    When I enter [fbcomments], I still data-href="{url}" in the source code.

    When I enter [fbcomments url="http://www.xxx.com"] things work fine.

    I've tried it with more basic default variables too, eg title=blah and same problem.

    Any thoughts on how I could fix this would be great!

    http://wordpress.org/extend/plugins/post-snippets/

  2. bigjohncss
    Member
    Posted 1 year ago #

    I'm having the identical problem, any set defaults break the variables. I've not tried to use vars before; did they ever work correctly?

  3. darinroman
    Member
    Posted 1 year ago #

    I am experiencing the same issue.

    Default variable values are not processed when a shortcode is called on it's own. When variables are defined in the shortcode, however, they work fine.

    Otherwise this plugin works as expected.

  4. James Collins
    Member
    Posted 1 year ago #

    I also noticed the same problem, so I have sent a patch (pull request) to the plugin developer.

    Hopefully he can include this bug fix in the next version.

    James

  5. darinroman
    Member
    Posted 1 year ago #

    Awesome, thanks James.

  6. James Collins
    Member
    Posted 1 year ago #

    @DarinRoman, you're welcome to try out the patched version by downloading it from here: https://github.com/OM4/post-snippets/archive/defaultvalues.zip

    Note: it's not guaranteed to work, but it seems to solve the issue for me.

    James

  7. Johan Steen
    Member
    Plugin Author

    Posted 1 year ago #

    @JamesCollins That is super! Thank you very much. I'll include your patch later today (I have a crazy working day ahead of me, but tonight - my time, I'll review it).

    Your contributions are much appreciated. And I am aiming of releasing a Post Snippets update before the end of the week, containing your contributions.

    I did refactor the code for my other wp.org published plugin the last days, which made that plugin much more maintainable. I'll probably do the same for Post Snippets - it'd would do it good, now when it has a few years of code added to it.

  8. James Collins
    Member
    Posted 1 year ago #

    For anyone reading this, the latest version (v2.1.1) includes this default values fix.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic