PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
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 / modules / gutenberg / classes / class-cartflows-init-blocks.php

class-cartflows-init-blocks.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.3.0, at modules/gutenberg/classes/class-cartflows-init-blocks.php

600 lines 21.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cartflows Blocks Initializer
4 *
5 * Enqueue CSS/JS of all the blocks.
6 *
7 * @since 1.6.15
8 * @package Cartflows
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Cartflows_Init_Blocks.
17 *
18 * @package Cartflows
19 */
20 class Cartflows_Init_Blocks {
21
22 /**
23 * Member Variable
24 *
25 * @var instance
26 */
27 private static $instance;
28
29 /**
30 * Store Json variable
31 *
32 * @since 1.8.1
33 * @var instance
34 */
35 public static $icon_json;
36
37 /**
38 * Initiator
39 */
40 public static function get_instance() {
41 if ( ! isset( self::$instance ) ) {
42 self::$instance = new self();
43 }
44 return self::$instance;
45 }
46
47 /**
48 * Constructor
49 */
50 public function __construct() {
51
52 // Hook: Frontend assets.
53 add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) );
54
55 // Hook: Editor assets.
56 add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ) );
57
58 if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
59 add_filter( 'block_categories_all', array( $this, 'register_block_category' ), 10, 2 );
60 } else {
61 add_filter( 'block_categories', array( $this, 'register_block_category' ), 10, 2 );
62 }
63
64 add_action( 'wp_ajax_wpcf_order_detail_form_shortcode', array( $this, 'order_detail_form_shortcode' ) );
65 add_action( 'wp_ajax_wpcf_order_checkout_form_shortcode', array( $this, 'order_checkout_form_shortcode' ) );
66 add_action( 'wp_ajax_wpcf_optin_form_shortcode', array( $this, 'optin_form_shortcode' ) );
67
68 // Demo order details are scoped to the editor preview request in
69 // order_detail_form_shortcode(), which is nonce- and capability-checked. Registering
70 // the filter here as well applied it to every request, front end included, so an
71 // administrator opening a live thank-you page without an order parameter was shown
72 // the store's most recent real order.
73
74 add_action( 'enqueue_block_editor_assets', array( $this, 'add_gcp_vars_to_block_editor' ), 12 );
75
76 // Load the action only if the theme.json file is present in the file.
77 if ( wp_theme_has_theme_json() ) {
78 add_filter( 'wp_theme_json_data_theme', array( $this, 'update_theme_json_file_config' ) );
79 }
80 }
81
82 /**
83 * Add CartFlows GCP css vars to the theme's theme.json file if it is present.
84 *
85 * Use-case: Some themes adds the theme.json file in the theme's root directory. Due to this change, it overrides the default color pallet.
86 * and the filter which are using to add the CSS vars in the Gutenberg does not works and hence, we have to re-add and append it to the theme.json file.
87 *
88 * Note: If theme.json is not present then this filter will not be executed.
89 *
90 * @param WP_Theme_JSON_Data $theme_json_data The Data from the theme.json file.
91 * @return WP_Theme_JSON_Data $theme_json_data Modified data of theme.json file.
92 *
93 * @since 2.0.0
94 */
95 public function update_theme_json_file_config( $theme_json_data ) {
96 $theme_json_data_two = $theme_json_data->get_data();
97
98 $post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
99 $flow_id = wcf()->utils->get_flow_id_from_step_id( $post_id );
100
101 if (
102 ! empty( $flow_id ) &&
103 Cartflows_Helper::is_gcp_styling_enabled( (int) $flow_id ) &&
104 isset( $theme_json_data_two['settings'] ) &&
105 isset( $theme_json_data_two['settings']['color'] )
106 ) {
107
108 $new_color_palette = Cartflows_Helper::generate_css_var_array( $flow_id );
109
110 if ( ! empty( $new_color_palette ) ) {
111 $theme_color_pallet = ! empty( $theme_json_data_two['settings']['color']['palette']['theme'] ) ? $theme_json_data_two['settings']['color']['palette']['theme'] : array();
112 $theme_json_data_two['settings']['color']['palette']['theme'] = ! empty( $theme_color_pallet ) ? array_merge( $theme_color_pallet, $new_color_palette ) : $new_color_palette;
113 }
114 }
115
116 return $theme_json_data->update_with( $theme_json_data_two );
117 }
118
119 /**
120 * Enqueue the Global Color Pallet CSS vars to the page to use in the page builder settings.
121 * This CSS vars needs to be re-added so as to enqueue in the block editor to display the colors in the editor window.
122 *
123 * Note: Currently the GCP support is added for Elementor and Block Builder.
124 *
125 * @since 2.0.0
126 * @return void
127 */
128 public function add_gcp_vars_to_block_editor() {
129
130 // Call the same function which generates the inline styles i:e the CSS VARs with the selected values.
131 wcf()->flow->enqueue_gcp_color_vars( 'CF_block-cartflows-frontend-style' );
132
133 }
134
135 /**
136 * Renders the Order Detail Form shortcode.
137 *
138 * @since 1.6.15
139 */
140 public function order_detail_form_shortcode() {
141
142 check_ajax_referer( 'wpcf_ajax_nonce', 'nonce' );
143
144 if ( ! current_user_can( 'cartflows_manage_flows_steps' ) ) {
145 wp_send_json_error( array( 'message' => __( 'Permission denied.', 'cartflows' ) ) );
146 }
147
148 add_filter(
149 'cartflows_show_demo_order_details',
150 function() {
151 return true;
152 }
153 );
154
155 if ( ! empty( $_POST['thanyouText'] ) ) {
156
157 add_filter(
158 'cartflows_thankyou_meta_wcf-tq-text',
159 function( $text ) {
160 check_ajax_referer( 'wpcf_ajax_nonce', 'nonce' );
161
162 $text = isset( $_POST['thanyouText'] ) ? sanitize_text_field( wp_unslash( $_POST['thanyouText'] ) ) : '';
163
164 return $text;
165 },
166 10,
167 1
168 );
169 }
170
171 add_filter(
172 'cartflows_thankyou_meta_wcf-tq-layout',
173 function( $layout ) {
174 check_ajax_referer( 'wpcf_ajax_nonce', 'nonce' );
175
176 $layout = isset( $_POST['layout'] ) ? sanitize_title( wp_unslash( $_POST['layout'] ) ) : '';
177 return $layout;
178 },
179 10,
180 1
181 );
182
183 $thankyou_id = isset( $_POST['id'] ) ? intval( wp_unslash( $_POST['id'] ) ) : 0;
184 $data['html'] = do_shortcode( '[cartflows_order_details]' );
185 $data['thankyouText'] = wcf()->options->get_thankyou_meta_value( $thankyou_id, 'wcf-tq-text' );
186 $data['layout'] = wcf()->options->get_thankyou_meta_value( $thankyou_id, 'wcf-tq-layout' );
187
188 wp_send_json_success( $data );
189 }
190
191 /**
192 * Renders the Order Checkout Form shortcode.
193 *
194 * @since 1.6.15
195 */
196 public function order_checkout_form_shortcode() {
197 check_ajax_referer( 'wpcf_ajax_nonce', 'nonce' );
198
199 if ( ! current_user_can( 'cartflows_manage_flows_steps' ) ) {
200 wp_send_json_error( array( 'message' => __( 'Permission denied.', 'cartflows' ) ) );
201 }
202
203 add_filter(
204 'cartflows_show_demo_checkout',
205 function() {
206 return true;
207 }
208 );
209
210 if ( isset( $_POST['id'] ) ) {
211 $checkout_id = intval( $_POST['id'] );
212 }
213
214 $store_checkout = intval( \Cartflows_Helper::get_global_setting( '_cartflows_store_checkout' ) );
215
216 $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
217
218 if ( ! wcf()->flow->is_flow_testmode( $flow_id ) && ( $store_checkout !== $flow_id ) ) {
219
220 $products = wcf()->utils->get_selected_checkout_products( $checkout_id );
221
222 if ( ! is_array( $products ) || empty( $products[0]['product'] ) ) {
223 wc_clear_notices();
224 wc_add_notice( __( 'No product is selected. Please select products from the checkout meta settings to continue.', 'cartflows' ), 'error' );
225 }
226 }
227 remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
228
229 add_action( 'woocommerce_checkout_order_review', array( Cartflows_Checkout_Markup::get_instance(), 'display_custom_coupon_field' ) );
230
231 $attributes['layout'] = isset( $_POST['layout'] ) ? sanitize_title( wp_unslash( $_POST['layout'] ) ) : '';
232 $attributes['orderBumpSkin'] = isset( $_POST['orderBumpSkin'] ) ? sanitize_title( wp_unslash( $_POST['orderBumpSkin'] ) ) : '';
233 $attributes['orderBumpCheckboxArrow'] = isset( $_POST['orderBumpCheckboxArrow'] ) ? sanitize_title( wp_unslash( $_POST['orderBumpCheckboxArrow'] ) ) : '';
234 $attributes['orderBumpCheckboxArrowAnimation'] = isset( $_POST['orderBumpCheckboxArrowAnimation'] ) ? sanitize_title( wp_unslash( $_POST['orderBumpCheckboxArrowAnimation'] ) ) : '';
235 $attributes['sectionposition'] = isset( $_POST['sectionposition'] ) ? sanitize_title( wp_unslash( $_POST['sectionposition'] ) ) : '';
236 $attributes['productOptionsSkin'] = isset( $_POST['productOptionsSkin'] ) ? sanitize_title( wp_unslash( $_POST['productOptionsSkin'] ) ) : '';
237 $attributes['productOptionsImages'] = isset( $_POST['productOptionsImages'] ) ? sanitize_title( wp_unslash( $_POST['productOptionsImages'] ) ) : '';
238 $attributes['productOptionsSectionTitleText'] = isset( $_POST['productOptionsSectionTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['productOptionsSectionTitleText'] ) ) : '';
239 $attributes['PreSkipText'] = isset( $_POST['PreSkipText'] ) ? sanitize_title( wp_unslash( $_POST['PreSkipText'] ) ) : '';
240 $attributes['PreOrderText'] = isset( $_POST['PreOrderText'] ) ? sanitize_title( wp_unslash( $_POST['PreOrderText'] ) ) : '';
241 $attributes['PreProductTitleText'] = isset( $_POST['PreProductTitleText'] ) ? sanitize_title( wp_unslash( $_POST['PreProductTitleText'] ) ) : '';
242 $attributes['preSubTitleText'] = isset( $_POST['preSubTitleText'] ) ? sanitize_title( wp_unslash( $_POST['preSubTitleText'] ) ) : '';
243 $attributes['preTitleText'] = isset( $_POST['preTitleText'] ) ? sanitize_title( wp_unslash( $_POST['preTitleText'] ) ) : '';
244 $attributes['PreProductDescText'] = isset( $_POST['PreProductDescText'] ) ? sanitize_title( wp_unslash( $_POST['PreProductDescText'] ) ) : '';
245 $attributes['inputSkins'] = isset( $_POST['inputSkins'] ) ? sanitize_title( wp_unslash( $_POST['inputSkins'] ) ) : '';
246 $attributes['enableNote'] = isset( $_POST['enableNote'] ) ? sanitize_title( wp_unslash( $_POST['enableNote'] ) ) : '';
247 $attributes['noteText'] = isset( $_POST['noteText'] ) ? sanitize_text_field( wp_unslash( $_POST['noteText'] ) ) : '';
248 $attributes['stepOneTitleText'] = isset( $_POST['stepOneTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['stepOneTitleText'] ) ) : '';
249 $attributes['stepOneSubTitleText'] = isset( $_POST['stepOneSubTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['stepOneSubTitleText'] ) ) : '';
250 $attributes['stepTwoTitleText'] = isset( $_POST['stepTwoTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['stepTwoTitleText'] ) ) : '';
251 $attributes['stepTwoSubTitleText'] = isset( $_POST['stepTwoSubTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['stepTwoSubTitleText'] ) ) : '';
252 $attributes['offerButtonTitleText'] = isset( $_POST['offerButtonTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['offerButtonTitleText'] ) ) : '';
253 $attributes['offerButtonSubTitleText'] = isset( $_POST['offerButtonSubTitleText'] ) ? sanitize_text_field( wp_unslash( $_POST['offerButtonSubTitleText'] ) ) : '';
254
255 $checkout_fields = array(
256 // Input Fields.
257 array(
258 'filter_slug' => 'wcf-fields-skins',
259 'setting_name' => 'inputSkins',
260 ),
261 array(
262 'filter_slug' => 'wcf-checkout-layout',
263 'setting_name' => 'layout',
264 ),
265 );
266
267 if ( isset( $checkout_fields ) && is_array( $checkout_fields ) ) {
268
269 foreach ( $checkout_fields as $key => $field ) {
270
271 $setting_name = $field['setting_name'];
272
273 if ( '' !== $attributes[ $setting_name ] ) {
274
275 add_filter(
276 'cartflows_checkout_meta_' . $field['filter_slug'],
277 function ( $value ) use ( $setting_name, $attributes ) {
278
279 $value = $attributes[ $setting_name ];
280
281 return $value;
282 },
283 10,
284 1
285 );
286 }
287 }
288 }
289 do_action( 'cartflows_gutenberg_before_checkout_shortcode', $checkout_id );
290
291 do_action( 'cartflows_gutenberg_checkout_options_filters', $attributes );
292
293 do_action( 'cartflows_gutenberg_before_checkout_shortcode' );
294
295 $data['html'] = do_shortcode( '[cartflows_checkout]' );
296
297 wp_send_json_success( $data );
298 }
299
300 /**
301 * Renders the Optin Form shortcode.
302 *
303 * @since 1.6.15
304 */
305 public function optin_form_shortcode() {
306
307 check_ajax_referer( 'wpcf_ajax_nonce', 'nonce' );
308
309 if ( ! current_user_can( 'cartflows_manage_flows_steps' ) ) {
310 wp_send_json_error( array( 'message' => __( 'Permission denied.', 'cartflows' ) ) );
311 }
312
313 add_filter(
314 'cartflows_show_demo_optin_form',
315 function() {
316 return true;
317 }
318 );
319
320 if ( isset( $_POST['id'] ) ) {
321 $optin_id = intval( $_POST['id'] );
322 }
323
324 $products = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-optin-product' );
325 if ( is_array( $products ) && count( $products ) < 1 ) {
326 wc_clear_notices();
327 wc_add_notice( __( 'No product is selected. Please select a Simple, Virtual and Free product from the meta settings.', 'cartflows' ), 'error' );
328 }
329
330 $attributes['input_skins'] = isset( $_POST['input_skins'] ) ? sanitize_title( wp_unslash( $_POST['input_skins'] ) ) : '';
331
332 $optin_fields = array(
333
334 // Input Fields.
335 array(
336 'filter_slug' => 'wcf-input-fields-skins',
337 'setting_name' => 'input_skins',
338 ),
339 );
340
341 if ( isset( $optin_fields ) && is_array( $optin_fields ) ) {
342
343 foreach ( $optin_fields as $key => $field ) {
344
345 $setting_name = $field['setting_name'];
346
347 add_filter(
348 'cartflows_optin_meta_' . $field['filter_slug'],
349 function ( $value ) use ( $setting_name, $attributes ) {
350
351 $value = $attributes[ $setting_name ];
352
353 return $value;
354 },
355 10,
356 1
357 );
358 }
359 }
360
361 do_action( 'cartflows_gutenberg_optin_options_filters', $attributes );
362
363 add_filter( 'woocommerce_cart_needs_payment', '__return_false' );
364 add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
365 add_filter( 'woocommerce_cart_needs_shipping_address', '__return_false' );
366
367 $data['html'] = do_shortcode( '[cartflows_optin]' );
368 $data['buttonText'] = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-submit-button-text' );
369 wp_send_json_success( $data );
370 }
371
372 /**
373 * Enqueue Gutenberg block assets for both frontend + backend.
374 *
375 * @since 1.6.15
376 */
377 public function block_assets() {
378
379 global $post;
380
381 if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
382
383 // Register block styles for both frontend + backend.
384 wp_enqueue_style(
385 'CF_block-cartflows-style-css', // Handle.
386 CARTFLOWS_URL . 'modules/gutenberg/build/style-blocks.css',
387 is_admin() ? array( 'wp-editor' ) : null, // Dependency to include the CSS after it.
388 CARTFLOWS_VER // filemtime( plugin_dir_path( __DIR__ ) . 'build/style-blocks.css' ) // Version: File modification time.
389 );
390
391 $flow_id = wcf()->utils->get_flow_id_from_step_id( $post->ID );
392
393 // Return if no flow ID is found.
394 if ( empty( $flow_id ) ) {
395 return;
396 }
397
398 if ( Cartflows_Helper::is_gcp_styling_enabled( (int) $flow_id ) ) {
399
400 $gcp_vars = Cartflows_Helper::generate_gcp_css_style( (int) $flow_id );
401
402 // Include the CSS/JS only if the CSS vars are set.
403 if ( ! empty( $gcp_vars ) ) {
404 // Add editor helper css & JS files.
405 wp_enqueue_style( 'wcf-editor-helper-style', CARTFLOWS_URL . 'modules/gutenberg/assets/css/editor-assets.css', array( 'wp-edit-blocks', 'wp-editor' ), CARTFLOWS_VER );
406 wp_enqueue_script( 'wcf-editor-helper-script', CARTFLOWS_URL . 'modules/gutenberg/assets/js/editor-assets.js', array( 'wp-editor', 'jquery' ), CARTFLOWS_VER, true );
407 }
408 }
409 }
410
411 }
412
413 /**
414 * Enqueue assets for both backend.
415 *
416 * @since 1.6.15
417 */
418 public function editor_assets() {
419
420 $post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : 0; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
421 $post_type = get_post_type( $post_id );
422
423 if ( CARTFLOWS_STEP_POST_TYPE === $post_type ) {
424
425 $wpcf_ajax_nonce = wp_create_nonce( 'wpcf_ajax_nonce' );
426 $step_type = wcf()->utils->get_step_type( $post_id );
427 $show_checkout_pro_opt = apply_filters( 'cartflows_show_checkout_pro_opt', false );
428
429 if ( 'optin' === $step_type && wcf()->is_woo_active ) {
430 wp_enqueue_style( 'wcf-optin-template', wcf()->utils->get_css_url( 'optin-template' ), array( 'wp-edit-blocks' ), CARTFLOWS_VER );
431 }
432 if ( 'checkout' === $step_type && wcf()->is_woo_active ) {
433 wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), array( 'wp-edit-blocks' ), CARTFLOWS_VER );
434 Cartflows_Checkout_Markup::get_instance()->shortcode_scripts();
435 }
436
437 $script_dep_path = CARTFLOWS_DIR . 'modules/gutenberg/build/blocks.asset.php';
438 $script_info = file_exists( $script_dep_path )
439 ? include $script_dep_path
440 : array(
441 'dependencies' => array(),
442 'version' => CARTFLOWS_VER,
443 );
444 $script_dep = array_merge( $script_info['dependencies'], array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) );
445 $script_ver = $script_info['version'];
446
447 // Register block editor script for backend.
448 wp_register_script(
449 'CF_block-cartflows-block-js', // Handle.
450 CARTFLOWS_URL . 'modules/gutenberg/build/blocks.js',
451 $script_dep, // Dependencies, defined above.
452 $script_ver, // Version: filemtime — Gets file modification time.
453 true // Enqueue the script in the footer.
454 );
455
456 wp_set_script_translations( 'CF_block-cartflows-block-js', 'cartflows' );
457
458 // Register block editor styles for backend.
459 wp_register_style(
460 'CF_block-cartflows-block-editor-css', // Handle.
461 CARTFLOWS_URL . 'modules/gutenberg/build/blocks.style.css',
462 array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
463 CARTFLOWS_VER // Version: File modification time.
464 );
465
466 // Common Editor style.
467 wp_enqueue_style(
468 'CF_block-common-editor-css', // Handle.
469 CARTFLOWS_URL . 'modules/gutenberg/dist/editor.css',
470 array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
471 CARTFLOWS_VER // Version: File modification time.
472 );
473
474 // Enqueue frontend CSS in editor.
475 wp_enqueue_style( 'CF_block-cartflows-frontend-style', CARTFLOWS_URL . 'assets/css/frontend.css', array( 'wp-edit-blocks' ), CARTFLOWS_VER );
476
477 // WP Localized globals. Use dynamic PHP stuff in JavaScript via `cartflowsGlobal` object.
478 wp_localize_script(
479 'CF_block-cartflows-block-js',
480 'cf_blocks_info', // Array containing dynamic data for a JS Global.
481 array(
482 'pluginDirPath' => plugin_dir_path( __DIR__ ),
483 'pluginDirUrl' => plugin_dir_url( __DIR__ ),
484 'category' => 'cartflows',
485 'ajax_url' => admin_url( 'admin-ajax.php' ),
486 'wpcf_ajax_nonce' => $wpcf_ajax_nonce,
487 'blocks' => Cartflows_Block_Config::get_block_attributes(),
488 'tablet_breakpoint' => CF_TABLET_BREAKPOINT,
489 'mobile_breakpoint' => CF_MOBILE_BREAKPOINT,
490 'show_checkout_pro_opt' => $show_checkout_pro_opt,
491 'ID' => $post_id,
492 'step_type' => $step_type,
493 'is_cartflows_pro_install' => _is_cartflows_pro(),
494 'is_woo_active' => wcf()->is_woo_active,
495 'wcf_svg_icons' => $this->backend_load_font_awesome_icons(),
496 'show_product_options' => $this->maybe_show_product_options_for_store_checkout( $post_id ),
497 // Add more data here that you want to access from `cartflowsGlobal` object.
498 )
499 );
500
501 /**
502 * Register Gutenberg block on server-side.
503 *
504 * Register the block on server-side to ensure that the block
505 * scripts and styles for both frontend and backend are
506 * enqueued when the editor loads.
507 *
508 * @link https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type#enqueuing-block-scripts
509 * @since 1.6.15
510 */
511 register_block_type(
512 'wcfb/next-step-button',
513 array(
514 // Enqueue blocks.js in the editor only.
515 'editor_script' => 'CF_block-cartflows-block-js',
516 // Enqueue blocks.css in the editor only.
517 'style' => 'CF_block-cartflows-block-editor-css',
518 // Enqueue blocks.commoneditorstyle.build.css in the editor only.
519 'editor_style' => 'CF_block-common-editor-css',
520 )
521 );
522
523 }
524 }
525
526 /**
527 * Maybe show product options.
528 *
529 * @param int $step_id step id.
530 * @return bool
531 */
532 public function maybe_show_product_options_for_store_checkout( $step_id ) {
533
534 $flow_id = (int) wcf()->utils->get_flow_id_from_step_id( $step_id );
535 $store_checkout = intval( get_option( '_cartflows_store_checkout', false ) );
536
537 if ( $flow_id !== $store_checkout ) {
538 return true;
539
540 }
541
542 if ( $flow_id === $store_checkout && Cartflows_Helper::display_product_tab_in_store_checkout() ) {
543 return true;
544 }
545
546 return false;
547
548 }
549
550 /**
551 * Get Json Data.
552 *
553 * @since 1.8.1
554 * @return Array
555 */
556 public function backend_load_font_awesome_icons() {
557
558 $json_file = CARTFLOWS_DIR . 'modules/gutenberg/src/controls/spectra-icons-v6.php';
559
560 if ( ! file_exists( $json_file ) ) {
561 return array();
562 }
563
564 // Function has already run.
565 if ( null !== self::$icon_json ) {
566 return self::$icon_json;
567 }
568
569 self::$icon_json = include $json_file;
570
571 return self::$icon_json;
572 }
573
574 /**
575 * Gutenberg block category for WCFB.
576 *
577 * @param array $categories Block categories.
578 * @param object $post Post object.
579 * @since 1.6.15
580 */
581 public function register_block_category( $categories, $post ) {
582 return array_merge(
583 $categories,
584 array(
585 array(
586 'slug' => 'cartflows',
587 'title' => __( 'Cartflows', 'cartflows' ),
588 ),
589 )
590 );
591 }
592
593 }
594
595 /**
596 * Prepare if class 'Cartflows_Init_Blocks' exist.
597 * Kicking this off by calling 'get_instance()' method
598 */
599 Cartflows_Init_Blocks::get_instance();
600