示例#1
0
/**
 * Show lightbox
 *
 * @since 1.9.2
 * @param int $post_id Item ID
 * @return void
 */
function sell_media_show_lightbox($post_id)
{
    echo sell_media_lightbox_link($post_id);
}
示例#2
0
/**
 * Query lightbox items
 */
function sell_media_lightbox_query()
{
    $html = '';
    // Decode the lightbox array of IDs since they're encoded
    if (isset($_COOKIE['sell_media_lightbox'])) {
        $items = json_decode(stripslashes($_COOKIE['sell_media_lightbox']), true);
    }
    // Check if items in lightbox
    if (isset($items)) {
        $i = 0;
        // loop over items from 'sell_media_lightbox' cookie
        foreach ($items as $item) {
            // Old cookies were stored as simple array of ids
            // New cookies are stored as a multidimensional array of ids
            // so that we can support attachments (galleries)
            $post_id = !empty($item['post_id']) ? $item['post_id'] : $item;
            $attachment_id = !empty($item['attachment_id']) ? $item['attachment_id'] : sell_media_get_attachment_id($post_id);
            $permalink = !empty($item['attachment_id']) ? add_query_arg('id', $attachment_id, get_permalink($post_id)) : get_permalink($attachment_id);
            $i++;
            $class = $i % 3 == 0 ? ' end' : '';
            $html .= '<div id="sell-media-' . $attachment_id . '" class="sell-media-grid' . $class . '">';
            $html .= '<div class="item-inner">';
            $html .= '<a href="' . esc_url($permalink) . '">' . sell_media_item_icon($attachment_id, apply_filters('sell_media_thumbnail', 'medium'), false) . '</a>';
            $html .= '<span class="item-overlay">';
            $html .= '<h3><a href="' . esc_url($permalink) . '">' . get_the_title($post_id) . '</a></h3>';
            $html .= sell_media_item_buy_button($post_id, $attachment_id, 'text', __('Buy', 'sell_media'), false);
            $html .= sell_media_lightbox_link($post_id, $attachment_id);
            $html .= '</span>';
            $html .= '</div>';
            $html .= '</div>';
        }
    } else {
        $html .= __('Your lightbox is empty.', 'sell_media');
    }
    return $html;
}