Jigoshop->Settings->Images * @since 0.9.9 **/ function jigoshop_set_image_sizes(){ add_image_size( 'admin_product_list', 32, 32, 'true' ); add_image_size( 'shop_tiny', get_option('jigoshop_shop_tiny_w'), get_option('jigoshop_shop_tiny_h'), 'true' ); add_image_size( 'shop_thumbnail', get_option('jigoshop_shop_thumbnail_w'), get_option('jigoshop_shop_thumbnail_h'), 'true' ); add_image_size( 'shop_small', get_option('jigoshop_shop_small_w'), get_option('jigoshop_shop_small_h'), 'true' ); add_image_size( 'shop_large', get_option('jigoshop_shop_large_w'), get_option('jigoshop_shop_large_h'), 'true' ); } /** * Get Jigoshop Product Image Size based on Admin->Jigoshop->Settings->Images * @param string $size - one of the 4 defined Jigoshop image sizes * @return array - an array containing the width and height of the required size * @since 0.9.9 **/ function jigoshop_get_image_size( $size ) { if ( is_array( $size ) ) return $size; switch ( $size ) : case 'admin_product_list': $image_size = array( 32, 32 ); break; case 'shop_tiny': $image_size = array( get_option('jigoshop_shop_tiny_w'), get_option('jigoshop_shop_tiny_h') ); break; case 'shop_thumbnail': $image_size = array( get_option('jigoshop_shop_thumbnail_w'), get_option('jigoshop_shop_thumbnail_h') ); break; case 'shop_small': $image_size = array( get_option('jigoshop_shop_small_w'), get_option('jigoshop_shop_small_h') ); break; case 'shop_large': $image_size = array( get_option('jigoshop_shop_large_w'), get_option('jigoshop_shop_large_h') ); break; default: $image_size = array( get_option('jigoshop_shop_small_w'), get_option('jigoshop_shop_small_h') ); break; endswitch; return $image_size; } function jigoshop_init() { /* ensure nothing is output to the browser prior to this (other than headers) */ ob_start(); jigoshop_session::instance()->test = 'val'; $array = array(0 => "3.15"); foreach ($array as $a) : $an = explode(':', $a); endforeach; jigoshop_post_type(); /* register taxonomies */ // add Singletons here so that the taxonomies are loaded before calling them. $jigoshop = jigoshop::instance(); $jigoshop_customer = jigoshop_customer::instance(); // Customer class, sorts session data such as location $jigoshop_shipping = jigoshop_shipping::instance(); // Shipping class. loads shipping methods $jigoshop_payment_gateways = jigoshop_payment_gateways::instance();// Payment gateways class. loads payment methods $jigoshop_cart = jigoshop_cart::instance(); // Cart class, stores the cart contents // if ( ! is_admin() ) $jigoshop_query = new jigoshop_catalog_query(); if ( ! is_admin() ) $jigoshop_query = jigoshop_catalog_query::instance(); // Image sizes jigoshop_set_image_sizes(); // Include template functions here so they are pluggable by themes include_once( 'jigoshop_template_functions.php' ); add_role('customer', 'Customer', array( 'read' => true, 'edit_posts' => false, 'delete_posts' => false )); $css = file_exists(get_stylesheet_directory() . '/jigoshop/style.css') ? get_stylesheet_directory_uri() . '/jigoshop/style.css' : jigoshop::assets_url() . '/assets/css/frontend.css'; if (JIGOSHOP_USE_CSS) wp_register_style('jigoshop_frontend_styles', $css ); if ( !is_admin()) : wp_register_style( 'jqueryui_styles', jigoshop::assets_url() . '/assets/css/ui.css' ); wp_enqueue_style('jigoshop_frontend_styles'); wp_enqueue_style('jqueryui_styles'); if( JIGOSHOP_LOAD_FANCYBOX ) { wp_register_style( 'jigoshop_fancybox_styles', jigoshop::assets_url() . '/assets/css/fancybox.css' ); wp_enqueue_style('jigoshop_fancybox_styles'); } endif; } add_action('init', 'jigoshop_init', 0); add_action( 'admin_enqueue_scripts', 'jigoshop_admin_styles' ); function jigoshop_admin_styles() { wp_register_style('jigoshop_admin_styles', jigoshop::assets_url() . '/assets/css/admin.css'); wp_enqueue_style('jigoshop_admin_styles'); wp_register_style('jquery-ui-jigoshop-styles', jigoshop::assets_url() . '/assets/css/jquery-ui-1.8.16.jigoshop.css'); wp_enqueue_style('jquery-ui-jigoshop-styles'); } function jigoshop_admin_scripts() { wp_register_script('jquery-ui-datepicker', jigoshop::assets_url() . '/assets/js/jquery-ui-datepicker-1.8.16.min.js', array( 'jquery' ), '1.8.16', true ); wp_enqueue_script('jquery-ui-datepicker'); wp_register_script( 'jigoshop_backend', jigoshop::assets_url() . '/assets/js/jigoshop_backend.js', array('jquery'), '1.0' ); wp_enqueue_script('jigoshop_backend'); } add_action('admin_print_scripts', 'jigoshop_admin_scripts'); function jigoshop_frontend_scripts() { if( JIGOSHOP_LOAD_FANCYBOX ) { wp_register_script( 'fancybox', jigoshop::assets_url() . '/assets/js/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0' ); wp_enqueue_script('fancybox'); } wp_register_script( 'jigoshop_frontend', jigoshop::assets_url() . '/assets/js/jigoshop_frontend.js', array('jquery'), '1.0' ); wp_register_script( 'jigoshop_script', jigoshop::assets_url() . '/assets/js/script.js', array('jquery'), '1.0' ); wp_register_script( 'jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js', array('jquery'), '1.0' ); wp_enqueue_script('jqueryui'); wp_enqueue_script('jigoshop_frontend'); wp_enqueue_script('jigoshop_script'); /* Script.js variables */ $params = array( 'currency_symbol' => get_jigoshop_currency_symbol(), 'countries' => json_encode(jigoshop_countries::$states), 'select_state_text' => __('Select a state…', 'jigoshop'), 'state_text' => __('state', 'jigoshop'), 'assets_url' => jigoshop::assets_url(), 'ajax_url' => (!is_ssl()) ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php'), 'get_variation_nonce' => wp_create_nonce("get-variation"), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'billing_state' => jigoshop_customer::get_state(), 'shipping_state' => jigoshop_customer::get_shipping_state(), 'option_guest_checkout' => get_option('jigoshop_enable_guest_checkout'), 'checkout_url' => admin_url('admin-ajax.php?action=jigoshop-checkout'), 'load_fancybox' => JIGOSHOP_LOAD_FANCYBOX ); if (isset( jigoshop_session::instance()->min_price )) : $params['min_price'] = $_GET['min_price']; endif; if (isset( jigoshop_session::instance()->max_price )) : $params['max_price'] = $_GET['max_price']; endif; if ( is_page(jigoshop_get_page_id('checkout')) || is_page(jigoshop_get_page_id('pay')) ) : $params['is_checkout'] = 1; else : $params['is_checkout'] = 0; endif; $params = apply_filters('jigoshop_params', $params); wp_localize_script( 'jigoshop_script', 'params', $params ); } add_action('template_redirect', 'jigoshop_frontend_scripts'); /* jigoshop_demo_store Adds a demo store banner to the site */ function jigoshop_demo_store() { if (get_option('jigoshop_demo_store')=='yes') : echo '
'.__('This is a demo store for testing purposes — no orders shall be fulfilled.', 'jigoshop').'
'; endif; } add_action( 'wp_footer', 'jigoshop_demo_store' ); /* jigoshop_sharethis Adds social sharing code to footer */ function jigoshop_sharethis() { if (is_single() && get_option('jigoshop_sharethis')) : if (is_ssl()) : $sharethis = 'https://ws.sharethis.com/button/buttons.js'; else : $sharethis = 'http://w.sharethis.com/button/buttons.js'; endif; echo ''; endif; } add_action( 'wp_footer', 'jigoshop_sharethis' ); /** * Evaluates to true only on the Shop page, not Product categories and tags * Note:is used to replace is_page( jigoshop_get_page_id( 'shop' ) ) * * @return bool * @since 0.9.9 */ function is_shop() { return is_post_type_archive( 'product' ) | is_page( jigoshop_get_page_id('shop') ); } /** * Evaluates to true only on the Category Pages * * @return bool * @since 0.9.9 */ function is_product_category() { return is_tax( 'product_cat' ); } /** * Evaluates to true only on the Tag Pages * * @return bool * @since 0.9.9 */ function is_product_tag() { return is_tax( 'product_tag' ); } /** * Evaluates to true only on the Single Product Page * * @return bool * @since 0.9.9 */ function is_product() { return is_singular( array('product') ); } /** * Evaluates to true only on Shop, Product Category, and Product Tag pages * * @return bool * @since 0.9.9 */ function is_product_list() { $is_list = false; $is_list |= is_shop(); $is_list |= is_product_tag(); $is_list |= is_product_category(); return $is_list; } /** * Evaluates to true for all Jigoshop pages * * @return bool * @since 0.9.9 */ function is_jigoshop() { $is_jigo = false; $is_jigo |= is_content_wrapped(); $is_jigo |= is_account(); $is_jigo |= is_cart(); $is_jigo |= is_checkout(); $is_jigo |= is_order_tracker(); return $is_jigo; } /** * Evaluates to true only on the Shop, Category, Tag and Single Product Pages * * @return bool * @since 0.9.9.1 */ function is_content_wrapped() { $is_wrapped = false; $is_wrapped |= is_product_list(); $is_wrapped |= is_product(); return $is_wrapped; } /** * Jigoshop page IDs * * returns -1 if no page is found **/ if (!function_exists('jigoshop_get_page_id')) { function jigoshop_get_page_id( $page ) { $page = apply_filters('jigoshop_get_' . $page . '_page_id', get_option('jigoshop_' . $page . '_page_id')); return ($page) ? $page : -1; } } /** * Evaluates to true only on the Order Tracking page * * @return bool * @since 0.9.9.1 */ function is_order_tracker() { return is_page( jigoshop_get_page_id('track_order')); } /** * Evaluates to true only on the Cart page * * @return bool * @since 0.9.8 */ function is_cart() { return is_page( jigoshop_get_page_id('cart')); } /** * Evaluates to true only on the Checkout or Pay pages * * @return bool * @since 0.9.8 */ function is_checkout() { return is_page( jigoshop_get_page_id('checkout')) | is_page( jigoshop_get_page_id('pay')); } /** * Evaluates to true only on the main Account or any sub-account pages * * @return bool * @since 0.9.9.1 */ function is_account() { $is_account = false; $is_account |= is_page( jigoshop_get_page_id('myaccount') ); $is_account |= is_page( jigoshop_get_page_id('edit_address') ); $is_account |= is_page( jigoshop_get_page_id('change_password') ); $is_account |= is_page( jigoshop_get_page_id('view_order') ); return $is_account; } if (!function_exists('is_ajax')) { function is_ajax() { if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) return true; return false; } } function jigoshop_force_ssl() { if (is_checkout() && !is_ssl()) : wp_safe_redirect( str_replace('http:', 'https:', get_permalink(jigoshop_get_page_id('checkout'))), 301 ); exit; endif; } if (!is_admin() && get_option('jigoshop_force_ssl_checkout')=='yes') add_action( 'wp', 'jigoshop_force_ssl'); function jigoshop_force_ssl_images( $content ) { if (is_ssl()) : if (is_array($content)) : $content = array_map('jigoshop_force_ssl_images', $content); else : $content = str_replace('http:', 'https:', $content); endif; endif; return $content; } add_filter('post_thumbnail_html', 'jigoshop_force_ssl_images'); add_filter('widget_text', 'jigoshop_force_ssl_images'); add_filter('wp_get_attachment_url', 'jigoshop_force_ssl_images'); add_filter('wp_get_attachment_image_attributes', 'jigoshop_force_ssl_images'); add_filter('wp_get_attachment_url', 'jigoshop_force_ssl_images'); function jigoshop_force_ssl_urls( $url ) { if (is_ssl()) : $url = str_replace('http:', 'https:', $url); endif; return $url; } add_filter('option_siteurl', 'jigoshop_force_ssl_urls'); add_filter('option_home', 'jigoshop_force_ssl_urls'); add_filter('option_url', 'jigoshop_force_ssl_urls'); add_filter('option_wpurl', 'jigoshop_force_ssl_urls'); add_filter('option_stylesheet_url', 'jigoshop_force_ssl_urls'); add_filter('option_template_url', 'jigoshop_force_ssl_urls'); add_filter('script_loader_src', 'jigoshop_force_ssl_urls'); add_filter('style_loader_src', 'jigoshop_force_ssl_urls'); // http://www.xe.com/symbols.php function get_jigoshop_currency_symbol() { $currency = get_option('jigoshop_currency'); $currency_symbol = ''; switch ($currency) : case 'AED' : $currency_symbol = 'د.إ'; break; case 'AUD' : $currency_symbol = '$'; break; case 'BRL' : $currency_symbol = 'R$'; break; case 'CAD' : $currency_symbol = '$'; break; case 'CHF' : $currency_symbol = 'SFr.'; break; case 'CNY' : $currency_symbol = '¥'; break; case 'CZK' : $currency_symbol = 'Kč'; break; case 'DKK' : $currency_symbol = 'kr'; break; case 'EUR' : $currency_symbol = '€'; break; case 'GBP' : $currency_symbol = '£'; break; case 'HKD' : $currency_symbol = '$'; break; case 'HRK' : $currency_symbol = 'kn'; break; case 'HUF' : $currency_symbol = 'Ft'; break; case 'IDR' : $currency_symbol = 'Rp'; break; case 'ILS' : $currency_symbol = '₪'; break; case 'INR' : $currency_symbol = '₨'; break; case 'JPY' : $currency_symbol = '¥'; break; case 'MXN' : $currency_symbol = '$'; break; case 'MYR' : $currency_symbol = 'RM'; break; case 'NGN' : $currency_symbol = '₦'; break; case 'NOK' : $currency_symbol = 'kr'; break; case 'NZD' : $currency_symbol = '$'; break; case 'PHP' : $currency_symbol = '₱'; break; case 'PLN' : $currency_symbol = 'zł'; break; case 'RON' : $currency_symbol = 'lei'; break; case 'RUB' : $currency_symbol = 'руб'; break; case 'SEK' : $currency_symbol = 'kr'; break; case 'SGD' : $currency_symbol = '$'; break; case 'THB' : $currency_symbol = '฿'; break; case 'TRY' : $currency_symbol = '₤'; break; case 'TWD' : $currency_symbol = 'NT$'; break; case 'USD' : $currency_symbol = '$'; break; case 'ZAR' : $currency_symbol = 'R'; break; default : $currency_symbol = '£'; break; endswitch; return apply_filters('jigoshop_currency_symbol', $currency_symbol, $currency); } function jigoshop_price( $price, $args = array() ) { extract(shortcode_atts(array( 'ex_tax_label' => '0', 'with_currency' => true ), $args)); $return = ''; $price = number_format( (double) $price, (int) get_option('jigoshop_price_num_decimals'), get_option('jigoshop_price_decimal_sep'), get_option('jigoshop_price_thousand_sep') ); $return = $price; if ($with_currency) : $currency_pos = get_option('jigoshop_currency_pos'); $currency_symbol = get_jigoshop_currency_symbol(); $currency_code = get_option('jigoshop_currency'); switch ($currency_pos) : case 'left' : $return = $currency_symbol . $price; break; case 'left_space' : $return = $currency_symbol . ' ' . $price; break; case 'right' : $return = $price . $currency_symbol; break; case 'right_space' : $return = $price . ' ' . $currency_symbol; break; case 'left_code' : $return = $currency_code . $price; break; case 'left_code_space' : $return = $currency_code . ' ' . $price; break; case 'right_code' : $return = $price . $currency_code; break; case 'right_code_space' : $return = $price . ' ' . $currency_code; break; case 'code_symbol' : $return = $currency_code . $price . $currency_symbol; break; case 'code_symbol_space' : $return = $currency_code . ' ' . $price . ' ' . $currency_symbol; break; case 'symbol_code' : $return = $currency_symbol . $price . $currency_code; break; case 'symbol_code_space' : $return = $currency_code . ' ' . $price . ' ' . $currency_code; break; endswitch; // only show (ex. tax) if we are going to show the price with currency as well. Otherwise we just want the formatted price if ($ex_tax_label && get_option('jigoshop_calc_taxes')=='yes') $return .= __(' (ex. tax)', 'jigoshop'); endif; return $return; } /** Show variation info if set */ function jigoshop_get_formatted_variation( $variation = '', $flat = false ) { if ($variation && is_array($variation)) : $return = ''; if (!$flat) : $return = '
: