Skip to content

Commit d9a968e

Browse files
committed
add error handling for when global post is called but post is not set
1 parent 9b23cb7 commit d9a968e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

web/app/themes/platformlondon/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}, 10, 2);
3030
add_filter('wp_trim_words', function ($text, $num_words, $more, $original_text) {
3131
global $post;
32-
if ($post->post_type === "pl_member") {
32+
if (isset($post) && $post->post_type === "pl_member") {
3333
return $original_text;
3434
}
3535
return $text;
@@ -294,7 +294,7 @@
294294
!wp_is_json_request()
295295
) {
296296
global $post;
297-
if ($post->post_type === "pl_member") {
297+
if (isset($post) && $post->post_type === "pl_member") {
298298
$block_content = str_replace('<p class="wp-block-post-excerpt__excerpt">', "", $block_content);
299299
$block_content = preg_replace("#</p></div>$#", "</div>", $block_content);
300300
}
@@ -306,7 +306,7 @@
306306
!wp_is_json_request()
307307
) {
308308
global $post;
309-
if ($post->post_name === "projects") {
309+
if (isset($post) && isset($post->post_name) && $post->post_name === "projects") {
310310
preg_match('#<img.*src="([^"]*)"#', $block_content, $matches);
311311
if (count($matches) !== 2) {
312312
return $block_content;

0 commit comments

Comments
 (0)