/** * Register post type * * @since 1.0 */ function edd_wl_register_post_type() { $labels = apply_filters('edd_wl_post_type_labels', array('name' => '%2$s', 'singular_name' => '%1$s', 'add_new' => __('Add New', 'edd-wish-lists'), 'add_new_item' => __('Add New %1$s', 'edd-wish-lists'), 'edit_item' => __('Edit %1$s', 'edd-wish-lists'), 'new_item' => __('New %1$s', 'edd-wish-lists'), 'all_items' => __('%2$s', 'edd-wish-lists'), 'view_item' => __('View %1$s', 'edd-wish-lists'), 'search_items' => __('Search %2$s', 'edd-wish-lists'), 'not_found' => __('No %2$s found', 'edd-wish-lists'), 'not_found_in_trash' => __('No %2$s found in Trash', 'edd-wish-lists'), 'parent_item_colon' => '', 'menu_name' => __('%2$s', 'edd-wish-lists'))); foreach ($labels as $key => $value) { $labels[$key] = sprintf($value, edd_wl_get_label_singular(), edd_wl_get_label_plural()); } $args = apply_filters('edd_wl_post_type_args', array('labels' => $labels, 'public' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'show_ui' => true, 'hierarchical' => false, 'query_var' => true, 'exclude_from_search' => true, 'rewrite' => false, 'supports' => array('title', 'editor'), 'show_in_menu' => 'edit.php?post_type=download')); register_post_type('edd_wish_list', $args); }
/** * Default Email Template Body * * @since 1.0 * @return string $default_email_body Body of the email */ function edd_wl_share_via_email_message($shortlink, $sender_name, $sender_email, $message, $referrer) { // Email body $default_email_body = __("Hi!", "edd-wish-lists") . "<br/><br/>"; $default_email_body .= sprintf(__("%s has suggested you look at this %s from %s:", "edd-wish-lists"), $sender_name, edd_wl_get_label_singular(true), get_bloginfo('name')) . "<br/>"; $default_email_body .= $shortlink . "<br/><br/>"; if ($message) { $default_email_body .= $message . "<br/><br/>"; } $default_email_body .= sprintf(__("Reply to %s by emailing %s", "edd-wish-lists"), $sender_name, '<a href="mailto:' . $sender_email . '" title="' . $sender_email . '">' . $sender_email . '</a>') . "<br/><br/>"; $default_email_body .= get_bloginfo('name') . "<br/>"; $default_email_body .= '<a title="' . get_bloginfo('name') . '" href="' . get_bloginfo('url') . '">' . get_bloginfo('url') . '</a>'; $default_email_body = apply_filters('edd_wl_share_via_email_message', $default_email_body, $shortlink, $sender_name, $message, $sender_email, $referrer); return $default_email_body; }
/** * Create list link * @since 1.0.2 */ function edd_wl_create_list_link($args = array()) { // exit if page is not selected in options, or guest creation is not allowed if ('none' == edd_get_option('edd_wl_page_create') || !edd_wl_allow_guest_creation()) { return; } $defaults = apply_filters('edd_wl_create_list_link_defaults', array('text' => sprintf(__('Create new %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'wrapper_class' => '', 'wrapper' => 'p', 'class' => '')); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); $default_class = ' edd-wl-button edd-wl-action'; $class .= $class ? $default_class : trim($default_class); ob_start(); $html = ''; $link = '<a href="' . edd_wl_get_wish_list_create_uri() . '" class="' . $class . '" title="' . $text . '">' . $text . '</a>'; if ($wrapper) { $html = '<' . $wrapper . ' class="' . $wrapper_class . '"' . '>' . $link . '</' . $wrapper . '>'; } else { $html .= $link; } echo $html; $html = ob_get_clean(); return apply_filters('edd_wl_create_list_link', $html); }
/** * Messages * * @since 1.0 */ function edd_wl_messages() { $messages = array('must_login' => sprintf(__('Sorry, you must login to create a %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'list_updated' => sprintf(__('%s updated', 'edd-wish-lists'), edd_wl_get_label_singular()), 'list_created_guest' => sprintf(__('%s created and saved for 30 days. If you wish to keep it longer, please create an account.', 'edd-wish-lists'), edd_wl_get_label_singular()), 'list_created' => sprintf(__('%s created', 'edd-wish-lists'), edd_wl_get_label_singular()), 'list_deleted' => sprintf(__('%s deleted', 'edd-wish-lists'), edd_wl_get_label_singular()), 'no_lists' => sprintf(__('You currently have no %s', 'edd-wish-lists'), edd_wl_get_label_plural(true)), 'list_delete_confirm' => sprintf(__('You are about to delete this %s, are you sure?', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'no_downloads' => sprintf(__('Nothing here yet, how about adding some %s?', 'edd-wish-lists'), edd_get_label_plural(true)), 'lists_included' => __('This item has already been added to: ', 'edd-wish-lists'), 'modal_option_save' => __('Save', 'edd-wish-lists'), 'modal_option_close' => __('Great, I\'m done', 'edd-wish-lists'), 'modal_option_add_new' => __('Add to new', 'edd-wish-lists'), 'modal_option_add_to_existing' => __('Add to existing', 'edd-wish-lists'), 'modal_option_title' => __('Title', 'edd-wish-lists'), 'modal_delete_title' => sprintf(__('Delete %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'modal_button_delete_confirm' => sprintf(__('Yes, delete this %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'modal_share_title' => sprintf(__('Share this %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)), 'modal_share_success' => __('Successfully shared', 'edd-wish-lists'), 'list_option_private' => __('Private - only viewable by you', 'edd-wish-lists'), 'list_option_public' => __('Public - viewable by anyone', 'edd-wish-lists'), 'list_title_required' => __('You need to enter a title', 'edd-wish-lists'), 'item_already_purchased' => __('Already purchased', 'edd-wish-lists')); return apply_filters('edd_wl_messages', $messages); }
/** * Get lists for post ID * * @since 1.0 */ function edd_wl_get_wish_lists($download_id, $price_ids, $items, $price_option_single) { ob_start(); $messages = edd_wl_messages(); global $edd_options; $text = !empty($edd_options['edd_wl_add_to_wish_list']) ? $edd_options['edd_wl_add_to_wish_list'] : sprintf(__('Add to %s', 'edd-wish-lists'), edd_wl_get_label_singular(true)); ?> <div class="modal-header"> <h2 id="edd-wl-modal-label"> <?php echo esc_attr($text); ?> </h2> <?php $download = $download_id ? get_the_title($download_id) : ''; // price variations // EG: Download Name - Option 1, Option 2, Option 3 if (edd_has_variable_prices($download_id)) { $price_options = array(); foreach ($items as $item) { $price_options[] = edd_get_price_name($item['id'], $item['options']); } } $options = !empty($price_options) ? ' - ' . implode(', ', $price_options) : ''; // show user what they have selected echo '<p>' . sprintf('%1$s%2$s', $download, $options) . '</p>'; ?> <a class="edd-wl-close" href="#" data-dismiss="modal"> <i class="glyphicon glyphicon-remove"></i> <span class="hide-text"><?php _e('Close', 'edd-wish-lists'); ?> </span> </a> </div> <div class="modal-body"> <?php // show lists this item is already included in echo edd_wl_lists_included($download_id, $items[0]['options']); ?> <?php if (!edd_wl_allow_guest_creation()) { ?> <?php echo '<p>' . $messages['must_login'] . '</p>'; ?> <?php } else { ?> <?php $list_query = edd_wl_get_query(); $private = edd_wl_get_query('private'); $public = edd_wl_get_query('public'); $variable_pricing = edd_has_variable_prices($download_id); $data_variable = $variable_pricing ? ' data-variable-price=yes' : 'data-variable-price=no'; $type = edd_single_price_option_mode($download_id) ? 'data-price-mode=multi' : 'data-price-mode=single'; ?> <form method="post" action="" class="form-modal"> <?php if ($list_query) { ?> <p id="current_lists"> <input type="radio" checked="" id="existing-list" value="existing-list" name="list-options"> <label for="existing-list"><?php echo $messages['modal_option_add_to_existing']; ?> </label> <select id="user-lists" name="user-lists"> <?php /** * Public lists */ if ($public) { ?> <optgroup label="Public"> <?php foreach ($public as $id) { ?> <option value="<?php echo $id; ?> "><?php echo get_the_title($id) . ' ' . edd_wl_get_item_count($id); ?> </option> <?php } ?> </optgroup> <?php } ?> <?php /** * Private lists */ if ($private) { ?> <optgroup label="Private"> <?php foreach ($private as $id) { ?> <option value="<?php echo $id; ?> "><?php echo get_the_title($id) . ' ' . edd_wl_get_item_count($id); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> </p> <?php } ?> <p> <input type="radio" id="new-list" value="new-list" name="list-options"> <label for="new-list"><?php echo $messages['modal_option_add_new']; ?> </label> <input type="text" id="list-name" name="list-name" placeholder="<?php echo $messages['modal_option_title']; ?> "> <select id="list-status" name="list-status"> <option value="private"><?php echo $messages['list_option_private']; ?> </option> <option value="publish"><?php echo $messages['list_option_public']; ?> </option> </select> </p> </div> <?php // add a hidden input field for each price ID which our next ajax function will grab foreach ($price_ids as $id) { ?> <input name="edd-wish-lists-post-id" type="hidden" value="<?php echo $id; ?> "> <?php } ?> <?php if ($price_option_single) { ?> <input name="edd-wl-single-price-option" type="hidden" value="yes"> <?php } ?> <div class="modal-footer"> <?php $args = array('download_id' => $download_id, 'text' => $messages['modal_option_save'], 'icon' => '', 'action' => 'edd_add_to_wish_list', 'class' => 'edd-wl-save edd-wl-action', 'style' => 'button'); edd_wl_wish_list_link($args); ?> <a class="edd-wl-button edd-wl-success edd-wl-action" href="#" data-dismiss="modal" style="display:none;"> <?php echo $messages['modal_option_close']; ?> </a> </div> </form> <?php } ?> </div> <?php $html = ob_get_clean(); return apply_filters('edd_wl_get_wish_lists', $html); }
/** * Settings * * @since 1.0 */ function edd_wl_settings($settings) { $plugin_settings = array(array('id' => 'edd_wl_header', 'name' => '<strong>' . sprintf(__('%s', 'edd-wish-lists'), edd_wl_get_label_plural()) . '</strong>', 'type' => 'header'), array('id' => 'edd_wl_page', 'name' => sprintf(__('%s Page', 'edd-wish-lists'), edd_wl_get_label_plural()), 'desc' => '<p class="description">' . sprintf(__('Select the page where users will view their %s. This page should include the [edd_wish_lists] shortcode', 'edd-wish-lists'), edd_wl_get_label_plural(true)) . '</p>', 'type' => 'dropdown_pages'), array('id' => 'edd_wl_page_view', 'name' => sprintf(__('%s View Page', 'edd-wish-lists'), edd_wl_get_label_plural()), 'desc' => '<p class="description">' . sprintf(__('Select the page where users will view each %s. This page should include the [edd_wish_lists_view] shortcode', 'edd-wish-lists'), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'dropdown_pages'), array('id' => 'edd_wl_page_edit', 'name' => sprintf(__('%s Edit Page', 'edd-wish-lists'), edd_wl_get_label_plural()), 'desc' => '<p class="description">' . sprintf(__('Select the page where users will edit a %s. This page should include the [edd_wish_lists_edit] shortcode', 'edd-wish-lists'), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'dropdown_pages'), array('id' => 'edd_wl_page_create', 'name' => sprintf(__('%s Create Page', 'edd-wish-lists'), edd_wl_get_label_plural()), 'desc' => '<p class="description">' . sprintf(__('Select the page where users will create a %s. This page should include the [edd_wish_lists_create] shortcode', 'edd-wish-lists'), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'dropdown_pages'), array('id' => 'edd_wl_add_to_wish_list', 'name' => sprintf(__('Add To %s Text', 'edd-wish-lists'), edd_wl_get_label_singular()), 'desc' => '<p class="description">' . sprintf(__('Enter the text you\'d like to appear for adding a %s to a %s', 'edd-wish-lists'), edd_get_label_singular(true), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'text', 'std' => sprintf(__('Add to %s', 'edd-wish-lists'), edd_wl_get_label_singular(true))), array('id' => 'edd_wl_add_to_cart', 'name' => __('Add To Cart Text', 'edd-wish-lists'), 'desc' => '<p class="description">' . sprintf(__('Enter the add to cart text you\'d like to appear on the single %s page', 'edd-wish-lists'), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'text', 'std' => __('Add to cart', 'edd-wish-lists')), array('id' => 'edd_wl_allow_guests', 'name' => sprintf(__('Allow Guests To Create %s', 'edd-wish-lists'), edd_wl_get_label_plural()), 'type' => 'select', 'options' => array('yes' => __('Yes', 'edd-wish-lists'), 'no' => __('No', 'edd-wish-lists')), 'std' => 'yes'), array('id' => 'edd_wl_icon', 'name' => __('Icon', 'edd-wish-lists'), 'desc' => '<p class="description">' . sprintf(__('The icon to show next to the add to %s links', 'edd-wish-lists'), edd_wl_get_label_singular(true)) . '</p>', 'type' => 'select', 'options' => apply_filters('edd_wl_icons', array('add' => __('Add', 'edd-wish-lists'), 'bookmark' => __('Bookmark', 'edd-wish-lists'), 'gift' => __('Gift', 'edd-wish-lists'), 'heart' => __('Heart', 'edd-wish-lists'), 'star' => __('Star', 'edd-wish-lists'), 'none' => __('No Icon', 'edd-wish-lists'))), 'std' => 'star'), array('id' => 'edd_wl_button_style', 'name' => __('Button Style', 'edd-wish-lists'), 'desc' => '<p class="description">' . __('Display a button or a plain text link', 'edd-wish-lists') . '</p>', 'type' => 'select', 'options' => array('plain' => __('Plain Text', 'edd-wish-lists'), 'button' => __('Button', 'edd-wish-lists')), 'std' => 'button'), array('id' => 'edd_wl_services', 'name' => __('Sharing', 'edd-wish-lists'), 'desc' => __('Select the services you\'d like users to share to', 'edd-wish-lists'), 'type' => 'multicheck', 'options' => apply_filters('edd_wl_settings_services', array('twitter' => __('Twitter', 'edd-wish-lists'), 'facebook' => __('Facebook', 'edd-wish-lists'), 'googleplus' => __('Google+', 'edd-wish-lists'), 'linkedin' => __('LinkedIn', 'edd-wish-lists'), 'email' => __('Email', 'edd-wish-lists'))))); return array_merge($settings, $plugin_settings); }