function et_divi_post_meta() { $postinfo = is_single() ? et_get_option('divi_postinfo2') : et_get_option('divi_postinfo1'); if ($postinfo) { echo '<p class="post-meta">'; echo et_pb_postinfo_meta($postinfo, et_get_option('divi_date_format', 'M j, Y'), esc_html__('0 comments', 'Divi'), esc_html__('1 comment', 'Divi'), '% ' . esc_html__('comments', 'Divi')); echo '</p>'; } }
function shortcode_callback($atts, $content = null, $function_name) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $title = $this->shortcode_atts['title']; $meta = $this->shortcode_atts['meta']; $author = $this->shortcode_atts['author']; $date = $this->shortcode_atts['date']; $date_format = $this->shortcode_atts['date_format']; $categories = $this->shortcode_atts['categories']; $comments = $this->shortcode_atts['comments']; $featured_image = $this->shortcode_atts['featured_image']; $featured_placement = $this->shortcode_atts['featured_placement']; $parallax_effect = $this->shortcode_atts['parallax_effect']; $parallax_method = $this->shortcode_atts['parallax_method']; $text_orientation = $this->shortcode_atts['text_orientation']; $text_color = $this->shortcode_atts['text_color']; $text_background = $this->shortcode_atts['text_background']; $text_bg_color = $this->shortcode_atts['text_bg_color']; $module_bg_color = $this->shortcode_atts['module_bg_color']; // display the shortcode only on singlular pages if (!is_singular()) { return; } $module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name); $output = ''; $featured_image_output = ''; $parallax_background_contaier = ''; if ('on' === $featured_image && ('above' === $featured_placement || 'below' === $featured_placement)) { $featured_image_output = sprintf('<div class="et_pb_title_featured_container">%1$s</div>', get_the_post_thumbnail(get_the_ID(), 'large')); } if ('on' === $title) { if (is_et_pb_preview() && isset($_POST['post_title']) && wp_verify_nonce($_POST['et_pb_preview_nonce'], 'et_pb_preview_nonce')) { $post_title = sanitize_text_field(wp_unslash($_POST['post_title'])); } else { $post_title = get_the_title(); } $output .= sprintf('<h1>%s</h1>', $post_title); } if ('on' === $meta) { $meta_array = array(); foreach (array('author', 'date', 'categories', 'comments') as $single_meta) { if ('on' === ${$single_meta} && ('categories' !== $single_meta || 'categories' === $single_meta && is_singular('post'))) { $meta_array[] = $single_meta; } } $output .= sprintf('<p class="et_pb_title_meta_container">%1$s</p>', et_pb_postinfo_meta($meta_array, $date_format, esc_html__('0 comments', 'et_builder'), esc_html__('1 comment', 'et_builder'), '% ' . esc_html__('comments', 'et_builder'))); } if ('on' === $featured_image && 'background' === $featured_placement) { $featured_image_src = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full'); ET_Builder_Element::set_style($function_name, array('selector' => sprintf('%%order_class%% %1$s', 'on' === $parallax_effect ? '.et_parallax_bg' : ''), 'declaration' => sprintf('background-image: url("%1$s");', esc_url($featured_image_src[0])))); if ('on' === $parallax_effect) { $parallax_background_contaier = sprintf('<div class="et_parallax_bg%1$s"></div>', 'on' === $parallax_method ? ' et_pb_parallax_css' : ''); } } if ('on' === $text_background) { ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%% .et_pb_title_container', 'declaration' => sprintf('background-color: %1$s; padding: 1em 1.5em;', esc_html($text_bg_color)))); } ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('text-align: %1$s;', esc_html($text_orientation)))); $background_layout = 'dark' === $text_color ? 'light' : 'dark'; $module_class .= ' et_pb_bg_layout_' . $background_layout; $module_class .= 'above' === $featured_placement ? ' et_pb_image_above' : ''; $module_class .= 'below' === $featured_placement ? ' et_pb_image_below' : ''; ET_Builder_Element::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => sprintf('background-color: %1$s;', esc_html($module_bg_color)))); $output = sprintf('<div%3$s class="et_pb_module et_pb_post_title %2$s%4$s"> %5$s %6$s <div class="et_pb_title_container"> %1$s </div> %7$s </div>', $output, '' !== $module_class ? sprintf(' %1$s', esc_attr($module_class)) : '', '' !== $module_id ? sprintf(' id="%1$s"', esc_attr($module_id)) : '', 'on' === $featured_image && 'background' === $featured_placement ? ' et_pb_featured_bg' : '', $parallax_background_contaier, 'on' === $featured_image && 'above' === $featured_placement ? $featured_image_output : '', 'on' === $featured_image && 'below' === $featured_placement ? $featured_image_output : ''); return $output; }