Branding.php
211 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress\Includes\Traits; |
| 4 | |
| 5 | if (!defined('ABSPATH')) { |
| 6 | exit; |
| 7 | } // Exit if accessed directly |
| 8 | use Elementor\Controls_Manager as Controls_Manager; |
| 9 | use Elementor\Group_Control_Image_Size; |
| 10 | use EmbedPress\Includes\Classes\Helper; |
| 11 | |
| 12 | |
| 13 | trait Branding |
| 14 | { |
| 15 | /** |
| 16 | * @param string $provider_name |
| 17 | */ |
| 18 | public function init_branding_controls($provider_name = '') |
| 19 | { |
| 20 | if (!isset($this->pro_class)) { |
| 21 | $this->pro_class = ''; |
| 22 | } |
| 23 | if (!isset($this->pro_text)) { |
| 24 | $this->pro_text = ''; |
| 25 | } |
| 26 | $logo_condition = [ |
| 27 | "embedpress_pro_{$provider_name}_logo[url]!" => '' |
| 28 | ]; |
| 29 | $condition = []; |
| 30 | if ($provider_name !== 'document') { |
| 31 | $logo_condition["embedpress_pro_embeded_source"] = $provider_name; |
| 32 | $condition["embedpress_pro_embeded_source"] = $provider_name; |
| 33 | } |
| 34 | $this->add_control( |
| 35 | "{$provider_name}_custom_logo_cta_heading", |
| 36 | [ |
| 37 | 'label' => __('Custom Branding', 'embedpress'), |
| 38 | 'type' => Controls_Manager::HEADING, |
| 39 | 'separator' => 'before', |
| 40 | 'condition' => $condition, |
| 41 | ] |
| 42 | ); |
| 43 | $this->add_control( |
| 44 | "embedpress_pro_{$provider_name}_logo", |
| 45 | [ |
| 46 | 'label' => sprintf(__('Custom Logo %s', 'embedpress'), $this->pro_text), |
| 47 | 'description' => __('Leave it empty to hide it', 'embedpress'), |
| 48 | 'type' => Controls_Manager::MEDIA, |
| 49 | 'dynamic' => [ |
| 50 | 'active' => true, |
| 51 | ], |
| 52 | 'classes' => $this->pro_class, |
| 53 | 'condition' => $condition, |
| 54 | 'default' => [ |
| 55 | 'url' => Helper::get_branding_value('logo_url', $provider_name) |
| 56 | ], |
| 57 | ] |
| 58 | ); |
| 59 | |
| 60 | $this->add_group_control( |
| 61 | Group_Control_Image_Size::get_type(), |
| 62 | [ |
| 63 | 'name' => "embedpress_pro_{$provider_name}_logo", |
| 64 | 'default' => 'full', |
| 65 | 'condition' => $logo_condition, |
| 66 | 'classes' => $this->pro_class, |
| 67 | ] |
| 68 | ); |
| 69 | $this->add_responsive_control( |
| 70 | "embedpress_pro_{$provider_name}_logo_xpos", |
| 71 | [ |
| 72 | 'label' => sprintf(__('Logo X Position %s', 'embedpress'), $this->pro_text), |
| 73 | 'description' => __('Change this number to move your logo in horizontal direction.', 'embedpress'), |
| 74 | 'type' => Controls_Manager::SLIDER, |
| 75 | 'size_units' => ['px', '%'], |
| 76 | 'range' => [ |
| 77 | 'px' => [ |
| 78 | 'min' => 0, |
| 79 | 'max' => 1000, |
| 80 | 'step' => 5, |
| 81 | ], |
| 82 | '%' => [ |
| 83 | 'min' => 0, |
| 84 | 'max' => 100, |
| 85 | ], |
| 86 | ], |
| 87 | 'default' => [ |
| 88 | 'unit' => '%', |
| 89 | 'size' => 10, |
| 90 | ], |
| 91 | 'selectors' => [ |
| 92 | "{{WRAPPER}} .ose-{$provider_name} .watermark, {{WRAPPER}} .ep-embed-content-wraper .watermark" => 'right: {{SIZE}}{{UNIT}};', |
| 93 | ], |
| 94 | 'condition' => $logo_condition, |
| 95 | 'classes' => $this->pro_class, |
| 96 | ] |
| 97 | ); |
| 98 | $this->add_responsive_control( |
| 99 | "embedpress_pro_{$provider_name}_logo_ypos", |
| 100 | [ |
| 101 | 'label' => sprintf(__('Logo Y Position %s', 'embedpress'), $this->pro_text), |
| 102 | 'description' => __('Change this number to move your logo in vertical direction.', 'embedpress'), |
| 103 | 'type' => Controls_Manager::SLIDER, |
| 104 | 'size_units' => ['px', '%'], |
| 105 | 'range' => [ |
| 106 | 'px' => [ |
| 107 | 'min' => 0, |
| 108 | 'max' => 1000, |
| 109 | 'step' => 5, |
| 110 | ], |
| 111 | '%' => [ |
| 112 | 'min' => 0, |
| 113 | 'max' => 100, |
| 114 | ], |
| 115 | ], |
| 116 | 'default' => [ |
| 117 | 'unit' => '%', |
| 118 | 'size' => 10, |
| 119 | ], |
| 120 | 'selectors' => [ |
| 121 | "{{WRAPPER}} .ose-{$provider_name} .watermark, {{WRAPPER}} .ep-embed-content-wraper .watermark" => 'bottom: {{SIZE}}{{UNIT}};', |
| 122 | ], |
| 123 | 'condition' => $logo_condition, |
| 124 | 'classes' => $this->pro_class, |
| 125 | |
| 126 | ] |
| 127 | ); |
| 128 | $this->start_controls_tabs( |
| 129 | "ep_{$provider_name}_cta_style_tabs", |
| 130 | [ |
| 131 | 'condition' => $logo_condition, |
| 132 | ] |
| 133 | ); |
| 134 | $this->start_controls_tab( |
| 135 | "ep_{$provider_name}_cta_normal_tab", |
| 136 | [ |
| 137 | 'label' => __('Normal', 'embedpress'), |
| 138 | ] |
| 139 | ); |
| 140 | $this->add_control( |
| 141 | "embedpress_pro_{$provider_name}_logo_opacity", |
| 142 | [ |
| 143 | 'label' => sprintf(__('Logo Opacity %s', 'embedpress'), $this->pro_text), |
| 144 | 'type' => Controls_Manager::SLIDER, |
| 145 | 'default' => [ |
| 146 | 'size' => .5, |
| 147 | ], |
| 148 | 'range' => [ |
| 149 | 'px' => [ |
| 150 | 'max' => 1, |
| 151 | 'step' => 0.01, |
| 152 | ], |
| 153 | ], |
| 154 | 'selectors' => [ |
| 155 | "{{WRAPPER}} .ose-{$provider_name} .watermark, {{WRAPPER}} .ep-embed-content-wraper .watermark" => 'opacity: {{SIZE}}!important;', |
| 156 | ], |
| 157 | 'condition' => $logo_condition, |
| 158 | 'classes' => $this->pro_class, |
| 159 | |
| 160 | ] |
| 161 | ); |
| 162 | $this->end_controls_tab(); |
| 163 | $this->start_controls_tab( |
| 164 | "ep_{$provider_name}_cta_hover__tab", |
| 165 | [ |
| 166 | 'label' => __('Hover', 'embedpress'), |
| 167 | ] |
| 168 | ); |
| 169 | $this->add_control( |
| 170 | "embedpress_pro_{$provider_name}_logo_opacity_hover", |
| 171 | [ |
| 172 | 'label' => sprintf(__('Logo Opacity %s', 'embedpress'), $this->pro_text), |
| 173 | 'type' => Controls_Manager::SLIDER, |
| 174 | 'size_units' => ['%'], |
| 175 | 'default' => [ |
| 176 | 'size' => 1, |
| 177 | ], |
| 178 | 'range' => [ |
| 179 | 'px' => [ |
| 180 | 'max' => 1, |
| 181 | 'step' => 0.01, |
| 182 | ], |
| 183 | ], |
| 184 | 'selectors' => [ |
| 185 | "{{WRAPPER}} .ose-{$provider_name} .watermark:hover, {{WRAPPER}} .ep-embed-content-wraper .watermark:hover" => 'opacity: {{SIZE}};', |
| 186 | ], |
| 187 | 'condition' => $logo_condition, |
| 188 | 'classes' => $this->pro_class, |
| 189 | |
| 190 | ] |
| 191 | ); |
| 192 | $this->end_controls_tab(); |
| 193 | $this->end_controls_tabs(); |
| 194 | $this->add_control( |
| 195 | "embedpress_pro_{$provider_name}_cta", |
| 196 | [ |
| 197 | 'label' => sprintf(__('CTA link for Logo %s', 'embedpress'), $this->pro_text), |
| 198 | 'description' => __('You can show the logo inside a link. Leave it empty to hide it', 'embedpress'), |
| 199 | 'type' => Controls_Manager::URL, |
| 200 | 'dynamic' => [ |
| 201 | 'active' => true, |
| 202 | ], |
| 203 | 'placeholder' => __('https://your-link.com', 'embedpress'), |
| 204 | 'condition' => $logo_condition, |
| 205 | 'classes' => $this->pro_class, |
| 206 | 'separator' => 'before', |
| 207 | ] |
| 208 | ); |
| 209 | } |
| 210 | } |
| 211 |