Add countdown module with team logos option
This commit is contained in:
105
modules/sportspress-countdowns.php
Normal file
105
modules/sportspress-countdowns.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: SportsPress Countdowns
|
||||
Plugin URI: http://themeboy.com/
|
||||
Description: Add countdown widgets to SportsPress.
|
||||
Author: ThemeBoy
|
||||
Author URI: http://themeboy.com/
|
||||
Version: 1.6.1
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Countdowns' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Countdowns Class
|
||||
*
|
||||
* @class SportsPress_Countdowns
|
||||
* @version 1.6
|
||||
*/
|
||||
class SportsPress_Countdowns {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// Actions
|
||||
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
|
||||
|
||||
// Filters
|
||||
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
|
||||
add_filter( 'sportspress_event_settings', array( $this, 'add_settings' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_COUNTDOWNS_VERSION' ) )
|
||||
define( 'SP_COUNTDOWNS_VERSION', '1.6.1' );
|
||||
|
||||
if ( !defined( 'SP_COUNTDOWNS_URL' ) )
|
||||
define( 'SP_COUNTDOWNS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_COUNTDOWNS_DIR' ) )
|
||||
define( 'SP_COUNTDOWNS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-countdown.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['event'][] = 'countdown';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
$settings = array_merge( $settings,
|
||||
array(
|
||||
array( 'title' => __( 'Countdowns', 'sportspress' ), 'type' => 'title', 'id' => 'countdown_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_countdown_options', array(
|
||||
array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'desc' => __( 'Display logos', 'sportspress' ),
|
||||
'id' => 'sportspress_countdown_show_logos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
)),
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'countdown_options' ),
|
||||
)
|
||||
);
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_countdowns_module', 'yes' ) == 'yes' ) {
|
||||
new SportsPress_Countdowns();
|
||||
}
|
||||
Reference in New Issue
Block a user