Skip to content

Commit

Permalink
chore: php error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasprzyk-sz committed Nov 18, 2024
1 parent 87fae98 commit 437cc58
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 40 deletions.
83 changes: 44 additions & 39 deletions wp-content/themes/vf-wp/blocks/vfwp-links-list/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,44 +52,49 @@
<h3 class="vf-links__heading"><?php echo $heading; ?></h3>
<?php } ?>
<ul class="<?php echo esc_attr($class_ul); ?>">
<?php while (have_rows('list_items')): the_row();
$text = get_sub_field('text');
$link = get_sub_field('link');
$badge_text = get_sub_field('badge_text');
$badge_style = get_sub_field('badge_style');
$image = get_sub_field('image');
<?php while (have_rows('list_items')): the_row();
$text = get_sub_field('text');
$link = get_sub_field('link');
$badge_text = get_sub_field('badge_text');
$badge_style = get_sub_field('badge_style');
$image = get_sub_field('image');

// Ensure $image is an array or set to null
if (!is_array($image)) {
$image = null;
} else {
$image = wp_get_attachment_image($image['ID'], 'thumbnail', false, [
'class' => 'vf-list__image',
'loading' => 'lazy',
'itemprop' => 'image',
]);
}
?>
<li class="vf-list__item">
<?php if (is_array($link) && isset($link['url'])): ?>
<a class="vf-list__link" href="<?php echo esc_url($link['url']); ?>">
<?php if ($type === 'has-image'):
echo $image ?: '<div class="vf-list__image"></div>';
endif;
echo esc_html($text);
if ($type === 'easy'): ?>
<svg class="vf-icon vf-icon__arrow--down | vf-list__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>arrow-button-down</title>
<path d="M.249,7.207,11.233,19.678h0a1.066,1.066,0,0,0,1.539,0L23.751,7.207a.987.987,0,0,0-.107-1.414l-1.85-1.557a1.028,1.028,0,0,0-1.438.111L12.191,13.8a.25.25,0,0,1-.379,0L3.644,4.346A1.021,1.021,0,0,0,2.948,4a1,1,0,0,0-.741.238L.356,5.793A.988.988,0,0,0,0,6.478.978.978,0,0,0,.249,7.207Z"/>
</svg>
<?php endif; ?>
</a>
<?php endif;
if (!empty($badge_text)): ?>
<span class="vf-badge vf-badge--<?php echo esc_attr($badge_style); ?>">
<?php echo esc_html($badge_text); ?>
</span>
<?php endif;
if (!empty($meta_information)): ?>
<p class="vf-links__meta"><?php echo esc_html($meta_information); ?></p>
<?php endif; ?>
</li>
<?php endwhile; ?>
</ul>

if (!is_array($image)) {
$image = null;
} else {
$image = wp_get_attachment_image($image['ID'], 'thumbnail', false, [
'class' => 'vf-list__image',
'loading' => 'lazy',
'itemprop' => 'image',
]);
}
?>
<li class="vf-list__item">
<?php if (is_array($link) && isset($link['url'])): ?>
<a class="vf-list__link" href="<?php echo esc_url($link['url']); ?>">
<?php if ($type === 'has-image'):
echo $image ?: '<div class="vf-list__image"></div>';
endif;
echo esc_html($text);
if ($type === 'easy'): ?>
<svg class="vf-icon vf-icon__arrow--down | vf-list__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>arrow-button-down</title><path d="M.249,7.207,11.233,19.678h0a1.066,1.066,0,0,0,1.539,0L23.751,7.207a.987.987,0,0,0-.107-1.414l-1.85-1.557a1.028,1.028,0,0,0-1.438.111L12.191,13.8a.25.25,0,0,1-.379,0L3.644,4.346A1.021,1.021,0,0,0,2.948,4a1,1,0,0,0-.741.238L.356,5.793A.988.988,0,0,0,0,6.478.978.978,0,0,0,.249,7.207Z"/></svg>
<?php endif; ?>
</a>
<?php endif;
if (!empty($badge_text)): ?>
<span class="vf-badge vf-badge--<?php echo esc_attr($badge_style); ?>">
<?php echo esc_html($badge_text); ?>
</span>
<?php endif;
if (!empty($meta_information)): ?>
<p class="vf-links__meta"><?php echo esc_html($meta_information); ?></p>
<?php endif; ?>
</li>
<?php endwhile; ?>
</ul>
</div>
18 changes: 17 additions & 1 deletion wp-content/themes/vf-wp/blocks/vfwp-social-icons/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function widget($args, $instance) {

// widget ID with prefix for use in ACF API functions
$widget_id = 'widget_' . $args['widget_id'];

$is_preview = isset($is_preview) && $is_preview;

$heading = get_field('vf_social_heading', $widget_id);
$color = get_field('vf_social_color', $widget_id);
Expand Down Expand Up @@ -52,6 +52,22 @@ public function widget($args, $instance) {
$dark_mode = 'dark-mode';
}

// Function to output a banner message in the Gutenberg editor only
$admin_banner = function($message, $modifier = 'info') use ($is_preview) {
if (! $is_preview) {
return; }
?>
<div class="vf-banner vf-banner--alert vf-banner--<?php echo $modifier; ?>">
<div class="vf-banner__content">
<p class="vf-banner__text">
<?php echo $message; ?>
</p>
</div>
</div>
<!--/vf-banner-->
<?php
};

if (
(! $select)
) {
Expand Down

0 comments on commit 437cc58

Please sign in to comment.