Skip to content

Commit db104e5

Browse files
authored
Merge pull request #1336 from visual-framework/php-errors-fix
php error fixes and warnings
2 parents 8e5449d + 08415f6 commit db104e5

File tree

5 files changed

+50
-55
lines changed

5 files changed

+50
-55
lines changed

wp-content/plugins/vf-wp/vf-containers.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ public function after_setup_theme() {
155155
'render_callback' => $callback
156156
)
157157
));
158-
} else {
159-
error_log("Error: No valid post found for plugin with key {$key}");
160158
}
161159
}
162160
}

wp-content/themes/vf-wp-groups/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
if( ! defined( 'ABSPATH' ) ) exit;
44

55
/* Adds scripts */
6-
add_action( 'wp_enqueue_scripts', 'add_scripts' );
7-
function add_scripts() {
6+
add_action( 'wp_enqueue_scripts', 'include_scripts' );
7+
function include_scripts() {
88
wp_enqueue_script('jplist', get_theme_file_uri( '/scripts/jplist.min.js'));
99
}
1010

wp-content/themes/vf-wp/blocks/vfwp-section-header/template.php

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
$heading = get_field('heading');
77
$sub_heading = get_field('sub_heading');
88
$link = get_field('link');
9+
$link_url = is_array($link) && isset($link['url']) ? $link['url'] : '';
910
$text = get_field('text');
1011
$anchor = get_field('anchor');
1112

@@ -20,7 +21,7 @@
2021

2122
// Function to output a banner message in the Gutenberg editor only
2223
$admin_banner = function($message, $modifier = 'info') use ($is_preview) {
23-
if ( ! $is_preview) {
24+
if (! $is_preview) {
2425
return; }
2526
?>
2627
<div class="vf-banner vf-banner--alert vf-banner--<?php echo $modifier; ?>">
@@ -43,31 +44,29 @@
4344

4445
?>
4546
<div class="vf-section-header | vf-u-margin__bottom--400">
46-
<h2 class="vf-section-header__heading"
47-
<?php
48-
if ($anchor) {
49-
echo 'id="' . $anchor .'"';
50-
} ?>
51-
>
52-
<?php
53-
if ($type === 'is_a_link' || $type === 'has_sub-heading_and_link' || $type === 'has_sub-heading_link_text' || $type === 'has_link_text') { ?>
54-
<a class="vf-section-header__heading vf-section-header__heading--is-link"
55-
<?php if ($anchor) { echo 'id="' . $anchor .'"';} ?>
56-
href="<?php echo esc_url($link['url']); ?>"><?php echo esc_html($heading); ?><svg aria-hidden="true" class="vf-section-header__icon | vf-icon vf-icon-arrow--inline-end" width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path></svg></a>
57-
<?php }
58-
else {
59-
echo $heading; } ?>
60-
</h2>
47+
<h2 class="vf-section-header__heading"
6148
<?php
49+
if ($anchor) {
50+
echo 'id="' . $anchor .'"';
51+
} ?>
52+
>
53+
<?php
54+
if ($type === 'is_a_link' || $type === 'has_sub-heading_and_link' || $type === 'has_sub-heading_link_text' || $type === 'has_link_text') { ?>
55+
<a class="vf-section-header__heading vf-section-header__heading--is-link"
56+
<?php if ($anchor) { echo 'id="' . $anchor .'"';} ?>
57+
href="<?php echo esc_url($link_url); ?>"><?php echo esc_html($heading); ?><svg aria-hidden="true" class="vf-section-header__icon | vf-icon vf-icon-arrow--inline-end" width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0C5.376.008.008 5.376 0 12zm13.707-5.209l4.5 4.5a1 1 0 010 1.414l-4.5 4.5a1 1 0 01-1.414-1.414l2.366-2.367a.25.25 0 00-.177-.424H6a1 1 0 010-2h8.482a.25.25 0 00.177-.427l-2.366-2.368a1 1 0 011.414-1.414z" fill="" fill-rule="nonzero"></path></svg></a>
58+
<?php }
59+
else {
60+
echo esc_html($heading); } ?>
61+
</h2>
62+
<?php
6263

63-
if ($type === 'has_sub-heading' || $type === 'has_sub-heading_and_link' || $type === 'has_sub-heading_link_text') { ?>
64-
<p class="vf-section-header__subheading"><?php echo esc_html($sub_heading); ?></p>
64+
if ($type === 'has_sub-heading' || $type === 'has_sub-heading_and_link' || $type === 'has_sub-heading_link_text') { ?>
65+
<p class="vf-section-header__subheading"><?php echo esc_html($sub_heading); ?></p>
6566

66-
<?php }
67-
if ($type === 'has_text' || $type === 'has_sub-heading_link_text' || $type === 'has_link_text') { ?>
68-
<p class="vf-section-header__text"><?php echo esc_html($text); ?></p>
69-
<?php } ?>
67+
<?php }
68+
if ($type === 'has_text' || $type === 'has_sub-heading_link_text' || $type === 'has_link_text') { ?>
69+
<p class="vf-section-header__text"><?php echo esc_html($text); ?></p>
70+
<?php } ?>
7071

7172
</div>
72-
73-

wp-content/themes/vf-wp/blocks/vfwp-summary/template.php

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
$title = trim($title);
1616

1717
$link = get_field('link');
18-
$link_target = isset($link['target']) ? $link['target'] : '_self';
18+
$link_target = is_array($link) && isset($link['target']) ? $link['target'] : '_self';
1919
$text = get_field('text', false, false);
2020
$text = wpautop($text);
2121
$text = str_replace('<p>', '<p class="vf-summary__text">', $text);
2222

2323
$image = get_field('image');
24-
if ( ! is_array($image)) {
24+
if (!is_array($image)) {
2525
$image = null;
2626
} else {
2727
$image = wp_get_attachment_image($image['ID'], 'medium', false, array(
@@ -33,10 +33,9 @@
3333
}
3434
$date = get_field('date');
3535

36-
3736
// Function to output a banner message in the Gutenberg editor only
3837
$admin_banner = function($message, $modifier = 'info') use ($is_preview) {
39-
if ( ! $is_preview) {
38+
if (! $is_preview) {
4039
return;
4140
}
4241
?>
@@ -54,12 +53,8 @@
5453
?>
5554

5655
<?php
57-
if ( $type === 'custom' ) {
58-
if (
59-
! $image
60-
&& vf_html_empty($title)
61-
&& vf_html_empty($text)
62-
) {
56+
if ($type === 'custom') {
57+
if (! $image && vf_html_empty($title) && vf_html_empty($text)) {
6358
$admin_banner(__('Please enter custom content for this summary.', 'vfwp'));
6459
return;
6560
}
@@ -72,7 +67,7 @@
7267
?>
7368
<h3 class="vf-summary__title">
7469
<?php if ($link) { ?>
75-
<a href="<?php echo esc_url($link['url']); ?>" class="vf-summary__link" target="<?php echo esc_attr( $link_target ); ?>">
70+
<a href="<?php echo esc_url($link['url']); ?>" class="vf-summary__link" target="<?php echo esc_attr($link_target); ?>">
7671
<?php } ?>
7772

7873
<?php echo esc_html($title); ?>
@@ -88,7 +83,7 @@
8883
return;
8984
}
9085

91-
if ( $type === 'post' ) {
86+
if ($type === 'post') {
9287
?>
9388
<article class="vf-summary vf-summary--news">
9489
<span class="vf-summary__date">
@@ -110,7 +105,7 @@
110105
<?php
111106
}
112107

113-
if ( $type === 'event' ) {
108+
if ($type === 'event') {
114109
$event_style = get_field('event_style');
115110
if (empty($event_style)) {
116111
$event_style = 'default';
@@ -144,10 +139,10 @@ class="vf-summary vf-summary--event | vf-summary--is-link vf-summary--easy vf-su
144139
<?php if (! empty($text)) { ?>
145140
<?php echo $text; ?>
146141
<?php } ?>
147-
<?php if ( ! empty($event_type)) { ?>
142+
<?php if (! empty($event_type)) { ?>
148143
<p class="vf-summary__text"><?php echo $event_type; ?></p>
149144
<?php } ?>
150-
<?php if ( ! empty($location)) { ?>
145+
<?php if (! empty($location)) { ?>
151146
<p class="vf-summary__location"><?php echo $location; ?></p>
152147
<?php } ?>
153148
<?php if ($event_style === 'alternate') { ?>
@@ -164,7 +159,7 @@ class="vf-summary vf-summary--event | vf-summary--is-link vf-summary--easy vf-su
164159
<?php
165160
}
166161

167-
if ( $type === 'publication' ) {
162+
if ($type === 'publication') {
168163

169164
$publication_title = get_field('publication_title');
170165
$publication_link = get_field('publication_link');
@@ -173,24 +168,22 @@ class="vf-summary vf-summary--event | vf-summary--is-link vf-summary--easy vf-su
173168
$source = get_field('source');
174169
$doi = get_field('doi');
175170

176-
if (
177-
178-
vf_html_empty($title)
179-
&& vf_html_empty($source)
180-
&& vf_html_empty($authors)
181-
) {
171+
if (vf_html_empty($title) && vf_html_empty($source) && vf_html_empty($authors)) {
182172
$admin_banner(__('Please enter custom content for this publication.', 'vfwp'));
183173
return;
184174
}
175+
176+
$publication_link_url = is_array($publication_link) && isset($publication_link['url']) ? $publication_link['url'] : '';
185177
?>
186178
<article class="vf-summary vf-summary--publication">
187179
<h3 class="vf-summary__title">
188-
<a href="<?php echo esc_url($publication_link['url']); ?>" class="vf-summary__link">
180+
<a href="<?php echo esc_url($publication_link_url); ?>" class="vf-summary__link">
189181
<?php echo $publication_title; ?>
190-
</a>
182+
</a>
191183
</h3>
192184
<p class="vf-summary__author">
193-
<?php echo $authors; ?> </p>
185+
<?php echo $authors; ?>
186+
</p>
194187
<p class="vf-summary__source">
195188
<?php echo $source; ?>
196189
<span class="vf-summary__date"><?php echo $year; ?></span>

wp-content/themes/vf-wp/functions.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ function remove_margin_wp_toolbar() {
137137

138138
function swiftype_metadata_description() {
139139
$text = '';
140+
$strippedText = ''; // Initialize the variable
141+
140142
// If text is empty use the Content Hub description
141143
if (class_exists('VF_Cache')) {
142144
// Get the global taxonomy term
@@ -153,15 +155,18 @@ function swiftype_metadata_description() {
153155
'source' => 'contenthub',
154156
), $url);
155157
$text = VF_Cache::fetch($url);
156-
$text = strstr($text, '<p>',);
158+
$text = strstr($text, '<p>');
157159
$text = strstr($text, '</p>', true);
158160
$text = str_replace('<p>','', $text);
159161
$strippedText = strip_tags($text);
160-
} }
162+
}
163+
}
164+
161165
return $strippedText;
162166
}
163167

164168

169+
165170
// allow only certain WP Gutenberg blocks
166171
add_filter( 'allowed_block_types_all', 'allowed_block_types' );
167172

0 commit comments

Comments
 (0)