File: //tmp/create_footer2.php
<?php
$_SERVER["SERVER_NAME"] = "sunsandholidays.com";
$_SERVER["HTTP_HOST"] = "sunsandholidays.com";
include "/var/www/sunsandholidays.com/wp-load.php";
// First delete the broken footer
wp_delete_post(6348, true);
$phone = get_theme_mod("tmp_phone", "+1 646-934-0970");
$email = "sunsandholidays2024@gmail.com";
$address = "333 E 46th street apt 1F, New York, NY 10017";
// Build HTML with single quotes consistently to avoid JSON issues
$contact_html = "<p style='color: #cccccc;'>Email: <a href='mailto:{$email}' style='color: #cccccc;'>{$email}</a><br>Phone: {$phone}<br>Address: {$address}</p>";
$links_html = "<p style='color: #cccccc; line-height: 2;'><a href='/' style='color: #cccccc;'>Home</a><br><a href='/?page_id=2546' style='color: #cccccc;'>Blog</a><br><a href='/?page_id=2553' style='color: #cccccc;'>About Us</a><br><a href='/?page_id=19' style='color: #cccccc;'>My Account</a></p>";
$policies_html = "<p style='color: #cccccc; line-height: 2;'><a href='/?page_id=6346' style='color: #cccccc;'>Terms and Conditions</a><br><a href='/?page_id=6347' style='color: #cccccc;'>Refund Policy</a></p>";
$copyright_html = "<p style='color: #888888; text-align: center; margin: 0;'>© " . date("Y") . " Sunsandholidays. All rights reserved.</p>";
$elementor_data = [
[
"id" => "footer-section-1",
"elType" => "container",
"settings" => [
"content_width" => "full",
"flex_direction" => "row",
"padding" => ["unit" => "px", "top" => "60", "right" => "30", "bottom" => "30", "left" => "30", "isLinked" => false],
"background_background" => "classic",
"background_color" => "#1C2011"
],
"elements" => [
[
"id" => "footer-col-1",
"elType" => "container",
"settings" => ["content_width" => "full", "flex_direction" => "column", "_column_size" => 33, "_inline_size" => 33],
"elements" => [
["id" => "footer-heading-1", "elType" => "widget", "settings" => ["title" => "Contact Us", "header_size" => "h3", "title_color" => "#FFFFFF", "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 22]], "widgetType" => "heading", "elements" => []],
["id" => "footer-address", "elType" => "widget", "settings" => ["editor" => $contact_html, "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 15]], "widgetType" => "text-editor", "elements" => []]
],
"isInner" => true
],
[
"id" => "footer-col-2",
"elType" => "container",
"settings" => ["content_width" => "full", "flex_direction" => "column", "_column_size" => 33, "_inline_size" => 33],
"elements" => [
["id" => "footer-heading-2", "elType" => "widget", "settings" => ["title" => "Quick Links", "header_size" => "h3", "title_color" => "#FFFFFF", "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 22]], "widgetType" => "heading", "elements" => []],
["id" => "footer-links", "elType" => "widget", "settings" => ["editor" => $links_html, "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 15]], "widgetType" => "text-editor", "elements" => []]
],
"isInner" => true
],
[
"id" => "footer-col-3",
"elType" => "container",
"settings" => ["content_width" => "full", "flex_direction" => "column", "_column_size" => 33, "_inline_size" => 33],
"elements" => [
["id" => "footer-heading-3", "elType" => "widget", "settings" => ["title" => "Policies", "header_size" => "h3", "title_color" => "#FFFFFF", "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 22]], "widgetType" => "heading", "elements" => []],
["id" => "footer-policy-links", "elType" => "widget", "settings" => ["editor" => $policies_html, "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 15]], "widgetType" => "text-editor", "elements" => []]
],
"isInner" => true
]
],
"isInner" => false
],
[
"id" => "footer-copyright-bar",
"elType" => "container",
"settings" => [
"content_width" => "full",
"flex_direction" => "row",
"padding" => ["unit" => "px", "top" => "15", "right" => "30", "bottom" => "15", "left" => "30", "isLinked" => false],
"background_background" => "classic",
"background_color" => "#151A0E"
],
"elements" => [
[
"id" => "copyright-text",
"elType" => "container",
"settings" => ["content_width" => "full", "flex_direction" => "column", "_column_size" => 100],
"elements" => [
["id" => "copyright-widget", "elType" => "widget", "settings" => ["editor" => $copyright_html, "align" => "center", "typography_typography" => "custom", "typography_font_size" => ["unit" => "px", "size" => 13]], "widgetType" => "text-editor", "elements" => []]
],
"isInner" => true
]
],
"isInner" => false
]
];
$elementor_json = wp_json_encode($elementor_data);
echo "JSON is valid: " . (json_decode($elementor_json) !== null ? "YES" : "NO") . "\n";
$footer_post_id = wp_insert_post([
"post_title" => "CustomFooter",
"post_status" => "publish",
"post_type" => "elementor-hf",
"post_author" => 1,
"meta_input" => [
"ehf_template_type" => "type_footer",
"ehf_target_include_locations" => ["rule" => ["basic-global"], "specific" => []],
"ehf_target_exclude_locations" => [],
"ehf_target_user_roles" => ["all"],
"_elementor_edit_mode" => "builder",
"_elementor_template_type" => "wp-post",
"_elementor_version" => "3.32.3",
"_elementor_data" => $elementor_json
]
]);
if (is_wp_error($footer_post_id)) {
echo "Error creating footer: " . $footer_post_id->get_error_message() . "\n";
} else {
echo "Footer created (ID: $footer_post_id)\n";
add_post_meta($footer_post_id, "_elementor_controls_usage", wp_json_encode([
"heading" => ["count" => 3, "control_percent" => 50],
"text-editor" => ["count" => 3, "control_percent" => 50]
]));
echo "Meta added\n";
// Clear Elementor CSS cache
update_post_meta($footer_post_id, "_elementor_css", "");
echo "CSS cache cleared\n";
// Clear airlift cache
system("sudo rm -rf /var/www/sunsandholidays.com/wp-content/cache/airlift/ 2>/dev/null");
echo "AirLift cache cleared\n";
}