function xt_single_post_image($withTitle = false, $asBackground = false) { global $post; $post_id = get_the_ID(); if (!has_post_thumbnail($post_id)) { return false; } list($single_post_featured_image, $single_post_featured_image_position) = xt_get_featured_image_settings($post_id); if ($single_post_featured_image != 'none') { $is_endless_template = xt_is_endless_template(); $featured_image_crop_height = (int) get_field('single_post_featured_image_crop'); if ($asBackground && empty($featured_image_crop_height)) { $featured_image_crop_height = 600; } $image_size = 'th-xlarge'; if ($is_endless_template) { $image_size = 'th-large'; $featured_image_crop_height = false; } if (!empty($featured_image_crop_height)) { $image = get_post(get_post_thumbnail_id($post_id, $image_size)); $image_width = XT_Theme::$image_sizes[$image_size]['width']; $image_url = $image->guid; if ($single_post_featured_image != 'fullwidth') { $image_width = null; } $resized_image = aq_resize($image_url, $image_width, $featured_image_crop_height, true, false, true); if (!$asBackground && $resized_image !== false) { $featured_image = '<img itemprop="image" alt="' . esc_attr($image->post_title) . '" src="' . esc_url($resized_image[0]) . '" width="' . esc_attr($resized_image[1]) . '" height="' . esc_attr($resized_image[2]) . '" class="wp-post-image wp-featured-image ' . esc_attr($single_post_featured_image) . '">'; } else { if ($asBackground && $resized_image !== false) { $featured_image = '<div itemprop="image" content="' . esc_url($resized_image[0]) . '" class="featured-background ' . esc_attr($single_post_featured_image) . '" style="background-image:url(' . esc_url($resized_image[0]) . '); height:' . $resized_image[2] . 'px">'; } } } else { if (!$asBackground) { $featured_image = get_the_post_thumbnail($post_id, $image_size, array('itemprop' => 'image', 'class' => 'wp-featured-image ' . esc_attr($single_post_featured_image))); } } if ($featured_image !== false) { if (!$asBackground) { echo '<div class="th ' . esc_attr($single_post_featured_image) . '">'; } echo $featured_image; if ($withTitle) { ?> <div class="featured-image-behind-title-wrap gradient-wrap"> <div class="vc_row in-container l-padding-10 r-padding-10"> <?php xt_post_title('h1'); ?> </div> </div> <?php } echo '</div>'; } } }
function renderTitle($tag = 'h3', $class = '') { $length = null; if (!empty($this->instance["title_length"])) { $length = $this->instance["title_length"]; xt_post_title($tag, $class, true, $length); } else { xt_post_title($tag, $class, true); } }
/** * Start the element output. * * @see Walker::start_el() * * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args An array of arguments. @see wp_nav_menu() * @param int $id Current item ID. */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { global $post; $backupPost = $post; $indent = $depth ? str_repeat("\t", $depth) : ''; $class_names = ''; $classes = empty($item->classes) ? array() : (array) $item->classes; $args->has_category_dropdown = false; if (!empty($item->enable_megamenu) && !empty($args)) { $args->megamenu_enabled = (bool) $item->enable_megamenu; if (!empty($args->megamenu_enabled) && $args->theme_location == 'main-menu' && in_array("menu-item-type-taxonomy", $classes) && $depth == 0) { $classes[] = 'has-category-dropdown'; $args->has_category_dropdown = $item->object_id; if ($item->object == 'category') { $query = new WP_Query(array('posts_per_page' => 6, 'cat' => $item->object_id)); } else { $query = new WP_Query(array('posts_per_page' => 6, 'tax_query' => array(array('taxonomy' => $item->object, 'field' => 'id', 'terms' => array($item->object_id), 'include_children' => true, 'operator' => 'IN')))); } $posts = $query->posts; $category_sub_menu = "\n{$indent}<div id=\"category_posts_sub_menu_" . $item->object_id . "\" class=\"category_posts_sub_menu inactive\" data-cid=\"" . $item->object_id . "\"><div class=\"row in-container\"><div class=\"medium-12 column\">"; ob_start(); $show_tags = (bool) xt_option('megamenu-show-tags-links', null, 1); $show_subcategories = (bool) xt_option('megamenu-show-subcategory-links', null, 1); $show_submenus = (bool) xt_option('megamenu-show-submenu-links', null, 1); $all_tags = array(); foreach ($posts as $post) { setup_postdata($post); // Get Tags if ($show_tags) { $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag) { $all_tags[$tag->term_id] = $tag; } } ?> <div class="category_submenu_post"> <?php xt_post_thumbnail('th-medium', true); xt_post_title('h5', '', true); ?> </div> <?php } wp_reset_postdata(); // Get Related Categories $subcategories = array(); if ($show_subcategories) { $args = array('child_of' => $item->object_id); $subcategories = get_categories($args); } if ($show_submenus) { $submenu_items = $item->hasChildren && !empty($item->childs) ? $item->childs : false; } $post = $backupPost; $category_sub_menu .= ob_get_clean(); $category_sub_menu .= "</div></div><div class=\"row in-container\"><div class=\"medium-12 column\">"; if (!empty($all_tags) || !empty($subcategories) || !empty($submenu_items)) { $category_sub_menu .= '<div class="category_links_wrap">'; } if (!empty($all_tags)) { $category_sub_menu .= '<span class="category_links megamenu-tags">'; $category_sub_menu .= '<span>' . __("In this category", XT_TEXT_DOMAIN) . ': </span>'; foreach ($all_tags as $tag) { $category_sub_menu .= ' <a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a> '; } $category_sub_menu .= '</span>'; $category_sub_menu .= '<span class="spacer"></span>'; } if (!empty($subcategories)) { $category_sub_menu .= '<span class="category_links megamenu-subcategories">'; $category_sub_menu .= '<span>' . __("Subcategories", XT_TEXT_DOMAIN) . ': </span>'; foreach ($subcategories as $cat) { $category_sub_menu .= ' <a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a> '; } $category_sub_menu .= '</span>'; $category_sub_menu .= '<span class="spacer"></span>'; } if (!empty($submenu_items)) { $category_sub_menu .= '<span class="category_links megamenu-submenu-items">'; $category_sub_menu .= '<span>' . __("Other Links", XT_TEXT_DOMAIN) . ': </span>'; foreach ($submenu_items as $menu_item) { $category_sub_menu .= '<a href="' . $menu_item->url . '">' . $menu_item->title . '</a>'; } $category_sub_menu .= '</span>'; $category_sub_menu .= '<span class="spacer"></span>'; } if (!empty($all_tags) || !empty($subcategories) || !empty($submenu_items)) { $category_sub_menu .= '</div>'; } $category_sub_menu .= "</div></div></div>"; $this->category_sub_menus[$item->object_id] = $category_sub_menu; } } /** * Filter the CSS class(es) applied to a menu item's <li>. * * @since 3.0.0 * * @see wp_nav_menu() * * @param array $classes The CSS classes that are applied to the menu item's <li>. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args)); $class_names = str_replace('menu-item-has-children', 'has-dropdown not-click', $class_names); $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; /** * Filter the ID applied to a menu item's <li>. * * @since 3.0.1 * * @see wp_nav_menu() * * @param string $menu_id The ID that is applied to the menu item's <li>. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args); $id = $id ? ' id="' . esc_attr($id) . '"' : ''; $output .= $indent . '<li' . $id . $class_names . ' data-itemid="' . $item->ID . '" data-objectid="' . $item->object_id . '">'; $atts = array(); $atts['title'] = !empty($item->attr_title) ? $item->attr_title : ''; $atts['target'] = !empty($item->target) ? $item->target : ''; $atts['rel'] = !empty($item->xfn) ? $item->xfn : ''; $atts['href'] = !empty($item->url) ? $item->url : ''; /** * Filter the HTML attributes applied to a menu item's <a>. * * @since 3.6.0 * * @see wp_nav_menu() * * @param array $atts { * The HTML attributes applied to the menu item's <a>, empty strings are ignored. * * @type string $title Title attribute. * @type string $target Target attribute. * @type string $rel The rel attribute. * @type string $href The href attribute. * } * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args); $attributes = ''; foreach ($atts as $attr => $value) { if (!empty($value)) { $value = 'href' === $attr ? esc_url($value) : esc_attr($value); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $item_output = !empty($args->before) ? $args->before : ''; $item_output .= '<a' . $attributes . '>'; /** This filter is documented in wp-includes/post-template.php */ $item_output .= (!empty($args->link_before) ? $args->link_before : '') . apply_filters('the_title', $item->title, $item->ID) . (!empty($args->link_after) ? $args->link_after : ''); $item_output .= '</a>'; $item_output .= !empty($args->after) ? $args->after : ''; /** * Filter a menu item's starting output. * * The menu item's starting output only includes $args->before, the opening <a>, * the menu item's title, the closing </a>, and $args->after. Currently, there is * no filter for modifying the opening and closing <li> for a menu item. * * @since 3.0.0 * * @see wp_nav_menu() * * @param string $item_output The menu item's starting HTML output. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args An array of wp_nav_menu() arguments. */ $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); }
function renderTitle($tag = 'h3', $class = '', $forFeatured = false) { $length = null; if (!$forFeatured && !empty($this->instance["title_length"])) { $length = $this->instance["title_length"]; xt_post_title($tag, $class, true, $length); } else { if (!$forFeatured && !empty($this->instance["title_length"])) { $length = $this->instance["featured_title_length"]; xt_post_title($tag, $class, true, $length); } else { xt_post_title($tag, $class, true); } } }
if ($single_post_featured_image_position == 'behind-title-fullwidth') { $asBackground = true; } ?> <div class="featured-image-behind-title"> <?php xt_post_featured_media(true, $asBackground); ?> </div> <?php } else { ?> <?php xt_post_title('h1'); ?> <?php } ?> <?php if ($single_post_featured_image_position == 'below-title') { ?> <?php xt_post_featured_media(); ?> <?php } ?>
} ?> <div class="meta"> <?php if ($show_post_category) { ?> <?php xt_post_category(); ?> <?php } ?> <?php xt_post_title($title_heading, $title_class); ?> <?php if ($show_post_excerpt) { ?> <?php xt_post_excerpt($excerpt_heading, $excerpt_class); ?> <?php } ?> <?php if ($show_post_author) { ?>