PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.5.2
Post Grid Gutenberg Blocks – PostX v2.5.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 2.5.2, at classes/Initialization.php

627 lines 23.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 $this->compatibility_check();
26 $this->requires(); // Include Necessary Files
27 $this->blocks(); // Include Blocks
28 $this->include_addons(); // Include Addons
29
30 add_action('wp', array($this, 'popular_posts_tracker_callback'));
31 add_filter('block_categories_all', array($this, 'register_category_callback'), 10, 2); // Block Category Register
32 add_action('after_setup_theme', array($this, 'add_image_size'));
33
34 add_action('enqueue_block_editor_assets', array($this, 'register_scripts_back_callback')); // Only editor
35 add_action('admin_enqueue_scripts', array($this, 'register_scripts_option_panel_callback')); // Option Panel
36 add_action('wp_enqueue_scripts', array($this, 'register_scripts_front_callback')); // Both frontend
37 register_activation_hook(ULTP_PATH.'ultimate-post.php', array($this, 'install_hook'));
38 add_action( 'activated_plugin', array($this, 'activation_redirect'));
39
40 add_action('wp_ajax_ultp_next_prev', array($this, 'ultp_next_prev_callback')); // Next Previous AJAX Call
41 add_action('wp_ajax_nopriv_ultp_next_prev', array($this, 'ultp_next_prev_callback')); // Next Previous AJAX Call Logout User
42 add_action('wp_ajax_ultp_filter', array($this, 'ultp_filter_callback')); // Next Previous AJAX Call
43 add_action('wp_ajax_nopriv_ultp_filter', array($this, 'ultp_filter_callback')); // Next Previous AJAX Call Logout User
44 add_action('wp_ajax_ultp_pagination', array($this, 'ultp_pagination_callback')); // Page Number AJAX Call
45 add_action('wp_ajax_nopriv_ultp_pagination',array($this, 'ultp_pagination_callback')); // Page Number AJAX Call Logout User
46 add_action('wp_ajax_ultp_addon', array($this, 'ultp_addon_callback')); // Next Previous AJAX Call
47
48 add_action('admin_init', array($this, 'check_theme_compatibility'));
49 add_action( 'after_switch_theme', array($this, 'wpxpo_swithch_thememe'));
50 }
51
52
53 /**
54 * Theme Switch Callback
55 *
56 * @since v.1.1.0
57 * @return NULL
58 */
59 public function wpxpo_swithch_thememe () {
60 $this->check_theme_compatibility();
61 }
62
63
64 /**
65 * Theme Compatibility Action
66 *
67 * @since v.1.1.0
68 * @return NULL
69 */
70 public function check_theme_compatibility() {
71 $licence = apply_filters( 'ultp_theme_integration' , FALSE);
72 $theme = get_transient( 'ulpt_theme_enable' );
73
74 if( $licence ) {
75 if( $theme != 'integration' ) {
76 $themes = wp_get_theme();
77 $api_params = array(
78 'wpxpo_theme_action' => 'theme_license',
79 'slug' => $themes->get('TextDomain'),
80 'author' => $themes->get('Author'),
81 'item_id' => 181,
82 'url' => home_url()
83 );
84
85 $response = wp_remote_post( 'https://www.wpxpo.com', array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
86
87 if ( !is_wp_error( $response ) || 200 === wp_remote_retrieve_response_code( $response ) ) {
88 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
89 if(isset($license_data->license)) {
90 if ( $license_data->license == 'valid' ) {
91 set_transient( 'ulpt_theme_enable', 'integration', 2592000 ); // 30 days time
92 }
93 }
94 }
95 }
96 } else {
97 if ( $theme == 'integration' ) {
98 delete_transient('ulpt_theme_enable');
99 }
100 }
101 }
102
103
104 /**
105 * Check Compatibility
106 *
107 * @since v.1.0.0
108 * @return NULL
109 */
110 public function compatibility_check(){
111 require_once ULTP_PATH.'classes/Compatibility.php';
112 new \ULTP\Compatibility();
113 }
114
115
116 /**
117 * Option Panel CSS and JS Scripts
118 *
119 * @since v.1.0.0
120 * @return NULL
121 */
122 public function register_scripts_option_panel_callback(){
123 wp_enqueue_style('wp-color-picker');
124 wp_enqueue_script('wp-color-picker');
125 wp_enqueue_script('ultp-option-script', ULTP_URL.'assets/js/ultp-option.js', array('jquery'), ULTP_VER, true);
126 wp_enqueue_style('ultp-option-style', ULTP_URL.'assets/css/ultp-option.css', array(), ULTP_VER);
127 wp_localize_script('ultp-option-script', 'ultp_option_panel', array(
128 'security' => wp_create_nonce('ultp-nonce'),
129 'ajax' => admin_url('admin-ajax.php')
130 ));
131 }
132
133
134 /**
135 * Common Frontend and Backend CSS and JS Scripts
136 *
137 * @since v.1.0.0
138 * @return NULL
139 */
140 public function register_scripts_common(){
141 wp_enqueue_style('ultp-style', ULTP_URL.'assets/css/style.min.css', array(), ULTP_VER );
142 wp_enqueue_script('ultp-script', ULTP_URL.'assets/js/ultp.min.js', array('jquery'), ULTP_VER, true);
143 wp_localize_script('ultp-script', 'ultp_data_frontend', array(
144 'url' => ULTP_URL,
145 'ajax' => admin_url('admin-ajax.php'),
146 'security' => wp_create_nonce('ultp-nonce')
147 ));
148
149 }
150
151
152 /**
153 * Only Frontend CSS and JS Scripts
154 *
155 * @since v.1.0.0
156 * @return NULL
157 */
158 public function register_scripts_front_callback() {
159 $call_common = false;
160 if (isset($_GET['preview_id']) && isset($_GET['preview_nonce'])) {
161 $call_common = true;
162 $this->register_scripts_common();
163 } else if ('yes' == get_post_meta(ultimate_post()->get_ID(), '_ultp_active', true)) {
164 $call_common = true;
165 $this->register_scripts_common();
166 } else if (ultimate_post()->is_builder()) {
167 $call_common = true;
168 $this->register_scripts_common();
169 } else if (apply_filters ('postx_common_script', false)) {
170 $call_common = true;
171 $this->register_scripts_common();
172 }
173
174 // For WidgetWidget
175 $has_block = false;
176 $widget_blocks = array();
177 global $wp_registered_sidebars, $sidebars_widgets;
178 foreach ($wp_registered_sidebars as $key => $value) {
179 if (is_active_sidebar($key)) {
180 foreach ($sidebars_widgets[$key] as $val) {
181 if (strpos($val, 'block-') !== false) {
182 if (empty($widget_blocks)) {
183 $widget_blocks = get_option( 'widget_block' );
184 }
185 foreach ( (array) $widget_blocks as $block ) {
186 if ( isset( $block['content'] ) && strpos($block['content'], 'wp:ultimate-post') !== false ) {
187 $has_block = true;
188 break;
189 }
190 }
191 if ($has_block) {
192 break;
193 }
194 }
195 }
196 }
197 }
198 if ($has_block) {
199 if (!$call_common) {
200 $this->register_scripts_common();
201 }
202 $css = get_option('ultp-widget', true);
203 if ($css) {
204 wp_register_style('ultp-post-widget', false );
205 wp_enqueue_style('ultp-post-widget' );
206 wp_add_inline_style('ultp-post-widget', $css);
207 }
208 }
209 }
210
211
212 /**
213 * Only Backend CSS and JS Scripts
214 *
215 * @since v.1.0.0
216 * @return NULL
217 */
218 public function register_scripts_back_callback() {
219 $this->register_scripts_common();
220 global $pagenow;
221 $depends = 'wp-editor';
222 if ( $pagenow === 'widgets.php' ) {
223 $depends = 'wp-edit-widgets';
224 }
225 wp_enqueue_script('ultp-blocks-editor-script', ULTP_URL.'assets/js/editor.blocks.min.js', array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', $depends ), ULTP_VER, true);
226 wp_enqueue_style('ultp-blocks-editor-css', ULTP_URL.'assets/css/blocks.editor.css', array(), ULTP_VER);
227 if(is_rtl()){
228 wp_enqueue_style('ultp-blocks-editor-rtl-css', ULTP_URL.'assets/css/rtl.css', array(), ULTP_VER);
229 }
230 $is_active = ultimate_post()->is_lc_active();
231 wp_localize_script('ultp-blocks-editor-script', 'ultp_data', array(
232 'url' => ULTP_URL,
233 'ajax' => admin_url('admin-ajax.php'),
234 'security' => wp_create_nonce('ultp-nonce'),
235 'hide_import_btn' => ultimate_post()->get_setting('hide_import_btn'),
236 'upload' => wp_upload_dir()['basedir'] . '/ultp',
237 'premium_link' => ultimate_post()->get_premium_link(),
238 'license' => $is_active ? get_option('edd_ultp_license_key') : '',
239 'active' => $is_active,
240 'archive' => $is_active ? ultimate_post()->is_archive_builder() : '',
241 'settings' => ultimate_post()->get_setting()
242 ));
243
244 wp_set_script_translations( 'ultp-blocks-editor-script', 'ultimate-post', ULTP_PATH . 'languages/' );
245 }
246
247
248 /**
249 * Fire When Plugin First Install
250 *
251 * @since v.1.0.0
252 * @return NULL
253 */
254 public function install_hook() {
255 if (!get_option('ultp_options')) {
256 ultimate_post()->init_set_data();
257 }
258 }
259
260
261 /**
262 * Redirect After Active Plugin
263 *
264 * @since v.1.0.0
265 * @param STRING | Plugin Path
266 * @return NULL
267 */
268 public function activation_redirect($plugin) {
269 if( $plugin == 'ultimate-post/ultimate-post.php' ) {
270 exit(wp_redirect(admin_url('admin.php?page=ultp-settings')));
271 }
272 }
273
274
275 /**
276 * Require Blocks
277 *
278 * @since v.1.0.0
279 * @return NULL
280 */
281 public function blocks() {
282 $setting = ultimate_post()->get_setting();
283 if (!isset($setting['post_list_1']) || $setting['post_list_1'] == 'yes') {
284 require_once ULTP_PATH.'blocks/Post_List_1.php';
285 $this->all_blocks['ultimate-post_post-list-1'] = new \ULTP\blocks\Post_List_1();
286 }
287 if (!isset($setting['post_list_2']) || $setting['post_list_2'] == 'yes') {
288 require_once ULTP_PATH.'blocks/Post_List_2.php';
289 $this->all_blocks['ultimate-post_post-list-2'] = new \ULTP\blocks\Post_List_2();
290 }
291 if (!isset($setting['post_list_3']) || $setting['post_list_3'] == 'yes') {
292 require_once ULTP_PATH.'blocks/Post_List_3.php';
293 $this->all_blocks['ultimate-post_post-list-3'] = new \ULTP\blocks\Post_List_3();
294 }
295 if (!isset($setting['post_list_4']) || $setting['post_list_4'] == 'yes') {
296 require_once ULTP_PATH.'blocks/Post_List_4.php';
297 $this->all_blocks['ultimate-post_post-list-4'] = new \ULTP\blocks\Post_List_4();
298 }
299 if (!isset($setting['post_grid_1']) || $setting['post_grid_1'] == 'yes') {
300 require_once ULTP_PATH.'blocks/Post_Grid_1.php';
301 $this->all_blocks['ultimate-post_post-grid-1'] = new \ULTP\blocks\Post_Grid_1();
302 }
303 if (!isset($setting['post_grid_2']) || $setting['post_grid_2'] == 'yes') {
304 require_once ULTP_PATH.'blocks/Post_Grid_2.php';
305 $this->all_blocks['ultimate-post_post-grid-2'] = new \ULTP\blocks\Post_Grid_2();
306 }
307 if (!isset($setting['post_grid_3']) || $setting['post_grid_3'] == 'yes') {
308 require_once ULTP_PATH.'blocks/Post_Grid_3.php';
309 $this->all_blocks['ultimate-post_post-grid-3'] = new \ULTP\blocks\Post_Grid_3();
310 }
311 if (!isset($setting['post_grid_4']) || $setting['post_grid_4'] == 'yes') {
312 require_once ULTP_PATH.'blocks/Post_Grid_4.php';
313 $this->all_blocks['ultimate-post_post-grid-4'] = new \ULTP\blocks\Post_Grid_4();
314 }
315 if (!isset($setting['post_grid_5']) || $setting['post_grid_5'] == 'yes') {
316 require_once ULTP_PATH.'blocks/Post_Grid_5.php';
317 $this->all_blocks['ultimate-post_post-grid-5'] = new \ULTP\blocks\Post_Grid_5();
318 }
319 if (!isset($setting['post_grid_6']) || $setting['post_grid_6'] == 'yes') {
320 require_once ULTP_PATH.'blocks/Post_Grid_6.php';
321 $this->all_blocks['ultimate-post_post-grid-6'] = new \ULTP\blocks\Post_Grid_6();
322 }
323 if (!isset($setting['post_grid_7']) || $setting['post_grid_7'] == 'yes') {
324 require_once ULTP_PATH.'blocks/Post_Grid_7.php';
325 $this->all_blocks['ultimate-post_post-grid-7'] = new \ULTP\blocks\Post_Grid_7();
326 }
327 if (!isset($setting['post_slider_1']) || $setting['post_slider_1'] == 'yes') {
328 require_once ULTP_PATH.'blocks/Post_Slider_1.php';
329 $this->all_blocks['ultimate-post_post-slider-1'] = new \ULTP\blocks\Post_Slider_1();
330 }
331 if (!isset($setting['post_module_1']) || $setting['post_module_1'] == 'yes') {
332 require_once ULTP_PATH.'blocks/Post_Module_1.php';
333 $this->all_blocks['ultimate-post_post-module-1'] = new \ULTP\blocks\Post_Module_1();
334 }
335 if (!isset($setting['post_module_2']) || $setting['post_module_2'] == 'yes') {
336 require_once ULTP_PATH.'blocks/Post_Module_2.php';
337 $this->all_blocks['ultimate-post_post-module-2'] = new \ULTP\blocks\Post_Module_2();
338 }
339 if (!isset($setting['heading']) || $setting['heading'] == 'yes') {
340 require_once ULTP_PATH.'blocks/Heading.php';
341 $this->all_blocks['ultimate-post_heading'] = new \ULTP\blocks\Heading();
342 }
343 if (!isset($setting['image']) || $setting['image'] == 'yes') {
344 require_once ULTP_PATH.'blocks/Image.php';
345 $this->all_blocks['ultimate-post_image'] = new \ULTP\blocks\Image();
346 }
347 if (!isset($setting['taxonomy']) || $setting['taxonomy'] == 'yes') {
348 require_once ULTP_PATH.'blocks/Taxonomy.php';
349 $this->all_blocks['ultimate-post_ultp-taxonomy'] = new \ULTP\blocks\Taxonomy();
350 }
351
352 if (!isset($setting['news_ticker']) || $setting['news_ticker'] == 'yes') {
353 require_once ULTP_PATH.'blocks/News_Ticker.php';
354 $this->all_blocks['ultimate-post_news-ticker'] = new \ULTP\blocks\News_Ticker();
355 }
356
357 require_once ULTP_PATH.'blocks/Archive_Title.php';
358 $this->all_blocks['ultimate-post_archive-title'] = new \ULTP\blocks\Archive_Title();
359 }
360
361
362 /**
363 * Necessary Requires Class
364 *
365 * @since v.1.0.0
366 * @return NULL
367 */
368 public function requires() {
369 require_once ULTP_PATH.'classes/Notice.php';
370 require_once ULTP_PATH.'classes/Styles.php';
371 require_once ULTP_PATH.'classes/Options.php';
372 require_once ULTP_PATH.'classes/REST_API.php';
373 require_once ULTP_PATH.'classes/Caches.php';
374 new \ULTP\REST_API();
375 new \ULTP\Caches();
376 new \ULTP\Options();
377 new \ULTP\Styles();
378 new \ULTP\Notice();
379
380 require_once ULTP_PATH.'classes/Deactive.php';
381 new \ULTP\Deactive();
382 }
383
384
385 /**
386 * Block Categories Initialization
387 *
388 * @since v.1.0.0
389 * @param $categories(ARRAY) | $post (ARRAY)
390 * @return NULL
391 */
392 public function register_category_callback( $categories, $post ) {
393 return array_merge(
394 array(
395 array(
396 'slug' => 'ultimate-post',
397 'title' => __( 'PostX - Gutenberg Post Blocks', 'ultimate-post' )
398 )
399 ), $categories
400 );
401 }
402
403
404 /**
405 * Post View Counter for Every Post
406 *
407 * @since v.1.0.0
408 * @param NUMBER | Post ID
409 * @return NULL
410 */
411 public function popular_posts_tracker_callback($post_id) {
412 if (!is_single()){ return; }
413 global $post;
414 $post_id = $post->ID;
415 $isEnable = apply_filters('ultp_view_cookies', true);
416 if ($post_id && $isEnable) {
417 $has_cookie = isset( $_COOKIE['ultp_view_'.$post_id] ) ? $_COOKIE['ultp_view_'.$post_id] : false;
418 if (!$has_cookie) {
419 $count = (int)get_post_meta( $post_id, '__post_views_count', true );
420 update_post_meta($post_id, '__post_views_count', $count ? (int)$count + 1 : 1 );
421 setcookie( 'ultp_view_'.$post_id, 1, time() + 86400, COOKIEPATH ); // 1 days cookies
422 }
423 }
424 }
425
426
427 /**
428 * Set Image Size
429 *
430 * @since v.1.0.0
431 * @return NULL
432 */
433 public function add_image_size() {
434 $size_disable = ultimate_post()->get_setting('disable_image_size');
435 if ($size_disable != 'yes') {
436 add_image_size('ultp_layout_landscape_large', 1200, 800, true);
437 add_image_size('ultp_layout_landscape', 870, 570, true);
438 add_image_size('ultp_layout_portrait', 600, 900, true);
439 add_image_size('ultp_layout_square', 600, 600, true);
440 }
441 }
442
443
444 /**
445 * Include Addons Directory
446 *
447 * @since v.1.0.0
448 * @return NULL
449 */
450 public function include_addons() {
451 $addons_dir = array_filter(glob(ULTP_PATH.'addons/*'), 'is_dir');
452 if (count($addons_dir) > 0) {
453 foreach( $addons_dir as $key => $value ) {
454 $addon_dir_name = str_replace(dirname($value).'/', '', $value);
455 $file_name = ULTP_PATH . 'addons/'.$addon_dir_name.'/init.php';
456 if ( file_exists($file_name) ) {
457 include_once $file_name;
458 }
459 }
460 }
461 }
462
463
464 /**
465 * Addon Callback
466 *
467 * @since v.1.0.0
468 * @return STRING
469 */
470 public function ultp_addon_callback() {
471 if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
472 return ;
473 }
474 $addon_name = sanitize_text_field($_POST['addon']);
475 $addon_value = sanitize_text_field($_POST['value']);
476 if ($addon_name && current_user_can('administrator')) {
477 $addon_data = ultimate_post()->get_setting();
478 $addon_data[$addon_name] = $addon_value;
479 $GLOBALS['ultp_settings'][$addon_name] = $addon_value;
480 update_option('ultp_options', $addon_data);
481 }
482 }
483
484
485 /**
486 * Next Preview Callback of the Blocks
487 *
488 * @since v.1.0.0
489 * @return STRING
490 */
491 public function ultp_next_prev_callback() {
492 if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
493 return ;
494 }
495
496 $paged = sanitize_text_field($_POST['paged']);
497 $blockId = sanitize_text_field($_POST['blockId']);
498 $postId = sanitize_text_field($_POST['postId']);
499 $blockRaw = sanitize_text_field($_POST['blockName']);
500 $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
501
502 $blockName = str_replace('_','/', $blockRaw);
503
504 if( $paged && $blockId && $postId && $blockName ) {
505 $post = get_post($postId);
506 if (has_blocks($post->post_content)) {
507 $blocks = parse_blocks($post->post_content);
508 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
509 }
510 }
511 }
512
513
514 /**
515 * Filter Callback of the Blocks
516 *
517 * @since v.1.0.0
518 * @return STRING
519 */
520 public function filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy) {
521 foreach ($blocks as $key => $value) {
522 if($blockName == $value['blockName']) {
523 if($value['attrs']['blockId'] == $blockId) {
524 $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
525 if($taxonomy) {
526 $value['attrs']['queryTaxValue'] = json_encode(array($taxonomy));
527 $value['attrs']['queryTax'] = $taxtype;
528 }
529 if(isset($value['attrs']['queryNumber'])){
530 $value['attrs']['queryNumber'] = $value['attrs']['queryNumber'];
531 }
532 $attr = array_merge($attr, $value['attrs']);
533 echo $this->all_blocks[$blockRaw]->content($attr, true);
534 die();
535 }
536 }
537 if(!empty($value['innerBlocks'])){
538 $this->filter_block_return($value['innerBlocks'], $blockId, $blockRaw, $blockName, $taxtype, $taxonomy);
539 }
540 }
541 }
542
543
544 /**
545 * Filter Callback of the Blocks
546 *
547 * @since v.1.0.0
548 * @return STRING
549 */
550 public function ultp_filter_callback() {
551 if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
552 return ;
553 }
554
555 $taxtype = sanitize_text_field($_POST['taxtype']);
556 if( $taxtype ) {
557 $blockId = sanitize_text_field($_POST['blockId']);
558 $postId = sanitize_text_field($_POST['postId']);
559 $taxonomy = sanitize_text_field($_POST['taxonomy']);
560 $blockRaw = sanitize_text_field($_POST['blockName']);
561 $blockName = str_replace('_','/', $blockRaw);
562 $post = get_post($postId);
563 if (has_blocks($post->post_content)) {
564 $blocks = parse_blocks($post->post_content);
565 $this->filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy);
566 }
567 }
568 }
569
570
571 /**
572 * Pagination of the Blocks
573 *
574 * @since v.1.0.0
575 * @return STRING
576 */
577 public function ultp_pagination_callback() {
578 if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local) {
579 return ;
580 }
581
582 $paged = sanitize_text_field($_POST['paged']);
583 if($paged) {
584 $blockId = sanitize_text_field($_POST['blockId']);
585 $postId = sanitize_text_field($_POST['postId']);
586 $blockRaw = sanitize_text_field($_POST['blockName']);
587 $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
588 $blockName = str_replace('_','/', $blockRaw);
589 $post = get_post($postId);
590 if (has_blocks($post->post_content)) {
591 $blocks = parse_blocks($post->post_content);
592 $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
593 }
594 }
595 }
596
597
598 /**
599 * Blocks Content Start
600 *
601 * @since v.1.0.0
602 * @return STRING
603 */
604 public function block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId) {
605 foreach ($blocks as $key => $value) {
606 if($blockName == $value['blockName']) {
607 if($value['attrs']['blockId'] == $blockId) {
608 $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
609 $value['attrs']['paged'] = $paged;
610 if ($builder) {
611 $value['attrs']['builder'] = $builder;
612 }
613 if ($postId) {
614 $attr['current_post'] = $postId;
615 }
616 $attr = array_merge($attr, $value['attrs']);
617 echo $this->all_blocks[$blockRaw]->content($attr, true);
618 die();
619 }
620 }
621 if(!empty($value['innerBlocks'])){
622 $this->block_return($value['innerBlocks'], $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
623 }
624 }
625 }
626
627 }