function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        extract($args);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        global $post;
        //Returns Array of Term Names for "collection"
        $terms = wp_get_post_terms($post->ID, 'collection', array("fields" => "slugs"));
        if (!empty($terms)) {
            $args = array('tax_query' => array(array('taxonomy' => 'collection', 'field' => 'slug', 'terms' => $terms)), 'posts_per_page' => '6', 'orderby' => 'rand');
        } else {
            $args = array('post_type' => 'sell_media_item', 'field' => 'slug', 'orderby' => 'rand', 'posts_per_page' => '6');
        }
        ?>

        <div class="sell-media-similar-widget sell-media">

            <?php 
        // Get available image sizes
        $image_sizes = get_intermediate_image_sizes();
        ?>

            <?php 
        $type_posts = new WP_Query($args);
        ?>
            <?php 
        while ($type_posts->have_posts()) {
            $type_posts->the_post();
            global $post;
            ?>

            <div class="sell-media-widget-item-warp sell-media-grid">
                <div class="sell-media-widget-thumb-wrap">
                    <a href="<?php 
            echo get_permalink();
            ?>
">
                        <?php 
            sell_media_item_icon($post->ID, apply_filters('sell_media_thumbnail', 'thumbnail'));
            ?>
                    </a>
                </div>
            </div> <!--  .sell-media-widget-item-warp  -->

    <?php 
        }
        wp_reset_postdata();
        ?>

</div><!-- .sell-media-recent -->


<?php 
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        $categoryNumber = empty($instance['categoryNumber']) ? '' : $instance['categoryNumber'];
        extract($args);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        global $post;
        $args = array('posts_per_page' => 6, 'field' => 'slug', 'orderby' => 'rand');
        if (!empty($categoryNumber)) {
            $args['taxonomy'] = 'collection';
            $args['term'] = $categoryNumber;
        } else {
            $args['post_type'] = 'sell_media_item';
        }
        ?>

		<div class="sell-media-featured-widget sell-media">

			<?php 
        $type_posts = new WP_Query($args);
        ?>
			<?php 
        while ($type_posts->have_posts()) {
            $type_posts->the_post();
            global $post;
            ?>

				<div class="sell-media-widget-item-warp sell-media-grid">
					<div class="sell-media-widget-thumb-wrap">
						<a href="<?php 
            echo get_permalink();
            ?>
">
							<?php 
            sell_media_item_icon($post->ID, apply_filters('sell_media_thumbnail', 'thumbnail'));
            ?>
						</a>
					</div>
				</div> <!--  .sell-media-widget-item-warp  -->

				<?php 
        }
        wp_reset_postdata();
        ?>

			</div><!-- .sell-media-featured -->

<?php 
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        extract($args);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<div class="sell-media-recent-widget sell-media">
			<?php 
        // Get available image sizes
        $image_sizes = get_intermediate_image_sizes();
        ?>

			<?php 
        $args = array('post_type' => 'sell_media_item', 'field' => 'slug', 'orderby' => 'ASC', 'posts_per_page' => '6');
        $type_posts = new WP_Query($args);
        ?>

			<?php 
        while ($type_posts->have_posts()) {
            $type_posts->the_post();
            global $post;
            ?>
			<div class="sell-media-widget-item-warp sell-media-grid">
				<div class="sell-media-widget-thumb-wrap">
					<a href="<?php 
            echo get_permalink();
            ?>
">
						<?php 
            sell_media_item_icon($post->ID, apply_filters('sell_media_thumbnail', 'thumbnail'));
            ?>
					</a>
				</div>
			</div> <!--  .sell-media-widget-item-warp  -->

			<?php 
        }
        wp_reset_postdata();
        ?>

		</div><!-- .sell-media-recent-widget -->

<?php 
        echo $after_widget;
    }
示例#4
0
 /**
  * By default, WordPress search results page shows.
  *
  * @param  [string] $excerpt [the_excerpt]
  * @return [string]          [the_excerpt]
  */
 public function the_search_excerpt($excerpt)
 {
     // Only proceed if on Sell Media search page
     if (is_search() && isset($_GET['post_type']) && 'sell_media_item' == $_GET['post_type']) {
         // return if no ID
         $id = get_the_ID();
         if (!$id) {
             return $excerpt;
         }
         // set variables
         $ancestors = get_post_ancestors($id);
         // check if in gallery (has post_parent)
         $link = $ancestors ? esc_url(add_query_arg('id', $id, get_permalink($ancestors[0]))) : get_permalink($id);
         $caption = wptexturize(get_post($id)->post_excerpt);
         $attributes = wp_get_attachment_image_src($id);
         // compile output with thumbnail image
         $excerpt = "<div id='attachment_{$id}' class='wp-caption aligncenter'>";
         $excerpt .= "<a href='{$link}'>";
         $excerpt .= sell_media_item_icon($id, 'large', false);
         $excerpt .= "</a>";
         if ($caption) {
             $excerpt .= "<p class='wp-caption-text'>{$caption}</p>";
         }
         $excerpt .= "</div>";
     }
     return $excerpt;
 }
示例#5
0
/**
 * Filter custom column content on the edit media table.
 *
 * @since 0.1
 */
function sell_media_item_content($column, $post_id)
{
    switch ($column) {
        case "icon":
            $html = '<a href="' . site_url() . '/wp-admin/post.php?post=' . $post_id . '&action=edit">';
            $html .= sell_media_item_icon($post_id, 'thumbnail', false);
            $html .= '</a>';
            echo $html;
            break;
        case "sell_media_price":
            $price = get_post_meta($post_id, 'sell_media_price', true);
            $settings = sell_media_get_plugin_options();
            if ($price) {
                echo sell_media_get_currency_symbol() . number_format($price, 2, '.', '');
            } elseif ($settings->default_price) {
                echo sell_media_get_currency_symbol() . number_format($settings->default_price, 2, '.', '');
            } else {
                echo __('No price set', 'sell_media');
            }
            break;
        default:
            break;
    }
}
示例#6
0
/**
 * Displays all collections.
 * Adds the 'sell_media_list_all_collections' short code to the editor. [sell_media_list_all_collections]
 *
 * @since 1.5.3
 */
function sell_media_list_all_collections_shortcode($atts)
{
    extract(shortcode_atts(array('details' => 'false', 'thumbs' => 'true'), $atts));
    if ('false' == $thumbs) {
        $html = null;
        $html .= '<div class="sell-media-collections-shortcode">';
        $taxonomy = 'collection';
        $term_ids = array();
        foreach (get_terms($taxonomy) as $term_obj) {
            $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true);
            if ($password) {
                $term_ids[] = $term_obj->term_id;
            }
        }
        $args = array('orderby' => 'name', 'hide_empty' => true, 'parent' => 0, 'exclude' => $term_ids);
        $terms = get_terms($taxonomy, $args);
        if (empty($terms)) {
            return;
        }
        $html .= '<ul class="sell-media-collections-shortcode-list">';
        foreach ($terms as $term) {
            $html .= '<li class="sell-media-collections-shortcode-list-item">';
            $html .= '<a href="' . get_term_link($term->slug, $taxonomy) . '" class="sell-media-collections-shortcode-list-item-link">' . $term->name . '</a>';
            $html .= '</li>';
        }
        $html .= '</ul>';
        $html .= '</div>';
        return $html;
    } else {
        $html = null;
        $html .= '<div class="sell-media-collections-shortcode sell-media">';
        $html .= '<div class="sell-media-grid-container">';
        $taxonomy = 'collection';
        $term_ids = array();
        foreach (get_terms($taxonomy) as $term_obj) {
            $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true);
            if ($password) {
                $term_ids[] = $term_obj->term_id;
            }
        }
        $args = array('orderby' => 'name', 'hide_empty' => true, 'parent' => 0, 'exclude' => $term_ids);
        $terms = get_terms($taxonomy, $args);
        if (empty($terms)) {
            return;
        }
        foreach ($terms as $term) {
            $args = array('post_status' => 'publish', 'taxonomy' => 'collection', 'field' => 'slug', 'term' => $term->slug, 'tax_query' => array(array('taxonomy' => 'collection', 'field' => 'id', 'terms' => $term_ids, 'operator' => 'NOT IN')));
            $posts = new WP_Query($args);
            $post_count = $posts->found_posts;
            if ($post_count != 0) {
                $html .= '<div class="sell-media-grid third">';
                $html .= '<div class="item-inner sell-media-collection">';
                $args = array('posts_per_page' => 1, 'taxonomy' => 'collection', 'field' => 'slug', 'term' => $term->slug);
                $posts = new WP_Query($args);
                foreach ($posts->posts as $post) {
                    $html .= '<a href="' . get_term_link($term->slug, $taxonomy) . '" class="collection">';
                    $collection_attachment_id = sell_media_get_term_meta($term->term_id, 'collection_icon_id', true);
                    $html .= sell_media_item_icon($post->ID, apply_filters('sell_media_thumbnail', 'medium', false), false);
                    if ('true' == $details) {
                        $settings = sell_media_get_plugin_options();
                        $html .= '<div class="item-overlay">';
                        $html .= '<div class="collection-details">';
                        $html .= '<span class="collection-count">';
                        $html .= '<span class="count">' . $post_count . '</span>' . __(' images in ', 'sell_media') . '<span class="collection">' . $term->name . '</span>' . __(' collection', 'sell_media');
                        $html .= '</span>';
                        $html .= '<span class="collection-price">';
                        $html .= __('Starting at ', 'sell_media') . '<span class="price">' . sell_media_get_currency_symbol() . $settings->default_price . '</span>';
                        $html .= '</span>';
                        $html .= '</div>';
                        $html .= '</div>';
                        $html .= '<h3>' . $term->name . '</h3>';
                    }
                    $html .= '</a>';
                }
                $html .= '</div>';
                $html .= '</div>';
            }
        }
        $html .= '</div>';
        $html .= '</div>';
        return $html;
    }
}
示例#7
0
$is_package = Sell_Media()->products->is_package($post_id);
// check if has assigned price group
$has_price_group = Sell_Media()->products->has_price_group($post_id);
// assign price
$price = $has_price_group ? 0 : Sell_Media()->products->get_original_price($post_id);
// assign licenses
$licenses = wp_get_post_terms($post_id, 'licenses');
// featured image id
$image_id = sell_media_has_multiple_attachments($post_id) ? $attachment_id : $post_id;
?>
<div class="main-container sellMediaCart_shelfItem">
    <span class="close">&times;</span>
    <div class="content">
        <header>
            <figure><?php 
sell_media_item_icon($image_id);
?>
</figure>
            <figcaption><?php 
echo get_the_title($post_id);
if (sell_media_has_multiple_attachments($post_id)) {
    echo ', ' . $attachment_id;
}
?>
</figcaption>
        </header>
        <section>
            <?php 
/*
 * Set required cart items to be passed to gateway
 * Any element tagged with item_* inside .sellMediaCart_shelfItem will be passed as an option/value key pair to PayPal
示例#8
0
 /**
  * Used to build out an HTML table for a single payment containing all items for that payment
  *
  * @param $post_id (int) The post_id for a post of post type "sell_media_payment"
  *
  * @return $html (string) An html table containing the item, size, price, qty, and other usefulness
  */
 public function payment_table($post_id = null)
 {
     $html = null;
     $html .= '<table class="wp-list-table widefat" cellspacing="0">';
     $html .= '<thead>
             <tr>
                 <th scope="col">' . __('Item', 'sell_media') . '</th>
                 <th>' . __('Size', 'sell_media') . '</th>
                 <th>' . __('Price', 'sell_media') . '</th>
                 <th>' . __('Quantity', 'sell_media') . '</th>
                 <th>' . __('License', 'sell_media') . '</th>
                 <th>' . apply_filters('sell_media_download_link_label', 'Download Link') . '</th>
             </tr>
         </thead>';
     $html .= '<tbody>';
     $products = $this->get_products($post_id);
     if ($products) {
         foreach ($this->get_products($post_id) as $product) {
             $product['attachment'] = !empty($product['attachment']) ? $product['attachment'] : null;
             $product['size']['name'] = !empty($product['size']['name']) ? $product['size']['name'] : null;
             $product['size']['id'] = !empty($product['size']['id']) ? $product['size']['id'] : null;
             $product['size']['amount'] = !empty($product['size']['amount']) ? $product['size']['amount'] : null;
             $product['license']['name'] = !empty($product['license']['name']) ? $product['license']['name'] : null;
             $image_id = $product['attachment'] ? $product['attachment'] : $product['id'];
             $html .= '<tr class="" valign="top">';
             $html .= '<td class="media-icon">';
             $html .= '<a href="' . get_edit_post_link($product['id']) . '">' . sell_media_item_icon($image_id, 'medium', false) . '</a></td>';
             $html .= '<td>' . $product['size']['name'] . '</td>';
             $html .= '<td>' . sell_media_get_currency_symbol() . $product['size']['amount'] . '</td>';
             $html .= '<td>' . $product['qty'] . '</td>';
             $html .= '<td>' . $product['license']['name'] . '</td>';
             if (!empty($product['type']) && 'print' == $product['type']) {
                 $html .= '<td class="title column-title">Sold a print</td>';
             } else {
                 $html .= '<td class="title column-title"><input type="text" value="' . $this->get_download_link($post_id, $product['id'], $product['attachment'], $product['size']['id']) . '" /></td>';
             }
             $html .= '</tr>';
         }
         // get legacy (pre 1.8) purchase data
     } else {
         $payment_meta = get_post_meta($post_id, '_sell_media_payment_meta');
         if (!$payment_meta) {
             return;
         }
         $products_legacy = maybe_unserialize($payment_meta['products']);
         if ($products_legacy) {
             foreach ($products as $product) {
                 $html .= '<tr class="" valign="top">';
                 $html .= '<td class="media-icon">';
                 $html .= '<a href="' . get_edit_post_link($product['id']) . '">' . sell_media_item_icon($product['id'], 'medium', false) . '</a></td>';
                 $html .= '<td>' . $product['price']['name'] . '</td>';
                 $html .= '<td>' . sell_media_get_currency_symbol() . $product['price']['amount'] . '</td>';
                 $html .= '<td>' . $product['qty'] . '</td>';
                 $html .= '<td>' . $product['license']['name'] . '</td>';
                 $html .= '<td class="title column-title"><input type="text" value="' . $this->get_download_link($post_id, $product['id'], $product['attachment'], $product['size']['id']) . '" /></td>';
                 $html .= '</tr>';
             }
         }
         // foreach
     }
     // if legacy
     $html .= '</tbody>';
     $html .= '</table>';
     return $html;
 }
示例#9
0
/**
 * Add media (featured image, etc) before the_content
 *
 * @since 1.9.2
 * @global $post
 *
 * @param $content The the_content field of the item object
 * @return string the content with any additional data attached
 */
function sell_media_append_media($post_id)
{
    $html = '';
    $sell_media_taxonomies = get_object_taxonomies('sell_media_item');
    if (is_post_type_archive('sell_media_item') || is_tax($sell_media_taxonomies) || is_search()) {
        $html .= '<a href="' . get_permalink($post_id) . '" ' . sell_media_link_attributes($post_id) . '>' . sell_media_item_icon($post_id, 'large', false) . '</a>';
    } elseif (is_singular('sell_media_item')) {
        sell_media_set_post_views($post_id);
        if (sell_media_has_multiple_attachments($post_id)) {
            $html .= sell_media_gallery($post_id);
        } else {
            sell_media_item_icon($post_id, 'large');
            $html .= '<p class="sell-media-caption">';
            $html .= '<span class="sell-media-title">' . sell_media_get_attachment_meta($post_id, 'title') . '</span>';
            if (sell_media_get_attachment_meta($post_id, 'caption')) {
                $html .= ' &mdash; ';
                $html .= sell_media_get_attachment_meta($post_id, 'caption');
            }
            $html .= '</p>';
        }
    }
    echo apply_filters('sell_media_append_media_filter', $html, $post_id);
}
示例#10
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;
}
示例#11
0
                                            </div>
                                        </div>
                                        <?php 
                $args = array('posts_per_page' => 1, 'taxonomy' => 'collection', 'field' => 'slug', 'term' => $child->slug);
                $posts = new WP_Query($args);
                ?>

                                        <?php 
                foreach ($posts->posts as $post) {
                    ?>
                                            <?php 
                    $collection_attachment_id = sell_media_get_term_meta($child->term_id, 'collection_icon_id', true);
                    if (!empty($collection_attachment_id)) {
                        echo wp_get_attachment_image($collection_attachment_id, 'sell_media_item');
                    } else {
                        sell_media_item_icon($post->ID, 'sell_media_item');
                    }
                    ?>
                                        <?php 
                }
                ?>
                                    </a>
                                </div><!-- .item-inner -->
                            </div>
                        <?php 
            }
            ?>
<!-- loop over term children -->
                    <?php 
        }
        ?>