/** * @param $post_id (int) The post to a sell media item post type * @param $term_id (int) The term id for a term from the price-group taxonomy * @param $size_not_available (bool) If true returns and array of unavailable sizes * * @return Array of downloadable sizes or single size if $term_id is present */ public function get_downloadable_size($post_id = null, $attachment_id = null, $term_id = null, $size_not_available = false) { $null = null; $download_sizes = array(); /** * Loop over price groups checking for children, * compare the width and height assigned to a price group * with the width and height of the current image. Remove * sizes that are not downloadable. */ $size_groups = sell_media_get_price_groups($post_id, 'price-group'); if (!empty($size_groups)) { $image = $this->get_original_image_size($attachment_id); foreach ($size_groups as $size) { /** * Check for children only */ if ($size->parent > 0) { /** * Retrieve the height and width for our price group */ $pg_width = sell_media_get_term_meta($size->term_id, 'width', true); $pg_height = sell_media_get_term_meta($size->term_id, 'height', true); /** * Build our array to be returned, the downloadable width and height * are calculated later and added to this array */ $download_sizes[$size->term_id] = array('name' => $size->name); /** * Calculate dimensions and coordinates for a resized image that fits * within a specified width and height. If $crop is true, the largest * matching central portion of the image will be cropped out and resized * to the required size. * * Note we need to pass in $null due to what image_resize_dimensions() returns */ list($null, $null, $null, $null, $download_sizes[$size->term_id]['width'], $download_sizes[$size->term_id]['height']) = image_resize_dimensions($image['original']['width'], $image['original']['height'], $pg_width, $pg_height, $crop = false); /** * If no width/height can be determined we remove it from our array of * available download sizes. */ if (empty($download_sizes[$size->term_id]['width'])) { $unavailable_size[$size->term_id] = array('name' => $download_sizes[$size->term_id]['name'], 'height' => $pg_height, 'width' => $pg_width); unset($download_sizes[$size->term_id]); } /** * Check for portraits and if the available download size is larger than * the original we remove it. */ $terms = wp_get_post_terms($post_id, 'price-group'); $heights[] = ''; if (!empty($terms)) { foreach ($terms as $term) { if ($term->parent != 0) { $height = sell_media_get_term_meta($term->term_id, 'height', true); $heights[] = $height; } } } $smallest_height = min($heights); /** * Compare the original image size with our array of images sizes from * Price Groups array, removing items that are not available. */ if ($image['original']['height'] >= $image['original']['width'] && isset($download_sizes[$size->term_id]) && $download_sizes[$size->term_id]['height'] <= $smallest_height) { $unavailable_size[$size->term_id] = array('name' => $download_sizes[$size->term_id]['name'], 'price' => $download_sizes[$size->term_id]['price'], 'height' => $pg_height, 'width' => $pg_width); unset($download_sizes[$price->term_id]); } } } } // Returns an array of available and unavailable sizes if ($size_not_available) { $sizes = array('available' => $download_sizes, 'unavailable' => empty($unavailable_size) ? null : $unavailable_size); } elseif (empty($term_id)) { $sizes = $download_sizes; } else { // Since we no longer check if the image sold is available in the download sizes // we allow the buyer to download the original image if the size they purchased // is larger than the original image i.e., they can purchase a size they can never // download. // // Hence if they paid for the original, OR they paid for a larger image than // available they get the original image. $sizes = empty($download_sizes[$term_id]) ? 'original' : $download_sizes[$term_id]; } return $sizes; }
/** * Builds html input field (radio or checkbox) * * @since 0.1 */ function sell_media_build_input($taxonomy = null) { if (is_array($taxonomy)) { extract($taxonomy); } if (!isset($label)) { $label = $taxonomy; } // @todo need to merge $defaults = array('value' => 'term_id'); // white list if (empty($prepend)) { $prepend = null; } if (empty($current_term)) { $current_term = null; } extract($defaults); /** All Terms */ $args = array('orderby' => 'id', 'hide_empty' => false); $terms = null; if (isset($post_id)) { $terms = wp_get_post_terms($post_id, $taxonomy); } else { $terms = get_terms($taxonomy, $args); } ?> <?php if ($terms) { ?> <?php do_action('sell_media_build_input_before'); ?> <?php foreach ($terms as $term) { ?> <?php $price = sell_media_get_term_meta($term->term_id, 'markup', true); ?> <input value="<?php echo $prepend; echo $term->{$value}; ?> " class="taxonomy-<?php echo $taxonomy; ?> term-<?php echo $term->slug; ?> <?php echo $taxonomy; ?> -<?php echo $term->term_id; ?> " data-value="<?php echo $term->slug; ?> " data-taxonomy="<?php echo $taxonomy; ?> " data-name="<?php echo $term->name; ?> " data-price="<?php echo $price; ?> " id="<?php echo $taxonomy; ?> -<?php echo $term->slug; ?> " name="<?php echo $taxonomy; ?> " type="<?php echo $type; ?> " /> <?php echo $term->name; ?> <?php if ($price) { ?> +<?php echo $price; ?> %<?php } ?> <br /> <?php } ?> <?php do_action('sell_media_build_input_after'); ?> <?php } }
/** * Determine the markup amount. * * @param $post_id (int) Post ID for a sell media item * @param $price_id (int) The term_id for a price of the price-group taxonomy * @param $license_id (int) The term_id for a price of the licenses taxonomy * * @return (float) returns the full markup amount without currency symbol */ public function markup_amount($post_id = null, $price_id = null, $license_id = null) { $license_obj = get_term_by('id', $license_id, 'licenses'); if (empty($license_obj)) { $markup_amount = 0; } else { $price = $this->verify_the_price($post_id, $price_id); $markup_percent = str_replace("%", "", sell_media_get_term_meta($license_obj->term_id, 'markup', true)); $markup_amount = $markup_percent / 100 * $price; } return $markup_amount; }
/** * Search query * * @since 1.8.7 */ public function search_query($query) { if (!$query->is_search) { return $query; } /** * Only proceed if searching Sell Media */ if ($query->get('post_type') && 'sell_media_item' == $query->get('post_type')) { /** * Add "sell_media_item" and "attachment" to search query */ $post_types = $query->get('post_type'); if ($post_types && 'sell_media_item' == $post_types) { $post_types = array('sell_media_item', 'attachment'); } $query->set('post_type', $post_types); /** * Add post status "inherit" (for attachments) since WP only searches "publish" */ $post_status = $query->get('post_status'); if (!$post_status || 'publish' == $post_status) { $post_status = array('publish', 'inherit'); } if (is_array($post_status)) { $post_status[] = 'inherit'; } $query->set('post_status', $post_status); /** * Exclude password protected collections from search query */ foreach (get_terms('collection') as $term_obj) { $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true); if ($password) { $exclude_term_ids[] = $term_obj->term_id; } } if (!empty($exclude_term_ids)) { $collection_querys = array('relation' => 'AND', array('taxonomy' => 'collection', 'field' => 'id', 'terms' => $exclude_term_ids, 'operator' => 'NOT IN')); $query->set('tax_query', $collections_query); } return $query; } }
/** * Collections * * @since 1.8.5 * @return void */ function sell_media_collection_password_check($query) { if (is_admin()) { return $query; } if (!$query->is_main_query()) { return $query; } // JetPack Infinite Scroll fix if (class_exists('Jetpack') && Jetpack::is_module_active('infinite-scroll')) { return $query; } if (!empty($_GET['sell_media_advanced_search_flag'])) { return; } /** * Check if "collections" is present in query vars */ if (!empty($query->query_vars['collection'])) { $term_obj = get_term_by('slug', $query->query_vars['collection'], 'collection'); if ($term_obj) { $term_id = $term_obj->term_id; } } else { if (is_single() && !empty($query->query['post_type']) && $query->query['post_type'] == 'sell_media_item' && !empty($query->query['sell_media_item'])) { global $wpdb; /** * build an array of terms that are password protected */ foreach (get_terms('collection') as $term_obj) { $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true); if ($password) { $exclude_term_ids[] = $term_obj->term_id; } } /** * Apparently none of our globals are set and the post_id is not in $query * so we run this query to get our post_id */ $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->prefix}posts WHERE `post_name` LIKE '{$query->query['sell_media_item']}' AND post_type LIKE 'sell_media_item';"); /** * Determine if this post has the given term and the term has a password * if it does we set our term_id to the password protected term */ if (!empty($exclude_term_ids)) { foreach ($exclude_term_ids as $t) { if (has_term($t, 'collection', $post_id) && sell_media_get_term_meta($t, 'collection_password', true)) { $term_id = $t; $message = __('This item is password protected', 'sell_media'); } } } } else { if (is_post_type_archive('sell_media_item') && !empty($query->query['post_type']) && $query->query['post_type'] == 'sell_media_item' || is_home() || is_tax() || is_page() || is_single()) { /** * build an array of terms that are password protected */ foreach (get_terms('collection') as $term_obj) { $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true); if ($password) { $exclude_term_ids[] = $term_obj->term_id; } } if (!empty($exclude_term_ids)) { // echo 'exclude these ids: '; $tax_query = array('relation' => 'AND', array('taxonomy' => 'collection', 'field' => 'id', 'terms' => $exclude_term_ids, 'operator' => 'NOT IN')); } if (isset($tax_query)) { $query->set('tax_query', $tax_query); } } else { $term_id = null; } } } /** * If we have a term ID check if this term is password protected */ if (!empty($term_id)) { /** * get the password for the collection */ $password = sell_media_get_term_meta($term_id, 'collection_password', true); if (empty($password)) { $child_term = get_term($term_id, 'collection'); $parent_term = get_term($child_term->parent, 'collection'); if (!empty($parent_term->term_id)) { $password = sell_media_get_term_meta($parent_term->term_id, 'collection_password', true); } else { $password = null; } } if (!isset($_SESSION)) { session_start(); } /** * Since we do not have a "logout link" and can't rely on * "garbage collection", we end our session after 30 minutes. */ if (isset($_SESSION['sell_media']['recent_activity']) && time() - $_SESSION['sell_media']['recent_activity'] > 30 * 60) { session_destroy(); session_unset(); } $_SESSION['sell_media']['recent_activity'] = time(); // the start of the session. if (!empty($password)) { if (!empty($_POST['collection_password']) && $_POST['collection_password'] == $password || !empty($_SESSION['sell_media']['collection_password'][$term_id]) || !empty($_SESSION['sell_media']['collection_password'][$term_id]) && $_SESSION['sell_media']['collection_password'][$term_id] == $password) { if (empty($_SESSION['sell_media']['collection_password'][$term_id])) { $_SESSION['sell_media']['collection_password'][$term_id] = $_POST['collection_password']; } return $query; } else { $custom = locate_template('collection-password.php'); if (empty($custom)) { load_template(SELL_MEDIA_PLUGIN_DIR . '/themes/collection-password.php'); exit; } else { load_template($custom); } } } } else { return $query; } }
/** * 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; } }
/** * Search query * * @since 1.8.7 */ public function search_query($query) { if (!$query->is_search) { return $query; } if ($query->get('post_type') && 'sell_media_item' == $query->get('post_type')) { /** * Exclude password protected collections from search query */ foreach (get_terms('collection') as $term_obj) { $password = sell_media_get_term_meta($term_obj->term_id, 'collection_password', true); if ($password) { $exclude_term_ids[] = $term_obj->term_id; } } if (!empty($exclude_term_ids)) { $collection_querys = array('relation' => 'AND', array('taxonomy' => 'collection', 'field' => 'id', 'terms' => $exclude_term_ids, 'operator' => 'NOT IN')); $query->set('tax_query', $collections_query); } return $query; } }
/** * Retrieve PayPal IPN $_POST, format into _sell_media_payment_data * There is a lot of useless data in PayPal's IPN * This standardizes the way we store payment data * * @param (int)$post_id The post id to a payment * @return Returns meta id on success false on failure */ public function paypal_copy_args($post_id = null) { $paypal_args = maybe_unserialize(get_post_meta($post_id, '_paypal_args', true)); $tmp = array(); $keys = array('email' => 'payer_email', 'first_name' => 'first_name', 'last_name' => 'last_name', 'address_street' => 'address_street', 'address_city' => 'address_city', 'address_state' => 'address_state', 'address_country_code' => 'address_country_code', 'address_zip' => 'address_zip', 'total' => 'mc_gross', 'shipping' => 'mc_handling', 'tax' => 'tax', 'number_products' => 'num_cart_items', 'transaction_id' => 'txn_id', 'gateway' => 'PayPal'); foreach ($keys as $k => $v) { // Assign our contact info if (array_key_exists($v, $paypal_args)) { $tmp[$k] = $paypal_args[$v]; // Assign the products } else { for ($i = 1; $i <= $paypal_args['num_cart_items']; $i++) { $tmp_products = array('name' => $paypal_args['item_name' . $i], 'id' => $paypal_args['item_number' . $i], 'attachment' => $paypal_args['option_selection7_' . $i], 'type' => $paypal_args['option_selection1_' . $i], 'size' => array('name' => $paypal_args['option_selection4_' . $i], 'id' => $paypal_args['option_selection3_' . $i], 'amount' => $paypal_args['mc_gross_' . $i], 'description' => null), 'license' => array('name' => $paypal_args['option_selection5_' . $i], 'id' => empty($paypal_args['option_selection6_' . $i]) ? null : $paypal_args['option_selection6_' . $i], 'description' => null, 'markup' => empty($paypal_args['option_selection6_' . $i]) ? null : str_replace('%', '', sell_media_get_term_meta($paypal_args['option_selection6_' . $i], 'markup', true))), 'qty' => $paypal_args['quantity' . $i], 'total' => $paypal_args['mc_gross_' . $i], 'shipping' => $paypal_args['mc_shipping' . $i], 'handling' => $paypal_args['mc_handling' . $i], 'tax' => $paypal_args['tax' . $i]); $tmp['products'][] = $tmp_products; } } } return update_post_meta($post_id, '_sell_media_payment_meta', $tmp); }
function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('title' => 'Featured Items', 'categoryNumber' => '')); $title = htmlspecialchars($instance['title']); $categoryNumber = htmlspecialchars($instance['categoryNumber']); # Title echo '<p><label for="' . $this->get_field_id('title') . '">' . 'Title:' . '</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>'; # Collection $productTerms = get_terms('collection'); $i = 0; foreach ($productTerms as $collection) { $password = sell_media_get_term_meta($collection->term_id, 'collection_password', true); if ($password) { unset($productTerms[$i]); } $i++; } ?> <p><label for="<?php echo $this->get_field_id('categoryNumber'); ?> "><?php _e(' Select Collection', 'sell_media'); ?> : </label> <select id="<?php echo $this->get_field_id('categoryNumber'); ?> " name="<?php echo $this->get_field_name('categoryNumber'); ?> " value="<?php echo $categoryNumber; ?> "> <option value="" <?php if ($categoryNumber == '') { echo 'selected="selected"'; } ?> ><?php _e('All Collections', 'sell_media'); ?> </option> <?php foreach ($productTerms as $term) { ?> <option value="<?php echo $term->slug; ?> " <?php if ($categoryNumber == $term->slug) { echo 'selected="selected"'; } ?> ><?php echo $term->name; ?> </option> <?php } ?> </select> </p> <?php }
/** * Custom collection column header content * * @since 0.1 */ function sell_media_custom_collection_columns_content($row_content, $column_name, $term_id) { switch ($column_name) { case 'collection_icon': return wp_get_attachment_image(sell_media_get_term_meta($term_id, 'collection_icon_id', true), 'thumbnail'); break; case 'collection_protected': if (sell_media_get_term_meta($term_id, 'collection_password', true)) { $colstatus = "Private"; } else { $colstatus = "Public"; } return $colstatus; break; default: break; } }
/** * Resize and download an image to the specified dimensions * http://codex.wordpress.org/Class_Reference/WP_Image_Editor * * Returns the new image file path * * @since 1.8.5 * @param $product_id * @param $attachment_id * @param $size_id * @return resized image file path */ public function download_image($product_id = null, $attachment_id = null, $size_id = null) { $file_path = Sell_Media()->products->get_protected_file($product_id, $attachment_id); $img = wp_get_image_editor($file_path); if (!is_wp_error($img)) { $width = sell_media_get_term_meta($size_id, 'width', true); $height = sell_media_get_term_meta($size_id, 'height', true); if ($width || $height) { if ($width >= $height) { $max = $width; } else { $max = $height; } $img->resize($max, $max, false); $img->set_quality(100); } $img->stream(); } }
echo sell_media_get_currency_symbol(); echo $settings->default_price; ?> </span></span> </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 } ?>
public function setting_ui() { $parent_terms = get_terms($this->taxonomy, array('hide_empty' => false, 'parent' => 0)); $current_parent = empty($_GET['term_parent']) ? '' : $_GET['term_parent']; if (is_wp_error($parent_terms)) { return; } $tmp = array(); $final = array(); $final['terms'] = null; $count = count($parent_terms); $current_term_id = null; $current_term = null; // Build our menu array foreach ($parent_terms as $term) { if ($current_parent == $term->term_id) { $current_term = $term->name; $current_term_id = $term->term_id; $link = '<span class="nav-tab nav-tab-active">' . $term->name . '</span>'; } else { $link = '<a href="' . admin_url('edit.php?post_type=sell_media_item&page=sell_media_plugin_options&tab=sell_media_size_settings&term_parent=' . $term->term_id) . '" class="nav-tab" data-term_id="' . $term->term_id . '">' . $term->name . '</a>'; } $tmp[] = array('term_id' => $term->term_id, 'name' => $term->name, 'current_id' => $current_term_id, 'current_term' => $current_term, 'html' => $link); $final['menu'] = $tmp; } if (empty($current_parent) || $current_parent == 'new_term') { $final['menu'][] = array('html' => '<span class="nav-tab-active nav-tab menu-add-new"><abbr title="Add menu">+</abbr></span>'); } else { $final['menu'][] = array('html' => '<a href="' . admin_url('edit.php?post_type=sell_media_item&page=sell_media_plugin_options&tab=sell_media_size_settings&term_parent=new_term') . '" class="nav-tab menu-add-new"><abbr title="Add menu">+</abbr></a>'); } // header if (empty($current_term_id)) { $value = null; $data_term_id = null; $class = "button-primary sell-media-add-term"; $link_text = __('Create Price Group', 'sell_media'); $message = null; } else { $data_term_id = $current_term_id; $class = "submitdelete sell-media-delete-term-group"; $message = sprintf("%s %s?\n\n%s", __("Are you sure you want to delete the price group:", "sell_media"), $current_term, __("This will delete the price group and ALL its prices associated with it.", "sell_media")); $link_text = __('Delete Group', 'sell_media'); } $final['header'] = array('html' => '<input name="price_group[term_name]" type="text" class="regular-text" placeholder="' . __('Enter price group name here', 'sell_media') . '" value="' . $current_term . '" data-term_id="' . $data_term_id . '" data-taxonomy="' . $this->taxonomy . '" /> <input type="hidden" value="' . $data_term_id . '" name="price_group[term_id]" /> <a href="#" class="' . $class . '" data-term_id="' . $data_term_id . '" data-message="' . $message . '" data-taxonomy="' . $this->taxonomy . '">' . $link_text . '</a>'); // build terms array $tmp = null; $terms_obj = get_terms($this->taxonomy, array('hide_empty' => false, 'child_of' => $current_term_id, 'orderby' => 'id')); foreach ($terms_obj as $term) { $tmp[] = array_merge((array) $term, array('field' => array('html' => ' <input type="text" class="" name="terms_children[' . $term->term_id . '][name]" size="24" value="' . $term->name . '" /> <p class="description">' . __('Name (shown to buyer, so be descriptive)', 'sell_media') . '</p>')), array('meta' => array('html' => ' <td> <input type="text" class="small-text" name="terms_children[' . $term->term_id . '][width]" value="' . sell_media_get_term_meta($term->term_id, 'width', true) . '"> <p class="description">' . __('Max width (pixels)', 'sell_media') . '</p> </td> <td> <input type="text" class="small-text" name="terms_children[' . $term->term_id . '][height]" value="' . sell_media_get_term_meta($term->term_id, 'height', true) . '"> <p class="description">' . __('Max Height (pixels)', 'sell_media') . '</p> </td> <td> <input type="text" class="small-text" name="terms_children[' . $term->term_id . '][price]" value="' . sprintf('%0.2f', sell_media_get_term_meta($term->term_id, 'price', true)) . '"> <p class="description">' . __('Price', 'sell_media') . ' (' . sell_media_get_currency_symbol() . ')</p> </td>')), array('delete' => array('html' => '<a href="#" class="sell-media-xit sell-media-delete-term" data-taxonomy="' . $this->taxonomy . '" data-term_id="' . $term->term_id . '" data-type="price" data-message="' . sprintf('%s: %s?', __('Are you sure you want to delete the price', 'sell_media'), $term->name) . '">×</a>'))); $final['terms'] = $tmp; } $final_additional = apply_filters('sell_media_additional_meta_price_group', $this->taxonomy, $final['terms']); if (!empty($final_additional)) { $final['terms'] = $final_additional; } else { $final['terms'] = $tmp; } if (has_filter('sell_media_additional_meta_price_group')) { $final['terms'] = apply_filters('sell_media_additional_meta_price_group', $this->taxonomy, $final['terms']); } else { $final['terms'] = $tmp; } // Default terms $max = count($final['terms']) < 1 ? 1 : 1; $html = null; for ($i = 1; $i <= $max; $i++) { $html .= '<tr class="sell-media-price-groups-row" data-index="' . $i . '"> <td class="name"> <input type="text" class="" name="new_child[' . $i . '][name]" size="24" value=""> <p class="description">' . __('Name (shown to buyer, so be descriptive)', 'sell_media') . '</p> </td> <td> <input type="hidden" class="sell-media-price-group-parent-id" name="new_child[' . $i . '][parent]" value="' . $current_term_id . '" /> <input type="text" class="small-text" name="new_child[' . $i . '][width]" value=""> <p class="description">' . __('Max width (pixels)', 'sell_media') . '</p> </td> <td> <input type="text" class="small-text" name="new_child[' . $i . '][height]" value=""> <p class="description">' . __('Max height (pixels)', 'sell_media') . '</p> </td> <td> <input type="text" class="small-text" name="new_child[' . $i . '][price]" value=""> <p class="description">' . __('Price', 'sell_media') . ' (' . sell_media_get_currency_symbol() . ')</p> </td> </tr>'; } $price_copy = apply_filters('sell_media_default_price_copy', __('The sizes listed below determine the maximum dimensions in pixels. Price Groups only apply to images.', 'sell_media'), $this->taxonomy); $price_group_copy = apply_filters('sell_media_default_price_group_copy', __('Create a price group to add prices to.', 'sell_media'), $this->taxonomy); ?> <div id="menu-management-liquid" class="sell-media-price-groups-container"> <input type="hidden" value="<?php echo $this->taxonomy; ?> " name="taxonomy" id="smtaxonomy" /> <div id="menu-management"> <div class="nav-tabs-nav"> <div class="nav-tabs-wrapper"> <div class="nav-tabs"> <?php foreach ($final['menu'] as $menu) { ?> <?php echo $menu['html']; ?> <?php } ?> </div> </div> </div> <!-- Nav menu --> <div class="menu-edit"> <!-- Print out the input field w/term name and delete button --> <div id="nav-menu-header"> <?php foreach ($final['header'] as $header) { ?> <?php echo $header; ?> <?php } ?> </div> <table class="form-table sell-media-price-groups-table" id="sell-media-<?php echo $this->taxonomy; ?> "> <tbody> <tr> <td colspan="4"> <p> <?php if (isset($_GET['term_parent']) && $_GET['term_parent'] == 'new_term') { ?> <?php echo $price_group_copy; ?> <?php } else { ?> <?php echo $price_copy; ?> <?php } ?> </p> </td> </tr> <?php if (empty($current_term_id)) { ?> <?php } else { ?> <?php if ($final['terms'] && is_array($final['terms'])) { foreach ($final['terms'] as $term) { ?> <tr> <td><?php echo $term['field']['html']; ?> </td> <?php echo $term['meta']['html']; ?> <td><?php echo $term['delete']['html']; ?> </td> </tr> <?php } } ?> <?php echo apply_filters('sell_media_default_price_group_children', $html, $this->taxonomy, $current_term_id); ?> <?php } ?> </tbody> <?php if (!empty($current_term_id)) { ?> <tfoot> <tr colspan="4"> <td> <a href="#" class="button sell-media-price-groups-repeater-add"><?php _e('Add New Price', 'sell_media'); ?> </a> </td> </tr> </tfoot> <?php } ?> </table> <div class="nav-menu-footer"> <?php if (!empty($current_term)) { ?> <a href="#" class="button-primary sell-media-save-term" data-taxonomy="<?php echo $this->taxonomy; ?> "><?php _e('Save Price Group', 'sell_media'); ?> </a> <?php } ?> </div><!-- /.nav-menu-footer --> </div> </div><!-- /.menu-edit --> </div><!-- /#menu-management --> <?php }