| 1 |
<?php |
| 2 |
namespace UiCoreElements\Widgets\ThemeBuilder; |
| 3 |
|
| 4 |
use UiCoreElements\UiCoreWidget; |
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use UiCoreElements\Utils\Meta_Trait; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit(); |
| 9 |
|
| 10 |
/** |
| 11 |
* The Title widget. |
| 12 |
* |
| 13 |
* @since 1.0.0 |
| 14 |
*/ |
| 15 |
class PostMeta extends UiCoreWidget { |
| 16 |
|
| 17 |
use Meta_Trait; |
| 18 |
|
| 19 |
public function get_name() { |
| 20 |
return 'uicore-post-meta'; |
| 21 |
} |
| 22 |
public function get_title() { |
| 23 |
return esc_html__( 'Post Meta', 'uicore-elements' ); |
| 24 |
} |
| 25 |
public function get_icon() { |
| 26 |
return 'eicon-post-info ui-e-widget'; |
| 27 |
} |
| 28 |
public function get_categories() { |
| 29 |
return ['uicore', 'uicore-theme-builder' ]; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_styles() { |
| 33 |
return [ 'post-meta' ]; |
| 34 |
} |
| 35 |
public function get_scripts() { |
| 36 |
return []; |
| 37 |
} |
| 38 |
public function get_keywords() { |
| 39 |
return [ 'post', 'meta', 'info' ]; |
| 40 |
} |
| 41 |
public function has_widget_inner_wrapper(): bool { |
| 42 |
// TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready |
| 43 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 44 |
} |
| 45 |
|
| 46 |
protected function register_controls() { |
| 47 |
$this->start_controls_section( |
| 48 |
'section_content', |
| 49 |
[ |
| 50 |
'label' => esc_html__( 'Content', 'uicore-elements' ), |
| 51 |
] |
| 52 |
); |
| 53 |
|
| 54 |
$this->add_control('meta_list',[ |
| 55 |
'label' => esc_html__( 'Meta Data', 'uicore-elements' ), |
| 56 |
'type' => \Elementor\Controls_Manager::REPEATER, |
| 57 |
'fields' => $this->get_meta_content_controls(), |
| 58 |
'default' => [ |
| 59 |
[ |
| 60 |
'type' => 'author' |
| 61 |
], |
| 62 |
], |
| 63 |
'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>', |
| 64 |
'prevent_empty' => false, |
| 65 |
'separator'=> 'before' |
| 66 |
] |
| 67 |
); |
| 68 |
$this->add_responsive_control('content_align', |
| 69 |
[ |
| 70 |
'label' => esc_html__( 'Content Alignment', 'uicore-elements' ), |
| 71 |
'type' => Controls_Manager::CHOOSE, |
| 72 |
'options' => [ |
| 73 |
'left' => [ |
| 74 |
'title' => esc_html__( 'Left', 'uicore-elements' ), |
| 75 |
'icon' => 'eicon-text-align-left', |
| 76 |
], |
| 77 |
'center' => [ |
| 78 |
'title' => esc_html__( 'Center', 'uicore-elements' ), |
| 79 |
'icon' => 'eicon-text-align-center', |
| 80 |
], |
| 81 |
], |
| 82 |
'selectors' => [ |
| 83 |
'{{WRAPPER}}' => 'text-align: {{VALUE}};', |
| 84 |
], |
| 85 |
] |
| 86 |
); |
| 87 |
$this->end_controls_section(); |
| 88 |
|
| 89 |
$this->start_controls_section( |
| 90 |
'section_meta_style', |
| 91 |
[ |
| 92 |
'label' => esc_html__( 'Style', 'uicore-elements' ), |
| 93 |
'tab' => Controls_Manager::TAB_STYLE, |
| 94 |
] |
| 95 |
); |
| 96 |
$this->get_meta_style_controls(); |
| 97 |
$this->end_controls_section(); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
protected function render() { |
| 102 |
|
| 103 |
if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) { |
| 104 |
$title = wp_title(null,false); |
| 105 |
$title = $title ? $title : get_bloginfo('name'); |
| 106 |
}else{ |
| 107 |
$title = __( 'This is a dummy title.', 'uicore-elements' ); |
| 108 |
} |
| 109 |
|
| 110 |
$meta_list = $this->get_settings_for_display( 'meta_list' ); |
| 111 |
if(!isset($meta_list[0]) || $meta_list[0]['type'] == ''){ |
| 112 |
return; |
| 113 |
} |
| 114 |
|
| 115 |
echo '<div class="ui-e-post-meta ui-e-tb-meta">'; |
| 116 |
foreach ($meta_list as $meta) { |
| 117 |
if($meta['type'] != 'none'){ |
| 118 |
$this->display_meta($meta); |
| 119 |
|
| 120 |
if( next( $meta_list ) && $this->get_settings_for_display( 'tb-meta_meta_separator' ) ) { |
| 121 |
echo '<span class="ui-e-separator">'.esc_html($this->get_settings_for_display('tb-meta_meta_separator' )).'</span>'; |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
echo '</div>'; |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
protected function content_template() { |
| 130 |
} |
| 131 |
} |
| 132 |
\Elementor\Plugin::instance()->widgets_manager->register(new PostMeta()); |
| 133 |
|