'', 'mode' => 'inline', 'height' => '700', 'text' => 'Open Form', 'color' => '', 'position' => 'inline', ), $atts, 'formbharat' ); $id = formbharat_clean_id( $atts['id'] ); if ( '' === $id ) { return current_user_can( 'edit_posts' ) ? '

' . esc_html__( 'FormBharat: missing or invalid form ID.', 'formbharat' ) . '

' : ''; } if ( 'popup' === $atts['mode'] ) { // Empty means "use the FormBharat brand gradient" (set in popup.js). $color = sanitize_hex_color( $atts['color'] ); $color = $color ? $color : ''; $position = in_array( $atts['position'], array( 'inline', 'bottom-right', 'bottom-left' ), true ) ? $atts['position'] : 'inline'; // Print the bundled launcher script for this form (it reads data-* attributes). // The script ships inside the plugin; nothing is loaded from a remote server. // wp_print_script_tag escapes every attribute value. ob_start(); $script_attrs = array( 'src' => plugins_url( 'assets/popup.js', __FILE__ ), 'data-formbharat-popup' => '1', 'data-origin' => FORMBHARAT_BASE_URL, 'data-form-id' => $id, 'data-button-text' => $atts['text'], 'data-position' => $position, 'async' => true, ); if ( '' !== $color ) { $script_attrs['data-button-color'] = $color; } wp_print_script_tag( $script_attrs ); return ob_get_clean(); } $height = max( 200, min( 3000, absint( $atts['height'] ) ) ); wp_enqueue_script( 'formbharat-resize', plugins_url( 'assets/resize.js', __FILE__ ), array(), '0.1.2', true ); return sprintf( '', esc_url( FORMBHARAT_BASE_URL . '/f/' . $id . '?fb_src=wordpress' ), esc_attr__( 'FormBharat form', 'formbharat' ), $height ); } add_shortcode( 'formbharat', 'formbharat_render' ); add_action( 'init', function () { register_block_type( __DIR__ . '/blocks/form', array( 'render_callback' => 'formbharat_render' ) ); } );