register_content_controls(); // Style Tab $this->register_style_controls(); } protected function register_content_controls() { // General Settings Section $this->start_controls_section( 'section_general', [ 'label' => esc_html__( 'General', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'page_type', [ 'label' => esc_html__( 'Page Type', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'current', 'options' => [ 'current' => esc_html__( 'Current Page', 'easy-elements' ), 'archive' => esc_html__( 'Archive Page', 'easy-elements' ), 'single' => esc_html__( 'Single Post/Page', 'easy-elements' ), 'home' => esc_html__( 'Home Page', 'easy-elements' ), ], 'description' => esc_html__( 'Select which page type to display meta for', 'easy-elements' ), ] ); $this->add_control( 'show_meta', [ 'label' => esc_html__( 'Show Meta', 'easy-elements' ), 'type' => Controls_Manager::SELECT2, 'multiple' => true, 'options' => [ 'date' => esc_html__( 'Date', 'easy-elements' ), 'author' => esc_html__( 'Author', 'easy-elements' ), 'category' => esc_html__( 'Category', 'easy-elements' ), 'comments' => esc_html__( 'Comments', 'easy-elements' ), ], 'default' => ['date', 'author'], 'label_block' => true, 'separator' => 'before', ] ); $this->end_controls_section(); // Date Settings Section $this->start_controls_section( 'section_date', [ 'label' => esc_html__( 'Date', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_date_icon', [ 'label' => esc_html__( 'Show Icon', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'date_icon', [ 'label' => esc_html__( 'Icon', 'easy-elements' ), 'type' => Controls_Manager::ICONS, 'condition' => [ 'show_date_icon' => 'yes', ], ] ); $this->add_control( 'date_format', [ 'label' => esc_html__( 'Date Format', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => esc_html__( 'Default', 'easy-elements' ), 'F j, Y' => esc_html__( 'January 1, 2024', 'easy-elements' ), 'j F Y' => esc_html__( '1 January 2024', 'easy-elements' ), 'Y-m-d' => esc_html__( '2024-01-01', 'easy-elements' ), 'm/d/Y' => esc_html__( '01/01/2024 (US)', 'easy-elements' ), 'd/m/Y' => esc_html__( '01/01/2024 (EU)', 'easy-elements' ), 'custom' => esc_html__( 'Custom', 'easy-elements' ), ], 'separator' => 'before', ] ); $this->add_control( 'custom_date_format', [ 'label' => esc_html__( 'Custom Format', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => 'F j, Y', 'description' => esc_html__( 'Enter a custom date format. See PHP date() function documentation.', 'easy-elements' ), 'condition' => [ 'date_format' => 'custom', ], ] ); $this->end_controls_section(); // Author Settings Section $this->start_controls_section( 'section_author', [ 'label' => esc_html__( 'Author', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_author_icon', [ 'label' => esc_html__( 'Show Icon', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'author_icon', [ 'label' => esc_html__( 'Icon', 'easy-elements' ), 'type' => Controls_Manager::ICONS, 'condition' => [ 'show_author_icon' => 'yes', ], ] ); $this->add_control( 'show_by_label', [ 'label' => esc_html__( 'Show "By" Label', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'return_value' => 'yes', 'default' => 'yes', 'separator' => 'before', ] ); $this->add_control( 'author_link_enable', [ 'label' => esc_html__( 'Author Link', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'return_value' => 'yes', 'default' => '', ] ); $this->end_controls_section(); // Category Settings Section $this->start_controls_section( 'section_category', [ 'label' => esc_html__( 'Category', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_category_icon', [ 'label' => esc_html__( 'Show Icon', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'category_icon', [ 'label' => esc_html__( 'Icon', 'easy-elements' ), 'type' => Controls_Manager::ICONS, 'condition' => [ 'show_category_icon' => 'yes', ], ] ); $this->add_control( 'category_separator', [ 'label' => esc_html__( 'Separator', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => ', ', 'description' => esc_html__( 'Separator between categories', 'easy-elements' ), 'separator' => 'before', ] ); $this->end_controls_section(); // Comments Settings Section $this->start_controls_section( 'section_comments', [ 'label' => esc_html__( 'Comments', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_comments_icon', [ 'label' => esc_html__( 'Show Icon', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'comments_icon', [ 'label' => esc_html__( 'Icon', 'easy-elements' ), 'type' => Controls_Manager::ICONS, 'condition' => [ 'show_comments_icon' => 'yes', ], ] ); $this->add_control( 'comments_text', [ 'label' => esc_html__( 'Comments Text', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'default', 'options' => [ 'default' => esc_html__( 'Default (Comment/Comments)', 'easy-elements' ), 'custom' => esc_html__( 'Custom', 'easy-elements' ), ], 'separator' => 'before', ] ); $this->add_control( 'custom_comments_text', [ 'label' => esc_html__( 'Custom Text', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => 'Comment', /* translators: %s: Number of comments */ 'description' => esc_html__( 'Use %s for the number', 'easy-elements' ), 'condition' => [ 'comments_text' => 'custom', ], ] ); $this->end_controls_section(); // Separator Settings Section $this->start_controls_section( 'section_separator', [ 'label' => esc_html__( 'Separator', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'eel_separator', [ 'label' => esc_html__( 'Enable Separator', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'easy-elements' ), 'label_off' => esc_html__( 'No', 'easy-elements' ), 'default' => '', ] ); $this->add_control( 'separator_type', [ 'label' => esc_html__( 'Separator Type', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'line', 'options' => [ 'dot' => esc_html__( 'Dot', 'easy-elements' ), 'line' => esc_html__( 'Line', 'easy-elements' ), ], 'condition' => [ 'eel_separator' => 'yes', ], ] ); $this->end_controls_section(); } protected function register_style_controls() { // Meta Container Style $this->start_controls_section( 'section_meta_style', [ 'label' => esc_html__( 'Meta Container', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'easyel_post_meta_margin', [ 'label' => esc_html__( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'meta_padding', [ 'label' => esc_html__( 'Padding', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'meta_border', 'label' => esc_html__( 'Border', 'easy-elements' ), 'selector' => '{{WRAPPER}} .eel--blog-meta', ] ); $this->add_control( 'meta_border_radius', [ 'label' => esc_html__( 'Border Radius', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'meta_box_shadow', 'label' => esc_html__( 'Box Shadow', 'easy-elements' ), 'selector' => '{{WRAPPER}} .eel--blog-meta', ] ); $this->end_controls_section(); // Meta Items Style $this->start_controls_section( 'section_meta_items_style', [ 'label' => esc_html__( 'Meta Items', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'meta_text_color', [ 'label' => esc_html__( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_TEXT, ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta li, {{WRAPPER}} .eel--blog-meta li *' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'meta_typography', 'label' => esc_html__( 'Typography', 'easy-elements' ), 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_TEXT, ], 'selector' => '{{WRAPPER}} .eel--blog-meta li', ] ); $this->add_responsive_control( 'meta_items_spacing', [ 'label' => esc_html__( 'Margin Right', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta li' => 'margin-right: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'meta_items_spacing_left', [ 'label' => esc_html__( 'Padding Left', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .eel--separator--line li + li' => 'padding-left: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Icons Style $this->start_controls_section( 'section_icons_style', [ 'label' => esc_html__( 'Icons', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'icon_color', [ 'label' => esc_html__( 'Icon Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel--blog-meta i, {{WRAPPER}} .eel--blog-meta svg' => 'color: {{VALUE}};', '{{WRAPPER}} .eel--blog-meta svg path' => 'fill: {{VALUE}};', ], ] ); $this->add_control( 'icon_size', [ 'label' => esc_html__( 'Icon Size', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 10, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta i, {{WRAPPER}} .eel--blog-meta svg' => 'font-size: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'meta_icon_offset', [ 'label' => esc_html__( 'Icon Offset Vertical', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => -50, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta svg, {{WRAPPER}} .eel--blog-meta i' => 'top: {{SIZE}}{{UNIT}}; position: relative;', ], ] ); $this->add_control( 'icon_spacing', [ 'label' => esc_html__( 'Icon Spacing', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 20, ], ], 'selectors' => [ '{{WRAPPER}} .eel--blog-meta i, {{WRAPPER}} .eel--blog-meta svg' => 'margin-right: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Separator Style $this->start_controls_section( 'section_separator_style', [ 'label' => esc_html__( 'Separator', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'eel_separator' => 'yes', ], ] ); $this->add_control( 'separator_color', [ 'label' => esc_html__( 'Separator Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel--separator--yes li + li::before' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'separator_size', [ 'label' => esc_html__( 'Separator Size', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 20, ], ], 'selectors' => [ '{{WRAPPER}} .eel--separator--yes li + li::before' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], 'condition' => [ 'separator_type' => 'dot', ], ] ); $this->add_responsive_control( 'separator_offset', [ 'label' => esc_html__( 'Separator Offset', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => -50, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .eel--separator--yes li + li::before' => 'top: {{SIZE}}{{UNIT}};', ], 'condition' => [ 'separator_type' => 'dot', ], ] ); $this->end_controls_section(); // Links Style $this->start_controls_section( 'section_links_style', [ 'label' => esc_html__( 'Links', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->start_controls_tabs( 'links_style_tabs' ); $this->start_controls_tab( 'links_normal_tab', [ 'label' => esc_html__( 'Normal', 'easy-elements' ), ] ); $this->add_control( 'links_color', [ 'label' => esc_html__( 'Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel--blog-meta a' => 'color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'links_hover_tab', [ 'label' => esc_html__( 'Hover', 'easy-elements' ), ] ); $this->add_control( 'links_hover_color', [ 'label' => esc_html__( 'Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel--blog-meta a:hover' => 'color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } protected function render_blog_meta( $settings ) { if ( empty( $settings['show_meta'] ) || ! is_array( $settings['show_meta'] ) ) { return; } $show_meta = $settings['show_meta']; $eel_separator = (! empty($settings['eel_separator']) && $settings['eel_separator'] == 'yes') ? 'eel--separator--yes' : ''; $page_type = ! empty($settings['page_type']) ? $settings['page_type'] : 'current'; $separator_type = ! empty($settings['separator_type']) ? $settings['separator_type'] : 'dot'; // Check if we should display meta based on page type if (!$this->should_display_meta($page_type)) { return; } ?>
get_settings_for_display(); $this->render_blog_meta( $settings ); } }