Пример #1
0
function cimy_uef_init_javascripts($rule_name)
{
    global $cuef_plugin_dir, $cuef_css_webpath, $cuef_js_webpath;
    $options = cimy_get_options();
    if ($options['image_fields'][$rule_name] > 0) {
        wp_enqueue_script('imgareaselect', "", array("jquery"));
        wp_enqueue_style('imgareaselect');
        wp_register_script('cimy_uef_img_selection', $cuef_js_webpath . "/img_selection.js", array(), false);
        wp_enqueue_script('cimy_uef_img_selection');
    }
    if ($options['file_fields'][$rule_name] > 0) {
        cimy_uef_init_upload_js();
    }
    if ($rule_name == "show_in_profile") {
        if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
            wp_register_style("cimy_uef_tinymce", $cuef_css_webpath . "/cimy_uef_tinymce.css", false, false);
            wp_enqueue_style('cimy_uef_tinymce');
        }
    }
    if ($rule_name == "show_in_reg") {
        // This is needed for registration form on WordPress >= 3.3
        if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
            wp_enqueue_script('jquery');
            wp_enqueue_script('utils');
        }
        if ($options['password_meter']) {
            wp_register_script("cimy_uef_password_strength_meter", $cuef_js_webpath . "/password_strength_meter.js", array("password-strength-meter"), false);
            wp_enqueue_script('cimy_uef_password_strength_meter');
        }
        // damn WordPress bugs
        if (is_multisite()) {
            wp_print_scripts();
        }
    }
}
function cimy_uef_init_javascripts($rule_name)
{
    global $cuef_plugin_dir, $cuef_css_webpath, $cuef_js_webpath;
    $options = cimy_get_options();
    if ($options['image_fields'][$rule_name] > 0) {
        wp_enqueue_style('imgareaselect');
        wp_register_script('cimy_uef_img_selection', $cuef_js_webpath . "/img_selection.js", array("imgareaselect", "jquery"), false);
        wp_enqueue_script('cimy_uef_img_selection');
    }
    if ($options['file_fields'][$rule_name] > 0) {
        cimy_uef_init_upload_js();
    }
    if ($options['date_fields'][$rule_name] > 0) {
        wp_register_script("cimy_uef_datepicker", $cuef_js_webpath . "/datepicker.js", array("jquery-ui-core", "jquery-ui-datepicker"), false, true);
        wp_enqueue_script('cimy_uef_datepicker');
        // Themes list: http://blog.jqueryui.com/
        wp_register_style('jquery-ui-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css', array());
        wp_enqueue_style('jquery-ui-style');
        // Fix for the following bug: http://forum.jquery.com/topic/jquery-ui-datepicker-initial-display-none-fixup
        wp_register_style('cimy_uef_datepicker', $cuef_css_webpath . '/cimy_uef_datepicker.css', array());
        wp_enqueue_style('cimy_uef_datepicker');
        // Pass the array to the enqueued JS
        wp_localize_script('cimy_uef_datepicker', 'datepickerL10n', cimy_uef_date_picker_l10n());
    }
    if ($rule_name == "show_in_profile") {
        if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
            wp_register_style("cimy_uef_tinymce", $cuef_css_webpath . "/cimy_uef_tinymce.css", array(), false);
            wp_enqueue_style('cimy_uef_tinymce');
        }
    }
    if ($rule_name == "show_in_reg") {
        // This is needed for registration form on WordPress >= 3.3
        if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
            wp_enqueue_script('jquery');
            wp_enqueue_script('utils');
        }
        if ($options['password_meter']) {
            wp_register_script("cimy_uef_password_strength_meter", $cuef_js_webpath . "/password_strength_meter.js", array("password-strength-meter"), false);
            wp_enqueue_script('cimy_uef_password_strength_meter');
        }
        // damn WordPress bugs
        if (is_multisite()) {
            wp_print_scripts();
        }
    }
}