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,
);
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 = floor($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;
}
// 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($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 ];
}
}
}