Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_shortcode( 'sp_contact_wa', 'sp_form_contact_whatsapp' );
function sp_form_contact_whatsapp( $atts ) {
$purpose = '';
$phone = '';
if( isset( $atts['purpose'] ) && $atts['purpose'] != '' ) {
$purpose = $atts['purpose'];
}
if( isset( $atts['phone'] ) && $atts['phone'] != '' ) {
$phone = $atts['phone'];
}
wp_enqueue_style( 'sp-css-grid' );
wp_localize_script( 'sp-contact-form-wa', 'sp_contact_form', [
'phone' => $phone,
'purpose' => $purpose
] );
wp_enqueue_script( 'sp-contact-form-wa' );
$col = array( 5,5,2 );
if( isset( $atts['columns'] ) && $atts['columns'] != '' ) {
$_col = explode( ',', $atts['columns'] );
if( count( $_col ) == 3 ) {
$col = $_col;
}
}
$html = '';
ob_start();
include plugin_dir_path( __FILE__ ) . '/sc-form-wa.php';
$html = ob_get_contents();
ob_end_clean();
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment