File: /var/www/html/wp-content/plugins/hover_effects_pack/widget.php
<?php
class Hover_Pack_Widget extends WP_Widget
{
function __construct() {
// Instantiate the parent object
parent::__construct( false, 'Hover Pack Widget' );
add_action('admin_enqueue_scripts', array($this, 'hp_widget_scripts'));
add_action('admin_enqueue_styles', array($this, 'hp_widget_styles'));
}
public function hp_widget_scripts()
{
wp_enqueue_media();
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script('thickbox');
wp_register_script('upload_media_widget', plugin_dir_url(__FILE__) . '/js/widget.js', array('jquery'), '1.1');
$widget_color_id = $this->get_field_id('color');
wp_localize_script('upload_media_widget', 'widget_color', array('widget_color_id' => $widget_color_id));
wp_enqueue_script('upload_media_widget');
}
public function hp_widget_styles()
{
wp_enqueue_style('thickbox');
wp_enqueue_style('admin_css', plugin_dir_url(__FILE__) . '/css/admin.css');
}
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance) {
// outputs the content of the widget
extract($instance);
$popup_class = '';
$rel = '';
$options = get_option('hp_options');
$popup_type = isset($options['popup_type']) ? $options['popup_type'] : '';
$image_css_size = isset($options['image_css_size_enable']) ? $options['image_css_size_enable'] : 'off';
switch ($popup_type) {
case 'tb':
$popup_class = 'thickbox';
$rel = $gallery_id;
break;
case 'pp':
$popup_class = 'prettyphoto';
if($gallery_id != '') {
$rel = 'PrettyPhoto['.$gallery_id.']';
} else {
$rel = 'PrettyPhoto';
}
break;
}
$effect_class = 'b-link-fade';
switch ($effect) {
case 'none':
$effect_class = 'b-link-none';
break;
case 'fade':
$effect_class = 'b-link-fade';
break;
case 'flow':
$effect_class = 'b-link-flow';
break;
case 'stroke':
$effect_class = 'b-link-stroke';
break;
case 'twist':
$effect_class = 'b-link-twist';
break;
case 'flip':
$effect_class = 'b-link-flip';
break;
case 'box':
$effect_class = 'b-link-box';
break;
case 'stripe':
$effect_class = 'b-link-stripe';
break;
case 'apart-horizontal':
$effect_class = 'b-link-apart-horisontal';
break;
case 'apart-vertical':
$effect_class = 'b-link-apart-vertical';
break;
case 'diagonal':
$effect_class = 'b-link-diagonal';
break;
}
if ($inverse_effect != '') {
$effect_class .= ' b-inverse-effect';
}
$opacity_class = ' ';
switch ($opacity) {
case '90':
$opacity_class = 'b-opacity-90';
break;
case '80':
$opacity_class = 'b-opacity-80';
break;
case '70':
$opacity_class = 'b-opacity-70';
break;
case '60':
$opacity_class = 'b-opacity-60';
break;
case '50':
$opacity_class = 'b-opacity-50';
break;
case '40':
$opacity_class = 'b-opacity-40';
break;
case '30':
$opacity_class = 'b-opacity-30';
break;
case '20':
$opacity_class = 'b-opacity-20';
break;
case '10':
$opacity_class = 'b-opacity-10';
break;
}
if ($radius != '') {
$border_radius = 'border-radius-' . $radius;
} else {
$border_radius = '';
}
$img_width_height_style = 'style="';
if ((int)$width > 0) {
$img_width = 'width="' . (int)$width . '"';
$img_width_height_style.= 'width: ' . (int)$width . 'px;';
} else {
$img_width = '';
$img_width_height_style.= '';
}
if ((int)$height > 0) {
$img_height = 'height="' . (int)$height . '"';
$img_width_height_style.= 'height: ' . (int)$height . 'px;';
} else {
$img_height = '';
$img_width_height_style.= '';
}
$img_width_height_style.= '"';
if($image_css_size != 'checked') {
$img_width_height_style = '';
}
if (isset($disable_popup) && $disable_popup == 'on') {
$popup_class = '';
}
$link_target = '';
if (isset($link_tab) && $link_tab == 'on') {
$link_target = 'target="_blank"';
}
if ($link == '') {
$link = 'javascript:void(0)';
}
// Get options
$options = get_option('hp_options');
$header_tag = isset($options['typography_header']) ? $options['typography_header'] : 'h2';
$paragraph_tag = isset($options['typography_paragraph']) ? $options['typography_paragraph'] : 'p';
$header_padding = isset($options['typography_header_padding']) ? $options['typography_header_padding'] : '';
$paragraph_padding = isset($options['typography_paragraph_padding']) ? $options['typography_paragraph_padding'] : '';
$link_wrap = isset($options['wrapper_settings']) ? $options['wrapper_settings'] : 'image';
$header_padding_html = '';
if (isset($header_padding)) {
$header_padding_html = 'style="padding-left:' . (int)$header_padding . 'px;padding-right:' . (int)$header_padding . 'px;"';
}
$paragraph_padding_html = '';
if (isset($paragraph_padding)) {
$paragraph_padding_html = 'style="padding-left:' . (int)$paragraph_padding . 'px;padding-right:' . (int)$paragraph_padding . 'px;"';
}
// Img Title and Alt
$img_title_html = '';
if(isset($img_title)) {
$img_title_html = "title='$img_title'";
}
$img_alt_html = '';
if(isset($img_alt)) {
$img_alt_html = "alt='$img_alt'";
}
$data_color = "";
if(isset($color)) {
if($color != '') {
$data_color = "data-color='".$color."'";
}
}
if($link_wrap == 'image') {
$html = '<a href="' . $link . '" ' . $link_target . ' class="' . $effect_class . ' b-animate-go ' . $class . ' ' . $popup_class . ' ' . $border_radius . ' ' . $opacity_class . '" '.$data_color.' rel="'.$rel.'">';
} else {
$html = '<span class="' . $effect_class . ' b-animate-go ' . $class . ' ' . $popup_class . ' ' . $border_radius . ' ' . $opacity_class . '" '.$data_color.' >';
}
$html .= '<img src="' . $img . '" ' . $img_width . ' ' . $img_height . ' ' . $img_width_height_style . ' '.$img_alt_html.' '.$img_title_html.' />';
// if we have title or text
if (isset($title) || isset($text)) {
$html.= '<div class="b-wrapper">';
if (isset($title) && $title != '') {
$title_delay_class = '';
if ($title_delay) {
switch ($title_delay) {
case '03':
$title_delay_class = 'b-delay03';
break;
case '06':
$title_delay_class = 'b-delay06';
break;
case '09':
$title_delay_class = 'b-delay09';
break;
case '12':
$title_delay_class = 'b-delay12';
break;
case '15':
$title_delay_class = 'b-delay15';
break;
}
}
$title_slide_class = '';
if ($title_slide) {
switch ($title_slide) {
case 'from-left':
$title_slide_class = 'b-from-left';
break;
case 'from-right':
$title_slide_class = 'b-from-right';
break;
case 'from-top':
$title_slide_class = 'b-from-top';
break;
case 'from-bottom':
$title_slide_class = 'b-from-bottom';
break;
}
}
$title_rotate_class = '';
if ($title_rotation) {
switch ($title_rotation) {
case 'cw-90':
$title_rotate_class = 'b-cw-90';
break;
case 'ccw-90':
$title_rotate_class = 'b-ccw-90';
break;
case 'cw-180':
$title_rotate_class = 'b-cw-180';
break;
case 'ccw-180':
$title_rotate_class = 'b-ccw-180';
break;
}
}
$title_scale_class = '';
if ($title_scale == 'on') {
$title_scale_class = 'b-scale';
}
$title_opacity_class = '';
if ($title_fade == 'on') {
$title_opacity_class = 'b-opacity';
}
if($link_wrap == 'title') {
$html .= '<a href = "' . $link . '" ' . $link_target . ' >';
}
if($title_visible == 'on') {
$html.= '<' . $header_tag . ' ' . $header_padding_html . ' class="b-animate h b-visible ">' . $title . '</' . $header_tag . '>';
} else {
$html.= '<' . $header_tag . ' ' . $header_padding_html . ' class="b-animate h ' . $title_slide_class . ' ' . $title_scale_class . ' ' . $title_opacity_class . ' ' . $title_rotate_class . ' ' . $title_delay_class . ' ">' . $title . '</' . $header_tag . '>';
}
if($link_wrap == 'title') {
$html .= '</a>';
}
}
if (isset($text) && $text != '') {
$text_delay_class = '';
if ($text_delay) {
switch ($text_delay) {
case '03':
$text_delay_class = 'b-delay03';
break;
case '06':
$text_delay_class = 'b-delay06';
break;
case '09':
$text_delay_class = 'b-delay09';
break;
case '12':
$text_delay_class = 'b-delay12';
break;
case '15':
$text_delay_class = 'b-delay15';
break;
}
}
$text_slide_class = '';
if ($text_slide) {
switch ($text_slide) {
case 'from-left':
$text_slide_class = 'b-from-left';
break;
case 'from-right':
$text_slide_class = 'b-from-right';
break;
case 'from-top':
$text_slide_class = 'b-from-top';
break;
case 'from-bottom':
$text_slide_class = 'b-from-bottom';
break;
}
}
$text_rotate_class = '';
if ($text_rotation) {
switch ($text_rotation) {
case 'cw-90':
$text_rotate_class = 'b-cw-90';
break;
case 'ccw-90':
$text_rotate_class = 'b-ccw-90';
break;
case 'cw-180':
$text_rotate_class = 'b-cw-180';
break;
case 'ccw-180':
$text_rotate_class = 'b-ccw-180';
break;
}
}
$text_scale_class = '';
if ($text_scale == 'on') {
$text_scale_class = 'b-scale';
}
$text_opacity_class = '';
if ($text_fade == 'on') {
$text_opacity_class = 'b-opacity';
}
if($link_wrap == 'text') {
$html .= '<a href = "' . $link . '" ' . $link_target . ' >';
}
if($text_visible == 'on') {
$html.= '<' . $paragraph_tag . ' ' . $paragraph_padding_html . ' class="b-animate p b-visible ">' . $text . '</' . $paragraph_tag . '>';
} else {
$html.= '<' . $paragraph_tag . ' ' . $paragraph_padding_html . ' class="b-animate p ' . $text_slide_class . ' ' . $text_scale_class . ' ' . $text_opacity_class . ' ' . $text_rotate_class . ' ' . $text_delay_class . ' ">' . $text . '</' . $paragraph_tag . '>';
}
if($link_wrap == 'text') {
$html .= '</a>';
}
}
$html.= '</div>';
}
if($link_wrap == 'image') {
$html.= '</a>';
} else {
$html.= '</span>';
}
echo $html;
}
/**
* Outputs the options form on admin
*
* @param array $instance The widget options
*/
public function form($instance) {
// outputs the options form on admin
$img = !empty($instance['img']) ? $instance['img'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('img'); ?>"><?php esc_html_e('Image:'); ?></label>
<input class="hpso-image" id="<?php echo $this->get_field_id('img'); ?>" name="<?php echo $this->get_field_name('img'); ?>" type="text" value="<?php echo esc_attr($img); ?>"> <input type="button" value="Upload/Select" class="button widget-upload">
</p>
<?php
$link = !empty($instance['link']) ? $instance['link'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('link'); ?>"><?php esc_html_e('Image Link:'); ?></label>
<input class="hpso-image-link widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr($link); ?>">
</p>
<?php
$img_title = !empty($instance['img_title']) ? $instance['img_title'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('img_title'); ?>"><?php esc_html_e('Image Title Attribute:'); ?></label>
<input class="hpso-image-img_title widefat" id="<?php echo $this->get_field_id('img_title'); ?>" name="<?php echo $this->get_field_name('img_title'); ?>" type="text" value="<?php echo esc_attr($img_title); ?>">
</p>
<?php
$img_alt = !empty($instance['img_alt']) ? $instance['img_alt'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('img_alt'); ?>"><?php esc_html_e('Image Alt Attribute:'); ?></label>
<input class="hpso-image-img_alt widefat" id="<?php echo $this->get_field_id('img_alt'); ?>" name="<?php echo $this->get_field_name('img_alt'); ?>" type="text" value="<?php echo esc_attr($img_alt); ?>">
</p>
<?php
$disable_popup = !empty($instance['disable_popup']) ? $instance['disable_popup'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('disable_popup'); ?>" name="<?php echo $this->get_field_name('disable_popup'); ?>" type="checkbox" value="on" <?php if($disable_popup == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('disable_popup'); ?>"><?php esc_html_e('Disable popup for this link'); ?></label>
</p>
<?php
$link_tab = !empty($instance['link_tab']) ? $instance['link_tab'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('link_tab'); ?>" name="<?php echo $this->get_field_name('link_tab'); ?>" type="checkbox" value="on" <?php if($link_tab == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('link_tab'); ?>"><?php esc_html_e('Open Link in new tab'); ?></label>
</p>
<?php
$gallery_id = !empty($instance['gallery_id']) ? $instance['gallery_id'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('gallery_id'); ?>"><?php esc_html_e('Image Gallery Id:'); ?></label>
<input class="hpso-image-gallery_id widefat" id="<?php echo $this->get_field_id('gallery_id'); ?>" name="<?php echo $this->get_field_name('gallery_id'); ?>" type="text" value="<?php echo esc_attr($gallery_id); ?>">
</p>
<?php
$width = !empty($instance['width']) ? $instance['width'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('width'); ?>"><?php esc_html_e('Image Width:'); ?></label>
<input class="hpso-image-width widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr($width); ?>">
</p>
<?php
$height = !empty($instance['height']) ? $instance['height'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('height'); ?>"><?php esc_html_e('Image Height:'); ?></label>
<input class="hpso-image-height widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr($height); ?>">
</p>
<?php
$class = !empty($instance['class']) ? $instance['class'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('class'); ?>"><?php esc_html_e('Custom Link Class:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('class'); ?>" name="<?php echo $this->get_field_name('class'); ?>" type="text" value="<?php echo esc_attr($class); ?>">
</p>
<?php
$radius = !empty($instance['radius']) ? $instance['radius'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('radius'); ?>"><?php esc_html_e('Border Radius:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('radius'); ?>" name="<?php echo $this->get_field_name('radius'); ?>" type="text" value="<?php echo esc_attr($radius); ?>">
</p>
<?php
$effect = !empty($instance['effect']) ? $instance['effect'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('effect'); ?>"><?php esc_html_e('Effect:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('effect'); ?>" name="<?php echo $this->get_field_name('effect'); ?>">
<option value="none">None</option>
<option value="fade" <?php if($effect == 'fade') echo "selected"; ?>>Fade</option>
<option value="stroke" <?php if($effect == 'stroke') echo "selected"; ?>>Stroke</option>
<option value="twist" <?php if($effect == 'twist') echo "selected"; ?>>Twist</option>
<option value="flip" <?php if($effect == 'flip') echo "selected"; ?>>Flip</option>
<option value="flow" <?php if($effect == 'flow') echo "selected"; ?>>Flow</option>
<option value="box" <?php if($effect == 'box') echo "selected"; ?>>Box</option>
<option value="stripe" <?php if($effect == 'stripe') echo "selected"; ?>>Stripe</option>
<option value="apart-horizontal" <?php if($effect == 'apart-horizontal') echo "selected"; ?>>Apart Horizontal</option>
<option value="apart-vertical" <?php if($effect == 'apart-vertical') echo "selected"; ?>>Apart Vertical</option>
<option value="diagonal" <?php if($effect == 'diagonal') echo "selected"; ?>>Diagonal</option>
</select>
</p>
<?php
$inverse_effect = !empty($instance['inverse_effect']) ? $instance['inverse_effect'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('inverse_effect'); ?>" name="<?php echo $this->get_field_name('inverse_effect'); ?>" type="checkbox" value="on" <?php if($inverse_effect == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('inverse_effect'); ?>"><?php esc_html_e('Inverse effect behavior'); ?></label>
</p>
<?php
$color = !empty($instance['color']) ? $instance['color'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('color'); ?>"><?php esc_html_e('Hover Color:'); ?></label><br/>
<input class="" id="<?php echo $this->get_field_id('color'); ?>" name="<?php echo $this->get_field_name('color'); ?>" type="text" value="<?php echo esc_attr($color); ?>">
</p>
<?php
$opacity = !empty($instance['opacity']) ? $instance['opacity'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('opacity'); ?>"><?php esc_html_e('Opacity:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('opacity'); ?>" name="<?php echo $this->get_field_name('opacity'); ?>">
<option value="100" <?php if($opacity == '100') echo "selected"; ?>>100%</option>
<option value="90" <?php if($opacity == '90') echo "selected"; ?>>90%</option>
<option value="80" <?php if($opacity == '80') echo "selected"; ?>>80%</option>
<option value="70" <?php if($opacity == '70') echo "selected"; ?>>70%</option>
<option value="60" <?php if($opacity == '60') echo "selected"; ?>>60%</option>
<option value="50" <?php if($opacity == '50') echo "selected"; ?>>50%</option>
<option value="40" <?php if($opacity == '40') echo "selected"; ?>>40%</option>
<option value="30" <?php if($opacity == '30') echo "selected"; ?>>30%</option>
<option value="20" <?php if($opacity == '20') echo "selected"; ?>>20%</option>
<option value="10" <?php if($opacity == '10') echo "selected"; ?>>10%</option>
</select>
</p>
<?php
$title = !empty($instance['title']) ? $instance['title'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Image Hover Title:'); ?></label>
<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); ?>">
</p>
<?php
$title_visible = !empty($instance['title_visible']) ? $instance['title_visible'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('title_visible'); ?>" name="<?php echo $this->get_field_name('title_visible'); ?>" type="checkbox" value="on" <?php if($title_visible == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('title_visible'); ?>"><?php esc_html_e('Disable Title Animation'); ?></label>
</p>
<?php
$title_delay = !empty($instance['title_delay']) ? $instance['title_delay'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('title_delay'); ?>"><?php esc_html_e('Title Effect Delay:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('title_delay'); ?>" name="<?php echo $this->get_field_name('title_delay'); ?>">
<option value="">None</option>
<option value="03" <?php if($title_delay == '03') echo "selected"; ?>>0,3 seconds</option>
<option value="06" <?php if($title_delay == '06') echo "selected"; ?>>0,6 seconds</option>
<option value="09" <?php if($title_delay == '09') echo "selected"; ?>>0,9 seconds</option>
<option value="12" <?php if($title_delay == '12') echo "selected"; ?>>1,2 seconds</option>
<option value="15" <?php if($title_delay == '15') echo "selected"; ?>>1,5 seconds</option>
</select>
</p>
<?php
$title_slide = !empty($instance['title_slide']) ? $instance['title_slide'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('title_slide'); ?>"><?php esc_html_e('Title Slide Effect:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('title_slide'); ?>" name="<?php echo $this->get_field_name('title_slide'); ?>">
<option value="">None</option>
<option value="from-left" <?php if($title_slide == 'from-left') echo "selected"; ?>>From left</option>
<option value="from-right" <?php if($title_slide == 'from-right') echo "selected"; ?>>From right</option>
<option value="from-bottom" <?php if($title_slide == 'from-bottom') echo "selected"; ?>>From bottom</option>
<option value="from-top" <?php if($title_slide == 'from-top') echo "selected"; ?>>From top</option>
</select>
</p>
<?php
$title_rotation = !empty($instance['title_rotation']) ? $instance['title_rotation'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('title_rotation'); ?>"><?php esc_html_e('Title Rotation Effect:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('title_rotation'); ?>" name="<?php echo $this->get_field_name('title_rotation'); ?>">
<option value="">None</option>
<option value="cw-90" <?php if($title_rotation == 'cw-90') echo "selected"; ?>>Clockwise 90</option>
<option value="cw-180" <?php if($title_rotation == 'cw-180') echo "selected"; ?>>Clockwise 180</option>
<option value="ccw-90" <?php if($title_rotation == 'ccw-90') echo "selected"; ?>>Counterclockwise 90</option>
<option value="ccw-180" <?php if($title_rotation == 'ccw-180') echo "selected"; ?>>Counterclockwise 180</option>
</select>
</p>
<?php
$title_scale = !empty($instance['title_scale']) ? $instance['title_scale'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('title_scale'); ?>" name="<?php echo $this->get_field_name('title_scale'); ?>" type="checkbox" value="on" <?php if($title_scale == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('title_scale'); ?>"><?php esc_html_e('Title Scale Effect'); ?></label>
</p>
<?php
$title_fade = !empty($instance['title_fade']) ? $instance['title_fade'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('title_fade'); ?>" name="<?php echo $this->get_field_name('title_fade'); ?>" type="checkbox" value="on" <?php if($title_fade == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('title_fade'); ?>"><?php esc_html_e('Title Fade Effect'); ?></label>
</p>
<?php
$text = !empty($instance['text']) ? $instance['text'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('text'); ?>"><?php esc_html_e('Image Hover Text:'); ?></label>
<textarea class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>" rows="3"><?php echo esc_attr($text); ?></textarea>
</p>
<?php
$text_visible = !empty($instance['text_visible']) ? $instance['text_visible'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('text_visible'); ?>" name="<?php echo $this->get_field_name('text_visible'); ?>" type="checkbox" value="on" <?php if($text_visible == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('text_visible'); ?>"><?php esc_html_e('Disable Text Animation'); ?></label>
</p>
<?php
$text_delay = !empty($instance['text_delay']) ? $instance['text_delay'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('text_delay'); ?>"><?php esc_html_e('Text Effect Delay:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('text_delay'); ?>" name="<?php echo $this->get_field_name('text_delay'); ?>">
<option value="">None</option>
<option value="03" <?php if($text_delay == '03') echo "selected"; ?>>0,3 seconds</option>
<option value="06" <?php if($text_delay == '06') echo "selected"; ?>>0,6 seconds</option>
<option value="09" <?php if($text_delay == '09') echo "selected"; ?>>0,9 seconds</option>
<option value="12" <?php if($text_delay == '12') echo "selected"; ?>>1,2 seconds</option>
<option value="15" <?php if($text_delay == '15') echo "selected"; ?>>1,5 seconds</option>
</select>
</p>
<?php
$text_slide = !empty($instance['text_slide']) ? $instance['text_slide'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('text_slide'); ?>"><?php esc_html_e('Text Slide Effect:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('text_slide'); ?>" name="<?php echo $this->get_field_name('text_slide'); ?>">
<option value="">None</option>
<option value="from-left" <?php if($text_slide == 'from-left') echo "selected"; ?>>From left</option>
<option value="from-right" <?php if($text_slide == 'from-right') echo "selected"; ?>>From right</option>
<option value="from-bottom" <?php if($text_slide == 'from-bottom') echo "selected"; ?>>From bottom</option>
<option value="from-top" <?php if($text_slide == 'from-top') echo "selected"; ?>>From top</option>
</select>
</p>
<?php
$text_rotation = !empty($instance['text_rotation']) ? $instance['text_rotation'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id('text_rotation'); ?>"><?php esc_html_e('Text Rotation Effect:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('text_rotation'); ?>" name="<?php echo $this->get_field_name('text_rotation'); ?>">
<option value="">None</option>
<option value="cw-90" <?php if($text_rotation == 'cw-90') echo "selected"; ?>>Clockwise 90</option>
<option value="cw-180" <?php if($text_rotation == 'cw-180') echo "selected"; ?>>Clockwise 180</option>
<option value="ccw-90" <?php if($text_rotation == 'ccw-90') echo "selected"; ?>>Counterclockwise 90</option>
<option value="ccw-180" <?php if($text_rotation == 'ccw-180') echo "selected"; ?>>Counterclockwise 180</option>
</select>
</p>
<?php
$text_scale = !empty($instance['text_scale']) ? $instance['text_scale'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('text_scale'); ?>" name="<?php echo $this->get_field_name('text_scale'); ?>" type="checkbox" value="on" <?php if($text_scale == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('text_scale'); ?>"><?php esc_html_e('Text Scale Effect'); ?></label>
</p>
<?php
$text_fade = !empty($instance['text_fade']) ? $instance['text_fade'] : '';
?>
<p>
<input class="" id="<?php echo $this->get_field_id('text_fade'); ?>" name="<?php echo $this->get_field_name('text_fade'); ?>" type="checkbox" value="on" <?php if($text_fade == 'on') echo "checked"; ?>>
<label for="<?php echo $this->get_field_id('text_fade'); ?>"><?php esc_html_e('Text Fade Effect'); ?></label>
</p>
<?php
}
/**
* Processing widget options on save
*
* @param array $new_instance The new options
* @param array $old_instance The previous options
*/
public function update($new_instance, $old_instance) {
// processes widget options to be saved
$instance['img'] = isset($new_instance['img'])?$new_instance['img']:'';
$instance['link'] = isset($new_instance['link'])?$new_instance['link']:'';
$instance['disable_popup'] = isset($new_instance['disable_popup'])?$new_instance['disable_popup']:'';
$instance['link_tab'] = isset($new_instance['link_tab'])?$new_instance['link_tab']:'';
$instance['gallery_id'] = isset($new_instance['gallery_id'])?$new_instance['gallery_id']:'';
$instance['img_title'] = isset($new_instance['img_title'])?$new_instance['img_title']:'';
$instance['img_alt'] = isset($new_instance['img_alt'])?$new_instance['img_alt']:'';
$instance['width'] = isset($new_instance['width'])?$new_instance['width']:'';
$instance['height'] = isset($new_instance['height'])?$new_instance['height']:'';
$instance['class'] = isset($new_instance['class'])?$new_instance['class']:'';
$instance['radius'] = isset($new_instance['radius'])?$new_instance['radius']:'';
$instance['effect'] = isset($new_instance['effect'])?$new_instance['effect']:'';
$instance['inverse_effect'] = isset($new_instance['inverse_effect'])?$new_instance['inverse_effect']:'';
$instance['color'] = isset($new_instance['color'])?$new_instance['color']:'';
$instance['opacity'] = isset($new_instance['opacity'])?$new_instance['opacity']:'';
$instance['title'] = isset($new_instance['title'])?$new_instance['title']:'';
$instance['title_visible'] = isset($new_instance['title_visible'])?$new_instance['title_visible']:'';
$instance['title_delay'] = isset($new_instance['title_delay'])?$new_instance['title_delay']:'';
$instance['title_slide'] = isset($new_instance['title_slide'])?$new_instance['title_slide']:'';
$instance['title_rotation'] = isset($new_instance['title_rotation'])?$new_instance['title_rotation']:'';
$instance['title_scale'] = isset($new_instance['title_scale'])?$new_instance['title_scale']:'';
$instance['title_fade'] = isset($new_instance['title_fade'])?$new_instance['title_fade']:'';
$instance['text'] = isset($new_instance['text'])?$new_instance['text']:'';
$instance['text_visible'] = isset($new_instance['text_visible'])?$new_instance['text_visible']:'';
$instance['text_delay'] = isset($new_instance['text_delay'])?$new_instance['text_delay']:'';
$instance['text_slide'] = isset($new_instance['text_slide'])?$new_instance['text_slide']:'';
$instance['text_rotation'] = isset($new_instance['text_rotation'])?$new_instance['text_rotation']:'';
$instance['text_scale'] = isset($new_instance['text_scale'])?$new_instance['text_scale']:'';
$instance['text_fade'] = isset($new_instance['text_fade'])?$new_instance['text_fade']:'';
return $instance;
}
}
$widget = 'Hover_Pack_Widget';
function hp_register_widgets() {
register_widget( 'Hover_Pack_Widget' );
}
add_action( 'widgets_init', 'hp_register_widgets' );