PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.4
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.4
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / admin / import-export / batch-processing / divi-5 / class-wpfnl-divi5-source.php

class-wpfnl-divi5-source.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.4, at admin/import-export/batch-processing/divi-5/class-wpfnl-divi5-source.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Divi 5 template source / importer.
4 *
5 * Divi 5 stores page content as JSON blocks (WordPress block grammar) rather
6 * than shortcode strings. This class handles importing templates in that
7 * format and falls back to the plain-string path used by the D4 importer.
8 *
9 * @package WPFunnels\Batch\DiviV5
10 * @since 2.9.1
11 */
12
13 namespace WPFunnels\Batch\DiviV5;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 die( 'Direct access forbidden.' );
17 }
18
19 class Wpfnl_Divi5_Source {
20
21 /**
22 * Import a single Divi 5 template into a step post.
23 *
24 * @param int $step_id The wpfunnel_steps post ID to update.
25 * @param string|array $content Raw template content (JSON string or decoded array).
26 */
27 public function import_single_template( int $step_id, $content ): void {
28 // Decode if JSON string
29 if ( is_string( $content ) ) {
30 $decoded = json_decode( $content, true );
31 if ( json_last_error() === JSON_ERROR_NONE && is_array( $decoded ) ) {
32 $content = $decoded;
33 }
34 }
35
36 // Re-encode arrays back to JSON for storage
37 $post_content = is_array( $content )
38 ? wp_json_encode( $content )
39 : (string) $content;
40
41 wp_update_post(
42 [
43 'ID' => $step_id,
44 'post_content' => $post_content,
45 ]
46 );
47
48 // Clean up temp meta keys
49 delete_post_meta( $step_id, 'divi5_content' );
50 delete_post_meta( $step_id, 'divi_content' );
51 }
52 }
53