| @@ -1,619 +1,96 @@ | ||
| 1 | -<?php | |
| 2 | -namespace Easyel\EasyElements\Widgets; | |
| 3 | -use Elementor\Controls_Manager; | |
| 4 | -use Elementor\Widget_Base; | |
| 5 | - | |
| 6 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | - exit; | |
| 8 | -} | |
| 9 | - | |
| 10 | -class Easyel_Free_Post_content_Widget extends \Elementor\Widget_Base { | |
| 11 | - | |
| 12 | - public function get_name() { | |
| 13 | - return 'eel-post-content'; | |
| 14 | - } | |
| 15 | - | |
| 16 | - public function get_title() { | |
| 17 | - return __( 'Post Content', 'easy-elements' ); | |
| 18 | - } | |
| 19 | - | |
| 20 | - public function get_icon() { | |
| 21 | - return 'easyicon easyelIcon-post-content'; | |
| 22 | - } | |
| 23 | - | |
| 24 | - public function get_categories() { | |
| 25 | - return [ 'easyelements_category' ]; | |
| 26 | - } | |
| 27 | - | |
| 28 | - public function get_keywords() { | |
| 29 | - return [ 'post', 'content', 'link', 'click', 'text' ]; | |
| 30 | - } | |
| 31 | - | |
| 32 | - public function get_style_depends() { | |
| 33 | - return [ | |
| 34 | - 'eel-post-content', | |
| 35 | - ]; | |
| 36 | - } | |
| 37 | - | |
| 38 | - | |
| 39 | - protected function register_controls() { | |
| 40 | - | |
| 41 | - $this->start_controls_section( | |
| 42 | - 'content_section', | |
| 43 | - [ | |
| 44 | - 'label' => esc_html__('Content Style', 'easy-elements'), | |
| 45 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 46 | - ] | |
| 47 | - ); | |
| 48 | - | |
| 49 | - $this->add_control( | |
| 50 | - 'content_color', | |
| 51 | - [ | |
| 52 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 53 | - 'type' => Controls_Manager::COLOR, | |
| 54 | - 'selectors' => [ | |
| 55 | - '{{WRAPPER}} .eel-post-content' => 'color: {{VALUE}};', | |
| 56 | - ], | |
| 57 | - ] | |
| 58 | - ); | |
| 59 | - | |
| 60 | - $this->add_group_control( | |
| 61 | - \Elementor\Group_Control_Typography::get_type(), | |
| 62 | - [ | |
| 63 | - 'name' => 'content_typography', | |
| 64 | - 'selector' => '{{WRAPPER}} .eel-post-content', | |
| 65 | - ] | |
| 66 | - ); | |
| 67 | - | |
| 68 | - $this->add_control( | |
| 69 | - 'global_heading', | |
| 70 | - [ | |
| 71 | - 'label' => esc_html__( 'Global Heading', 'easy-elements' ), | |
| 72 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 73 | - 'separator' => 'after', | |
| 74 | - ] | |
| 75 | - ); | |
| 76 | - | |
| 77 | - $this->add_control( | |
| 78 | - 'global_color', | |
| 79 | - [ | |
| 80 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 81 | - 'type' => Controls_Manager::COLOR, | |
| 82 | - 'selectors' => [ | |
| 83 | - '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6' => 'color: {{VALUE}};', | |
| 84 | - ], | |
| 85 | - ] | |
| 86 | - ); | |
| 87 | - | |
| 88 | - $this->add_group_control( | |
| 89 | - \Elementor\Group_Control_Typography::get_type(), | |
| 90 | - [ | |
| 91 | - 'name' => 'global_typography', | |
| 92 | - 'selector' => '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6', | |
| 93 | - ] | |
| 94 | - ); | |
| 95 | - | |
| 96 | - $this->add_responsive_control( | |
| 97 | - 'global_margin', | |
| 98 | - [ | |
| 99 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 100 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 101 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 102 | - 'selectors' => [ | |
| 103 | - '{{WRAPPER}} .eel-post-content h1, {{WRAPPER}} .eel-post-content h2, {{WRAPPER}} .eel-post-content h3, {{WRAPPER}} .eel-post-content h4, {{WRAPPER}} .eel-post-content h5, {{WRAPPER}} .eel-post-content h6' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 104 | - ], | |
| 105 | - ] | |
| 106 | - ); | |
| 107 | - | |
| 108 | - $this->add_control( | |
| 109 | - 'strong_heading', | |
| 110 | - [ | |
| 111 | - 'label' => esc_html__( 'Strong Style', 'easy-elements' ), | |
| 112 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 113 | - 'separator' => 'after', | |
| 114 | - ] | |
| 115 | - ); | |
| 116 | - | |
| 117 | - $this->add_control( | |
| 118 | - 'strong_color', | |
| 119 | - [ | |
| 120 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 121 | - 'type' => Controls_Manager::COLOR, | |
| 122 | - 'selectors' => [ | |
| 123 | - '{{WRAPPER}} .eel-post-content strong' => 'color: {{VALUE}};', | |
| 124 | - ], | |
| 125 | - ] | |
| 126 | - ); | |
| 127 | - | |
| 128 | - $this->add_group_control( | |
| 129 | - \Elementor\Group_Control_Typography::get_type(), | |
| 130 | - [ | |
| 131 | - 'name' => 'strong_typography', | |
| 132 | - 'selector' => '{{WRAPPER}} .eel-post-content strong', | |
| 133 | - ] | |
| 134 | - ); | |
| 135 | - | |
| 136 | - $this->add_control( | |
| 137 | - 'link_heading', | |
| 138 | - [ | |
| 139 | - 'label' => esc_html__( 'Link Style', 'easy-elements' ), | |
| 140 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 141 | - 'separator' => 'after', | |
| 142 | - ] | |
| 143 | - ); | |
| 144 | - | |
| 145 | - $this->add_control( | |
| 146 | - 'link_color', | |
| 147 | - [ | |
| 148 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 149 | - 'type' => Controls_Manager::COLOR, | |
| 150 | - 'selectors' => [ | |
| 151 | - '{{WRAPPER}} .eel-post-content a' => 'color: {{VALUE}};', | |
| 152 | - ], | |
| 153 | - ] | |
| 154 | - ); | |
| 155 | - | |
| 156 | - $this->add_group_control( | |
| 157 | - \Elementor\Group_Control_Typography::get_type(), | |
| 158 | - [ | |
| 159 | - 'name' => 'link_typography', | |
| 160 | - 'selector' => '{{WRAPPER}} .eel-post-content a', | |
| 161 | - ] | |
| 162 | - ); | |
| 163 | - | |
| 164 | - $this->end_controls_section(); | |
| 165 | - | |
| 166 | - $this->start_controls_section( | |
| 167 | - 'content_section_heading', | |
| 168 | - [ | |
| 169 | - 'label' => esc_html__('Heading Style', 'easy-elements'), | |
| 170 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 171 | - ] | |
| 172 | - ); | |
| 173 | - | |
| 174 | - $this->add_control( | |
| 175 | - 'h1_heading', | |
| 176 | - [ | |
| 177 | - 'label' => esc_html__( 'H1 Heading', 'easy-elements' ), | |
| 178 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 179 | - ] | |
| 180 | - ); | |
| 181 | - | |
| 182 | - $this->add_control( | |
| 183 | - 'h1_color', | |
| 184 | - [ | |
| 185 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 186 | - 'type' => Controls_Manager::COLOR, | |
| 187 | - 'selectors' => [ | |
| 188 | - '{{WRAPPER}} .eel-post-content h1' => 'color: {{VALUE}};', | |
| 189 | - ], | |
| 190 | - ] | |
| 191 | - ); | |
| 192 | - | |
| 193 | - $this->add_group_control( | |
| 194 | - \Elementor\Group_Control_Typography::get_type(), | |
| 195 | - [ | |
| 196 | - 'name' => 'h1_typography', | |
| 197 | - 'selector' => '{{WRAPPER}} .eel-post-content h1', | |
| 198 | - ] | |
| 199 | - ); | |
| 200 | - | |
| 201 | - $this->add_responsive_control( | |
| 202 | - 'h1_margin', | |
| 203 | - [ | |
| 204 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 205 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 206 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 207 | - 'selectors' => [ | |
| 208 | - '{{WRAPPER}} .eel-post-content h1' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 209 | - ], | |
| 210 | - ] | |
| 211 | - ); | |
| 212 | - | |
| 213 | - $this->add_control( | |
| 214 | - 'h2_heading', | |
| 215 | - [ | |
| 216 | - 'label' => esc_html__( 'H2 Heading', 'easy-elements' ), | |
| 217 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 218 | - ] | |
| 219 | - ); | |
| 220 | - | |
| 221 | - $this->add_control( | |
| 222 | - 'h2_color', | |
| 223 | - [ | |
| 224 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 225 | - 'type' => Controls_Manager::COLOR, | |
| 226 | - 'selectors' => [ | |
| 227 | - '{{WRAPPER}} .eel-post-content h2' => 'color: {{VALUE}};', | |
| 228 | - ], | |
| 229 | - ] | |
| 230 | - ); | |
| 231 | - | |
| 232 | - $this->add_group_control( | |
| 233 | - \Elementor\Group_Control_Typography::get_type(), | |
| 234 | - [ | |
| 235 | - 'name' => 'h2_typography', | |
| 236 | - 'selector' => '{{WRAPPER}} .eel-post-content h2', | |
| 237 | - ] | |
| 238 | - ); | |
| 239 | - | |
| 240 | - $this->add_responsive_control( | |
| 241 | - 'h2_margin', | |
| 242 | - [ | |
| 243 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 244 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 245 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 246 | - 'selectors' => [ | |
| 247 | - '{{WRAPPER}} .eel-post-content h2' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 248 | - ], | |
| 249 | - ] | |
| 250 | - ); | |
| 251 | - | |
| 252 | - $this->add_control( | |
| 253 | - 'h3_heading', | |
| 254 | - [ | |
| 255 | - 'label' => esc_html__( 'H3 Heading', 'easy-elements' ), | |
| 256 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 257 | - ] | |
| 258 | - ); | |
| 259 | - | |
| 260 | - $this->add_control( | |
| 261 | - 'h3_color', | |
| 262 | - [ | |
| 263 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 264 | - 'type' => Controls_Manager::COLOR, | |
| 265 | - 'selectors' => [ | |
| 266 | - '{{WRAPPER}} .eel-post-content h3' => 'color: {{VALUE}};', | |
| 267 | - ], | |
| 268 | - ] | |
| 269 | - ); | |
| 270 | - | |
| 271 | - $this->add_group_control( | |
| 272 | - \Elementor\Group_Control_Typography::get_type(), | |
| 273 | - [ | |
| 274 | - 'name' => 'h3_typography', | |
| 275 | - 'selector' => '{{WRAPPER}} .eel-post-content h3', | |
| 276 | - ] | |
| 277 | - ); | |
| 278 | - | |
| 279 | - $this->add_responsive_control( | |
| 280 | - 'h3_margin', | |
| 281 | - [ | |
| 282 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 283 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 284 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 285 | - 'selectors' => [ | |
| 286 | - '{{WRAPPER}} .eel-post-content h3' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 287 | - ], | |
| 288 | - ] | |
| 289 | - ); | |
| 290 | - | |
| 291 | - $this->add_control( | |
| 292 | - 'h4_heading', | |
| 293 | - [ | |
| 294 | - 'label' => esc_html__( 'H4 Heading', 'easy-elements' ), | |
| 295 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 296 | - ] | |
| 297 | - ); | |
| 298 | - | |
| 299 | - $this->add_control( | |
| 300 | - 'h4_color', | |
| 301 | - [ | |
| 302 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 303 | - 'type' => Controls_Manager::COLOR, | |
| 304 | - 'selectors' => [ | |
| 305 | - '{{WRAPPER}} .eel-post-content h4' => 'color: {{VALUE}};', | |
| 306 | - ], | |
| 307 | - ] | |
| 308 | - ); | |
| 309 | - | |
| 310 | - $this->add_group_control( | |
| 311 | - \Elementor\Group_Control_Typography::get_type(), | |
| 312 | - [ | |
| 313 | - 'name' => 'h4_typography', | |
| 314 | - 'selector' => '{{WRAPPER}} .eel-post-content h4', | |
| 315 | - ] | |
| 316 | - ); | |
| 317 | - | |
| 318 | - $this->add_responsive_control( | |
| 319 | - 'h4_margin', | |
| 320 | - [ | |
| 321 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 322 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 323 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 324 | - 'selectors' => [ | |
| 325 | - '{{WRAPPER}} .eel-post-content h4' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 326 | - ], | |
| 327 | - ] | |
| 328 | - ); | |
| 329 | - | |
| 330 | - $this->add_control( | |
| 331 | - 'h5_heading', | |
| 332 | - [ | |
| 333 | - 'label' => esc_html__( 'H5 Heading', 'easy-elements' ), | |
| 334 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 335 | - ] | |
| 336 | - ); | |
| 337 | - | |
| 338 | - $this->add_control( | |
| 339 | - 'h5_color', | |
| 340 | - [ | |
| 341 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 342 | - 'type' => Controls_Manager::COLOR, | |
| 343 | - 'selectors' => [ | |
| 344 | - '{{WRAPPER}} .eel-post-content h5' => 'color: {{VALUE}};', | |
| 345 | - ], | |
| 346 | - ] | |
| 347 | - ); | |
| 348 | - | |
| 349 | - $this->add_group_control( | |
| 350 | - \Elementor\Group_Control_Typography::get_type(), | |
| 351 | - [ | |
| 352 | - 'name' => 'h5_typography', | |
| 353 | - 'selector' => '{{WRAPPER}} .eel-post-content h5', | |
| 354 | - ] | |
| 355 | - ); | |
| 356 | - | |
| 357 | - $this->add_responsive_control( | |
| 358 | - 'h5_margin', | |
| 359 | - [ | |
| 360 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 361 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 362 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 363 | - 'selectors' => [ | |
| 364 | - '{{WRAPPER}} .eel-post-content h5' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 365 | - ], | |
| 366 | - ] | |
| 367 | - ); | |
| 368 | - | |
| 369 | - $this->add_control( | |
| 370 | - 'h6_heading', | |
| 371 | - [ | |
| 372 | - 'label' => esc_html__( 'H6 Heading', 'easy-elements' ), | |
| 373 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 374 | - 'separator' => 'after', | |
| 375 | - ] | |
| 376 | - ); | |
| 377 | - | |
| 378 | - $this->add_control( | |
| 379 | - 'h6_color', | |
| 380 | - [ | |
| 381 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 382 | - 'type' => Controls_Manager::COLOR, | |
| 383 | - 'selectors' => [ | |
| 384 | - '{{WRAPPER}} .eel-post-content h6' => 'color: {{VALUE}};', | |
| 385 | - ], | |
| 386 | - ] | |
| 387 | - ); | |
| 388 | - | |
| 389 | - $this->add_group_control( | |
| 390 | - \Elementor\Group_Control_Typography::get_type(), | |
| 391 | - [ | |
| 392 | - 'name' => 'h6_typography', | |
| 393 | - 'selector' => '{{WRAPPER}} .eel-post-content h6', | |
| 394 | - ] | |
| 395 | - ); | |
| 396 | - | |
| 397 | - $this->add_responsive_control( | |
| 398 | - 'h6_margin', | |
| 399 | - [ | |
| 400 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 401 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 402 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 403 | - 'selectors' => [ | |
| 404 | - '{{WRAPPER}} .eel-post-content h6' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 405 | - ], | |
| 406 | - ] | |
| 407 | - ); | |
| 408 | - | |
| 409 | - $this->end_controls_section(); | |
| 410 | - | |
| 411 | - $this->start_controls_section( | |
| 412 | - 'ul_content_section', | |
| 413 | - [ | |
| 414 | - 'label' => esc_html__('Others Style', 'easy-elements'), | |
| 415 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 416 | - ] | |
| 417 | - ); | |
| 418 | - | |
| 419 | - $this->add_control( | |
| 420 | - 'ul_heading', | |
| 421 | - [ | |
| 422 | - 'label' => esc_html__( 'UL Style', 'easy-elements' ), | |
| 423 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 424 | - 'separator' => 'after', | |
| 425 | - ] | |
| 426 | - ); | |
| 427 | - $this->add_control( | |
| 428 | - 'ul_color', | |
| 429 | - [ | |
| 430 | - 'label' => esc_html__('Color', 'easy-elements'), | |
| 431 | - 'type' => Controls_Manager::COLOR, | |
| 432 | - 'selectors' => [ | |
| 433 | - '{{WRAPPER}} .eel-post-content ul' => 'color: {{VALUE}};', | |
| 434 | - ], | |
| 435 | - ] | |
| 436 | - ); | |
| 437 | - | |
| 438 | - $this->add_group_control( | |
| 439 | - \Elementor\Group_Control_Typography::get_type(), | |
| 440 | - [ | |
| 441 | - 'name' => 'ul_typography', | |
| 442 | - 'selector' => '{{WRAPPER}} .eel-post-content ul', | |
| 443 | - ] | |
| 444 | - ); | |
| 445 | - | |
| 446 | - $this->add_responsive_control( | |
| 447 | - 'ul_margin', | |
| 448 | - [ | |
| 449 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 450 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 451 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 452 | - 'selectors' => [ | |
| 453 | - '{{WRAPPER}} .eel-post-content ul' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 454 | - ], | |
| 455 | - ] | |
| 456 | - ); | |
| 457 | - | |
| 458 | - $this->add_responsive_control( | |
| 459 | - 'ul_padding', | |
| 460 | - [ | |
| 461 | - 'label' => __( 'Padding', 'easy-elements' ), | |
| 462 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 463 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 464 | - 'selectors' => [ | |
| 465 | - '{{WRAPPER}} .eel-post-content ul' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 466 | - ], | |
| 467 | - ] | |
| 468 | - ); | |
| 469 | - | |
| 470 | - $this->add_control( | |
| 471 | - 'li_heading', | |
| 472 | - [ | |
| 473 | - 'label' => esc_html__( 'LI Style', 'easy-elements' ), | |
| 474 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 475 | - 'separator' => 'after', | |
| 476 | - ] | |
| 477 | - ); | |
| 478 | - | |
| 479 | - $this->add_responsive_control( | |
| 480 | - 'li_margin', | |
| 481 | - [ | |
| 482 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 483 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 484 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 485 | - 'selectors' => [ | |
| 486 | - '{{WRAPPER}} .eel-post-content ul > li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 487 | - ], | |
| 488 | - ] | |
| 489 | - ); | |
| 490 | - | |
| 491 | - $this->add_responsive_control( | |
| 492 | - 'li_padding', | |
| 493 | - [ | |
| 494 | - 'label' => __( 'Padding', 'easy-elements' ), | |
| 495 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 496 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 497 | - 'selectors' => [ | |
| 498 | - '{{WRAPPER}} .eel-post-content ul > li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 499 | - ], | |
| 500 | - ] | |
| 501 | - ); | |
| 502 | - | |
| 503 | - $this->add_control( | |
| 504 | - 'p_heading', | |
| 505 | - [ | |
| 506 | - 'label' => esc_html__( 'Paragraph Style', 'easy-elements' ), | |
| 507 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 508 | - 'separator' => 'after', | |
| 509 | - ] | |
| 510 | - ); | |
| 511 | - | |
| 512 | - $this->add_responsive_control( | |
| 513 | - 'p__margin', | |
| 514 | - [ | |
| 515 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 516 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 517 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 518 | - 'selectors' => [ | |
| 519 | - '{{WRAPPER}} .eel-post-content p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 520 | - ], | |
| 521 | - ] | |
| 522 | - ); | |
| 523 | - | |
| 524 | - $this->add_control( | |
| 525 | - 'p_img_heading', | |
| 526 | - [ | |
| 527 | - 'label' => esc_html__( 'Paragraph Image Style', 'easy-elements' ), | |
| 528 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 529 | - 'separator' => 'after', | |
| 530 | - ] | |
| 531 | - ); | |
| 532 | - | |
| 533 | - $this->add_responsive_control( | |
| 534 | - 'p_image_margin', | |
| 535 | - [ | |
| 536 | - 'label' => __( 'Margin', 'easy-elements' ), | |
| 537 | - 'type' => \Elementor\Controls_Manager::DIMENSIONS, | |
| 538 | - 'size_units' => [ 'px', 'em', '%' ], | |
| 539 | - 'selectors' => [ | |
| 540 | - '{{WRAPPER}} .eel-post-content img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 541 | - ], | |
| 542 | - ] | |
| 543 | - ); | |
| 544 | - | |
| 545 | - $this->end_controls_section(); | |
| 546 | - | |
| 547 | - } | |
| 548 | - | |
| 549 | - protected function render() { | |
| 550 | - | |
| 551 | - $post_id = function_exists( 'easyel_get_prepared_post_id' ) | |
| 552 | - ? easyel_get_prepared_post_id() | |
| 553 | - : get_the_ID(); | |
| 554 | - | |
| 555 | - if ( ! $post_id ) { | |
| 556 | - return; | |
| 557 | - } | |
| 558 | - | |
| 559 | - $plugin = \Elementor\Plugin::$instance; | |
| 560 | - | |
| 561 | - $is_editor = $plugin->editor->is_edit_mode(); | |
| 562 | - $is_preview = $plugin->preview->is_preview_mode(); | |
| 563 | - $is_elementor = $is_editor || $is_preview; | |
| 564 | - | |
| 565 | - // Prevent recursion | |
| 566 | - static $rendering_post_ids = []; | |
| 567 | - if ( in_array( $post_id, $rendering_post_ids, true ) ) { | |
| 568 | - echo '<div class="easyel-editor-placeholder" style="padding:10px;border:1px dashed #ccc;"> | |
| 569 | - Post content will appear on frontend. | |
| 570 | - </div>'; | |
| 571 | - return; | |
| 572 | - } | |
| 573 | - $rendering_post_ids[] = $post_id; | |
| 574 | - | |
| 575 | - $content = ''; | |
| 576 | - | |
| 577 | - if ( $is_elementor ) { | |
| 578 | - $content = $plugin->frontend->get_builder_content_for_display( | |
| 579 | - $post_id, | |
| 580 | - true | |
| 581 | - ); | |
| 582 | - } | |
| 583 | - | |
| 584 | - if ( empty( $content ) ) { | |
| 585 | - $raw_content = get_post_field( 'post_content', $post_id ); | |
| 586 | - | |
| 587 | - if ( $is_editor || $is_preview ) { | |
| 588 | - $blocks = parse_blocks( $raw_content ); | |
| 589 | - if ( ! empty( $blocks ) ) { | |
| 590 | - $content = ''; | |
| 591 | - foreach ( $blocks as $block ) { | |
| 592 | - $content .= render_block( $block ); | |
| 593 | - } | |
| 594 | - } | |
| 595 | - } else { | |
| 596 | - | |
| 597 | - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 598 | - $content = apply_filters( 'the_content', $raw_content ); | |
| 599 | - } | |
| 600 | - } | |
| 601 | - | |
| 602 | - if ( empty( $content ) ) { | |
| 603 | - echo '<div class="easyel-editor-placeholder" style="padding:10px;border:1px dashed #ccc;"> | |
| 604 | - Post content will appear here. | |
| 605 | - </div>'; | |
| 606 | - $key = array_search( $post_id, $rendering_post_ids, true ); | |
| 607 | - if ( $key !== false ) unset( $rendering_post_ids[ $key ] ); | |
| 608 | - return; | |
| 609 | - } | |
| 610 | - | |
| 611 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 612 | - echo '<div class="eel-post-content eel-gutenberg-content">' . $content . '</div>'; | |
| 613 | - | |
| 614 | - $key = array_search( $post_id, $rendering_post_ids, true ); | |
| 615 | - if ( $key !== false ) unset( $rendering_post_ids[ $key ] ); | |
| 616 | - } | |
| 617 | - | |
| 618 | - | |
| 619 | -} | |
| 1 | +<?php | |
| 2 | +use Elementor\Controls_Manager; | |
| 3 | +use Elementor\Widget_Base; | |
| 4 | + | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | + | |
| 9 | +if( class_exists("Easyel_Free_Post_content_Widget")) { | |
| 10 | + return; | |
| 11 | +} | |
| 12 | + | |
| 13 | +class Easyel_Free_Post_content_Widget extends \Elementor\Widget_Base { | |
| 14 | + public function get_style_depends() { | |
| 15 | + $handle = 'eel-post-content'; | |
| 16 | + $css_path = plugin_dir_path( __FILE__ ) . 'css/post-content.css'; | |
| 17 | + | |
| 18 | + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) { | |
| 19 | + wp_register_style( $handle, plugins_url( 'css/post-content.css', __FILE__ ), [], defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : EASYELEMENTS_VER ); | |
| 20 | + } | |
| 21 | + return [ $handle ]; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function get_name() { | |
| 25 | + return 'eel-post-content'; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public function get_title() { | |
| 29 | + return __( 'Post Content', 'easy-elements' ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public function get_icon() { | |
| 33 | + return 'easyicon easyelIcon-post-content'; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public function get_categories() { | |
| 37 | + return [ 'easyelements_category_pro' ]; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public function get_keywords() { | |
| 41 | + return [ 'post', 'content', 'link', 'click', 'text' ]; | |
| 42 | + } | |
| 43 | + | |
| 44 | + protected function register_controls() { | |
| 45 | + | |
| 46 | + $this->start_controls_section( | |
| 47 | + 'content_section', | |
| 48 | + [ | |
| 49 | + 'label' => esc_html__('Post Content Settings', 'easy-elements'), | |
| 50 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 51 | + ] | |
| 52 | + ); | |
| 53 | + | |
| 54 | + $this->add_control( | |
| 55 | + 'content_color', | |
| 56 | + [ | |
| 57 | + 'label' => esc_html__('Color', 'easy-elements'), | |
| 58 | + 'type' => Controls_Manager::COLOR, | |
| 59 | + 'selectors' => [ | |
| 60 | + '{{WRAPPER}} .eel-post-content' => 'color: {{VALUE}};', | |
| 61 | + ], | |
| 62 | + ] | |
| 63 | + ); | |
| 64 | + | |
| 65 | + $this->add_group_control( | |
| 66 | + \Elementor\Group_Control_Typography::get_type(), | |
| 67 | + [ | |
| 68 | + 'name' => 'content_typography', | |
| 69 | + 'selector' => '{{WRAPPER}} .eel-post-content', | |
| 70 | + ] | |
| 71 | + ); | |
| 72 | + | |
| 73 | + $this->end_controls_section(); | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | +protected function render() { | |
| 78 | + global $post; | |
| 79 | + | |
| 80 | + if ( ! $post ) { | |
| 81 | + return; | |
| 82 | + } | |
| 83 | + | |
| 84 | + $content = \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( get_the_ID() ); | |
| 85 | + | |
| 86 | + if ( empty( $content ) ) { | |
| 87 | + $content = apply_filters( 'the_content', $post->post_content ); | |
| 88 | + } | |
| 89 | + | |
| 90 | + echo '<div class="eel-post-content">'; | |
| 91 | + echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 92 | + echo '</div>'; | |
| 93 | +} | |
| 94 | + | |
| 95 | + | |
| 96 | +} | |