CSS only loaded when shortcode present.
This commit is contained in:
@ -14,6 +14,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
||||
function wplt_get_default_options() {
|
||||
return array(
|
||||
'enable_css' => 1,
|
||||
'reset_settings' => 0 z
|
||||
'reset_settings' => 0,
|
||||
'shortcode_present' => false
|
||||
);
|
||||
}
|
@ -8,23 +8,26 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Register scripts and styles
|
||||
*
|
||||
* @param string $page current page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function wplt_enqueue_scripts( $page ) {
|
||||
function wplt_register_scripts() {
|
||||
// Register frontend CSS
|
||||
wp_register_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.css', '', WPLT_VERSION, 'all' );
|
||||
}
|
||||
add_action( 'init', 'wplt_register_scripts' );
|
||||
|
||||
/**
|
||||
* Print scripts and styles if shortcode is present.
|
||||
* @return bool
|
||||
*/
|
||||
function wplt_print_scripts() {
|
||||
global $wplt_options;
|
||||
|
||||
// Register frontend CSS
|
||||
wp_register_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.css', '', '1.0', 'all' );
|
||||
|
||||
// Enqueue frontend CSS if option is enabled
|
||||
if( $wplt_options['enable_css'] ) {
|
||||
wp_enqueue_style( 'wplt-css' );
|
||||
if( $wplt_options['enable_css'] && $wplt_options['shortcode_present'] ) {
|
||||
wp_print_styles( 'wplt-css' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'wplt_enqueue_scripts' );
|
||||
add_action( 'wp_footer', 'wplt_print_scripts' );
|
||||
|
||||
/**
|
||||
* Register admin scripts and style
|
||||
|
@ -23,6 +23,8 @@ add_filter( 'wp_ajax_get_new_ticks', array( $this, 'wplt_ajax_get_new_ticks' ) )
|
||||
function wplt_shortcode_ticker_show( $atts ) {
|
||||
global $wplt_options;
|
||||
|
||||
$wplt_options['shortcode_present'] = true;
|
||||
|
||||
/*$wplt_ticker_options = array();
|
||||
|
||||
extract(
|
||||
@ -37,7 +39,7 @@ function wplt_shortcode_ticker_show( $atts ) {
|
||||
{
|
||||
if(!$atts[1]) $atts[1] = -1;
|
||||
|
||||
$output .= '<ul class="wplt_ticker">';
|
||||
$output = '<ul class="wplt_ticker">';
|
||||
|
||||
$args = array( 'post_type' => 'wplt_tick',
|
||||
'posts_per_page' => $atts[1],
|
||||
|
Reference in New Issue
Block a user