Example #1
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since 1.0
 * @global       $post
 *
 * @param string $hook Page hook
 *
 * @return void
 */
function give_load_admin_scripts($hook)
{
    global $wp_version, $post, $post_type;
    //Directories of assets
    $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/';
    $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
    $css_dir = GIVE_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    //Global Admin:
    wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css');
    wp_enqueue_style('give-admin-bar-notification');
    //Give Admin Only:
    if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
        return;
    }
    //CSS
    wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css');
    wp_enqueue_style('jquery-ui-css');
    wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION);
    wp_enqueue_style('give-admin');
    wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION);
    wp_enqueue_style('jquery-chosen');
    wp_enqueue_style('thickbox');
    //JS
    wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-admin-scripts');
    wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js');
    wp_enqueue_script('jquery-flot');
    wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-qtip');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('thickbox');
    //Forms CPT Script
    if ($post_type === 'give_forms') {
        wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-forms-scripts');
    }
    //Localize strings & variables for JS
    wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'quick_edit_warning' => __('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'give'), 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your donor', 'give'), 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => __('You must have at least one price', 'give'), 'one_file_min' => __('You must have at least one file', 'give'), 'one_field_min' => __('You must have at least one field', 'give'), 'one_option' => sprintf(__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => __('Item price must be numeric', 'give'), 'numeric_quantity' => __('Quantity must be numeric', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => __('Remove', 'give'), 'type_to_search' => sprintf(__('Type to search %s', 'give'), give_get_forms_label_plural())));
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        //call for new media manager
        wp_enqueue_media();
    }
}
Example #2
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since 1.0
 *
 * @global       $post
 * @global       $give_options
 *
 * @param string $hook Page hook
 *
 * @return void
 */
function give_load_admin_scripts($hook)
{
    global $wp_version, $post, $post_type, $give_options;
    //Directories of assets
    $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/';
    $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
    $css_dir = GIVE_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    //Global Admin:
    wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css');
    wp_enqueue_style('give-admin-bar-notification');
    //Give Admin Only:
    if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
        return;
    }
    //CSS
    wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css');
    wp_enqueue_style('jquery-ui-css');
    wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION);
    wp_enqueue_style('give-admin');
    wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION);
    wp_enqueue_style('jquery-chosen');
    wp_enqueue_style('thickbox');
    //JS
    wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_register_script('give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-accounting');
    wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-admin-scripts');
    wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js');
    wp_enqueue_script('jquery-flot');
    wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-qtip');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('thickbox');
    // Forms CPT Script.
    if ($post_type === 'give_forms') {
        wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-forms-scripts');
    }
    //Settings Scripts
    if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
        wp_register_script('give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-settings-scripts');
    }
    // Price Separators.
    $thousand_separator = give_get_price_thousand_separator();
    $decimal_separator = give_get_price_decimal_separator();
    //Localize strings & variables for JS
    wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'thousands_separator' => $thousand_separator, 'decimal_separator' => $decimal_separator, 'quick_edit_warning' => esc_html__('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => esc_html__('You must have at least one price.', 'give'), 'one_file_min' => esc_html__('You must have at least one file.', 'give'), 'one_field_min' => esc_html__('You must have at least one field.', 'give'), 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => esc_html__('Remove', 'give'), 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), 'price_format_guide' => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator)));
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        //call for new media manager
        wp_enqueue_media();
    }
}