Files
powerservice/wp-content/themes/powerservices/template-parts/service-contact-form.php
T
2026-10-19 12:45:45 -06:00

68 lines
2.9 KiB
PHP

<?php
/**
* Reusable contact section for service pages.
*
* @var array $args Template arguments supplied through get_template_part().
*/
$service_contact = wp_parse_args(
isset( $args ) ? $args : array(),
array(
'section_id' => 'contacto-servicios',
'heading_id' => 'contacto-servicios-title',
'background_image_id' => 0,
'background_color' => '',
'title' => 'Contacta con nosotros',
'subtitle' => 'Estamos comprometidos en ofrecerte el mejor servicio y atención',
'form_id' => '',
'form_title' => '',
'form_html_id' => 'formulario-servicios',
'form_max_width' => 800,
)
);
$section_id = sanitize_html_class( $service_contact['section_id'] );
$heading_id = sanitize_html_class( $service_contact['heading_id'] );
$form_id = sanitize_key( $service_contact['form_id'] );
$form_html_id = sanitize_html_class( $service_contact['form_html_id'] );
$form_max_width = max( 280, absint( $service_contact['form_max_width'] ) );
$background_color = sanitize_hex_color( $service_contact['background_color'] );
$form_shortcode = sprintf(
'[contact-form-7 id="%s" title="%s" html_id="%s"]',
$form_id,
esc_attr( $service_contact['form_title'] ),
$form_html_id
);
?>
<section id="<?php echo esc_attr( $section_id ); ?>" class="relative isolate scroll-mt-32 overflow-hidden bg-white py-[70px] text-color-5 md:py-[50px]"<?php echo $background_color ? ' style="background-color: ' . esc_attr( $background_color ) . ';"' : ''; ?> aria-labelledby="<?php echo esc_attr( $heading_id ); ?>">
<?php if ( $service_contact['background_image_id'] ) : ?>
<?php echo wp_get_attachment_image( $service_contact['background_image_id'], 'full', false, array(
'class' => 'pointer-events-none absolute inset-0 -z-10 h-full w-full object-cover object-center',
'alt' => '',
'loading' => 'lazy',
'sizes' => '100vw',
'aria-hidden' => 'true',
) ); ?>
<?php endif; ?>
<div class="container px-[50px] lg:px-8 md:w-[85%] md:px-0">
<div class="text-center" data-scroll-reveal>
<h2 id="<?php echo esc_attr( $heading_id ); ?>" class="text-[51px] font-black uppercase leading-[1.2] lg:text-[40px] md:text-[24px]">
<?php echo esc_html( $service_contact['title'] ); ?>
</h2>
<p class="mt-4 text-[19px] font-medium leading-[1.4] md:text-[17px]">
<?php echo esc_html( $service_contact['subtitle'] ); ?>
</p>
</div>
<div class="ps-contact-form ps-service-contact-form mx-auto mt-12 w-full md:mt-8" style="max-width: <?php echo esc_attr( $form_max_width ); ?>px;" data-scroll-reveal>
<?php if ( shortcode_exists( 'contact-form-7' ) && $form_id ) : ?>
<?php echo do_shortcode( $form_shortcode ); ?>
<?php else : ?>
<p class="text-center">Contáctanos por <a class="text-color-3 underline" href="https://wa.me/5213318079513">WhatsApp</a> para solicitar más información.</p>
<?php endif; ?>
</div>
</div>
</section>