PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.2
Post Grid Gutenberg Blocks – PostX v4.0.2
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
ultimate-post / classes / Initialization.php

Initialization.php in Post Grid Gutenberg Blocks – PostX 4.0.2, at classes/Initialization.php

1,139 lines 51.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Initialization Action.
4 *
5 * @package ULTP\Notice
6 * @since v.1.1.0
7 */
8 namespace ULTP;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Initialization class.
14 */
15 class ULTP_Initialization {
16
17 private $all_blocks;
18
19 /**
20 * Setup class.
21 *
22 * @since v.1.1.0
23 */
24 public function __construct() {
25
26 $this->compatibility_check();
27 $this->requires(); // Include Necessary Files
28 $this->blocks(); // Include Blocks
29 $this->include_addons(); // Include Addons
30
31 add_action( 'wp', array( $this, 'popular_posts_tracker_callback' ) );
32 add_filter( 'block_categories_all', array( $this, 'register_category_callback' ), 999999999, 2 ); // Block Category Register
33 add_action( 'after_setup_theme', array( $this, 'add_image_size' ) );
34
35 add_action( 'enqueue_block_editor_assets', array( $this, 'register_scripts_back_callback' ) ); // Only editor
36 add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts_option_panel_callback' ) ); // Option Panel
37 add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts_front_callback' ) ); // Both frontend
38 register_activation_hook( ULTP_PATH.'ultimate-post.php', array( $this, 'install_hook' ) );
39 add_action( 'activated_plugin', array( $this, 'activation_redirect' ) );
40
41 add_action( 'wp_ajax_ultp_next_prev', array( $this, 'ultp_next_prev_callback' )); // Next Previous AJAX Call
42 add_action( 'wp_ajax_nopriv_ultp_next_prev', array( $this, 'ultp_next_prev_callback' )); // Next Previous AJAX Call Logout User
43 add_action( 'wp_ajax_ultp_filter', array( $this, 'ultp_filter_callback' )); // Next Previous AJAX Call
44 add_action( 'wp_ajax_nopriv_ultp_filter', array( $this, 'ultp_filter_callback' )); // Next Previous AJAX Call Logout User
45 add_action( 'wp_ajax_ultp_pagination', array( $this, 'ultp_pagination_callback' )); // Page Number AJAX Call
46 add_action( 'wp_ajax_nopriv_ultp_pagination',array( $this, 'ultp_pagination_callback' )); // Page Number AJAX Call Logout User
47 add_action( 'wp_ajax_ultp_share_count', array( $this, 'ultp_shareCount_callback' )); // share Count save
48
49 add_action('admin_init', array($this, 'check_theme_compatibility'));
50 add_action( 'after_switch_theme', array($this, 'wpxpo_swithch_thememe'));
51
52 // add_action( 'in_plugin_update_message-'.ULTP_BASE, array( $this, 'in_plugin_settings_update_message' ) );
53
54 add_action( 'upgrader_process_complete', array($this, 'plugin_upgrade_completed'), 10, 2 );
55
56 // add_action( 'wp_ajax_ultp_getsearch_result', array($this, 'ultp_get_search_result')); // Search Result Showing
57
58 add_filter( 'admin_body_class', array( $this, 'add_admin_body_class' ) ); // add body class in editor
59 add_filter( 'body_class', array( $this, 'add_body_class') ); // add body class in front end
60
61 add_filter( 'wp_kses_allowed_html', [ $this, 'ultp_handle_allowed_html' ], 99, 2 ); // support for svg icon used in list, row, icon block
62 add_filter( 'safe_style_css', [ $this, 'ultp_handle_safe_style_css' ] ); // support for css used in svg icon
63 }
64
65 /**
66 * Add support for css to use svg
67 *
68 * @since 4.0.0
69 * @return styles
70 */
71 public function ultp_handle_safe_style_css( $styles ) {
72 if( !is_multisite() && !current_user_can('edit_posts') ) {
73 return $styles;
74 }
75 return array_merge( $styles, array(
76 'opacity',
77 // for SVG gradients.
78 // 'stop-opacity',
79 // 'stop-color',
80 ) );
81 }
82
83 /**
84 * Add support for html tag to use svg
85 *
86 * @since 4.0.0
87 * @return supported_tags
88 */
89 public function ultp_handle_allowed_html ($tags, $context) {
90 if ( 'post' !== $context && !is_multisite() && !current_user_can('edit_posts') ) {
91 return $tags;
92 }
93 if ( ! isset( $tags['svg'] ) ) {
94 $tags['svg'] = array_merge(
95 [
96 'xmlns' => true,
97 // 'xmlns:xlink' => true,
98 // 'xlink:href' => true,
99 // 'xml:id' => true,
100 // 'xlink:title' => true,
101 // 'xml:space' => true,
102 'viewbox' => true,
103 'enable-background' => true,
104 'version' => true,
105 'preserveaspectratio' => true,
106 'fill' => true,
107 ]
108 );
109 }
110 if ( ! isset( $tags['path'] ) ) {
111 $tags['path'] = [
112 'd' => true,
113 'stroke' => true,
114 'stroke-miterlimit' => true,
115 'data-original' => true,
116 'class' => true,
117 'transform' => true,
118 'style' => true,
119 'opacity' => true,
120 'fill' => true
121 ];
122 }
123 if ( ! isset( $tags['g'] ) ) {
124 $tags['g'] = [
125 'transform' => true,
126 'clip-path' => true,
127 ];
128 }
129 if ( ! isset( $tags['clippath'] ) ) {
130 $tags['clippath'] = [];
131 }
132 if ( ! isset( $tags['defs'] ) ) {
133 $tags['defs'] = [
134 ];
135 }
136 if ( ! isset( $tags['rect'] ) ) {
137 $tags['rect'] = [
138 'rx' => true,
139 'height' => true,
140 'width' => true,
141 'transform' => true,
142 'x' => true,
143 'fill' => true,
144 ];
145 }
146 if ( ! isset( $tags['circle'] ) ) {
147 $tags['circle'] = [
148 'cx' => true,
149 'cy' => true,
150 'transform' => true,
151 'r' => true,
152 ];
153 }
154 if ( ! isset( $tags['polygon'] ) ) {
155 $tags['polygon'] = [
156 'points' => true,
157 ];
158 }
159 if ( ! isset( $tags['lineargradient'] ) ) {
160 $tags['lineargradient'] = [
161 'gradienttransform' => true,
162 'id' => true,
163 ];
164 }
165 if ( ! isset( $tags['stop'] ) ) {
166 $tags['stop'] = [
167 'offset' => true,
168 'stop-color' => true,
169 'style' => true,
170 'stop-opacity' => true,
171 ];
172 }
173 return $tags;
174 }
175
176 /**
177 * Add Admin Body_class
178 *
179 * @since v.3.1.6
180 * @return NULL
181 */
182 public function add_admin_body_class ($classes) {
183 $classes .= " postx-admin-page ";
184 return $classes;
185 }
186 /**
187 * Theme Switch Callback
188 *
189 * @since v.3.1.6
190 * @return NULL
191 */
192 public function add_body_class ($classes) {
193 $classes[] = "postx-page";
194 return $classes;
195 }
196
197 /**
198 * Theme Switch Callback
199 *
200 * @since v.1.1.0
201 * @return NULL
202 */
203 public function wpxpo_swithch_thememe () {
204 $this->check_theme_compatibility();
205 }
206
207
208 /**
209 * Theme Compatibility Action
210 *
211 * @since v.1.1.0
212 * @return NULL
213 */
214 public function check_theme_compatibility() {
215 $licence = apply_filters( 'ultp_theme_integration' , FALSE );
216 $theme = get_transient( 'ulpt_theme_enable' );
217
218 if ( $licence ) {
219 if ( $theme != 'integration' ) {
220 $themes = wp_get_theme();
221 $api_params = array(
222 'wpxpo_theme_action' => 'theme_license',
223 'slug' => $themes->get('TextDomain'),
224 'author' => $themes->get('Author'),
225 'item_id' => 181,
226 'url' => home_url()
227 );
228
229 $response = wp_remote_post( 'https://www.wpxpo.com', array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
230
231 if ( !is_wp_error( $response ) || 200 === wp_remote_retrieve_response_code( $response ) ) {
232 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
233 if ( isset($license_data->license) ) {
234 if ( $license_data->license == 'valid' ) {
235 set_transient( 'ulpt_theme_enable', 'integration', 2592000 ); // 30 days time
236 }
237 }
238 }
239 }
240 } else {
241 if ( $theme == 'integration' ) {
242 delete_transient( 'ulpt_theme_enable' );
243 }
244 }
245 }
246
247
248 /**
249 * Check Compatibility
250 *
251 * @since v.1.0.0
252 * @return NULL
253 */
254 public function compatibility_check() {
255 require_once ULTP_PATH.'classes/Compatibility.php';
256 new \ULTP\Compatibility();
257 }
258
259
260 /**
261 * Option Panel CSS and JS Scripts
262 *
263 * @since v.1.0.0
264 * @return NULL
265 */
266 public function register_scripts_option_panel_callback() {
267 $is_active = ultimate_post()->is_lc_active();
268 $license_key = get_option( 'edd_ultp_license_key' );
269 $_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; // @codingStandardsIgnoreLine
270
271 // Custom Font Support Added
272 $font_settings = ultimate_post()->get_setting( 'ultp_custom_font' );
273 $custom_fonts = array();
274 if ( $font_settings == 'true' ) {
275 wp_enqueue_media();
276 $args = array(
277 'post_type' => 'ultp_custom_font',
278 'post_status' => 'publish',
279 'numberposts' => 333,
280 'order' => 'ASC'
281 );
282 $posts = get_posts( $args );
283 if ( $posts ) {
284 foreach( $posts as $post ) {
285 setup_postdata( $post );
286 $font = get_post_meta($post->ID , '__font_settings', true);
287
288 if ( $font ) {
289 array_push( $custom_fonts, array(
290 'title' => $post->post_title,
291 'font' => $font
292 ));
293 }
294 }
295 wp_reset_postdata();
296 }
297 }
298
299 wp_enqueue_style( 'wp-color-picker' );
300 wp_enqueue_script( 'wp-color-picker' );
301 wp_enqueue_script( 'ultp-option-script', ULTP_URL.'assets/js/ultp-option.js', array('jquery'), ULTP_VER, true );
302 wp_enqueue_style( 'ultp-option-style', ULTP_URL.'assets/css/ultp-option.css', array(), ULTP_VER );
303
304 wp_localize_script( 'ultp-option-script', 'ultp_option_panel', array(
305 'url' => ULTP_URL,
306 'active' => $is_active,
307 'security' => wp_create_nonce('ultp-nonce'),
308 'ajax' => admin_url('admin-ajax.php'),
309 'license' => $license_key,
310 'settings' => ultimate_post()->get_setting(),
311 'addons' => ultimate_post()->all_addons(),
312 'premium_link' => ultimate_post()->get_premium_link(),
313 'affiliate_id' => apply_filters( 'ultp_affiliate_id', false ),
314 'custom_fonts' => $custom_fonts,
315 'addons_settings' => apply_filters('ultp_settings', []),
316 'post_type' => get_post_type(),
317 'saved_template_url' => admin_url('admin.php?page=ultp-settings#saved-templates'),
318 ));
319
320 /* === Installation Wizard === */
321 if ( $_page == 'ultp-initial-setup-wizard' ) {
322 wp_enqueue_script( 'ultp-initial-setup-script', ULTP_URL.'assets/js/ultp_initial_setup_min.js', array('wp-i18n', 'wp-api-fetch', 'wp-api-request'), ULTP_VER, true );
323 wp_set_script_translations( 'ultp-initial-setup-script', 'ultimate-post', ULTP_PATH . 'languages/' );
324 }
325
326 /* === Builder And Setting Pannel === */
327 if ( get_post_type(get_the_ID()) == 'ultp_builder' ) {
328 wp_enqueue_script( 'ultp-conditions-script', ULTP_URL.'addons/builder/assets/js/conditions.js', array('wp-i18n', 'wp-api-fetch','wp-components','wp-i18n','wp-blocks'), ULTP_VER, true );
329 wp_localize_script( 'ultp-conditions-script', 'ultp_condition', array(
330 'url' => ULTP_URL,
331 'active' => $is_active,
332 'premium_link' => ultimate_post()->get_premium_link(),
333 'license' => $license_key,
334 'builder_url' => admin_url('admin.php?page=ultp-settings#builder'),
335 'affiliate_id' => apply_filters( 'ultp_affiliate_id', FALSE )
336 ) );
337 wp_set_script_translations( 'ultp-conditions-script', 'ultimate-post', ULTP_PATH . 'languages/' );
338 }
339
340 /* === Dashboard === */
341 $_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
342 if ($_page == 'ultp-settings') {
343 wp_enqueue_script('ultp-dashboard-script', ULTP_URL.'assets/js/ultp_dashboard_min.js', array('wp-i18n', 'wp-api-fetch', 'wp-api-request', 'wp-components','wp-blocks'), ULTP_VER, true);
344 wp_localize_script('ultp-dashboard-script', 'ultp_dashboard_pannel', array(
345 'ajax' => admin_url('admin-ajax.php'),
346 'security' => wp_create_nonce('ultp-nonce'),
347 'url' => ULTP_URL,
348 'active' => $is_active,
349 'license' => $license_key,
350 'settings' => ultimate_post()->get_setting(),
351 'addons' => ultimate_post()->all_addons(),
352 'addons_settings' => apply_filters('ultp_settings', []),
353 'premium_link' => ultimate_post()->get_premium_link(),
354 'builder_url' => admin_url('admin.php?page=ultp-settings#builder'),
355 'affiliate_id' => apply_filters( 'ultp_affiliate_id', false ),
356 'version' => ULTP_VER,
357 'setup_wizard_link' => admin_url('admin.php?page=ultp-initial-setup-wizard'),
358 'helloBar' => get_transient('ultp_helloBar'.ULTP_HELLOBAR),
359 'status' => get_option( 'edd_ultp_license_status' ),
360 'expire' => get_option( 'edd_ultp_license_expire' ),
361 'is_free' => !ultimate_post()->is_lc_active(),
362 'is_pro' => (ultimate_post()->is_lc_active() && get_option('edd_ultp_license_expire') != 'lifetime'),
363 'user_email' => wp_get_current_user()->user_email,
364 'home_url' => home_url(),
365 'generalDiscount' => get_transient('ultp_generalDiscount'),
366 ) );
367 wp_set_script_translations( 'ultp-dashboard-script', 'ultimate-post', ULTP_PATH . 'languages/' );
368 }
369
370 }
371
372
373 /**
374 * Only Frontend CSS and JS Scripts
375 *
376 * @since v.1.0.0
377 * @return NULL
378 */
379 public function register_scripts_front_callback() {
380 $call_common = false;
381 if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { // @codingStandardsIgnoreLine
382 $call_common = true;
383 ultimate_post()->register_scripts_common();
384 } else if ( 'yes' == get_post_meta(ultimate_post()->get_ID(), '_ultp_active', true) ) {
385 $call_common = true;
386 ultimate_post()->register_scripts_common();
387 } else if ( ultimate_post()->is_builder() ) {
388 $call_common = true;
389 ultimate_post()->register_scripts_common();
390 } else if ( apply_filters('postx_common_script', false) ) {
391 $call_common = true;
392 ultimate_post()->register_scripts_common();
393 } else if ( isset($_GET['et_fb']) ) { // @codingStandardsIgnoreLine
394 $call_common = true;
395 ultimate_post()->register_scripts_common();
396 }
397
398 // For WidgetWidget
399 $has_block = false;
400 $widget_blocks = array();
401 global $wp_registered_sidebars, $sidebars_widgets;
402 foreach ( $wp_registered_sidebars as $key => $value ) {
403 if ( is_active_sidebar($key) ) {
404 foreach ( $sidebars_widgets[$key] as $val ) {
405 if ( strpos($val, 'block-') !== false ) {
406 if ( empty($widget_blocks) ) {
407 $widget_blocks = get_option( 'widget_block' );
408 }
409 foreach ( (array) $widget_blocks as $block ) {
410 if ( isset( $block['content'] ) && strpos($block['content'], 'wp:ultimate-post') !== false ) {
411 $has_block = true;
412 break;
413 }
414 }
415 if ( $has_block ) {
416 break;
417 }
418 }
419 }
420 }
421 }
422 if ( $has_block ) {
423 if ( !$call_common ) {
424 ultimate_post()->register_scripts_common();
425 }
426 $css = get_option('ultp-widget', true);
427 if ( $css ) {
428 wp_register_style( 'ultp-post-widget', false );
429 wp_enqueue_style( 'ultp-post-widget' );
430 wp_add_inline_style( 'ultp-post-widget', $css);
431 }
432 }
433 }
434
435
436 /**
437 * Only Backend CSS and JS Scripts
438 *
439 * @since v.1.0.0
440 * @return NULL
441 */
442 public function register_scripts_back_callback() {
443 ultimate_post()->register_scripts_common();
444 global $pagenow;
445 $depends = 'wp-editor';
446 if ( $pagenow === 'widgets.php' ) {
447 $depends = 'wp-edit-widgets';
448 }
449 wp_enqueue_script( 'ultp-blocks-editor-script', ULTP_URL.'assets/js/editor.blocks.js', array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', $depends ), ULTP_VER, true );
450 wp_enqueue_style( 'ultp-blocks-editor-css', ULTP_URL.'assets/css/blocks.editor.css', array(), ULTP_VER );
451 if ( is_rtl() ) {
452 wp_enqueue_style( 'ultp-blocks-editor-rtl-css', ULTP_URL.'assets/css/rtl.css', array(), ULTP_VER );
453 }
454 $is_active = ultimate_post()->is_lc_active();
455 $post_type = get_post_type();
456 wp_localize_script( 'ultp-blocks-editor-script', 'ultp_data', array(
457 'url' => ULTP_URL,
458 'ajax' => admin_url('admin-ajax.php'),
459 'security' => wp_create_nonce('ultp-nonce'),
460 'hide_import_btn' => ultimate_post()->get_setting('hide_import_btn'),
461 'upload' => wp_upload_dir()['basedir'] . '/ultp',
462 'premium_link' => ultimate_post()->get_premium_link(),
463 'license' => $is_active ? get_option('edd_ultp_license_key') : '',
464 'active' => $is_active,
465 'archive' => ultimate_post()->is_archive_builder(),
466 'settings' => ultimate_post()->get_setting(),
467 'post_type' => $post_type == 'premade' ? 'ultp_builder' : $post_type, // premade used for ultp.wpxpo.com
468 'date_format' => get_option('date_format'),
469 'time_format' => get_option('time_format'),
470 'blog' => get_current_blog_id(),
471 'archive_child' => ultimate_post()->is_archive_child_builder(),
472 'affiliate_id' => apply_filters( 'ultp_affiliate_id', FALSE ),
473 'category_url' =>admin_url( 'edit-tags.php?taxonomy=category' ),
474 'disable_image_size' => ultimate_post()->get_setting('disable_image_size'),
475 'dark_logo' => get_option('ultp_site_dark_logo') ? get_option('ultp_site_dark_logo') : false,
476 'builder_url' => admin_url('admin.php?page=ultp-settings#builder')
477 ));
478 wp_set_script_translations( 'ultp-blocks-editor-script', 'ultimate-post', ULTP_PATH . 'languages/' );
479 }
480
481
482 /**
483 * Fire When Plugin First Install
484 *
485 * @since v.1.0.0
486 * @return NULL
487 */
488 public function install_hook() {
489 $data = get_option( 'ultp_options', array() );
490 if ( empty( $data ) ) {
491 $init_data = array(
492 'css_save_as' => 'wp_head',
493 'preloader_style' => 'style1',
494 'preloader_color' => '#037fff',
495 'container_width' => '1140',
496 'hide_import_btn' => '',
497 'disable_image_size'=> '',
498 'disable_view_cookies' => '',
499 'disable_google_font' => '',
500 'ultp_templates' => 'true',
501 'ultp_elementor' => 'true',
502 'ultp_table_of_content'=> 'true',
503 'ultp_builder' => 'true',
504 'ultp_custom_font' => 'true',
505 'ultp_chatgpt' => 'true',
506 'post_grid_1' => 'yes',
507 'post_grid_2' => 'yes',
508 'post_grid_3' => 'yes',
509 'post_grid_4' => 'yes',
510 'post_grid_5' => 'yes',
511 'post_grid_6' => 'yes',
512 'post_grid_7' => 'yes',
513 'post_list_1' => 'yes',
514 'post_list_2' => 'yes',
515 'post_list_3' => 'yes',
516 'post_list_4' => 'yes',
517 'post_module_1' => 'yes',
518 'post_module_2' => 'yes',
519 'post_slider_1' => 'yes',
520 'post_slider_2' => 'yes',
521 'heading' => 'yes',
522 'image' => 'yes',
523 'taxonomy' => 'yes',
524 'wrapper' => 'yes',
525 'news_ticker' => 'yes',
526 'builder_advance_post_meta' => 'yes',
527 'builder_archive_title' => 'yes',
528 'builder_author_box' => 'yes',
529 'builder_post_next_previous'=> 'yes',
530 'builder_post_author_meta' => 'yes',
531 'builder_post_breadcrumb' => 'yes',
532 'builder_post_category' => 'yes',
533 'builder_post_comment_count'=> 'yes',
534 'builder_post_comments' => 'yes',
535 'builder_post_content' => 'yes',
536 'builder_post_date_meta' => 'yes',
537 'builder_post_excerpt' => 'yes',
538 'builder_post_featured_image'=> 'yes',
539 'builder_post_reading_time' => 'yes',
540 'builder_post_social_share' => 'yes',
541 'builder_post_tag' => 'yes',
542 'builder_post_title' => 'yes',
543 'builder_post_view_count' => 'yes',
544 'save_version' => wp_rand(1, 1000)
545 );
546 if ( empty( $data ) ) {
547 update_option( 'ultp_options', $init_data );
548 $GLOBALS['ultp_settings'] = $init_data;
549 } else {
550 foreach ( $init_data as $key => $single ) {
551 if ( ! isset( $data[$key] ) ) {
552 $data[$key] = $single;
553 }
554 }
555 update_option( 'ultp_options', $data );
556 $GLOBALS['ultp_settings'] = $data;
557 }
558 }
559 if (!get_transient( 'wpxpo_installation_date' )) {
560 set_transient( 'wpxpo_installation_date', 'yes', 5 * DAY_IN_SECONDS ); // 5 Days Notice
561 }
562 }
563
564
565 /**
566 * Redirect After Active Plugin
567 *
568 * @since v.1.0.0
569 * @param STRING | Plugin Path
570 * @return NULL
571 */
572 public function activation_redirect($plugin) {
573 if ( wp_doing_ajax() ) {
574 return;
575 }
576
577 if ( $plugin == 'ultimate-post/ultimate-post.php' ) {
578 if ( ultimate_post()->get_setting('init_setup') != 'yes' ) {
579 exit(wp_safe_redirect(admin_url('admin.php?page=ultp-initial-setup-wizard'))); //phpcs:ignore
580 } else {
581 exit(wp_safe_redirect(admin_url('admin.php?page=ultp-settings#home'))); //phpcs:ignore
582 }
583 }
584 }
585
586
587 /**
588 * Require Blocks
589 *
590 * @since v.1.0.0
591 * @return NULL
592 */
593 public function blocks() {
594 global $unique_ID;
595 $setting = ultimate_post()->get_setting();
596 require_once ULTP_PATH.'blocks/Post_List_1.php';
597 require_once ULTP_PATH.'blocks/Post_List_2.php';
598 require_once ULTP_PATH.'blocks/Post_List_3.php';
599 require_once ULTP_PATH.'blocks/Post_List_4.php';
600 require_once ULTP_PATH.'blocks/Post_Grid_1.php';
601 require_once ULTP_PATH.'blocks/Post_Grid_2.php';
602 require_once ULTP_PATH.'blocks/Post_Grid_3.php';
603 require_once ULTP_PATH.'blocks/Post_Grid_4.php';
604 require_once ULTP_PATH.'blocks/Post_Grid_5.php';
605 require_once ULTP_PATH.'blocks/Post_Grid_6.php';
606 require_once ULTP_PATH.'blocks/Post_Grid_7.php';
607 require_once ULTP_PATH.'blocks/Post_Slider_1.php';
608 require_once ULTP_PATH.'blocks/Post_Slider_2.php';
609 require_once ULTP_PATH.'blocks/Post_Module_1.php';
610 require_once ULTP_PATH.'blocks/Post_Module_2.php';
611 require_once ULTP_PATH.'blocks/Heading.php';
612 require_once ULTP_PATH.'blocks/Image.php';
613 require_once ULTP_PATH.'blocks/Taxonomy.php';
614 require_once ULTP_PATH.'blocks/News_Ticker.php';
615 require_once ULTP_PATH.'blocks/Advanced_Search.php';
616 require_once ULTP_PATH.'blocks/Dark_Light.php';
617
618 $this->all_blocks['ultimate-post_post-list-1'] = new \ULTP\blocks\Post_List_1();
619 $this->all_blocks['ultimate-post_post-list-2'] = new \ULTP\blocks\Post_List_2();
620 $this->all_blocks['ultimate-post_post-list-3'] = new \ULTP\blocks\Post_List_3();
621 $this->all_blocks['ultimate-post_post-list-4'] = new \ULTP\blocks\Post_List_4();
622 $this->all_blocks['ultimate-post_post-grid-1'] = new \ULTP\blocks\Post_Grid_1();
623 $this->all_blocks['ultimate-post_post-grid-2'] = new \ULTP\blocks\Post_Grid_2();
624 $this->all_blocks['ultimate-post_post-grid-3'] = new \ULTP\blocks\Post_Grid_3();
625 $this->all_blocks['ultimate-post_post-grid-4'] = new \ULTP\blocks\Post_Grid_4();
626 $this->all_blocks['ultimate-post_post-grid-5'] = new \ULTP\blocks\Post_Grid_5();
627 $this->all_blocks['ultimate-post_post-grid-6'] = new \ULTP\blocks\Post_Grid_6();
628 $this->all_blocks['ultimate-post_post-grid-7'] = new \ULTP\blocks\Post_Grid_7();
629 $this->all_blocks['ultimate-post_post-slider-1'] = new \ULTP\blocks\Post_Slider_1();
630 $this->all_blocks['ultimate-post_post-slider-2'] = new \ULTP\blocks\Post_Slider_2();
631 $this->all_blocks['ultimate-post_post-module-1'] = new \ULTP\blocks\Post_Module_1();
632 $this->all_blocks['ultimate-post_post-module-2'] = new \ULTP\blocks\Post_Module_2();
633 $this->all_blocks['ultimate-post_heading'] = new \ULTP\blocks\Heading();
634 $this->all_blocks['ultimate-post_image'] = new \ULTP\blocks\Image();
635 $this->all_blocks['ultimate-post_ultp-taxonomy'] = new \ULTP\blocks\Taxonomy();
636 $this->all_blocks['ultimate-post_news-ticker'] = new \ULTP\blocks\News_Ticker();
637 $this->all_blocks['ultimate-post_news-ticker'] = new \ULTP\blocks\Advanced_Search();
638 $this->all_blocks['ultimate-post_dark-light'] = new \ULTP\blocks\Dark_Light();
639
640 if ( ultimate_post()->get_setting('ultp_builder') == 'true' ) {
641 require_once ULTP_PATH.'addons/builder/blocks/Archive_Title.php';
642 require_once ULTP_PATH.'addons/builder/blocks/Post_Title.php';
643 require_once ULTP_PATH.'addons/builder/blocks/Post_Content.php';
644 require_once ULTP_PATH.'addons/builder/blocks/Post_Featured_Image.php';
645 require_once ULTP_PATH.'addons/builder/blocks/Post_Breadcrumb.php';
646 require_once ULTP_PATH.'addons/builder/blocks/Post_Tag.php';
647 require_once ULTP_PATH.'addons/builder/blocks/Post_Category.php';
648 require_once ULTP_PATH.'addons/builder/blocks/Next_Previous.php';
649 require_once ULTP_PATH.'addons/builder/blocks/Post_Excerpt.php';
650 require_once ULTP_PATH.'addons/builder/blocks/Author_Box.php';
651 require_once ULTP_PATH.'addons/builder/blocks/Post_Comments.php';
652 require_once ULTP_PATH.'addons/builder/blocks/Post_View_Count.php';
653 require_once ULTP_PATH.'addons/builder/blocks/Post_Reading_Time.php';
654 require_once ULTP_PATH.'addons/builder/blocks/Post_Comment_Count.php';
655 require_once ULTP_PATH.'addons/builder/blocks/Post_Author_Meta.php';
656 require_once ULTP_PATH.'addons/builder/blocks/Post_Date_Meta.php';
657 require_once ULTP_PATH.'addons/builder/blocks/Post_Social_Share.php';
658 require_once ULTP_PATH.'addons/builder/blocks/Advance_Post_Meta.php';
659
660 new \ULTP\blocks\Archive_Title();
661 new \ULTP\blocks\Post_Title();
662 new \ULTP\blocks\Post_Content();
663 new \ULTP\blocks\Post_Featured_Image();
664 new \ULTP\blocks\Post_Breadcrumb();
665 new \ULTP\blocks\Post_Tag();
666 new \ULTP\blocks\Post_Category();
667 new \ULTP\blocks\Next_Previous();
668 new \ULTP\blocks\Post_Excerpt();
669 new \ULTP\blocks\Author_Box();
670 new \ULTP\blocks\Post_Comments();
671 new \ULTP\blocks\Post_View_Count();
672 new \ULTP\blocks\Post_Reading_Time();
673 new \ULTP\blocks\Post_Comment_Count();
674 new \ULTP\blocks\Post_Author_Meta();
675 new \ULTP\blocks\Post_Date_Meta();
676 new \ULTP\blocks\Post_Social_Share();
677 new \ULTP\blocks\Advance_Post_Meta();
678 }
679 }
680
681
682 /**
683 * Necessary Requires Class
684 *
685 * @since v.1.0.0
686 * @return NULL
687 */
688 public function requires() {
689 require_once ULTP_PATH.'classes/Notice.php';
690 require_once ULTP_PATH.'classes/Styles.php';
691 require_once ULTP_PATH.'classes/Options.php';
692 require_once ULTP_PATH.'classes/REST_API.php';
693 require_once ULTP_PATH.'classes/Caches.php';
694 require_once ULTP_PATH.'classes/Importer.php';
695 new \ULTP\REST_API();
696 new \ULTP\Options();
697 new \ULTP\Caches();
698 new \ULTP\Styles();
699 new \ULTP\Notice();
700 new \ULTP\Importer();
701
702 require_once ULTP_PATH.'classes/Deactive.php';
703 new \ULTP\Deactive();
704 }
705
706
707 /**
708 * Block Categories Initialization
709 *
710 * @since v.1.0.0
711 * @param $categories(ARRAY) | $post (ARRAY)
712 * @return NULL
713 */
714 public function register_category_callback( $categories, $post ) {
715 $attr = array(
716 array(
717 'slug' => 'ultimate-post',
718 'title' => __('PostX - Gutenberg Post Blocks', 'ultimate-post')
719 ),
720 array(
721 'slug' => 'postx-site-builder',
722 'title' => __('PostX Site Builder', 'ultimate-post')
723 )
724 );
725 return array_merge($attr, $categories);
726 }
727
728
729 /**
730 * Post View Counter for Every Post
731 *
732 * @since v.1.0.0
733 * @param NUMBER | Post ID
734 * @return NULL
735 */
736 public function popular_posts_tracker_callback($post_id) {
737 if ( !is_single() ) { return; }
738 global $post;
739 $post_id = isset($post->ID) ? $post->ID : '';
740 $isEnable = apply_filters('ultp_view_cookies', true);
741 // add_filter( 'ultp_view_cookies', '__return_false' );
742 $cookies_disable = ultimate_post()->get_setting('disable_view_cookies');
743 if ( $post_id && $isEnable && $cookies_disable != 'yes' ) {
744 $has_cookie = isset( $_COOKIE['ultp_view_'.$post_id] ) ? sanitize_text_field($_COOKIE['ultp_view_'.$post_id]) : false;
745 if ( !$has_cookie ) {
746 $count = (int)get_post_meta( $post_id, '__post_views_count', true );
747 update_post_meta($post_id, '__post_views_count', $count ? (int)$count + 1 : 1 );
748 setcookie( 'ultp_view_'.$post_id, 1, time() + 86400, COOKIEPATH ); // 1 days cookies
749 }
750 }
751 }
752
753
754 /**
755 * Set Image Size
756 *
757 * @since v.1.0.0
758 * @return NULL
759 */
760 public function add_image_size() {
761 $size_disable = ultimate_post()->get_setting('disable_image_size');
762 if ( $size_disable != 'yes' ) {
763 add_image_size( 'ultp_layout_landscape_large', 1200, 800, true );
764 add_image_size( 'ultp_layout_landscape', 870, 570, true );
765 add_image_size( 'ultp_layout_portrait', 600, 900, true );
766 add_image_size( 'ultp_layout_square', 600, 600, true );
767 }
768 }
769
770
771 /**
772 * Include Addons Directory
773 *
774 * @since v.1.0.0
775 * @return NULL
776 */
777 public function include_addons() {
778 $addons_dir = array_filter(glob(ULTP_PATH.'addons/*'), 'is_dir');
779 if ( count($addons_dir) > 0 ) {
780 foreach( $addons_dir as $key => $value ) {
781 $addon_dir_name = str_replace(dirname($value).'/', '', $value);
782 $file_name = ULTP_PATH . 'addons/'.$addon_dir_name.'/init.php';
783 if ( file_exists($file_name) ) {
784 include_once $file_name;
785 }
786 }
787 }
788 }
789
790
791 /**
792 * Next Preview Callback of the Blocks
793 *
794 * @since v.1.0.0
795 * @return STRING
796 */
797 public function ultp_next_prev_callback() {
798 if ( ! (isset($_REQUEST['wpnonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_REQUEST['wpnonce'])), 'ultp-nonce')) ) {
799 return ;
800 }
801
802 $paged = isset($_POST['paged'])?sanitize_text_field($_POST['paged']):'';
803 $blockId = isset($_POST['blockId'])? sanitize_text_field($_POST['blockId']):'';
804 $postId = isset($_POST['postId'])? sanitize_text_field($_POST['postId']):'';
805 $blockRaw = isset($_POST['blockName'])? sanitize_text_field($_POST['blockName']):'';
806 $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
807 $blockName = str_replace('_','/', $blockRaw);
808 $widgetBlockId = isset($_POST['widgetBlockId'])?sanitize_text_field($_POST['widgetBlockId']):'';
809 $filterValue = isset($_POST['filterValue'])?sanitize_text_field($_POST['filterValue']):'';
810 $filterType = isset($_POST['filterType'])?sanitize_text_field($_POST['filterType']):'';
811 $exclude_post_id = isset($_POST['exclude']) ? sanitize_text_field($_POST['exclude']) : '';
812
813 $ultp_uniqueIds = isset($_POST['ultpUniqueIds']) ? json_decode(stripslashes(sanitize_text_field($_POST['ultpUniqueIds'])), true) : [];
814 $ultp_current_unique_posts = isset($_POST['ultpCurrentUniquePosts']) ? json_decode(stripslashes(sanitize_text_field($_POST['ultpCurrentUniquePosts'])), true) : [];
815
816 if( $widgetBlockId ) {
817 $blocks = parse_blocks(get_option('widget_block')[$widgetBlockId]['content']);
818 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, '', $filterValue, $filterType, $ultp_uniqueIds, $ultp_current_unique_posts, $widgetBlockId, '');
819 }elseif ($paged && $blockId && $postId && $blockName ) {
820 $post = get_post($postId);
821 if( has_blocks($post->post_content) ) {
822 $blocks = parse_blocks($post->post_content);
823 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId, $filterValue, $filterType, $ultp_uniqueIds, $ultp_current_unique_posts, '', $exclude_post_id);
824 }
825 }
826 }
827
828 /**
829 * Pagination for filter cal'back
830 *
831 * @since v.2.8.9
832 * @return STRING
833 */
834 public function pagination_for_filter( $attr, $postId, $blockRaw, $filter_attributes ) {
835 $attr['queryNumber'] = ultimate_post()->get_post_number(4, $attr['queryNumber'], $attr['queryNumPosts']);
836 $recent_posts = new \WP_Query( ultimate_post()->get_query( $attr ) );
837 $pageNum = ultimate_post()->get_page_number($attr, $recent_posts->found_posts);
838
839 $data_filter_value = 'data-filter-value=" ' . $filter_attributes['queryTaxValue']. '"';
840 $data_filter_type = 'data-filter-type=" ' . $filter_attributes['queryTax']. '"';
841 $wraper_after = '';
842 $style = $pageNum == 1 ? 'style="display:none"' : '';
843
844 if( $attr['paginationType'] == 'loadMore' ) {
845 $wraper_after .= '<div '.$style.' class="ultp-loadmore "'. $data_filter_value . $data_filter_type .'>';
846 $wraper_after .= '<span class="ultp-loadmore-action" tabindex="0" role="button" data-pages="'.$pageNum.'" data-pagenum="1" data-blockid="'.$attr['blockId'].'" data-blockname="'.$blockRaw.'" data-postid="'.$postId.'" '.ultimate_post()->get_builder_attr($attr['queryType']).'>'.( isset($attr['loadMoreText']) ? $attr['loadMoreText'] : 'Load More' ).' <span class="ultp-spin">'.ultimate_post()->svg_icon('refresh').'</span></span>';
847 $wraper_after .= '</div>';
848 }
849 else if( $attr['paginationType'] == 'navigation' ) {
850 $wraper_after .= '<div '.$style.' class="ultp-next-prev-wrap" data-pages="'.$pageNum.'" data-pagenum="1" data-blockid="'.$attr['blockId'].'" data-blockname="'.$blockRaw.'" data-postid="'.$postId.'" '.ultimate_post()->get_builder_attr($attr['queryType']). $data_filter_value . $data_filter_type .'>';
851 $wraper_after .= ultimate_post()->next_prev();
852 $wraper_after .= '</div>';
853 }
854 else if( $attr['paginationType'] == 'pagination' ) {
855 $wraper_after .= '<div class="ultp-pagination-wrap'.($attr["paginationAjax"] ? " ultp-pagination-ajax-action" : "").'" data-paged="1" data-blockid="'.$attr['blockId'].'" data-postid="'.$postId.'" data-pages="'.$pageNum.'" data-blockname="'.$blockRaw.'" '.ultimate_post()->get_builder_attr($attr['queryType']). $data_filter_value . $data_filter_type .'>';
856 $wraper_after .= ultimate_post()->pagination($pageNum, $attr['paginationNav'], $attr['paginationText'], $attr["paginationAjax"], isset($_SERVER['HTTP_REFERER'])?esc_url_raw($_SERVER['HTTP_REFERER']):'');
857 $wraper_after .= '</div>';
858 }
859 wp_reset_query();
860
861 return $wraper_after;
862 }
863
864 /**
865 * Filter Callback of the Blocks
866 *
867 * @since v.1.0.0
868 * @return STRING
869 */
870 public function filter_block_return( $blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, &$toReturn, $widgetBlockId='' ) {
871 foreach ( $blocks as $key => $value ) {
872 if ( $blockName == $value['blockName'] ) {
873 if ( $value['attrs']['blockId'] == $blockId ) {
874 $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
875 if ( $taxonomy ) {
876 $value['attrs']['queryTaxValue'] = wp_json_encode(array($taxonomy));
877 $value['attrs']['queryTax'] = $taxtype;
878 $value['attrs']['ajaxCall'] = true;
879 }
880 if ( isset($value['attrs']['queryNumber']) ) {
881 $value['attrs']['queryNumber'] = $value['attrs']['queryNumber'];
882 }
883 $attr = array_merge($attr, $value['attrs']);
884
885 $filter_attributes = [];
886 $filter_attributes['queryTaxValue'] = $taxonomy;
887 $filter_attributes['queryTax'] = $taxtype;
888
889 $toReturn = [
890 'blocks' => $this->all_blocks[$blockRaw]->content($attr, true),
891 'pagination' => $this->pagination_for_filter($attr, $postId, $blockRaw, $filter_attributes),
892 'paginationType' => $attr['paginationType'],
893 'paginationShow' => $attr['paginationShow']
894 ];
895 }
896 }
897 if ( !empty($value['innerBlocks']) ) {
898 $this->filter_block_return($value['innerBlocks'], $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, $toReturn, $widgetBlockId);
899 }
900 }
901 return $toReturn;
902 }
903
904
905 /**
906 * Filter Callback of the Blocks
907 *
908 * @since v.1.0.0
909 * @return STRING
910 */
911 public function ultp_filter_callback() {
912 if ( ! (isset($_REQUEST['wpnonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_REQUEST['wpnonce'])), 'ultp-nonce')) ) {
913 return ;
914 }
915
916 $taxtype = isset($_POST['taxtype'])? sanitize_text_field($_POST['taxtype']):'';
917 if ( $taxtype ) {
918 $blockId = isset($_POST['blockId'])? sanitize_text_field($_POST['blockId']):'';
919 $postId = isset($_POST['postId'])?sanitize_text_field($_POST['postId']):'';
920 $taxonomy = isset($_POST['taxonomy'])?sanitize_text_field($_POST['taxonomy']):'';
921 $blockRaw = isset($_POST['blockName'])?sanitize_text_field($_POST['blockName']):'';
922 $blockName = str_replace('_','/', $blockRaw);
923 $post = get_post($postId);
924 $widgetBlockId = isset($_POST['widgetBlockId'])? sanitize_text_field($_POST['widgetBlockId']):'';
925 $toReturn = [];
926 if( $widgetBlockId ) {
927 $blocks = parse_blocks(get_option('widget_block')[$widgetBlockId]['content']);
928 $data = $this->filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, $toReturn, $widgetBlockId);
929 }elseif ( has_blocks($post->post_content) ) {
930 $blocks = parse_blocks($post->post_content);
931 $data = $this->filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy, $postId, $toReturn, '');
932 }
933 return wp_send_json_success( [
934 'filteredData' => $data
935 ] );
936 }
937 }
938
939
940 /**
941 * Pagination of the Blocks
942 *
943 * @since v.1.0.0
944 * @return STRING
945 */
946 public function ultp_pagination_callback() {
947 if (! (isset($_REQUEST['wpnonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_REQUEST['wpnonce'])), 'ultp-nonce'))) {
948 return ;
949 }
950
951 $paged = isset($_POST['paged'])? sanitize_text_field($_POST['paged']):'';
952 if ( $paged ) {
953 $blockId = isset($_POST['blockId'])? sanitize_text_field($_POST['blockId']):'';
954 $postId = isset($_POST['postId'])?sanitize_text_field($_POST['postId']):'';
955 $blockRaw = isset($_POST['blockName'])?sanitize_text_field($_POST['blockName']):'';
956 $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
957 $blockName = str_replace('_','/', $blockRaw);
958 $post = get_post($postId);
959 $widgetBlockId = isset($_POST['widgetBlockId'])? sanitize_text_field($_POST['widgetBlockId']):'';
960 $filterValue = isset($_POST['filterValue'])? sanitize_text_field($_POST['filterValue']):'';
961 $filterType = isset($_POST['filterType'])? sanitize_text_field($_POST['filterType']):'';
962 $exclude_post_id = isset($_POST['exclude']) ? sanitize_text_field($_POST['exclude']) : '';
963 $ultp_uniqueIds = isset($_POST['ultpUniqueIds']) ? json_decode(stripslashes(sanitize_text_field($_POST['ultpUniqueIds'])), true) : [];
964 $ultp_current_unique_posts = isset($_POST['ultpCurrentUniquePosts']) ? json_decode(stripslashes(sanitize_text_field($_POST['ultpCurrentUniquePosts'])), true) : [];
965
966 if( $widgetBlockId ) {
967 $blocks = parse_blocks(get_option('widget_block')[$widgetBlockId]['content']);
968 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, '', $filterValue, $filterType, $ultp_uniqueIds, $ultp_current_unique_posts, $widgetBlockId, '');
969 }elseif( has_blocks($post->post_content) ) {
970 $blocks = parse_blocks($post->post_content);
971 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId, $filterValue, $filterType, $ultp_uniqueIds, $ultp_current_unique_posts, '', $exclude_post_id);
972 }
973 }
974 }
975
976 /**
977 * share Count callback
978 *
979 * @since v.1.0.0
980 * @return STRING
981 */
982 public function ultp_shareCount_callback() {
983 if ( ! (isset($_REQUEST['wpnonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_REQUEST['wpnonce'])), 'ultp-nonce')) ) {
984 return ;
985 }
986 $id =isset($_POST['postId'])? sanitize_text_field($_POST['postId']):'';
987 $count = isset($_POST['shareCount'])? sanitize_text_field($_POST['shareCount']):'';
988 $post_id = $id;
989 $new_count = $count+1;
990 update_post_meta($post_id, 'share_count', $new_count);
991 }
992
993 /**
994 * update_block_attrUpdate Block Attr for Pagination Loadmore and Navigation
995 *
996 * @since v.3.1.1
997 */
998 function update_block_attr($postId, $blocks, $key, $widgetBlockId ) {
999 if( $widgetBlockId ) {
1000 $widget_blocks = get_option('widget_block');
1001 $block_parsed = parse_blocks($widget_blocks[$widgetBlockId]['content']);
1002 $block_parsed[$key]['attrs']['currentPostId'] = 'widgets';
1003 $widget_blocks[$widgetBlockId]['content'] = serialize_blocks($block_parsed);
1004 update_option('widget_block', str_replace('u0022', '\u0022', $widget_blocks));
1005 } else {
1006 $blocks[$key]['attrs']['currentPostId'] = $postId;
1007 wp_update_post(array(
1008 'ID' => $postId,
1009 'post_content' => str_replace('u0022', '\u0022', serialize_blocks($blocks))
1010 ));
1011 }
1012 }
1013
1014 /**
1015 * Blocks Content Start
1016 *
1017 * @since v.1.0.0
1018 * @return STRING
1019 */
1020 public function block_return( $blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId, $filterValue, $filterType, $ultp_uniqueIds=[], $ultp_current_unique_posts=[] , $widgetBlockId='', $exclude_post_id = '' ) {
1021 foreach ( $blocks as $key => $value ) {
1022 if ($blockName == $value['blockName']) {
1023 if ( $value['attrs']['blockId'] == $blockId ) {
1024 $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
1025 $value['attrs']['paged'] = $paged;
1026 if ( $builder ) {
1027 $value['attrs']['builder'] = $builder;
1028 }
1029 if ( $postId ) {
1030 $attr['current_post'] = $postId;
1031 if( get_post_type($postId) == 'ultp_builder' && !$builder ){
1032 $attr['current_post'] = $exclude_post_id;
1033 }
1034 }
1035 if ( isset($value['attrs']['queryUnique']) && $value['attrs']['queryUnique'] ) {
1036 $value['attrs']['loadMoreQueryUnique'] = $ultp_uniqueIds;
1037 $ultp_uniqueIds[$value['attrs']['queryUnique']] = array_diff( $ultp_uniqueIds[$value['attrs']['queryUnique']], $ultp_current_unique_posts );
1038 $value['attrs']['savedQueryUnique'] = $ultp_uniqueIds;
1039 $value['attrs']['ultp_current_unique_posts'] = $ultp_current_unique_posts;
1040 }
1041 if( isset($value['attrs']['queryUnique']) && $value['attrs']['queryUnique'] && ( $value['attrs']['paginationType'] == 'loadMore' || $value['attrs']['paginationType'] == 'navigation') && isset($ultp_uniqueIds) && !isset($ultp_current_unique_posts) ) {
1042 die();
1043 }
1044
1045 if( $filterValue ) {
1046 $value['attrs']['queryTaxValue'] = wp_json_encode(array($filterValue));
1047 $value['attrs']['queryTax'] = $filterType;
1048 $value['attrs']['checkFilter'] = true;
1049 }
1050 // Exclude Current Post From Pagination
1051 if( $exclude_post_id ){
1052 $queryArr = json_decode( $value['attrs']['queryExclude']);
1053 $queryArr[] = array(
1054 'value' => $exclude_post_id,
1055 'title' => ''
1056 );
1057 $value['attrs']['queryExclude'] = wp_json_encode($queryArr);
1058 }
1059 $attr = array_merge($attr, $value['attrs']);
1060 echo $this->all_blocks[$blockRaw]->content($attr, true); //phpcs:ignore
1061 die();
1062 }
1063 }
1064 if ( !empty($value['innerBlocks']) ) {
1065 $this->block_return($value['innerBlocks'], $paged, $blockId, $blockRaw, $blockName, $builder, $postId, $filterValue, $filterType, $ultp_uniqueIds, $ultp_current_unique_posts, $widgetBlockId, $exclude_post_id);
1066 }
1067 }
1068 }
1069
1070 /**
1071 * WordPress Plugin Notice
1072 *
1073 * @since v.2.6.4
1074 * @return NULL
1075 */
1076 public function in_plugin_settings_update_message() {
1077 $response = wp_remote_get(
1078 'https://plugins.svn.wordpress.org/ultimate-post/trunk/readme.txt', array(
1079 'method' => 'GET'
1080 ));
1081
1082 if ( is_wp_error( $response ) || $response['response']['code'] != 200 ) {
1083 return;
1084 }
1085
1086 $changelog_lines = preg_split("/(\r\n|\n|\r)/", $response['body']);
1087
1088 $is_copy = false;
1089 $current_tag = '';
1090 $tag_text = 'Stable tag:';
1091 if ( !empty($changelog_lines) ) {
1092 echo '<hr style="border-color:#dba617;"/>';
1093 echo '<div style="color:#50575e;font-size:13px;font-weight:bold;"> <span style="color:#f56e28;" class="dashicons dashicons-warning"></span> ' . esc_html('PostX is ready for the next update. Changelog:-') . '</div>';
1094 echo '<hr style="border-color:#dba617;"/>';
1095 echo '<ul style="max-height:200px;overflow:scroll;">';
1096 foreach ( $changelog_lines as $key => $line ) {
1097 // Get Current Vesion
1098 if ( $current_tag == '' ) {
1099 if ( strpos($line, $tag_text) !== false ) {
1100 $current_tag = trim(str_replace($tag_text, '', $line));
1101 }
1102 } else {
1103 if ( $is_copy ) {
1104 if ( strpos($line, '= '.ULTP_VER) !== false ) {
1105 break;
1106 }
1107 if ( !empty($line) ) {
1108 if ( strpos($line, '= ') !== false ) {
1109 echo '<li style="color:#50575e;font-weight:bold;"><br/>'.esc_html($line).'</li>';
1110 } else {
1111 echo '<li>'.esc_html($line).'</li>';
1112 }
1113 }
1114 } else {
1115 if ( strpos($line, '= '.$current_tag) !== false ) { // Current Version
1116 $is_copy = true;
1117 echo '<li style="color:#50575e;font-weight:bold;">'.esc_html($line).'</li>';
1118 }
1119 }
1120 }
1121 }
1122 echo '</ul>';
1123 }
1124 }
1125
1126 /**
1127 * Check Plugin Upgrade
1128 *
1129 * @since 2.4.3
1130 *
1131 * @return void
1132 */
1133 public function plugin_upgrade_completed() {
1134 if ( ultimate_post()->get_setting('init_setup') != 'yes' ) {
1135 ultimate_post()->set_setting('init_setup', 'yes');
1136 }
1137 }
1138
1139 }