WordPress.org

Forums

Live Stream Badger
Menu Item Class (2 posts)

  1. johanronstrom
    Member
    Posted 1 year ago #

    Hello!

    Thank you for a great plugin!

    My feature request was to add the WordPress feature Menu Item Custom CSS Class ( http://sevenspark.com/how-to/how-to-add-a-custom-class-to-a-wordpress-menu-item ) to the outputed list item.

    I'm considering using this for adding game ('starcraft2','dota' etc) and adding game icons to the list. But it could be used for anything (flags have come up).

    Since this is a core WP feature, it would be nice if the plugin outputted it! :-)

    If you have tips on where I can add this myself that'd be nice, so I could start using it right away!

    / johanr
    https://wordpress.org/plugins/live-stream-badger/

  2. johanronstrom
    Member
    Posted 1 year ago #

    I solved it by editing the plugin like so:

    stream-status-widget.php from line 120

    $var_status_class = $is_on ? 'lsb-on' : 'lsb-off';
    $var_url = $menu_item->url;
    $var_title = apply_filters( 'lsb_stream_status_widget_text', $menu_item->title );
    $var_status_indicator = $is_on ? $stream->watching_now : 'Offline';
    $var_item_classes = implode(" ",$menu_item->classes);  // added
    
    $item = '';
    if ($show_image == true) {
    	$item = $templates->printt( $lsb_status_widget_item_with_image_format,
    		array(
    			'%%status_class%%'     => $var_status_class,
    			'%%url%%'              => $var_url,
    			'%%title%%'            => $var_title,
    			'%%status_indicator%%' => $var_status_indicator,
    			'%%image_src%%'        => $var_image_src,
    			'%%item_classes%%'	   => $var_item_classes  // added
    		)
    	);
    } else {
    	$item = $templates->printt( $lsb_status_widget_item_format,
    		array(
    			'%%status_class%%'     => $var_status_class,
    			'%%url%%'              => $var_url,
    			'%%title%%'            => $var_title,
    			'%%status_indicator%%' => $var_status_indicator,
    			'%%item_classes%%'	   => $var_item_classes  // added
    		)
    	);
    }

    and class-templates.php lines 18 and 29

    <li class="lsb-status-widget-list-item %%status_class%% %%item_classes%%">

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Live Stream Badger
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic