| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Addons; |
| 4 |
|
| 5 |
/** |
| 6 |
* Author Name: Liton Arefin |
| 7 |
* Author URL: https://jeweltheme.com |
| 8 |
* Date: 8/18/19 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Elementor Classes |
| 12 |
use MasterAddons\Inc\Classes\Base\Master_Widget; |
| 13 |
use \Elementor\Controls_Manager; |
| 14 |
use \Elementor\Repeater; |
| 15 |
use \Elementor\Group_Control_Typography; |
| 16 |
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 17 |
|
| 18 |
use MasterAddons\Inc\Admin\Config; |
| 19 |
|
| 20 |
if (!defined('ABSPATH')) exit; // If this file is called directly, abort. |
| 21 |
|
| 22 |
class Changelogs extends Master_Widget |
| 23 |
{ |
| 24 |
use \MasterAddons\Inc\Traits\Widget_Notice; |
| 25 |
use \MasterAddons\Inc\Traits\Widget_Assets_Trait; |
| 26 |
|
| 27 |
public function get_name() |
| 28 |
{ |
| 29 |
return 'ma-changelog'; |
| 30 |
} |
| 31 |
public function get_title() |
| 32 |
{ |
| 33 |
return esc_html__('Changelog', 'master-addons' ); |
| 34 |
} |
| 35 |
|
| 36 |
public function get_icon() |
| 37 |
{ |
| 38 |
return 'jltma-icon ' . Config::get_addon_icon($this->get_name()); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
protected function register_controls() |
| 43 |
{ |
| 44 |
|
| 45 |
/** |
| 46 |
* Master Headlines Content Section |
| 47 |
*/ |
| 48 |
$this->start_controls_section( |
| 49 |
'ma_el_changelog_content_section', |
| 50 |
[ |
| 51 |
'label' => esc_html__('Changelog Content', 'master-addons' ), |
| 52 |
] |
| 53 |
); |
| 54 |
|
| 55 |
$this->add_control( |
| 56 |
'ma_el_changelog_heading', |
| 57 |
[ |
| 58 |
'label' => esc_html__('Heading', 'master-addons' ), |
| 59 |
'type' => Controls_Manager::TEXT, |
| 60 |
'label_block' => true, |
| 61 |
'default' => esc_html__('1.1.1 [18th August 2019]', 'master-addons' ), |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_control( |
| 66 |
'ma_el_changelog_main_title', |
| 67 |
[ |
| 68 |
'label' => esc_html__('Main Title', 'master-addons' ), |
| 69 |
'type' => Controls_Manager::SELECT, |
| 70 |
'default' => 'Added', |
| 71 |
'options' => [ |
| 72 |
'Added' => esc_html__('Added', 'master-addons' ), |
| 73 |
'Fixed' => esc_html__('Fixed', 'master-addons' ), |
| 74 |
'Updated' => esc_html__('Updated', 'master-addons' ), |
| 75 |
'Removed' => esc_html__('Removed', 'master-addons' ), |
| 76 |
'Changed' => esc_html__('Changed', 'master-addons' ), |
| 77 |
'Note' => esc_html__('Note', 'master-addons' ), |
| 78 |
'Info' => esc_html__('Info', 'master-addons' ), |
| 79 |
'Language' => esc_html__('Language', 'master-addons' ), |
| 80 |
] |
| 81 |
] |
| 82 |
); |
| 83 |
$repeater = new Repeater(); |
| 84 |
|
| 85 |
$repeater->add_control( |
| 86 |
'ma_el_changelog_title', |
| 87 |
[ |
| 88 |
'label' => esc_html__('Title', 'master-addons' ), |
| 89 |
'type' => Controls_Manager::SELECT, |
| 90 |
'default' => 'Fixed', |
| 91 |
'options' => [ |
| 92 |
'Added' => esc_html__('Added', 'master-addons' ), |
| 93 |
'Fixed' => esc_html__('Fixed', 'master-addons' ), |
| 94 |
'Updated' => esc_html__('Updated', 'master-addons' ), |
| 95 |
'Removed' => esc_html__('Removed', 'master-addons' ), |
| 96 |
'Changed' => esc_html__('Changed', 'master-addons' ), |
| 97 |
'Note' => esc_html__('Note', 'master-addons' ), |
| 98 |
'Info' => esc_html__('Info', 'master-addons' ), |
| 99 |
'Language' => esc_html__('Language', 'master-addons' ), |
| 100 |
] |
| 101 |
] |
| 102 |
); |
| 103 |
|
| 104 |
$repeater->add_control( |
| 105 |
'ma_el_changelog_content', |
| 106 |
[ |
| 107 |
'label' => __('Content', 'master-addons' ), |
| 108 |
'type' => Controls_Manager::TEXTAREA, |
| 109 |
'default' => __( |
| 110 |
'Changelog Contents. If you want to link them, enable option below.', |
| 111 |
'master-addons' |
| 112 |
), |
| 113 |
'dynamic' => [ |
| 114 |
'active' => true, |
| 115 |
], |
| 116 |
] |
| 117 |
); |
| 118 |
// |
| 119 |
// $repeater->add_control( |
| 120 |
// 'ma_changelog_content_link', |
| 121 |
// [ |
| 122 |
// 'label' => esc_html__( 'Content Link URL', 'master-addons' ), |
| 123 |
// 'type' => Controls_Manager::URL, |
| 124 |
// 'label_block' => true, |
| 125 |
// 'default' => [ |
| 126 |
// 'url' => '#', |
| 127 |
// 'is_external' => true, |
| 128 |
// ], |
| 129 |
// 'show_external' => true, |
| 130 |
// ] |
| 131 |
// ); |
| 132 |
|
| 133 |
$this->add_control( |
| 134 |
'changelog_tabs', |
| 135 |
[ |
| 136 |
'type' => Controls_Manager::REPEATER, |
| 137 |
'default' => [ |
| 138 |
['ma_el_changelog_title' => esc_html__('Added', 'master-addons' )], |
| 139 |
['ma_el_changelog_title' => esc_html__('Fixed', 'master-addons' )], |
| 140 |
], |
| 141 |
'fields' => $repeater->get_controls(), |
| 142 |
'title_field' => '{{ma_el_changelog_title}}', |
| 143 |
] |
| 144 |
); |
| 145 |
|
| 146 |
$this->end_controls_section(); |
| 147 |
|
| 148 |
/** |
| 149 |
* Style Tab: Heading |
| 150 |
*/ |
| 151 |
$this->start_controls_section( |
| 152 |
'ma_el_changelog_heading_style', |
| 153 |
[ |
| 154 |
'label' => esc_html__('Heading', 'master-addons' ), |
| 155 |
'tab' => Controls_Manager::TAB_STYLE, |
| 156 |
] |
| 157 |
); |
| 158 |
|
| 159 |
$this->add_control( |
| 160 |
'ma_el_changelog_heading_color', |
| 161 |
[ |
| 162 |
'label' => esc_html__('Color', 'master-addons' ), |
| 163 |
'type' => Controls_Manager::COLOR, |
| 164 |
'selectors' => [ |
| 165 |
'{{WRAPPER}} .jltma-changelog .jltma-changelog-heading' => 'color: {{VALUE}};', |
| 166 |
], |
| 167 |
] |
| 168 |
); |
| 169 |
|
| 170 |
$this->add_group_control( |
| 171 |
Group_Control_Typography::get_type(), |
| 172 |
[ |
| 173 |
'name' => 'ma_el_changelog_heading_typography', |
| 174 |
'selector' => '{{WRAPPER}} .jltma-changelog .jltma-changelog-heading', |
| 175 |
'global' => [ |
| 176 |
'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 177 |
], |
| 178 |
] |
| 179 |
); |
| 180 |
|
| 181 |
$this->end_controls_section(); |
| 182 |
|
| 183 |
/** |
| 184 |
* Style Tab: Title |
| 185 |
*/ |
| 186 |
$this->start_controls_section( |
| 187 |
'ma_el_changelog_title_style', |
| 188 |
[ |
| 189 |
'label' => esc_html__('Title', 'master-addons' ), |
| 190 |
'tab' => Controls_Manager::TAB_STYLE, |
| 191 |
] |
| 192 |
); |
| 193 |
|
| 194 |
$this->add_control( |
| 195 |
'ma_el_changelog_title_color', |
| 196 |
[ |
| 197 |
'label' => esc_html__('Color', 'master-addons' ), |
| 198 |
'type' => Controls_Manager::COLOR, |
| 199 |
'selectors' => [ |
| 200 |
'{{WRAPPER}} .jltma-changelog .jltma-changelog-title' => 'color: {{VALUE}};', |
| 201 |
], |
| 202 |
] |
| 203 |
); |
| 204 |
|
| 205 |
$this->add_group_control( |
| 206 |
Group_Control_Typography::get_type(), |
| 207 |
[ |
| 208 |
'name' => 'ma_el_changelog_title_typography', |
| 209 |
'selector' => '{{WRAPPER}} .jltma-changelog .jltma-changelog-title', |
| 210 |
'global' => [ |
| 211 |
'default' => Global_Typography::TYPOGRAPHY_SECONDARY, |
| 212 |
], |
| 213 |
] |
| 214 |
); |
| 215 |
|
| 216 |
$this->end_controls_section(); |
| 217 |
|
| 218 |
/** |
| 219 |
* Style Tab: Content |
| 220 |
*/ |
| 221 |
$this->start_controls_section( |
| 222 |
'ma_el_changelog_content_style', |
| 223 |
[ |
| 224 |
'label' => esc_html__('Content', 'master-addons' ), |
| 225 |
'tab' => Controls_Manager::TAB_STYLE, |
| 226 |
] |
| 227 |
); |
| 228 |
|
| 229 |
$this->add_control( |
| 230 |
'ma_el_changelog_content_color', |
| 231 |
[ |
| 232 |
'label' => esc_html__('Color', 'master-addons' ), |
| 233 |
'type' => Controls_Manager::COLOR, |
| 234 |
'selectors' => [ |
| 235 |
'{{WRAPPER}} .jltma-changelog ul li' => 'color: {{VALUE}};', |
| 236 |
], |
| 237 |
] |
| 238 |
); |
| 239 |
|
| 240 |
$this->add_group_control( |
| 241 |
Group_Control_Typography::get_type(), |
| 242 |
[ |
| 243 |
'name' => 'ma_el_changelog_content_typography', |
| 244 |
'selector' => '{{WRAPPER}} .jltma-changelog ul li', |
| 245 |
'global' => [ |
| 246 |
'default' => Global_Typography::TYPOGRAPHY_TEXT, |
| 247 |
], |
| 248 |
] |
| 249 |
); |
| 250 |
|
| 251 |
$this->end_controls_section(); |
| 252 |
|
| 253 |
// Help Docs section (links from config.php) |
| 254 |
$this->jltma_help_docs(); |
| 255 |
|
| 256 |
$this->upgrade_to_pro_message(); |
| 257 |
|
| 258 |
} |
| 259 |
|
| 260 |
protected function render() |
| 261 |
{ |
| 262 |
$settings = $this->get_settings_for_display(); |
| 263 |
?> |
| 264 |
|
| 265 |
<div id="jltma-changelog-<?php echo esc_attr($this->get_id()); ?>" class="jltma-changelog"> |
| 266 |
<?php if ($settings['ma_el_changelog_heading']) { ?> |
| 267 |
<h2 class="jltma-changelog-heading"> |
| 268 |
<?php echo esc_html($this->parse_text_editor($settings['ma_el_changelog_heading'])); ?> |
| 269 |
</h2> |
| 270 |
<?php } ?> |
| 271 |
|
| 272 |
<?php if ($settings['ma_el_changelog_main_title']) { ?> |
| 273 |
<h3 class="jltma-changelog-title"> |
| 274 |
<?php echo esc_html($this->parse_text_editor($settings['ma_el_changelog_main_title'])); ?> |
| 275 |
</h3> |
| 276 |
<?php } ?> |
| 277 |
|
| 278 |
<?php foreach ($settings['changelog_tabs'] as $index => $tab) { ?> |
| 279 |
<ul> |
| 280 |
<li> |
| 281 |
<span class="jltma-label jltma-<?php echo esc_attr( strtolower($tab['ma_el_changelog_title']) ); ?>"> |
| 282 |
<?php echo wp_kses_post( $this->parse_text_editor($tab['ma_el_changelog_title']) ); ?> |
| 283 |
</span> |
| 284 |
<?php echo wp_kses_post( $this->parse_text_editor($tab['ma_el_changelog_content']) ); ?> |
| 285 |
</li> |
| 286 |
</ul> |
| 287 |
|
| 288 |
<?php } ?> |
| 289 |
|
| 290 |
</div> |
| 291 |
|
| 292 |
<?php |
| 293 |
} |
| 294 |
} |
| 295 |
|