WordPress.org

Ready to get started?Download WordPress

Forums

Popular Widget
Suggestion: Include custom CSS from template dir if available (2 posts)

  1. adnan360
    Member
    Posted 6 months ago #

    I have been using the Popular Widget plugin in one of my projects. In that project I had to customize the default CSS. So I modified the functions.php at around line 52 like this:

    if( ! is_admin() || is_active_widget( false, false, $this->id_base, true ) ) {
    
    				if ( file_exists( get_template_directory().'/pop-widget.css' ) ) {
    
    					wp_enqueue_style( 'popular-widget', get_template_directory_uri() . '/pop-widget.css', NULL, $this->version );
    
    				} else {
    
    					wp_enqueue_style( 'popular-widget', POPWIDGET_URL . '_css/pop-widget.css', NULL, $this->version );
    
    				}
    
    				wp_enqueue_script( 'popular-widget', POPWIDGET_URL . '_js/pop-widget.js', array('jquery'), $this->version, true );
    			}

    It checks for a pop-widget.css in the theme directory. If not found, it includes the pop-widget.css from plugin _css directory.

    This way, when the plugin is updated, the CSS should stay there.

    Please include it in the next release of the plugin.

    http://wordpress.org/plugins/popular-widget/

  2. Hax
    Member
    Plugin Author

    Posted 6 months ago #

    @adnan360,

    sorry, we won't make the change if you want to remove the styles and add your own try this code

    function remove_pop_widget_styles( ){
    	 wp_dequeue_style( 'popular-widget' );
    	 wp_enqueue_style( 'popular-widget', get_template_directory_uri() . '/pop-widget.css' );
    
    }
    add_action(  'wp_enqueue_scripts', 'remove_pop_widget_styles',100 );

    Add it to your child theme functions.php file.

Reply

You must log in to post.

About this Plugin

About this Topic