From 08415f673296633a2ae3c110d4441a70cbfa89f2 Mon Sep 17 00:00:00 2001 From: Szymon Kasprzyk Date: Wed, 19 Jun 2024 12:02:20 +0200 Subject: [PATCH] php error fixes and warnings --- wp-content/plugins/vf-wp/vf-containers.php | 2 - wp-content/themes/vf-wp-groups/functions.php | 4 +- .../blocks/vfwp-section-header/template.php | 47 +++++++++---------- .../vf-wp/blocks/vfwp-summary/template.php | 43 +++++++---------- wp-content/themes/vf-wp/functions.php | 9 +++- 5 files changed, 50 insertions(+), 55 deletions(-) diff --git a/wp-content/plugins/vf-wp/vf-containers.php b/wp-content/plugins/vf-wp/vf-containers.php index 34a274364..8cd20ce60 100644 --- a/wp-content/plugins/vf-wp/vf-containers.php +++ b/wp-content/plugins/vf-wp/vf-containers.php @@ -155,8 +155,6 @@ public function after_setup_theme() { 'render_callback' => $callback ) )); - } else { - error_log("Error: No valid post found for plugin with key {$key}"); } } } diff --git a/wp-content/themes/vf-wp-groups/functions.php b/wp-content/themes/vf-wp-groups/functions.php index 6eb9edb93..9ef9d25fa 100644 --- a/wp-content/themes/vf-wp-groups/functions.php +++ b/wp-content/themes/vf-wp-groups/functions.php @@ -3,8 +3,8 @@ if( ! defined( 'ABSPATH' ) ) exit; /* Adds scripts */ -add_action( 'wp_enqueue_scripts', 'add_scripts' ); -function add_scripts() { +add_action( 'wp_enqueue_scripts', 'include_scripts' ); +function include_scripts() { wp_enqueue_script('jplist', get_theme_file_uri( '/scripts/jplist.min.js')); } diff --git a/wp-content/themes/vf-wp/blocks/vfwp-section-header/template.php b/wp-content/themes/vf-wp/blocks/vfwp-section-header/template.php index e6131a7ca..6a87ea15d 100644 --- a/wp-content/themes/vf-wp/blocks/vfwp-section-header/template.php +++ b/wp-content/themes/vf-wp/blocks/vfwp-section-header/template.php @@ -6,6 +6,7 @@ $heading = get_field('heading'); $sub_heading = get_field('sub_heading'); $link = get_field('link'); +$link_url = is_array($link) && isset($link['url']) ? $link['url'] : ''; $text = get_field('text'); $anchor = get_field('anchor'); @@ -20,7 +21,7 @@ // Function to output a banner message in the Gutenberg editor only $admin_banner = function($message, $modifier = 'info') use ($is_preview) { - if ( ! $is_preview) { + if (! $is_preview) { return; } ?>
@@ -43,31 +44,29 @@ ?>
-

- > - - - href=""> - -

+

+ > + + + href=""> + +

+ -

+if ($type === 'has_sub-heading' || $type === 'has_sub-heading_and_link' || $type === 'has_sub-heading_link_text') { ?> +

- -

- + +

+
- - diff --git a/wp-content/themes/vf-wp/blocks/vfwp-summary/template.php b/wp-content/themes/vf-wp/blocks/vfwp-summary/template.php index 2eb151af7..cbbd0668e 100644 --- a/wp-content/themes/vf-wp/blocks/vfwp-summary/template.php +++ b/wp-content/themes/vf-wp/blocks/vfwp-summary/template.php @@ -15,13 +15,13 @@ $title = trim($title); $link = get_field('link'); -$link_target = isset($link['target']) ? $link['target'] : '_self'; +$link_target = is_array($link) && isset($link['target']) ? $link['target'] : '_self'; $text = get_field('text', false, false); $text = wpautop($text); $text = str_replace('

', '

', $text); $image = get_field('image'); -if ( ! is_array($image)) { +if (!is_array($image)) { $image = null; } else { $image = wp_get_attachment_image($image['ID'], 'medium', false, array( @@ -33,10 +33,9 @@ } $date = get_field('date'); - // Function to output a banner message in the Gutenberg editor only $admin_banner = function($message, $modifier = 'info') use ($is_preview) { - if ( ! $is_preview) { + if (! $is_preview) { return; } ?> @@ -54,12 +53,8 @@ ?>

- + @@ -88,7 +83,7 @@ return; } -if ( $type === 'post' ) { +if ($type === 'post') { ?>
@@ -110,7 +105,7 @@ - +

- +

@@ -164,7 +159,7 @@ class="vf-summary vf-summary--event | vf-summary--is-link vf-summary--easy vf-su

- + - +

-

+ +

diff --git a/wp-content/themes/vf-wp/functions.php b/wp-content/themes/vf-wp/functions.php index 21fc3b74a..a25e95fee 100644 --- a/wp-content/themes/vf-wp/functions.php +++ b/wp-content/themes/vf-wp/functions.php @@ -137,6 +137,8 @@ function remove_margin_wp_toolbar() { function swiftype_metadata_description() { $text = ''; + $strippedText = ''; // Initialize the variable + // If text is empty use the Content Hub description if (class_exists('VF_Cache')) { // Get the global taxonomy term @@ -153,15 +155,18 @@ function swiftype_metadata_description() { 'source' => 'contenthub', ), $url); $text = VF_Cache::fetch($url); - $text = strstr($text, '

',); + $text = strstr($text, '

'); $text = strstr($text, '

', true); $text = str_replace('

','', $text); $strippedText = strip_tags($text); - } } + } + } + return $strippedText; } + // allow only certain WP Gutenberg blocks add_filter( 'allowed_block_types_all', 'allowed_block_types' );