• I’m trying to use deactivate_plugins to turn off a Mobile Jquery plugin when the theme is Thematic. It’s not working – what am I doing wrong, please?

    <?php
    /*
    Plugin Name: jQuery Mobile
    Plugin URI: https://www.ramoonus.nl/wordpress/jquery-mobile/
    Description: jQuery Mobile: Touch-Optimized Web Framework for Smartphones & Tablets. Requires jQuery 1.6 and WordPress 3.2
    Version: 1.1.0
    Author: Ramoonus
    Author URI: https://www.ramoonus.nl/
    */
    function deactivate_JQuery_Mobile() {
    	$theme_name = get_current_theme();
        $pos = strrpos($theme_name, "Thematic");
    	$plugin = plugin_basename( __FILE__ );
    	$plugin_data = get_plugin_data( __FILE__, false );
    
    	if ($pos === false){
    		if( is_plugin_active($plugin) ) {
    			deactivate_plugins( $plugin );
    			wp_die( "'".$plugin_data['Name']."' requires Thematic Theme! Deactivating Plugin.<br /><br />Back to <a href='".admin_url()."'>WordPress admin</a>." );
    		}
    	}
    }
    function rw_jquery_mobile() {
    		// javascript
    		wp_deregister_script('jquery-mobile'); // deregister
    		wp_enqueue_script('jquery-mobile', plugins_url('/js/jquery.mobile-1.1.0.min.js', __FILE__), array("jquery"), '1.1.0'); // forces jQuery to load
    
    		// css
    		wp_deregister_style('jquery-mobile'); // deregister
    		wp_enqueue_style('jquery-mobile', plugins_url('/css/jquery.mobile-1.1.0.min.css', __FILE__), false, '1.1.0');
    		// css 2
    		wp_deregister_style('jquery-mobile-structure'); // deregister
    		wp_enqueue_style('jquery-mobile-structure', plugins_url('/css/jquery.mobile.structure-1.1.0.min.css', __FILE__), false, '1.1.0');
    		// css 3
    		wp_deregister_style('jquery-mobile-theme'); // deregister
    		wp_enqueue_style('jquery-mobile-structure', plugins_url('/css/jquery.mobile.theme-1.1.0.min.css', __FILE__), false, '1.1.0');
    }
    add_action('init', 'rw_jquery_mobile');
    ?>
  • The topic ‘How to Deactivate a Plugin when a Specific Theme is Used’ is closed to new replies.