示例#1
0
文件: scripts.php 项目: serker72/T3S
/**
 * Register scripts and styles.
 */
function wpmtst_scripts()
{
    $plugin_version = get_option('wpmtst_plugin_version');
    wp_register_script('wpmtst-pager-plugin', WPMTST_URL . 'js/quickpager.jquery.js', array('jquery'), false, true);
    wp_register_script('wpmtst-pager-script', WPMTST_URL . 'js/wpmtst-pager.js', array('wpmtst-pager-plugin'), $plugin_version, true);
    wp_register_style('wpmtst-custom-style', WPMTST_URL . 'css/wpmtst-custom.css');
    wp_register_script('imagesloaded-script', WPMTST_URL . 'js/imagesloaded.pkgd.min.js', array(), false, true);
    wp_register_script('wpmtst-masonry-script', WPMTST_URL . 'js/wpmtst-masonry.js', array('jquery-masonry', 'imagesloaded-script'), $plugin_version, true);
    wp_register_style('wpmtst-masonry-style', WPMTST_URL . 'css/wpmtst-masonry.css', array(), $plugin_version);
    wp_register_style('wpmtst-columns-style', WPMTST_URL . 'css/wpmtst-columns.css', array(), $plugin_version);
    wp_register_script('wpmtst-grid-script', WPMTST_URL . 'js/wpmtst-grid.js', array('jquery'), $plugin_version, true);
    wp_register_style('wpmtst-grid-style', WPMTST_URL . 'css/wpmtst-grid.css', array(), $plugin_version);
    if (wpmtst_using_form_validation_script()) {
        wp_register_script('wpmtst-validation-plugin', WPMTST_URL . 'js/validate/jquery.validate.min.js', array('jquery'), false, true);
        wp_register_script('wpmtst-form-script', WPMTST_URL . 'js/wpmtst-form.js', array('wpmtst-validation-plugin', 'jquery-form'), $plugin_version, true);
        /**
         * Localize jQuery Validate plugin.
         *
         * @since 1.16.0
         */
        $locale = get_locale();
        if ('en_US' != $locale) {
            $lang_parts = explode('_', $locale);
            $lang_file = 'js/validate/localization/messages_' . $lang_parts[0] . '.min.js';
            if (file_exists(WPMTST_DIR . $lang_file)) {
                wp_register_script('wpmtst-validation-lang', WPMTST_URL . $lang_file, array('wpmtst-validation-plugin'), false, true);
            }
        }
    }
}
示例#2
0
 /**
  * Load form validation and add honeypot actions.
  *
  * @since 1.25.0
  *
  * @param array $atts
  */
 private static function after_form($atts = array())
 {
     $form_options = get_option('wpmtst_form_options');
     if (wp_script_is('wpmtst-validation-lang', 'registered')) {
         wp_enqueue_script('wpmtst-validation-lang');
     }
     if (wpmtst_using_form_validation_script()) {
         wp_localize_script('wpmtst-form-script', 'form_ajax_object', array('ajaxUrl' => admin_url('admin-ajax.php'), 'ajaxSubmit' => isset($atts['form_ajax']) && $atts['form_ajax'] ? 1 : 0));
         wp_enqueue_script('wpmtst-form-script');
     }
     if ($form_options['honeypot_before']) {
         add_action('wp_footer', 'wpmtst_honeypot_before_script');
     }
     if ($form_options['honeypot_after']) {
         add_action('wp_footer', 'wpmtst_honeypot_after_script');
     }
 }