PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.14
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / Widgets / FireBoxButton.php

FireBoxButton.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.14, at Inc/Core/Widgets/FireBoxButton.php

115 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 2.1.14 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Widgets;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Includes/Abstracts/FPF_Widget.php';
20
21 class FireBoxButton extends \FPF_Widget
22 {
23 public function __construct() {
24 $this->widget_cssclass = '';
25 $this->widget_description = firebox()->_('FB_CHOOSE_BOX_TO_HANDLE');
26 $this->widget_id = 'firebox_add_button_widget';
27 $this->widget_name = firebox()->_('FB_ADD_A_FIREBOX_BUTTON');
28 $this->settings = [
29 'box' => [
30 'type' => 'select',
31 'default' => '',
32 'label' => firebox()->_('FB_SELECT_A_CAMPAIGN'),
33 'options' => \FireBox\Core\Helpers\BoxHelper::getAllBoxesParsedByKeyValue()
34 ],
35 'action' => [
36 'type' => 'select',
37 'default' => 'close',
38 'label' => firebox()->_('FB_FIREBOX_ACTION'),
39 'options' => [
40 'open' => firebox()->_('FB_OPEN'),
41 'close' => firebox()->_('FB_CLOSE'),
42 'toggle' => firebox()->_('FB_TOGGLE'),
43 ]
44 ],
45 'button_label' => [
46 'type' => 'text',
47 'default' => firebox()->_('FB_CLOSE'),
48 'label' => firebox()->_('FB_BUTTON_LABEL')
49 ],
50 'button_classes' => [
51 'type' => 'text',
52 'default' => 'button',
53 'label' => firebox()->_('FB_BUTTON_CLASSES')
54 ],
55 'button_link' => [
56 'type' => 'text',
57 'default' => '',
58 'label' => firebox()->_('FB_BUTTON_LINK')
59 ],
60 'prevent_default' => [
61 'type' => 'checkbox',
62 'default' => true,
63 'label' => firebox()->_('FB_METABOX_PREVENTDEFAULT')
64 ],
65 ];
66
67 parent::__construct();
68 }
69
70 /**
71 * Widget Output
72 *
73 * @param array $args
74 * @param array $instance
75 *
76 * @return void
77 */
78 public function widget($args, $instance)
79 {
80 if ($this->get_cached_widget($args))
81 {
82 return;
83 }
84
85 ob_start();
86
87 $box = !empty($instance['box']) ? absint($instance['box']) : '';
88 $action = !empty($instance['action']) ? strval($instance['action']) : '';
89 $button_label = !empty($instance['button_label']) ? strval($instance['button_label']) : '';
90 $button_classes = !empty($instance['button_classes']) ? strval($instance['button_classes']) : '';
91 $button_link = !empty($instance['button_link']) ? $instance['button_link'] : '';
92 $prevent_default = !empty($instance['prevent_default']) ? $instance['prevent_default'] : false;
93
94 if (empty($box) || empty($action) || empty($button_label))
95 {
96 return;
97 }
98
99 $box = ' data-fbox="' . esc_attr($box) . '"';
100 $action = ' data-fbox-cmd="' . esc_attr($action) . '"';
101 $prevent_default = ' data-fbox-prevent="' . ($prevent_default ? '1' : '0') . '"';
102
103 $this->widget_start($args, $instance);
104 ?>
105 <a href="<?php echo esc_url($button_link); ?>"<?php echo wp_kses_data($box . $action . $prevent_default); ?> class="<?php echo esc_attr($button_classes); ?>"><?php echo esc_html($button_label); ?></a>
106 <?php
107 $this->widget_end($args );
108
109 $content = ob_get_clean();
110
111 echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
112
113 $this->cache_widget($args, $content);
114 }
115 }