Begin transformation into classes
Grouped single PHP files with various funcitons into classes for basic, admin and system scope.
This commit is contained in:
parent
85ca371fa5
commit
f831027aec
61
Gulpfile.js
Normal file
61
Gulpfile.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var clean = require('gulp-clean');
|
||||||
|
var copy = require('gulp-copy');
|
||||||
|
var zip = require('gulp-zip');
|
||||||
|
var composer = require('gulp-composer');
|
||||||
|
var phpunit = require('gulp-phpunit');
|
||||||
|
var exec = require('child_process').exec;
|
||||||
|
var phpcs = require('gulp-phpcs');
|
||||||
|
var config = require('./package.json');
|
||||||
|
|
||||||
|
// Clean the target directory.
|
||||||
|
gulp.task('clean', function () {
|
||||||
|
console.log('Cleaning up target directory ...');
|
||||||
|
return gulp.src('dist', {read: false})
|
||||||
|
.pipe(clean());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prepare composer.
|
||||||
|
gulp.task('compose', function () {
|
||||||
|
console.log('Preparing Composer ...');
|
||||||
|
return composer('install');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Execute unit tests.
|
||||||
|
gulp.task('test', ['compose'], function () {
|
||||||
|
console.log('Running PHPUnit tests ...');
|
||||||
|
return gulp.src('phpunit.xml')
|
||||||
|
.pipe(phpunit('./vendor/bin/phpunit', {debug: false}));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Execute PHP Code Sniffer.
|
||||||
|
gulp.task('test-cs', function (cb) {
|
||||||
|
return exec('./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs', function (err, stdout, stderr) {
|
||||||
|
console.log(stdout);
|
||||||
|
console.log(stderr);
|
||||||
|
if (null === err) {
|
||||||
|
console.log('Running PHP Code Sniffer tests ...');
|
||||||
|
gulp.src(['statify-blacklist.php', 'inc/**/*.php'])
|
||||||
|
.pipe(phpcs({bin: './vendor/bin/phpcs', standard: 'phpcs.xml'}))
|
||||||
|
.pipe(phpcs.reporter('log'));
|
||||||
|
}
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bundle files as required for plugin distribution..
|
||||||
|
gulp.task('bundle', ['clean'], function () {
|
||||||
|
console.log('Collecting files for package dist/' + config.name + config.version + ' ...');
|
||||||
|
return gulp.src(['**/*.php', '!test/**', '!vendor/**', 'README.md', 'LICENSE.md'], {base: './'})
|
||||||
|
.pipe(copy('./dist/' + config.name + '.' + config.version + '/' + config.name));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a ZIP package of the relevant files for plugin distribution.
|
||||||
|
gulp.task('package', ['bundle'], function () {
|
||||||
|
console.log('Building package dist/' + config.name + config.version + '.zip ...');
|
||||||
|
return gulp.src('./dist/' + config.name + '.' + config.version + '/**')
|
||||||
|
.pipe(zip(config.name + '.' + config.version + '.zip'))
|
||||||
|
.pipe(gulp.dest('./dist'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('default', ['clean', 'compose', 'test', 'test-cs', 'bundle', 'package']);
|
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Dashboard
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Exit if accessed directly
|
|
||||||
if ( !defined( 'ABSPATH' ) ) exit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to Right Now Widget
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function wplt_dashboard_right_now() {
|
|
||||||
$total_files = wp_count_posts( 'wplt_tick' );
|
|
||||||
|
|
||||||
echo '<tr>';
|
|
||||||
echo '<td class="first b b-tags"><a href="edit.php?post_type=wplt_tick">' . $total_files->publish . '</a></td>';
|
|
||||||
echo '<td class="t tags"><a href="edit.php?post_type=wplt_tick">' . __( 'Ticks', 'wplt2' ) . '</a></td>';
|
|
||||||
echo '</tr>';
|
|
||||||
}
|
|
||||||
add_action( 'right_now_content_table_end' , 'wplt_dashboard_right_now' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register dashboard widgets
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function wplt_register_dashboard_widgets() {
|
|
||||||
wp_add_dashboard_widget( 'wplt_dashboard_downloads', __( 'Download Stats', 'wplt2' ), 'wplt_dashboard_downloads_widget' );
|
|
||||||
}
|
|
||||||
//add_action( 'wp_dashboard_setup', 'wplt_register_dashboard_widgets' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ticks Dashboard Widget
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @since 1.0
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function wplt_dashboard_ticks_widget() {
|
|
||||||
echo 'Content to follow...';
|
|
||||||
}
|
|
32
includes/class-wpliveticker2-admin.php
Normal file
32
includes/class-wpliveticker2-admin.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2: Plugin admin class.
|
||||||
|
*
|
||||||
|
* This file contains the derived class for the plugin's administration features.
|
||||||
|
*
|
||||||
|
* @package WPLiveticker2
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2 admin configuration.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class WPLiveticker2_Admin extends WPLiveticker2 {
|
||||||
|
/**
|
||||||
|
* Add to Right Now Widget
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function dashboard_right_now() {
|
||||||
|
$total_files = wp_count_posts( 'wplt2_tick' );
|
||||||
|
|
||||||
|
echo '<tr>';
|
||||||
|
echo '<td class="first b b-tags"><a href="edit.php?post_type=wplt_tick">' . $total_files->publish . '</a></td>';
|
||||||
|
echo '<td class="t tags"><a href="edit.php?post_type=wplt_tick">' . __( 'Ticks', 'wplt2' ) . '</a></td>';
|
||||||
|
echo '</tr>';
|
||||||
|
}
|
||||||
|
}
|
41
includes/class-wpliveticker2-system.php
Normal file
41
includes/class-wpliveticker2-system.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2: Plugin system class.
|
||||||
|
*
|
||||||
|
* This file contains the derived class for the plugin's system operations.
|
||||||
|
*
|
||||||
|
* @package WPLiveticker2
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2 system configuration.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class WPLiveticker2_System extends WPLiveticker2 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activation hook.
|
||||||
|
*
|
||||||
|
* Initializes default options.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function activate() {
|
||||||
|
// Load current options.
|
||||||
|
self::update_options();
|
||||||
|
|
||||||
|
// Add default settings to database.
|
||||||
|
$defaults = self::default_options();
|
||||||
|
|
||||||
|
if ( self::$_options['reset_settings'] ) {
|
||||||
|
// Reset requested, overwrite existing options with default.
|
||||||
|
update_option( self::OPTION, $defaults );
|
||||||
|
} else {
|
||||||
|
// Otherwise add new options.
|
||||||
|
add_option( self::OPTION, $defaults );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
211
includes/class-wpliveticker2.php
Normal file
211
includes/class-wpliveticker2.php
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2: Plugin main class.
|
||||||
|
*
|
||||||
|
* This file contains the plugin's base class.
|
||||||
|
*
|
||||||
|
* @package WPLiveticker2
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WP Liveticker 2.
|
||||||
|
*/
|
||||||
|
class WPLiveticker2 {
|
||||||
|
/**
|
||||||
|
* Options tag.
|
||||||
|
*
|
||||||
|
* @var string OPTIONS
|
||||||
|
*/
|
||||||
|
const OPTION = 'wplt2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin options.
|
||||||
|
*
|
||||||
|
* @var array $_options
|
||||||
|
*/
|
||||||
|
protected static $_options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin options.
|
||||||
|
*
|
||||||
|
* @var boolean $shortcode_present
|
||||||
|
*/
|
||||||
|
protected static $shortcode_present = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin initialization.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
// Skip on autosave or AJAX.
|
||||||
|
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load plugin options.
|
||||||
|
self::update_options();
|
||||||
|
|
||||||
|
// Load Textdomain.
|
||||||
|
load_plugin_textdomain( 'wplt2', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
|
||||||
|
|
||||||
|
// Allow shortcodes in widgets.
|
||||||
|
add_filter( 'widget_text', 'do_shortcode' );
|
||||||
|
|
||||||
|
// Add shortcode.
|
||||||
|
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
|
||||||
|
|
||||||
|
// Admin only actions.
|
||||||
|
if ( is_admin() ) {
|
||||||
|
// Add dashboard "right now" functionality.
|
||||||
|
add_action( 'right_now_content_table_end', array( 'WPLiveticker2_Admin', 'dashboard_right_now' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register tick post type.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function register_types() {
|
||||||
|
// Add new taxonomy, make it hierarchical (like categories).
|
||||||
|
$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' ),
|
||||||
|
);
|
||||||
|
|
||||||
|
register_taxonomy(
|
||||||
|
'wplt2_ticker',
|
||||||
|
array( 'wplt2_tick' ),
|
||||||
|
array(
|
||||||
|
'hierarchical' => true,
|
||||||
|
'labels' => $labels,
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_admin_column' => true,
|
||||||
|
'query_var' => true,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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' ),
|
||||||
|
'parent_item_colon' => '',
|
||||||
|
'menu_name' => __( 'Liveticker', 'wplt2' ),
|
||||||
|
),
|
||||||
|
'public' => false,
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_in_menu' => true,
|
||||||
|
'menu_icon' => 'dashicons-rss',
|
||||||
|
'capability_type' => 'post',
|
||||||
|
'supports' => array( 'title', 'editor', 'author' ),
|
||||||
|
'taxonomies' => array( 'wplt2_ticker' ),
|
||||||
|
);
|
||||||
|
|
||||||
|
register_post_type( 'wplt2_tick', $args );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output Liveticker
|
||||||
|
*
|
||||||
|
* @param array $atts Shortcode attributes.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function shortcode_ticker_show( $atts ) {
|
||||||
|
// Indicate presence of shortcode (to enqueue styles/scripts later).
|
||||||
|
self::$shortcode_present = true;
|
||||||
|
|
||||||
|
// Initialize output.
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
// Check if first attribute is filled.
|
||||||
|
if ( $atts['ticker'] ) {
|
||||||
|
// Set limit to infinite, if not set explicitly.
|
||||||
|
if ( ! isset( $atts['limit'] ) ) {
|
||||||
|
$atts['limit'] = - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = '<ul class="wplt2_ticker">';
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'wplt2_tick',
|
||||||
|
'posts_per_page' => $atts['limit'],
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'wplt2_ticker',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $atts['ticker'],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$wp_query = new WP_Query( $args );
|
||||||
|
|
||||||
|
while ( $wp_query->have_posts() ) {
|
||||||
|
$wp_query->the_post();
|
||||||
|
$output .= '<li class="wplt2_tick">
|
||||||
|
<p><span class="wplt2_tick_time">' . get_the_time( 'd.m.Y H.i' ) . '</span>
|
||||||
|
<span class="wplt2_tick_title">' . get_the_title() . '</span></p>
|
||||||
|
<p class="wplt2_tick_content">' . get_the_content() . '</p></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</ul>';
|
||||||
|
|
||||||
|
// Show RSS feed link, if configured.
|
||||||
|
if (1 === self::$_options['show_feed']) {
|
||||||
|
$output .= '<a href="/feed/liveticker/' . esc_html( $atts['ticker'] ) . '"><img class="wplt2_rss" src="/wp-content/plugins/wp-liveticker2/images/rss.jpg" alt="RSS" /></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update options.
|
||||||
|
*
|
||||||
|
* @param array $options Optional. New options to save.
|
||||||
|
*/
|
||||||
|
protected static function update_options( $options = null ) {
|
||||||
|
self::$_options = wp_parse_args(
|
||||||
|
get_option( self::OPTION ),
|
||||||
|
self::default_options()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create default plugin configuration.
|
||||||
|
*
|
||||||
|
* @return array The options array.
|
||||||
|
*/
|
||||||
|
protected static function default_options() {
|
||||||
|
return array(
|
||||||
|
'enable_ajax' => 1,
|
||||||
|
'enable_css' => 1,
|
||||||
|
'show_feed' => 0,
|
||||||
|
'reset_settings' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Exit if accessed directly
|
|
||||||
if ( !defined( 'ABSPATH' ) ) exit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns default options
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function wplt_get_default_options() {
|
|
||||||
return array(
|
|
||||||
'enable_css' => 1,
|
|
||||||
'reset_settings' => 0,
|
|
||||||
'shortcode_present' => false
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Post Types
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Exit if accessed directly
|
|
||||||
if ( !defined( 'ABSPATH' ) ) exit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register tick post type
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function wplt_tick_post_type() {
|
|
||||||
$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' ),
|
|
||||||
'parent_item_colon' => '',
|
|
||||||
'menu_name' => __( 'Liveticker', 'wplt2' )
|
|
||||||
),
|
|
||||||
'public' => false,
|
|
||||||
'show_ui' => true,
|
|
||||||
'show_in_menu' => true,
|
|
||||||
'menu_icon' => 'dashicons-rss',
|
|
||||||
'capability_type' => 'post',
|
|
||||||
'supports' => array( 'title', 'editor', 'author'),
|
|
||||||
'taxonomies' => array('wplt_ticker')
|
|
||||||
);
|
|
||||||
|
|
||||||
register_post_type( 'wplt_tick', $args );
|
|
||||||
}
|
|
||||||
add_action( 'init', 'wplt_tick_post_type' );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register custom taxamony (category)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
//hook into the init action and call create_book_taxonomies when it fires
|
|
||||||
add_action( 'init', 'wplt_ticker_taxonomy', 0 );
|
|
||||||
|
|
||||||
//create two taxonomies, genres and writers for the post type "book"
|
|
||||||
function wplt_ticker_taxonomy()
|
|
||||||
{
|
|
||||||
// Add new taxonomy, make it hierarchical (like categories)
|
|
||||||
$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' ),
|
|
||||||
);
|
|
||||||
|
|
||||||
register_taxonomy('wplt_ticker',array('wplt_tick'), array(
|
|
||||||
'hierarchical' => true,
|
|
||||||
'labels' => $labels,
|
|
||||||
'show_ui' => true,
|
|
||||||
'show_admin_column' => true,
|
|
||||||
'query_var' => true,
|
|
||||||
));
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Shortcodes
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Exit if accessed directly
|
|
||||||
if ( !defined( 'ABSPATH' ) ) exit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow shortcodes in widgets
|
|
||||||
*/
|
|
||||||
add_filter( 'widget_text', 'do_shortcode' );
|
|
||||||
add_filter( 'wp_ajax_get_new_ticks', array( $this, 'wplt_ajax_get_new_ticks' ) );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output Liveticker
|
|
||||||
*
|
|
||||||
* @param array atts shortcode options
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function wplt_shortcode_ticker_show( $atts ) {
|
|
||||||
global $wplt_options;
|
|
||||||
|
|
||||||
$wplt_options['shortcode_present'] = true;
|
|
||||||
|
|
||||||
/*$wplt_ticker_options = array();
|
|
||||||
|
|
||||||
extract(
|
|
||||||
shortcode_atts( array(
|
|
||||||
'id' => $wplt_ticker_options['id'],
|
|
||||||
'count' => $wplt_ticker_options['count'],
|
|
||||||
'order' => $wplt_ticker_options['order']
|
|
||||||
), $atts )
|
|
||||||
);*/
|
|
||||||
|
|
||||||
if($atts[0])
|
|
||||||
{
|
|
||||||
if(!$atts[1]) $atts[1] = -1;
|
|
||||||
|
|
||||||
$output = '<ul class="wplt_ticker">';
|
|
||||||
|
|
||||||
$args = array( 'post_type' => 'wplt_tick',
|
|
||||||
'posts_per_page' => $atts[1],
|
|
||||||
'tax_query' => array(
|
|
||||||
array( 'taxonomy' => 'wplt_ticker',
|
|
||||||
'field' => 'slug',
|
|
||||||
'terms' => $atts[0]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$wp_query = new WP_Query($args);
|
|
||||||
|
|
||||||
while ($wp_query->have_posts()) : $wp_query->the_post();
|
|
||||||
$output .= '<li class="wplt_tick">
|
|
||||||
<p><span class="wplt_tick_time">'.get_the_time('d.m.Y H.i').'</span>
|
|
||||||
<span class="wplt_tick_title">'.get_the_title().'</span></p>
|
|
||||||
<p class="wplt_tick_content">'.get_the_content().'</p></li>';
|
|
||||||
endwhile;
|
|
||||||
|
|
||||||
$output .= '</ul>';
|
|
||||||
$output .= '<a href="/feed/liveticker/lager-live"><img class="wplt_rss" src="/wp-content/plugins/wp-liveticker2/images/rss.jpg" alt="RSS" /></a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_shortcode( 'liveticker', 'wplt_shortcode_ticker_show' );
|
|
@ -1,128 +1,192 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class wplt_widget extends WP_Widget {
|
class wplt_widget extends WP_Widget {
|
||||||
function wplt_widget() {
|
function __construct() {
|
||||||
parent::WP_Widget( false, $name = 'Liveticker' );
|
parent::__construct( false, $name = 'Liveticker' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function widget( $args, $instance ) {
|
function widget( $args, $instance ) {
|
||||||
extract( $args );
|
extract( $args );
|
||||||
$title = apply_filters( 'wplt_catlit', $instance['title'] );
|
$title = apply_filters( 'wplt_catlit', $instance['title'] );
|
||||||
$category = apply_filters( 'wplt_catlit', $instance['category'] );
|
$category = apply_filters( 'wplt_catlit', $instance['category'] );
|
||||||
$count = apply_filters( 'wplt_catlit', $instance['count'] );
|
$count = apply_filters( 'wplt_catlit', $instance['count'] );
|
||||||
$link = apply_filters( 'wplt_catlit', $instance['link'] );
|
$link = apply_filters( 'wplt_catlit', $instance['link'] );
|
||||||
$highlight = apply_filters( 'wplt_catlit', $instance['highlight'] );
|
$highlight = apply_filters( 'wplt_catlit', $instance['highlight'] );
|
||||||
$highlight_time = apply_filters( 'wplt_catlit', $instance['highlight_time'] );
|
$highlight_time = apply_filters( 'wplt_catlit', $instance['highlight_time'] );
|
||||||
$ajax = apply_filters( 'wplt_catlit', $instance['ajax'] );
|
$ajax = apply_filters( 'wplt_catlit', $instance['ajax'] );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($title) {
|
if ( $title ) {
|
||||||
echo $before_title . $title . $after_title;
|
echo $before_title . $title . $after_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
<ul class="wplt_widget">
|
|
||||||
<?php
|
|
||||||
$args = array( 'post_type' => 'wplt_tick',
|
|
||||||
'tax_query' => array(
|
|
||||||
array( 'taxonomy' => 'wplt_ticker',
|
|
||||||
'field' => 'slug',
|
|
||||||
'terms' => $category,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$wp_query = new WP_Query($args);
|
?>
|
||||||
while ($wp_query->have_posts()) : $wp_query->the_post();
|
<ul class="wplt_widget">
|
||||||
?>
|
<?php
|
||||||
<li><span class="wplt_widget_time"><?php echo get_the_time('d.m.Y - H.i'); ?></span><span class="wplt_widget_content<?php if($highlight=="1" && get_the_time('U') > (time()-$highlight_time)) echo '_new'; ?>"><br /><?php echo the_title(); ?></span></li>
|
$args = array(
|
||||||
<?php
|
'post_type' => 'wplt_tick',
|
||||||
if( $count > 0 && ++$cnt == $count ) break;
|
'tax_query' => array(
|
||||||
endwhile;
|
array(
|
||||||
?>
|
'taxonomy' => 'wplt_ticker',
|
||||||
</ul>
|
'field' => 'slug',
|
||||||
|
'terms' => $category,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
<?php
|
$wp_query = new WP_Query( $args );
|
||||||
if ($link)
|
while ( $wp_query->have_posts() ) : $wp_query->the_post();
|
||||||
print '<p class="wplt_widget_link"><a href="'.$link.'">'.__( 'show all', 'wplt2' ).'...</a></p>';
|
?>
|
||||||
|
<li>
|
||||||
echo $after_widget;
|
<span class="wplt_widget_time"><?php echo get_the_time( 'd.m.Y - H.i' ); ?></span><span class="wplt_widget_content<?php if ( $highlight == "1" && get_the_time( 'U' ) > ( time() - $highlight_time ) ) {
|
||||||
?>
|
echo '_new';
|
||||||
<?php
|
} ?>"><br /><?php echo the_title(); ?></span></li>
|
||||||
}
|
<?php
|
||||||
|
if ( $count > 0 && ++ $cnt == $count ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
endwhile;
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
function update( $new_instance, $old_instance ) {
|
<?php
|
||||||
return $new_instance;
|
if ( $link ) {
|
||||||
}
|
print '<p class="wplt_widget_link"><a href="' . $link . '">' . __( 'show all', 'wplt2' ) . '...</a></p>';
|
||||||
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
echo $after_widget;
|
||||||
$title = esc_attr( $instance['title'] );
|
?>
|
||||||
$category = esc_attr( $instance['category'] );
|
<?php
|
||||||
$count = esc_attr( $instance['count'] );
|
}
|
||||||
$link = esc_attr( $instance['link'] );
|
|
||||||
$highlight = esc_attr( $instance['highlight'] );
|
function update( $new_instance, $old_instance ) {
|
||||||
$highlight_time = esc_attr( $instance['highlight_time'] );
|
return $new_instance;
|
||||||
$ajax = esc_attr( $instance['ajax'] );
|
}
|
||||||
$categories = get_terms('wplt_ticker', 'orderby=name&order=ASC');
|
|
||||||
?>
|
function form( $instance ) {
|
||||||
|
$title = esc_attr( $instance['title'] );
|
||||||
<table>
|
$category = esc_attr( $instance['category'] );
|
||||||
<tr>
|
$count = esc_attr( $instance['count'] );
|
||||||
<td><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label></td>
|
$link = esc_attr( $instance['link'] );
|
||||||
<td><input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></td>
|
$highlight = esc_attr( $instance['highlight'] );
|
||||||
</tr>
|
$highlight_time = esc_attr( $instance['highlight_time'] );
|
||||||
<tr>
|
$ajax = esc_attr( $instance['ajax'] );
|
||||||
<td> <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Ticker:', 'wplt2' ); ?></label></td>
|
$categories = get_terms( 'wplt_ticker', 'orderby=name&order=ASC' );
|
||||||
<td>
|
?>
|
||||||
<select id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
|
|
||||||
<?php foreach ($categories as $cat) {
|
<table>
|
||||||
echo '<option value="'.$cat->slug.'"'; if($category==$cat->slug) echo ' selected="selected"'; echo '>'.$cat->name.'</option>';
|
<tr>
|
||||||
} ?>
|
<td><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label></td>
|
||||||
</select>
|
<td>
|
||||||
</td>
|
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of Ticks:', 'wplt2' ); ?></label></td>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>">
|
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Ticker:', 'wplt2' ); ?></label>
|
||||||
<option value="0"<?php if($count==0) echo ' selected="selected"' ?>><?php _e('all','wplt2');?></option>
|
</td>
|
||||||
<option value="1"<?php if($count==1) echo ' selected="selected"' ?>>1</option><option value="2"<?php if($count==2) echo ' selected="selected"' ?>>2</option>
|
<td>
|
||||||
<option value="3"<?php if($count==3) echo ' selected="selected"' ?>>3</option><option value="4"<?php if($count==4) echo ' selected="selected"' ?>>4</option>
|
<select id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
|
||||||
<option value="5"<?php if($count==5) echo ' selected="selected"' ?>>5</option><option value="6"<?php if($count==6) echo ' selected="selected"' ?>>6</option>
|
<?php foreach ( $categories as $cat ) {
|
||||||
<option value="7"<?php if($count==7) echo ' selected="selected"' ?>>7</option><option value="8"<?php if($count==8) echo ' selected="selected"' ?>>8</option>
|
echo '<option value="' . $cat->slug . '"';
|
||||||
<option value="9"<?php if($count==9) echo ' selected="selected"' ?>>9</option><option value="10"<?php if($count==10) echo ' selected="selected"' ?>>10</option>
|
if ( $category == $cat->slug ) {
|
||||||
</select>
|
echo ' selected="selected"';
|
||||||
</td>
|
}
|
||||||
</tr>
|
echo '>' . $cat->name . '</option>';
|
||||||
<tr>
|
} ?>
|
||||||
<td><label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link (optional):', 'wplt2' ); ?></label></td>
|
</select>
|
||||||
<td><input class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" type="text" value="<?php echo $link; ?>" /></td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="<?php echo $this->get_field_id( 'highlight' ); ?>"><?php _e( 'Highlight new:', 'wplt2' ); ?></label></td>
|
<td>
|
||||||
<td><input class="widefat" id="<?php echo $this->get_field_id( 'highlight' ); ?>" name="<?php echo $this->get_field_name( 'highlight' ); ?>" type="checkbox" value="1" <?php if($highlight=="1") echo ' checked="checked"'; ?> /></td>
|
<label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of Ticks:', 'wplt2' ); ?></label>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
<td>
|
||||||
<td><label for="<?php echo $this->get_field_id( 'highlight_time' ); ?>"><?php _e( 'Highlight time [s]:', 'wplt2' ); ?></label></td>
|
<select id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>">
|
||||||
<td><input class="widefat" id="<?php echo $this->get_field_id( 'highlight_time' ); ?>" name="<?php echo $this->get_field_name( 'highlight_time' ); ?>" type="text" value="<?php echo $highlight_time; ?>" /></td>
|
<option value="0"<?php if ( $count == 0 )
|
||||||
</tr>
|
echo ' selected="selected"' ?>><?php _e( 'all', 'wplt2' ); ?></option>
|
||||||
<tr>
|
<option value="1"<?php if ( $count == 1 )
|
||||||
<td><label for="<?php echo $this->get_field_id( 'ajax' ); ?>"><?php _e( 'Auto refresh:', 'wplt2' ); ?></label></td>
|
echo ' selected="selected"' ?>>1
|
||||||
<td><input class="widefat" id="<?php echo $this->get_field_id( 'ajax' ); ?>" name="<?php echo $this->get_field_name( 'ajax' ); ?>" type="checkbox" value="1"<?php if($ajax=="1") echo ' checked="checked"'; ?> disabled="disabled" /> <small><?php _e( '(enables ajax)', 'wplt2' ); ?></small></td>
|
</option>
|
||||||
</tr>
|
<option value="2"<?php if ( $count == 2 )
|
||||||
</table>
|
echo ' selected="selected"' ?>>2
|
||||||
|
</option>
|
||||||
|
<option value="3"<?php if ( $count == 3 )
|
||||||
|
echo ' selected="selected"' ?>>3
|
||||||
<?php
|
</option>
|
||||||
}
|
<option value="4"<?php if ( $count == 4 )
|
||||||
|
echo ' selected="selected"' ?>>4
|
||||||
|
</option>
|
||||||
|
<option value="5"<?php if ( $count == 5 )
|
||||||
|
echo ' selected="selected"' ?>>5
|
||||||
|
</option>
|
||||||
|
<option value="6"<?php if ( $count == 6 )
|
||||||
|
echo ' selected="selected"' ?>>6
|
||||||
|
</option>
|
||||||
|
<option value="7"<?php if ( $count == 7 )
|
||||||
|
echo ' selected="selected"' ?>>7
|
||||||
|
</option>
|
||||||
|
<option value="8"<?php if ( $count == 8 )
|
||||||
|
echo ' selected="selected"' ?>>8
|
||||||
|
</option>
|
||||||
|
<option value="9"<?php if ( $count == 9 )
|
||||||
|
echo ' selected="selected"' ?>>9
|
||||||
|
</option>
|
||||||
|
<option value="10"<?php if ( $count == 10 )
|
||||||
|
echo ' selected="selected"' ?>>10
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link (optional):', 'wplt2' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" type="text" value="<?php echo $link; ?>" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'highlight' ); ?>"><?php _e( 'Highlight new:', 'wplt2' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id( 'highlight' ); ?>" name="<?php echo $this->get_field_name( 'highlight' ); ?>" type="checkbox" value="1" <?php if ( $highlight == "1" ) {
|
||||||
|
echo ' checked="checked"';
|
||||||
|
} ?> /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'highlight_time' ); ?>"><?php _e( 'Highlight time [s]:', 'wplt2' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id( 'highlight_time' ); ?>" name="<?php echo $this->get_field_name( 'highlight_time' ); ?>" type="text" value="<?php echo $highlight_time; ?>" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'ajax' ); ?>"><?php _e( 'Auto refresh:', 'wplt2' ); ?></label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id( 'ajax' ); ?>" name="<?php echo $this->get_field_name( 'ajax' ); ?>" type="checkbox" value="1"<?php if ( $ajax == "1" ) {
|
||||||
|
echo ' checked="checked"';
|
||||||
|
} ?> disabled="disabled" />
|
||||||
|
<small><?php _e( '(enables ajax)', 'wplt2' ); ?></small>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'widgets_init', 'wplt_widget_init' );
|
add_action( 'widgets_init', 'wplt_widget_init' );
|
||||||
function wplt_widget_init() {
|
function wplt_widget_init() {
|
||||||
register_widget( 'wplt_widget' );
|
register_widget( 'wplt_widget' );
|
||||||
}
|
}
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
ul.wplt_ticker {
|
ul.wplt2_ticker {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.wplt_tick {
|
li.wplt2_tick {
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
margin: 0.1em;
|
margin: 0.1em;
|
||||||
padding: 0.1em 0.3em;
|
padding: 0.1em 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.wplt_tick p {
|
li.wplt2_tick p {
|
||||||
margin: 0.3em;
|
margin: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.wplt_tick_time {
|
span.wplt2_tick_time {
|
||||||
color: #002C58;
|
color: #002C58;
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.wplt_tick_title {
|
span.wplt2_tick_title {
|
||||||
color: #002C58;
|
color: #002C58;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.wplt_tick_content {
|
p.wplt2_tick_content {
|
||||||
margin-top: -0.7em;
|
margin-top: -0.7em;
|
||||||
text-indent: 0.5em;
|
text-indent: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.wplt_widget {
|
ul.wplt_2widget {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
margin-top: -0.5em;
|
margin-top: -0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.wplt_widget li {
|
ul.wplt2_widget li {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.wplt_widget_time {
|
span.wplt2_widget_time {
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.wplt_widget_content {
|
span.wplt2_widget_content {
|
||||||
color: #002C58;
|
color: #002C58;
|
||||||
text-indent: 0.2em;
|
text-indent: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.wplt_widget_content_new {
|
span.wplt2_widget_content_new {
|
||||||
color: #800000;
|
color: #800000;
|
||||||
text-indent: 0.2em;
|
text-indent: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.wplt_widget_link {
|
p.wplt2_widget_link {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
@ -34,56 +34,45 @@
|
|||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
// Constants.
|
// Constants.
|
||||||
define( 'WPLT_VERSION', '0.4' );
|
define( 'WPLT2_FILE', __FILE__ );
|
||||||
define( 'WPLT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'WPLT2_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'WPLT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'WPLT2_BASE', plugin_basename( __FILE__ ) );
|
||||||
define( 'WPLT_TEXTDOM', 'wplt2' );
|
|
||||||
define( 'WPLT_OPTIONS', 'wplt2' );
|
// 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' ) );
|
||||||
|
|
||||||
|
// Allow shortcodes in widgets.
|
||||||
|
add_filter( 'widget_text', 'do_shortcode' );
|
||||||
|
|
||||||
|
// Add shortcode.
|
||||||
|
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
|
||||||
|
|
||||||
|
|
||||||
|
// Autoload.
|
||||||
|
spl_autoload_register( 'wplt2_autoload' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Localization.
|
* Autoloader for StatifyBlacklist classes.
|
||||||
|
*
|
||||||
|
* @param string $class Name of the class to load.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
function wplt2_localization() {
|
function wplt2_autoload( $class ) {
|
||||||
load_plugin_textdomain( WPLT_TEXTDOM, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
|
$plugin_classes = array(
|
||||||
}
|
'WPLiveticker2',
|
||||||
|
'WPLiveticker2_Admin',
|
||||||
add_action( 'plugins_loaded', 'wplt2_localization' );
|
'WPLiveticker2_System',
|
||||||
|
);
|
||||||
/**
|
if ( in_array( $class, $plugin_classes, true ) ) {
|
||||||
* Options.
|
require_once(
|
||||||
*/
|
sprintf(
|
||||||
global $wplt_options;
|
'%s/includes/class-%s.php',
|
||||||
$wplt_options = get_option( WPLT_OPTIONS );
|
WPLT2_DIR,
|
||||||
|
strtolower( str_replace( '_', '-', $class ) )
|
||||||
/**
|
)
|
||||||
* Include required plugin files.
|
);
|
||||||
*/
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/functions.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/post-types.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/scripts.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/rss.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/shortcodes.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/widget.php' );
|
|
||||||
if ( is_admin() ) {
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/admin/page-settings.php' );
|
|
||||||
include_once( WPLT_PLUGIN_DIR . 'includes/admin/post-types-columns.php' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On activation.
|
|
||||||
*/
|
|
||||||
function wplt2_activation() {
|
|
||||||
global $wplt_options;
|
|
||||||
|
|
||||||
// Add default settings to database.
|
|
||||||
$defaults = WPLT_get_default_options();
|
|
||||||
|
|
||||||
if ( $wplt_options['reset_settings'] ) {
|
|
||||||
update_option( WPLT_OPTIONS, $defaults );
|
|
||||||
} else {
|
|
||||||
add_option( WPLT_OPTIONS, $defaults );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
register_activation_hook( __FILE__, 'wplt2_activation' );
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user