| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contains the widget admin and its registration |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
if( ! defined( 'ABSPATH' ) ) exit; |
| 8 |
|
| 9 |
class SRR_Widget{ |
| 10 |
|
| 11 |
public static function init(){ |
| 12 |
|
| 13 |
add_action( 'widgets_init', array( __CLASS__, 'init_widget' ) ); |
| 14 |
|
| 15 |
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'public_scripts' ) ); |
| 16 |
|
| 17 |
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_scripts' ) ); |
| 18 |
|
| 19 |
} |
| 20 |
|
| 21 |
public static function init_widget(){ |
| 22 |
|
| 23 |
register_widget( 'super_rss_reader_widget' ); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
public static function public_scripts(){ |
| 28 |
|
| 29 |
wp_enqueue_script( 'jquery-easy-ticker-js', SRR_URL . 'public/js/jquery.easy-ticker.min.js', array( 'jquery', 'super-rss-reader-js' ), SRR_VERSION ); |
| 30 |
wp_enqueue_script( 'super-rss-reader-js', SRR_URL . 'public/js/script.min.js', array( 'jquery' ), SRR_VERSION ); |
| 31 |
wp_enqueue_style( 'super-rss-reader-css', SRR_URL . 'public/css/style.min.css', array(), SRR_VERSION ); |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
public static function admin_scripts( $hook ){ |
| 36 |
|
| 37 |
if( $hook == 'widgets.php' ){ |
| 38 |
wp_enqueue_style( 'srr_admin_css', SRR_URL . 'admin/css/style.css', array(), SRR_VERSION ); |
| 39 |
wp_enqueue_script( 'srr_admin_js', SRR_URL . 'admin/js/script.js', array( 'jquery' ), SRR_VERSION ); |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
public static function render_feed( $options ){ |
| 45 |
|
| 46 |
$feed = new SRR_Feed( $options ); |
| 47 |
echo $feed->html(); |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
SRR_Widget::init(); |
| 54 |
|
| 55 |
?> |