array( 'class' => array(), 'href' => array(), 'rel' => array(), 'title' => array(), ), 'option' => array( 'value' => array(), ), 'abbr' => array( 'title' => array(), ), 'b' => array(), 'blockquote' => array( 'cite' => array(), ), 'cite' => array( 'title' => array(), ), 'code' => array(), 'del' => array( 'datetime' => array(), 'title' => array(), ), 'dd' => array(), 'div' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'dl' => array(), 'dt' => array(), 'em' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'i' => array(), 'img' => array( 'alt' => array(), 'class' => array(), 'height' => array(), 'src' => array(), 'width' => array(), ), 'li' => array( 'class' => array(), ), 'sup'=> array( 'class' => array(), ), 'ol' => array( 'class' => array(), ), 'p' => array( 'class' => array(), ), 'q' => array( 'cite' => array(), 'title' => array(), ), 'span' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'i' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'strike' => array(), 'strong' => array(), 'ul' => array( 'class' => array(), ), ); if ( function_exists( 'wp_kses' ) ) { // WP is here $allowed = wp_kses( $raw, $allowed_tags ); } else { $allowed = $raw; } return $allowed; } function cafesio_get_crop_title( $title , $count = 10 ) { if(cafesio_option('cafesio_categry_title_lenght')) { $count = cafesio_option('cafesio_categry_title_lenght'); } return wp_trim_words($title,$count,''); } /* Excerp limit function default 100 */ function cafesio_get_excerpt($count = 100 ) { $count = cafesio_desc_limit($count); $cafesio_blog_read_more_text = cafesio_option('cafesio_blog_readmore_text',esc_html__('Read More','cafesio')); $excerpt = get_the_excerpt(); $excerpt = esc_html($excerpt); $words = str_word_count($excerpt, 2); $pos = array_keys($words); if(count($words)>$count){ $excerpt = substr($excerpt, 0, $pos[$count]); } $cafesio_blog_read_more = cafesio_option('cafesio_blog_readmore','yes'); if($cafesio_blog_read_more == 'yes'){ $excerpt = wp_kses_post($excerpt .''. $cafesio_blog_read_more_text. ' '); } return $excerpt; } function cafesio_desc_limit($default){ if(!is_single() && !is_page()) { if(cafesio_option('cafesio_categry_post_desc_lenght') ){ return cafesio_option('cafesio_categry_post_desc_lenght'); }else{ return $default; } }else{ return $default; } } // cafesio related post by tags function cafesio_related_posts_by_tags( $post_id = '', $related_count = 4, $feature_image = false ) { try{ if($post_id==''){ $post_id = get_the_ID(); } $tags = wp_get_post_tags($post_id); $term_tags = wp_list_pluck($tags,'term_id'); $args = array( 'tag__in' => $term_tags, 'post__not_in' => array($post_id), 'posts_per_page'=>$related_count, 'ignore_sticky_posts'=>1, ); if($feature_image){ $args["meta_query"] = array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ); } return new WP_Query($args); } catch(Exception $e) { return new WP_Query( [] ); } } // cafesio feature post by sticky function cafesio_related_posts_by_sticky( ) { if(!is_category()){ return new WP_Query( [] ); } try{ $term = get_queried_object(); $args = [ 'post_type' => 'post', 'post__in' => get_option( 'sticky_posts' ), 'posts_per_page' => 10, 'ignore_sticky_posts' => 1, 'tax_query' => array( array ( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => $term->slug, ) ), ]; return new WP_Query($args); } catch(Exception $e) { return new WP_Query( [] ); } } function cafesio_src($key='',$default=''){ if($key=='' || !cafesio_option($key)){ return $default; } return cafesio_option($key); } /* theme_mod alter function check json value */ // function cafesio_option($key='',$default=''){ // if($key=='' || !get_theme_mod($key)){ // return $default; // } // $option = get_theme_mod($key,$default); // if(cafesio_isJson($option)){ // return json_decode($option); // } // return $option; // } function cafesio_option( $key, $default_value = '', $method = 'customizer' ) { if ( defined( 'DEVM' ) ) { switch ( $method ) { case 'customizer': $value = devm_theme_option( $key ); break; default: $value = ''; break; } return (!isset($value) || $value == '') ? $default_value : $value; } return $default_value; } function cafesio_isJson($string) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); } // meta option function cafesio_meta_option( $postid, $key, $default_value = '' ) { if ( defined( 'DEVM' ) ) { $value = devm_meta_option($postid, $key, $default_value); } return (!isset($value) || $value == '') ? $default_value : $value; }