PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.15
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.15
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / batch-process / class-cartflows-importer-divi.php

class-cartflows-importer-divi.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.15, at classes/batch-process/class-cartflows-importer-divi.php

117 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Divi Importer
4 *
5 * @package CartFlows
6 * @since 1.1.1
7 */
8
9 if ( ! class_exists( 'CartFlows_Importer_Divi' ) ) :
10
11 /**
12 * CartFlows Import Divi
13 *
14 * @since 1.1.1
15 */
16 class CartFlows_Importer_Divi {
17
18 /**
19 * Instance
20 *
21 * @since 1.1.1
22 * @access private
23 * @var object Class object.
24 */
25 private static $instance;
26
27 /**
28 * Initiator
29 *
30 * @since 1.1.1
31 * @return object initialized object of class.
32 */
33 public static function get_instance() {
34
35 if ( ! isset( self::$instance ) ) {
36 self::$instance = new self;
37 }
38 return self::$instance;
39 }
40
41 /**
42 * Constructor
43 *
44 * @since 1.1.1
45 */
46 public function __construct() {}
47
48 /**
49 * Allowed tags for the batch update process
50 *
51 * @since x.x.x
52 *
53 * @param array $allowedposttags Array of default allowable HTML tags.
54 * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
55 * 'strip', 'data', 'entities', or the name of a field filter such as
56 * 'pre_user_description'.
57 * @return array Array of allowed HTML tags and their allowed attributes.
58 */
59 function allowed_tags_and_attributes( $allowedposttags, $context ) {
60
61 // Keep only for 'post' contenxt.
62 if ( 'post' === $context ) {
63
64 // <style> tag and attributes.
65 $allowedposttags['style'] = array();
66 }
67
68 return $allowedposttags;
69 }
70
71 /**
72 * Update post meta.
73 *
74 * @param integer $post_id Post ID.
75 * @return void
76 */
77 public function import_single_post( $post_id = 0 ) {
78
79 // Allow the SVG tags in batch update process.
80 add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
81
82 // Download and replace images.
83 $content = get_post_meta( $post_id, 'divi_content', true );
84
85 if ( empty( $content ) ) {
86 wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
87 } else {
88
89 wcf()->logger->import_log( '(✓) Processing Request..' );
90
91 // Update hotlink images.
92 $content = CartFlows_Importer::get_instance()->get_content( $content );
93
94 // Update post content.
95 wp_update_post(
96 array(
97 'ID' => $post_id,
98 'post_content' => $content,
99 )
100 );
101
102 // Delete temporary meta key.
103 delete_post_meta( $post_id, 'divi_content' );
104
105 wcf()->logger->import_log( '(✓) Process Complete' );
106 }
107 }
108
109 }
110
111 /**
112 * Initialize class object with 'get_instance()' method
113 */
114 CartFlows_Importer_Divi::get_instance();
115
116 endif;
117