php - Wordpress 为前端主题 functions.php 包含 jQuery UI Checkboxradio

标签 php jquery wordpress

jQuery UI 和 jQuery 主题未加载时我遇到了一些问题。

我使用的是最新的 Wordpress 4.6。 在我的主题文件夹中使用 Functions.php,我添加了这段代码:

    function jquery_frontend_scripts() {
        global $wp_scripts; 
        wp_enqueue_script('jquery-core');
        wp_enqueue_script('jquery-ui-core');
        wp_enqueue_script('jquery-ui-checkboxradio'); 

        $queryui = $wp_scripts->query('jquery-ui-core'); 

        $url = "//ajax.googleapis.com/ajax/libs/jqueryui/".$queryui->ver."/themes/base/jquery-ui.css";
        wp_enqueue_style('jquery-ui-base', $url, false, null);
    }

    if (!is_admin()) add_action('wp_enqueue_scripts', 'jquery_frontend_scripts');

在 wordpress 管理中的 contact7 页面上,我添加了:

    <script>
     jQuery(function() {
        jQuery( "input" ).checkboxradio({
          icon: false
        });
    } );
    </script>

    <legend>Välj belopp: </legend>
    <label for="radio-50">50 kr</label>
    <input type="radio" name="radio-50" id="radio-50">
    <label for="radio-200">200 kr</label>
    <input type="radio" name="radio-200" id="radio-200">
    <label for="radio-500">500 kr</label>
    <input type="radio" name="radio-500" id="radio-500">

正在调用该函数。所以我想 jQuery UI 一定有问题,或者 jQuery 主题没有正确加载。 谢谢!

最佳答案

wp_enqueue_script('jquery-ui-checkboxradio');

我没有在引用中看到依赖关系 https://developer.wordpress.org/reference/functions/wp_enqueue_script/

不是吗

jquery-ui-button

jquery-ui-form

关于php - Wordpress 为前端主题 functions.php 包含 jQuery UI Checkboxradio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39975552/

相关文章:

php - 在 Web 服务不可用的情况下测试 Web 服务的客户端

javascript - 获取客户端外部页面的标题

javascript - 在 Wordpress 中使用 Visual Composer;原始 js 未应用于我的原始 html

php - 如何使用目录从 html 文件中获取标题 - php

php - PDO 中的预处理语句真的能提高安全性吗?

php - 通过 jquery 可折叠的动态 BOM?

javascript - 如何使用 jquery 隐藏/更新/显示具有相同 ID 的多个实例?

jquery - CSS 当前窗口大小

php - 使用服务器数据库在本地托管我的 wordpress 网站

php - WordPress CSRF 利用草稿状态