post_content; if ( has_shortcode( $content, 'dayslot_checkout_field' ) || ( function_exists( 'has_block' ) && has_block( 'dayslot/checkout-field', $post ) ) ) { $memo = true; } elseif ( false !== strpos( (string) get_post_meta( $post->ID, '_elementor_data', true ), '"widgetType":"dys-checkout-field"' ) ) { $memo = true; } } $memo = (bool) apply_filters( 'dayslot_manual_placement', $memo, $post ); return $memo; } /** * Output of the shortcode, block and widget. */ function dayslot_checkout_field_html() { if ( ! dayslot_is_checkout_page() || ! dayslot_cart_needs_date() ) { return ''; } ob_start(); dayslot_render_box( true ); return (string) ob_get_clean(); } add_action( 'init', function () { add_shortcode( 'dayslot_checkout_field', 'dayslot_checkout_field_html' ); add_shortcode( 'edc_checkout_field', 'dayslot_checkout_field_html' ); // Old name (Event Date Calendar). if ( function_exists( 'register_block_type' ) ) { wp_register_script( 'dys-block-editor', dayslot_asset( 'assets/block-editor.js' ), array( 'wp-blocks', 'wp-element', 'wp-i18n' ), DAYSLOT_VERSION, true ); register_block_type( 'dayslot/checkout-field', array( 'api_version' => 2, 'title' => __( 'Delivery date & time', 'dayslot' ), 'category' => 'woocommerce', 'editor_script' => 'dys-block-editor', 'render_callback' => 'dayslot_checkout_field_html', 'supports' => array( 'html' => false ), ) ); // Old name (Event Date Calendar): pages that already have the block keep working. register_block_type( 'edc/checkout-field', array( 'api_version' => 2, 'title' => __( 'Delivery date & time', 'dayslot' ), 'category' => 'woocommerce', 'render_callback' => 'dayslot_checkout_field_html', 'supports' => array( 'html' => false, 'inserter' => false, ), ) ); } } ); /** * Elementor widget (only when Elementor is active). */ add_action( 'elementor/widgets/register', function ( $widgets_manager ) { require_once DAYSLOT_DIR . 'includes/elementor-widget.php'; require_once DAYSLOT_DIR . 'includes/elementor-widget-old.php'; $widgets_manager->register( new DAYSLOT_Elementor_Widget() ); $widgets_manager->register( new DAYSLOT_Elementor_Widget_Old() ); } );