Esempio n. 1
0
/**
 * Returns current product category ID or default category ID if one is set.  If one is not set and there is no current category, returns empty string
 * @return mixed
 */
function wpsc_get_current_category_id()
{
    global $wp_query;
    $category_id = '';
    if (isset($wp_query) && isset($wp_query->query_vars['taxonomy']) && 'wpsc_product_category' == $wp_query->query_vars['taxonomy'] || is_numeric(get_option('wpsc_default_category'))) {
        $category_id = isset($wp_query->query_vars['term']) && is_string($wp_query->query_vars['term']) ? wpsc_get_category_id($wp_query->query_vars['term'], 'slug') : get_option('wpsc_default_category');
    }
    return $category_id;
}
Esempio n. 2
0
/**
 * wpsc_user_enqueues products function,
 * enqueue all javascript and CSS for wp ecommerce
 */
function wpsc_enqueue_user_script_and_css()
{
    global $wp_styles, $wpsc_theme_url, $wp_query;
    /**
     * added by xiligroup.dev to be compatible with touchshop
     */
    if (has_filter('wpsc_enqueue_user_script_and_css') && apply_filters('wpsc_mobile_scripts_css_filters', false)) {
        do_action('wpsc_enqueue_user_script_and_css');
    } else {
        /**
         * end of added by xiligroup.dev to be compatible with touchshop
         */
        $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
        $category_id = '';
        if (isset($wp_query) && isset($wp_query->query_vars['taxonomy']) && 'wpsc_product_category' == $wp_query->query_vars['taxonomy'] || is_numeric(get_option('wpsc_default_category'))) {
            if (isset($wp_query->query_vars['term']) && is_string($wp_query->query_vars['term'])) {
                $category_id = wpsc_get_category_id($wp_query->query_vars['term'], 'slug');
            } else {
                $category_id = get_option('wpsc_default_category');
            }
        }
        $siteurl = get_option('siteurl');
        $remote_protocol = is_ssl() ? 'https://' : 'http://';
        if (get_option('wpsc_share_this') == 1) {
            wp_enqueue_script('sharethis', $remote_protocol . 'w.sharethis.com/button/buttons.js', array(), false, true);
        }
        wp_enqueue_script('jQuery');
        wp_enqueue_script('wp-e-commerce', WPSC_CORE_JS_URL . '/wp-e-commerce.js', array('jquery'), $version_identifier);
        wp_enqueue_script('infieldlabel', WPSC_CORE_JS_URL . '/jquery.infieldlabel.min.js', array('jquery'), $version_identifier);
        wp_enqueue_script('wp-e-commerce-ajax-legacy', WPSC_CORE_JS_URL . '/ajax.js', false, $version_identifier);
        wp_enqueue_script('wp-e-commerce-dynamic', site_url('/index.php?wpsc_user_dynamic_js=true'), false, $version_identifier);
        wp_localize_script('wp-e-commerce-dynamic', 'wpsc_ajax', array('ajaxurl' => admin_url('admin-ajax.php')));
        wp_enqueue_script('livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3');
        if (get_option('product_ratings') == 1) {
            wp_enqueue_script('jquery-rating', WPSC_CORE_JS_URL . '/jquery.rating.js', array('jquery'), $version_identifier);
        }
        wp_enqueue_script('wp-e-commerce-legacy', WPSC_CORE_JS_URL . '/user.js', array('jquery'), WPSC_VERSION . WPSC_MINOR_VERSION);
        if (get_option('show_thumbnails_thickbox') == 1) {
            $lightbox = get_option('wpsc_lightbox', 'thickbox');
            if ($lightbox == 'thickbox') {
                wp_enqueue_script('wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.js', array('jquery'), 'Instinct_e-commerce');
                wp_enqueue_style('wpsc-thickbox', WPSC_CORE_JS_URL . '/thickbox.css', false, $version_identifier, 'all');
            } elseif ($lightbox == 'colorbox') {
                wp_enqueue_script('colorbox-min', WPSC_CORE_JS_URL . '/jquery.colorbox-min.js', array('jquery'), 'Instinct_e-commerce');
                wp_enqueue_script('wpsc_colorbox', WPSC_CORE_JS_URL . '/wpsc_colorbox.js', array('jquery', 'colorbox-min'), 'Instinct_e-commerce');
                wp_enqueue_style('wpsc-colorbox-css', WPSC_CORE_JS_URL . '/wpsc_colorbox.css', false, $version_identifier, 'all');
            }
        }
        wp_enqueue_style('wpsc-theme-css', wpsc_get_template_file_url('wpsc-' . get_option('wpsc_selected_theme') . '.css'), false, $version_identifier, 'all');
        wp_enqueue_style('wpsc-theme-css-compatibility', WPSC_CORE_THEME_URL . 'compatibility.css', false, $version_identifier, 'all');
        if (get_option('product_ratings') == 1) {
            wp_enqueue_style('wpsc-product-rater', WPSC_CORE_JS_URL . '/product_rater.css', false, $version_identifier, 'all');
        }
        wp_enqueue_style('wp-e-commerce-dynamic', site_url("/index.php?wpsc_user_dynamic_css=true&category={$category_id}"), false, $version_identifier, 'all');
    }
    if (!defined('WPSC_MP3_MODULE_USES_HOOKS') && function_exists('listen_button')) {
        function wpsc_legacy_add_mp3_preview($product_id, &$product_data)
        {
            global $wpdb;
            if (function_exists('listen_button')) {
                $file_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` = %d LIMIT 1", $product_data['file']), ARRAY_A);
                if ($file_data != null) {
                    echo listen_button($file_data['idhash'], $file_data['id']);
                }
            }
        }
        add_action('wpsc_product_before_description', 'wpsc_legacy_add_mp3_preview', 10, 2);
    }
}