I’m getting this error when trying to create a new page: “There has been a critical error on this website. Please check your site admin email inbox for instructions.”
I contacted
my host and they said this error on the theme: [21-Dec-2022 02:19:15 UTC] PHP Warning: Undefined variable $attachmentid in /home4/aisuperc/public html/wp-content/themes/experthive/functions.php on line 36. this is line 36 in functions.php: $image_html = str_replace( ‘class=“hp-listing__image”’, ‘class=“hp-listing__image hp-listing__image–square”’, $image_html );
this is the whole php. funcions code that i have:
<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Include the theme framework.
require_once __DIR__ . '/vendor/hivepress/hivetheme/hivetheme.php';
add_filter(
'hivepress/v1/forms/listing_search',
function( $form ) {
if ( isset( $form['fields']['s'] ) ) {
$form['fields']['s']['placeholder'] = 'search';
}
return $form;
},
1000
);
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function( $blocks, $template ) {
return hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
'blocks' => [
'listing_image' => [
'path' => 'listing/view/block/listing-image',
],
],
]
)['blocks'];
},
1000,
2
);
// Modify the image HTML to remove the rounded corners.
$image_html = str_replace( 'class="hp-listing__image"', 'class="hp-listing__image hp-listing__image--square"', $image_html );
// Print the modified image HTML.
echo $image_html;
function replace_text_in_class($content) {
$doc = new DOMDocument();
$doc->loadHTML($content);
$xpath = new DOMXPath($doc);
$elements = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' hp-listing-category__item-count hp-listing-category__count ')]");
foreach($elements as $element) {
$element->nodeValue = 'Verified';
}
return $doc->saveHTML();
}
add_filter('the_content', 'replace_text_in_class');
add_filter(
'hivepress/v1/templates/user_login_page',
function($template){
$redirect_url = hivepress()->router->get_redirect_url();
if(!$redirect_url || strpos($redirect_url, 'submit-listing') === false){
return $template;
}
hivepress()->template->fetch_block($template, 'user_login_form');
return hivepress()->template->merge_blocks(
$template,
[
'page_content' => [
'blocks' => [
'page_title' => [
'type' => 'content',
'content' => '<h1 class="hp-page__title">Register</h1>',
],
'user_login_form' => [
'type' => 'user_register_form',
'_order' => 10,
],
],
],
]
);
},
1000
);
please assist asap