PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.5.6
Post Grid Gutenberg Blocks – PostX v2.5.6
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/Initialization.php +564 -555 5.0.192.5.6 View file →
@@ -1,619 +1,628 @@
1 1 <?php
2 -
3 2 /**
4 3 * Initialization Action.
5 - *
6 - * @package ULTP\ULTP_Initialization
4 + *
5 + * @package ULTP\Notice
7 6 * @since v.1.1.0
8 7 */
9 -
10 8 namespace ULTP;
11 9
12 -defined( 'ABSPATH' ) || exit;
10 +defined('ABSPATH') || exit;
13 11
14 -use ULTP\Includes\Durbin\Xpo;
15 -use ULTP\Includes\Notice\Notice;
16 -
17 12 /**
18 13 * Initialization class.
19 - *
20 - * Handles plugin initialization for Ultimate Post.
21 - *
22 - * @package ULTP\Initialization
23 - * @since 4.0.0
24 14 */
25 -class ULTP_Initialization {
15 +class ULTP_Initialization{
26 16
27 - /**
17 + private $all_blocks;
18 +
19 + /**
28 20 * Setup class.
29 21 *
30 - * @since 4.0.0
31 - * @return void No return value.
22 + * @since v.1.1.0
32 23 */
33 - public function __construct() {
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
34 29
35 - $this->compatibility_check();
36 - $this->requires();
37 - $this->include_addons();
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'));
38 33
39 - add_filter( 'admin_body_class', array( $this, 'add_admin_body_class' ) ); // add body class in editor.
40 - add_filter( 'body_class', array( $this, 'add_body_class' ) ); // add body class in front end.
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'));
41 39
42 - add_action( 'wp', array( $this, 'popular_posts_tracker_callback' ) );
43 - add_action( 'after_setup_theme', array( $this, 'add_image_size' ) );
44 - add_filter( 'block_categories_all', array( $this, 'register_category_callback' ), 999999999, 2 ); // Block Category Register.
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
45 47
46 - add_filter( 'safe_style_css', array( $this, 'ultp_handle_safe_style_css' ) ); // support for css used in svg icon.
47 - add_filter( 'wp_kses_allowed_html', array( $this, 'ultp_handle_allowed_html' ), 99, 2 ); // support for svg icon used in list, row, icon block.
48 + add_action('admin_init', array($this, 'check_theme_compatibility'));
49 + add_action( 'after_switch_theme', array($this, 'wpxpo_swithch_thememe'));
50 + }
48 51
49 - add_action( 'enqueue_block_editor_assets', array( $this, 'register_block_scripts_editor_area' ) ); // Only editor.
50 - add_action( 'admin_enqueue_scripts', array( $this, 'register_option_panel_scripts_callback' ) ); // Option Panel.
51 - register_activation_hook( ULTP_PATH . 'ultimate-post.php', array( $this, 'plugin_activation_hook' ) );
52 - add_action( 'activated_plugin', array( $this, 'ultp_plugin_activation' ) ); // Plugin Activation Call.
53 - // new Notice();
54 - }
55 52
56 - /**
57 - * Check plugin compatibility.
58 - *
59 - * @since v.1.0.0
60 - * @return void
53 + /**
54 + * Theme Switch Callback
55 + *
56 + * @since v.1.1.0
57 + * @return NULL
61 58 */
62 - public function compatibility_check() {
63 - require_once ULTP_PATH . 'classes/Compatibility.php';
64 - new \ULTP\Compatibility();
65 - }
59 + public function wpxpo_swithch_thememe () {
60 + $this->check_theme_compatibility();
61 + }
66 62
67 - /**
68 - * Load all required classes.
69 - *
70 - * @since v.1.0.0
71 - * @return void No return value.
63 +
64 + /**
65 + * Theme Compatibility Action
66 + *
67 + * @since v.1.1.0
68 + * @return NULL
72 69 */
73 - public function requires() {
74 - require_once ULTP_PATH . 'classes/Styles.php';
75 - require_once ULTP_PATH . 'classes/Options.php';
76 - require_once ULTP_PATH . 'classes/REST_API.php';
77 - require_once ULTP_PATH . 'classes/Caches.php';
78 - require_once ULTP_PATH . 'classes/Importer.php';
79 - require_once ULTP_PATH . 'classes/Dashboard.php';
80 - require_once ULTP_PATH . 'classes/Blocks.php';
81 - new \ULTP\REST_API();
82 - new \ULTP\Options();
83 - new \ULTP\Caches();
84 - new \ULTP\Styles();
85 - new \ULTP\Importer();
86 - new \ULTP\Dashboard();
87 - new \ULTP\Blocks();
70 + public function check_theme_compatibility() {
71 + $licence = apply_filters( 'ultp_theme_integration' , FALSE);
72 + $theme = get_transient( 'ulpt_theme_enable' );
88 73
89 - require_once ULTP_PATH . 'includes/durbin/class-durbin-client.php';
90 - require_once ULTP_PATH . 'includes/durbin/class-xpo.php';
91 - require_once ULTP_PATH . 'includes/deactive/class-deactive.php';
92 - require_once ULTP_PATH . 'includes/notice/class-notice.php';
93 - require_once ULTP_PATH . 'includes/durbin/class-our-plugins.php';
94 - require_once ULTP_PATH . 'includes/notice/class-wow-shipping-promotion.php';
95 - new \ULTP\Includes\Deactive\Deactive();
96 - new \ULTP\Includes\notice\Notice();
97 - new \ULTP\Includes\notice\WowShippingPromotion();
98 - new \ULTP\Includes\Durbin\OurPlugins();
99 - }
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 ) );
100 86
101 - /**
102 - * Include all addons from the addons directory.
103 - *
104 - * @since v.1.0.0
105 - * @return void
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
106 109 */
107 - public function include_addons() {
108 - $addons_dir = array_filter( glob( ULTP_PATH . 'addons/*' ), 'is_dir' );
109 - if ( count( $addons_dir ) > 0 ) {
110 - foreach ( $addons_dir as $key => $value ) {
111 - $addon_dir_name = str_replace( dirname( $value ) . '/', '', $value );
112 - $file_name = ULTP_PATH . 'addons/' . $addon_dir_name . '/init.php';
113 - if ( file_exists( $file_name ) ) {
114 - include_once $file_name;
115 - }
116 - }
117 - }
118 - }
110 + public function compatibility_check(){
111 + require_once ULTP_PATH.'classes/Compatibility.php';
112 + new \ULTP\Compatibility();
113 + }
119 114
120 115
121 - /**
122 - * Add admin body class in editor.
123 - *
124 - * @since v.3.1.6
125 - * @param STRING $classes The existing admin body classes.
126 - * @return STRING Modified admin body classes.
116 + /**
117 + * Option Panel CSS and JS Scripts
118 + *
119 + * @since v.1.0.0
120 + * @return NULL
127 121 */
128 - public function add_admin_body_class( $classes ) {
129 - $classes .= ' postx-admin-page ';
130 - return $classes;
131 - }
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 132
133 - /**
134 - * Add body class in front end.
135 - *
136 - * @since v.3.1.6
137 - * @param ARRAY $classes The existing body classes.
138 - * @return ARRAY Modified body classes.
133 +
134 + /**
135 + * Common Frontend and Backend CSS and JS Scripts
136 + *
137 + * @since v.1.0.0
138 + * @return NULL
139 139 */
140 - public function add_body_class( $classes ) {
141 - $classes[] = 'postx-page';
142 - return $classes;
143 - }
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 + ));
144 148
145 - /**
146 - * Post view counter for every post.
147 - *
148 - * @since v.1.0.0
149 - * @param INT $post_id The post ID.
150 - * @return NULL No return value.
149 + }
150 +
151 +
152 + /**
153 + * Only Frontend CSS and JS Scripts
154 + *
155 + * @since v.1.0.0
156 + * @return NULL
151 157 */
152 - public function popular_posts_tracker_callback( $post_id ) {
153 - if ( ! is_single() ) {
154 - return;
155 - }
156 - global $post;
157 - $post_id = isset( $post->ID ) ? $post->ID : '';
158 - $isEnable = apply_filters( 'ultp_view_cookies', true );
159 - // add_filter( 'ultp_view_cookies', '__return_false' );
160 - $cookies_disable = ultimate_post()->get_setting( 'disable_view_cookies' );
161 - if ( $post_id && $isEnable && $cookies_disable != 'yes' ) {
162 - $has_cookie = isset( $_COOKIE[ 'ultp_view_' . $post_id ] ) ? sanitize_text_field( $_COOKIE[ 'ultp_view_' . $post_id ] ) : false;
163 - if ( ! $has_cookie ) {
164 - $count = (int) get_post_meta( $post_id, '__post_views_count', true );
165 - update_post_meta( $post_id, '__post_views_count', $count ? (int) $count + 1 : 1 );
166 - setcookie( 'ultp_view_' . $post_id, 1, time() + 86400, COOKIEPATH ); // 1 days cookies
167 - }
168 - }
169 - }
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 + }
170 173
171 - /**
172 - * Set image sizes for the plugin.
173 - *
174 - * @since v.1.0.0
175 - * @return void No return value.
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
176 217 */
177 - public function add_image_size() {
178 - $size_disable = ultimate_post()->get_setting( 'disable_image_size' );
179 - if ( $size_disable != 'yes' ) {
180 - add_image_size( 'ultp_layout_landscape_large', 1200, 800, true );
181 - add_image_size( 'ultp_layout_landscape', 870, 570, true );
182 - add_image_size( 'ultp_layout_portrait', 600, 900, true );
183 - add_image_size( 'ultp_layout_square', 600, 600, true );
184 - }
185 - }
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 + ));
186 243
187 - /**
188 - * Block categories initialization.
189 - *
190 - * @since v.1.0.0
191 - * @param ARRAY $categories The block categories.
192 - * @param ARRAY $post The post object.
193 - * @return ARRAY Modified block categories.
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
194 253 */
195 - public function register_category_callback( $categories, $post ) {
196 - $attr = array(
197 - array(
198 - 'slug' => 'ultimate-post',
199 - 'title' => __( 'PostX - Gutenberg Post Blocks', 'ultimate-post' ),
200 - ),
201 - array(
202 - 'slug' => 'postx-site-builder',
203 - 'title' => __( 'PostX Site Builder', 'ultimate-post' ),
204 - ),
205 - );
206 - return array_merge( $attr, $categories );
207 - }
254 + public function install_hook() {
255 + if (!get_option('ultp_options')) {
256 + ultimate_post()->init_set_data();
257 + }
258 + }
208 259
209 - /**
210 - * Add support for CSS to use SVG.
211 - *
212 - * @since 4.0.0
213 - * @param ARRAY $styles The allowed CSS styles.
214 - * @return ARRAY Modified allowed CSS styles.
260 +
261 + /**
262 + * Redirect After Active Plugin
263 + *
264 + * @since v.1.0.0
265 + * @param STRING | Plugin Path
266 + * @return NULL
215 267 */
216 - public function ultp_handle_safe_style_css( $styles ) {
217 - if ( ! is_multisite() && ! current_user_can( 'edit_posts' ) ) {
218 - return $styles;
219 - }
220 - return array_merge(
221 - $styles,
222 - array(
223 - 'opacity',
224 - // for SVG gradients.
225 - // 'stop-opacity',
226 - // 'stop-color',
227 - )
228 - );
229 - }
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 + }
230 273
231 - /**
232 - * Add support for HTML tags to use SVG.
233 - *
234 - * @since 4.0.0
235 - * @param ARRAY $tags The allowed HTML tags.
236 - * @param STRING $context The context for allowed HTML.
237 - * @return ARRAY Modified allowed HTML tags.
274 +
275 + /**
276 + * Require Blocks
277 + *
278 + * @since v.1.0.0
279 + * @return NULL
238 280 */
239 - public function ultp_handle_allowed_html( $tags, $context ) {
240 - if ( 'post' !== $context && ! is_multisite() && ! current_user_can( 'edit_posts' ) ) {
241 - return $tags;
242 - }
243 - if ( ! isset( $tags['svg'] ) ) {
244 - $tags['svg'] = array_merge(
245 - array(
246 - 'xmlns' => true,
247 - // 'xmlns:xlink' => true,
248 - // 'xlink:href' => true,
249 - // 'xml:id' => true,
250 - // 'xlink:title' => true,
251 - // 'xml:space' => true,
252 - 'viewbox' => true,
253 - 'enable-background' => true,
254 - 'version' => true,
255 - 'preserveaspectratio' => true,
256 - 'fill' => true,
257 - )
258 - );
259 - }
260 - if ( ! isset( $tags['path'] ) || ! is_array( $tags['path'] ) ) {
261 - $tags['path'] = array();
262 - }
281 + public function blocks() {
282 + global $unique_ID;
283 + $setting = ultimate_post()->get_setting();
284 + if (!isset($setting['post_list_1']) || $setting['post_list_1'] == 'yes') {
285 + require_once ULTP_PATH.'blocks/Post_List_1.php';
286 + $this->all_blocks['ultimate-post_post-list-1'] = new \ULTP\blocks\Post_List_1();
287 + }
288 + if (!isset($setting['post_list_2']) || $setting['post_list_2'] == 'yes') {
289 + require_once ULTP_PATH.'blocks/Post_List_2.php';
290 + $this->all_blocks['ultimate-post_post-list-2'] = new \ULTP\blocks\Post_List_2();
291 + }
292 + if (!isset($setting['post_list_3']) || $setting['post_list_3'] == 'yes') {
293 + require_once ULTP_PATH.'blocks/Post_List_3.php';
294 + $this->all_blocks['ultimate-post_post-list-3'] = new \ULTP\blocks\Post_List_3();
295 + }
296 + if (!isset($setting['post_list_4']) || $setting['post_list_4'] == 'yes') {
297 + require_once ULTP_PATH.'blocks/Post_List_4.php';
298 + $this->all_blocks['ultimate-post_post-list-4'] = new \ULTP\blocks\Post_List_4();
299 + }
300 + if (!isset($setting['post_grid_1']) || $setting['post_grid_1'] == 'yes') {
301 + require_once ULTP_PATH.'blocks/Post_Grid_1.php';
302 + $this->all_blocks['ultimate-post_post-grid-1'] = new \ULTP\blocks\Post_Grid_1();
303 + }
304 + if (!isset($setting['post_grid_2']) || $setting['post_grid_2'] == 'yes') {
305 + require_once ULTP_PATH.'blocks/Post_Grid_2.php';
306 + $this->all_blocks['ultimate-post_post-grid-2'] = new \ULTP\blocks\Post_Grid_2();
307 + }
308 + if (!isset($setting['post_grid_3']) || $setting['post_grid_3'] == 'yes') {
309 + require_once ULTP_PATH.'blocks/Post_Grid_3.php';
310 + $this->all_blocks['ultimate-post_post-grid-3'] = new \ULTP\blocks\Post_Grid_3();
311 + }
312 + if (!isset($setting['post_grid_4']) || $setting['post_grid_4'] == 'yes') {
313 + require_once ULTP_PATH.'blocks/Post_Grid_4.php';
314 + $this->all_blocks['ultimate-post_post-grid-4'] = new \ULTP\blocks\Post_Grid_4();
315 + }
316 + if (!isset($setting['post_grid_5']) || $setting['post_grid_5'] == 'yes') {
317 + require_once ULTP_PATH.'blocks/Post_Grid_5.php';
318 + $this->all_blocks['ultimate-post_post-grid-5'] = new \ULTP\blocks\Post_Grid_5();
319 + }
320 + if (!isset($setting['post_grid_6']) || $setting['post_grid_6'] == 'yes') {
321 + require_once ULTP_PATH.'blocks/Post_Grid_6.php';
322 + $this->all_blocks['ultimate-post_post-grid-6'] = new \ULTP\blocks\Post_Grid_6();
323 + }
324 + if (!isset($setting['post_grid_7']) || $setting['post_grid_7'] == 'yes') {
325 + require_once ULTP_PATH.'blocks/Post_Grid_7.php';
326 + $this->all_blocks['ultimate-post_post-grid-7'] = new \ULTP\blocks\Post_Grid_7();
327 + }
328 + if (!isset($setting['post_slider_1']) || $setting['post_slider_1'] == 'yes') {
329 + require_once ULTP_PATH.'blocks/Post_Slider_1.php';
330 + $this->all_blocks['ultimate-post_post-slider-1'] = new \ULTP\blocks\Post_Slider_1();
331 + }
332 + if (!isset($setting['post_module_1']) || $setting['post_module_1'] == 'yes') {
333 + require_once ULTP_PATH.'blocks/Post_Module_1.php';
334 + $this->all_blocks['ultimate-post_post-module-1'] = new \ULTP\blocks\Post_Module_1();
335 + }
336 + if (!isset($setting['post_module_2']) || $setting['post_module_2'] == 'yes') {
337 + require_once ULTP_PATH.'blocks/Post_Module_2.php';
338 + $this->all_blocks['ultimate-post_post-module-2'] = new \ULTP\blocks\Post_Module_2();
339 + }
340 + if (!isset($setting['heading']) || $setting['heading'] == 'yes') {
341 + require_once ULTP_PATH.'blocks/Heading.php';
342 + $this->all_blocks['ultimate-post_heading'] = new \ULTP\blocks\Heading();
343 + }
344 + if (!isset($setting['image']) || $setting['image'] == 'yes') {
345 + require_once ULTP_PATH.'blocks/Image.php';
346 + $this->all_blocks['ultimate-post_image'] = new \ULTP\blocks\Image();
347 + }
348 + if (!isset($setting['taxonomy']) || $setting['taxonomy'] == 'yes') {
349 + require_once ULTP_PATH.'blocks/Taxonomy.php';
350 + $this->all_blocks['ultimate-post_ultp-taxonomy'] = new \ULTP\blocks\Taxonomy();
351 + }
352 +
353 + if (!isset($setting['news_ticker']) || $setting['news_ticker'] == 'yes') {
354 + require_once ULTP_PATH.'blocks/News_Ticker.php';
355 + $this->all_blocks['ultimate-post_news-ticker'] = new \ULTP\blocks\News_Ticker();
356 + }
357 +
358 + require_once ULTP_PATH.'blocks/Archive_Title.php';
359 + $this->all_blocks['ultimate-post_archive-title'] = new \ULTP\blocks\Archive_Title();
360 + }
263 361
264 - $tags['path'] = array_merge(
265 - $tags['path'],
266 - array(
267 - 'd' => true,
268 - 'stroke' => true,
269 - 'stroke-miterlimit' => true,
270 - 'data-original' => true,
271 - 'class' => true,
272 - 'transform' => true,
273 - 'style' => true,
274 - 'opacity' => true,
275 - 'fill' => true,
276 - 'stroke-width' => true,
277 - 'stroke-linecap' => true,
278 - 'stroke-linejoin' => true,
279 - )
280 - );
281 362
282 - if ( ! isset( $tags['g'] ) ) {
283 - $tags['g'] = array(
284 - 'transform' => true,
285 - 'clip-path' => true,
286 - );
287 - }
288 - if ( ! isset( $tags['clippath'] ) ) {
289 - $tags['clippath'] = array();
290 - }
291 - if ( ! isset( $tags['defs'] ) ) {
292 - $tags['defs'] = array();
293 - }
294 - if ( ! isset( $tags['rect'] ) ) {
295 - $tags['rect'] = array(
296 - 'rx' => true,
297 - 'height' => true,
298 - 'width' => true,
299 - 'transform' => true,
300 - 'x' => true,
301 - 'fill' => true,
302 - );
303 - }
304 - if ( ! isset( $tags['circle'] ) ) {
305 - $tags['circle'] = array(
306 - 'cx' => true,
307 - 'cy' => true,
308 - 'transform' => true,
309 - 'r' => true,
310 - );
311 - }
312 - if ( ! isset( $tags['polygon'] ) ) {
313 - $tags['polygon'] = array(
314 - 'points' => true,
315 - );
316 - }
317 - if ( ! isset( $tags['lineargradient'] ) ) {
318 - $tags['lineargradient'] = array(
319 - 'gradienttransform' => true,
320 - 'id' => true,
321 - );
322 - }
323 - if ( ! isset( $tags['stop'] ) ) {
324 - $tags['stop'] = array(
325 - 'offset' => true,
326 - 'stop-color' => true,
327 - 'style' => true,
328 - 'stop-opacity' => true,
329 - );
330 - }
331 - return $tags;
332 - }
363 + /**
364 + * Necessary Requires Class
365 + *
366 + * @since v.1.0.0
367 + * @return NULL
368 + */
369 + public function requires() {
370 + require_once ULTP_PATH.'classes/Notice.php';
371 + require_once ULTP_PATH.'classes/Styles.php';
372 + require_once ULTP_PATH.'classes/Options.php';
373 + require_once ULTP_PATH.'classes/REST_API.php';
374 + require_once ULTP_PATH.'classes/Caches.php';
375 + new \ULTP\REST_API();
376 + new \ULTP\Caches();
377 + new \ULTP\Options();
378 + new \ULTP\Styles();
379 + new \ULTP\Notice();
333 380
334 - /**
335 - * Plugin activation callback.
336 - *
337 - * @since v.1.1.0
338 - * @param STRING $plugin The plugin file path.
339 - * @return NULL No return value.
381 + require_once ULTP_PATH.'classes/Deactive.php';
382 + new \ULTP\Deactive();
383 + }
384 +
385 +
386 + /**
387 + * Block Categories Initialization
388 + *
389 + * @since v.1.0.0
390 + * @param $categories(ARRAY) | $post (ARRAY)
391 + * @return NULL
340 392 */
341 - public function ultp_plugin_activation( $plugin ) {
342 - if ( wp_doing_ajax() ) {
343 - return;
344 - }
345 - if ( $plugin == 'ultimate-post/ultimate-post.php' ) {
346 - if ( wp_doing_ajax() || is_network_admin() || isset( $_GET['activate-multi'] ) || isset( $_POST['action'] ) && 'activate-selected' == $_POST['action'] ) {
347 - return;
393 + public function register_category_callback( $categories, $post ) {
394 + return array_merge(
395 + array(
396 + array(
397 + 'slug' => 'ultimate-post',
398 + 'title' => __( 'PostX - Gutenberg Post Blocks', 'ultimate-post' )
399 + )
400 + ), $categories
401 + );
402 + }
403 +
404 +
405 + /**
406 + * Post View Counter for Every Post
407 + *
408 + * @since v.1.0.0
409 + * @param NUMBER | Post ID
410 + * @return NULL
411 + */
412 + public function popular_posts_tracker_callback($post_id) {
413 + if (!is_single()){ return; }
414 + global $post;
415 + $post_id = $post->ID;
416 + $isEnable = apply_filters('ultp_view_cookies', true);
417 + if ($post_id && $isEnable) {
418 + $has_cookie = isset( $_COOKIE['ultp_view_'.$post_id] ) ? $_COOKIE['ultp_view_'.$post_id] : false;
419 + if (!$has_cookie) {
420 + $count = (int)get_post_meta( $post_id, '__post_views_count', true );
421 + update_post_meta($post_id, '__post_views_count', $count ? (int)$count + 1 : 1 );
422 + setcookie( 'ultp_view_'.$post_id, 1, time() + 86400, COOKIEPATH ); // 1 days cookies
423 + }
424 + }
425 + }
426 +
427 +
428 + /**
429 + * Set Image Size
430 + *
431 + * @since v.1.0.0
432 + * @return NULL
433 + */
434 + public function add_image_size() {
435 + $size_disable = ultimate_post()->get_setting('disable_image_size');
436 + if ($size_disable != 'yes') {
437 + add_image_size('ultp_layout_landscape_large', 1200, 800, true);
438 + add_image_size('ultp_layout_landscape', 870, 570, true);
439 + add_image_size('ultp_layout_portrait', 600, 900, true);
440 + add_image_size('ultp_layout_square', 600, 600, true);
441 + }
442 + }
443 +
444 +
445 + /**
446 + * Include Addons Directory
447 + *
448 + * @since v.1.0.0
449 + * @return NULL
450 + */
451 + public function include_addons() {
452 + $addons_dir = array_filter(glob(ULTP_PATH.'addons/*'), 'is_dir');
453 + if (count($addons_dir) > 0) {
454 + foreach( $addons_dir as $key => $value ) {
455 + $addon_dir_name = str_replace(dirname($value).'/', '', $value);
456 + $file_name = ULTP_PATH . 'addons/'.$addon_dir_name.'/init.php';
457 + if ( file_exists($file_name) ) {
458 + include_once $file_name;
459 + }
348 460 }
349 - if ( ultimate_post()->get_setting( 'init_setup' ) != 'yes' ) {
350 - ultimate_post()->set_setting( 'init_setup', 'yes' );
351 - exit(wp_safe_redirect(admin_url('admin.php?page=ultp-setup-wizard'))); //phpcs:ignore
352 - } else {
353 - exit(wp_safe_redirect(admin_url('admin.php?page=ultp-settings#home'))); //phpcs:ignore
354 - }
355 461 }
356 - }
462 + }
357 463
358 - /**
359 - * Enqueue option panel CSS and JS scripts.
360 - *
361 - * @since v.1.0.0
362 - * @return void No return value.
464 +
465 + /**
466 + * Addon Callback
467 + *
468 + * @since v.1.0.0
469 + * @return STRING
363 470 */
364 - public function register_option_panel_scripts_callback() {
365 - $is_active = ultimate_post()->is_lc_active();
366 - $license_key = Xpo::get_lc_key();
367 - $_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; // @codingStandardsIgnoreLine
368 - $post_type = get_post_type();
471 + public function ultp_addon_callback() {
472 + if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
473 + return ;
474 + }
475 + $addon_name = sanitize_text_field($_POST['addon']);
476 + $addon_value = sanitize_text_field($_POST['value']);
477 + if ($addon_name && current_user_can('administrator')) {
478 + $addon_data = ultimate_post()->get_setting();
479 + $addon_data[$addon_name] = $addon_value;
480 + $GLOBALS['ultp_settings'][$addon_name] = $addon_value;
481 + update_option('ultp_options', $addon_data);
482 + }
483 + }
369 484
370 - wp_enqueue_style( 'wp-color-picker' );
371 - wp_enqueue_script( 'wp-color-picker' );
372 485
373 - wp_enqueue_script( 'ultp-option-script', ULTP_URL . 'assets/js/ultp-option.js', array( 'jquery' ), ULTP_VER, true );
374 - wp_enqueue_style( 'ultp-option-style', ULTP_URL . 'assets/css/ultp-option.css', array(), ULTP_VER );
375 - wp_localize_script(
376 - 'ultp-option-script',
377 - 'ultp_option_panel',
378 - array(
379 - 'url' => ULTP_URL,
380 - 'version' => ULTP_VER,
381 - 'active' => $is_active,
382 - 'security' => wp_create_nonce( 'ultp-nonce' ),
383 - 'ajax' => admin_url( 'admin-ajax.php' ),
384 - 'settings' => ultimate_post()->get_setting(),
385 - 'post_type' => $post_type,
386 - 'saved_template_url' => admin_url( 'admin.php?page=ultp-settings#saved-templates' ),
387 - )
388 - );
486 + /**
487 + * Next Preview Callback of the Blocks
488 + *
489 + * @since v.1.0.0
490 + * @return STRING
491 + */
492 + public function ultp_next_prev_callback() {
493 + if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
494 + return ;
495 + }
389 496
390 - if ( $post_type == 'ultp_custom_font' ) {
391 - $font_settings = ultimate_post()->get_setting( 'ultp_custom_font' );
392 - if ( $font_settings == 'true' ) {
393 - wp_enqueue_media();
394 - }
395 - }
497 + $paged = sanitize_text_field($_POST['paged']);
498 + $blockId = sanitize_text_field($_POST['blockId']);
499 + $postId = sanitize_text_field($_POST['postId']);
500 + $blockRaw = sanitize_text_field($_POST['blockName']);
501 + $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
502 +
503 + $blockName = str_replace('_','/', $blockRaw);
396 504
397 - /* === Installation Wizard === */
398 - if ( $_page == 'ultp-setup-wizard' ) {
399 - 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 );
400 - wp_set_script_translations( 'ultp-initial-setup-script', 'ultimate-post', ULTP_PATH . 'languages/' );
401 - }
505 + if( $paged && $blockId && $postId && $blockName ) {
506 + $post = get_post($postId);
507 + if (has_blocks($post->post_content)) {
508 + $blocks = parse_blocks($post->post_content);
509 + $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
510 + }
511 + }
512 + }
402 513
403 - /* === Builder And Setting Pannel === */
404 - if ( get_post_type( get_the_ID() ) == 'ultp_builder' ) {
405 - 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 );
406 - wp_localize_script(
407 - 'ultp-conditions-script',
408 - 'ultp_condition',
409 - array(
410 - 'url' => ULTP_URL,
411 - 'active' => $is_active,
412 - 'builder_url' => admin_url( 'admin.php?page=ultp-settings#builder' ),
413 - )
414 - );
415 - wp_set_script_translations( 'ultp-conditions-script', 'ultimate-post', ULTP_PATH . 'languages/' );
416 - }
417 514
418 - /* === Dashboard === */
419 - if ( $_page == 'ultp-settings' ) {
420 - 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 );
421 - $user_info = get_userdata( get_current_user_id() );
422 - wp_localize_script(
423 - 'ultp-dashboard-script',
424 - 'ultp_dashboard_pannel',
425 - array_merge(
426 - array(
427 - 'ajax' => admin_url( 'admin-ajax.php' ),
428 - 'security' => wp_create_nonce( 'ultp-nonce' ),
429 - 'url' => ULTP_URL,
430 - 'active' => $is_active,
431 - 'license' => $license_key,
432 - 'settings' => ultimate_post()->get_setting(),
433 - 'addons_settings' => apply_filters( 'ultp_settings', array() ),
434 - 'builder_url' => admin_url( 'admin.php?page=ultp-settings#builder' ),
435 - 'version' => ULTP_VER,
436 - 'setup_wizard_link' => admin_url( 'admin.php?page=ultp-setup-wizard' ),
437 - 'is_free' => ! $is_active,
438 - 'user_email' => wp_get_current_user()->user_email,
439 - 'home_url' => home_url(),
440 - 'generalDiscount' => get_transient( 'ultp_generalDiscount' ),
441 - 'helloBar' => Notice::get_hellobar_config(),
442 - 'userInfo' => array(
443 - 'name' => $user_info->first_name ? $user_info->first_name . ( $user_info->last_name ? ' ' . $user_info->last_name : '' ) : $user_info->user_login,
444 - 'email' => $user_info->user_email,
445 - ),
446 - ),
447 - Xpo::get_wow_products_details()
448 - )
449 - );
450 - wp_set_script_translations( 'ultp-dashboard-script', 'ultimate-post', ULTP_PATH . 'languages/' );
451 - }
452 - }
515 + /**
516 + * Filter Callback of the Blocks
517 + *
518 + * @since v.1.0.0
519 + * @return STRING
520 + */
521 + public function filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy) {
522 + foreach ($blocks as $key => $value) {
523 + if($blockName == $value['blockName']) {
524 + if($value['attrs']['blockId'] == $blockId) {
525 + $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
526 + if($taxonomy) {
527 + $value['attrs']['queryTaxValue'] = json_encode(array($taxonomy));
528 + $value['attrs']['queryTax'] = $taxtype;
529 + }
530 + if(isset($value['attrs']['queryNumber'])){
531 + $value['attrs']['queryNumber'] = $value['attrs']['queryNumber'];
532 + }
533 + $attr = array_merge($attr, $value['attrs']);
534 + echo $this->all_blocks[$blockRaw]->content($attr, true);
535 + die();
536 + }
537 + }
538 + if(!empty($value['innerBlocks'])){
539 + $this->filter_block_return($value['innerBlocks'], $blockId, $blockRaw, $blockName, $taxtype, $taxonomy);
540 + }
541 + }
542 + }
453 543
454 - /**
455 - * Enqueue backend CSS and JS scripts for the block editor.
456 - *
457 - * @since v.1.0.0
458 - * @return void No return value.
544 +
545 + /**
546 + * Filter Callback of the Blocks
547 + *
548 + * @since v.1.0.0
549 + * @return STRING
459 550 */
460 - public function register_block_scripts_editor_area() {
461 - ultimate_post()->register_scripts_common();
462 - global $pagenow;
463 - $depends = 'wp-editor';
464 - if ( $pagenow === 'widgets.php' ) {
465 - $depends = 'wp-edit-widgets';
466 - }
467 - 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 );
468 - wp_enqueue_style( 'ultp-blocks-editor-css', ULTP_URL . 'assets/css/blocks.editor.css', array(), ULTP_VER );
469 - if ( is_rtl() ) {
470 - wp_enqueue_style( 'ultp-blocks-editor-rtl-css', ULTP_URL . 'assets/css/rtl.css', array(), ULTP_VER );
471 - }
472 - $is_active = ultimate_post()->is_lc_active();
473 - $post_type = get_post_type();
551 + public function ultp_filter_callback() {
552 + if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local){
553 + return ;
554 + }
555 +
556 + $taxtype = sanitize_text_field($_POST['taxtype']);
557 + if( $taxtype ) {
558 + $blockId = sanitize_text_field($_POST['blockId']);
559 + $postId = sanitize_text_field($_POST['postId']);
560 + $taxonomy = sanitize_text_field($_POST['taxonomy']);
561 + $blockRaw = sanitize_text_field($_POST['blockName']);
562 + $blockName = str_replace('_','/', $blockRaw);
563 + $post = get_post($postId);
564 + if (has_blocks($post->post_content)) {
565 + $blocks = parse_blocks($post->post_content);
566 + $this->filter_block_return($blocks, $blockId, $blockRaw, $blockName, $taxtype, $taxonomy);
567 + }
568 + }
569 + }
474 570
475 - // Custom Font Support Added
476 - $font_settings = ultimate_post()->get_setting( 'ultp_custom_font' );
477 - $custom_fonts = array();
478 - if ( $font_settings == 'true' ) {
479 - $args = array(
480 - 'post_type' => 'ultp_custom_font',
481 - 'post_status' => 'publish',
482 - 'numberposts' => -1,
483 - 'order' => 'ASC',
484 - );
485 - $posts = get_posts( $args );
486 - if ( $posts ) {
487 - foreach ( $posts as $post ) {
488 - setup_postdata( $post );
489 - $font = get_post_meta( $post->ID, '__font_settings', true );
490 571
491 - if ( $font ) {
492 - array_push(
493 - $custom_fonts,
494 - array(
495 - 'title' => $post->post_title,
496 - 'font' => $font,
497 - )
498 - );
499 - }
500 - }
501 - wp_reset_postdata();
502 - }
503 - }
572 + /**
573 + * Pagination of the Blocks
574 + *
575 + * @since v.1.0.0
576 + * @return STRING
577 + */
578 + public function ultp_pagination_callback() {
579 + if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-nonce') && $local) {
580 + return ;
581 + }
504 582
505 - wp_localize_script(
506 - 'ultp-blocks-editor-script',
507 - 'ultp_data',
508 - array(
509 - 'url' => ULTP_URL,
510 - 'ajax' => admin_url( 'admin-ajax.php' ),
511 - 'security' => wp_create_nonce( 'ultp-nonce' ),
512 - 'hide_import_btn' => ultimate_post()->get_setting( 'hide_import_btn' ),
513 - 'premium_link' => Xpo::generate_utm_link(),
514 - 'license' => $is_active ? Xpo::get_lc_key() : '',
515 - 'active' => $is_active,
516 - 'archive' => ultimate_post()->is_archive_builder(),
517 - 'settings' => ultimate_post()->get_setting(),
518 - 'post_type' => $post_type == 'premade' ? 'ultp_builder' : $post_type, // premade used for ultp.wpxpo.com
519 - 'date_format' => get_option( 'date_format' ),
520 - 'time_format' => get_option( 'time_format' ),
521 - 'blog' => get_current_blog_id(),
522 - 'affiliate_id' => apply_filters( 'ultp_affiliate_id', false ),
523 - 'category_url' => admin_url( 'edit-tags.php?taxonomy=category' ),
524 - 'disable_image_size' => ultimate_post()->get_setting( 'disable_image_size' ),
525 - 'dark_logo' => get_option( 'ultp_site_dark_logo' ) ? get_option( 'ultp_site_dark_logo' ) : false,
526 - 'builder_url' => admin_url( 'admin.php?page=ultp-settings#builder' ),
527 - 'custom_fonts' => $custom_fonts,
528 - )
529 - );
530 - wp_set_script_translations( 'ultp-blocks-editor-script', 'ultimate-post', ULTP_PATH . 'languages/' );
531 - }
583 + $paged = sanitize_text_field($_POST['paged']);
584 + if($paged) {
585 + $blockId = sanitize_text_field($_POST['blockId']);
586 + $postId = sanitize_text_field($_POST['postId']);
587 + $blockRaw = sanitize_text_field($_POST['blockName']);
588 + $builder = isset($_POST['builder']) ? sanitize_text_field($_POST['builder']) : '';
589 + $blockName = str_replace('_','/', $blockRaw);
590 + $post = get_post($postId);
591 + if (has_blocks($post->post_content)) {
592 + $blocks = parse_blocks($post->post_content);
593 + $this->block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
594 + }
595 + }
596 + }
532 597
533 598
534 - /**
535 - * Fire when plugin is first installed.
536 - *
537 - * @since v.1.0.0
538 - * @return void No return value.
599 + /**
600 + * Blocks Content Start
601 + *
602 + * @since v.1.0.0
603 + * @return STRING
539 604 */
540 - public function plugin_activation_hook() {
541 - $data = get_option( 'ultp_options', array() );
542 - $currentDate = new \DateTime();
543 - $currentDate->setTime( 0, 0, 0, 0 );
544 - $init_data = array(
545 - 'preloader_style' => 'style1',
546 - 'preloader_color' => '#037fff',
547 - 'container_width' => '1140',
548 - 'hide_import_btn' => '',
549 - 'disable_image_size' => '',
550 - 'disable_view_cookies' => '',
551 - 'disable_google_font' => '',
552 - 'ultp_templates' => 'true',
553 - 'ultp_elementor' => 'true',
554 - 'ultp_table_of_content' => 'true',
555 - 'ultp_builder' => 'true',
556 - 'ultp_dynamic_content' => 'true',
557 - 'ultp_custom_font' => 'true',
558 - 'ultp_chatgpt' => 'true',
559 - 'post_grid_1' => 'yes',
560 - 'post_grid_2' => 'yes',
561 - 'post_grid_3' => 'yes',
562 - 'post_grid_4' => 'yes',
563 - 'post_grid_5' => 'yes',
564 - 'post_grid_6' => 'yes',
565 - 'post_grid_7' => 'yes',
566 - 'post_list_1' => 'yes',
567 - 'post_list_2' => 'yes',
568 - 'post_list_3' => 'yes',
569 - 'post_list_4' => 'yes',
570 - 'post_module_1' => 'yes',
571 - 'post_module_2' => 'yes',
572 - 'post_slider_1' => 'yes',
573 - 'post_slider_2' => 'yes',
574 - 'heading' => 'yes',
575 - 'image' => 'yes',
576 - 'taxonomy' => 'yes',
577 - 'wrapper' => 'yes',
578 - 'news_ticker' => 'yes',
579 - 'accordion' => 'yes',
580 - 'star_rating' => 'yes',
581 - 'youtube_gallery' => 'yes',
582 - 'builder_advance_post_meta' => 'yes',
583 - 'builder_archive_title' => 'yes',
584 - 'builder_author_box' => 'yes',
585 - 'builder_post_next_previous' => 'yes',
586 - 'builder_post_author_meta' => 'yes',
587 - 'builder_post_breadcrumb' => 'yes',
588 - 'builder_post_category' => 'yes',
589 - 'builder_post_comment_count' => 'yes',
590 - 'builder_post_comments' => 'yes',
591 - 'builder_post_content' => 'yes',
592 - 'builder_post_date_meta' => 'yes',
593 - 'builder_post_excerpt' => 'yes',
594 - 'builder_post_featured_image' => 'yes',
595 - 'builder_post_reading_time' => 'yes',
596 - 'builder_post_social_share' => 'yes',
597 - 'builder_post_tag' => 'yes',
598 - 'builder_post_title' => 'yes',
599 - 'builder_post_view_count' => 'yes',
600 - 'save_version' => wp_rand( 1, 1000 ),
601 - 'activated_date' => $currentDate->getTimestamp(),
602 - );
603 - if ( empty( $data ) ) {
604 - update_option( 'ultp_options', $init_data );
605 - $GLOBALS['ultp_settings'] = $init_data;
606 - } else {
607 - foreach ( $init_data as $key => $single ) {
608 - if ( ! isset( $data[ $key ] ) ) {
609 - $data[ $key ] = $single;
610 - }
611 - }
612 - update_option( 'ultp_options', $data );
613 - $GLOBALS['ultp_settings'] = $data;
614 - }
615 - if ( ! get_transient( 'wpxpo_installation_date' ) ) {
616 - set_transient( 'wpxpo_installation_date', 'yes', 5 * DAY_IN_SECONDS ); // 5 Days Notice
617 - }
618 - }
619 -}
605 + public function block_return($blocks, $paged, $blockId, $blockRaw, $blockName, $builder, $postId) {
606 + foreach ($blocks as $key => $value) {
607 + if($blockName == $value['blockName']) {
608 + if($value['attrs']['blockId'] == $blockId) {
609 + $attr = $this->all_blocks[$blockRaw]->get_attributes(true);
610 + $value['attrs']['paged'] = $paged;
611 + if ($builder) {
612 + $value['attrs']['builder'] = $builder;
613 + }
614 + if ($postId) {
615 + $attr['current_post'] = $postId;
616 + }
617 + $attr = array_merge($attr, $value['attrs']);
618 + echo $this->all_blocks[$blockRaw]->content($attr, true);
619 + die();
620 + }
621 + }
622 + if(!empty($value['innerBlocks'])){
623 + $this->block_return($value['innerBlocks'], $paged, $blockId, $blockRaw, $blockName, $builder, $postId);
624 + }
625 + }
626 + }
627 +
628 +}