PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 4.0.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v4.0.0
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / components / buttons / class-button.php
superb-blocks / src / components / buttons Last commit date
class-button.php 1 month ago class-insert-button.php 1 month ago class-premium-button.php 1 month ago class-preview-button.php 1 month ago
class-button.php
63 lines
1 <?php
2
3 namespace SuperbAddons\Components\Buttons;
4
5 defined('ABSPATH') || exit();
6
7 class Button
8 {
9 private $type;
10 private $text;
11 private $icon;
12 private $url;
13 private $class;
14 private $target;
15 private $id;
16 private $data;
17
18 public function __construct($type = ButtonType::Primary, $icon = ButtonIcon::ExternalLink, $options = array())
19 {
20
21 $this->text = isset($options['text']) ? $options['text'] : '';
22 $this->url = isset($options['url']) ? $options['url'] : '';
23 $this->id = isset($options['id']) ? $options['id'] : '';
24 $this->class = isset($options['class']) ? $options['class'] : '';
25 $this->target = isset($options['target']) ? $options['target'] : '';
26 $this->data = isset($options['data']) && is_array($options['data']) ? $options['data'] : array();
27 $this->type = $type;
28 $this->icon = $icon;
29
30 $this->Render();
31 }
32
33 private function Render()
34 {
35 ?>
36 <a id="<?php echo esc_attr($this->id); ?>" <?php echo !empty($this->url) ? 'href="' . esc_url($this->url) . '"' : ''; ?> <?php echo !empty($this->target) ? 'target="' . esc_attr($this->target) . '"' : ''; ?><?php foreach ($this->data as $key => $value) : ?> data-<?php echo esc_attr($key); ?>="<?php echo esc_attr($value); ?>"<?php endforeach; ?> class="superb-addons-template-library-button superb-addons-template-library-button-<?php echo esc_attr($this->type); ?> <?php echo esc_attr($this->class); ?>">
37 <?php if (!empty($this->text)) {
38 echo esc_html($this->text);
39 }
40
41 if (!empty($this->icon)) : ?>
42 <img src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . "/img/" . esc_attr($this->icon)); ?>" />
43 <?php endif; ?>
44 </a>
45 <?php
46 }
47 }
48
49 class ButtonType
50 {
51 const Primary = 'primary';
52 const Secondary = 'secondary';
53 const Success = 'success';
54 const Danger = 'danger';
55 }
56
57 class ButtonIcon
58 {
59 const Insert = 'plus-circle.svg';
60 const Preview = 'preview.svg';
61 const ExternalLink = 'external-link.svg';
62 }
63