absint( $num ), 'ignore_sticky_posts' => 1 ); switch ( $slides_from ) { case 'category': $category = azeria_get_option( 'slides_cat' ); if ( $category ) { $query_args['category_name'] = esc_attr( $category ); } break; case 'sticky': $sticky = get_option( 'sticky_posts' ); if ( ! empty( $sticky ) ) { $query_args['post__in'] = $sticky; } break; } /** * Allow to rewrite slider query arguments from child theme/3rd party plugins */ $query_args = apply_filters( 'azeria_slider_query_args', $query_args ); $slider_query = new WP_Query( $query_args ); if ( ! $slider_query->have_posts() ) { return; } $show_banner = azeria_get_option( 'slider_banner', true ); $btn_text = azeria_get_option( 'slider_btn_text', __( 'Read', 'azeria' ) ); $result = ''; while ( $slider_query->have_posts() ) { $slider_query->the_post(); if ( ! has_post_thumbnail( $slider_query->post->ID ) ) { continue; } $image = get_the_post_thumbnail( $slider_query->post->ID, 'azeria-slider-thumbnail', array( 'alt' => get_the_title( $slider_query->post->ID ) ) ); $banner = ''; if ( $show_banner ) { $banner = azeria_get_slider_banner( $slider_query->post->ID, esc_html( $btn_text ) ); } $result .= '
' . $image . $banner . '
'; } $slider_defaults = apply_filters( 'azeria_slider_default_args', array( 'fade' => false, 'arrows' => true, 'dots' => true, 'speed' => 400 ) ); $fade = ( 'fade' == azeria_get_option( 'slider_animation', 'slide' ) ); $arrows = azeria_get_option( 'slider_arrows', true ); $pager = azeria_get_option( 'slider_pager', true ); $slider_args = wp_parse_args( array( 'fade' => (bool)$fade, 'arrows' => (bool)$arrows, 'dots' => (bool)$pager ), $slider_defaults ); $slider_args = json_encode( $slider_args ); wp_reset_postdata(); wp_reset_query(); /** * Filter slider output before printing */ $result = apply_filters( 'azeria_slider_output', sprintf( '
%1$s
', $result, $slider_args ) ); echo $result; } /** * Get slider banner content by post ID * * @param int $post_id post ID to get banner for * @param string $btn_text banner button text */ function azeria_get_slider_banner( $post_id, $btn_text ) { $format = '
%1$s%2$s
%3$s
'; $title = '

' . get_the_title( $post_id ) . '

'; if ( has_excerpt( $post_id ) ) { $excerpt = get_the_excerpt(); } else { $content = get_the_content(); $excerpt = strip_shortcodes( $content ); $excerpt = str_replace( ']]>', ']]>', $content ); $excerpt = wp_trim_words( $excerpt, 20, '' ); } $excerpt = '
' . $excerpt . '
'; $button = '
' . $btn_text . '
'; return sprintf( $format, $title, $excerpt, $button ); } /** * Show about box in sidebar */ function azeria_about_box() { $is_enabled = azeria_get_option( 'about_enabled', true ); if ( ! $is_enabled ) { return; } // prepare data $title = azeria_get_option( 'about_title', __( 'About Me', 'azeria' ) ); $image = azeria_get_option( 'about_img' ); $message = azeria_get_option( 'about_message', __( 'Hello! And welcome to my personal website!', 'azeria' ) ); $title_html = ( ! empty( $title ) ) ? sprintf( '

%s

', sanitize_text_field( $title ) ) : ''; $image_html = ( ! empty( $image ) ) ? sprintf( '%2$s', esc_url( $image ), esc_attr( $title ) ) : ''; $message_html = ( ! empty( $message ) ) ? sprintf( '
%s
', esc_textarea( $message ) ) : ''; ?>
%s', sanitize_text_field( $title ) ) : ''; $social_list = ''; $item_format = '
'; foreach ( $socials as $net => $data ) { $data = wp_parse_args( $data, array( 'label' => '', 'icon' => '', 'default' => '' ) ); $url = azeria_get_option( 'follow_' . $net, $data['default'] ); if ( ! $url ) { continue; } $social_list .= sprintf( $item_format, esc_url( $url ), esc_attr( $data['icon'] ), esc_attr( $net ) ); } $social_list_html = ( ! empty( $social_list ) ) ? sprintf( '
%s
', $social_list ) : ''; ?>
'

', 'email' => '

', 'url' => '

' ); return $fields; } /** * Replace default excerpt more symbols */ function azeria_excerpt_more($more) { return ' ...'; } /** * Backwards compatibility for title tag */ if ( ! function_exists( '_wp_render_title_tag' ) ) : function azeria_render_title() { ?> <?php wp_title( '|', true, 'right' ); ?>