/* FyrePro — callback form installer WITH diagnostics.
Reports why it did not run instead of failing silently. */
if ( ! function_exists( 'fyrepro_cb_install' ) ) {function fyrepro_cb_say( $msg, $ok = false ) {
printf(
'
FyrePro installer: %s
',
$ok ? '#065f46' : '#b91c1c',
$msg
);
}function fyrepro_cb_install() {if ( ! is_user_logged_in() ) { return; } // silent for visitors
if ( ! current_user_can( 'manage_options' ) ) { return; } // silent for non-adminsif ( ! class_exists( 'GFAPI' ) ) {
fyrepro_cb_say( 'Gravity Forms is not loaded (GFAPI missing). The code ran, but GF was not available at this point.' );
return;
}$existing = get_option( 'fyrepro_callback_form_id' );
if ( $existing ) {
$form = GFAPI::get_form( $existing );
if ( $form ) {
fyrepro_cb_say( 'Already created earlier. FORM ID = ' . (int) $existing . ' ("' . esc_html( $form['title'] ) . '"). Nothing more to do.', true );
} else {
delete_option( 'fyrepro_callback_form_id' );
fyrepro_cb_say( 'A previous run recorded form ID ' . (int) $existing . ' but that form no longer exists. Flag cleared — reload this page to create it fresh.' );
}
return;
}$nid = uniqid( '', true );
$cid = uniqid( '', true );$form_id = GFAPI::add_form( array(
'title' => 'LP Callback Request',
'labelPlacement' => 'top_label',
'enableHoneypot' => true,
'button' => array( 'type' => 'text', 'text' => 'Request callback' ),
'fields' => array(
array( 'id' => 1, 'type' => 'phone', 'label' => 'Your phone number', 'isRequired' => true, 'phoneFormat' => 'international', 'placeholder' => 'Your phone number' ),
array( 'id' => 2, 'type' => 'select', 'label' => 'Best time to call you back', 'choices' => array(
array( 'text' => 'Any time in business hours', 'value' => '', 'isSelected' => true ),
array( 'text' => 'Early morning, 7am to 9am', 'value' => 'Early morning (7am to 9am)' ),
array( 'text' => 'Morning, 9am to 12pm', 'value' => 'Morning (9am to 12pm)' ),
array( 'text' => 'Afternoon, 12pm to 4pm', 'value' => 'Afternoon (12pm to 4pm)' ),
array( 'text' => 'After hours, after 4pm', 'value' => 'After hours (after 4pm)' ),
) ),
array( 'id' => 3, 'type' => 'hidden', 'label' => 'Source', 'defaultValue' => 'LP callback banner' ),
),
'notifications' => array( $nid => array(
'id' => $nid, 'isActive' => true, 'name' => 'Callback request', 'event' => 'form_submission',
'toType' => 'email', 'to' => '{admin_email}', 'from' => '{admin_email}', 'fromName' => 'FyrePro website',
'subject' => 'CALLBACK - {Your phone number:1} - {Best time to call you back:2}',
'message' => "Phone: {Your phone number:1}\nPreferred window: {Best time to call you back:2}\nSource: {Source:3}",
) ),
'confirmations' => array( $cid => array(
'id' => $cid, 'name' => 'Default Confirmation', 'isDefault' => true, 'type' => 'message',
'message' => '