Renamed Plugin and changed slug to stklcode-liveticker
Due to naming conflicts with the original wp-liveticker plugin this one is now renamed to a unique identifier.
This commit is contained in:
parent
9d64f9f415
commit
65eafd2524
@ -1,4 +1,4 @@
|
||||
# WP-Liveticker 2
|
||||
# Liveticker (by stklcode)
|
||||
|
||||
* Contributors: Stefan Kalscheuer
|
||||
* Tags: liveticker, feed, rss
|
||||
@ -15,9 +15,6 @@ A simple ajaxified liveticker plugin for WordPress.
|
||||
|
||||
WP-Liveticker 2 is a simple liveticker plugin for WordPress. Easily add multiple livetickers, add them to posts with shortcode or use them as Widget.
|
||||
|
||||
This plugin has been inspired by the _wp-liveticker_ Plugin by _DasLlama_ which is no longer available.
|
||||
However the code is now completely rewritten from scratch
|
||||
|
||||
### Features
|
||||
|
||||
* Handle multiple Tickers
|
||||
|
22
RoboFile.php
22
RoboFile.php
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2 Robo build script.
|
||||
* Liveticker Robo build script.
|
||||
*
|
||||
* This file contains the Robo tasks for building a distributable plugin package.
|
||||
* Should not be included in final package.
|
||||
*
|
||||
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||
*
|
||||
* @package WP Liveticker 2
|
||||
* @package Liveticker
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
@ -19,8 +19,8 @@ use Symfony\Component\Finder\Finder;
|
||||
* Class RoboFile
|
||||
*/
|
||||
class RoboFile extends Tasks {
|
||||
const PROJECT_NAME = 'wp-liveticker2';
|
||||
const SVN_URL = 'https://plugins.svn.wordpress.org/wp-liveticker2';
|
||||
const PROJECT_NAME = 'stklcode-liveticker';
|
||||
const SVN_URL = 'https://plugins.svn.wordpress.org/stklcode-liveticker';
|
||||
|
||||
const OPT_TARGET = 'target';
|
||||
const OPT_SKIPTEST = 'skipTests';
|
||||
@ -143,7 +143,7 @@ class RoboFile extends Tasks {
|
||||
'styles' => $this->target_dir . '/' . $this->final_name . '/styles',
|
||||
'views' => $this->target_dir . '/' . $this->final_name . '/views',
|
||||
) )->run();
|
||||
$this->_copy( 'wp-liveticker2.php', $this->target_dir . '/' . $this->final_name . '/wp-liveticker2.php' );
|
||||
$this->_copy( 'stklcode-liveticker.php', $this->target_dir . '/' . $this->final_name . '/stklcode-liveticker.php' );
|
||||
$this->_copy( 'README.md', $this->target_dir . '/' . $this->final_name . '/README.md' );
|
||||
$this->_copy( 'LICENSE.md', $this->target_dir . '/' . $this->final_name . '/LICENSE.md' );
|
||||
}
|
||||
@ -409,7 +409,7 @@ class RoboFile extends Tasks {
|
||||
if ( is_dir( $this->target_dir . '/svn' ) ) {
|
||||
$this->taskSvnStack()
|
||||
->stopOnFail()
|
||||
->dir( $this->target_dir . '/svn/wp-liveticker2' )
|
||||
->dir( $this->target_dir . '/svn/stklcode-liveticker' )
|
||||
->update()
|
||||
->run();
|
||||
} else {
|
||||
@ -433,7 +433,7 @@ class RoboFile extends Tasks {
|
||||
private function commitVCS( $to_add, $msg ) {
|
||||
$task = $this->taskSvnStack()
|
||||
->stopOnFail()
|
||||
->dir( $this->target_dir . '/svn/wp-liveticker2' );
|
||||
->dir( $this->target_dir . '/svn/stklode-liveticker' );
|
||||
|
||||
if ( is_array( $to_add ) ) {
|
||||
foreach ( $to_add as $ta ) {
|
||||
@ -452,7 +452,7 @@ class RoboFile extends Tasks {
|
||||
* @return void
|
||||
*/
|
||||
private function updateVCSreadme() {
|
||||
$trunk_dir = $this->target_dir . '/svn/wp-liveticker2/trunk';
|
||||
$trunk_dir = $this->target_dir . '/svn/stklcode-liveticker/trunk';
|
||||
$this->_copy( $this->target_dir . '/' . $this->final_name . 'README.md', $trunk_dir . 'README.md' );
|
||||
}
|
||||
|
||||
@ -463,7 +463,7 @@ class RoboFile extends Tasks {
|
||||
*/
|
||||
private function updateVCStrunk() {
|
||||
// Clean trunk directory.
|
||||
$trunk_dir = $this->target_dir . '/svn/wp-liveticker2/trunk';
|
||||
$trunk_dir = $this->target_dir . '/svn/stklcode-liveticker/trunk';
|
||||
$this->taskCleanDir( $trunk_dir )->run();
|
||||
|
||||
// Copy built bundle to trunk.
|
||||
@ -477,9 +477,9 @@ class RoboFile extends Tasks {
|
||||
*/
|
||||
private function updateVCStag() {
|
||||
// Clean tag directory if it exists.
|
||||
$tag_dir = $this->target_dir . '/svn/wp-liveticker2/tags/' . $this->version;
|
||||
$tag_dir = $this->target_dir . '/svn/stklcode-liveticker/tags/' . $this->version;
|
||||
if ( is_dir( $tag_dir ) ) {
|
||||
$this->taskCleanDir( $this->target_dir . '/svn/wp-liveticker2/tags/' . $this->version )->run();
|
||||
$this->taskCleanDir( $this->target_dir . '/svn/stklcode-liveticker/tags/' . $this->version )->run();
|
||||
} else {
|
||||
$this->_mkdir( $tag_dir );
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "stklcode/wp-liveticker2",
|
||||
"name": "stklcode/wp-liveticker",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple Liveticker for Wordpress.",
|
||||
"keywords": [
|
||||
@ -68,8 +68,8 @@
|
||||
"phpcbf --standard=phpcs.xml"
|
||||
],
|
||||
"minify": [
|
||||
"minifycss styles/wp-liveticker2.css > styles/wp-liveticker2.min.css",
|
||||
"minifyjs scripts/wp-liveticker2.js > scripts/wp-liveticker2.min.js"
|
||||
"minifycss styles/liveticker.css > styles/liveticker.min.css",
|
||||
"minifyjs scripts/liveticker.js > scripts/liveticker.min.js"
|
||||
]
|
||||
},
|
||||
"repositories": [
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Plugin admin class.
|
||||
* Liveticker: Plugin admin class.
|
||||
*
|
||||
* This file contains the derived class for the plugin's administration features.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
@ -13,22 +13,20 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* WP Liveticker 2 admin configuration.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* Liveticker admin configuration.
|
||||
*/
|
||||
class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
class SCLiveticker_Admin extends SCLiveticker {
|
||||
/**
|
||||
* Add to Right Now Widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function dashboard_right_now() {
|
||||
$total_files = wp_count_posts( 'wplt2_tick' );
|
||||
$total_files = wp_count_posts( 'scliveticker_tick' );
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="first b b-tags"><a href="edit.php?post_type=wplt2_tick">' . esc_html( $total_files->publish ) . '</a></td>';
|
||||
echo '<td class="t tags"><a href="edit.php?post_type=wplt2_tick">' . esc_html__( 'Ticks', 'wplt2' ) . '</a></td>';
|
||||
echo '<td class="first b b-tags"><a href="edit.php?post_type=scliveticker_tick">' . esc_html( $total_files->publish ) . '</a></td>';
|
||||
echo '<td class="t tags"><a href="edit.php?post_type=scliveticker_tick">' . esc_html__( 'Ticks', 'stklcode-liveticker' ) . '</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
@ -39,13 +37,13 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
*/
|
||||
public static function register_settings_page() {
|
||||
add_submenu_page(
|
||||
'edit.php?post_type=wplt2_tick',
|
||||
'Liveticker2 ' . __( 'Settings', 'wplt2' ),
|
||||
__( 'Settings', 'wplt2' ),
|
||||
'edit.php?post_type=scliveticker_tick',
|
||||
'Liveticker ' . __( 'Settings', 'stklcode-liveticker' ),
|
||||
__( 'Settings', 'stklcode-liveticker' ),
|
||||
'manage_options',
|
||||
'wplt2_settings',
|
||||
'scliveticker_settings',
|
||||
array(
|
||||
'WPLiveticker2_Admin',
|
||||
__CLASS__,
|
||||
'settings_page',
|
||||
)
|
||||
);
|
||||
@ -58,53 +56,53 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
*/
|
||||
public static function register_settings() {
|
||||
register_setting(
|
||||
'wplt2_settings',
|
||||
'wplt2',
|
||||
array( 'WPLiveticker2_Admin', 'validate_settings' )
|
||||
'scliveticker_settings',
|
||||
self::OPTION,
|
||||
array( __CLASS__, 'validate_settings' )
|
||||
);
|
||||
|
||||
// Form sections.
|
||||
add_settings_section(
|
||||
'wplt2_settings_general',
|
||||
__( 'General', 'wplt2' ),
|
||||
array( 'WPLiveticker2_Admin', 'settings_general_section' ),
|
||||
'wplt2-settings-page'
|
||||
'scliveticker_settings_general',
|
||||
__( 'General', 'stklcode-liveticker' ),
|
||||
array( __CLASS__, 'settings_general_section' ),
|
||||
'scliveticker-settings-page'
|
||||
);
|
||||
|
||||
// Form fields.
|
||||
add_settings_field(
|
||||
'enable_ajax',
|
||||
__( 'Use AJAX', 'wplt2' ),
|
||||
array( 'WPLiveticker2_Admin', 'settings_enable_ajax_field' ),
|
||||
'wplt2-settings-page',
|
||||
'wplt2_settings_general',
|
||||
__( 'Use AJAX', 'stklcode-liveticker' ),
|
||||
array( __CLASS__, 'settings_enable_ajax_field' ),
|
||||
'scliveticker-settings-page',
|
||||
'scliveticker_settings_general',
|
||||
array( 'label_for' => esc_attr( self::OPTION ) . '-enable-ajax' )
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'poll_interval',
|
||||
__( 'AJAX poll interval', 'wplt2' ),
|
||||
array( 'WPLiveticker2_Admin', 'settings_poll_interval_field' ),
|
||||
'wplt2-settings-page',
|
||||
'wplt2_settings_general',
|
||||
__( 'AJAX poll interval', 'stklcode-liveticker' ),
|
||||
array( __CLASS__, 'settings_poll_interval_field' ),
|
||||
'scliveticker-settings-page',
|
||||
'scliveticker_settings_general',
|
||||
array( 'label_for' => esc_attr( self::OPTION ) . '-poll-interval' )
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'enable_css',
|
||||
__( 'Default CSS Styles', 'wplt2' ),
|
||||
array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ),
|
||||
'wplt2-settings-page',
|
||||
'wplt2_settings_general',
|
||||
__( 'Default CSS Styles', 'stklcode-liveticker' ),
|
||||
array( __CLASS__, 'settings_enable_css_field' ),
|
||||
'scliveticker-settings-page',
|
||||
'scliveticker_settings_general',
|
||||
array( 'label_for' => esc_attr( self::OPTION ) . '-enable-css' )
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'show_feed',
|
||||
__( 'Show RSS feed', 'wplt2' ),
|
||||
array( 'WPLiveticker2_Admin', 'settings_show_feed_field' ),
|
||||
'wplt2-settings-page',
|
||||
'wplt2_settings_general',
|
||||
__( 'Show RSS feed', 'stklcode-liveticker' ),
|
||||
array( __CLASS__, 'settings_show_feed_field' ),
|
||||
'scliveticker-settings-page',
|
||||
'scliveticker_settings_general',
|
||||
array( 'label_for' => esc_attr( self::OPTION ) . '-show-feed' )
|
||||
);
|
||||
}
|
||||
@ -134,8 +132,8 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
$checked = self::$_options['enable_ajax'];
|
||||
|
||||
echo '<input id="' . esc_attr( self::OPTION ) . '-enable-ajax" type="checkbox" name="' . esc_attr( self::OPTION ) . '[enable_ajax]" value="1" ' . checked( $checked, 1, false ) . '> ';
|
||||
esc_html_e( 'Enable', 'wplt2' );
|
||||
echo '<p class="description">' . esc_html__( 'Disable this option to not use AJAX update. This means all liveticker widgets and shortcodes are only updated once on site load.', 'wplt2' ) . '</p>';
|
||||
esc_html_e( 'Enable', 'stklcode-liveticker' );
|
||||
echo '<p class="description">' . esc_html__( 'Disable this option to not use AJAX update. This means all liveticker widgets and shortcodes are only updated once on site load.', 'stklcode-liveticker' ) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,8 +145,8 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
$poll_interval = self::$_options['poll_interval'];
|
||||
|
||||
echo '<input id="' . esc_attr( self::OPTION ) . '-poll-interval" type="number" name="' . esc_attr( self::OPTION ) . '[poll_interval]" value="' . esc_attr( $poll_interval ) . '"> ';
|
||||
esc_html_e( 'seconds', 'wplt2' );
|
||||
echo '<p class="description">' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '</p>';
|
||||
esc_html_e( 'seconds', 'stklcode-liveticker' );
|
||||
echo '<p class="description">' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'stklcode-liveticker' ) . '</p>';
|
||||
}
|
||||
|
||||
|
||||
@ -161,8 +159,8 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
$checked = self::$_options['enable_css'];
|
||||
|
||||
echo '<input id="' . esc_attr( self::OPTION ) . '-enable-css" type="checkbox" name="' . esc_attr( self::OPTION ) . '[enable_css]" value="1" ' . checked( $checked, 1, false ) . ' /> ';
|
||||
esc_html_e( 'Enable', 'wplt2' );
|
||||
echo '<p class="description">' . esc_html__( 'Disable this option to remove the default styling CSS file.', 'wplt2' ) . '</p>';
|
||||
esc_html_e( 'Enable', 'stklcode-liveticker' );
|
||||
echo '<p class="description">' . esc_html__( 'Disable this option to remove the default styling CSS file.', 'stklcode-liveticker' ) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,8 +172,8 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
$checked = self::$_options['show_feed'];
|
||||
|
||||
echo '<input id="' . esc_attr( self::OPTION ) . '-show-feed" type="checkbox" name="' . esc_attr( self::OPTION ) . '[show_feed]" value="1" ' . checked( $checked, 1, false ) . ' /> ';
|
||||
esc_html_e( 'Enable', 'wplt2' );
|
||||
echo '<p class="description">' . esc_html__( 'Can be overwritten in shortcode.', 'wplt2' ) . '</p>';
|
||||
esc_html_e( 'Enable', 'stklcode-liveticker' );
|
||||
echo '<p class="description">' . esc_html__( 'Can be overwritten in shortcode.', 'stklcode-liveticker' ) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +182,7 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||
* @return void
|
||||
*/
|
||||
public static function settings_page() {
|
||||
include WPLT2_DIR . 'views/settings-page.php';
|
||||
include SCLIVETICKER_DIR . 'views/settings-page.php';
|
||||
}
|
||||
|
||||
/**
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Plugin system class.
|
||||
* Liveticker: Plugin system class.
|
||||
*
|
||||
* This file contains the derived class for the plugin's system operations.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
@ -13,9 +13,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* WP Liveticker 2 system configuration.
|
||||
* Liveticker system configuration.
|
||||
*/
|
||||
class WPLiveticker2_System extends WPLiveticker2 {
|
||||
class SCLiveticker_System extends SCLiveticker {
|
||||
|
||||
/**
|
||||
* Activation hook.
|
||||
@ -47,27 +47,27 @@ class WPLiveticker2_System extends WPLiveticker2 {
|
||||
*/
|
||||
public static function uninstall() {
|
||||
// Delete all ticks.
|
||||
$ticks = new WP_Query( array( 'post_type' => 'wplt2_tick' ) );
|
||||
$ticks = new WP_Query( array( 'post_type' => 'scliveticker_tick' ) );
|
||||
foreach ( $ticks->get_posts() as $tick ) {
|
||||
wp_delete_post( $tick->ID, true );
|
||||
}
|
||||
|
||||
// Temporarily register taxonomy to delete it.
|
||||
register_taxonomy( 'wplt2_ticker', array( 'wplt2_tick' ) );
|
||||
register_taxonomy( 'scliveticker_ticker', array( 'scliveticker_tick' ) );
|
||||
|
||||
// Delete tickers.
|
||||
$tickers = get_terms(
|
||||
array(
|
||||
'taxonomy' => 'wplt2_ticker',
|
||||
'taxonomy' => 'scliveticker_ticker',
|
||||
'hide_empty' => false,
|
||||
)
|
||||
);
|
||||
foreach ( $tickers as $ticker ) {
|
||||
wp_delete_term( $ticker->term_id, 'wplt2_ticker' );
|
||||
wp_delete_term( $ticker->term_id, 'scliveticker_ticker' );
|
||||
}
|
||||
|
||||
// Unregister taxonomy again.
|
||||
unregister_taxonomy( 'wplt2_ticker' );
|
||||
unregister_taxonomy( 'scliveticker_ticker' );
|
||||
|
||||
// Delete the option.
|
||||
delete_option( self::OPTION );
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Widget class.
|
||||
* Liveticker: Widget class.
|
||||
*
|
||||
* This file contains the liveticker widget.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
@ -12,12 +12,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WPLiveticker2_Widget.
|
||||
* Class SCLiveticker_Widget.
|
||||
*/
|
||||
class WPLiveticker2_Widget extends WP_Widget {
|
||||
class SCLiveticker_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* WPLiveticker2_Widget constructor.
|
||||
* SCLiveticker_Widget constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct( false, 'Liveticker' );
|
||||
@ -27,7 +27,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
* Register the widget.
|
||||
*/
|
||||
public static function register() {
|
||||
register_widget( 'WPLiveticker2_Widget' );
|
||||
register_widget( __CLASS__ );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,21 +40,21 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
* @return void
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
// Notify WPLT2 class that widget is present.
|
||||
WPLiveticker2::mark_widget_present();
|
||||
// Notify scLiveticker class that widget is present.
|
||||
SCLiveticker::mark_widget_present();
|
||||
|
||||
$instance = self::fill_options_with_defaults( $instance );
|
||||
$before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
|
||||
$after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
|
||||
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
|
||||
$after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';
|
||||
$title = apply_filters( 'wplt2_catlit', $instance['title'] );
|
||||
$category = apply_filters( 'wplt2_catlit', $instance['category'] );
|
||||
$count = apply_filters( 'wplt2_catlit', $instance['count'] );
|
||||
$link = apply_filters( 'wplt2_catlit', $instance['link'] );
|
||||
$highlight = apply_filters( 'wplt2_catlit', $instance['highlight'] );
|
||||
$highlight_time = apply_filters( 'wplt2_catlit', $instance['highlight_time'] );
|
||||
$ajax = apply_filters( 'wplt2_catlit', $instance['ajax'] );
|
||||
$title = apply_filters( 'scliveticker_catlit', $instance['title'] );
|
||||
$category = apply_filters( 'scliveticker_catlit', $instance['category'] );
|
||||
$count = apply_filters( 'scliveticker_catlit', $instance['count'] );
|
||||
$link = apply_filters( 'scliveticker_catlit', $instance['link'] );
|
||||
$highlight = apply_filters( 'scliveticker_catlit', $instance['highlight'] );
|
||||
$highlight_time = apply_filters( 'scliveticker_catlit', $instance['highlight_time'] );
|
||||
$ajax = apply_filters( 'scliveticker_catlit', $instance['ajax'] );
|
||||
?>
|
||||
|
||||
<?php
|
||||
@ -68,20 +68,20 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
echo $before_title . esc_html( $title ) . $after_title;
|
||||
}
|
||||
|
||||
echo '<ul class="wplt2-widget';
|
||||
echo '<ul class="sclt-widget';
|
||||
if ( '1' === $ajax ) {
|
||||
echo ' wplt2-widget-ajax" '
|
||||
. 'data-wplt2-ticker="' . esc_attr( $category ) . '" '
|
||||
. 'data-wplt2-limit="' . esc_attr( $count ) . '" '
|
||||
. 'data-wplt2-last="' . esc_attr( time() );
|
||||
echo ' sclt-widget-ajax" '
|
||||
. 'data-sclt-ticker="' . esc_attr( $category ) . '" '
|
||||
. 'data-sclt-limit="' . esc_attr( $count ) . '" '
|
||||
. 'data-sclt-last="' . esc_attr( time() );
|
||||
}
|
||||
echo '">';
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'wplt2_tick',
|
||||
'post_type' => 'scliveticker_tick',
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'wplt2_ticker',
|
||||
'taxonomy' => 'scliveticker_ticker',
|
||||
'field' => 'slug',
|
||||
'terms' => $category,
|
||||
),
|
||||
@ -93,7 +93,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
while ( $wp_query->have_posts() && ( $count <= 0 || ++ $cnt < $count ) ) {
|
||||
$wp_query->the_post();
|
||||
// @codingStandardsIgnoreLine
|
||||
echo WPLiveticker2::tick_html_widget(
|
||||
echo SCLiveticker::tick_html_widget(
|
||||
esc_html( get_the_time( 'd.m.Y - H.i' ) ),
|
||||
get_the_title(),
|
||||
( '1' === $highlight && get_the_time( 'U' ) > ( time() - $highlight_time ) )
|
||||
@ -103,8 +103,8 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
echo '</ul>';
|
||||
|
||||
if ( $link ) {
|
||||
echo '<p class="wplt2-widget-link">'
|
||||
. '<a href="' . esc_attr( $link ) . '">' . esc_html__( 'show all', 'wplt2' ) . '...</a>'
|
||||
echo '<p class="sclt-widget-link">'
|
||||
. '<a href="' . esc_attr( $link ) . '">' . esc_html__( 'show all', 'stklcode-liveticker' ) . '...</a>'
|
||||
. '</p>';
|
||||
}
|
||||
// @codingStandardsIgnoreLine
|
||||
@ -139,9 +139,9 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
$highlight = isset( $instance['highlight'] ) ? esc_attr( $instance['highlight'] ) : '0';
|
||||
$highlight_time = isset( $instance['highlight_time'] ) ? esc_attr( $instance['highlight_time'] ) : '0';
|
||||
$ajax = isset( $instance['ajax'] ) ? esc_attr( $instance['ajax'] ) : '0';
|
||||
$categories = get_terms( 'wplt2_ticker', 'orderby=name&order=ASC' );
|
||||
$categories = get_terms( 'scliveticker_ticker', 'orderby=name&order=ASC' );
|
||||
|
||||
include WPLT2_DIR . 'views/widget-form.php';
|
||||
include SCLIVETICKER_DIR . 'views/widget-form.php';
|
||||
}
|
||||
|
||||
/**
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Plugin main class.
|
||||
* Liveticker: Plugin main class.
|
||||
*
|
||||
* This file contains the plugin's base class.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
@ -13,9 +13,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* WP Liveticker 2.
|
||||
* Liveticker.
|
||||
*/
|
||||
class WPLiveticker2 {
|
||||
class SCLiveticker {
|
||||
/**
|
||||
* Options tag.
|
||||
*
|
||||
@ -28,7 +28,7 @@ class WPLiveticker2 {
|
||||
*
|
||||
* @var string OPTIONS
|
||||
*/
|
||||
const OPTION = 'wplt2';
|
||||
const OPTION = 'stklcode-liveticker';
|
||||
|
||||
/**
|
||||
* Plugin options.
|
||||
@ -72,34 +72,34 @@ class WPLiveticker2 {
|
||||
}
|
||||
|
||||
// Load Textdomain.
|
||||
load_plugin_textdomain( 'wplt2', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
|
||||
load_plugin_textdomain( 'stklcode-liveticker', false );
|
||||
|
||||
// Allow shortcodes in widgets.
|
||||
add_filter( 'widget_text', 'do_shortcode' );
|
||||
|
||||
// Add shortcode.
|
||||
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
|
||||
add_shortcode( 'liveticker', array( __CLASS__, 'shortcode_ticker_show' ) );
|
||||
|
||||
// Enqueue styles.
|
||||
add_action( 'wp_footer', array( 'WPLiveticker2', 'enqueue_styles' ) );
|
||||
add_action( 'wp_footer', array( __CLASS__, 'enqueue_styles' ) );
|
||||
|
||||
// Enqueue JavaScript.
|
||||
add_action( 'wp_footer', array( 'WPLiveticker2', 'enqueue_scripts' ) );
|
||||
add_action( 'wp_footer', array( __CLASS__, 'enqueue_scripts' ) );
|
||||
|
||||
// Add AJAX hook if configured.
|
||||
if ( 1 === self::$_options['enable_ajax'] ) {
|
||||
add_action( 'wp_ajax_wplt2_update-ticks', array( 'WPLiveticker2', 'ajax_update' ) );
|
||||
add_action( 'wp_ajax_nopriv_wplt2_update-ticks', array( 'WPLiveticker2', 'ajax_update' ) );
|
||||
add_action( 'wp_ajax_sclt_update-ticks', array( __CLASS__, 'ajax_update' ) );
|
||||
add_action( 'wp_ajax_nopriv_sclt_update-ticks', array( __CLASS__, 'ajax_update' ) );
|
||||
}
|
||||
|
||||
// Admin only actions.
|
||||
if ( is_admin() ) {
|
||||
// Add dashboard "right now" functionality.
|
||||
add_action( 'right_now_content_table_end', array( 'WPLiveticker2_Admin', 'dashboard_right_now' ) );
|
||||
add_action( 'right_now_content_table_end', array( 'SCLiveticker_Admin', 'dashboard_right_now' ) );
|
||||
|
||||
// Settings.
|
||||
add_action( 'admin_init', array( 'WPLiveticker2_Admin', 'register_settings' ) );
|
||||
add_action( 'admin_menu', array( 'WPLiveticker2_Admin', 'register_settings_page' ) );
|
||||
add_action( 'admin_init', array( 'SCLiveticker_Admin', 'register_settings' ) );
|
||||
add_action( 'admin_menu', array( 'SCLiveticker_Admin', 'register_settings_page' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,20 +113,20 @@ class WPLiveticker2 {
|
||||
$labels = array(
|
||||
'name' => _x( 'Ticker', 'taxonomy general name' ),
|
||||
'singular_name' => _x( 'Ticker', 'taxonomy singular name' ),
|
||||
'search_items' => __( 'Search Tickers', 'wplt2' ),
|
||||
'all_items' => __( 'All Tickers', 'wplt2' ),
|
||||
'parent_item' => __( 'Parent Ticker', 'wplt2' ),
|
||||
'parent_item_colon' => __( 'Parent Ticker:', 'wplt2' ),
|
||||
'edit_item' => __( 'Edit Ticker', 'wplt2' ),
|
||||
'update_item' => __( 'Update Ticker', 'wplt2' ),
|
||||
'add_new_item' => __( 'Add New Ticker', 'wplt2' ),
|
||||
'new_item_name' => __( 'New Ticker', 'wplt2' ),
|
||||
'menu_name' => __( 'Ticker', 'wplt2' ),
|
||||
'search_items' => __( 'Search Tickers', 'stklcode-liveticker' ),
|
||||
'all_items' => __( 'All Tickers', 'stklcode-liveticker' ),
|
||||
'parent_item' => __( 'Parent Ticker', 'stklcode-liveticker' ),
|
||||
'parent_item_colon' => __( 'Parent Ticker:', 'stklcode-liveticker' ),
|
||||
'edit_item' => __( 'Edit Ticker', 'stklcode-liveticker' ),
|
||||
'update_item' => __( 'Update Ticker', 'stklcode-liveticker' ),
|
||||
'add_new_item' => __( 'Add New Ticker', 'stklcode-liveticker' ),
|
||||
'new_item_name' => __( 'New Ticker', 'stklcode-liveticker' ),
|
||||
'menu_name' => __( 'Ticker', 'stklcode-liveticker' ),
|
||||
);
|
||||
|
||||
register_taxonomy(
|
||||
'wplt2_ticker',
|
||||
array( 'wplt2_tick' ),
|
||||
'scliveticker_ticker',
|
||||
array( 'scliveticker_tick' ),
|
||||
array(
|
||||
'hierarchical' => true,
|
||||
'labels' => $labels,
|
||||
@ -139,19 +139,19 @@ class WPLiveticker2 {
|
||||
// Post type arguments.
|
||||
$args = array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Ticks', 'wplt2' ),
|
||||
'singular_name' => __( 'Tick', 'wplt2' ),
|
||||
'add_new' => __( 'Add New', 'wplt2' ),
|
||||
'add_new_item' => __( 'Add New Tick', 'wplt2' ),
|
||||
'edit_item' => __( 'Edit Tick', 'wplt2' ),
|
||||
'new_item' => __( 'New Tick', 'wplt2' ),
|
||||
'all_items' => __( 'All Ticks', 'wplt2' ),
|
||||
'view_item' => __( 'View Tick', 'wplt2' ),
|
||||
'search_items' => __( 'Search Ticks', 'wplt2' ),
|
||||
'not_found' => __( 'No Ticks found', 'wplt2' ),
|
||||
'not_found_in_trash' => __( 'No Ticks found in Trash', 'wplt2' ),
|
||||
'name' => __( 'Ticks', 'stklcode-liveticker' ),
|
||||
'singular_name' => __( 'Tick', 'stklcode-liveticker' ),
|
||||
'add_new' => __( 'Add New', 'stklcode-liveticker' ),
|
||||
'add_new_item' => __( 'Add New Tick', 'stklcode-liveticker' ),
|
||||
'edit_item' => __( 'Edit Tick', 'stklcode-liveticker' ),
|
||||
'new_item' => __( 'New Tick', 'stklcode-liveticker' ),
|
||||
'all_items' => __( 'All Ticks', 'stklcode-liveticker' ),
|
||||
'view_item' => __( 'View Tick', 'stklcode-liveticker' ),
|
||||
'search_items' => __( 'Search Ticks', 'stklcode-liveticker' ),
|
||||
'not_found' => __( 'No Ticks found', 'stklcode-liveticker' ),
|
||||
'not_found_in_trash' => __( 'No Ticks found in Trash', 'stklcode-liveticker' ),
|
||||
'parent_item_colon' => '',
|
||||
'menu_name' => __( 'Liveticker', 'wplt2' ),
|
||||
'menu_name' => __( 'Liveticker', 'stklcode-liveticker' ),
|
||||
),
|
||||
'public' => false,
|
||||
'publicly_queryable' => true,
|
||||
@ -160,11 +160,11 @@ class WPLiveticker2 {
|
||||
'menu_icon' => 'dashicons-rss',
|
||||
'capability_type' => 'post',
|
||||
'supports' => array( 'title', 'editor', 'author' ),
|
||||
'taxonomies' => array( 'wplt2_ticker' ),
|
||||
'taxonomies' => array( 'scliveticker_ticker' ),
|
||||
'has_archive' => true,
|
||||
);
|
||||
|
||||
register_post_type( 'wplt2_tick', $args );
|
||||
register_post_type( 'scliveticker_tick', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,21 +198,21 @@ class WPLiveticker2 {
|
||||
$show_feed = 1 === self::$_options['show_feed'];
|
||||
}
|
||||
|
||||
$output = '<ul class="wplt2-ticker';
|
||||
$output = '<ul class="sclt-ticker';
|
||||
if ( 1 === self::$_options['enable_ajax'] ) {
|
||||
$output .= ' wplt2-ticker-ajax" '
|
||||
. 'data-wplt2-ticker="' . $ticker . '" '
|
||||
. 'data-wplt2-limit="' . $limit . '" '
|
||||
. 'data-wplt2-last="' . time();
|
||||
$output .= ' sclt-ticker-ajax" '
|
||||
. 'data-sclt-ticker="' . $ticker . '" '
|
||||
. 'data-sclt-limit="' . $limit . '" '
|
||||
. 'data-sclt-last="' . time();
|
||||
}
|
||||
$output .= '">';
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'wplt2_tick',
|
||||
'post_type' => 'scliveticker_tick',
|
||||
'posts_per_page' => $limit,
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'wplt2_ticker',
|
||||
'taxonomy' => 'scliveticker_ticker',
|
||||
'field' => 'slug',
|
||||
'terms' => $ticker,
|
||||
),
|
||||
@ -230,11 +230,11 @@ class WPLiveticker2 {
|
||||
|
||||
// Show RSS feed link, if configured.
|
||||
if ( $show_feed ) {
|
||||
$feed_link = get_post_type_archive_feed_link( 'wplt2_tick' ) . '';
|
||||
$feed_link = get_post_type_archive_feed_link( 'scliveticker_tick' ) . '';
|
||||
if ( false === strpos( $feed_link, '&' ) ) {
|
||||
$feed_link .= '?wplt2_ticker=' . $ticker;
|
||||
$feed_link .= '?scliveticker_ticker=' . $ticker;
|
||||
} else {
|
||||
$feed_link .= '&wplt2_ticker=' . $ticker;
|
||||
$feed_link .= '&scliveticker_ticker=' . $ticker;
|
||||
}
|
||||
$output .= '<a href="' . esc_attr( $feed_link ) . '">Feed</a>';
|
||||
}
|
||||
@ -253,7 +253,7 @@ class WPLiveticker2 {
|
||||
if ( self::$shortcode_present || self::$widget_present ) {
|
||||
wp_enqueue_style(
|
||||
'wplt-css',
|
||||
WPLT2_BASE . 'styles/wp-liveticker2.min.css',
|
||||
SCLIVETICKER_BASE . 'styles/liveticker.min.css',
|
||||
'',
|
||||
self::VERSION, 'all'
|
||||
);
|
||||
@ -269,8 +269,8 @@ class WPLiveticker2 {
|
||||
// Only add if shortcode is present.
|
||||
if ( self::$shortcode_present || self::$widget_present ) {
|
||||
wp_enqueue_script(
|
||||
'wplt2-js',
|
||||
WPLT2_BASE . 'scripts/wp-liveticker2.min.js',
|
||||
'scliveticker-js',
|
||||
SCLIVETICKER_BASE . 'scripts/liveticker.min.js',
|
||||
array(),
|
||||
self::VERSION,
|
||||
true
|
||||
@ -278,11 +278,11 @@ class WPLiveticker2 {
|
||||
|
||||
// Add endpoint to script.
|
||||
wp_localize_script(
|
||||
'wplt2-js',
|
||||
'wplt2Ajax',
|
||||
'scliveticker-js',
|
||||
'sclivetickerAjax',
|
||||
array(
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wplt2_update-ticks' ),
|
||||
'nonce' => wp_create_nonce( 'scliveticker_update-ticks' ),
|
||||
'poll_interval' => self::$_options['poll_interval'] * 1000,
|
||||
)
|
||||
);
|
||||
@ -296,7 +296,7 @@ class WPLiveticker2 {
|
||||
*/
|
||||
public static function ajax_update() {
|
||||
// Verify AJAX nonce.
|
||||
check_ajax_referer( 'wplt2_update-ticks' );
|
||||
check_ajax_referer( 'scliveticker_update-ticks' );
|
||||
|
||||
// Extract update requests.
|
||||
if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) { // Input var okay.
|
||||
@ -320,11 +320,11 @@ class WPLiveticker2 {
|
||||
|
||||
// Query new ticks from DB.
|
||||
$query_args = array(
|
||||
'post_type' => 'wplt2_tick',
|
||||
'post_type' => 'scliveticker_tick',
|
||||
'posts_per_page' => $limit,
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'wplt2_ticker',
|
||||
'taxonomy' => 'scliveticker_ticker',
|
||||
'field' => 'slug',
|
||||
'terms' => $slug,
|
||||
),
|
||||
@ -417,10 +417,10 @@ class WPLiveticker2 {
|
||||
* @return string HTML code of tick.
|
||||
*/
|
||||
private static function tick_html( $time, $title, $content, $is_widget = false ) {
|
||||
return '<li class="wplt2-tick">'
|
||||
. '<p><span class="wplt2-tick_time">' . esc_html( $time ) . '</span>'
|
||||
. '<span class="wplt2-tick-title">' . esc_html( $title ) . '</span></p>'
|
||||
. '<p class="wplt2-tick-content">' . $content . '</p></li>';
|
||||
return '<li class="sclt-tick">'
|
||||
. '<p><span class="sclt-tick_time">' . esc_html( $time ) . '</span>'
|
||||
. '<span class="sclt-tick-title">' . esc_html( $title ) . '</span></p>'
|
||||
. '<p class="sclt-tick-content">' . $content . '</p></li>';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,11 +435,11 @@ class WPLiveticker2 {
|
||||
public static function tick_html_widget( $time, $title, $highlight ) {
|
||||
$out = '<li';
|
||||
if ( $highlight ) {
|
||||
$out .= ' class="wplt2-widget-new"';
|
||||
$out .= ' class="sclt-widget-new"';
|
||||
}
|
||||
return $out . '>'
|
||||
. '<span class="wplt2-widget-time">' . esc_html( $time ) . '</span>'
|
||||
. '<span class="wplt2-widget-title">' . $title . '</span>'
|
||||
. '<span class="sclt-widget-time">' . esc_html( $time ) . '</span>'
|
||||
. '<span class="sclt-widget-title">' . $title . '</span>'
|
||||
. '</li>';
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "wp-liveticker2",
|
||||
"name": "wp-liveticker",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple Liveticker for Wordpress.",
|
||||
"author": "Stefan Kalscheuer",
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="WPLiveticker2">
|
||||
<ruleset name="Liveticker">
|
||||
<description>Derived from WordPress Coding Standard</description>
|
||||
|
||||
<!-- Config arguments -->
|
||||
@ -7,7 +7,7 @@
|
||||
<arg name="colors"/>
|
||||
|
||||
<!-- Files to sniff -->
|
||||
<file>wp-liveticker2.php</file>
|
||||
<file>stklcode-liveticker.php</file>
|
||||
<file>includes</file>
|
||||
<file>views</file>
|
||||
|
||||
|
154
scripts/liveticker.js
Normal file
154
scripts/liveticker.js
Normal file
@ -0,0 +1,154 @@
|
||||
/**
|
||||
* Contructor of the scLiveticker object.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function scLiveticker() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize iveticker JS component.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
scLiveticker.init = function() {
|
||||
|
||||
// Opt out if AJAX pobject not present.
|
||||
if ( 'undefined' === typeof sclivetickerAjax ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract AJAX settings.
|
||||
scLiveticker.ajaxURL = sclivetickerAjax.ajax_url;
|
||||
scLiveticker.nonce = sclivetickerAjax.nonce;
|
||||
scLiveticker.pollInterval = sclivetickerAjax.poll_interval;
|
||||
|
||||
// Get ticker elements.
|
||||
scLiveticker.ticker = [].map.call(
|
||||
document.querySelectorAll( 'ul.sclt-ticker-ajax' ),
|
||||
function( elem ) {
|
||||
return {
|
||||
s: elem.getAttribute( 'data-sclt-ticker' ),
|
||||
l: elem.getAttribute( 'data-sclt-limit' ),
|
||||
t: elem.getAttribute( 'data-sclt-last' ),
|
||||
e: elem
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Get widget elements.
|
||||
scLiveticker.widgets = [].map.call(
|
||||
document.querySelectorAll( 'ul.sclt-widget-ajax' ),
|
||||
function( elem ) {
|
||||
return {
|
||||
w: elem.getAttribute( 'data-sclt-ticker' ),
|
||||
l: elem.getAttribute( 'data-sclt-limit' ),
|
||||
t: elem.getAttribute( 'data-sclt-last' ),
|
||||
e: elem
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Trigger update, if necessary.
|
||||
if ( ( 0 < scLiveticker.ticker.length || scLiveticker.widgets.length ) && 0 < scLiveticker.pollInterval ) {
|
||||
setTimeout( scLiveticker.update, scLiveticker.pollInterval );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update liveticker on current page via AJAX call.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
scLiveticker.update = function() {
|
||||
|
||||
// Extract ticker-slug, limit and timestamp of last poll.
|
||||
var updateReq = 'action=sclt_update-ticks&_ajax_nonce=' + scLiveticker.nonce;
|
||||
var i, j;
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
for ( i = 0; i < scLiveticker.ticker.length; i++ ) {
|
||||
updateReq = updateReq +
|
||||
'&update[' + i + '][s]=' + scLiveticker.ticker[ i ].s +
|
||||
'&update[' + i + '][l]=' + scLiveticker.ticker[ i ].l +
|
||||
'&update[' + i + '][t]=' + scLiveticker.ticker[ i ].t;
|
||||
}
|
||||
for ( j = 0; j < scLiveticker.widgets.length; j++ ) {
|
||||
updateReq = updateReq +
|
||||
'&update[' + ( i + j ) + '][w]=' + scLiveticker.widgets[ j ].w +
|
||||
'&update[' + ( i + j ) + '][l]=' + scLiveticker.widgets[ j ].l +
|
||||
'&update[' + ( i + j ) + '][t]=' + scLiveticker.widgets[ j ].t;
|
||||
}
|
||||
|
||||
// Issue AJAX request.
|
||||
xhr.open( 'POST', scLiveticker.ajaxURL, true );
|
||||
xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded;' );
|
||||
xhr.onreadystatechange = function() {
|
||||
var update;
|
||||
if ( XMLHttpRequest.DONE === this.readyState && 200 === this.status ) {
|
||||
try {
|
||||
update = JSON.parse( this.responseText );
|
||||
if ( update ) {
|
||||
update.forEach(
|
||||
function( u ) {
|
||||
scLiveticker.ticker.forEach(
|
||||
function( t ) {
|
||||
if ( t.s === u.s ) {
|
||||
t.t = u.t; // Update last poll timestamp.
|
||||
scLiveticker.updateHTML( t, u ); // Update HTML markup.
|
||||
}
|
||||
}
|
||||
);
|
||||
scLiveticker.widgets.forEach(
|
||||
function( t ) {
|
||||
if ( t.w === u.w ) {
|
||||
t.t = u.t;
|
||||
scLiveticker.updateHTML( t, u );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
setTimeout( scLiveticker.update, scLiveticker.pollInterval ); // Re-trigger update.
|
||||
} catch ( e ) {
|
||||
console.warn( 'Liveticker AJAX update failed, stopping automatic updates.' );
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send( updateReq );
|
||||
};
|
||||
|
||||
/**
|
||||
* Do actual update of HTML code.
|
||||
*
|
||||
* @param {Object} t Ticker or Widget reference.
|
||||
* @param {number} t.l Limit of entries to display.
|
||||
* @param {HTMLElement} t.e HTML element of the ticker/widget.
|
||||
* @param {Object} u Update entity.
|
||||
* @param {string} u.h HTML code to append.
|
||||
* @param {number} u.t Timetsamp of last update.
|
||||
* @return {void}
|
||||
*/
|
||||
scLiveticker.updateHTML = function( t, u ) {
|
||||
|
||||
// Prepend HTML of new ticks.
|
||||
t.e.innerHTML = u.h + t.e.innerHTML;
|
||||
t.e.setAttribute( 'data-sclt-last', u.t );
|
||||
|
||||
// Remove tail, if limit is set.
|
||||
if ( 0 < t.l ) {
|
||||
[].slice.call( t.e.getElementsByTagName( 'li' ), t.l ).forEach(
|
||||
function( li ) {
|
||||
li.remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
function() {
|
||||
scLiveticker.init(); // Trigger periodic update of livetickers.
|
||||
}
|
||||
);
|
@ -1,154 +0,0 @@
|
||||
/**
|
||||
* Contructor of the WPLT object.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function WPLT2() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize WP-Liveticker 2 JS component.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
WPLT2.init = function() {
|
||||
|
||||
// Opt out if AJAX pobject not present.
|
||||
if ( 'undefined' === typeof wplt2Ajax ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract AJAX settings.
|
||||
WPLT2.ajaxURL = wplt2Ajax.ajax_url;
|
||||
WPLT2.nonce = wplt2Ajax.nonce;
|
||||
WPLT2.pollInterval = wplt2Ajax.poll_interval;
|
||||
|
||||
// Get ticker elements.
|
||||
WPLT2.ticker = [].map.call(
|
||||
document.querySelectorAll( 'ul.wplt2-ticker-ajax' ),
|
||||
function( elem ) {
|
||||
return {
|
||||
s: elem.getAttribute( 'data-wplt2-ticker' ),
|
||||
l: elem.getAttribute( 'data-wplt2-limit' ),
|
||||
t: elem.getAttribute( 'data-wplt2-last' ),
|
||||
e: elem
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Get widget elements.
|
||||
WPLT2.widgets = [].map.call(
|
||||
document.querySelectorAll( 'ul.wplt2-widget-ajax' ),
|
||||
function( elem ) {
|
||||
return {
|
||||
w: elem.getAttribute( 'data-wplt2-ticker' ),
|
||||
l: elem.getAttribute( 'data-wplt2-limit' ),
|
||||
t: elem.getAttribute( 'data-wplt2-last' ),
|
||||
e: elem
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Trigger update, if necessary.
|
||||
if ( ( 0 < WPLT2.ticker.length || WPLT2.widgets.length ) && 0 < WPLT2.pollInterval ) {
|
||||
setTimeout( WPLT2.update, WPLT2.pollInterval );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update liveticker on current page via AJAX call.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
WPLT2.update = function() {
|
||||
|
||||
// Extract ticker-slug, limit and timestamp of last poll.
|
||||
var updateReq = 'action=wplt2_update-ticks&_ajax_nonce=' + WPLT2.nonce;
|
||||
var i, j;
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
for ( i = 0; i < WPLT2.ticker.length; i++ ) {
|
||||
updateReq = updateReq +
|
||||
'&update[' + i + '][s]=' + WPLT2.ticker[ i ].s +
|
||||
'&update[' + i + '][l]=' + WPLT2.ticker[ i ].l +
|
||||
'&update[' + i + '][t]=' + WPLT2.ticker[ i ].t;
|
||||
}
|
||||
for ( j = 0; j < WPLT2.widgets.length; j++ ) {
|
||||
updateReq = updateReq +
|
||||
'&update[' + ( i + j ) + '][w]=' + WPLT2.widgets[ j ].w +
|
||||
'&update[' + ( i + j ) + '][l]=' + WPLT2.widgets[ j ].l +
|
||||
'&update[' + ( i + j ) + '][t]=' + WPLT2.widgets[ j ].t;
|
||||
}
|
||||
|
||||
// Issue AJAX request.
|
||||
xhr.open( 'POST', WPLT2.ajaxURL, true );
|
||||
xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded;' );
|
||||
xhr.onreadystatechange = function() {
|
||||
var update;
|
||||
if ( XMLHttpRequest.DONE === this.readyState && 200 === this.status ) {
|
||||
try {
|
||||
update = JSON.parse( this.responseText );
|
||||
if ( update ) {
|
||||
update.forEach(
|
||||
function( u ) {
|
||||
WPLT2.ticker.forEach(
|
||||
function( t ) {
|
||||
if ( t.s === u.s ) {
|
||||
t.t = u.t; // Update last poll timestamp.
|
||||
WPLT2.updateHTML( t, u ); // Update HTML markup.
|
||||
}
|
||||
}
|
||||
);
|
||||
WPLT2.widgets.forEach(
|
||||
function( t ) {
|
||||
if ( t.w === u.w ) {
|
||||
t.t = u.t;
|
||||
WPLT2.updateHTML( t, u );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
setTimeout( WPLT2.update, WPLT2.pollInterval ); // Re-trigger update.
|
||||
} catch ( e ) {
|
||||
console.warn( 'WP-Liveticker 2 AJAX update failed, stopping automatic updates.' );
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send( updateReq );
|
||||
};
|
||||
|
||||
/**
|
||||
* Do actual update of HTML code.
|
||||
*
|
||||
* @param {Object} t Ticker or Widget reference.
|
||||
* @param {number} t.l Limit of entries to display.
|
||||
* @param {HTMLElement} t.e HTML element of the ticker/widget.
|
||||
* @param {Object} u Update entity.
|
||||
* @param {string} u.h HTML code to append.
|
||||
* @param {number} u.t Timetsamp of last update.
|
||||
* @return {void}
|
||||
*/
|
||||
WPLT2.updateHTML = function( t, u ) {
|
||||
|
||||
// Prepend HTML of new ticks.
|
||||
t.e.innerHTML = u.h + t.e.innerHTML;
|
||||
t.e.setAttribute( 'data-wplt2-last', u.t );
|
||||
|
||||
// Remove tail, if limit is set.
|
||||
if ( 0 < t.l ) {
|
||||
[].slice.call( t.e.getElementsByTagName( 'li' ), t.l ).forEach(
|
||||
function( li ) {
|
||||
li.remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
function() {
|
||||
WPLT2.init(); // Trigger periodic update of livetickers.
|
||||
}
|
||||
);
|
82
stklcode-liveticker.php
Normal file
82
stklcode-liveticker.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Liveticker
|
||||
*
|
||||
* @package Liveticker
|
||||
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||
* @license GPL-2.0+
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: Liveticker (by stklcode)
|
||||
* Description: A simple Liveticker for WordPress.
|
||||
* Version: 1.0.0
|
||||
* Author: Stefan Kalscheuer
|
||||
* Author URI: https://www.stklcode.de
|
||||
* Text Domain: stklcode-liveticker
|
||||
* License: GPLv2 or later
|
||||
*
|
||||
* Liveticker (by stklcode) is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Liveticker (by stklcode) is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Liveticker (by stklcode). If not, see http://www.gnu.org/licenses/gpl-2.0.html.
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Constants.
|
||||
define( 'SCLIVETICKER_FILE', __FILE__ );
|
||||
define( 'SCLIVETICKER_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'SCLIVETICKER_BASE', plugin_dir_url( __FILE__ ) );
|
||||
define( 'SCLIVETICKER_BASENAME', plugin_basename( __FILE__ ) );
|
||||
|
||||
// System Hooks.
|
||||
add_action( 'init', array( 'SCLiveticker', 'register_types' ) );
|
||||
add_action( 'plugins_loaded', array( 'SCLiveticker', 'init' ) );
|
||||
register_activation_hook( SCLIVETICKER_FILE, array( 'SCLiveticker_System', 'activate' ) );
|
||||
register_uninstall_hook( SCLIVETICKER_FILE, array( 'SCLiveticker_System', 'uninstall' ) );
|
||||
|
||||
// Allow shortcodes in widgets.
|
||||
add_filter( 'widget_text', 'do_shortcode' );
|
||||
|
||||
// Add shortcode.
|
||||
add_shortcode( 'liveticker', array( 'SCLiveticker', 'shortcode_ticker_show' ) );
|
||||
|
||||
// Add Widget.
|
||||
add_action( 'widgets_init', array( 'SCLiveticker_Widget', 'register' ) );
|
||||
|
||||
// Autoload.
|
||||
spl_autoload_register( 'scliveticker_autoload' );
|
||||
|
||||
/**
|
||||
* Autoloader for Liveticker classes.
|
||||
*
|
||||
* @param string $class Name of the class to load.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function scliveticker_autoload( $class ) {
|
||||
$plugin_classes = array(
|
||||
'SCLiveticker',
|
||||
'SCLiveticker_Admin',
|
||||
'SCLiveticker_System',
|
||||
'SCLiveticker_Widget',
|
||||
);
|
||||
if ( in_array( $class, $plugin_classes, true ) ) {
|
||||
require_once sprintf(
|
||||
'%s/includes/class-%s.php',
|
||||
SCLIVETICKER_DIR,
|
||||
strtolower( str_replace( '_', '-', $class ) )
|
||||
);
|
||||
}
|
||||
}
|
@ -1,59 +1,59 @@
|
||||
ul.wplt2-ticker {
|
||||
ul.sclt-ticker {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
ul.wplt2-ticker > li.wplt2-tick {
|
||||
ul.sclt-ticker > li.sclt-tick {
|
||||
background-color: #f5f5f5;
|
||||
list-style-type: none;
|
||||
margin: 0.1em;
|
||||
padding: 0.1em 0.3em;
|
||||
}
|
||||
|
||||
li.wplt2-tick p {
|
||||
li.sclt-tick p {
|
||||
margin: 0.3em;
|
||||
}
|
||||
|
||||
span.wplt2-tick-time {
|
||||
span.sclt-tick-time {
|
||||
color: #002c58;
|
||||
font-size: 0.7em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.wplt2-tick-title {
|
||||
span.sclt-tick-title {
|
||||
color: #002c58;
|
||||
font-weight: 700;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
p.wplt2-tick-content {
|
||||
p.sclt-tick-content {
|
||||
margin-top: -0.7em;
|
||||
text-indent: 0.5em;
|
||||
}
|
||||
|
||||
ul.wplt2-widget {
|
||||
ul.sclt-widget {
|
||||
list-style-type: none;
|
||||
margin-top: -0.5em;
|
||||
}
|
||||
|
||||
ul.wplt2-widget li {
|
||||
ul.sclt-widget li {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
span.wplt2-widget-time {
|
||||
span.sclt-widget-time {
|
||||
font-size: 0.7em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.wplt2-widget-content {
|
||||
span.sclt-widget-content {
|
||||
color: #002c58;
|
||||
text-indent: 0.2em;
|
||||
}
|
||||
|
||||
span.wplt2-widget-content-new {
|
||||
span.sclt-widget-content-new {
|
||||
color: #800000;
|
||||
text-indent: 0.2em;
|
||||
}
|
||||
|
||||
p.wplt2-widget-link {
|
||||
p.sclt-widget-link {
|
||||
text-align: right;
|
||||
}
|
@ -1,26 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Settings page.
|
||||
* Liveticker: Settings page.
|
||||
*
|
||||
* This file contains the view model for the Plugin settings oage.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class="wrap">
|
||||
<div id="icon-options-general" class="icon32"><br></div>
|
||||
<h2>Liveticker <?php esc_html_e( 'Settings', 'wplt2' ); ?></h2>
|
||||
<h2>Liveticker <?php esc_html_e( 'Settings', 'stklcode-liveticker' ); ?></h2>
|
||||
<?php
|
||||
if ( isset( $_GET['settings-updated'] ) ) { // phpcs:ignore
|
||||
echo '<div class="updated"><p>' . esc_html__( 'Settings updated successfully.', 'wplt2' ) . '</p></div>';
|
||||
echo '<div class="updated"><p>' . esc_html__( 'Settings updated successfully.', 'stklcode-liveticker' ) . '</p></div>';
|
||||
}
|
||||
?>
|
||||
<form action="options.php" method="post">
|
||||
<?php
|
||||
settings_fields( 'wplt2_settings' );
|
||||
do_settings_sections( 'wplt2-settings-page' );
|
||||
settings_fields( 'scliveticker_settings' );
|
||||
do_settings_sections( 'scliveticker-settings-page' );
|
||||
submit_button();
|
||||
?>
|
||||
</form>
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2: Widget form.
|
||||
* Liveticker: Widget form.
|
||||
*
|
||||
* This file contains the view model for the Widget settings form.
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @package Liveticker
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
@ -20,7 +22,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_html( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Ticker:', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_html( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Ticker:', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
|
||||
@ -38,7 +40,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php esc_html_e( 'Number of Ticks:', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php esc_html_e( 'Number of Ticks:', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>">
|
||||
@ -49,7 +51,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
}
|
||||
?>
|
||||
>
|
||||
<?php esc_html_e( 'all', 'wplt2' ); ?>
|
||||
<?php esc_html_e( 'all', 'stklcode-liveticker' ); ?>
|
||||
</option>
|
||||
<?php
|
||||
for ( $i = 1; $i <= 10; $i ++ ) {
|
||||
@ -66,7 +68,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link (optional):', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link (optional):', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" type="text" value="<?php echo esc_attr( $link ); ?>" />
|
||||
@ -74,7 +76,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'highlight' ) ); ?>"><?php esc_html_e( 'Highlight new:', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'highlight' ) ); ?>"><?php esc_html_e( 'Highlight new:', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
@ -88,7 +90,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'highlight_time' ) ); ?>"><?php esc_html_e( 'Highlight time [s]:', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'highlight_time' ) ); ?>"><?php esc_html_e( 'Highlight time [s]:', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'highlight_time' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'highlight_time' ) ); ?>" type="text" value="<?php echo esc_html( $highlight_time ); ?>" />
|
||||
@ -96,7 +98,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'ajax' ) ); ?>"><?php esc_html_e( 'Auto refresh:', 'wplt2' ); ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'ajax' ) ); ?>"><?php esc_html_e( 'Auto refresh:', 'stklcode-liveticker' ); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
@ -108,7 +110,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
' . ( ( '1' === $ajax ) ? ' checked' : '' ) . '/>';
|
||||
|
||||
?>
|
||||
<small><?php esc_html_e( '(enables ajax)', 'wplt2' ); ?></small>
|
||||
<small><?php esc_html_e( '(enables ajax)', 'stklcode-liveticker' ); ?></small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Liveticker 2
|
||||
*
|
||||
* @package WPLiveticker2
|
||||
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||
* @license GPL-2.0+
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: WP Liveticker 2
|
||||
* Description: A simple Liveticker for WordPress.
|
||||
* Version: 1.0.0
|
||||
* Author: Stefan Kalscheuer
|
||||
* Author URI: https://www.stklcode.de
|
||||
* Text Domain: wplt2
|
||||
* License: GPLv2 or later
|
||||
*
|
||||
* WP Liveticker 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* WP Liveticker 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WP Liveticker 2. If not, see http://www.gnu.org/licenses/gpl-2.0.html.
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Constants.
|
||||
define( 'WPLT2_FILE', __FILE__ );
|
||||
define( 'WPLT2_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'WPLT2_BASE', plugin_dir_url( __FILE__ ) );
|
||||
define( 'WPLT2_BASENAME', plugin_basename( __FILE__ ) );
|
||||
|
||||
// System Hooks.
|
||||
add_action( 'init', array( 'WPLiveticker2', 'register_types' ) );
|
||||
add_action( 'plugins_loaded', array( 'WPLiveticker2', 'init' ) );
|
||||
register_activation_hook( WPLT2_FILE, array( 'WPLiveticker2_System', 'activate' ) );
|
||||
register_uninstall_hook( WPLT2_FILE, array( 'WPLiveticker2_System', 'uninstall' ) );
|
||||
|
||||
// Allow shortcodes in widgets.
|
||||
add_filter( 'widget_text', 'do_shortcode' );
|
||||
|
||||
// Add shortcode.
|
||||
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
|
||||
|
||||
// Add Widget.
|
||||
add_action( 'widgets_init', array( 'WPLiveticker2_Widget', 'register' ) );
|
||||
|
||||
// Autoload.
|
||||
spl_autoload_register( 'wplt2_autoload' );
|
||||
|
||||
/**
|
||||
* Autoloader for StatifyBlacklist classes.
|
||||
*
|
||||
* @param string $class Name of the class to load.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt2_autoload( $class ) {
|
||||
$plugin_classes = array(
|
||||
'WPLiveticker2',
|
||||
'WPLiveticker2_Admin',
|
||||
'WPLiveticker2_System',
|
||||
'WPLiveticker2_Widget',
|
||||
);
|
||||
if ( in_array( $class, $plugin_classes, true ) ) {
|
||||
require_once sprintf(
|
||||
'%s/includes/class-%s.php',
|
||||
WPLT2_DIR,
|
||||
strtolower( str_replace( '_', '-', $class ) )
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user