PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.2.5
Post Grid Gutenberg Blocks – PostX v2.2.5
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
← All changes | classes/Functions.php +170 -46 2.1.22.2.5 View file →
@@ -8,8 +8,144 @@
8 8 public function __construct(){
9 9 $GLOBALS['ultp_settings'] = get_option('ultp_options');
10 10 }
11 11
12 + public function get_premium_link( $url = 'https://www.wpxpo.com/postx/' ) {
13 + $affiliate_id = apply_filters( 'ultp_affiliate_id', FALSE );
14 + $arg = array( 'utm_source' => 'go_premium' );
15 + if ( ! empty( $affiliate_id ) ) {
16 + $arg[ 'ref' ] = esc_attr( $affiliate_id );
17 + }
18 + return add_query_arg( $arg, $url );
19 + }
20 +
21 +
22 + // Get Size of the Image
23 + public function get_size($name = ''){
24 + global $_wp_additional_image_sizes;
25 + $image_size = $name ? ( isset($_wp_additional_image_sizes[$name]) ? $_wp_additional_image_sizes[$name] : array_values($_wp_additional_image_sizes)[0] ) : array_values($_wp_additional_image_sizes)[0];
26 +
27 + return ' width="'.$image_size['width'].'" height="'.$image_size['height'].'" ';
28 + }
29 +
30 + // Image Placeholder
31 + public function img_placeholder($type = 'small') {
32 + switch ($type) {
33 + case 'small':
34 + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABLAQMAAACr9CA9AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABZJREFUOI1jYMADmEe5o9xR7iiXQi4A4BsA388WUyMAAAAASUVORK5CYII=';
35 + break;
36 +
37 + case 'wide':
38 + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB9JREFUeNpi/P//P8NAAiaGAQajDhh1wKgDRh0AEGAAQTcDEcKDrpMAAAAASUVORK5CYII=';
39 + break;
40 +
41 + case 'square':
42 + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAApJREFUCJljYAAAAAIAAfRxZKYAAAAASUVORK5CYII=';
43 + break;
44 +
45 + case 'slider':
46 + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKYAAABkCAMAAAA7drv6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAAqSURBVHja7MEBDQAAAMKg909tDjegAAAAAAAAAAAAAAAAAAAAAH5NgAEAQTwAAWZtItYAAAAASUVORK5CYII=';
47 + break;
48 +
49 + default:
50 + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYYAAADcAQMAAABOLJSDAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAACJJREFUaIHtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAA4N8AKvgAAUFIrrEAAAAASUVORK5CYII=';
51 + break;
52 + }
53 + }
54 +
55 + // Quick Query
56 + public function get_quick_query($prams, $args) {
57 + switch ($prams['queryQuick']) {
58 + case 'sticky_posts':
59 + $args['post__in'] = get_option('sticky_posts');
60 + break;
61 + case 'latest_post_published':
62 + $args['orderby'] = 'date';
63 + $args['order'] = 'DESC';
64 + break;
65 + case 'latest_post_modified':
66 + $args['orderby'] = 'modified';
67 + $args['order'] = 'DESC';
68 + break;
69 + case 'oldest_post_published':
70 + $args['orderby'] = 'date';
71 + $args['order'] = 'ASC';
72 + break;
73 + case 'oldest_post_modified':
74 + $args['orderby'] = 'modified';
75 + $args['order'] = 'ASC';
76 + break;
77 + case 'alphabet_asc':
78 + $args['orderby'] = 'title';
79 + $args['order'] = 'ASC';
80 + break;
81 + case 'alphabet_desc':
82 + $args['orderby'] = 'title';
83 + $args['order'] = 'DESC';
84 + break;
85 + case 'random_post':
86 + $args['orderby'] = 'rand';
87 + $args['order'] = 'ASC';
88 + break;
89 + case 'random_post_7_days':
90 + $args['orderby'] = 'rand';
91 + $args['order'] = 'ASC';
92 + $args['date_query'] = array( array( 'after' => '1 week ago') );
93 + break;
94 + case 'random_post_30_days':
95 + $args['orderby'] = 'rand';
96 + $args['order'] = 'ASC';
97 + $args['date_query'] = array( array( 'after' => '1 month ago') );
98 + break;
99 + case 'most_comment':
100 + $args['orderby'] = 'comment_count';
101 + $args['order'] = 'DESC';
102 + break;
103 + case 'most_comment_1_day':
104 + $args['orderby'] = 'comment_count';
105 + $args['order'] = 'DESC';
106 + $args['date_query'] = array( array( 'after' => '1 day ago') );
107 + break;
108 + case 'most_comment_7_days':
109 + $args['orderby'] = 'comment_count';
110 + $args['order'] = 'DESC';
111 + $args['date_query'] = array( array( 'after' => '1 week ago') );
112 + break;
113 + case 'most_comment_30_days':
114 + $args['orderby'] = 'comment_count';
115 + $args['order'] = 'DESC';
116 + $args['date_query'] = array( array( 'after' => '1 month ago') );
117 + break;
118 + case 'popular_post_1_day_view':
119 + $args['meta_key'] = '__post_views_count';
120 + $args['orderby'] = 'meta_value meta_value_num';
121 + $args['order'] = 'DESC';
122 + $args['date_query'] = array( array( 'after' => '1 day ago') );
123 + break;
124 + case 'popular_post_7_days_view':
125 + $args['meta_key'] = '__post_views_count';
126 + $args['orderby'] = 'meta_value meta_value_num';
127 + $args['order'] = 'DESC';
128 + $args['date_query'] = array( array( 'after' => '1 week ago') );
129 + break;
130 + case 'popular_post_30_days_view':
131 + $args['meta_key'] = '__post_views_count';
132 + $args['orderby'] = 'meta_value meta_value_num';
133 + $args['order'] = 'DESC';
134 + $args['date_query'] = array( array( 'after' => '1 month ago') );
135 + break;
136 + case 'popular_post_all_times_view':
137 + $args['meta_key'] = '__post_views_count';
138 + $args['orderby'] = 'meta_value meta_value_num';
139 + $args['order'] = 'DESC';
140 + break;
141 + default:
142 + # code...
143 + break;
144 + }
145 + return $args;
146 + }
147 +
12 148 public function reusable_id($post_id){
13 149 $reusable_id = array();
14 150 if($post_id){
15 151 $post = get_post($post_id);
@@ -83,12 +219,12 @@
83 219
84 220 public function get_image_html($url = '', $size = 'full', $class = '', $alt = ''){
85 221 $alt = $alt ? ' alt="'.$alt.'" ' : '';
86 222 if( function_exists('ultimate_post_pro') ){
87 - $addon_enable = ultimate_post()->get_setting();
88 - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){
223 + $addon_enable = ultimate_post()->get_setting('addons_imageloading');
224 + if($addon_enable == 'true'){
89 225 $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" ';
90 - return '<img loading="lazy" loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.$url.'"/>';
226 + return '<img loading="lazy" loading="lazy" '.$class.$alt.' '.ultimate_post()->get_size($size).' src="'.ultimate_post()->img_placeholder($size).'" data-src="'.$url.'"/>';
91 227 }else{
92 228 $class = $class ? ' class="'.$class.'" ' : '';
93 229 return '<img loading="lazy" '.$class.$alt.' src="'.$url.'" />';
94 230 }
@@ -99,14 +235,15 @@
99 235 }
100 236
101 237 public function get_image($attach_id, $size = 'full', $class = '', $alt = ''){
102 238 $alt = $alt ? ' alt="'.$alt.'" ' : '';
239 + $size = ( ultimate_post()->get_setting('disable_image_size') == 'yes' && strpos($size, 'ultp_layout_') !== false ) ? 'full' : $size;
103 240 if( function_exists('ultimate_post_pro') ){
104 - $addon_enable = ultimate_post()->get_setting();
105 - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){
241 + $addon_enable = ultimate_post()->get_setting('addons_imageloading');
242 + if ($addon_enable == 'true') {
106 243 $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" ';
107 - return '<img loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.wp_get_attachment_image_url( $attach_id, $size ).'"/>';
108 - }else{
244 + return '<img loading="lazy" '.$class.$alt.' '.ultimate_post()->get_size($size).' src="'.ultimate_post()->img_placeholder($size).'" data-src="'.wp_get_attachment_image_url( $attach_id, $size ).'"/>';
245 + } else {
109 246 $class = $class ? ' class="'.$class.'" ' : '';
110 247 return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
111 248 }
112 249 } else {
@@ -124,8 +261,9 @@
124 261 'preloader_color' => '#1740f5',
125 262 'container_width' => '1140',
126 263 'editor_container' => 'full_width',
127 264 'hide_import_btn' => '',
265 + 'disable_image_size'=> '',
128 266 'ultp_templates' => 'true',
129 267 'ultp_elementor' => 'true'
130 268 );
131 269 if (empty($data)) {
@@ -174,13 +312,17 @@
174 312 $query_args['post__not_in'] = explode(',', $attr['queryExclude']);
175 313 }
176 314
177 315 if(isset($attr['queryTax'])){
178 - if(isset($attr['queryCat'])){
179 - if($attr['queryTax'] == 'category' && !empty($attr['queryCat'])){
316 + if(isset($attr['queryTaxValue'])){
317 +
318 + $tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : ($attr['queryTax'] == 'category' ? $attr['queryCat'] : $attr['queryTag']);
319 +
320 + if(strlen($tax_value) > 2){
180 321 $var = array('relation'=>'OR');
181 - foreach (json_decode($attr['queryCat']) as $val) {
182 - $var[] = array('taxonomy'=>'category', 'field' => 'slug', 'terms' => $val );
322 + foreach (json_decode($tax_value) as $val) {
323 + $tax_name = $attr['queryTax'] == 'tag' ? 'post_tag' : $attr['queryTax']; // for compatibility
324 + $var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val );
183 325 }
184 326 if(count($var) > 1){
185 327 $query_args['tax_query'] = $var;
186 328 }
@@ -185,24 +327,13 @@
185 327 $query_args['tax_query'] = $var;
186 328 }
187 329 }
188 330 }
189 - if(isset($attr['queryTag'])){
190 - if($attr['queryTax'] == 'post_tag' && !empty($attr['queryTag'])){
191 - $var = array('relation'=>'OR');
192 - foreach (json_decode($attr['queryTag']) as $val) {
193 - $var[] = array('taxonomy'=>'post_tag', 'field' => 'slug', 'terms' => $val );
194 - }
195 - $query_args['tax_query'] = $var;
196 - }
197 - }
198 331 }
199 332
200 333 if(isset($attr['queryQuick'])){
201 334 if($attr['queryQuick'] != ''){
202 - if(function_exists('ultimate_post_pro')){
203 - $query_args = ultimate_post_pro()->get_quick_query($attr, $query_args);
204 - }
335 + $query_args = ultimate_post()->get_quick_query($attr, $query_args);
205 336 }
206 337 }
207 338
208 339 if(isset($attr['queryOffset']) && $attr['queryOffset'] ){
@@ -255,9 +386,10 @@
255 386 // Pagination
256 387 public function pagination($pages = '', $paginationNav, $range = 1) {
257 388 $html = '';
258 389 $showitems = 3;
259 - $paged = get_query_var('paged') ? get_query_var('paged') : 1;
390 + $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
391 + $paged = $paged ? $paged : 1;
260 392 if($pages == '') {
261 393 global $wp_query;
262 394 $pages = $wp_query->max_num_pages;
263 395 if(!$pages) {
@@ -351,13 +483,9 @@
351 483 }
352 484
353 485 public function loading(){
354 486 $html = '';
355 - $style = 'style1';
356 - $option_data = ultimate_post()->get_setting();
357 - if( isset($option_data['preloader_style']) ){
358 - $style = $option_data['preloader_style'];
359 - }
487 + $style = ultimate_post()->get_setting('preloader_style');
360 488 if( $style == 'style2' ){
361 489 $html .= '<div class="ultp-loading-spinner" style="width:100%;height:100%"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>';//ultp-block-items-wrap
362 490 } else {
363 491 $html .= '<div class="ultp-loading-blocks" style="width:100%;height:100%;"><div style="left: 0;top: 0;animation-delay:0s;"></div><div style="left: 21px;top: 0;animation-delay:0.125s;"></div><div style="left: 42px;top: 0;animation-delay:0.25s;"></div><div style="left: 0;top: 21px;animation-delay:0.875s;"></div><div style="left: 42px;top: 21px;animation-delay:0.375s;"></div><div style="left: 0;top: 42px;animation-delay:0.75s;"></div><div style="left: 42px;top: 42px;animation-delay:0.625s;"></div><div style="left: 21px;top: 42px;animation-delay:0.5s;"></div></div>';
@@ -364,27 +492,23 @@
364 492 }
365 493 return '<div class="ultp-loading">'.$html.'</div>';
366 494 }
367 495
368 - public function filter($filterText = '', $filterType = '', $filterCat = '[]', $filterTag = '[]'){
496 + public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterCat = [], $filterTag = []){
369 497 $html = '';
370 498 $html .= '<ul class="ultp-flex-menu">';
371 - if ($filterType == 'category') {
372 - $cat = $this->taxonomy('category');
373 - if($filterText){
374 - $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>';
375 - }
376 - foreach (json_decode($filterCat) as $val) {
377 - $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>';
378 - }
379 - } else {
380 - $tag = $this->taxonomy('post_tag');
381 - if($filterText){
382 - $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>';
383 - }
384 - foreach (json_decode($filterTag) as $val) {
385 - $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($tag[$val]) ? $tag[$val] : $val).'</a></li>';
386 - }
499 +
500 + $filterType = $filterType == 'tag' ? 'post_tag' : $filterType; // for compatibility
501 +
502 + $cat = $this->taxonomy($filterType);
503 + if($filterText){
504 + $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>';
505 + }
506 +
507 + $filterValue = strlen($filterValue) > 2 ? $filterValue : ($filterType == 'category' ? $filterCat : $filterTag);
508 +
509 + foreach (json_decode($filterValue) as $val) {
510 + $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>';
387 511 }
388 512 $html .= '</ul>';
389 513 return $html;
390 514 }