dongting7352 2013-01-20 18:03
浏览 56
已采纳

如何强制主题使用Wordpress jQuery?

I installed a new awesome theme and got it working after hard work. Everything's running fine, except the 'Add Media', 'Add Link' and the 'HTML Editor'.

I read how to diagnose the problem according the official diagnosing instructions and posted it on Wordpress.org forum as they told me to, but I got no response yet and I don't think I'll be getting one anyway.

I used this:

define('SCRIPT_DEBUG', true);

And it did solve the problem for 'Add Media' and 'HTML Editor', but not for the 'add link'. When I click it, it DOES open, but the screen goes grey and the box is way far in the bottom-left corner and and I can't close it with the 'Cancel' button (see here).

I did try disabling all the plugins but it doesn't work (see here).

In summary the problem is that the theme probably has its own version of jQuery and Wordpress 3.5 has its own. How do I force the theme to use Wordpress's jQuery? Or force Wordpress to use the theme's jQuery? Anything that will fix the editor, I want that.

EDIT: Just to make it clearer. There is NO conflict with plugins. The conflict is between Wordpress's jQuery and the theme's jQuery.

If it helps, this is in the header file.

    <?php
    wp_enqueue_style("jqueryui_css", get_stylesheet_directory_uri()."/css/jqueryui/custom.css", false, $pp_theme_version, "all");
    wp_enqueue_style("screen_css", get_stylesheet_directory_uri()."/css/screen.css", false, $pp_theme_version, "all");
    wp_enqueue_style("tipsy_css", get_stylesheet_directory_uri()."/css/tipsy.css", false, $pp_theme_version, "all");
    wp_enqueue_style("fancybox_css", get_stylesheet_directory_uri()."/js/fancybox/jquery.fancybox.css", false, $pp_theme_version, "all");
    wp_enqueue_style("flexslider_css", get_stylesheet_directory_uri()."/js/flexslider/flexslider.css", false, $pp_theme_version, "all");

    $pp_advance_enable_responsive = get_option('pp_advance_enable_responsive');

    if(!empty($pp_advance_enable_responsive))
    {
        wp_enqueue_style("grid_css", get_stylesheet_directory_uri()."/css/grid.css", false, $pp_theme_version, "all");
    }

    if(isset($_SESSION['pp_slider_style']))
    {
        $pp_slider_style = $_SESSION['pp_slider_style'];
    }
    else
    {
        $pp_slider_style = get_option('pp_slider_style');
    }

    if($pp_slider_style=='full')
    {
        wp_enqueue_style("pp_slider_style", get_stylesheet_directory_uri()."/css/fullslide.css", false, $pp_theme_version, "all");
    }
    wp_enqueue_style("colorpicker.css", get_stylesheet_directory_uri()."/js/colorpicker/css/colorpicker.css", false, $pp_theme_version, "all");
?>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<?php   
    wp_enqueue_script("jquery", get_stylesheet_directory_uri()."/js/jquery.js", false, $pp_theme_version);
    wp_enqueue_script("jQuery_UI_js", get_stylesheet_directory_uri()."/js/jquery-ui.js", false, $pp_theme_version);
    wp_enqueue_script("swfobject.js", get_stylesheet_directory_uri()."/swfobject/swfobject.js", false, $pp_theme_version);
    wp_enqueue_script("colorpicker.js", get_stylesheet_directory_uri()."/js/colorpicker.js", false, $pp_theme_version);
    wp_enqueue_script("eye.js", get_stylesheet_directory_uri()."/js/eye.js", false, $pp_theme_version);
    wp_enqueue_script("utils.js", get_stylesheet_directory_uri()."/js/utils.js", false, $pp_theme_version);
    wp_enqueue_script("fancybox_js", get_stylesheet_directory_uri()."/js/fancybox/jquery.fancybox.pack.js", false, $pp_theme_version);
    wp_enqueue_script("jQuery_easing", get_stylesheet_directory_uri()."/js/jquery.easing.js", false, $pp_theme_version);
    wp_enqueue_script("jQuery_hint", get_stylesheet_directory_uri()."/js/hint.js", false, $pp_theme_version);
    wp_enqueue_script("jQuery_validate", get_stylesheet_directory_uri()."/js/jquery.validate.js", false, $pp_theme_version);
    wp_enqueue_script("jQuery_tipsy", get_stylesheet_directory_uri()."/js/jquery.tipsy.js", false, $pp_theme_version);
    wp_enqueue_script("reflection_js", get_stylesheet_directory_uri()."/js/reflection.js", false, $pp_theme_version);
    wp_enqueue_script("browser_js", get_stylesheet_directory_uri()."/js/browser.js", false, $pp_theme_version);
    wp_enqueue_script("flexslider_js", get_stylesheet_directory_uri()."/js/flexslider/jquery.flexslider-min.js", false, $pp_theme_version);
    wp_enqueue_script("marquee_js", get_stylesheet_directory_uri()."/js/jquery.marquee.js", false, $pp_theme_version);
    wp_enqueue_script("jwplayer_js", get_stylesheet_directory_uri()."/js/jwplayer.js", false, $pp_theme_version);
    wp_enqueue_script("gmap_js", get_stylesheet_directory_uri()."/js/gmap.js", false, $pp_theme_version);
    wp_enqueue_script("custom_js", get_stylesheet_directory_uri()."/js/custom.js", false, $pp_theme_version);

    /* Always have wp_head() just before the closing </head>
     * tag of your theme, or you will break many plugins, which
     * generally use this hook to add elements to <head> such
     * as styles, scripts, and meta tags.
     */
    wp_head();
?> 
  • 写回答

2条回答 默认 最新

  • dongxili9934 2013-01-20 19:01
    关注
    // only for Themes since WordPress 3.0
    function jquery_190() {
        if ( !is_admin() ) { // actually not necessary, because the Hook only get used in the Theme
            wp_deregister_script( 'jquery' ); // unregistered key jQuery
            wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js', false, '1.9.0'); // register key jQuery with URL of Google CDN
            wp_enqueue_script( 'jquery' ); // include jQuery
        }
    }
    add_action( 'after_setup_theme', 'jquery_190' ); // Theme active, include function
    

    MORE INFO

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。