File: /var/www/html/site/newsite/wp-content/themes/ooze/inc/widgets/cta-widget.php
<?php
if (!defined('ABSPATH')) {
exit;
}
class Ooze_Call_To_Action extends Ooze_Widget_Base
{
/**
* Constructor.
*/
public function __construct()
{
$this->widget_cssclass = 'widget_ooze_call_to_action';
$this->widget_description = __("Adds Call to action section", 'ooze');
$this->widget_id = 'ooze_call_to_action';
$this->widget_name = __('Ooze: Call To Action', 'ooze');
$this->settings = array(
'title' => array(
'type' => 'text',
'label' => __('CTA Title', 'ooze'),
),
'title_text' => array(
'type' => 'text',
'label' => __('CTA Subtitle', 'ooze'),
),
'desc' => array(
'type' => 'textarea',
'label' => __('CTA Description', 'ooze'),
'rows' => 10,
),
'bg_image' => array(
'type' => 'image',
'label' => __('Background Image', 'ooze'),
),
'btn_text' => array(
'type' => 'text',
'label' => __('Button Text', 'ooze'),
),
'btn_link' => array(
'type' => 'url',
'label' => __('Link to url', 'ooze'),
'desc' => __('Enter a proper url with http: OR https:', 'ooze'),
),
'link_target' => array(
'type' => 'checkbox',
'label' => __('Open Link in new Tab', 'ooze'),
'std' => true,
),
'msg' => array(
'type' => 'message',
'label' => __('Additonal Settings', 'ooze'),
),
'height' => array(
'type' => 'number',
'step' => 20,
'min' => 300,
'max' => 700,
'std' => 400,
'label' => __('Height: Between 300px and 700px (Default 400px)', 'ooze'),
),
'text_color_option' => array(
'type' => 'color',
'label' => __('Text Color', 'ooze'),
'std' => '#ffffff',
),
'text_align' => array(
'type' => 'select',
'label' => __('Text Alignment', 'ooze'),
'options' => array(
'left' => __('Left Align', 'ooze'),
'center' => __('Center Align', 'ooze'),
'right' => __('Right Align', 'ooze'),
),
'std' => 'left',
),
'enable_fixed_bg' => array(
'type' => 'checkbox',
'label' => __('Enable Fixed Background Image', 'ooze'),
'std' => true,
),
'bg_overlay_color' => array(
'type' => 'color',
'label' => __('Overlay Background Color', 'ooze'),
'std' => '#000000',
),
'overlay_opacity' => array(
'type' => 'number',
'step' => 10,
'min' => 0,
'max' => 100,
'std' => 50,
'label' => __('Overlay Opacity (Default 50%)', 'ooze'),
),
);
parent::__construct();
}
/**
* Output widget.
*
* @see WP_Widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
ob_start();
echo $args['before_widget'];
do_action('ooze_before_cta');
?>
<?php if ($instance['bg_image'] && 0 != $instance['bg_image']): ?>
<?php
$style_text = 'color:' . $instance['text_color_option'] . ';';
$style_text .= 'min-height:' . $instance['height'] . 'px;';
$style_text .= 'text-align:' . $instance['text_align'] . ';';
$style = 'background-color:' . $instance['bg_overlay_color'] . ';';
$style .= 'opacity:' . ($instance['overlay_opacity'] / 100) . ';';
?>
<div class="ooze-cta-widget ooze-cover-block <?php echo ($instance['enable_fixed_bg']) ? 'ooze-bg-image ooze-bg-attachment-fixed' : ''; ?>"
style="<?php echo esc_attr($style_text); ?>">
<span aria-hidden="true" class="ooze-block-overlay" style="<?php echo esc_attr($style); ?>"></span>
<?php echo wp_get_attachment_image($instance['bg_image'], 'full'); ?>
<div class="ooze-cta-inner-wrapper ooze-block-inner-wrapper">
<?php if ($instance['title']): ?>
<h2 class="entry-title font-size-big mb-8 animate__animated animate__fadeInUp animate__delay-1s">
<?php echo esc_html($instance['title']); ?>
</h2>
<?php endif; ?>
<?php if ($instance['title_text']): ?>
<h3 class="entry-title font-size-medium mb-8 animate__animated animate__fadeInUp animate__delay-2s">
<?php echo esc_html($instance['title_text']); ?>
</h3>
<?php endif; ?>
<?php if ($instance['desc']): ?>
<div class="entry-summary animate__animated animate__fadeInUp animate__delay-3s">
<?php echo wpautop(wp_kses_post($instance['desc'])); ?>
</div>
<?php endif; ?>
<?php if ($instance['btn_text']): ?>
<footer class="entry-footer animate__animated animate__fadeInUp animate__delay-4s">
<a href="<?php echo ($instance['btn_link']) ? esc_url($instance['btn_link']) : ''; ?>"
target="<?php echo ($instance['link_target']) ? "_blank" : '_self'; ?>" class="theme-button">
<?php echo esc_html(($instance['btn_text'])); ?>
</a>
</footer>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php
do_action('ooze_after_cta');
echo $args['after_widget'];
echo ob_get_clean();
}
}