-
Notifications
You must be signed in to change notification settings - Fork 33
Activation
Archetyped edited this page May 15, 2020
·
7 revisions
SLB automatically activates links in recognized content areas.
The following content areas are supported by default:
- Posts/Pages (including custom post types)
- Widgets
- Menus
Support for additional content areas can be enabled via extensions:
- WooCommerce Extension - Adds support for WooCommerce product content areas (product gallery, short description, etc.).
- Request support for a content area - Support for content areas is driven my your suggestions.
Other content areas can be activated using SLB's slb_activate()
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;
These are the parameters that can be passed to slb_activate()
-
$content
(string
) Content containing links to be activated -
$group
(string
) Name of group to add activate links to in lightbox (e.g. for slideshows)- Note: Grouping must be enabled in SLB's admin settings for this parameter to have any effect.
📒 Note: Code should be added to a theme's post loop.
// Link post thumbnail to full-size image.
if ( has_post_thumbnail() ) {
$thumbnail = [
// URI of full-size post thumbnail image.
'uri' => get_the_post_thumbnail_url( null, 'full' ),
// HTML to display post thumbnail.
'img' => get_the_post_thumbnail(),
];
// Build thumbnail link.
$thumbnail['link'] = sprintf( '<a href="%s">%s</a>', esc_attr( $thumbnail['uri'] ), $thumbnail['img'] );
// Display full-size image in lightbox when clicked.
if ( function_exists( 'slb_activate' ) ) {
$thumbnail['link'] = slb_activate( $thumbnail['link'] );
}
// Display post thumbnail.
echo $thumbnail['link'];
}