= 2 || $page >= 2) && ! is_404() ) { $title .= ' ' . $sep . ' ' . sprintf( esc_html__( 'Page %s', 'amy-xmas' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'amy_xmas_filter_wp_title' ); } /** * Add class to menu link. */ if ( ! defined( 'AMY_VERSION' ) ) { if ( ! function_exists( 'amy_xmas_filter_nav_menu_link_attributes' ) ) { function amy_xmas_filter_nav_menu_link_attributes( $atts, $item, $args ) { if ( $args->theme_location == 'primary' ) { $atts['class'] = isset( $atts['class'] ) ? $atts['class'] . ' amy-link' : 'amy-link'; } return $atts; } add_filter( 'nav_menu_link_attributes', 'amy_xmas_filter_nav_menu_link_attributes', 10, 3 ); } if ( ! function_exists( 'amy_xmas_filter_wp_nav_menu_args' ) ) { function amy_xmas_filter_wp_nav_menu_args( $args ) { $location = $args['theme_location']; if ( ($location == 'primary' && ! isset( $args['mobile'] )) ) { $args['container'] = false; } return $args; } add_filter( 'wp_nav_menu_args', 'amy_xmas_filter_wp_nav_menu_args', 99 ); } } /** * Post format filters in the_content */ if ( ! function_exists( 'amy_xmas_filter_the_content' ) ) { function amy_xmas_filter_the_content( $content ) { $post_format = get_post_format(); if ( $post_format ) { $content = apply_filters( 'amy_xmas_post_format_' . $post_format, $content ); } return $content; } add_filter( 'the_content', 'amy_xmas_filter_the_content', 2 ); } /** * Blog auto excerpt read more. */ if ( ! function_exists( 'amy_xmas_filter_auto_excerpt_read_more_link' ) ) { function amy_xmas_filter_auto_excerpt_read_more_link( $content ) { if ( amy_get_option( 'blog_auto_excerpt' ) === true && get_post_type() == 'post' && ! is_feed() && ! is_single() && ! is_search() ) { $content = amy_xmas_create_post_excerpt( $content ); } return $content; } add_filter( 'the_content', 'amy_xmas_filter_auto_excerpt_read_more_link', 7 ); } /** * Post format video/audio */ if ( ! function_exists( 'amy_xmas_filter_post_format_media' ) ) { function amy_xmas_filter_post_format_media( $content ) { $media = amy_xmas_get_first_url( $content ); if ( ! empty( $media ) ) { $content = str_replace( $media, '', $content ); } else { $pattern = amy_xmas_get_shortcode_regex( amy_xmas_get_tagregex() ); preg_match( '/' . $pattern . '/', $content, $media ); if ( ! empty( $media[2] ) ) { $content = str_replace( $media[0], '', $content ); } } return $content; } add_filter( 'amy_xmas_post_format_video', 'amy_xmas_filter_post_format_media' ); add_filter( 'amy_xmas_post_format_audio', 'amy_xmas_filter_post_format_media' ); } /** * Post format link. */ if ( ! function_exists( 'amy_xmas_filter_post_format_link' ) ) { function amy_xmas_filter_post_format_link( $content ) { $parse = amy_xmas_post_format_link_helper( $content ); return $parse['content']; } add_filter( 'amy_xmas_post_format_link', 'amy_xmas_filter_post_format_link' ); } /** * comment_form_fields filter. Move comment field to bottom. */ if ( ! function_exists( 'amy_xmas_filter_comment_form_fields' ) ) { function amy_xmas_filter_comment_form_fields( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } add_filter( 'comment_form_fields', 'amy_xmas_filter_comment_form_fields' ); }