Stylesheet with lazy loading included in main class

This commit is contained in:
2017-11-12 20:31:03 +01:00
parent e164efcd3a
commit 01f8b1f29f
7 changed files with 23 additions and 393 deletions

View File

@ -14,6 +14,13 @@ defined( 'ABSPATH' ) || exit;
* WP Liveticker 2.
*/
class WPLiveticker2 {
/**
* Options tag.
*
* @var string OPTIONS
*/
const VERSION = '1.0.0';
/**
* Options tag.
*
@ -58,6 +65,9 @@ class WPLiveticker2 {
// Add shortcode.
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
// Enqueue styles.
add_action( 'wp_footer', array( 'WPLiveticker2', 'enqueue_styles' ) );
// Admin only actions.
if ( is_admin() ) {
// Add dashboard "right now" functionality.
@ -187,6 +197,16 @@ class WPLiveticker2 {
return $output;
}
/**
* Register frontend CSS.
*/
public static function enqueue_styles() {
// Only add if shortcode is present.
if ( self::$shortcode_present ) {
wp_enqueue_style( 'wplt-css', WPLT2_BASE . 'styles/wp-liveticker2.min.css', '', self::VERSION, 'all' );
}
}
/**
* Update options.
*