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

  1. menathor
    Posted 4 years 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!


  2. bigjohncss
    Posted 4 years 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
    Posted 4 years 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
    Posted 3 years 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.


  5. darinroman
    Posted 3 years ago #

    Awesome, thanks James.

  6. James Collins
    Posted 3 years 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.


  7. Johan Steen
    Plugin Author

    Posted 3 years 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 w.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
    Posted 3 years 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

  • Post Snippets
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic