本文整理汇总了PHP中edd_print_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_print_errors函数的具体用法?PHP edd_print_errors怎么用?PHP edd_print_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_print_errors函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_render_customer_view
/**
* Renders the customer view wrapper
*
* @since 2.3
* @param string $view The View being requested
* @param array $callbacks The Registered views and their callback functions
* @return void
*/
function edd_render_customer_view($view, $callbacks)
{
$render = true;
$customer_view_role = apply_filters('edd_view_customers_role', 'view_shop_reports');
if (!current_user_can($customer_view_role)) {
edd_set_error('edd-no-access', __('You are not permitted to view this data.', 'edd'));
$render = false;
}
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
edd_set_error('edd-invalid_customer', __('Invalid Customer ID Provided.', 'edd'));
$render = false;
}
$customer_id = (int) $_GET['id'];
$customer = new EDD_Customer($customer_id);
if (empty($customer->id)) {
edd_set_error('edd-invalid_customer', __('Invalid Customer ID Provided.', 'edd'));
$render = false;
}
$customer_tabs = edd_customer_tabs();
?>
<div class='wrap'>
<h2><?php
_e('Customer Details', 'edd');
?>
</h2>
<?php
if (edd_get_errors()) {
?>
<div class="error settings-error">
<?php
edd_print_errors();
?>
</div>
<?php
}
?>
<?php
if ($customer && $render) {
?>
<div id="customer-tab-wrapper">
<ul id="customer-tab-wrapper-list">
<?php
foreach ($customer_tabs as $key => $tab) {
?>
<?php
$active = $key === $view ? true : false;
?>
<?php
$class = $active ? 'active' : 'inactive';
?>
<?php
if (!$active) {
?>
<a title="<?php
echo esc_attr($tab['title']);
?>
" aria-label="<?php
echo esc_attr($tab['title']);
?>
" href="<?php
echo esc_url(admin_url('edit.php?post_type=download&page=edd-customers&view=' . $key . '&id=' . $customer->id));
?>
">
<?php
}
?>
<li class="<?php
echo sanitize_html_class($class);
?>
"><span class="dashicons <?php
echo sanitize_html_class($tab['dashicon']);
?>
"></span></li>
<?php
if (!$active) {
?>
</a>
<?php
}
?>
<?php
}
?>
</ul>
</div>
//.........这里部分代码省略.........
示例2: edd_print_errors
<?php
global $edd_login_redirect;
if (!is_user_logged_in()) {
// Show any error messages after form submission
edd_print_errors();
?>
<form id="edd_login_form" class="edd_form" action="" method="post">
<fieldset>
<span><legend><?php
_e('Log into Your Account', 'edd');
?>
</legend></span>
<?php
do_action('edd_login_fields_before');
?>
<p>
<label for="edd_user_Login"><?php
_e('Username', 'edd');
?>
</label>
<input name="edd_user_login" id="edd_user_login" class="required edd-input" type="text" title="<?php
_e('Username', 'edd');
?>
"/>
</p>
<p>
<label for="edd_user_pass"><?php
_e('Password', 'edd');
?>
</label>
示例3: pre_checkout_errors
/**
* Inspects the cart in order to catch out-of-stock issues etc and display them to the customer
* before they go on to complete their personal and payment details, etc.
*
* If this is undesirable or different formatting etc is needed
*/
public function pre_checkout_errors()
{
ob_start();
$this->checkout_errors();
edd_print_errors();
echo apply_filters('eddtickets_pre_checkout_errors', ob_get_clean());
}
示例4: edd_profile_editor_shortcode
/**
* Profile Editor Shortcode
*
* Outputs the EDD Profile Editor to allow users to amend their details from the front-end
*
* @access public
* @since 1.4
* @author Sunny Ratilal
*/
function edd_profile_editor_shortcode($atts, $content = null)
{
global $current_user;
ob_start();
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$first_name = get_user_meta($user_id, 'first_name', true);
$last_name = get_user_meta($user_id, 'last_name', true);
$display_name = $current_user->display_name;
if (isset($_GET['updated']) && $_GET['updated'] == true && !edd_get_errors()) {
?>
<p class="edd_success"><strong><?php
_e('Success', 'edd');
?>
:</strong> <?php
_e('Your profile has been edited successfully.', 'edd');
?>
</p>
<?php
}
edd_print_errors();
?>
<form id="edd_profile_editor_form" class="edd_form" action="<?php
echo edd_get_current_page_url();
?>
" method="post">
<fieldset>
<legend><?php
_e('Change your Name', 'edd');
?>
</legend>
<p id="edd_profile_name_wrap">
<label for="edd_first_name"><?php
_e('First Name', 'edd');
?>
</label>
<input name="edd_first_name" id="edd_first_name" class="text edd-input" type="text" value="<?php
echo $first_name;
?>
" />
<br />
<label for="edd_last_name"><?php
_e('Last Name', 'edd');
?>
</label>
<input name="edd_last_name" id="edd_last_name" class="text edd-input" type="text" value="<?php
echo $last_name;
?>
" />
</p>
<p id="edd_profile_display_name_wrap">
<label for="edd_display_name"><?php
_e('Display Name', 'edd');
?>
</label>
<select name="edd_display_name">
<?php
if (!empty($current_user->first_name)) {
?>
<option <?php
selected($display_name, $current_user->first_name);
?>
value="<?php
echo $current_user->first_name;
?>
"><?php
echo $current_user->first_name;
?>
</option>
<?php
}
?>
<option <?php
selected($display_name, $current_user->user_nicename);
?>
value="<?php
echo $current_user->user_nicename;
?>
"><?php
echo $current_user->user_nicename;
?>
</option>
<?php
if (!empty($current_user->last_name)) {
?>
<option <?php
selected($display_name, $current_user->last_name);
?>
value="<?php
echo $current_user->last_name;
?>
//.........这里部分代码省略.........
示例5: edd_get_purchase_link
/**
* Get Purchase Link
*
* Builds a Purchase link for a specified download based on arguments passed.
* This function is used all over EDD to generate the Purchase or Add to Cart
* buttons. If no arguments are passed, the function uses the defaults that have
* been set by the plugin. The Purchase link is built for simple and variable
* pricing and filters are available throughout the function to override
* certain elements of the function.
*
* $download_id = null, $link_text = null, $style = null, $color = null, $class = null
*
* @since 1.0
* @param array $args Arguments for display
* @return string $purchase_form
*/
function edd_get_purchase_link($args = array())
{
global $post, $edd_displayed_form_ids;
$purchase_page = edd_get_option('purchase_page', false);
if (!$purchase_page || $purchase_page == 0) {
edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'easy-digital-downloads'), admin_url('edit.php?post_type=download&page=edd-settings')));
edd_print_errors();
return false;
}
$post_id = is_object($post) ? $post->ID : 0;
$button_behavior = edd_get_download_button_behavior($post_id);
$defaults = apply_filters('edd_purchase_link_defaults', array('download_id' => $post_id, 'price' => (bool) true, 'price_id' => isset($args['price_id']) ? $args['price_id'] : false, 'direct' => $button_behavior == 'direct' ? true : false, 'text' => $button_behavior == 'direct' ? edd_get_option('buy_now_text', __('Buy Now', 'easy-digital-downloads')) : edd_get_option('add_to_cart_text', __('Purchase', 'easy-digital-downloads')), 'style' => edd_get_option('button_style', 'button'), 'color' => edd_get_option('checkout_color', 'blue'), 'class' => 'edd-submit'));
$args = wp_parse_args($args, $defaults);
// Override the stright_to_gateway if the shop doesn't support it
if (!edd_shop_supports_buy_now()) {
$args['direct'] = false;
}
$download = new EDD_Download($args['download_id']);
if (empty($download->ID)) {
return false;
}
if ('publish' !== $download->post_status && !current_user_can('edit_product', $download->ID)) {
return false;
// Product not published or user doesn't have permission to view drafts
}
// Override color if color == inherit
$args['color'] = $args['color'] == 'inherit' ? '' : $args['color'];
$options = array();
$variable_pricing = $download->has_variable_prices();
$data_variable = $variable_pricing ? ' data-variable-price="yes"' : 'data-variable-price="no"';
$type = $download->is_single_price_mode() ? 'data-price-mode=multi' : 'data-price-mode=single';
$show_price = $args['price'] && $args['price'] !== 'no';
$data_price_value = 0;
$price = false;
if ($variable_pricing && false !== $args['price_id']) {
$price_id = $args['price_id'];
$prices = $download->prices;
$options['price_id'] = $args['price_id'];
$found_price = isset($prices[$price_id]) ? $prices[$price_id]['amount'] : false;
$data_price_value = $found_price;
if ($show_price) {
$price = $found_price;
}
} elseif (!$variable_pricing) {
$data_price_value = $download->price;
if ($show_price) {
$price = $download->price;
}
}
$args['display_price'] = $data_price_value;
$data_price = 'data-price="' . $data_price_value . '"';
$button_text = !empty($args['text']) ? ' – ' . $args['text'] : '';
if (false !== $price) {
if (0 == $price) {
$args['text'] = __('Free', 'easy-digital-downloads') . $button_text;
} else {
$args['text'] = edd_currency_filter(edd_format_amount($price)) . $button_text;
}
}
if (edd_item_in_cart($download->ID, $options) && (!$variable_pricing || !$download->is_single_price_mode())) {
$button_display = 'style="display:none;"';
$checkout_display = '';
} else {
$button_display = '';
$checkout_display = 'style="display:none;"';
}
// Collect any form IDs we've displayed already so we can avoid duplicate IDs
if (isset($edd_displayed_form_ids[$download->ID])) {
$edd_displayed_form_ids[$download->ID]++;
} else {
$edd_displayed_form_ids[$download->ID] = 1;
}
$form_id = !empty($args['form_id']) ? $args['form_id'] : 'edd_purchase_' . $download->ID;
// If we've already generated a form ID for this download ID, apped -#
if ($edd_displayed_form_ids[$download->ID] > 1) {
$form_id .= '-' . $edd_displayed_form_ids[$download->ID];
}
$args = apply_filters('edd_purchase_link_args', $args);
ob_start();
?>
<form id="<?php
echo $form_id;
?>
" class="edd_download_purchase_form edd_purchase_<?php
//.........这里部分代码省略.........
示例6: update_payment_form
/**
* Displays a payment update form
*
* @since x.x
* @return string
*/
public function update_payment_form()
{
global $user_ID;
if (!is_user_logged_in()) {
return;
}
if (!EDD_Recurring_Customer::is_customer_active($user_ID)) {
return;
}
if ('cancelled' === EDD_Recurring_Customer::get_customer_status($user_ID)) {
return;
}
// Gateways can choose to show the form or not by using this filter
$show_cc_form = apply_filters('edd_recurring_customer_can_update_card', false, $user_ID);
if (!$show_cc_form) {
$form_fields = array();
$form_fields['cc_number'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-card-number', 'label' => __('Credit Card Number', 'edd-recurring'), 'placeholder' => __('Credit Card Number', 'edd-recurring'), 'autocomplete' => false));
$form_fields['cc_name'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-card-name', 'label' => __('Name on Card', 'edd-recurring'), 'placeholder' => __('Name on Card', 'edd-recurring'), 'autocomplete' => true));
$form_fields['cvc_number'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-cvc-number', 'class' => 'small-text', 'label' => __('CVC Number', 'edd-recurring'), 'placeholder' => __('###', 'edd-recurring'), 'autocomplete' => false));
$form_fields['exp_head'] = array('type' => 'legend', 'options' => array('text' => __('Card Expiration', 'edd-recurring')));
$form_fields['exp_month'] = array('type' => 'month_dropdown');
$form_fields['exp_year'] = array('type' => 'year_dropdown', 'number_of_years' => 10);
$elements = apply_filters('edd_recurring_update_form_elements', $form_fields, $user_ID);
}
$form_output = '';
if (isset($_GET['updated']) && $_GET['updated'] == true && !edd_get_errors()) {
$form_output = '<p class="edd_success"><strong>' . __('Success', 'edd') . ':</strong> ' . __('Your profile has been edited successfully.', 'edd') . '</p>';
}
$form_output .= '<div id="edd-recurring-update-wrapper">';
$form_output .= '<form action="' . remove_query_arg('updated', edd_get_current_page_url()) . '" id="edd-recurring-form" method="POST">';
$form_input_html = '';
if (!$show_cc_form) {
// Iterate through all the form elements, and add them to the HTML
foreach ($elements as $element) {
switch ($element['type']) {
case 'month_dropdown':
$form_input_html .= EDD()->html->{$element}['type']();
break;
case 'year_dropdown':
$form_input_html .= EDD()->html->{$element}['type']('edd-recurring-exp-year', null, 0, $element['number_of_years']);
break;
case 'legend':
$form_input_html .= '<legend>' . $element['options']['text'] . '</legend>';
break;
default:
$form_input_html .= EDD()->html->{$element}['type']($element['options']);
$form_input_html .= '<br />';
break;
}
}
}
ob_start();
edd_print_errors();
$form_output .= ob_get_clean();
$form_output .= apply_filters('edd_recurring_update_form_html', $form_input_html, $user_ID);
$recurring_gateway = apply_filters('edd_recurring_update_gateway', '', $user_ID);
$form_output .= '<input name="edd-recurring-update-gateway" type="hidden" value="' . $recurring_gateway . '" />';
$form_output .= wp_nonce_field('update-payment', 'edd_recurring_update_nonce', true, false);
$form_output .= '<input type="hidden" name="edd_action" value="recurring_update_payment" />';
$form_output .= '<input type="submit" name="edd-recurring-update-submit" id="edd-recurring-update-submit" value="' . esc_attr(__('Update Payment', 'edd-recurring')) . '" />';
$form_output .= '</form>';
$form_output .= '</div>';
return '<div id="edd_checkout_form_wrap">' . $form_output . '</div>';
}
示例7: get_current_user_id
$user_id = get_current_user_id();
$first_name = get_user_meta( $user_id, 'first_name', true );
$last_name = get_user_meta( $user_id, 'last_name', true );
$display_name = $current_user->display_name;
$address = edd_get_customer_address( $user_id );
if ( edd_is_cart_saved() ): ?>
<?php $restore_url = add_query_arg( array( 'edd_action' => 'restore_cart', 'edd_cart_token' => edd_get_cart_token() ), edd_get_checkout_uri() ); ?>
<div class="edd_success edd-alert edd-alert-success"><strong><?php _e( 'Saved cart', 'edd'); ?>:</strong> <?php printf( __( 'You have a saved cart, <a href="%s">click here</a> to restore it.', 'edd' ), esc_url( $restore_url ) ); ?></div>
<?php endif; ?>
<?php if ( isset( $_GET['updated'] ) && $_GET['updated'] == true && ! edd_get_errors() ): ?>
<div class="edd_success edd-alert edd-alert-success"><strong><?php _e( 'Success', 'edd'); ?>:</strong> <?php _e( 'Your profile has been edited successfully.', 'edd' ); ?></div>
<?php endif; ?>
<?php edd_print_errors(); ?>
<?php do_action( 'edd_profile_editor_before' ); ?>
<form id="edd_profile_editor_form" class="edd_form" action="<?php echo edd_get_current_page_url(); ?>" method="post">
<fieldset>
<span id="edd_profile_name_label"><legend><?php _e( 'Change your Name', 'edd' ); ?></legend></span>
<p id="edd_profile_name_wrap">
<label for="edd_first_name"><?php _e( 'First Name', 'edd' ); ?></label>
<input name="edd_first_name" id="edd_first_name" class="text edd-input" type="text" value="<?php echo esc_attr( $first_name ); ?>" />
<br />
<label for="edd_last_name"><?php _e( 'Last Name', 'edd' ); ?></label>
<input name="edd_last_name" id="edd_last_name" class="text edd-input" type="text" value="<?php echo esc_attr( $last_name ); ?>" />
</p>
<p id="edd_profile_display_name_wrap">
<label for="edd_display_name"><?php _e( 'Display Name', 'edd' ); ?></label>
示例8: edd_get_purchase_link
/**
* Get Purchase Link
*
* Builds a Purchase link for a specified download based on arguments passed.
* This function is used all over EDD to generate the Purchase or Add to Cart
* buttons. If no arguments are passed, the function uses the defaults that have
* been set by the plugin. The Purchase link is built for simple and variable
* pricing and filters are available throughout the function to override
* certain elements of the function.
*
* $download_id = null, $link_text = null, $style = null, $color = null, $class = null
*
* @since 1.0
* @param array $args Arguments for display
* @return string $purchase_form
*/
function edd_get_purchase_link($args = array())
{
global $edd_options, $post;
if (!isset($edd_options['purchase_page']) || $edd_options['purchase_page'] == 0) {
edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'edd'), admin_url('edit.php?post_type=download&page=edd-settings')));
edd_print_errors();
return false;
}
$post_id = is_object($post) ? $post->ID : 0;
$defaults = apply_filters('edd_purchase_link_defaults', array('download_id' => $post_id, 'price' => (bool) true, 'direct' => edd_get_download_button_behavior($post_id) == 'direct' ? true : false, 'text' => !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd'), 'style' => isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button', 'color' => isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue', 'class' => 'edd-submit'));
$args = wp_parse_args($args, $defaults);
if ('publish' != get_post_field('post_status', $args['download_id']) && !current_user_can('edit_product', $args['download_id'])) {
return false;
// Product not published or user doesn't have permission to view drafts
}
// Override color if color == inherit
$args['color'] = $args['color'] == 'inherit' ? '' : $args['color'];
$variable_pricing = edd_has_variable_prices($args['download_id']);
$data_variable = $variable_pricing ? ' data-variable-price="yes"' : 'data-variable-price="no"';
$type = edd_single_price_option_mode($args['download_id']) ? 'data-price-mode=multi' : 'data-price-mode=single';
if ($args['price'] && $args['price'] !== 'no' && !$variable_pricing) {
$price = edd_get_download_price($args['download_id']);
$button_text = !empty($args['text']) ? ' – ' . $args['text'] : '';
if (0 == $price) {
$args['text'] = __('Free', 'edd') . $button_text;
} else {
$args['text'] = edd_currency_filter(edd_format_amount($price)) . $button_text;
}
}
if (edd_item_in_cart($args['download_id']) && !$variable_pricing) {
$button_display = 'style="display:none;"';
$checkout_display = '';
} else {
$button_display = '';
$checkout_display = 'style="display:none;"';
}
global $edd_displayed_form_ids;
$form_id = !empty($args['form_id']) ? $args['form_id'] : 'edd_purchase_' . $args['download_id'];
$args = apply_filters('edd_purchase_link_args', $args);
ob_start();
?>
<form id="<?php
echo $form_id;
?>
" class="edd_download_purchase_form" method="post">
<?php
do_action('edd_purchase_link_top', $args['download_id'], $args);
?>
<div class="edd_purchase_submit_wrapper">
<?php
$class = implode(' ', array($args['style'], $args['color'], trim($args['class'])));
if (!edd_is_ajax_disabled()) {
echo '<a href="#" class="edd-add-to-cart ' . esc_attr($class) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($args['download_id']) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '><span class="edd-add-to-cart-label">' . $args['text'] . '</span> <span class="edd-loading"><i class="edd-icon-spinner edd-icon-spin"></i></span></a>';
}
echo '<input type="submit" class="edd-add-to-cart edd-no-js ' . esc_attr($class) . '" name="edd_purchase_download" value="' . esc_attr($args['text']) . '" data-action="edd_add_to_cart" data-download-id="' . esc_attr($args['download_id']) . '" ' . $data_variable . ' ' . $type . ' ' . $button_display . '/>';
echo '<a href="' . esc_url(edd_get_checkout_uri()) . '" class="edd_go_to_checkout ' . esc_attr($class) . '" ' . $checkout_display . '>' . __('Checkout', 'edd') . '</a>';
?>
<?php
if (!edd_is_ajax_disabled()) {
?>
<span class="edd-cart-ajax-alert">
<span class="edd-cart-added-alert" style="display: none;">
<?php
printf(__('<i class="edd-icon-ok"></i> Added to cart', 'edd'), '<a href="' . esc_url(edd_get_checkout_uri()) . '" title="' . __('Go to Checkout', 'edd') . '">', '</a>');
?>
</span>
</span>
<?php
}
?>
<?php
if (edd_display_tax_rate() && edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Includes %1$s% tax', 'edd'), edd_get_tax_rate() * 100) . '</span>';
} elseif (edd_display_tax_rate() && !edd_prices_include_tax()) {
echo '<span class="edd_purchase_tax_rate">' . sprintf(__('Excluding %1$s% tax', 'edd'), edd_get_tax_rate() * 100) . '</span>';
}
?>
</div><!--end .edd_purchase_submit_wrapper-->
<input type="hidden" name="download_id" value="<?php
echo esc_attr($args['download_id']);
//.........这里部分代码省略.........
示例9: edd_get_purchase_link
/**
* Get Purchase Link
*
* Returns the purchase link.
*
* $download_id = null, $link_text = null, $style = null, $color = null, $class = null
*
* @access public
* @since 1.0
* @return string
*/
function edd_get_purchase_link($args = array())
{
global $edd_options, $post;
if (!isset($edd_options['purchase_page']) || $edd_options['purchase_page'] == 0) {
edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'edd'), admin_url('edit.php?post_type=download&page=edd-settings')));
edd_print_errors();
return false;
}
$defaults = array('download_id' => $post->ID, 'price' => (bool) true, 'text' => isset($edd_options['add_to_cart_text']) && $edd_options['add_to_cart_text'] != '' ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd'), 'style' => isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button', 'color' => isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue', 'class' => 'edd-submit');
$args = wp_parse_args($args, $defaults);
$variable_pricing = edd_has_variable_prices($args['download_id']);
$data_variable = $variable_pricing ? ' data-variable-price="yes"' : '';
if ($args['price'] && !$variable_pricing) {
$price = edd_get_download_price($args['download_id']);
if (edd_use_taxes() && edd_taxes_on_prices()) {
$price += edd_calculate_tax($price);
}
$args['text'] = edd_currency_filter(edd_format_amount($price)) . ' – ' . $args['text'];
}
if (edd_item_in_cart($args['download_id'])) {
$button_display = 'style="display:none;"';
$checkout_display = '';
} else {
$button_display = '';
$checkout_display = 'style="display:none;"';
}
ob_start();
?>
<form id="edd_purchase_<?php
echo $args['download_id'];
?>
" class="edd_download_purchase_form" method="post">
<?php
do_action('edd_purchase_link_top', $args['download_id']);
?>
<div class="edd_purchase_submit_wrapper">
<?php
printf('<input type="submit" class="edd-add-to-cart %1$s" name="edd_purchase_download" value="%2$s" data-action="edd_add_to_cart" data-download-id="%3$s" %4$s %5$s/>', implode(' ', array($args['style'], $args['color'], trim($args['class']))), esc_attr($args['text']), esc_attr($args['download_id']), esc_attr($data_variable), $button_display);
printf('<a href="%1$s" class="%2$s %3$s" %4$s>' . __('Checkout', 'edd') . '</a>', esc_url(edd_get_checkout_uri()), esc_attr('edd_go_to_checkout'), implode(' ', array($args['style'], $args['color'], trim($args['class']))), $checkout_display);
?>
<?php
if (edd_is_ajax_enabled()) {
?>
<span class="edd-cart-ajax-alert">
<img src="<?php
echo esc_url(EDD_PLUGIN_URL . 'assets/images/loading.gif');
?>
" class="edd-cart-ajax" style="display: none;" />
<span class="edd-cart-added-alert" style="display: none;">—<?php
_e('Item successfully added to your cart.', 'edd');
?>
</span>
</span>
<?php
}
?>
</div><!--end .edd_purchase_submit_wrapper-->
<input type="hidden" name="download_id" value="<?php
echo esc_attr($args['download_id']);
?>
">
<input type="hidden" name="edd_action" value="add_to_cart">
<?php
do_action('edd_purchase_link_end', $args['download_id']);
?>
</form><!--end #edd_purchase_<?php
echo esc_attr($args['download_id']);
?>
-->
<?php
$purchase_form = ob_get_clean();
return apply_filters('edd_purchase_download_form', $purchase_form, $args);
}
示例10: edd_get_purchase_link
/**
* Get Purchase Link
*
* Returns the purchase link.
*
* @access public
* @since 1.0
* @return string
*/
function edd_get_purchase_link($download_id = null, $link_text = null, $style = null, $color = null, $class = '')
{
global $edd_options, $post, $user_ID;
if (!isset($edd_options['purchase_page']) || $edd_options['purchase_page'] == 0) {
edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'edd'), admin_url('edit.php?post_type=download&page=edd-settings')));
edd_print_errors();
return false;
}
$page = get_permalink($post->ID);
// current page
$link_args = array('download_id' => $download_id, 'edd_action' => 'add_to_cart');
$link = add_query_arg($link_args, $page);
$checkout_url = get_permalink($edd_options['purchase_page']);
$variable_pricing = edd_has_variable_prices($download_id);
if (is_null($link_text)) {
$link_text = get_post_meta($post->ID, '_edd_purchase_text', true) ? get_post_meta($post->ID, '_edd_purchase_text', true) : __('Purchase', 'edd');
}
if (is_null($style)) {
$style = get_post_meta($post->ID, '_edd_purchase_style', true) ? get_post_meta($post->ID, '_edd_purchase_style', true) : 'button';
}
if (is_null($color)) {
$color = get_post_meta($post->ID, '_edd_purchase_color', true) ? str_replace(' ', '_', get_post_meta($post->ID, '_edd_purchase_color', true)) : 'blue';
}
$purchase_form = '<form id="edd_purchase_' . $download_id . '" class="edd_download_purchase_form" method="POST">';
if ($variable_pricing) {
$prices = edd_get_variable_prices($download_id);
$purchase_form .= '<div class="edd_price_options">';
if ($prices) {
foreach ($prices as $key => $price) {
$checked = '';
if ($key == 0) {
$checked = 'checked="checked"';
}
$purchase_form .= sprintf('<input type="radio" %1$s name="edd_options[price_id]" id="%2$s" class="%3$s" value="%4$s"/> ', $checked, esc_attr('edd_price_option_' . $download_id . '_' . $key), esc_attr('edd_price_option_' . $download_id), esc_attr($key));
$purchase_form .= sprintf('<label for="%1$s">%2$s</label><br/>', esc_attr('edd_price_option_' . $download_id . '_' . $key), esc_html($price['name'] . ' - ' . edd_currency_filter($price['amount'])));
}
}
$purchase_form .= '</div><!--end .edd_price_options-->';
}
$purchase_form .= '<div class="edd_purchase_submit_wrapper">';
$data_variable = $variable_pricing ? ' data-variable-price="yes"' : '';
if (edd_item_in_cart($download_id)) {
$button_display = 'style="display:none;"';
$checkout_display = '';
} else {
$button_display = '';
$checkout_display = 'style="display:none;"';
}
if ($style == 'button') {
$purchase_button = sprintf('<span class="%1$s" %2$s>', esc_attr('edd_button edd_add_to_cart_wrap edd_' . $color), $button_display);
$purchase_button .= '<span class="edd_button_outer">';
$purchase_button .= '<span class="edd_button_inner">';
$purchase_button .= sprintf('<input type="submit" class="%1$s" name="edd_purchase_download" value="%2$s" data-action="edd_add_to_cart" data-download-id="%3$s" %4$s/>', esc_attr('edd_button_text edd-submit edd-add-to-cart ' . $class), esc_attr($link_text), esc_attr($download_id), $data_variable);
$purchase_button .= '</span>';
$purchase_button .= '</span>';
$purchase_button .= '</span>';
$checkout_link = sprintf('<a href="%1$s" class="%2$s" %3$s>', esc_url($checkout_url), esc_attr('edd_go_to_checkout edd_button edd_' . $color), $checkout_display);
$checkout_link .= '<span class="edd_button_outer"><span class="edd_button_inner">';
$checkout_link .= '<span class="edd_button_text"><span>' . __('Checkout', 'edd') . '</span></span>';
$checkout_link .= '</span></span>';
$checkout_link .= '</a>';
$purchase_form .= $purchase_button . $checkout_link;
} else {
$purchase_text = sprintf('<input type="submit" class="%1$s" name="edd_purchase_download" value="%2$s" data-action="edd_add_to_cart" data-download-id="%3$s" %4$s %5$s/>', esc_attr('edd_submit_plain edd-add-to-cart ' . $class), esc_attr($link_text), esc_attr($download_id), esc_attr($data_variable), esc_attr($button_display));
$checkout_link = sprintf('<a href="%1$s" class="%2$s" %3$s>', esc_url($checkout_url), esc_attr('edd_go_to_checkout edd_button edd_' . $color), $checkout_display);
$checkout_link .= __('Checkout', 'edd');
$checkout_link .= '</a>';
$purchase_form .= $purchase_text . $checkout_link;
}
if (edd_is_ajax_enabled()) {
$purchase_form .= sprintf('<div class="edd-cart-ajax-alert"><img src="%1$s" class="edd-cart-ajax" style="display: none;"/>', esc_url(EDD_PLUGIN_URL . 'includes/images/loading.gif'));
$purchase_form .= ' <span style="display:none;" class="edd-cart-added-alert">' . __('added to your cart', 'edd') . '</span></div>';
}
$purchase_form .= '</div><!--end .edd_purchase_submit_wrapper-->';
$purchase_form .= '<input type="hidden" name="download_id" value="' . esc_attr($download_id) . '">';
$purchase_form .= '<input type="hidden" name="edd_action" value="add_to_cart">';
$purchase_form .= '</form><!--end #edd_purchase_' . esc_html($download_id) . '-->';
return apply_filters('edd_purchase_download_form', $purchase_form, $download_id, $link_text, $style, $color, $class);
}
示例11: edd_login_form
/**
* Login Form
*
* @access private
* @since 1.0
* @return string
*/
function edd_login_form($redirect = '')
{
global $edd_options, $post;
if ($redirect == '') {
$redirect = edd_get_current_page_url();
}
ob_start();
if (!is_user_logged_in()) {
?>
<?php
// show any error messages after form submission
edd_print_errors();
?>
<form id="edd_login_form" class="edd_form" action="" method="post">
<fieldset>
<legend><?php
_e('Log into Your Account', 'edd');
?>
</legend>
<p>
<label for="edd_user_Login"><?php
_e('Username', 'edd');
?>
</label>
<input name="edd_user_login" id="edd_user_login" class="required" type="text" title="<?php
_e('Username', 'edd');
?>
"/>
</p>
<p>
<label for="edd_user_pass"><?php
_e('Password', 'edd');
?>
</label>
<input name="edd_user_pass" id="edd_user_pass" class="password required" type="password"/>
</p>
<p>
<input type="hidden" name="edd_redirect" value="<?php
echo $redirect;
?>
"/>
<input type="hidden" name="edd_login_nonce" value="<?php
echo wp_create_nonce('edd-login-nonce');
?>
"/>
<input type="hidden" name="edd_action" value="user_login"/>
<input id="edd_login_submit" type="submit" class="edd_submit" value="<?php
_e('Login', 'edd');
?>
"/>
</p>
<p class="edd-lost-password">
<a href="<?php
echo wp_lostpassword_url();
?>
" title="<?php
_e('Lost Password', 'edd');
?>
">
<?php
_e('Lost Password?', 'edd');
?>
</a>
</p>
</fieldset>
</form>
<?php
} else {
echo '<p class="edd-logged-in">' . __('You are already logged in', 'edd') . '</p>';
}
return ob_get_clean();
}
示例12: edd_login_form
/**
* Login Form
*
* @access private
* @since 1.0
* @return string
*/
function edd_login_form($redirect = '')
{
global $edd_options, $post;
if ($redirect == '') {
if (is_singular()) {
$redirect = home_url();
} else {
$redirect = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$redirect .= "s";
}
$redirect .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$redirect .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
} else {
$redirect .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
}
}
ob_start();
if (!is_user_logged_in()) {
?>
<?php
// show any error messages after form submission
edd_print_errors();
?>
<form id="edd_login_form" class="edd_form" action="" method="post">
<fieldset>
<legend><?php
_e('Log into Your Account', 'edd');
?>
</legend>
<p>
<label for="edd_user_Login"><?php
_e('Username', 'edd');
?>
</label>
<input name="edd_user_login" id="edd_user_login" class="required" type="text" title="<?php
_e('Username', 'edd');
?>
"/>
</p>
<p>
<label for="edd_user_pass"><?php
_e('Password', 'edd');
?>
</label>
<input name="edd_user_pass" id="edd_user_pass" class="password required" type="password"/>
</p>
<p>
<input type="hidden" name="edd_redirect" value="<?php
echo $redirect;
?>
"/>
<input type="hidden" name="edd_login_nonce" value="<?php
echo wp_create_nonce('edd-login-nonce');
?>
"/>
<input type="hidden" name="edd_action" value="user_login"/>
<input id="edd_login_submit" type="submit" class="edd_submit" value="<?php
_e('Login', 'edd');
?>
"/>
</p>
<p class="edd-lost-password">
<a href="<?php
echo wp_lostpassword_url();
?>
" title="<?php
_e('Lost Password', 'edd');
?>
">
<?php
_e('Lost Password?', 'edd');
?>
</a>
</p>
</fieldset>
</form>
<?php
} else {
echo '<p class="edd-logged-in">' . __('You are already logged in', 'edd') . '</p>';
}
return ob_get_clean();
}