| 1 |
<?php |
| 2 |
/** |
| 3 |
* Simple Ticker |
| 4 |
* |
| 5 |
* @package SimpleTicker |
| 6 |
* @subpackage SimpleTicker Widget |
| 7 |
Copyright (c) 2016- Katsushi Kawamori (email : dodesyoswift312@gmail.com) |
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; version 2 of the License. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with this program; if not, write to the Free Software |
| 19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
*/ |
| 21 |
|
| 22 |
add_action('widgets_init', create_function('', 'return register_widget("SimpleTickerWidgetItem");')); |
| 23 |
|
| 24 |
/* ================================================== |
| 25 |
* Widget |
| 26 |
* @since 1.0 |
| 27 |
*/ |
| 28 |
class SimpleTickerWidgetItem extends WP_Widget { |
| 29 |
|
| 30 |
public function __construct() { |
| 31 |
parent::__construct( |
| 32 |
'SimpleTickerWidgetItem', // Base ID |
| 33 |
__( 'Ticker', 'simple-ticker' ), // Name |
| 34 |
array( 'description' => __( 'Ticker from SimpleTicker.', 'simple-ticker'), ) // Args |
| 35 |
); |
| 36 |
} |
| 37 |
|
| 38 |
public function widget($args, $instance) { |
| 39 |
extract($args); |
| 40 |
$title = apply_filters('widget_title', $instance['title']); |
| 41 |
|
| 42 |
if ($title) { |
| 43 |
echo $before_widget; |
| 44 |
echo $before_title . $title . $after_title; |
| 45 |
include_once( dirname(__FILE__).'/SimpleTicker.php' ); |
| 46 |
$simpleticker = new SimpleTicker(); |
| 47 |
echo $simpleticker->read_tickers(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| 48 |
unset($simpleticker); |
| 49 |
echo $after_widget; |
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
public function update($new_instance, $old_instance) { |
| 55 |
$instance = $old_instance; |
| 56 |
$instance['title'] = strip_tags($new_instance['title']); |
| 57 |
return $instance; |
| 58 |
} |
| 59 |
|
| 60 |
public function form($instance) { |
| 61 |
|
| 62 |
if (isset($instance['title'])) { |
| 63 |
$title = esc_attr($instance['title']); |
| 64 |
} else { |
| 65 |
$title = NULL; |
| 66 |
} |
| 67 |
|
| 68 |
?> |
| 69 |
<p> |
| 70 |
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title'); ?>:</label> |
| 71 |
<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; ?>" /> |
| 72 |
</p> |
| 73 |
<?php |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
?> |