move devices
This commit is contained in:
@@ -455,6 +455,31 @@ add_action('init', function () {
|
||||
'render_callback' => 'oribi_render_addon_card',
|
||||
]);
|
||||
|
||||
/* Device Section (parent) */
|
||||
register_block_type('oribi/device-section', [
|
||||
'attributes' => oribi_card_section_attributes(2),
|
||||
'supports' => $block_supports,
|
||||
'render_callback' => 'oribi_render_device_section',
|
||||
]);
|
||||
|
||||
/* Device Card (child) */
|
||||
register_block_type('oribi/device-card', [
|
||||
'attributes' => array_merge(
|
||||
[
|
||||
'title' => ['type' => 'string', 'default' => ''],
|
||||
'description' => ['type' => 'string', 'default' => ''],
|
||||
'price' => ['type' => 'string', 'default' => ''],
|
||||
'bestFor' => ['type' => 'string', 'default' => ''],
|
||||
'specs' => ['type' => 'array', 'default' => [], 'items' => ['type' => 'object']],
|
||||
'btnText' => ['type' => 'string', 'default' => ''],
|
||||
'btnUrl' => ['type' => 'string', 'default' => ''],
|
||||
],
|
||||
oribi_card_image_attributes()
|
||||
),
|
||||
'supports' => $block_supports,
|
||||
'render_callback' => 'oribi_render_device_card',
|
||||
]);
|
||||
|
||||
/* Image Section (parent) */
|
||||
register_block_type('oribi/image-section', [
|
||||
'attributes' => oribi_card_section_attributes(3),
|
||||
@@ -1655,6 +1680,56 @@ function oribi_render_addon_card($a)
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/* ── Device Section ────────────────────────────────────────────────────────── */
|
||||
function oribi_render_device_section($a, $content)
|
||||
{
|
||||
return oribi_render_card_section($a, $content, 'grid device-grid', 2);
|
||||
}
|
||||
|
||||
/* ── Device Card ───────────────────────────────────────────────────────────── */
|
||||
function oribi_render_device_card($a)
|
||||
{
|
||||
$img = oribi_card_image_html($a);
|
||||
$img_cls = $img['card_class'] ? ' ' . $img['card_class'] : '';
|
||||
|
||||
$specs = !empty($a['specs']) && is_array($a['specs']) ? $a['specs'] : [];
|
||||
$price = !empty($a['price']) ? $a['price'] : '';
|
||||
$bestFor = !empty($a['bestFor']) ? $a['bestFor'] : '';
|
||||
$btnText = !empty($a['btnText']) ? $a['btnText'] : 'Order Now';
|
||||
$btnUrl = !empty($a['btnUrl']) ? $a['btnUrl'] : '/contact';
|
||||
|
||||
ob_start(); ?>
|
||||
<div class="oribi-card device-card<?php echo esc_attr($img_cls); ?>">
|
||||
<?php if ($img['html']): echo $img['html']; endif; ?>
|
||||
<div class="device-card-body">
|
||||
<?php if ($bestFor): ?>
|
||||
<span class="device-best-for"><?php echo esc_html($bestFor); ?></span>
|
||||
<?php endif; ?>
|
||||
<h3><?php echo wp_kses_post($a['title']); ?></h3>
|
||||
<p><?php echo wp_kses_post($a['description']); ?></p>
|
||||
<?php if ($specs): ?>
|
||||
<dl class="device-specs">
|
||||
<?php foreach ($specs as $spec):
|
||||
$k = isset($spec['key']) ? $spec['key'] : '';
|
||||
$v = isset($spec['value']) ? $spec['value'] : '';
|
||||
if (!$k && !$v) continue; ?>
|
||||
<dt><?php echo esc_html($k); ?></dt>
|
||||
<dd><?php echo esc_html($v); ?></dd>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
<?php if ($price): ?>
|
||||
<div class="device-price"><?php echo esc_html($price); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($btnText && $btnUrl): ?>
|
||||
<a href="<?php echo esc_url($btnUrl); ?>" class="wp-block-button__link device-card-btn"><?php echo esc_html($btnText); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/* ── Image Section ─────────────────────────────────────────────────────────── */
|
||||
function oribi_render_image_section($a, $content)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user