38dd0c4866
- Added logo parameter to hero-section.php component - Added .hero-section-logo CSS (200px max-width, centered) - Updated front-page.php to pass logo.webp to hero 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
109 lines
5.0 KiB
PHP
Executable File
109 lines
5.0 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Hero Section Component
|
|
*
|
|
* @package HomeProz
|
|
*
|
|
* Args:
|
|
* - logo (string): Logo image URL to show above title
|
|
* - title (string): Hero headline
|
|
* - subtitle (string): Hero subheadline
|
|
* - primary_cta_text (string): Primary button text
|
|
* - primary_cta_url (string): Primary button URL
|
|
* - secondary_cta_text (string): Secondary button text
|
|
* - secondary_cta_url (string): Secondary button URL
|
|
* - background_image (string): Background image URL
|
|
* - size (string): 'large' or 'small' (default: 'large')
|
|
* - show_location_search (bool): Show location search dropdown (default: false)
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Get args with defaults
|
|
$logo = isset($args['logo']) ? $args['logo'] : '';
|
|
$title = isset($args['title']) ? $args['title'] : '';
|
|
$subtitle = isset($args['subtitle']) ? $args['subtitle'] : '';
|
|
$primary_cta_text = isset($args['primary_cta_text']) ? $args['primary_cta_text'] : '';
|
|
$primary_cta_url = isset($args['primary_cta_url']) ? $args['primary_cta_url'] : '';
|
|
$secondary_cta_text = isset($args['secondary_cta_text']) ? $args['secondary_cta_text'] : '';
|
|
$secondary_cta_url = isset($args['secondary_cta_url']) ? $args['secondary_cta_url'] : '';
|
|
$background_image = isset($args['background_image']) ? $args['background_image'] : '';
|
|
$size = isset($args['size']) ? $args['size'] : 'large';
|
|
$show_location_search = isset($args['show_location_search']) ? $args['show_location_search'] : false;
|
|
|
|
$size_class = $size === 'small' ? 'hero-section--small' : 'hero-section--large';
|
|
$style = $background_image ? 'background-image: url(' . esc_url($background_image) . ');' : '';
|
|
|
|
// Get locations for dropdown if needed
|
|
$locations = array();
|
|
if ($show_location_search) {
|
|
$locations = get_terms(array(
|
|
'taxonomy' => 'property_location',
|
|
'hide_empty' => false,
|
|
'orderby' => 'name',
|
|
'order' => 'ASC',
|
|
));
|
|
}
|
|
?>
|
|
|
|
<section class="hero-section <?php echo esc_attr($size_class); ?>" <?php echo $style ? 'style="' . esc_attr($style) . '"' : ''; ?>>
|
|
<div class="hero-section-overlay"></div>
|
|
<div class="container">
|
|
<div class="hero-section-content">
|
|
<?php if ($logo) : ?>
|
|
<img src="<?php echo esc_url($logo); ?>" alt="" class="hero-section-logo">
|
|
<?php endif; ?>
|
|
|
|
<?php if ($title) : ?>
|
|
<h1 class="hero-section-title"><?php echo esc_html($title); ?></h1>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($subtitle) : ?>
|
|
<p class="hero-section-subtitle"><?php echo esc_html($subtitle); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($show_location_search && !empty($locations) && !is_wp_error($locations)) : ?>
|
|
<form class="hero-location-search" action="<?php echo esc_url(home_url('/properties/')); ?>" method="get">
|
|
<div class="hero-location-search-inner">
|
|
<label for="hero-location-select" class="screen-reader-text">Select a community</label>
|
|
<select name="location" id="hero-location-select" class="hero-location-select">
|
|
<option value="">Select a Community</option>
|
|
<?php foreach ($locations as $location) : ?>
|
|
<option value="<?php echo esc_attr($location->slug); ?>">
|
|
<?php echo esc_html($location->name); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<button type="submit" class="btn btn-primary hero-search-btn">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
|
<circle cx="11" cy="11" r="8"/>
|
|
<path d="M21 21l-4.35-4.35"/>
|
|
</svg>
|
|
<span>Search Properties</span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($primary_cta_text || $secondary_cta_text) : ?>
|
|
<div class="hero-section-actions">
|
|
<?php if ($primary_cta_text && $primary_cta_url) : ?>
|
|
<a href="<?php echo esc_url($primary_cta_url); ?>" class="btn btn-primary">
|
|
<?php echo esc_html($primary_cta_text); ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($secondary_cta_text && $secondary_cta_url) : ?>
|
|
<a href="<?php echo esc_url($secondary_cta_url); ?>" class="btn btn-secondary">
|
|
<?php echo esc_html($secondary_cta_text); ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|