'wp_head', 'preloader_style' => 'style1', 'preloader_color' => '#1740f5', 'container_width' => '1140', 'hide_import_btn' => '' ); update_option('ultp_options', $option_data); return $option_data; } // Excerpt public function excerpt( $post_id, $limit = 55 ) { return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) ); } // Query Builder public function get_query($attr) { $query_args = array( 'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3, 'post_type' => isset($attr['queryType']) ? $attr['queryType'] : 'post', 'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date', 'order' => isset($attr['queryOrder']) ? $attr['queryOrder'] : 'desc', 'paged' => isset($attr['paged']) ? $attr['paged'] : 1, 'post_status' => 'publish' ); if(isset($attr['queryOrderBy']) && isset($attr['metaKey'])){ if($attr['queryOrderBy'] == 'meta_value_num') { $query_args['meta_key'] = $attr['metaKey']; } } if(isset($attr['queryOffset']) && $attr['queryOffset'] && !($query_args['paged'] > 1) ){ $query_args['offset'] = isset($attr['queryOffset']) ? $attr['queryOffset'] : 0; } if(isset($attr['queryInclude']) && $attr['queryInclude']){ $query_args['post__in'] = explode(',', $attr['queryInclude']); } if(isset($attr['queryExclude']) && $attr['queryExclude']){ $query_args['post__not_in'] = explode(',', $attr['queryExclude']); } if(isset($attr['queryTax'])){ if(isset($attr['queryCat'])){ if($attr['queryTax'] == 'category' && !empty($attr['queryCat'])){ $var = array('relation'=>'OR'); foreach (json_decode($attr['queryCat']) as $val) { $var[] = array('taxonomy'=>'category', 'field' => 'slug', 'terms' => $val ); } $query_args['tax_query'] = $var; } } if(isset($attr['queryTag'])){ if($attr['queryTax'] == 'tag' && !empty($attr['queryTag'])){ $var = array('relation'=>'OR'); foreach (json_decode($attr['queryTag']) as $val) { $var[] = array('taxonomy'=>'post_tag', 'field' => 'slug', 'terms' => $val ); } $query_args['tax_query'] = $var; } } } $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' ); return $query_args; } public function get_page_number($attr, $post_number) { if($post_number > 0){ $post_per_page = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; $pages = ceil($post_number/$post_per_page); return $pages ? $pages : 1; }else{ return 1; } } public function get_image_size() { $sizes = get_intermediate_image_sizes(); $filter = array('full' => 'Full'); foreach ($sizes as $value) { $filter[$value] = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); } return $filter; } public function get_post_type() { $post_type = get_post_types( '', 'names' ); return array_diff($post_type, array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' )); } // Pagination public function pagination($pages = '', $paginationNav, $range = 1) { $html = ''; $showitems = 3; $paged = get_query_var('paged') ? get_query_var('paged') : 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]); if(1 != $pages) { $html .= ''; } return $html; } public function excerpt_word($charlength = 200) { $html = ''; $charlength++; $excerpt = get_the_excerpt(); if ( mb_strlen( $excerpt ) > $charlength ) { $subex = mb_substr( $excerpt, 0, $charlength - 5 ); $exwords = explode( ' ', $subex ); $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); if ( $excut < 0 ) { $html = mb_substr( $subex, 0, $excut ); } else { $html = $subex; } $html .= '...'; } else { $html = $excerpt; } return $html; } public function taxonomy( $prams = 'category' ) { $data = array(); $terms = get_terms( $prams, array( 'hide_empty' => true, )); if( !empty($terms) ){ foreach ($terms as $val) { $data[$val->slug] = $val->name; } } return $data; } public function next_prev() { $html = ''; $html .= ''; return $html; } public function loading(){ $html = ''; $style = 'style1'; $option_data = get_option('ultp_options'); if( isset($option_data['preloader_style']) ){ $style = $option_data['preloader_style']; } if( $style == 'style2' ){ $html .= '
';//ultp-block-items-wrap } else { $html .= '
'; } return '
'.$html.'
'; } public function filter($filterText = '', $filterType = '', $filterCat = '[]', $filterTag = '[]'){ $html = ''; $html .= ''; return $html; } public function svg_icon($icons = ''){ $icon_lists = array( 'eye' => file_get_contents(ULTP_PATH.'assets/img/svg/eye.svg'), 'user' => file_get_contents(ULTP_PATH.'assets/img/svg/user.svg'), 'calendar' => file_get_contents(ULTP_PATH.'assets/img/svg/calendar.svg'), 'comment' => file_get_contents(ULTP_PATH.'assets/img/svg/comment.svg'), 'book' => file_get_contents(ULTP_PATH.'assets/img/svg/book.svg'), 'tag' => file_get_contents(ULTP_PATH.'assets/img/svg/tag.svg'), 'clock' => file_get_contents(ULTP_PATH.'assets/img/svg/clock.svg'), 'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle.svg'), 'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle.svg'), 'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle2.svg'), 'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle2.svg'), 'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/leftArrowLg.svg'), 'refresh' => file_get_contents(ULTP_PATH.'assets/img/svg/refresh.svg'), 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'), ); if($icons){ return $icon_lists[ $icons ]; } } }