MortgageNews_Widget::widget( array $args, array $instance )
Widget init.
Contents
Parameters Parameters
- $args
-
(array) (Required) arguments
- $instance
-
(array) (Required) instance
Source Source
File: mortgage-news-widget/inc/MortgageNews_Widget.php
public function widget( $args, $instance ) {
extract( $args );
/**
* Widget title filter.
*
* @param mixed $instance ['title'] title
*/
$title = apply_filters( 'widget_title', $instance['title'] );
// before and after widget arguments are defined by themes
$type = $instance['type'];
echo $args['before_widget'] ;
if ( $title ) {
echo $before_title . esc_html( $title ) . $after_title ;
}
$embedded = new MortgageNews_Embedded();
$enqueue = new MortgageNews_Enqueue();
$news = new MortgageNews;
$news_data = $news->get_news();
if ( $type == 'bullets' ) {
$embedded->embedded_bullets_html();
$enqueue->enqueue_bullets();
}
if ( $type == 'scroller-1' ) {
$embedded->scroller_html_type1( $news_data );
wp_enqueue_style( 'mortgage-news-scroller-1', plugins_url( '../assets/css/mortgage-news-scroller-1.css', __FILE__ ), array(), '1.0.0' );
}
if ( $type == 'scroller-2' ) {
$embedded->scroller_html_type2( $news_data );
wp_enqueue_style( 'mortgage-news-scroller-2', plugins_url( '../assets/css/mortgage-news-scroller-2.css', __FILE__ ), array(), '1.0.0' );
}
if ( $type == 'scroller-3' ) {
$embedded->scroller_html_type3( $news_data );
wp_enqueue_style( 'mortgage-news-scroller-3', plugins_url( '../assets/css/mortgage-news-scroller-3.css', __FILE__ ), array(), '1.0.0' );
}
if ( $type == 'scroller-4' ) {
$embedded->scroller_html_type4( $news_data );
wp_enqueue_style( 'mortgage-news-scroller-4', plugins_url( '../assets/css/mortgage-news-scroller-4.css', __FILE__ ), array(), '1.0.0' );
}
if ('scroller-1'===$type || 'scroller-2'===$type || 'scroller-3'===$type || 'scroller-4'===$type){
wp_enqueue_script( 'breakingNews-scroller', plugins_url( '../assets/js/breakingNews-scroller.js', __FILE__ ), array( 'jquery' ), '1.0.0', true );
$data = ' if (jQuery(".newsTicker-' . $type . '").length) {
jQuery(".newsTicker-' . $type . '").breakingNews()
}';
wp_add_inline_script( 'breakingNews-scroller', $data, 'after' );
}
if ( 'list' === $type || 'plaintext' === $type ) {
$embedded->plain_text($news_data, $type);
}
echo $args['after_widget'] ;
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |