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 = '
'; endif; $varation_list = array(); foreach ($variation as $name => $value) : $name = str_replace('tax_', '', $name); if ( taxonomy_exists( 'pa_'.$name )) : $terms = get_terms( 'pa_'.$name, array( 'orderby' => 'slug', 'hide_empty' => '0' ) ); foreach ( $terms as $term ) : if ( $term->slug == $value ) $value = $term->name; endforeach; $name = get_taxonomy( 'pa_'.$name )->labels->name; $name = jigoshop_product::attribute_label('pa_'.$name); endif; if ($flat) : $varation_list[] = $name.': '.$value; else : $varation_list[] = '
'.$name.':
'.$value.'
'; endif; endforeach; if ($flat) : $return .= implode(', ', $varation_list); else : $return .= implode('', $varation_list); endif; if (!$flat) : $return .= '
'; endif; return $return; endif; } // Remove pingbacks/trackbacks from Comments Feed // betterwp.net/wordpress-tips/remove-pingbackstrackbacks-from-comments-feed/ add_filter('request', 'jigoshop_filter_request'); function jigoshop_filter_request($qv) { if (isset($qv['feed']) && !empty($qv['withcomments'])) { add_filter('comment_feed_where', 'jigoshop_comment_feed_where'); } return $qv; } function jigoshop_comment_feed_where($cwhere) { $cwhere .= " AND comment_type != 'jigoshop' "; return $cwhere; } function jigoshop_let_to_num($v) { $l = substr($v, -1); $ret = substr($v, 0, -1); switch(strtoupper($l)){ case 'P': $ret *= 1024; case 'T': $ret *= 1024; case 'G': $ret *= 1024; case 'M': $ret *= 1024; case 'K': $ret *= 1024; break; } return $ret; } function jigowatt_clean( $var ) { return strip_tags(stripslashes(trim($var))); } // Returns a float value function jigoshop_sanitize_num( $var ) { return strip_tags(stripslashes(floatval(preg_replace("/^[^0-9\.]/","",$var)))); } //Author: Sergey Biryukov // Plugin URI: http://wordpress.org/extend/plugins/allow-cyrillic-usernames/ function jigoshop_sanitize_user($username, $raw_username, $strict) { $username = wp_strip_all_tags( $raw_username ); $username = remove_accents( $username ); $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities if ( $strict ) $username = preg_replace( '|[^a-z?-?0-9 _.\-@]|iu', '', $username ); $username = trim( $username ); $username = preg_replace( '|\s+|', ' ', $username ); return $username; } add_filter('sanitize_user', 'jigoshop_sanitize_user', 10, 3); global $jigoshop_body_classes; function jigoshop_page_body_classes() { global $jigoshop_body_classes; $jigoshop_body_classes = (array) $jigoshop_body_classes; if ( is_order_tracker() ) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-tracker' ) ); if ( is_checkout() ) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-checkout' ) ); if ( is_cart() ) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-cart' ) ); if ( is_page(jigoshop_get_page_id('thanks'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-thanks' ) ); if ( is_page(jigoshop_get_page_id('pay'))) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-pay' ) ); if ( is_account() ) jigoshop_add_body_class( array( 'jigoshop', 'jigoshop-myaccount' ) ); } add_action('wp_head', 'jigoshop_page_body_classes'); function jigoshop_add_body_class( $class = array() ) { global $jigoshop_body_classes; $jigoshop_body_classes = (array) $jigoshop_body_classes; $jigoshop_body_classes = array_unique( array_merge( $class, $jigoshop_body_classes )); } function jigoshop_body_class($classes) { global $jigoshop_body_classes; $jigoshop_body_classes = (array) $jigoshop_body_classes; $classes = array_unique( array_merge( $classes, $jigoshop_body_classes )); return $classes; } add_filter('body_class','jigoshop_body_class'); function jigoshop_hide_out_of_stock_product( $item_id ) { update_post_meta( $item_id, 'visibility', 'hidden' ); } if ( get_option( 'jigoshop_hide_no_stock_product' ) == 'yes' ) : add_action( 'jigoshop_no_stock_notification', 'jigoshop_hide_out_of_stock_product' ); endif; //### Extra Review Field in comments ######################################################### function jigoshop_add_comment_rating($comment_id) { if ( isset($_POST['rating']) ) : if (!$_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0) $_POST['rating'] = 5; add_comment_meta( $comment_id, 'rating', $_POST['rating'], true ); endif; } add_action( 'comment_post', 'jigoshop_add_comment_rating', 1 ); function jigoshop_check_comment_rating($comment_data) { // If posting a comment (not trackback etc) and not logged in if ( isset($_POST['rating']) && !jigoshop::verify_nonce('comment_rating') ) wp_die( __('You have taken too long. Please go back and refresh the page.', 'jigoshop') ); elseif ( isset($_POST['rating']) && empty($_POST['rating']) && $comment_data['comment_type']== '' ) { wp_die( __('Please rate the product.',"jigowatt") ); exit; } return $comment_data; } add_filter('preprocess_comment', 'jigoshop_check_comment_rating', 0); //### Comments ######################################################### function jigoshop_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; global $post; ?>
  • id="li-comment-">
    comment_ID, 'rating', true ) ): ?>
    comment_approved == '0') : ?>

    :

    parse( $file ); if (isset($import_data['posts'])) : $posts = $import_data['posts']; if ($posts && sizeof($posts)>0) foreach ($posts as $post) : if ($post['post_type']=='product') : if ($post['terms'] && sizeof($post['terms'])>0) : foreach ($post['terms'] as $term) : $domain = $term['domain']; if (strstr($domain, 'pa_')) : // Make sure it exists! if (!taxonomy_exists( $domain )) : $nicename = sanitize_title(str_replace('pa_', '', $domain)); $exists_in_db = $wpdb->get_var("SELECT attribute_id FROM ".$wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_name = '".$nicename."';"); // Create the taxonomy if (!$exists_in_db) : $wpdb->insert( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_type' => 'select' ), array( '%s', '%s' ) ); endif; // Register the taxonomy now so that the import works! register_taxonomy( $domain, array('product'), array( 'hierarchical' => true, 'labels' => array( 'name' => $nicename, 'singular_name' => $nicename, 'search_items' => __( 'Search ', 'jigoshop') . $nicename, 'all_items' => __( 'All ', 'jigoshop') . $nicename, 'parent_item' => __( 'Parent ', 'jigoshop') . $nicename, 'parent_item_colon' => __( 'Parent ', 'jigoshop') . $nicename . ':', 'edit_item' => __( 'Edit ', 'jigoshop') . $nicename, 'update_item' => __( 'Update ', 'jigoshop') . $nicename, 'add_new_item' => __( 'Add New ', 'jigoshop') . $nicename, 'new_item_name' => __( 'New ', 'jigoshop') . $nicename ), 'show_ui' => false, 'query_var' => true, 'rewrite' => array( 'slug' => sanitize_title($nicename), 'with_front' => false, 'hierarchical' => true ), ) ); update_option('jigowatt_update_rewrite_rules', '1'); endif; endif; endforeach; endif; endif; endforeach; endif; } add_action('import_start', 'jigoshop_import_start'); /** * Support for Jigoshop being the very first plugin loaded by WordPress * * Will only happen once a user has 'activated' a (any) plugin. * * Ensures our sessions are run first. * Runs last on the 'activated_plugin' hook due to a low priority. * **/ function jigoshop_plugin_loads_first() { // ensure path to this file is via main wp plugin path $wp_path_to_this_file = preg_replace( '/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__ ); $this_plugin = plugin_basename( trim( $wp_path_to_this_file )); $active_plugins = get_option( 'active_plugins' ); $this_plugin_key = array_search( $this_plugin, $active_plugins ); if ( $this_plugin_key ) { // if it's 0 it's the first plugin already, no need to continue array_splice( $active_plugins, $this_plugin_key, 1 ); array_unshift( $active_plugins, $this_plugin ); update_option( 'active_plugins', $active_plugins ); } } add_action( 'activated_plugin', 'jigoshop_plugin_loads_first', 999 );