Support » Plugin: WP User Control » [Plugin: WP User Control] Deregister styles

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author wmsedgar

    (@wmsedgar)

    MickeyRoush,

    Thanks for your post. The stylesheet is also enqueued, however it is done via another class that is extended by the WP User Control widget class. At present there is no built-in capability to de-register the WP User Control style sheet. That said, the easiest hack to accomplish this would be to do as follows:

    Open the ../wordpress_root/wp-content/plugins/wp-user-control/inc/SidebarWidget.php class file for editing.

    Comment out lines 282-289, effectively disabling the addWidgetStyle() method:

    public function addWidgetStyle() {
    	/*
    	 * COMMENT OUT LINES BELOW TO DISABLE STYLE SHEET
    	 *
    	$style = WP_USER_CONTROL_WIDGET_CSS . $this->widgetStyle;
    	wp_register_style(
        	    	$handle = $this->widgetStyleHandle,
        	    	$src = $style
        	    	);
    	wp_enqueue_style(
    		$handle = $this->widgetStyleHandle
     		);
        	 *
        	 * END OF COMMENTS TO DISABLE STYLE SHEET
     	 */
    }

    Just keep in mind that this hack will be overwritten by the next release of WP User Control, so you will need to redo it in order to preserve. We will look at adding this type of functionality in a future release of WP User Control to provide this capability natively.

    Thanks, this works. But is there anyway to add a conditional statement using WordPress Conditionals?

    Something like:

    !is_front_page() || !is_single() || !is_page( array( ‘page-one’, ‘page-two’, ‘page-three’ ) )

    I tried this, but it didn’t work:

    public function addWidgetStyle() {
    
    	if ( !is_front_page() || !is_single() || !is_page( array( 'page-one', 'page-two', 'page-three' ) ) ) {
    
    	$style = WP_USER_CONTROL_WIDGET_CSS . $this->widgetStyle;
    	wp_register_style(
        	    	$handle = $this->widgetStyleHandle,
        	    	$src = $style
        	    	);
    	wp_enqueue_style(
    		$handle = $this->widgetStyleHandle
     		);
    	}
    }
    Plugin Author wmsedgar

    (@wmsedgar)

    MickeyRoush,

    Yes, you can do that, however those functions will not work in the SidebarWidget class addWidgetStyle method contained in WP User Control. To do that on your own you’ll need to write your own function to enqueue the style and hook it to the wp_enqueue_scripts action. Look at the wp_enqueue_style codex for reference. This article on WordPress Answers also has some relevant info.

    +1 for the ability to disable the default CSS.

    Plugin Author wmsedgar

    (@wmsedgar)

    flyingpylon,

    Thanks for your feedback on this item as well, we’re looking at a number of key features to be added to our next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP User Control] Deregister styles’ is closed to new replies.