/** * Get Cart Item Template * * @since 1.0 * @param int $cart_key Cart key * @param array $item Cart item * @param bool $ajax AJAX? * @return string Cart item */ function edd_get_cart_item_template($cart_key, $item, $ajax = false) { global $post; $id = is_array($item) ? $item['id'] : $item; $remove_url = edd_remove_item_url($cart_key); $title = get_the_title($id); $options = !empty($item['options']) ? $item['options'] : array(); $quantity = edd_get_cart_item_quantity($id, $options); $price = edd_get_cart_item_price($id, $options); if (!empty($options)) { $title .= edd_has_variable_prices($item['id']) ? ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']) : edd_get_price_name($id, $item['options']); } ob_start(); edd_get_template_part('widget', 'cart-item'); $item = ob_get_clean(); $item = str_replace('{item_title}', $title, $item); $item = str_replace('{item_amount}', edd_currency_filter(edd_format_amount($price)), $item); $item = str_replace('{cart_item_id}', absint($cart_key), $item); $item = str_replace('{item_id}', absint($id), $item); $item = str_replace('{item_quantity}', absint($quantity), $item); $item = str_replace('{remove_url}', $remove_url, $item); $subtotal = ''; if ($ajax) { $subtotal = edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())); } $item = str_replace('{subtotal}', $subtotal, $item); return apply_filters('edd_cart_item', $item, $id); }
/** * Share list via email * * @since 1.0 */ function edd_wl_modal_share_via_email() { $messages = edd_wl_messages(); // only load on view page, when email sharing is present if (!(edd_wl_is_view_page() && edd_wl_sharing_is_enabled('email'))) { return; } $list_id = get_query_var('wl_view'); ?> <form class="wish-list-form" id="edd-wl-share-email-form" method="get" action=""> <div class="modal-header"> <h2 id="edd-wl-modal-label"> <?php echo $messages['modal_share_title']; ?> </h2> <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 // get template edd_get_template_part('wish-list-email-share'); ?> <input type="hidden" name="submitted" id="submitted" value="true"> <input name="referrer" type="hidden" value="<?php echo get_the_ID(); ?> "> <?php wp_nonce_field('share_via_email_nonce', 'share_via_email_nonce_field'); ?> </div> <div class="modal-footer"> <a href="#" data-action="edd_wl_share_via_email" data-post-id="<?php echo $list_id; ?> " class="edd-wl-button edd-wl-action edd-wl-share-via-email"> <span class="label"><?php _e('Send Now', 'edd-wish-lists'); ?> </span> <span class="edd-loading"><i class="edd-icon-spinner edd-icon-spin"></i></span> </a> </div> </form> <?php }
/** * Registration Form * * @since 2.0 * @global $post * @param string $redirect Redirect page URL * @return string Register form */ function edd_register_form($redirect = '') { global $edd_register_redirect; if (empty($redirect)) { $redirect = edd_get_current_page_url(); } $edd_register_redirect = $redirect; ob_start(); if (!is_user_logged_in()) { edd_get_template_part('shortcode', 'register'); } return apply_filters('edd_register_form', ob_get_clean()); }
/** * Override the content of the purchase history page to show our license management UI * * @since 2.7 */ function edd_sl_override_history_content($content) { if (empty($_GET['action']) || 'manage_licenses' != $_GET['action']) { return $content; } if (empty($_GET['payment_id'])) { return $content; } if (isset($_GET['license_id']) && isset($_GET['view']) && 'upgrades' == $_GET['view']) { ob_start(); edd_get_template_part('licenses', 'upgrades'); $content = ob_get_clean(); } else { $view = isset($_GET['license_id']) ? 'single' : 'overview'; ob_start(); edd_get_template_part('licenses', 'manage-' . $view); $content = ob_get_clean(); } return $content; }
/** * Profile Editor Shortcode * * Outputs the EDD Profile Editor to allow users to amend their details from the * front-end. This function uses the EDD templating system allowing users to * override the default profile editor template. The profile editor template is located * under templates/profile-editor.php, however, it can be altered by creating a * file called profile-editor.php in the edd_template directory in your active theme's * folder. Please visit the EDD Documentation for more information on how the * templating system is used. * * @since 1.4 * * @author Sunny Ratilal * * @param $atts Shortcode attributes * @param null $content * @return string Output generated from the profile editor */ function edd_profile_editor_shortcode($atts, $content = null) { ob_start(); if (!edd_user_pending_verification()) { edd_get_template_part('shortcode', 'profile-editor'); } else { edd_get_template_part('account', 'pending'); } $display = ob_get_clean(); return $display; }
/** * Shows "Purchase Processing" message for PayPal payments are still pending on site return * * This helps address the Race Condition, as detailed in issue #1839 * * @since 1.9 * @return string */ function edd_paypal_success_page_content($content) { if (!isset($_GET['payment-id']) && !edd_get_purchase_session()) { return $content; } $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; if (!$payment_id) { $session = edd_get_purchase_session(); $payment_id = edd_get_purchase_id_by_key($session['purchase_key']); } $payment = get_post($payment_id); if ($payment && 'pending' == $payment->post_status) { // Payment is still pending so show processing indicator to fix the Race Condition, issue # ob_start(); edd_get_template_part('payment', 'processing'); $content = ob_get_clean(); } return $content; }
/** * Receipt Shortcode * * Shows an order receipt. * * @access public * @since 1.4 * @return string */ function edd_receipt_shortcode($atts, $content = null) { global $edd_receipt_args; $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'payment_key' => true, 'payment_method' => true, 'payment_id' => true), $atts); $session = edd_get_purchase_session(); if (isset($_GET['purchase_key'])) { $purchase_key = urldecode($_GET['purchase_key']); } else { if ($session) { $purchase_key = $session['purchase_key']; } } // No key found if (!isset($purchase_key)) { return $edd_receipt_args['error']; } $edd_receipt_args['id'] = edd_get_purchase_id_by_key($purchase_key); $user = edd_get_payment_meta_user_info($edd_receipt_args['id']); // Not the proper user if ($user['id'] != get_current_user_id()) { return $edd_receipt_args['error']; } ob_start(); edd_get_template_part('shortcode', 'receipt'); $display = ob_get_clean(); return $display; }
/** * Featured Downloads Shortcode * Created a new shortcode as filtering the shortcode atts is not possible yet * https://core.trac.wordpress.org/ticket/15155 * @since 1.0 */ function edd_fd_shortcode($atts, $content = null) { extract(shortcode_atts(array('category' => '', 'exclude_category' => '', 'tags' => '', 'exclude_tags' => '', 'relation' => 'AND', 'number' => 10, 'price' => 'no', 'excerpt' => 'yes', 'full_content' => 'no', 'buy_button' => 'yes', 'columns' => 3, 'thumbnails' => 'true', 'orderby' => 'post_date', 'order' => 'DESC'), $atts)); $query = array('post_type' => 'download', 'posts_per_page' => absint($number), 'orderby' => $orderby, 'order' => $order, 'meta_key' => 'edd_feature_download'); switch ($orderby) { case 'price': $orderby = 'meta_value'; $query['meta_key'] = 'edd_price'; $query['orderby'] = 'meta_value_num'; break; case 'title': $query['orderby'] = 'title'; break; case 'id': $query['orderby'] = 'ID'; break; case 'random': $query['orderby'] = 'rand'; break; default: $query['orderby'] = 'post_date'; break; } if ($tags || $category || $exclude_category || $exclude_tags) { $query['tax_query'] = array('relation' => $relation); if ($tags) { $query['tax_query'][] = array('taxonomy' => 'download_tag', 'terms' => explode(',', $tags), 'field' => 'slug'); } if ($category) { $query['tax_query'][] = array('taxonomy' => 'download_category', 'terms' => explode(',', $category), 'field' => 'slug'); } if ($exclude_category) { $query['tax_query'][] = array('taxonomy' => 'download_category', 'terms' => explode(',', $exclude_category), 'field' => 'slug', 'operator' => 'NOT IN'); } if ($exclude_tags) { $query['tax_query'][] = array('taxonomy' => 'download_tag', 'terms' => explode(',', $exclude_tags), 'field' => 'slug', 'operator' => 'NOT IN'); } } if (get_query_var('paged')) { $query['paged'] = get_query_var('paged'); } else { if (get_query_var('page')) { $query['paged'] = get_query_var('page'); } else { $query['paged'] = 1; } } switch (intval($columns)) { case 1: $column_width = '100%'; break; case 2: $column_width = '50%'; break; case 3: $column_width = '33%'; break; case 4: $column_width = '25%'; break; case 5: $column_width = '20%'; break; case 6: $column_width = '16.6%'; break; } // Allow the query to be manipulated by other plugins $query = apply_filters('edd_featured_downloads_query', $query); $downloads = new WP_Query($query); if ($downloads->have_posts()) { $i = 1; ob_start(); ?> <div class="edd_downloads_list"> <?php while ($downloads->have_posts()) { $downloads->the_post(); ?> <div itemscope itemtype="http://schema.org/Product" class="edd_download" id="edd_download_<?php echo get_the_ID(); ?> " style="width: <?php echo $column_width; ?> ; float: left;"> <div class="edd_download_inner"> <?php do_action('edd_download_before'); if ('false' != $thumbnails) { edd_get_template_part('shortcode', 'content-image'); } edd_get_template_part('shortcode', 'content-title'); if ($excerpt == 'yes' && $full_content != 'yes') { edd_get_template_part('shortcode', 'content-excerpt'); } else { if ($full_content == 'yes') { edd_get_template_part('shortcode', 'content-full'); } } if ($price == 'yes') { edd_get_template_part('shortcode', 'content-price'); } if ($buy_button == 'yes') { edd_get_template_part('shortcode', 'content-cart-button'); } do_action('edd_download_after'); ?> </div> </div> <?php if ($i % $columns == 0) { ?> <div style="clear:both;"></div><?php } ?> <?php $i++; } ?> <div style="clear:both;"></div> <?php wp_reset_postdata(); ?> </div> <?php $display = ob_get_clean(); } else { $display = sprintf(_x('No %s found', 'download post type name', 'edd-fd'), edd_get_label_plural()); } return apply_filters('edd_fd_shortcode', $display, $atts, $buy_button, $columns, $column_width, $downloads, $excerpt, $full_content, $price, $thumbnails, $query); }
if ($cart_items) { ?> <?php foreach ($cart_items as $key => $item) { ?> <?php echo edd_get_cart_item_template($key, $item, false); ?> <?php } ?> <?php edd_get_template_part('widget', 'cart-checkout'); ?> <?php } else { ?> <?php edd_get_template_part('widget', 'cart-empty'); ?> <?php } ?> </ul>
/** * Build the final email * * @since 2.1 * @param string $message * * @return string */ public function build_email($message) { if (false === $this->html) { return apply_filters('edd_email_message', wp_strip_all_tags($message), $this); } $message = $this->text_to_html($message); ob_start(); edd_get_template_part('emails/header', $this->get_template(), true); /** * Hooks into the email header * * @since 2.1 */ do_action('edd_email_header', $this); if (has_action('edd_email_template_' . $this->get_template())) { /** * Hooks into the template of the email * * @param string $this->template Gets the enabled email template * @since 2.1 */ do_action('edd_email_template_' . $this->get_template()); } else { edd_get_template_part('emails/body', $this->get_template(), true); } /** * Hooks into the body of the email * * @since 2.1 */ do_action('edd_email_body', $this); edd_get_template_part('emails/footer', $this->get_template(), true); /** * Hooks into the footer of the email * * @since 2.1 */ do_action('edd_email_footer', $this); $body = ob_get_clean(); $message = str_replace('{email}', $message, $body); return apply_filters('edd_email_message', $message, $this); }
?> <aside> <h2>Ready to purchase?</h2> <ul class="edd-cart"> <?php foreach ($cart_items as $key => $item) { ?> <?php echo edd_get_cart_item_template($key, $item, false); ?> <?php } ?> <?php edd_get_template_part('widget', 'cart-checkout'); ?> </ul> </aside> <?php } ?> <?php $support_url = get_post_meta(get_the_ID(), '_pp_product_support_url', true) ? get_post_meta(get_the_ID(), '_pp_product_support_url', true) : site_url('plugin-support'); $target = get_post_meta(get_the_ID(), '_pp_product_support_url', true) ? ' target="_blank"' : ''; ?> <div class="support box"> <h2>Need Help?</h2> <p>For support related questions, please <a href="<?php echo esc_url($support_url);
public function render_email_tab() { edd_get_template_part('fes', 'email-customers-tab'); }
Added to cart </span> </span> </div> <!--end .edd_purchase_submit_wrapper--> <input type="hidden" name="download_id" value="<?php echo $ym_response->id; ?> "> <input type="hidden" name="is_yaymicro_image" value="true"> <input type="hidden" name="edd_action" class="edd_action_input" value="add_to_cart"> </form> <?php edd_get_template_part('widget', 'cart'); ?> <table id="isa-edd-specs"> <caption>Image Information</caption> <tbody> <tr> <td>License:</td> <td><?php echo $ym_response->license; ?> </td> </tr> <tr> <td>Filetype:</td> <td><?php
/** * Build the final email * * @since 2.1 */ public function build_email($message) { if (false === $this->html) { return apply_filters('edd_email_message', wp_strip_all_tags($message), $this); } $message = $this->text_to_html($message); ob_start(); edd_get_template_part('emails/header', $this->get_template(), true); do_action('edd_email_header', $this); if (has_action('edd_email_template_' . $this->get_template())) { do_action('edd_email_template_' . $this->get_template()); } else { edd_get_template_part('emails/body', $this->get_template(), true); } do_action('edd_email_body', $this); edd_get_template_part('emails/footer', $this->get_template(), true); do_action('edd_email_footer', $this); $body = ob_get_clean(); $message = str_replace('{email}', $message, $body); return apply_filters('edd_email_message', $message, $this); }
/** * Get Checkout Cart * * @access public * @since 1.0 * @return void */ function edd_checkout_cart() { edd_get_template_part('checkout_cart'); }
<?php /** * @package Marketify */ ?> <article id="post-<?php the_ID(); ?> " <?php post_class('content-grid-download'); ?> > <?php edd_get_template_part('shortcode', 'content-image'); ?> <?php edd_get_template_part('shortcode', 'content-title'); ?> </article><!-- #post-## -->
/** * Get Checkout Cart * * @access public * @since 1.0 * @return void */ function edd_checkout_cart() { do_action('edd_before_checkout_cart'); edd_get_template_part('checkout_cart'); do_action('edd_after_checkout_cart'); }
/** * Profile Editor Shortcode * * Outputs the EDD Profile Editor to allow users to amend their details from the * front-end. This function uses the EDD templating system allowing users to * override the default profile editor template. The profile editor template is located * under templates/profile-editor.php, however, it can be altered by creating a * file called profile-editor.php in the edd_template directory in your active theme's * folder. Please visit the EDD Documentation for more information on how the * templating system is used. * * @since 1.4 * @author Sunny Ratilal * @param array $atts Shortcode attributes * @param string $content * @return $display Output generated from the profile editor */ function edd_profile_editor_shortcode($atts, $content = null) { ob_start(); edd_get_template_part('shortcode', 'profile-editor'); $display = ob_get_clean(); return $display; }
/** * Main Wish List function called by [edd_wish_lists] shortcode * This template can be found in the /templates folder. * Copy wish-lists.php to your edd_templates folder in your child theme * Would be nice to use get_template_part but you cannot pass variables along * * @since 1.0 * @return [type] [description] */ function edd_wl_wish_list() { ob_start(); echo edd_wl_print_messages(); edd_get_template_part('wish-lists'); return ob_get_clean(); }
/** * Receipt Shortcode * * Shows an order receipt. * * @since 1.4 * @param array $atts Shortcode attributes * @param string $content * @return string */ function wbcom_edd_receipt_shortcode($atts, $content = null) { global $edd_receipt_args; $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'easy-digital-downloads'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt'); $session = edd_get_purchase_session(); if (isset($_GET['payment_key'])) { $payment_key = urldecode($_GET['payment_key']); } else { if ($session) { $payment_key = $session['purchase_key']; } elseif ($edd_receipt_args['payment_key']) { $payment_key = $edd_receipt_args['payment_key']; } } // No key found if (!isset($payment_key)) { return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>'; } $payment_id = edd_get_purchase_id_by_key($payment_key); $user_can_view = edd_can_view_receipt($payment_key); // Key was provided, but user is logged out. Offer them the ability to login and view the receipt if (!$user_can_view && !empty($payment_key) && !is_user_logged_in() && !edd_is_guest_payment($payment_id)) { global $edd_login_redirect; $edd_login_redirect = edd_get_current_page_url(); ob_start(); echo '<p class="edd-alert edd-alert-warn">' . __('You must be logged in to view this payment receipt.', 'easy-digital-downloads') . '</p>'; edd_get_template_part('shortcode', 'login'); $login_form = ob_get_clean(); return $login_form; } /* * Check if the user has permission to view the receipt * * If user is logged in, user ID is compared to user ID of ID stored in payment meta * * Or if user is logged out and purchase was made as a guest, the purchase session is checked for * * Or if user is logged in and the user can view sensitive shop data * */ if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) { return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>'; } ob_start(); // edd_get_template_part( 'shortcode', 'receipt' ); include WBCOM_EDD_DASH_MSG_PATH . 'includes/edd-shortcode_receipt.php'; $display = ob_get_clean(); return $display; }
/** * Display Cross-sell/Upsell products * * @since 1.0 */ function edd_csau_html($columns = '3') { global $post, $edd_options; // upsell products for the single download page if (is_singular('download')) { $products = edd_csau_get_products(get_the_ID(), 'upsell'); } elseif (edd_is_checkout()) { // get contents on the cart $cart_items = edd_get_cart_contents(); // return if there's nothing in the cart if (!$cart_items) { return; } $cart = array(); // create new products array with the cart items cross sell products if ($cart_items) { foreach ($cart_items as $cart_item) { $download_id = $cart_item['id']; // create $cart array with IDs $cart[] = (int) $cart_item['id']; // create $product_list array with cross sell products $product_list[] = get_post_meta($download_id, '_edd_csau_cross_sell_products', false); } } $products = $product_list; // clean the array $products = array_filter($products); // return if no cross sell products after clean if (!$products) { return; } // merge into single level array $products = call_user_func_array('array_merge', $products); // remove duplicate IDs $products = array_unique($products); } else { return; } if ($products) { ?> <?php if (edd_is_checkout()) { $posts_per_page = isset($edd_options['edd_csau_cross_sell_number']) && !empty($edd_options['edd_csau_cross_sell_number']) ? $edd_options['edd_csau_cross_sell_number'] : '3'; } elseif (is_singular('download')) { $posts_per_page = isset($edd_options['edd_csau_upsell_number']) && !empty($edd_options['edd_csau_upsell_number']) ? $edd_options['edd_csau_upsell_number'] : '3'; } $query = array('post_type' => 'download', 'posts_per_page' => $posts_per_page, 'orderby' => 'date', 'order' => 'DESC', 'post__in' => $products); $query = apply_filters('edd_csau_query', $query); $downloads = new WP_Query($query); if ($downloads->have_posts()) { // upsell heading if (is_singular('download')) { $upsell_heading = get_post_meta(get_the_ID(), '_edd_csau_upsell_heading', true); // show singular heading if ($upsell_heading) { $heading = esc_attr($upsell_heading); } elseif (isset($edd_options['edd_csau_upsell_heading'])) { $heading = esc_attr($edd_options['edd_csau_upsell_heading']); } else { $heading = __('You may also like', 'edd-csau'); } } elseif (edd_is_checkout()) { $ids = edd_csau_get_cart_trigger_ids(); if (count($ids) == 1) { $heading = esc_attr(get_post_meta($ids[0], '_edd_csau_cross_sell_heading', true)); } elseif (isset($edd_options['edd_csau_cross_sell_heading'])) { $heading = esc_attr($edd_options['edd_csau_cross_sell_heading']); } else { $heading = __('You may also like', 'edd-csau'); } } // end is_checkout $i = 1; global $wp_query; //$download_count = $downloads->found_posts > 3 ? 3 : $downloads->found_posts; $classes = array(); $classes = apply_filters('edd_csau_classes', $classes); // default classes $classes[] = 'edd-csau-products'; // columns if ($columns) { $classes[] = 'col-' . $columns; } // filter array and remove empty values $classes = array_filter($classes); $classes = !empty($classes) ? implode(' ', $classes) : ''; $class_list = !empty($classes) ? 'class="' . $classes . '"' : ''; ob_start(); ?> <div <?php echo $class_list; ?> > <h2><?php echo esc_attr($heading); ?> </h2> <?php while ($downloads->have_posts()) { $downloads->the_post(); ?> <div itemscope itemtype="http://schema.org/Product" class="<?php echo apply_filters('edd_download_class', 'edd_download', '', ''); ?> " id="edd_download_<?php echo get_the_ID(); ?> "> <div class="edd_download_inner"> <?php do_action('edd_csau_download_before'); $show_excerpt = apply_filters('edd_csau_show_excerpt', true); $show_price = apply_filters('edd_csau_show_price', true); $show_button = apply_filters('edd_csau_upsell_show_button', true); edd_get_template_part('shortcode', 'content-image'); edd_get_template_part('shortcode', 'content-title'); if ($show_price) { edd_get_template_part('shortcode', 'content-price'); } if ($show_excerpt) { edd_get_template_part('shortcode', 'content-excerpt'); } // if the download is not in the cart, show the add to cart button if (edd_is_checkout()) { if (!edd_item_in_cart(get_the_ID())) { $text = apply_filters('edd_csau_cross_sell_add_to_cart_text', __('Add to cart', 'edd-csau')); $price = apply_filters('edd_csau_cross_sell_show_button_price', false); if ($show_button) { ?> <div class="edd_download_buy_button"> <?php echo edd_get_purchase_link(array('download_id' => get_the_ID(), 'text' => $text, 'price' => $price)); ?> </div> <?php } ?> <?php } else { echo apply_filters('edd_csau_added_to_cart_text', '<span class="edd-cart-added-alert"><i class="edd-icon-ok"></i> ' . __('Added to cart', 'edd-csau') . '</span>'); } } else { $text = apply_filters('edd_csau_upsell_add_to_cart_text', __('Add to cart', 'edd-csau')); $price = apply_filters('edd_csau_upsell_show_button_price', false); $show_button = apply_filters('edd_csau_upsell_show_button', true); if ($show_button) { ?> <div class="edd_download_buy_button"> <?php echo edd_get_purchase_link(array('download_id' => get_the_ID(), 'text' => $text, 'price' => $price)); ?> </div> <?php } ?> <?php } do_action('edd_csau_download_after'); ?> </div> </div> <?php if ($columns && $i % $columns == 0) { ?> <div style="clear:both;"></div><?php } ?> <?php $i++; } ?> <?php wp_reset_postdata(); ?> </div> <?php $html = ob_get_clean(); return apply_filters('edd_csau_html', $html, $downloads, $heading, $columns, $class_list); } ?> <?php } ?> <?php }