SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | /* | |
| 3 | Plugin Name: Kamera Widget | |
| 4 | Description: kamera | |
| 5 | */ | |
| 6 | ||
| 7 | class KameraRa extends WP_Widget {
| |
| 8 | ||
| 9 | function __construct() {
| |
| 10 | parent::__construct( | |
| 11 | ||
| 12 | 'KameraRa', | |
| 13 | ||
| 14 | __('Kamera', 'wpb_widget_domain'),
| |
| 15 | ||
| 16 | array( 'description' => __( 'Kamera v živo', 'wpb_widget_domain' ), ) | |
| 17 | ); | |
| 18 | } | |
| 19 | ||
| 20 | public function widget( $args, $instance ) {
| |
| 21 | $title = apply_filters( 'widget_title', $instance['title'] ); | |
| 22 | // before and after widget arguments are defined by themes | |
| 23 | echo $args['before_widget']; | |
| 24 | if ( ! empty( $title ) ) | |
| 25 | echo $args['before_title'] . $title . $args['after_title']; | |
| 26 | ||
| 27 | ||
| 28 | echo __( '<a target="_blank" href="http://www.ex.com"> | |
| 29 | <center><img width="100%" src="http://ex2.com" alt="RTC Kranjska Gora - Kekec"></center> | |
| 30 | </a>', 'wpb_widget_domain' ); | |
| 31 | echo $args['after_widget']; | |
| 32 | } | |
| 33 | ||
| 34 | public function form( $instance ) {
| |
| 35 | if ( isset( $instance[ 'title' ] ) ) {
| |
| 36 | $title = $instance[ 'title' ]; | |
| 37 | } | |
| 38 | else {
| |
| 39 | $title = __( 'Snežni park v živo', 'wpb_widget_domain' ); | |
| 40 | } | |
| 41 | ?> | |
| 42 | <p> | |
| 43 | <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> | |
| 44 | <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> | |
| 45 | </p> | |
| 46 | <?php | |
| 47 | - | <?php |
| 47 | + | |
| 48 | ||
| 49 | ||
| 50 | public function update( $new_instance, $old_instance ) {
| |
| 51 | $instance = array(); | |
| 52 | $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; | |
| 53 | return $instance; | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 57 | ||
| 58 | function wpb_load_widget() {
| |
| 59 | register_widget( 'KameraRa' ); | |
| 60 | } | |
| 61 | add_action( 'widgets_init', 'wpb_load_widget' ); | |
| 62 | ?> |