Support » Plugin: WP Maintenance Mode » Unable to enqueue css via wpmm_head hook

  • Resolved rizkysyazuli

    (@rizkysyazuli)


    I saw some of the other topics here about adding custom css via the wpmm_head hook. but it seems rather odd to hardcode the css like that. So i’m trying to enqueue an external css instead. But it doesn’t seem to work.

    I’m not exactly a WP expert. So pardon my ignorance with hooks, etc. Any help would be appreciated.

    
    function custom_comingsoon() {
    	wp_register_style( 'comingsoon',
    		get_stylesheet_directory_uri() . '/comingsoon.css',
    		array(),
    		wp_get_theme()->get('Version')
    	);
    
    	wp_enqueue_style( 'comingsoon' );
    }
    
    add_action('wpmm_head', 'custom_comingsoon');
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author George J

    (@georgejipa)

    Hello @rizkysyazuli,

    You should try:

    
    /**
     * Enqueue custom css files
     * 
     * @param array $styles
     * @return array
     */
    function wpmm_enqueue_css_files($styles) {
    	$styles[] = get_stylesheet_directory_uri() . '/comingsoon.css?ver=' . wp_get_theme()->get('Version');
    
    	return $styles;
    }
    
    add_filter('wpmm_styles', 'wpmm_enqueue_css_files', 10, 1);
    
    rizkysyazuli

    (@rizkysyazuli)

    Ah, i see. We’re injecting it into the $styles array on the header.
    Well, you learn something new everyday 🙂 Thx. it works now btw.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.