WordPress.org

Forums

Shortcodes Pro
[resolved] "Uncaught SyntaxError" when name begins with number (7 posts)

  1. GabLeRoux
    Member
    Posted 3 years ago #

    Hello, this plugin is just awesome, but there are some little bugs :(.

    1st bug I found:
    There's a minor bug that make the tinyMCE buttons disapear because of the generated javascript located in shortcodes-pro/inc/shortcodespro-edit-js.php

    Uncaught SyntaxError: Unexpected identifier

    when shortcode name is a number or begin with a number:

    I made a shortcode named 960gs (guess what I was about to do).

    Javascript parser fails at line 153 of the generated javascript (may be different for you as it's generated javascript).

    Here is the line that fails:
    tinymce.PluginManager.add('960gs', tinymce.plugins.960gs);

    With syntax highlight, I can see that the second 960 get another color (seen as a number or I don't know).

    You should consider writting it somewhere or just fix it because somme people won't know why it's not working if they try with a shortcode named with a number on the first try and they will delete the plugin!

    Second bug:
    Ordering buttons is not working properly on 3.4.1 with Chrome Browser (did not test with others, it doesn't save state and I don't really know why. I can reorder using the parameter in the shortcode edit page (setting row manually), but I can't add any separator.

    When I move a button to an empty row, it saves the list, but they're not showing in tinyMCE if they're not in the first row (kind of weird).

    Edit: Only the items in row 2 doesn't show in tinyMCE 1, 3 and 4 shows fine (but still can't reorder using that nice ui)

    I hope you can fix this (but take your time)
    This is a badass plugin, seriously, I made some shortcode and the result is the same as those templates that provide some shortcode, it's even better and it's not theme dependant! Wonderfull, saves me so much time.

    http://wordpress.org/extend/plugins/shortcodes-pro/

  2. GabLeRoux
    Member
    Posted 3 years ago #

    Another syntax bug here: Screenshot of the error

    The quick description string is not escaped so if you insert any ' it will fail! :(, they need to be manually escaped with \'.

  3. Matt
    Member
    Plugin Author

    Posted 3 years ago #

    Hi GabLeRoux,

    You rock dude. Thanks a ton for these amazing feedback. Update coming soon.

    Kind Regards!

  4. Matt
    Member
    Plugin Author

    Posted 3 years ago #

    Hey GabLeRoux,

    Both Issues fixed on 1.1.2. Please let me know if you have any feedback, thanks!!

  5. GabLeRoux
    Member
    Posted 3 years ago #

    Cool, thanks for the update.

    I don't have much time atm, but I tested the Order Ui and it's still a bit buggy, having two shortcodes, I can't permute there positions (1,2) (2,1) on a same row and I also tried to insert a separator between those two and it did not save the separator.

    Other than that, the plugin is awesome ^^.

    Something that could be awesome is a system for simply wrapping a div with given classes for making the shortcode creation very fast in the case of a shortcode like this:

    <div class="alert (color)">do_shortcode(content)</div>

    as most of the shortcodes I make looks like this, but it's only a suggestion, I make these by myself using a pattern with some php, ;). Will post it here tonight

  6. Matt
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks GabLeRoux, much appreciated.

  7. GabLeRoux
    Member
    Posted 3 years ago #

    This is my alert shortcode:

    if ($content == '')
        $content = $atts["content"];
    return '<div class="alert ' . $atts["color"] . '">' . $content . '</div>';

    I've set the content as an attribute so this let me use the generated shortcode inside another shortcode.

    This is a shortcode for making columns with the 960gs:

    if ($atts["prefix"] == 'none')
    {
    	$atts["prefix"] = '';
    }
    else
    {
    	$atts["prefix"] = ' ' . $atts["prefix"];
    }
    
    if ($atts["suffix"] == 'none')
    {
    	$atts["suffix"] = '';
    }
    else
    {
    	$atts["suffix"] = ' ' . $atts["suffix"];
    }
    
    if ($atts["appearence"] == 'none')
    {
    	$atts["appearence"] = '';
    }
    else
    {
    	$atts["appearence"] = ' ' . $atts["appearence"];
    }
    if ($atts["position"] == 'none')
    {
    	$atts["position"] = '';
    }
    else
    {
    	$atts["position"] = ' ' . $atts["position"];
    }
    
    return '<div class="' . $atts["grid"] . $atts["position"] . $atts["prefix"] . $atts["suffix"] . $atts["appearence"] . '">' . do_shortcode($content) . '</div>';

    As you can see, all I do is add classes to a div. This could be accomplished without any shorcode in my theme by entering div code in html, but my clients don't like to learn html so it's much easier to click on buttons ;).

    Anyway, as you can see, I've put do_shortcodes($content) so I can even exec some of the [do action="stuff"/] inside another shortcode :). And that is the reason why I've set an attribute for content in the alert for the first example, this result in something like that:

    [do action="nine_six_zero_gs" grid="grid_6" appearence="none" position="alpha" prefix="none" suffix="none"]
    [do action="alert" color="yellow" content="listen to us!"/]
    [/do]

    That way, I get a nice alert inside a grid_6.
    HTML result looks like this:

    <div class="grid_6 alpha"><br>
    <div class="alert yellow">listen to us!</div><br>
    </div>

    html result is much more simple than the text in the shortcode but All I really had to do is to click on the two buttons and select what I wanted.

    This plugin is a very good idea considering that we can make our shortcodes the first time and than, if we ever decide to change from a theme to the other, we're not stuck by changing all the shortcodes used before, All we have to do is add some css to the new theme and voila.

    As I told in the post before, it would be nice to have a div wrapping system with class handling in a user friendly way.

    All I'd have to do is to set a list of classes for each attributes. (yup, all my shortcodes look the same, the only one that is a bit different is the btn class witch is an anchor tag with classes instead of a div. :P

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Shortcodes Pro
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic