| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Traits; |
| 4 |
|
| 5 |
use MasterAddons\Inc\Classes\Helper; |
| 6 |
use MasterAddons\Inc\Admin\Config; |
| 7 |
use Elementor\Controls_Manager; |
| 8 |
|
| 9 |
if (!defined('ABSPATH')) exit; // If this file is called directly, abort. |
| 10 |
|
| 11 |
trait Widget_Notice |
| 12 |
{ |
| 13 |
/** |
| 14 |
* Adding Go Premium message to all widgets |
| 15 |
*/ |
| 16 |
public function upgrade_to_pro_message() |
| 17 |
{ |
| 18 |
if (!Helper::jltma_premium()) { |
| 19 |
$this->start_controls_section( |
| 20 |
'jltma_pro_section', |
| 21 |
[ |
| 22 |
'label' => sprintf( |
| 23 |
/* translators: %s: icon for the "Pro" section */ |
| 24 |
__('%s Unlock more possibilities', 'master-addons'), |
| 25 |
'<i class="eicon-pro-icon"></i>' |
| 26 |
), |
| 27 |
] |
| 28 |
); |
| 29 |
|
| 30 |
$this->add_control( |
| 31 |
'jltma_get_pro_style_tab', |
| 32 |
[ |
| 33 |
'label' => __('Unlock more possibilities', 'master-addons'), |
| 34 |
'type' => Controls_Manager::CHOOSE, |
| 35 |
'options' => [ |
| 36 |
'1' => [ |
| 37 |
'title' => '', |
| 38 |
'icon' => 'eicon-lock', |
| 39 |
], |
| 40 |
], |
| 41 |
'default' => '1', |
| 42 |
'toggle' => false, |
| 43 |
'description' => Helper::unlock_pro_feature(), |
| 44 |
] |
| 45 |
); |
| 46 |
|
| 47 |
$this->end_controls_section(); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Add Help Docs section with links from config |
| 53 |
* Auto-detects widget key from $this->get_name() if not provided |
| 54 |
* |
| 55 |
* @param string $widget_key Optional widget key (defaults to $this->get_name()) |
| 56 |
*/ |
| 57 |
public function jltma_help_docs($widget_key = '') |
| 58 |
{ |
| 59 |
// Auto-detect widget key from widget name if not provided |
| 60 |
if (empty($widget_key)) { |
| 61 |
$widget_key = $this->get_name(); |
| 62 |
} |
| 63 |
|
| 64 |
// Get docs from config |
| 65 |
$docs = Config::get_addon_docs($widget_key); |
| 66 |
|
| 67 |
// Skip if no links available |
| 68 |
if (empty($docs['demo_url']) && empty($docs['docs_url']) && empty($docs['tuts_url'])) { |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
$demo_url = $docs['demo_url'] ?? ''; |
| 73 |
$docs_url = $docs['docs_url'] ?? ''; |
| 74 |
$tuts_url = $docs['tuts_url'] ?? ''; |
| 75 |
|
| 76 |
$this->start_controls_section( |
| 77 |
'jltma_section_help_docs', |
| 78 |
[ |
| 79 |
'label' => esc_html__('Help Docs', 'master-addons'), |
| 80 |
] |
| 81 |
); |
| 82 |
|
| 83 |
$control_index = 1; |
| 84 |
|
| 85 |
if (!empty($demo_url)) { |
| 86 |
$this->add_control( |
| 87 |
'help_doc_' . $control_index++, |
| 88 |
[ |
| 89 |
'type' => Controls_Manager::RAW_HTML, |
| 90 |
'raw' => sprintf( |
| 91 |
/* translators: %1$s: Opening anchor tag, %2$s: Closing anchor tag. */ |
| 92 |
esc_html__('%1$s Live Demo %2$s', 'master-addons'), |
| 93 |
'<a href="' . esc_url($demo_url) . '" target="_blank" rel="noopener">', |
| 94 |
'</a>' |
| 95 |
), |
| 96 |
'content_classes' => 'jltma-editor-doc-links', |
| 97 |
] |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
if (!empty($docs_url)) { |
| 102 |
$this->add_control( |
| 103 |
'help_doc_' . $control_index++, |
| 104 |
[ |
| 105 |
'type' => Controls_Manager::RAW_HTML, |
| 106 |
'raw' => sprintf( |
| 107 |
/* translators: %1$s: Opening anchor tag, %2$s: Closing anchor tag. */ |
| 108 |
esc_html__('%1$s Documentation %2$s', 'master-addons'), |
| 109 |
'<a href="' . esc_url($docs_url) . '?utm_source=widget&utm_medium=panel&utm_campaign=dashboard" target="_blank" rel="noopener">', |
| 110 |
'</a>' |
| 111 |
), |
| 112 |
'content_classes' => 'jltma-editor-doc-links', |
| 113 |
] |
| 114 |
); |
| 115 |
} |
| 116 |
|
| 117 |
if (!empty($tuts_url)) { |
| 118 |
$this->add_control( |
| 119 |
'help_doc_' . $control_index++, |
| 120 |
[ |
| 121 |
'type' => Controls_Manager::RAW_HTML, |
| 122 |
'raw' => sprintf( |
| 123 |
/* translators: %1$s: Opening anchor tag, %2$s: Closing anchor tag. */ |
| 124 |
esc_html__('%1$s Watch Video Tutorial %2$s', 'master-addons'), |
| 125 |
'<a href="' . esc_url($tuts_url) . '" target="_blank" rel="noopener">', |
| 126 |
'</a>' |
| 127 |
), |
| 128 |
'content_classes' => 'jltma-editor-doc-links', |
| 129 |
] |
| 130 |
); |
| 131 |
} |
| 132 |
|
| 133 |
$this->end_controls_section(); |
| 134 |
} |
| 135 |
} |
| 136 |
|