/** * Adds the 'sell_media' short code to the editor. [sell_media_item] * * @since 0.1 */ function sell_media_item_shortcode($atts) { extract(shortcode_atts(array('style' => 'default', 'color' => 'blue', 'id' => '', 'attachment' => '', 'text' => 'BUY', 'size' => 'medium', 'align' => 'center'), $atts)); $image = sell_media_item_icon($id, $size, false); $text = apply_filters('sell_media_purchase_text', $text, $id); if (sell_media_has_multiple_attachments($id)) { $button = sell_media_item_buy_button($id, $attachment, 'button', $text, false); } else { $button = ''; } return '<div class="sell-media-item-container sell-media-align' . $align . ' "><a href="' . get_permalink($id) . '">' . $image . '</a>' . $button . '</div>'; }
/** * Show item links * * @param $post_id * @return $html * @since 2.0.1 */ function sell_media_item_links($post_id) { return '<p id="sell-media-item-links-' . $post_id . '" class="sell-media-item-links">' . sell_media_item_buy_button($post_id, $attachment_id = '', 'text', __('Buy', 'sell_media'), false) . ' | ' . sell_media_lightbox_link($post_id) . ' | <a href="' . get_permalink($post_id) . '" class="sell-media-permalink">' . __('More', 'sell_media') . ' »</a></p>'; }
/** * Show item links * * @param $post_id * @return $html * @since 2.0.1 */ function sell_media_item_links($post_id) { $links = sell_media_item_buy_button($post_id, $attachment_id = '', 'text', __('Buy', 'sell_media'), false) . ' | ' . sell_media_lightbox_link($post_id) . ' | <a href="' . get_permalink($post_id) . '" class="sell-media-permalink">' . __('More', 'sell_media') . ' »</a>'; $html = '<p id="sell-media-item-links-' . $post_id . '" class="sell-media-item-links">'; $html .= apply_filters('sell_media_item_links_filter', $links, $post_id); $html .= '</p>'; return $html; }
/** * 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; }