| 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_Post_content_Widget")) { |
| 10 |
return; |
| 11 |
} |
| 12 |
|
| 13 |
class Easyel_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 ) : '1.0.0' ); |
| 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 |
} |
| 97 |
|