PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.1.3
Post Grid Gutenberg Blocks – PostX v4.1.3
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 / Compatibility.php

Compatibility.php in Post Grid Gutenberg Blocks – PostX 4.1.3, at classes/Compatibility.php

200 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compatibility Action.
4 *
5 * @package ULTP\Notice
6 * @since v.1.1.0
7 */
8
9 namespace ULTP;
10
11 defined('ABSPATH') || exit;
12
13 /**
14 * Compatibility class.
15 */
16 class Compatibility{
17
18 /**
19 * Setup class.
20 *
21 * @since v.1.1.0
22 */
23 public function __construct() {
24 add_action( 'upgrader_process_complete', array($this, 'plugin_upgrade_completed'), 10, 2 );
25 if (class_exists('KTP_Requirements_Check')) {
26 $this->handle_kadence_element();
27 }
28 // PublishPress Revisions Plugin Compatibility Add
29 add_action('revisionary_copy_postmeta', array($this, 'ultp_revisionary_copy_postmeta_callback'), 10, 3);
30 }
31
32
33 /**
34 * Compatibility for PublishPress Revisions Plugin
35 * @url https://wordpress.org/plugins/revisionary/
36 *
37 * @since v.2.9.8
38 */
39 public function ultp_revisionary_copy_postmeta_callback($from_post, $to_post_id, $args) {
40 global $wp_filesystem;
41 if (! $wp_filesystem ) {
42 require_once( ABSPATH . 'wp-admin/includes/file.php' );
43 WP_Filesystem();
44 }
45 $css_meta = get_post_meta( $to_post_id, '_ultp_css', true );
46 $upload_dir_url = wp_get_upload_dir();
47 $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] );
48 $css_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$to_post_id}.css";
49
50 if (file_exists( $css_dir_path )) {
51 $css = $wp_filesystem->get_contents($css_dir_path);
52 if ($css_meta != $css) {
53 $wp_filesystem->put_contents( $css_dir_path, $css_meta );
54 }
55 }
56 }
57
58
59 /**
60 * Compatibility to handle kadence element
61 *
62 * @since v.2.8.3
63 */
64 public function handle_kadence_element() {
65 $hook_lists = array(
66 'replace_header' => 'kadence_header',
67 'replace_footer' => 'kadence_footer',
68 'replace_hero_header' => 'kadence_hero_header',
69 'replace_404' => 'kadence_404_content',
70 'replace_single_content' => 'kadence_single_content',
71 'replace_loop_content' => 'kadence_loop_entry',
72 'woocommerce_before_single_product_image' => 'woocommerce_before_single_product_summary',
73 'woocommerce_after_single_product_image' => 'woocommerce_before_single_product_summary',
74 'replace_login_modal' => 'kadence_account_login_form',
75 'fixed_above_trans_header' => 'kadence_before_wrapper',
76 'fixed_above_header' => 'kadence_before_header',
77 'fixed_on_header' => 'kadence_after_wrapper',
78 'fixed_below_footer' => 'kadence_after_footer',
79 'fixed_on_footer' => 'kadence_after_wrapper',
80 'fixed_on_footer_scroll' => 'kadence_after_wrapper',
81 'fixed_on_footer_scroll_space' => 'kadence_after_wrapper',
82 );
83 $args = array(
84 'post_type' => 'kadence_element',
85 'no_found_rows' => true,
86 'update_post_term_cache' => false,
87 'post_status' => 'publish',
88 'numberposts' => 333,
89 'order' => 'ASC',
90 'orderby' => 'menu_order',
91 'suppress_filters' => false,
92 );
93
94 $posts = get_posts( $args );
95 foreach( $posts as $post) {
96 $post_id = $post->ID;
97 $post_hook_meta = get_post_meta($post_id , ( get_post_meta($post_id , '_kad_element_hook', true) == 'custom' ? '_kad_element_hook_custom' : '_kad_element_hook' ), true);
98 if ( $post_hook_meta ) {
99 $selected_hook = isset($hook_lists[$post_hook_meta]) ? $hook_lists[$post_hook_meta] : $post_hook_meta;
100 add_action($selected_hook , function() use (&$post_id) {
101 ultimate_post()->register_scripts_common();
102 ultimate_post()->set_css_style($post_id);
103 });
104 }
105 }
106 }
107
108 /**
109 * Compatibility Class Run after Plugin Upgrade
110 *
111 * @since v.1.1.0
112 */
113 public function plugin_upgrade_completed( $upgrader_object, $options ) {
114 if ($options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] )) {
115 foreach( $options['plugins'] as $plugin ) {
116 if ($plugin == ULTP_BASE ) {
117 $set_settings = array(
118 'disable_view_cookies' => '',
119 'disable_google_font' => '',
120 'ultp_category' => 'false',
121 'ultp_templates' => 'true',
122 'ultp_elementor' => 'true',
123 'ultp_table_of_content' => 'true',
124 'ultp_builder' => 'true',
125 'ultp_custom_font' => 'true',
126 'ultp_chatgpt' => 'true',
127 'post_grid_1' => 'yes',
128 'post_grid_2' => 'yes',
129 'post_grid_3' => 'yes',
130 'post_grid_4' => 'yes',
131 'post_grid_5' => 'yes',
132 'post_grid_6' => 'yes',
133 'post_grid_7' => 'yes',
134 'post_list_1' => 'yes',
135 'post_list_2' => 'yes',
136 'post_list_3' => 'yes',
137 'post_list_4' => 'yes',
138 'post_module_1' => 'yes',
139 'post_module_2' => 'yes',
140 'post_slider_1' => 'yes',
141 'post_slider_2' => 'yes',
142 'heading' => 'yes',
143 'image' => 'yes',
144 'taxonomy' => 'yes',
145 'wrapper' => 'yes',
146 'news_ticker' => 'yes',
147 'builder_advance_post_meta' => 'yes',
148 'builder_archive_title' => 'yes',
149 'builder_author_box' => 'yes',
150 'builder_post_next_previous'=> 'yes',
151 'builder_post_author_meta' => 'yes',
152 'builder_post_breadcrumb' => 'yes',
153 'builder_post_category' => 'yes',
154 'builder_post_comment_count'=> 'yes',
155 'builder_post_comments' => 'yes',
156 'builder_post_content' => 'yes',
157 'builder_post_date_meta' => 'yes',
158 'builder_post_excerpt' => 'yes',
159 'builder_post_featured_image'=> 'yes',
160 'builder_post_reading_time' => 'yes',
161 'builder_post_social_share' => 'yes',
162 'builder_post_tag' => 'yes',
163 'builder_post_title' => 'yes',
164 'builder_post_view_count' => 'yes',
165 'save_version' => wp_rand(1, 1000)
166 );
167 $addon_data = ultimate_post()->get_setting();
168 foreach ($set_settings as $key => $value) {
169 if (!isset($addon_data[$key])) {
170 ultimate_post()->set_setting($key, $value);
171 }
172 }
173
174
175 // License Check And Active
176 if (defined('ULTP_PRO_VER')) {
177 $license = get_option( 'edd_ultp_license_key' );
178 $response = wp_remote_post(
179 'https://account.wpxpo.com',
180 array(
181 'timeout' => 15,
182 'sslverify' => false,
183 'body' => array(
184 'edd_action' => 'activate_license',
185 'license' => $license,
186 'item_id' => 181,
187 'url' => home_url()
188 )
189 )
190 );
191 if (!is_wp_error( $response ) && 200 == wp_remote_retrieve_response_code( $response ) ) {
192 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
193 update_option( 'edd_ultp_license_status', $license_data->license );
194 }
195 }
196 }
197 }
198 }
199 }
200 }