?AlkantarClanX12
| Current Path : /home/r/a/n/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/ |
| Current File : /home/r/a/n/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/widget_promo_boxes.php |
<?php
/**
* Add function to widgets_init that'll load our widget.
*/
add_action('widgets_init', 'bk_register_promoboxes_widget');
function bk_register_promoboxes_widget(){
register_widget('bk_promoboxes_widget');
}
class bk_promoboxes_widget extends WP_Widget {
/**
* Widget setup.
*/
function __construct() {
/* Widget settings. */
$widget_ops = array( 'classname' => 'widget-promoboxes', 'description' => esc_html__('Displays Promobox in widget area.', 'rubik') );
/* Create the widget. */
parent::__construct('widget-promoboxed', esc_html__('BK: Promo Boxes', 'rubik'), $widget_ops );
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', $instance['title'] );
$pm_title_1 = esc_attr($instance['promo_title_1']);
$pm_image_1 = esc_url($instance['imgurl_1']);
$pm_url_1 = esc_url($instance['linkurl_1']);
$pm_title_2 = esc_attr($instance['promo_title_2']);
$pm_image_2 = esc_url($instance['imgurl_2']);
$pm_url_2 = esc_url($instance['linkurl_2']);
$pm_title_3 = esc_attr($instance['promo_title_3']);
$pm_image_3 = esc_url($instance['imgurl_3']);
$pm_url_3 = esc_url($instance['linkurl_3']);
echo $before_widget;
if ( $title ) {?>
<div class="widget-title-wrap">
<?php echo $before_title . esc_html($title) . $after_title;?>
</div>
<?php }?>
<div class="rubik-promoboxes-wrap">
<?php if (strlen($pm_image_1) > 0) {?>
<div class="rubik-promo-item" style="background-image:url(<?php echo esc_url($pm_image_1);?>)">
<a class="rubik-promo-link" target="_blank" href="<?php echo esc_url($pm_url_1);?>"></a>
<div class="rubik-promo-content">
<?php if($pm_title_1) : ?>
<h4><?php echo esc_html($pm_title_1); ?></h4>
<?php endif; ?>
</div>
</div>
<?php }?>
<?php if (strlen($pm_image_2) > 0) {?>
<div class="rubik-promo-item" style="background-image:url(<?php echo esc_url($pm_image_2);?>)">
<a class="rubik-promo-link" target="_blank" href="<?php echo esc_url($pm_url_2);?>"></a>
<div class="rubik-promo-content">
<?php if($pm_title_2) : ?>
<h4><?php echo esc_html($pm_title_2); ?></h4>
<?php endif; ?>
</div>
</div>
<?php }?>
<?php if (strlen($pm_image_3) > 0) {?>
<div class="rubik-promo-item" style="background-image:url(<?php echo esc_url($pm_image_3);?>)">
<a class="rubik-promo-link" target="_blank" href="<?php echo esc_url($pm_url_3);?>"></a>
<div class="rubik-promo-content">
<?php if($pm_title_3) : ?>
<h4><?php echo esc_html($pm_title_3); ?></h4>
<?php endif; ?>
</div>
</div>
<?php }?>
</div>
<?php
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$new_instance = wp_parse_args( (array) $new_instance, $this->default );
$instance['title'] = strip_tags($new_instance['title']);
$instance['imgurl_1'] = strip_tags( $new_instance['imgurl_1'] );
$instance['linkurl_1'] = strip_tags( $new_instance['linkurl_1'] );
$instance['promo_title_1'] = strip_tags( $new_instance['promo_title_1'] );
$instance['imgurl_2'] = strip_tags( $new_instance['imgurl_2'] );
$instance['linkurl_2'] = strip_tags( $new_instance['linkurl_2'] );
$instance['promo_title_2'] = strip_tags( $new_instance['promo_title_2'] );
$instance['imgurl_3'] = strip_tags( $new_instance['imgurl_3'] );
$instance['linkurl_3'] = strip_tags( $new_instance['linkurl_3'] );
$instance['promo_title_3'] = strip_tags( $new_instance['promo_title_3'] );
return $instance;
}
function form( $instance ) {
$defaults = array('title' => esc_html__('','rubik'), 'imgurl_1' => '', 'linkurl_1' => '','promo_title_1' => '', 'imgurl_2' => '', 'linkurl_2' => '','promo_title_2' => '', 'imgurl_3' => '', 'linkurl_3' => '', 'promo_title_3' => '');
$instance = wp_parse_args((array) $instance, $defaults);
$imgurl_1 = strip_tags( $instance['imgurl_1'] );
$linkurl_1 = strip_tags( $instance['linkurl_1'] );
$imgurl_2 = strip_tags( $instance['imgurl_2'] );
$linkurl_2 = strip_tags( $instance['linkurl_2'] );
$imgurl_3 = strip_tags( $instance['imgurl_3'] );
$linkurl_3 = strip_tags( $instance['linkurl_3'] );
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><strong><?php esc_html_e('Title:', 'rubik'); ?></strong></label>
<input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
</p>
<!-- img url -->
<p>
<label for="<?php echo $this->get_field_id('imgurl_1'); ?>"><strong><?php esc_html_e('1. Image Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('imgurl_1'); ?>" name="<?php echo $this->get_field_name('imgurl_1'); ?>" type="text" value="<?php echo esc_attr($imgurl_1); ?>" />
</p>
<!-- link url -->
<p>
<label for="<?php echo $this->get_field_id('linkurl_1'); ?>"><strong><?php esc_html_e('1. Link Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('linkurl_1'); ?>" name="<?php echo $this->get_field_name('linkurl_1'); ?>" type="text" value="<?php echo esc_attr($linkurl_1); ?>" />
</p>
<!-- Text -->
<p>
<label for="<?php echo $this->get_field_id( 'promo_title_1' ); ?>"><strong><?php esc_html_e('1. Title:', 'rubik'); ?></strong></label>
<input type="text" id="<?php echo $this->get_field_id('promo_title_1'); ?>" name="<?php echo $this->get_field_name('promo_title_1'); ?>" value="<?php echo $instance['promo_title_1']; ?>" style="width:100%;" />
</p>
<!--- 2 -->
<!-- img url -->
<p>
<label for="<?php echo $this->get_field_id('imgurl_2'); ?>"><strong><?php esc_html_e('2. Image Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('imgurl_2'); ?>" name="<?php echo $this->get_field_name('imgurl_2'); ?>" type="text" value="<?php echo esc_attr($imgurl_2); ?>" />
</p>
<!-- link url -->
<p>
<label for="<?php echo $this->get_field_id('linkurl_2'); ?>"><strong><?php esc_html_e('2. Link Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('linkurl_2'); ?>" name="<?php echo $this->get_field_name('linkurl_2'); ?>" type="text" value="<?php echo esc_attr($linkurl_2); ?>" />
</p>
<!-- Text -->
<p>
<label for="<?php echo $this->get_field_id( 'promo_title_2' ); ?>"><strong><?php esc_html_e('2. Title:', 'rubik'); ?></strong></label>
<input type="text" id="<?php echo $this->get_field_id('promo_title_2'); ?>" name="<?php echo $this->get_field_name('promo_title_2'); ?>" value="<?php echo $instance['promo_title_2']; ?>" style="width:100%;" />
</p>
<!--- 3 -->
<!-- img url -->
<p>
<label for="<?php echo $this->get_field_id('imgurl_3'); ?>"><strong><?php esc_html_e('3. Image Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('imgurl_3'); ?>" name="<?php echo $this->get_field_name('imgurl_3'); ?>" type="text" value="<?php echo esc_attr($imgurl_3); ?>" />
</p>
<!-- link url -->
<p>
<label for="<?php echo $this->get_field_id('linkurl_3'); ?>"><strong><?php esc_html_e('3. Link Url:','rubik'); ?></strong></label>
<input class="widefat" id="<?php echo $this->get_field_id('linkurl_3'); ?>" name="<?php echo $this->get_field_name('linkurl_3'); ?>" type="text" value="<?php echo esc_attr($linkurl_3); ?>" />
</p>
<!-- Text -->
<p>
<label for="<?php echo $this->get_field_id( 'promo_title_3' ); ?>"><strong><?php esc_html_e('3. Title:', 'rubik'); ?></strong></label>
<input type="text" id="<?php echo $this->get_field_id('promo_title_3'); ?>" name="<?php echo $this->get_field_name('promo_title_3'); ?>" value="<?php echo $instance['promo_title_3']; ?>" style="width:100%;" />
</p>
<?php
}
}