function _wpsc_maybe_update_user_log_file() { $hashes = array('3.8' => '1526bcf18869f9ea2f4061f528a1a21a', '3.8.4' => '1d17c7fb086e2afcf942ca497629b4c9', '3.8.8' => 'f9549ba1b1956c78f96b1551ab965c13', '3.8.9' => '4d0bcba88d211147399e79661cf3b41d', '3.8.10' => '09e2cb9c753587c9228a4e9e8008a82f'); if (function_exists('wpsc_flush_theme_transients')) { wpsc_flush_theme_transients(true); } // Using TEv2 if (!function_exists('wpsc_get_template_file_path')) { return; } //Make sure the theme has actually been moved. $file = wpsc_get_template_file_path('wpsc-user-log.php'); if (false !== strpos(WPSC_CORE_THEME_PATH, $file)) { return; } //If it has been moved, but it's the 3.8.10 version, we should be good to go. $hash = md5_file($file); if ($hashes['3.8.10'] === $hash) { return; } //At this point, we know the file has been moved to the active file folder. Checking now if it has been modified. if (in_array($hash, $hashes)) { //We now know that they've moved the file, but haven't actually changed anything. We can safely overwrite the file with the new core file. @copy($file, path_join(get_stylesheet_directory(), 'wpsc-user-log.php')); } else { //This means they have indeed changed the file. We need to add a notice letting them know about the issue and how to fix it. update_option('_wpsc_3811_user_log_notice', '1'); } }
function wpsc_show_categories($content) { ob_start(); include wpsc_get_template_file_path('wpsc-category-list.php'); $output = ob_get_contents(); ob_end_clean(); return $output; }
function wpsc_shopping_basket_internals($deprecated = false, $quantity_limit = false, $no_title = false) { global $wpdb; $display_state = ''; if ((isset($_SESSION['slider_state']) && $_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) { $display_state = "style='display: none;'"; } echo " <div id='sliding_cart' class='shopping-cart-wrapper' {$display_state}>"; include_once wpsc_get_template_file_path('wpsc-cart_widget.php'); echo ' </div>'; }
/** * Widget Output * * @param $args (array) * @param $instance (array) Widget values. */ function widget($args, $instance) { global $wpdb; extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Product Categories', 'wpsc') : $instance['title']); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $show_thumbnails = $instance['image']; if (isset($instance['grid'])) { $grid = (bool) $instance['grid']; } if (isset($instance['width'])) { $width = $instance['width']; } if (isset($instance['height'])) { $height = $instance['height']; } if (!isset($instance['categories'])) { $instance_categories = get_terms('wpsc_product_category', 'hide_empty=0&parent=0'); if (!empty($instance_categories)) { foreach ($instance_categories as $categories) { $instance['categories'][$categories->term_id] = 'on'; } } } foreach (array_keys((array) $instance['categories']) as $category_id) { if (!get_term($category_id, "wpsc_product_category")) { continue; } if (file_exists(wpsc_get_template_file_path('wpsc-category_widget.php'))) { include wpsc_get_template_file_path('wpsc-category_widget.php'); } else { include wpsc_get_template_file_path('category_widget.php'); } } if (isset($grid) && $grid) { echo "<div class='clear_category_group'></div>"; } echo $after_widget; }
/** * Displays the Downloads template * * @access private * @since 3.8.10 * */ function _wpsc_action_downloads_section() { global $files, $products; $items = array(); if (wpsc_has_downloads() && !empty($files)) { foreach ($files as $key => $file) { $item = array(); if ($products[$key]['downloads'] > 0) { $url = add_query_arg('downloadid', $products[$key]['uniqueid'], home_url()); $item['title'] = sprintf('<a href="%1$s">%2$s</a>', esc_url($url), esc_html($file['post_title'])); } else { $item['title'] = esc_html($file['post_title']); } $item['downloads'] = $products[$key]['downloads']; $item['datetime'] = date(get_option('date_format'), strtotime($products[$key]['datetime'])); $items[] = (object) $item; } } include wpsc_get_template_file_path('wpsc-account-downloads.php'); }
/** * Checks the active theme folder for the particular file, if it exists then return the active theme directory otherwise * return the global wpsc_theme_path * @access public * * @since 3.8 * @param $file string filename * @return PATH to the file */ function wpsc_get_template_file_path($file = '') { // If we're not looking for a file, do not proceed if (empty($file)) { return; } // No cache, so find one and set it if (false === ($file_path = get_transient(WPEC_TRANSIENT_THEME_PATH_PREFIX . $file))) { // Plugin may override the template file, get the file name and check to be sure file exists $file_path = apply_filters('wpsc_get_template_file_path', false); if (!empty($file_path) && file_exists($file_path)) { $file_path = realpath($file_path); // real path just in case plugin doesn't return canonicalized path name // Look for file in stylesheet directory } elseif (file_exists(get_stylesheet_directory() . '/' . $file)) { $file_path = get_stylesheet_directory() . '/' . $file; // Look for file in template } elseif (file_exists(get_template_directory() . '/' . $file)) { $file_path = get_template_directory() . '/' . $file; // Backwards compatibility } else { // Look in old theme path $selected_theme_check = WPSC_OLD_THEMES_PATH . get_option('wpsc_selected_theme') . '/' . str_ireplace('wpsc-', '', $file); // Check the selected theme if (file_exists($selected_theme_check)) { $file_path = $selected_theme_check; // Use the bundled file } else { $file_path = path_join(WPSC_CORE_THEME_PATH, $file); } } // Save the transient and update it every 12 hours if (!empty($file_path)) { set_transient(WPEC_TRANSIENT_THEME_PATH_PREFIX . $file, $file_path, 60 * 60 * 12); } } elseif (!file_exists($file_path)) { delete_transient(WPEC_TRANSIENT_THEME_PATH_PREFIX . $file); wpsc_get_template_file_path($file); } // Return filtered result return apply_filters(WPEC_TRANSIENT_THEME_PATH_PREFIX . $file, $file_path); }
/** * wpsc_change_tax function, used through ajax and in normal page loading. * No parameters, returns nothing */ function wpsc_change_tax() { global $wpdb, $wpsc_cart; $form_id = absint($_POST['form_id']); $wpsc_selected_country = $wpsc_cart->selected_country; $wpsc_selected_region = $wpsc_cart->selected_region; $wpsc_delivery_country = $wpsc_cart->delivery_country; $wpsc_delivery_region = $wpsc_cart->delivery_region; $previous_country = $_SESSION['wpsc_selected_country']; if (isset($_POST['billing_country'])) { $wpsc_selected_country = $wpdb->escape($_POST['billing_country']); $_SESSION['wpsc_selected_country'] = $wpsc_selected_country; } if (isset($_POST['billing_region'])) { $wpsc_selected_region = absint($_POST['billing_region']); $_SESSION['wpsc_selected_region'] = $wpsc_selected_region; } $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $_SESSION['wpsc_selected_region'] . "' LIMIT 1"); if ($_SESSION['wpsc_selected_country'] != $check_country_code) { $wpsc_selected_region = null; } if (isset($_POST['shipping_country'])) { $wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']); $_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country; } if (isset($_POST['shipping_region'])) { $wpsc_delivery_region = absint($_POST['shipping_region']); $_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region; } $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `" . WPSC_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '" . $wpsc_delivery_region . "' LIMIT 1"); if ($wpsc_delivery_country != $check_country_code) { $wpsc_delivery_region = null; } $wpsc_cart->update_location(); $wpsc_cart->get_shipping_method(); $wpsc_cart->get_shipping_option(); if ($wpsc_cart->selected_shipping_method != '') { $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option); } $tax = $wpsc_cart->calculate_total_tax(); $total = wpsc_cart_total(); $total_input = wpsc_cart_total(false); if ($wpsc_cart->coupons_amount >= wpsc_cart_total() && !empty($wpsc_cart->coupons_amount)) { $total = 0; } if ($wpsc_cart->total_price < 0) { $wpsc_cart->coupons_amount += $wpsc_cart->total_price; $wpsc_cart->total_price = null; $wpsc_cart->calculate_total_price(); } ob_start(); include_once wpsc_get_template_file_path('wpsc-cart_widget.php'); $output = ob_get_contents(); ob_end_clean(); $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); if (get_option('lock_tax') == 1) { echo "jQuery('#current_country').val('" . $_SESSION['wpsc_delivery_country'] . "'); \n"; if ($_SESSION['wpsc_delivery_country'] == 'US' && get_option('lock_tax') == 1) { $output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']); $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); echo "jQuery('#region').remove();\n\r"; echo "jQuery('#change_country').append(\"" . $output . "\");\n\r"; } } foreach ($wpsc_cart->cart_items as $key => $cart_item) { echo "jQuery('#shipping_{$key}').html(\"" . wpsc_currency_display($cart_item->shipping) . "\");\n\r"; } echo "jQuery('#checkout_shipping').html(\"" . wpsc_cart_shipping() . "\");\n\r"; echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n"; if (get_option('lock_tax') == 1) { echo "jQuery('.shipping_country').val('" . $_SESSION['wpsc_delivery_country'] . "') \n"; $sql = "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $_SESSION['wpsc_selected_country'] . "'"; $country_name = $wpdb->get_var($sql); echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n"; } $form_selected_country = null; $form_selected_region = null; $onchange_function = null; if ($_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) { $form_selected_country = $wpsc_selected_country; $form_selected_region = $wpsc_selected_region; $onchange_function = 'set_billing_country'; } else { if ($_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) { $form_selected_country = $wpsc_delivery_country; $form_selected_region = $wpsc_delivery_region; $onchange_function = 'set_shipping_country'; } } if ($form_selected_country != null && $onchange_function != null) { $region_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $form_selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A); if ($region_list != null) { $title = empty($_POST['billing_country']) ? 'shippingstate' : 'billingstate'; $output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");' title='" . $title . "'>\n\r"; foreach ($region_list as $region) { if ($form_selected_region == $region['id']) { $selected = "selected='selected'"; } else { $selected = ""; } $output .= " <option value='" . $region['id'] . "' {$selected}>" . htmlspecialchars($region['name']) . "</option>\n\r"; } $output .= "</select>\n\r"; $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); echo "jQuery('#region_select_{$form_id}').html(\"" . $output . "\");\n\r"; echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().hide();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().hide();\n\t\t\t"; } else { if (get_option('lock_tax') == 1) { echo "jQuery('#region').hide();"; } echo "jQuery('#region_select_{$form_id}').html('');\n\r"; echo "\n\t\t\t\tvar wpsc_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpsc_checkout_table').attr('class');\n\t\t\t\twpsc_checkout_table_selector = wpsc_checkout_table_selector.replace(' ','.');\n\t\t\t\twpsc_checkout_table_selector = '.'+wpsc_checkout_table_selector;\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.billing_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' input.shipping_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .billing_region').parent().parent().show();\n\t\t\t\tjQuery(wpsc_checkout_table_selector + ' .shipping_region').parent().parent().show();\n\t\t\t"; } } if ($tax > 0) { echo "jQuery(\"tr.total_tax\").show();\n\r"; } else { echo "jQuery(\"tr.total_tax\").hide();\n\r"; } echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpsc_cart_tax() . "</span>\");\n\r"; echo "jQuery('#checkout_total').html(\"{$total}<input id='shopping_cart_total_price' type='hidden' value='{$total_input}' />\");\n\r"; echo "if(jQuery(\"#shippingSameBilling\").is(\":checked\")) wpsc_shipping_same_as_billing();"; exit; }
/** * wpsc_display_products_page function. * * @access public * @param mixed $query * @return void */ function wpsc_display_featured_products_page() { global $wp_query; $output = ''; $sticky_array = get_option('sticky_products'); if ((is_front_page() || is_home() || is_products_page()) && !empty($sticky_array) && $wp_query->post_count > 1) { $query = get_posts(array('post__in' => $sticky_array, 'post_type' => 'wpsc-product', 'orderby' => 'rand', 'numberposts' => 1, 'posts_per_page' => 1)); if (count($query) > 0) { $GLOBALS['nzshpcrt_activateshpcrt'] = true; $image_width = get_option('product_image_width'); $image_height = get_option('product_image_height'); $featured_product_theme_path = wpsc_get_template_file_path('wpsc-featured_product.php'); ob_start(); include_once $featured_product_theme_path; $is_single = false; $output .= ob_get_contents(); ob_end_clean(); //Begin outputting featured product. We can worry about templating later, or folks can just CSS it up. echo $output; //End output } } }
/** * Widget Output * * @param $args (array) * @param $instance (array) Widget values. * */ function widget($args, $instance) { extract($args); // Create fancy collapser $fancy_collapser = ''; if ($instance['show_sliding_cart'] == 1) { if (isset($_SESSION['slider_state']) && is_numeric($_SESSION['slider_state'])) { if ($_SESSION['slider_state'] == 0) { $collapser_image = 'plus.png'; } else { $collapser_image = 'minus.png'; } $fancy_collapser = ' <a href="#" onclick="return shopping_cart_collapser()" id="fancy_collapser_link"><img src="' . WPSC_CORE_IMAGES_URL . '/' . $collapser_image . '" title="" alt="" id="fancy_collapser" /></a>'; } else { if (!wpsc_get_customer_meta('nzshpcart')) { $collapser_image = 'plus.png'; } else { $collapser_image = 'minus.png'; } $fancy_collapser = ' <a href="#" onclick="return shopping_cart_collapser()" id="fancy_collapser_link"><img src="' . WPSC_CORE_IMAGES_URL . '/' . $collapser_image . '" title="" alt="" id="fancy_collapser" /></a>'; } } // Start widget output $title = apply_filters('widget_title', empty($instance['title']) ? __('Shopping Cart', 'wpsc') : $instance['title']); echo $before_widget; if ($title) { echo $before_title . $title . $fancy_collapser . $after_title; } // Set display state $display_state = ''; if ((isset($_SESSION['slider_state']) && $_SESSION['slider_state'] == 0 || wpsc_cart_item_count() < 1) && get_option('show_sliding_cart') == 1) { $display_state = 'style="display: none;"'; } // Output start, if we are not allowed to save results ( WPSC_DONT_CACHE ) load the cart using ajax $use_object_frame = false; if (WPSC_PAGE_CACHE_IN_USE) { echo '<div id="sliding_cart" class="shopping-cart-wrapper">'; if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') == false && $use_object_frame == true) { ?> <object codetype="text/html" type="text/html" data="index.php?wpsc_action=cart_html_page" border="0"> <p><?php _e('Loading...', 'wpsc'); ?> </p> </object> <?php } else { ?> <div class="wpsc_cart_loading"><p><?php _e('Loading...', 'wpsc'); ?> </p></div> <?php } echo '</div>'; } else { echo '<div id="sliding_cart" class="shopping-cart-wrapper" ' . $display_state . '>'; include wpsc_get_template_file_path('wpsc-cart_widget.php'); echo '</div>'; } // End widget output echo $after_widget; }
/** * Returns the Cart Widget * * @param boolean $die Whether or not to return the output (for new JSON requests) or to die() on the old $output / action. * @param array $cart_message An array of cart messages to be optionally passed. Primarily passed via wpsc_add_to_cart(). * * @since 3.8.11 * @return mixed Returns an array of output data, alternatively */ function _wpsc_ajax_get_cart($die = true, $cart_messages = array()) { $return = array(); if (defined('DOING_AJAX') && DOING_AJAX) { ob_start(); include_once wpsc_get_template_file_path('wpsc-cart_widget.php'); $output = ob_get_contents(); ob_end_clean(); $output = str_replace(array('\\n', '\\r'), '', $output); $return['widget_output'] = $output; $return['core_images_url'] = WPSC_CORE_IMAGES_URL; if (1 == get_option('show_sliding_cart') || empty($cart_messages)) { if (wpsc_cart_item_count()) { $_SESSION['slider_state'] = 1; $return['sliding_cart_state'] = 'show'; } else { $_SESSION['slider_state'] = 0; $return['sliding_cart_state'] = 'hide'; } } $action_output = ''; if (has_action('wpsc_alternate_cart_html') && empty($_REQUEST['_wpsc_compat_ajax'])) { //Deprecated action. Do not use. We now have a custom JS event called 'wpsc_fancy_notification'. There is access to the complete $json_response object. ob_start(); echo _wpsc_get_alternate_html($cart_messages); $action_output = ob_get_contents(); $output = ''; ob_end_clean(); } if (!empty($action_output)) { _wpsc_doing_it_wrong('wpsc_alternate_cart_html', __('As of WPeC 3.8.11, it is improper to hook into "wpsc_alternate_cart_html" to output javascript. We now have a custom javascript event called "wpsc_fancy_notification" you can hook into.', 'wpsc'), '3.8.11'); $return['wpsc_alternate_cart_html'] = $action_output; } } if ($die) { echo $output . $action_output; die; } else { return $return; } }
echo wpsc_cart_item_count(); ?> </span> <?php _e('items', 'themeva'); ?> </a> </span> <span class="shop-cart-icon"> <a target="_parent" href="<?php echo get_option('shopping_cart_url'); ?> "></a> </span> <div class="shopping-cart-wrapper widget_wp_shopping_cart shop-cart-contents"> <?php include wpsc_get_template_file_path('wpsc-cart_widget.php'); ?> </div> </li> <?php } if (of_get_option('enable_droppanel') == 'enable') { ?> <li class="toppaneltrigger"> <a class="toggle" href="#"><i class="fa fa-lg fa-chevron-down"></i></a> </li> <?php } ?> </ul> </div> <!-- / tab-wrap -->