forked from alexander-young/custom-elementor-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
advertisement.php
119 lines (99 loc) · 2.82 KB
/
advertisement.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace WPC\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class Advertisement extends Widget_Base{
public function get_name(){
return 'advertisement';
}
public function get_title(){
return 'Advertisement';
}
public function get_icon(){
return 'fa fa-camera';
}
public function get_categories(){
return ['general'];
}
protected function _register_controls(){
$this->start_controls_section(
'section_content',
[
'label' => 'Settings',
]
);
$this->add_control(
'label_heading',
[
'label' => 'Label Heading',
'type' => \Elementor\Controls_Manager::TEXT,
'default' => 'My Example Heading'
]
);
$this->add_control(
'content_heading',
[
'label' => 'Content Heading',
'type' => \Elementor\Controls_Manager::TEXT,
'default' => 'My Other Example Heading'
]
);
$this->add_control(
'content',
[
'label' => 'Content',
'type' => \Elementor\Controls_Manager::WYSIWYG,
'default' => 'Some example content. Start Editing Here.'
]
);
$this->end_controls_section();
}
protected function render(){
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes('label_heading', 'basic');
$this->add_render_attribute(
'label_heading',
[
'class' => ['advertisement__label-heading'],
]
);
?>
<div class="advertisement">
<div <?php echo $this->get_render_attribute_string('label_heading'); ?>>
<?php echo $settings['label_heading']?>
</div>
<div class="advertisement__content">
<div class="advertisement__content__heading" <?php echo $this->get_render_attribute_string('content_heading'); ?>>
<?php echo $settings['content_heading'] ?>
</div>
<div class="advertisement__content__copy" <?php echo $this->get_render_attribute_string('content'); ?>>
<?php echo $settings['content'] ?>
</div>
</div>
</div>
<?php
}
protected function _content_template(){
?>
<#
view.addInlineEditingAttributes( 'label_heading', 'basic' );
view.addRenderAttribute(
'label_heading',
{
'class': [ 'advertisement__label-heading' ],
}
);
#>
<div class="advertisement">
<div {{{ view.getRenderAttributeString( 'label_heading' ) }}}>{{{ settings.label_heading }}}</div>
<div class="advertisement__content">
<div class="advertisement__content__heading">{{{ settings.content_heading }}}</div>
<div class="advertisement__content__copy">
{{{ settings.content }}}
</div>
</div>
</div>
<?php
}
}