/** * Set various messages * * @since 1.0 * @todo provide better filtering of messages */ function edd_wl_set_messages() { // get array of messages $messages = edd_wl_messages(); /** * wish-lists.php */ // no lists if no posts if (!edd_wl_get_query() && edd_wl_is_page('wish-lists')) { edd_wl_set_message('no_lists', $messages['no_lists']); } /** * wish-list-create.php */ // must login if (edd_wl_is_page('create') && !edd_wl_allow_guest_creation()) { edd_wl_set_message('must_login', $messages['must_login']); } /** * wish-list-view.php */ if (edd_wl_is_page('view')) { $downloads = edd_wl_get_list_id() ? edd_wl_get_wish_list(edd_wl_get_list_id()) : array(); // list updated if (isset($_GET['list']) && $_GET['list'] == 'updated') { edd_wl_set_message('list_updated', $messages['list_updated']); } // list created if (isset($_GET['list']) && $_GET['list'] == 'created') { if (is_user_logged_in()) { edd_wl_set_message('list_created', $messages['list_created']); } else { edd_wl_set_message('list_created', $messages['list_created_guest']); } } // no downloads if (empty($downloads)) { edd_wl_set_message('no_downloads', $messages['no_downloads']); } } }
<?php /** * Wish List template */ // get list ID $list_id = edd_wl_get_list_id(); // get the downloads from the wish list $downloads = edd_wl_get_wish_list($list_id); // get list post object $list = get_post($list_id); // title $title = get_the_title($list_id); //status $privacy = get_post_status($list_id); ?> <?php if ($list_id) { ?> <p><?php echo $list->post_content; ?> </p> <?php } ?> <?php if ($downloads) { ?>
/** * Purchase all items in wish list * * @since 1.0.2 * @param [type] $item [description] * @return [type] [description] */ function edd_wl_add_all_to_cart_link($list_id = 0, $args = array()) { if (!apply_filters('edd_wl_show_add_all_to_cart_link', true)) { return; } $defaults = apply_filters('edd_wl_add_all_to_cart_link_defaults', array('list_id' => $list_id, 'text' => __('Add all to cart', 'edd-wish-lists'), 'style' => 'button', 'color' => '', 'class' => 'edd-wl-action edd-wl-add-all-to-cart', 'wrapper' => 'p', 'wrapper_class' => '')); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); // return if there's only 1 item in list $list = edd_wl_get_wish_list($list_id); if (count($list) == 1) { return; } // change CSS class based on style chosen if ('button' == $style) { $style = 'edd-wl-button'; } elseif ('plain' == $style) { $style = 'plain'; } $html = ''; $button = sprintf('<a href="' . add_query_arg(array('edd_action' => 'wl_purchase_all', 'list_id' => $list_id)) . '" class="%1$s">%2$s</a>', implode(' ', array($style, $color, trim($class))), esc_attr($text)); $wrapper_class = $wrapper_class ? ' class="' . $wrapper_class . '"' : ''; if ($wrapper) { $html .= '<' . $wrapper . $wrapper_class . '>' . $button . '</' . $wrapper . '>'; } else { $html .= $button; } echo $html; $html = ob_get_clean(); return apply_filters('edd_wl_add_all_to_cart_link', $html); }
<?php /** * Wish List template */ // get list ID $list_id = edd_wl_get_list_id(); // gets the list $downloads = edd_wl_get_wish_list(); // get list post object $list = get_post($list_id); // title $title = get_the_title($list_id); //status $privacy = get_post_status($list_id); ?> <?php if ($list_id) { ?> <p><?php echo $list->post_content; ?> </p> <?php } ?> <?php if ($downloads) { ?>
/** * Get the Item Position in list * * @since 1.0.2 * * @param int $download_id ID of the download to get position of * @param array $options array of price options * @return bool|int|string false if empty list | position of the item in the list */ function edd_wl_get_item_position_in_list($download_id = 0, $list_id = 0, $options = array()) { $list_items = edd_wl_get_wish_list($list_id); if (!is_array($list_items)) { return false; // Empty list } else { foreach ($list_items as $position => $item) { if ($item['id'] == $download_id) { if (isset($options['price_id']) && isset($item['options']['price_id'])) { if ((int) $options['price_id'] == (int) $item['options']['price_id']) { return $position; } } else { return $position; } } } } return false; // Not found }