CSS only loaded when shortcode present.
This commit is contained in:
parent
2692f2bd0c
commit
b39a577faf
@ -14,6 +14,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|||||||
function wplt_get_default_options() {
|
function wplt_get_default_options() {
|
||||||
return array(
|
return array(
|
||||||
'enable_css' => 1,
|
'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
|
* Register scripts and styles
|
||||||
*
|
|
||||||
* @param string $page current page
|
|
||||||
*
|
|
||||||
* @return bool
|
* @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;
|
global $wplt_options;
|
||||||
|
|
||||||
// Register frontend CSS
|
if( $wplt_options['enable_css'] && $wplt_options['shortcode_present'] ) {
|
||||||
wp_register_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.css', '', '1.0', 'all' );
|
wp_print_styles( 'wplt-css' );
|
||||||
|
|
||||||
// Enqueue frontend CSS if option is enabled
|
|
||||||
if( $wplt_options['enable_css'] ) {
|
|
||||||
wp_enqueue_style( 'wplt-css' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'wp_enqueue_scripts', 'wplt_enqueue_scripts' );
|
add_action( 'wp_footer', 'wplt_print_scripts' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register admin scripts and style
|
* 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 ) {
|
function wplt_shortcode_ticker_show( $atts ) {
|
||||||
global $wplt_options;
|
global $wplt_options;
|
||||||
|
|
||||||
|
$wplt_options['shortcode_present'] = true;
|
||||||
|
|
||||||
/*$wplt_ticker_options = array();
|
/*$wplt_ticker_options = array();
|
||||||
|
|
||||||
extract(
|
extract(
|
||||||
@ -37,7 +39,7 @@ function wplt_shortcode_ticker_show( $atts ) {
|
|||||||
{
|
{
|
||||||
if(!$atts[1]) $atts[1] = -1;
|
if(!$atts[1]) $atts[1] = -1;
|
||||||
|
|
||||||
$output .= '<ul class="wplt_ticker">';
|
$output = '<ul class="wplt_ticker">';
|
||||||
|
|
||||||
$args = array( 'post_type' => 'wplt_tick',
|
$args = array( 'post_type' => 'wplt_tick',
|
||||||
'posts_per_page' => $atts[1],
|
'posts_per_page' => $atts[1],
|
||||||
|
@ -44,5 +44,8 @@ Use the shortcode [liveticker2 id="slug"].
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
= 1.0 =
|
= 0.4 =
|
||||||
+ Initial stable plugin release.
|
+ CSS only loaded when shortcode is called
|
||||||
|
|
||||||
|
= 0.3 =
|
||||||
|
+ Initial plugin release.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Plugin Name: WP Liveticker 2
|
* Plugin Name: WP Liveticker 2
|
||||||
* Description: A simple Liveticker for Wordpress.
|
* Description: A simple Liveticker for Wordpress.
|
||||||
* Version: 0.3 beta
|
* Version: 0.4 beta
|
||||||
* Author: Stefan Kalscheuer
|
* Author: Stefan Kalscheuer
|
||||||
* Author URI: http://www.stklblog.de
|
* Author URI: http://www.stklblog.de
|
||||||
* Text Domain: wplt2
|
* Text Domain: wplt2
|
||||||
@ -34,7 +34,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
if( !defined( 'WPLT_VERSION' ) )
|
if( !defined( 'WPLT_VERSION' ) )
|
||||||
define( 'WPLT_VERSION', '0.1' );
|
define( 'WPLT_VERSION', '0.4' );
|
||||||
|
|
||||||
if( !defined( 'WPLT_PLUGIN_URL' ) )
|
if( !defined( 'WPLT_PLUGIN_URL' ) )
|
||||||
define( 'WPLT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'WPLT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
@ -55,14 +55,14 @@ add_action( 'plugins_loaded', 'WPLT_localization' );
|
|||||||
*/
|
*/
|
||||||
global $wplt_options;
|
global $wplt_options;
|
||||||
$wplt_options = get_option( 'wplt2' );
|
$wplt_options = get_option( 'wplt2' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include required plugin files
|
* Include required plugin files
|
||||||
*/
|
*/
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/functions.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/functions.php' );
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/post-types.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/post-types.php' );
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/scripts.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/scripts.php' );
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/rss.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/rss.php' );
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/shortcodes.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/shortcodes.php' );
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/widget.php' );
|
include_once( WPLT_PLUGIN_DIR . 'includes/widget.php' );
|
||||||
if( is_admin() ) {
|
if( is_admin() ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user