WordPress.org

Ready to get started?Download WordPress

Forums

WP User Control
[resolved] Deregister styles (6 posts)

  1. MickeyRoush
    Member
    Posted 2 years ago #

    Is there anyway to deregister the style sheet that's loaded on every page? I can deregister the script, but cannot deregister the the style sheet. It doesn't look like it's enqueued like the script.

    define( 'WP_USER_CONTROL_WIDGET_STYLE', 'style.css' );

    Thanks.

    http://wordpress.org/extend/plugins/wp-user-control/

  2. wmsedgar
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. MickeyRoush
    Member
    Posted 2 years ago #

    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
     		);
    	}
    }
  4. wmsedgar
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  5. flyingpylon
    Member
    Posted 1 year ago #

    +1 for the ability to disable the default CSS.

  6. wmsedgar
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic