What’s New in Simple Lightbox 2.3.0

By Sol in Lab

191 Commits Ago…

It seems like only yesterday that Simple Lightbox (SLB) 2.2.2 was set free upon the world, but 191 commits have actually taken place since v2.2.2 was released barely more than a month ago.

Simple Lightbox 2.3.0 is a big update with lots of new features and enhancements. Let’s take a look at what’s new in this release.

Activate Anywhere

You asked for it, so here it is. slb_activate() is a new template tag that allows you to activate content with SLB anywhere. Themes and plugins can now activate content that is not directly supported by SLB, such as featured images in templates or plugin-specific output.

Content activated with slb_activate() supports all of SLB’s awesome functionality you’re used to in natively-supported content areas such as:

  • Intelligent link activation
  • Support for WordPress attachments
  • Use metadata from your site’s media library (titles, captions, descriptions, etc.)
  • Support for additional content types (video, etc.) via add-ons
  • Shortcode support (see next section)

Usage

slb_activate() is used like a standard WordPress template tag. Simply pass the content to slb_activate() and it will process and return the activated content.

$content = 'content with links and stuff to activate';
if ( function_exists('slb_activate') )
    $content = slb_activate($content);
echo $content;

New Shortcodes

Simple Lightbox has two new shortcodes in v2.3.0 that give you even greater control over how content is activated by SLB:

Note: Due to formatting issues with WordPress, shortcodes in the examples below use curly braces ({ / }) in place of square braces ([ / ]) normally used for shortcodes. Make sure to use square braces in your posts when using these shortcodes.

Exclude

You can now manually exclude parts of a post from being activated by SLB by using the slb_exclude shortcode. Any content between the shortcode’s opening and closing tags will not be activated by SLB.

Some text here.  Links up here will be activated normally.

{slb_exclude}Nothing between these tags will be activated by SLB{/slb_exclude}

More text here. This content will be activated normally.

Group

You can also manually group links in content using the slb_group shortcode. Grouped links are displayed in the lightbox as a slideshow.

Some text here.

{slb_group}Links between these tags will be grouped together.{/slb_group}

More text here.

By default, links grouped using the slb_group shortcode will be assigned to an automatically-generated group. If you want to assign a specific group to some links, you can use the id attribute in the shortcode. This allows you to group links in different parts of a post (or across multiple posts) together.

Some text here

{slb_group id="group-1"}Links in here will be grouped together{/slb_group}

More text here

{slb_group id="group-1"}These links will be in the same group as the ones above{/slb_group}

New Filters

Several new filters have been added to SLB 2.3.0, allowing users and developers to extend and customize SLB’s behavior.

slb_pre_process_links

Filter content before it is processed by SLB.

  • Parameters
    1. $content (string) – Content to be processed by SLB.
  • Return (string) – Updated content to be processed by SLB

slb_post_process_links

Filter content after it has been processed by SLB.

  • Parameters
    1. $content (string) – Content processed by SLB
  • Return (string) – Updated content

slb_process_link_attributes

Filter a link’s attributes before the link is saved.

  • Parameters
    1. $attributes (array) – The link’s attributes (key = attribute name / value = attribute value)
  • Return (array) – Updated link attributes

slb_media_item_properties

Filter the properties associated with an item activated by SLB (e.g. image properties from WordPress’ media library).

  • Parameters
    1. $properties (object) – Item properties
  • Return (object) – Updated item properties

slb_pre_exclude_content

Filter content before instances of the slb_exclude shortcode are processed.

  • Parameters
    1. $content (string) – Content before slb_exclude shortcodes are processed.
  • Return (string) – Updated content

slb_exclude_shortcodes

Exclude specific shortcodes from activation by SLB.

  • Parameters
    1. $shortcodes (array) – List of shortcodes to exclude from activation.
  • Return (array) – Updated list of shortcodes to exclude.

slb_group_shortcodes

Automatically group links in content generated by specific shortcodes when activated by SLB.

  • Parameters
    1. $shortcodes (array) – List of shortcodes to group automatically.
  • Return (array) – Updated list of shortcodes to group.

Bye-Bye Default Title

When you upload images to WordPress’ media library, WordPress will automatically generate values for the required metadata fields if you do not set values for these fields yourself.

One of the required fields is the image’s title field. By default, WordPress uses the image’s file name when automatically-generating a title. This has been a point of confusion for some users who think the image’s file name is being displayed in the lightbox, when in fact SLB is using the title from the media library.

You now can control whether to display the default WordPress-generated title using the “Enable default title” option in SLB’s settings. When this option is disabled, the default WordPress-generated title will not be displayed and the title will instead be blank in the lightbox.

Faster Client-Side Loading

Optimized versions of Simple Lightbox’s JavaScript files are used to improve client-side loading. By removing unnecessary white space, SLB’s client-side footprint is reduced by nearly 60%.

Of course, development versions are still included if you want to peruse the code or load them instead of the optimized production files.

Ready for the Future

WordPress 3.9 is coming and SLB is ready for it. SLB has been tested against the beta versions of WordPress’ upcoming update to make sure that SLB continues to run perfectly when the WordPress 3.9 is officially released.

Clean & Polish

Aside from that, SLB’s code has been cleaned and polished to make SLB run faster and smoother. SLB was already fast and now it’s faster.

A Big Update, The Next One Has Already Begun

SLB 2.3.0 was a big update with a lot of new features and optimizations. Now that 2.3.0 is out the door, work can continue on the next update.

Yep, you read that right, work on SLB 2.4 is already underway and it’s going to make SLB even faster and more robust.

For your reference, here’s the full list of changes in SLB 2.3.0:

  • Update: WordPress 3.9 support
  • Update: Support URI, content
  • Add: Enhanced grouping support
  • Add: Shortcode: slb_group
  • Add: Shortcode: slb_exclude
  • Add: Filter: slb_pre_process_links
  • Add: Filter: slb_post_process_links
  • Add: Filter: slb_process_link_attributes
  • Add: Filter: slb_media_item_properties
  • Add: Filter: slb_pre_exclude_content
  • Add: Filter: slb_exclude_shortcodes
  • Add: Filter: slb_group_shortcodes
  • Add: Template Tag: slb_activate() – Manually activate content
  • Add: Option to enable/disable usage of WordPress-generated media title
  • Add: Dev mode
  • Add: Theme breakpoints
  • Optimize: Remove deprecated code
  • Optimize: Remove deprecated legacy support
  • Optimize: Content exclusion performance
  • Optimize: Content grouping performance
  • Optimize: Harden code against third-party post query modifications
  • Optimize: Utility code
  • Optimize: Loading process
  • Optimize: Client-side code
  • Optimize: Client-side: Code loading
  • Optimize: Client-side: Simplified dependency detection
  • Optimize: Client-side: Default Theme transitions
  • Optimize: Grunt: Cleanup
  • Optimize: Grunt: Path abstraction
  • Optimize: Grunt: Task loading
  • Optimize: Grunt: Selective file compilation

Related

  • Simple Lightbox — The only lightbox custom-built specifically for WordPress.