Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Widget Image xing
- */
- // we can only use this Widget if the plugin is active
- if( class_exists( 'WidgetImageField' ) )
- add_action( 'widgets_init', create_function( '', "register_widget( 'ITI_Widget_Image_OTM' );" ) );
- class ITI_Widget_Image_OTM extends WP_Widget
- {
- var $image_field = 'image';
- function __construct()
- {
- $widget_ops = array(
- 'classname' => 'image_otm',
- 'description' => __( "Image of the Month")
- );
- parent::__construct( 'image_otm', __('Image of the Month'), $widget_ops );
- }
- function form( $instance ) {
- $headline = esc_attr( isset( $instance['headline'] ) ? $instance['headline'] : '' );
- $images = array();
- for ( $i = 1; $i <= 3; $i++ ) {
- $image_data = esc_attr( isset( $instance[ $this->image_field . $i ] ) ? $instance[ $this->image_field . $i ] : 0 );
- $images[] = array( 'count' => $i, 'data' => new WidgetImageField( $this, $image_data ) );
- }
- ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Titel:' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo $headline; ?>" />
- </label>
- </p>
- <?php
- foreach ( $images as $image ) :
- ?><div>
- <label><?php _e( 'Bild' . $image[ 'count' ] . ':' ); ?></label>
- <?php echo $image[ 'data' ]->get_widget_field( $image[ 'count' ] ); ?>
- </div><?php
- endforeach;
- }
- function widget( $args, $instance ) {
- /*
- *
- * muss noch geschrieben werden
- *
- * */
- }
- function update( $new_instance, $old_instance )
- {
- $instance = $old_instance;
- $instance['headline'] = strip_tags( $new_instance['headline'] );
- for ( $i = 1; $i <= 3; $i++ )
- $instance[ $this->image_field . $i ] = intval( strip_tags( $new_instance[ $this->image_field . $i ] ) );
- $instance['blurb'] = strip_tags( $new_instance['blurb'] );
- return $instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement