ul class in class-eo-event-list-widget.php

WordPress Event Management, Calendars & Registration Forums General Question ul class in class-eo-event-list-widget.php

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 8 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2821

    I have a question about the ul class in class-eo-event-list-widget.php. I use the shortcode [eo_events] to display a list of events on my site. Since I wanted it to fit the style of my site, I changed <ul class="%2$s">%1$s</ul> to <ul class="zebra">%1$s</ul>. Works like a charm!
    But now I would like to display the same list somewhere else on my site is a different style.

    I have two questions:
    – what means the %2$s in the original file?
    – is there a way to display [eo_events] with different ul classes? Can I implement it in the shortcode for example?

    Sorry if the answers are logical, but I’m not so good (yet) in php… Thanks!

    Ties
    #2822

    Hi,

    The %2$s is used inside a sprintf or printf function (see this page). It acts a placeholder. The first argument of those functions takes a string (which will contain those placeholders), subsequent arguments are used as the values of those placeholders. So %1$s will be replaced by the next and %2$s by the following argument. The ‘s’ means string – it can also be ‘f’ for float or ‘d’ for digit.

    E.g.

     $num = 5;
     $location = 'tree';
     $format = 'There are %2$d monkeys in the %1$s';
     echo sprintf($format, $location, $num );
     //Prints There are 5 monkeys in the tree
    

    In the particular instance you reference it used as follows;

    $html = sprintf($container, $html, esc_attr($args['class']) );
    

    Where $args['class'] contains class name(s) as set here.

    Currently there isn’t a way of adding custom classes (but I’m planning on major improvements to template handling in 1.7 – including ‘templates’ for shortcodes, and widgets etc.).

    I’d suggest wrapping the shortcode in div element with a certain class and apply the styling that way. In any case – I’d recommend avoiding making any changes to the plug-in code as this will be lost in an update.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.