'1170', 'menu_bar_bg_clr' => '#ffffff', 'menu_bar_link_clr' => '#000000', 'menu_bar_linkh_clr' => '#FF6347', 'continue_read_clr' => '#000000', 'continue_read_hvr_clr' => '#FF6347', 'h1_clr' => '#000000', 'h2_clr' => '#000000', 'h3_clr' => '#000000', 'h4_clr' => '#000000', 'h5_clr' => '#000000', 'h6_clr' => '#000000', 'link_clr' => '#000000', 'hover_link_clr' => '#FF6347', 'header_style' => '1', 'show_loader' => 0, 'logo_position' => 'logo-position-center', 'show_search' => 1, 'blog_layout' => 'grid', 'blog_layout_grid' => 12, 'blog_layout_design' => 'design-1', 'cat_layout_design' => 'design-1', 'blog_template' => 'right', 'news_template' => 'right', 'blog_excerpt_length' => 40, 'blog_show_date' => 1, 'blog_show_author' => 1, 'blog_show_cat' => 1, 'blog_show_tags' => 1, 'blog_show_comment' => 1, 'blog_show_date_above' => 0, 'blog_show_author_above' => 0, 'blog_show_cat_above' => 0, 'single_show_comment' => 1, 'cat_layout' => 'grid', 'cat_layout_grid' => 12, 'cat_template' => 'right', 'cat_show_date' => 1, 'cat_show_author' => 1, 'cat_show_cat' => 1, 'cat_show_tags' => 1, 'cat_show_comment' => 1, 'single_post_template' => 'right', 'single_post_fet_img' => 1, 'related_post_show' => 1, 'related_post_title' => __('More from', 'amyra') , 'fc_post_layout' => '[fpc_post_block]', 'show_fc_post_home' => 0, 'show_fc_post_front' => 0, 'show_fc_post_search' => 0, 'show_fc_post_single' => 0, 'show_fc_post_cat' => 0, 'show_fc_news_page' => 0, 'fc_post_design' => 1, 'show_fc_post_full' => 0, 'header_social' => 0, 'footer_social' => 0, 'facebook' => '', 'twitter' => '', 'linkedin' => '', 'behance' => '', 'dribbble' => '', 'instagram' => '', 'youtube' => '', 'pinterest' => '', 'copyright' => __('© {year} Amyra WordPress Blog Theme', 'amyra'), 'footer_sec1_icon' => '', 'footer_sec1_cnt' => '', 'footer_sec2_icon' => '', 'footer_sec2_cnt' => '', 'footer_sec3_icon' => '', 'footer_sec3_cnt' => '', 'loader_img' => '', ); return apply_filters('amyra_options_default_values', $default_settings ); } /** * Escape Tags & Slashes * * Handles escapping the slashes and tags * * @package Amyra * @since 1.0 */ function amyra_esc_attr($data) { return esc_attr( $data ); } /** * Function to unique number value * * @package Amyra * @since 1.0 */ function amyra_get_unique() { static $unique = 0; $unique++; return $unique; } /** * Function to excerpt length * * @package Amyra * @since 1.0 */ function iclean_excerpt_length( $length ) { $blog_excerpt_length = amyra_get_theme_mod( 'blog_excerpt_length' ); return $blog_excerpt_length; } add_filter( 'excerpt_length', 'iclean_excerpt_length', 999 ); /** * Function to excerpt more * * @package Amyra * @since 1.0 */ function iclean_excerpt_more( $more ) { return '...'; } add_filter('excerpt_more', 'iclean_excerpt_more'); /** * Function to add array after specific key * * @package Amyra * @since 1.0 */ function amyra_add_array(&$array, $value, $index, $from_last = false) { if( is_array($array) && is_array($value) ) { if( $from_last ) { $total_count = count($array); $index = (!empty($total_count) && ($total_count > $index)) ? ($total_count-$index): $index; } $split_arr = array_splice($array, max(0, $index)); $array = array_merge( $array, $value, $split_arr); } return $array; } /** * Function to get footer sidebar widget class * * @package Amyra * @since 1.0 */ function amyra_footer_widgets_cls( $sidebar_id ) { global $_wp_sidebars_widgets; $sidebars_widgets_count = $_wp_sidebars_widgets; if ( isset( $sidebars_widgets_count[ $sidebar_id ] ) ) { $widget_count = count( $sidebars_widgets_count[ $sidebar_id ] ); $widget_classes = 'widget-count-' . count( $sidebars_widgets_count[ $sidebar_id ] ); if ( $widget_count == 2 ) { $widget_classes .= ' amyra-col-6'; } elseif ( $widget_count == 3 ) { $widget_classes .= ' amyra-col-4'; } elseif ( $widget_count == 4 ) { $widget_classes .= ' amyra-col-3'; } elseif ( $widget_count == 5 ) { $widget_classes .= ' amyra-col-5c'; } elseif ( $widget_count == 6 ) { $widget_classes .= ' amyra-col-2'; } else { $widget_classes .= ' amyra-col-12'; } return $widget_classes; } } /** * Determine where to display featured content section * * @package Amyra * @since 1.0 */ function amyra_fcs_display() { global $wp_query; $display = false; $fp_is_home = amyra_get_theme_mod( 'show_fc_post_home' ); $fp_is_frontp = amyra_get_theme_mod( 'show_fc_post_front' ); $fp_is_search = amyra_get_theme_mod( 'show_fc_post_search' ); $fp_is_single = amyra_get_theme_mod( 'show_fc_post_single' ); $fp_is_cat = amyra_get_theme_mod( 'show_fc_post_cat' ); $fp_is_news = amyra_get_theme_mod( 'show_fc_news_page' ); if( is_search() && !empty($fp_is_search) ) { $display = true; } elseif( $wp_query->is_posts_page && !empty($fp_is_home) ) { $display = true; } elseif( is_front_page() && !empty($fp_is_frontp) && !is_page_template('page-templates/news-page.php') ){ $display = true; } elseif( is_front_page() && !empty($fp_is_news) && is_page_template('page-templates/news-page.php') ) { $display = true; } elseif( !is_front_page() && is_home() && !$wp_query->is_posts_page && !empty($fp_is_home) ) { // If Front page is not set and latest post is being displayed $display = true; } elseif( get_query_var('cat') && !empty($fp_is_cat) ) { // If WordPress category page $display = true; } elseif( is_single() && !empty($fp_is_single) ) { // If WordPress single page $display = true; } return $display; } /** * Get Google fonts URL for the theme. * * @package Amyra * @since 1.0 */ function amyra_google_fonts_url() { $fonts = array(); $subsets = 'latin,latin-ext'; if ( 'off' !== _x( 'on', 'Playfair Display font: on or off', 'amyra' ) ) { $fonts[] = 'Playfair Display:400,400i,700,700i,900,900i'; } if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'amyra' ) ) { $fonts[] = 'Open Sans:400,400i,700,700i'; } $fonts_url = add_query_arg( array( 'family' => rawurlencode( implode( '|', $fonts ) ), 'subset' => rawurlencode( $subsets ), ), 'https://fonts.googleapis.com/css' ); return $fonts_url; } /** * Function to get registered post types * * @package Amyra * @since 1.0 */ function amyra_get_post_types( $args = array() ) { // Taking defaults $all_post_types = array(); $args = array( 'public' => !empty($args['public']) ? $args['public'] : 'true' ); $all_post_types = get_post_types( $args, 'object' ); $exclude_post = array('attachment'); foreach ($all_post_types as $post_type_key => $post_data) { if( !in_array( $post_type_key, $exclude_post) ) { $post_types[$post_type_key] = !empty($post_data->label) ? $post_data->label : $post_type_key; } } return apply_filters('amyra_get_post_types', $post_types ); } /** * Function to get comment count text * * @package Amyra * @since 1.0 */ function amyra_get_comments_number( $post_id = '', $hide_empty = false ) { $comment_text = ''; if( !empty($post_id) ) { $comment_number = get_comments_number( $post_id ); if ( $comment_number == 0 && empty($hide_empty) ) { $comment_text = __('0 Comments', 'amyra'); } elseif ( $comment_number > 1 ) { $comment_text = $comment_number . __(' Comments', 'amyra'); } elseif ( $comment_number == 1 ) { $comment_text = __('1 Comment', 'amyra'); } } return $comment_text; } /** * Function to get post featured image * * @package Amyra * @since 1.0 */ function amyra_get_post_featured_image( $post_id = '', $size = 'full', $default_img = false ) { $size = !empty($size) ? $size : 'full'; $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size ); if( !empty($image) ) { $image = isset($image[0]) ? $image[0] : ''; } // Getting default image if( $default_img && empty($image) ) { $image = ''; } return $image; } /** * Function to get post excerpt * * @package Amyra * @since 1.0 */ function amyra_get_post_excerpt( $post_id = null, $content = '', $word_length = '55', $more = '...' ) { $word_length = !empty($word_length) ? $word_length : '55'; // If post id is passed if( !empty($post_id) ) { if (has_excerpt($post_id)) { $content = get_the_excerpt(); } else { $content = !empty($content) ? $content : get_the_content(); } } if( !empty($content) ) { $content = strip_shortcodes( $content ); // Strip shortcodes $content = wp_trim_words( $content, $word_length, $more ); } return $content; } /** * Strip Slashes From Array * * @package Amyra * @since 1.0 */ function amyra_slashes_deep($data = array(), $flag = false) { if($flag != true) { $data = amyra_nohtml_kses($data); } $data = stripslashes_deep($data); return $data; } function amyra_nohtml_kses($data = array()) { if ( is_array($data) ) { $data = array_map('amyra_nohtml_kses', $data); } elseif ( is_string( $data ) ) { $data = trim( $data ); $data = wp_filter_nohtml_kses($data); } return $data; } /** * Function to get customizer value * * @package Amyra * @since 1.0 */ function amyra_get_theme_mod( $mod = '' ) { $default_settings = amyra_default_settings(); $default_val = isset($default_settings[ $mod ]) ? $default_settings[ $mod ] : ''; return get_theme_mod( $mod, $default_val ); } /** * Clean variables using sanitize_text_field. Arrays are cleaned recursively. * Non-scalar values are ignored. * * @package Amyra * @since 1.0 */ function amyra_sanitize_clean( $var ) { if ( is_array( $var ) ) { return array_map( 'amyra_sanitize_clean', $var ); } else { $data = is_scalar( $var ) ? sanitize_text_field( $var ) : $var; return wp_unslash($data); } } /** * Checkbox sanitization callback. */ function amyra_sanitize_checkbox( $checked ) { return ( ( !empty( $checked ) ) ? true : false ); } /** * Select sanitization callback. * * @package Amyra * @since 1.0 */ function amyra_sanitize_select( $input, $setting ) { $input = sanitize_key( $input ); $choices = $setting->manager->get_control( $setting->id )->choices; return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Sanitize URL * * @package Amyra * @since 1.0 */ function amyra_sanitize_url( $url ) { return esc_url_raw( trim($url) ); } /** * Category image template set * * @package Amyra * @since 1.0 */ function amyra_cat_template($name, $params = array(), $echo_html = true) { $filename = AMYRA_PATH_CAT_IMG_TEMPLATES . $name . '.php'; if (! file_exists($filename)) { return; } foreach ($params as $param => $value) { $$param = $value; } ob_start(); include $filename; $html = ob_get_contents(); ob_end_clean(); if (! $echo_html) { return $html; } echo $html; } /** * Removing Jetpack share button. * * @package Amyra * @since 1.0 */ function amyra_remove_share() { remove_filter( 'the_content', 'sharing_display', 19 ); remove_filter( 'the_excerpt', 'sharing_display', 19 ); if ( class_exists( 'Jetpack_Likes' ) ) { remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 ); } } add_action( 'loop_start', 'amyra_remove_share' ); /** * Handles the footer copy right text * * @package Amyra * @since 1.0 */ function amyra_footer_copyright() { $current_year = date( 'Y', current_time('timestamp') ); $copyright_text = amyra_get_theme_mod( 'copyright' ); $copyright_text = str_replace('{year}', $current_year, $copyright_text); return apply_filters( 'amyra_footer_copyright', $copyright_text); } /** * Check has post formate has any media * * @package Amyra * @since 1.0 */ function amyra_post_has_media() { $prefix = AMYRA_META_PREFIX; if( has_post_format('audio') ){ $post_audio_iframe = get_post_meta( get_the_ID(), $prefix. 'post_audio', true ); $post_audio_ogg = get_post_meta( get_the_ID(), $prefix. 'ogg_file_url', true ); $post_audio_mp3 = get_post_meta( get_the_ID(), $prefix. 'mp3_file_url', true ); $content_media = (!empty($post_audio_iframe) || !empty($post_audio_ogg) || !empty($post_audio_mp3) ) ? true:false; } elseif( has_post_format('video') ) { $post_video_iframe = get_post_meta( get_the_ID(), $prefix. 'post_video', true ); $post_video_m4v = get_post_meta( get_the_ID(), $prefix. 'm4v_file_url', true ); $post_video_ogv = get_post_meta( get_the_ID(), $prefix. 'ogv_file_url', true ); $content_media = (!empty($post_video_iframe) || !empty($post_video_m4v) || !empty($post_video_ogv) ) ? true:false; } elseif( has_post_format('quote') ) { $post_quote = get_post_meta( get_the_ID(), $prefix. 'post_quote', true ); $content_media = ( !empty($post_quote) ) ? true:false; } elseif( has_post_format('gallery') ) { $post_images_list = get_post_meta( get_the_ID(), $prefix. 'gallery_imgs', true ); $gallery = get_post_gallery(get_the_ID(), false); $content_media = ( !empty($post_images_list) || !empty($gallery) ) ? true:false; }else { if(has_post_thumbnail()){ $content_media = true; }else{ $content_media = false; } } return $content_media; } /** * Handles column if has thumb or post formate media * * @package Amyra * @since 1.0 */ function amyra_grid_column_class() { $grid_class = 'amyra-col-12 amyra-content-full'; if( has_post_thumbnail() || amyra_post_has_media() ){ $grid_class = 'amyra-col-6 amyra-content-right'; } return $grid_class; }