private function callback_login() { if (empty($_COOKIE[TEST_COOKIE])) { $this->message_collection->add(__("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to log in to your account.", 'wp-e-commerce'), 'error'); } $form_args = wpsc_get_login_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } $user = wp_signon(array('user_login' => $_POST['username'], 'user_password' => $_POST['password'], 'rememberme' => !empty($_POST['rememberme']))); if (is_wp_error($user)) { $this->message_collection->add(__('We do not recognize the login information you entered. Please try again.', 'wp-e-commerce'), 'error'); return; } $redirect_to = wp_get_referer(); if (wpsc_get_customer_meta('checkout_after_login')) { $redirect_to = wpsc_get_checkout_url(); wpsc_delete_customer_meta('checkout_after_login'); } if (!$redirect_to || trim(str_replace(home_url(), '', $redirect_to), '/') == trim($_SERVER['REQUEST_URI'], '/')) { $redirect_to = wpsc_get_store_url(); } wp_redirect($redirect_to); exit; }
/** * Generate the form configuration array for this tab * * @since 0.1 * @access private */ private function populate_form_array() { // define the sections $this->sections = array('locations' => array('title' => _x('Page Slugs', 'page locations section title', 'wpsc'), 'fields' => array('store_slug', 'store_as_front_page', 'category_base_slug', 'product_base_slug', 'cart_page_slug', 'checkout_page_slug', 'customer_account_page_slug', 'login_page_slug', 'password_reminder_page_slug', 'register_page_slug', 'prefix_product_slug', 'hierarchical_product_category_url')), 'titles' => array('title' => _x('Page Titles', 'page titles section title', 'wpsc'), 'fields' => array('store_title', 'cart_page_title', 'checkout_page_title', 'customer_account_page_title', 'login_page_title', 'password_reminder_page_title', 'register_page_title'))); // Shortcut variables for buttons and messages $view_button = '<a class="button button-secondary button-view-page" href="%1$s">%2$s</a>'; $view_message = _x('View', 'view page', 'wpsc'); $view_category_message = _x('Sample Category', 'view page', 'wpsc'); $view_product_message = _x('Sample Product', 'view page', 'wpsc'); // generate sample URLs for single product and product category $base_shop_url = '<small>' . esc_url(wpsc_get_store_url('/')) . '</small>'; $sample_category = get_terms('wpsc_product_category', array('number' => 1)); $sample_product = get_posts(array('post_type' => 'wpsc-product', 'numberposts' => 1)); // generate form fields $this->form_array = array('store_slug' => array('type' => 'textfield', 'prepend' => '<small>' . esc_url(home_url('/')) . '</small>', 'title' => _x('Main store', 'page slug setting', 'wpsc'), 'append' => sprintf($view_button, wpsc_get_store_url(), $view_message), 'validation' => 'required', 'class' => 'regular-text'), 'store_as_front_page' => array('type' => 'radios', 'title' => _x('Display main store on front page', 'page settings', 'wpsc'), 'options' => array(1 => _x('Yes', 'settings', 'wpsc'), 0 => _x('No', 'settings', 'wpsc'))), 'store_title' => array('type' => 'textfield', 'title' => _x('Main store title', 'page slug title', 'wpsc'), 'validation' => 'required'), 'category_base_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => empty($sample_category) ? '' : sprintf($view_button, get_term_link($sample_category[0]), $view_category_message), 'title' => _x('Product category base slug', 'permalinks setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'product_base_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => empty($sample_product) ? '' : sprintf($view_button, get_permalink($sample_product[0]), $view_product_message), 'title' => _x('Single product base slug', 'permalinks setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'prefix_product_slug' => array('type' => 'checkboxes', 'title' => _x('Product prefix', 'permalinks setting', 'wpsc'), 'options' => array(1 => __('Include category slug in product URL.', 'wpsc'))), 'hierarchical_product_category_url' => array('type' => 'radios', 'title' => _x('Hierarchical product category URL', 'permalinks setting', 'wpsc'), 'options' => array(1 => _x('Yes', 'settings', 'wpsc'), 0 => _x('No', 'settings', 'wpsc')), 'description' => __('When hierarchical product category URL is enabled, parent product categories are also included in the product URL.', 'wpsc')), 'cart_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => sprintf($view_button, wpsc_get_cart_url(), $view_message), 'title' => _x('Cart page', 'page settings', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'cart_page_title' => array('type' => 'textfield', 'title' => _x('Cart page', 'page settings', 'wpsc'), 'validation' => 'required'), 'checkout_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Checkout page', 'page setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'checkout_page_title' => array('type' => 'textfield', 'title' => _x('Checkout page', 'page settings', 'wpsc'), 'validation' => 'required'), 'customer_account_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => sprintf($view_button, wpsc_get_customer_account_url(), $view_message), 'title' => _x('Customer account page', 'permalinks setting', 'wpsc'), 'validation' => 'required|slug_not_conflicted', 'class' => 'regular-text'), 'customer_account_page_title' => array('type' => 'textfield', 'title' => _x('Customer account page', 'page settings', 'wpsc'), 'validation' => 'required'), 'login_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Login page', 'permalinks setting', 'wpsc'), 'description' => __('Leaving this field blank will disable the page.', 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'login_page_title' => array('type' => 'textfield', 'title' => _x('Login page', 'page settings', 'wpsc'), 'validation' => 'required'), 'password_reminder_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Password reminder page', 'permalinks setting', 'wpsc'), 'description' => __("Leaving this field blank will disable the page.", 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'password_reminder_page_title' => array('type' => 'textfield', 'title' => _x('Password reminder page', 'page settings', 'wpsc'), 'validation' => 'required'), 'register_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Register page', 'permalinks setting', 'wpsc'), 'description' => __("Leaving this field blank will disable the page.", 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'register_page_title' => array('type' => 'textfield', 'title' => _x('Register page', 'page settings', 'wpsc'), 'validation' => 'required')); // display warnings for login, register and password reminder pages when // "Anyone can register" is disabled. if (!get_option('users_can_register')) { $additional_description = '<br /> ' . __('<strong>Note:</strong> Enable "Anyone can register" in <a href="%s">Settings -> General</a> first if you want to use this page.', 'wpsc'); $additional_description = sprintf($additional_description, admin_url('options-general.php')); $this->form_array['login_page_slug']['description'] .= $additional_description; $this->form_array['password_reminder_page_slug']['description'] .= $additional_description; $this->form_array['register_page_slug']['description'] .= $additional_description; } }
public function __construct() { if (is_user_logged_in()) { wp_redirect(wpsc_get_store_url()); exit; } $this->title = wpsc_get_password_reminder_title(); parent::__construct(); }
public function __construct() { if (is_user_logged_in()) { wp_redirect(wpsc_get_store_url()); exit; } parent::__construct(); $this->title = wpsc_get_register_title(); }
public function widget($args, $instance) { global $wpdb; $prices = $wpdb->get_row('SELECT COUNT(DISTINCT meta_value) AS count, MAX(meta_value) AS max, MIN(meta_value) AS min FROM ' . $wpdb->postmeta . ' AS m INNER JOIN ' . $wpdb->posts . ' ON m.post_id = ID WHERE meta_key = "_wpsc_price" AND meta_value > 0'); if (empty($prices->count)) { return; } $prices->min = round($prices->min); $prices->max = round($prices->max); $range_count = $prices->count > 5 ? 6 : $prices->count; $diff = ($prices->max - $prices->min) / $range_count; $instance = wp_parse_args($instance, $this->defaults); $title = apply_filters('widget_title', $instance['title']); if ($range_count == 1 || $prices->min == $prices->max) { return; } extract($args); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } echo '<ul>'; /** %1$s: min price, %2$s: max price **/ $text = _x('From %1$s to %2$s', 'price range widget', 'wpsc'); $range_max = $prices->min - 0.01; $i = 0; while ($range_max <= $prices->max) { $range_min = $range_max + 0.01; $range_max = $range_min + round($diff) - 0.01; $href = wpsc_get_store_url() . $range_min . '/' . $range_max; echo '<li>'; if ($i === 0) { echo '<a href="' . esc_url($href) . '">' . sprintf(__('Under %s', 'price range widget', 'wpsc'), wpsc_format_currency($range_max)) . '</a>'; } elseif ($range_max >= $prices->max) { echo '<a href="' . esc_url($href) . '">' . sprintf(__('Over %s', 'price range widget', 'wpsc'), wpsc_format_currency($range_min)) . '</a>'; } else { echo '<a href="' . esc_url($href) . '">' . sprintf($text, wpsc_format_currency($range_min), wpsc_format_currency($range_max)) . '</a>'; } echo '</li>'; $i++; } echo '</ul>'; echo $after_widget; }
private function send_registration_notification($user_id, $username, $email, $password) { wp_new_user_notification($user_id); $username = stripslashes($username); $password = stripslashes($password); $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $title = apply_filters('wpsc_registration_notification_title', __('[%s] Thank you for registering', 'wpsc')); $title = sprintf($title, $blogname); $message = sprintf(__('Welcome, %s.', 'wpsc'), $username) . "\r\n\r\n"; $message .= __("Thank you for registering with us. Your account has been created:", 'wpsc') . "\r\n\r\n"; $message .= sprintf(__('Username: %s', 'wpsc'), $username) . "\r\n\r\n"; $message .= sprintf(__('Password: %s', 'wpsc'), $password) . "\r\n\r\n"; $message .= __("Here's a list of things you can do to get started:", 'wpsc') . "\r\n\r\n"; $message .= sprintf(__('1. Log in with your new account details <%s>', 'wpsc'), wpsc_get_login_url()) . "\r\n\r\n"; $message .= sprintf(__('2. Build your customer profile, and probably change your password to something easier to remember <%s>', 'wpsc'), wpsc_get_customer_account_url()) . "\r\n\r\n"; $message .= sprintf(__('3. Explore our shop! <%s>', 'wpsc'), wpsc_get_store_url()) . "\r\n\r\n"; $message = apply_filters('wpsc_registration_notification_body', $message); wp_mail($email, $title, $message); }
function wpsc_get_category_filter($args = '') { if (!wpsc_get_option('display_category_filter')) { return ''; } if (!wpsc_is_store() && !wpsc_is_product_category()) { return ''; } $defaults = array('before' => '<div class="%s">', 'after' => '</div>', 'before_cat_list' => '<ul class="%s">', 'after_cat_list' => '</ul>', 'before_drill_down' => '<ul class="%s">', 'after_drill_down' => '</ul>', 'before_item' => '<li class="%s">', 'after_item' => '</li>', 'before_divider' => '<span class="%s">', 'after_divider' => '</span>', 'before_drill_down_divider' => '<span class="%s">', 'after_drill_down_divider' => '<span class="%s">', 'divider' => '|', 'drill_down_divider' => '»', 'padding' => 1, 'all_text' => _x('All', 'category filter', 'wpsc')); $defaults = apply_filters('wpsc_get_category_filter_default_args', $defaults); $r = wp_parse_args($args, $defaults); extract($r); $before = sprintf($before, 'wpsc-category-filter'); $before_cat_list = sprintf($before_cat_list, 'wpsc-category-filter-list'); $before_drill_down = sprintf($before_drill_down, 'wpsc-category-filter-drill-down'); $before_divider = sprintf($before_divider, 'wpsc-category-filter-divider'); $before_drill_down_divider = sprintf($before_drill_down_divider, 'wpsc-category-filter-drill-down-divider'); if ($padding) { $length = strlen($divider) + $padding * 2; $padding = str_repeat(" ", $padding); $divider = $padding . $divider . $padding; $drill_down_divider = $padding . $drill_down_divider . $padding; } $divider = $before_divider . $divider . $after_divider; $drill_down_divider = $before_drill_down_divider . $drill_down_divider . $after_drill_down_divider; $displayed_categories = _wpsc_get_filtered_categories(); $ids = wp_list_pluck($displayed_categories, 'term_id'); $filters = array(); $drilldown = array(); // When drill down is enabled and we're not on store page if (wpsc_get_option('category_filter_drill_down') && !wpsc_is_store()) { $term = get_queried_object(); $current = $term; // we need to trace back this category ancestors, if none of its ancestors // is one of the categories selected in the settings, the filter is not // output $ancestor_is_displayed = in_array($term->term_id, $ids); $ancestors = array(); while ($term->parent) { $term = get_term($term->parent, 'wpsc_product_category'); $ancestors[] = $term; if (in_array($term->term_id, $ids)) { $ancestor_is_displayed = true; break; } } if (!$ancestor_is_displayed) { return ''; } // First item is always "All" $before_all = sprintf($before_item, 'wpsc-category-filter-drill-down-item wpsc-category-filter-drill-down-item-all'); $link = '<a href="' . esc_url(wpsc_get_store_url()) . '">' . esc_html_x('All', 'category filter', 'wpsc') . '</a>'; $drilldown[] = $before_all . $link . $drill_down_divider . $after_item; $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $before_this_item = sprintf($before_item, 'wpsc-category-filter-drill-down-item'); $url = add_query_arg('wpsc_category_filter', 1, wpsc_get_product_category_permalink($ancestor->term_id)); $link = '<a href="' . esc_url($url) . '">' . esc_html($ancestor->name) . '</a>'; $drilldown[] = $before_this_item . $link . $drill_down_divider . $after_item; } // current category $before_this_item = sprintf($before_item, 'wpsc-category-filter-drill-down-item wpsc-category-filter-drill-down-item-active'); $url = add_query_arg('wpsc_category_filter', 1, wpsc_get_product_category_permalink($current->term_id)); $link = '<a href="' . esc_url($url) . '">' . esc_html($current->name) . '</a>'; $drilldown[] = $before_this_item . $link . $after_item; $displayed_categories = get_terms('wpsc_product_category', array('parent' => $current->term_id, 'hide_empty' => 0)); // When drill down is disabled, or when it is enabled and we're on store page } else { // If we're in store page, just simply display all categories as selected in // Settings->Store->Presentation // if we're in the wrong category, don't display the filter $current = get_queried_object_id(); if (!wpsc_is_store() && !in_array($current, $ids)) { return ''; } // if we're not on store page, and the 'wpsc_category_filter' query arg // is not set to 1, don't display the filter if (!wpsc_is_store() && empty($_GET['wpsc_category_filter'])) { return ''; } // First item is always "All" $before_all = sprintf($before_item, 'wpsc-category-filter-item wpsc-category-filter-item-all'); $link = '<a href="' . esc_url(wpsc_get_store_url()) . '">' . esc_html_x('All', 'category filter', 'wpsc') . '</a>'; $filters[] = $before_all . $link . $divider . $after_item; } $cats_count = count($displayed_categories); // Subsequent items are extracted from $displayed_categories for ($i = 0; $i < $cats_count; $i++) { $cat = $displayed_categories[$i]; $classes = 'wpsc-category-filter-item'; // mark current category if (!wpsc_is_store() && $cat->term_id == $current) { $classes .= ' wpsc-category-filter-item-active'; } $before_this_item = sprintf($before_item, $classes); $url = add_query_arg('wpsc_category_filter', 1, wpsc_get_product_category_permalink($cat->term_id)); $link = '<a href="' . esc_url($url) . '">' . esc_html($cat->name) . '</a>'; $filter = $before_this_item . $link; if ($i < $cats_count - 1) { $filter .= $divider; } $filter .= $after_item; $filters[] = $filter; } $html = $before; if (!empty($drilldown)) { $html .= $before_drill_down . implode('', $drilldown) . $after_drill_down; } if (!empty($filters)) { $html .= $before_cat_list . implode('', $filters) . $after_cat_list; } $html .= $after; return apply_filters('wpsc_get_category_filter', $html, $filters, $r); }
/** * Return the HTML for the Keep Shopping button * * @since 0.1 * @return string HTML output */ function wpsc_get_keep_shopping_button() { $keep_shopping_url = isset($_REQUEST['_wp_http_referer']) ? esc_attr($_REQUEST['_wp_http_referer']) : wpsc_get_store_url(); $title = apply_filters('wpsc_keep_shopping_button_title', __('Keep Shopping', 'wp-e-commerce')); $button = sprintf('<a class="wpsc-button wpsc-keep-shopping-button" href="%1$s">%2$s</a>', esc_url($keep_shopping_url), $title); return apply_filters('wpsc_get_keep_shopping_button', $button); }
function wpsc_store_url() { echo wpsc_get_store_url(); }