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