$exs_word ) { $exs_counter = $exs_index + 1; $exs_array[] = '' . esc_html( $exs_word ) . ''; } return implode( ' ', $exs_array ); } endif; add_filter( 'widget_title', 'exs_filter_widget_title', 999, 3 ); //Since 5.4 this do not needed? //filter calendar widget to fix validation errors if ( ! function_exists( 'exs_filter_widget_calendar_html' ) ) : function exs_filter_widget_calendar_html( $exs_html ) { //get tfoot $exs_tfoot = preg_match( '/(.|\n)*<\/tfoot>/', $exs_html, $exs_match ); //remove tfoot from table $exs_html = preg_replace( '/(.|\n)*<\/tfoot>/', '', $exs_html ); //attach tfoot after tbody if ( ! empty( $exs_match[0] ) ) { $exs_html = str_replace( '', "\n\t" . $exs_match[0], $exs_html ); } return $exs_html; } //exs_filter_widget_calendar_html() endif; add_filter( 'get_calendar', 'exs_filter_widget_calendar_html' ); //wrapping in a span widgets categories and archives items count - but skip dropdowns if ( ! function_exists( 'exs_filter_add_span_to_arhcive_widget_count' ) ) : function exs_filter_add_span_to_arhcive_widget_count( $exs_links ) { if ( stristr( $exs_links, '(', '(', $exs_links ); //for categories widget $exs_links = str_replace( ' (', ' (', $exs_links ); //for archive widget $exs_links = str_replace( ' (', ' (', $exs_links ); $exs_links = preg_replace( '/([0-9]+)\)/', '$1)', $exs_links ); //putting span before link for styling purpose $exs_links = preg_replace( '~() (\(([0-9]*)\))~', '$2$1', $exs_links ); return $exs_links; } endif; add_filter( 'wp_list_categories', 'exs_filter_add_span_to_arhcive_widget_count' ); add_filter( 'get_archives_link', 'exs_filter_add_span_to_arhcive_widget_count' ); //wrapping tag links in span if ( ! function_exists( 'exs_filter_add_spans_to_tag_links' ) ) : function exs_filter_add_spans_to_tag_links( $exs_html ) { $exs_html = str_replace( '', '', $exs_html ); return $exs_html; } endif; add_filter( 'wp_tag_cloud', 'exs_filter_add_spans_to_tag_links' ); //wrapping "category" word in title area in a span if ( ! function_exists( 'exs_filter_wrap_cat_title_before_colon_in_span' ) ) : function exs_filter_wrap_cat_title_before_colon_in_span( $exs_title ) { $exs_hide_tax_name_title = exs_option( 'blog_hide_taxonomy_type_name', false ); if ( is_category() && exs_get_post_special_category_slug() ) { $exs_hide_tax_name_title = true; } if ( empty( $exs_hide_tax_name_title ) ) { return preg_replace( '/^.*: /', '${0}', $exs_title ); } else { return preg_replace( '/^.*: /', '', $exs_title ); } } endif; add_filter( 'get_the_archive_title', 'exs_filter_wrap_cat_title_before_colon_in_span' ); /** * Fix active class in nav for blog page and special cats or post inside special cat. * since 1.9.9 - auto insert Logo menu item in center of the menu primary if appropriate header is set * * @param array $menu_items Menu items. * @return array */ if ( ! function_exists( 'exs_filter_nav_menu_item_classes' ) ) : function exs_filter_nav_menu_item_classes( $menu_items, $args ) { //logo in the middle of the primary menu if ( 'primary' === $args->theme_location && '7' === exs_option( 'header' ) ) : $count = exs_get_menu_top_level_items_count( 'primary' ); $logo_item_key = ( int ) round( $count / 2 ); ob_start(); get_template_part( 'template-parts/header/logo/logo', exs_template_part( 'logo', '1' ), array( 'div' => true ) ); $html_logo = ob_get_clean(); $logo_el = new WP_Post( ( object ) array( 'menu_item_parent' => '0', 'url' => esc_url( home_url( '/' ) ), 'title' => $html_logo, 'ID' => 'primary-logo-id', 'classes' => array( 'd-none', 'desktop-logo-menu-item', ), ) ); $new_items = array(); $top_level_count = 0; $logo_added = false; foreach ( $menu_items as $key => $item ) { if ( '0' === $item->menu_item_parent ) { $top_level_count++; } if( ! $logo_added ) : if ( ( $top_level_count === $logo_item_key + 1 ) || ( 1 === $count ) || ( 0 === $count ) ) : $new_items[] = $logo_el; $logo_added = true; endif; //count = key endif; //logo added $new_items[] = $item; } $menu_items = $new_items; unset( $new_items ); endif; //primary and heading with center logo if ( ! is_category( exs_get_special_categories_from_options_ids_with_children() ) && ! is_singular( 'post' ) ) { return $menu_items; } $page_for_posts = (int) get_option( 'page_for_posts' ); $exs_special_slug = is_singular( 'post' ) ? exs_get_post_special_category_slug() : false; if ( ! empty( $menu_items ) && is_array( $menu_items ) ) { foreach ( $menu_items as $key => $menu_item ) { $classes = (array) $menu_item->classes; $menu_id = (int) $menu_item->object_id; // Unset active class for blog page. if ( ( $page_for_posts === $menu_id && is_category() ) || $exs_special_slug ) { $menu_items[ $key ]->current = false; if ( in_array( 'current_page_parent', $classes, true ) ) { unset( $classes[ array_search( 'current_page_parent', $classes, true ) ] ); } } $menu_items[ $key ]->classes = array_unique( $classes ); } } return $menu_items; } endif; add_filter( 'wp_nav_menu_objects', 'exs_filter_nav_menu_item_classes', 10, 2 ); // add icon to edit comment link if ( ! function_exists( 'exs_filter_edit_comment_link' ) ) : function exs_filter_edit_comment_link( $edit_comment_html ) { $edit_comment_html = str_replace( '', ' ', $edit_comment_html ); return $edit_comment_html; } endif; add_filter( 'edit_comment_link', 'exs_filter_edit_comment_link' ); // add 'data-hover' attribute to nav menu link if ( ! function_exists( 'exs_filter_menu_item_data_hover_attribute' ) ) : function exs_filter_menu_item_data_hover_attribute( $atts, $item, $args, $depth ) { //detect if item is a logo. Since 1.9.9 if ( ! strpos( $item->title, 'rel="home" itemprop="url"' ) ) { $atts['data-hover'] = esc_attr( $item->title ); } return $atts; } endif; //this filter is removed since 1.5.1 in favor of inner span - exs_filter_menu_item_inner_span_whti_data_hover_attribute add_filter( 'nav_menu_link_attributes', 'exs_filter_menu_item_data_hover_attribute', 4, 10 ); // add 'span' inside nav menu item and add 'data-hover' attribute to nav menu link // since 1.5.1 if ( ! function_exists( 'exs_filter_menu_item_inner_span_whti_data_hover_attribute' ) ) : function exs_filter_menu_item_inner_span_whti_data_hover_attribute( $args, $item, $depth ) { //detect if item is a logo. Since 1.9.9 if ( ! strpos( $item->title, 'rel="home" itemprop="url"' ) ) { $args->link_before = ''; $args->link_after = ''; } else { $args->link_before = ''; $args->link_after = ''; } return $args; } endif; add_filter( 'nav_menu_item_args', 'exs_filter_menu_item_inner_span_whti_data_hover_attribute', 3, 10 ); //add ALT text on post thumbnail if it is empty if ( ! function_exists( 'exs_filter_post_thumbnail_add_alt_text_if_empty' ) ) : function exs_filter_post_thumbnail_add_alt_text_if_empty( $html, $post_id ) { return str_replace( 'alt=""', 'alt="' . esc_attr( get_the_title( $post_id ) ) . '"', $html ); } endif; add_filter( 'post_thumbnail_html', 'exs_filter_post_thumbnail_add_alt_text_if_empty', 10, 2 ); //add spans for all headings in the_content if ( ! function_exists( 'exs_filter_the_content_add_spans_to_headings' ) ) : function exs_filter_the_content_add_spans_to_headings( $html ) { //the_title markup: //''; $exs_headings = array( '

', '

', '

', '

', '

', '
' ); $exs_headings_with_atts = array( '', '', '', '', '', '' ); $exs_headings_end = array( '
', '', '', '', '', '' ); foreach ( $exs_headings as $exs_heading ) { $html = str_replace( $exs_heading, $exs_heading . '', $html ); } foreach ( $exs_headings_end as $exs_heading ) { $html = str_replace( $exs_heading, '' . $exs_heading, $html ); } foreach ( $exs_headings_with_atts as $exs_heading ) { $html = preg_replace( '/(' . $exs_heading . ')/', '${1}', $html ); } return $html; } endif; add_filter( 'exs_the_content', 'exs_filter_the_content_add_spans_to_headings', 99 ); //add table of contents based on headings if ( ! function_exists( 'exs_filter_the_content_add_toc_in_post' ) ) : function exs_filter_the_content_add_toc_in_post( $html ) { //return if not single post and not the main query if ( ! is_singular( 'post' ) || ! in_the_loop() || ! is_main_query() || empty( exs_option( 'blog_single_toc_enabled' ) ) ) { return $html; } $toc_html = ''; $h = preg_match_all('~(.*)~i',$html,$matches); if ( ! empty( $h ) ) : //set IDs for titles foreach ( $matches[0] as $key => $heading ) { if ( stripos( $heading, ' id=' ) === false ) { $pos = strpos( $heading, '>' ); if ($pos !== false) { $new_heading = substr_replace( $heading, ' id="' . sanitize_title( $matches[2][ $key ] ). '">', $pos, strlen('>' ) ); $html = str_replace( $heading, $new_heading, $html ); } } } //create a TOC markup $toc_title = exs_option( 'blog_single_toc_title', '' ); $toc_bg = exs_option( 'blog_single_toc_background', '' ); $toc_mt = exs_option( 'blog_single_toc_mt', 'mt-2' ); $toc_mb = exs_option( 'blog_single_toc_mb', 'mb-2' ); $toc_padding = $toc_bg ? ' extra-padding' : ''; $toc_bordered = exs_option( 'blog_single_toc_bordered', '' ) ? ' bordered' : ''; $toc_shadow = exs_option( 'blog_single_toc_shadow', '' ) ? ' shadow' : ''; $toc_rounded = exs_option( 'blog_single_toc_rounded', '' ) ? ' rounded' : ''; $toc_html .= '
'; if ( ! empty( $toc_title ) ) { $toc_html .= '

' . esc_html ( $toc_title ) . '

'; } $toc_html .= '
'; endif; //! empty $h $toc_position = exs_option( 'blog_single_toc_after_first_p' ); if ( ( '2' === $toc_position ) ) { add_action( 'exs_action_top_of_aside_column', function () use ( $toc_html ){ $exs = ExS::instance(); if ( ! $exs->get('toc') ) { echo wp_kses_post( str_replace( '
set('toc', 1); } }); return str_replace( '
false, ) ); return $args; } endif; add_filter( 'widget_nav_menu_args', 'exs_filter_widget_nav_menu_args' ); //add custom image size to Gutenberg dropdown add_filter( 'image_size_names_choose', 'exs_filter_image_size_names_choose' ); if ( ! function_exists( 'exs_filter_image_size_names_choose' ) ) : function exs_filter_image_size_names_choose( $sizes ) { return array_merge( $sizes, array( 'exs-square' => esc_html__( 'Square 800x800', 'exs' ), 'exs-square-half' => esc_html__( 'Half Square 800x400', 'exs' ), ) ); } endif; //filter page menu if ( ! function_exists( 'exs_filter_wp_page_menu_args' ) ) : function exs_filter_wp_page_menu_args( $args ) { $args['menu_class'] = 'top-menu '; $args['container'] = 'ul'; return $args; } endif; add_filter( 'wp_page_menu_args', 'exs_filter_wp_page_menu_args' ); //add social icons to bottom menu and additional logo, search and meta to the mobile primary menu if ( ! function_exists( 'exs_filter_nav_additional_links' ) ) : function exs_filter_nav_additional_links( $items, $args ) { //bottom menu if( 'bottom' === $args->theme_location && exs_option( 'bottom_nav_show_social' ) ) { $links = exs_social_links_html(); if ( ! empty( $links ) ) { $items .= '
  • '; $items .= $links; $items .= '
  • '; } } //primary menu if( 'primary' === $args->theme_location ) { $items_before = ''; if ( exs_option( 'menu_mobile_show_logo' ) ) { ob_start(); get_template_part( 'template-parts/header/logo/logo', exs_template_part( 'logo', '1' ) ); $html_logo = ob_get_clean(); $items_before .= ''; } if ( exs_option( 'menu_mobile_show_search' ) ) { ob_start(); get_search_form(); $html_search = ob_get_clean(); $items_before .= ''; } if ( $items_before ) { $items = $items_before . $items; } if ( exs_option( 'menu_mobile_show_meta' ) ) { ob_start(); get_template_part( 'template-parts/site-meta' ); $html_meta = ob_get_clean(); if ( $html_meta ) { $items = $items . ''; } } if ( exs_option( 'menu_mobile_show_social' ) ) { $html_links = exs_social_links_html(); if ( $html_links ) { $items = $items . ''; } } } return $items; } endif; add_filter( 'wp_nav_menu_items', 'exs_filter_nav_additional_links', 20, 2 ); //add avatar custom image if exist if ( ! function_exists( 'exs_filter_custom_avatar_image_for_comments' ) ) : function exs_filter_custom_avatar_image_for_comments( $args, $id_or_email ) { if( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) { $img = get_user_meta( $id_or_email->user_id, 'custom_profile_image'); if(!empty($img)&&!empty($img[0])){ $args['url']=esc_url($img[0]); } } return $args; } endif; add_filter( 'get_avatar_data', 'exs_filter_custom_avatar_image_for_comments', 10, 2 );