Esempio n. 1
0
function shopp_default_script_settings()
{
    $base = array();
    $settings = Shopp::currency_format();
    if (!empty($settings)) {
        $currency = array('cp' => $settings['cpos'], 'c' => $settings['currency'], 'p' => (int) $settings['precision'], 't' => $settings['thousands'], 'd' => $settings['decimals']);
        if (isset($settings['grouping'])) {
            $currency['g'] = is_array($settings['grouping']) ? join(',', $settings['grouping']) : $settings['grouping'];
        }
    }
    if (!is_admin()) {
        $base = array('nocache' => is_shopp_page('account'));
    }
    // Validation alerts
    shopp_localize_script('catalog', '$cv', array('field' => __('Your %s is required.', 'Shopp'), 'email' => __('The e-mail address you provided does not appear to be a valid address.', 'Shopp'), 'minlen' => __('The %s you entered is too short. It must be at least %d characters long.', 'Shopp'), 'pwdmm' => __('The passwords you entered do not match. They must match in order to confirm you are correctly entering the password you want to use.', 'Shopp'), 'chkbox' => __('%s must be checked before you can proceed.', 'Shopp')));
    // Address Helper
    shopp_localize_script('address', '$shopp_address', array('country_no_postal_codes' => Lookup::country_no_postal_codes()));
    // Checkout page settings & localization
    shopp_localize_script('checkout', '$co', array('ajaxurl' => admin_url('admin-ajax.php'), 'loginname' => Shopp::__('You did not enter a login.'), 'loginpwd' => Shopp::__('You did not enter a password to login with.'), 'badpan' => Shopp::__('Not a valid card number.'), 'submitting' => Shopp::__('Submitting…'), 'error' => Shopp::__('An error occurred while submitting your order. Please try submitting your order again.'), 'timeout' => (int) SHOPP_SUBMIT_TIMEOUT));
    // Validation alerts
    shopp_localize_script('cart', '$ct', array('items' => __('Items', 'Shopp'), 'total' => __('Total', 'Shopp')));
    // Calendar localization
    shopp_localize_script('calendar', '$cal', array('jan' => __('January', 'Shopp'), 'feb' => __('February', 'Shopp'), 'mar' => __('March', 'Shopp'), 'apr' => __('April', 'Shopp'), 'may' => __('May', 'Shopp'), 'jun' => __('June', 'Shopp'), 'jul' => __('July', 'Shopp'), 'aug' => __('August', 'Shopp'), 'sep' => __('September', 'Shopp'), 'oct' => __('October', 'Shopp'), 'nov' => __('November', 'Shopp'), 'dec' => __('December', 'Shopp'), 'sun' => __('Sun', 'Shopp'), 'mon' => __('Mon', 'Shopp'), 'tue' => __('Tue', 'Shopp'), 'wed' => __('Wed', 'Shopp'), 'thu' => __('Thu', 'Shopp'), 'fri' => __('Fri', 'Shopp'), 'sat' => __('Sat', 'Shopp')));
    // Product editor: unsaved changes warning
    shopp_localize_script('product-editor', '$msg', array('confirm' => __('The changes you made will be lost if you navigate away from this page.', 'Shopp')));
    // Order editor
    shopp_localize_script('orders', '$l10n', array('total' => Shopp::__('Total'), 'newc' => Shopp::__('New Customer Contact')));
    $defaults = apply_filters('shopp_js_settings', array_merge($currency, $base));
    shopp_localize_script('shopp', '$s', $defaults);
}