get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.$url.'"/>';
}else{
$class = $class ? ' class="'.$class.'" ' : '';
return '';
}
} else {
$class = $class ? ' class="'.$class.'" ' : '';
return '
';
}
}
public function get_image($attach_id, $size = 'full', $class = '', $alt = ''){
$alt = $alt ? ' alt="'.$alt.'" ' : '';
if( function_exists('ultimate_post_pro') ){
$addon_enable = get_option('ultp_pro_options');
if($addon_enable['addons_imageloading']){
$class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" ';
return '
get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.wp_get_attachment_image_url( $attach_id, $size ).'"/>';
}else{
$class = $class ? ' class="'.$class.'" ' : '';
return '
';
}
} else {
$class = $class ? ' class="'.$class.'" ' : '';
return '
';
}
}
// Init data
public function init_set_data(){
$option_data = array(
'css_save_as' => '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;
}
}
}
if(isset($attr['queryQuick'])){
if($attr['queryQuick'] != ''){
if(function_exists('ultimate_post_pro')){
$query_args = ultimate_post_pro()->get_quick_query($attr, $query_args);
}
}
}
$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 .= '