#!/bin/bash

echo "=== Forcing Full Width Layout for HVAC Pages ==="

# SSH into staging and force full width
ssh roodev@146.190.76.204 << 'EOF'
cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html

# Update page meta to force no sidebar
echo "Setting page layout to no-sidebar..."

# Get all HVAC related pages
HVAC_PAGES=$(wp post list --post_type=page --fields=ID,post_title --format=csv | grep -E "(Trainer|Master|Certificate|Event|Registration|Login)" | cut -d',' -f1 | grep -v "ID")

for page_id in $HVAC_PAGES; do
    if [ ! -z "$page_id" ]; then
        echo "Updating page $page_id to no-sidebar layout"
        # Astra uses this meta key for sidebar layout
        wp post meta update $page_id ast-site-content-layout "no-sidebar"
        wp post meta update $page_id site-content-layout "no-sidebar"
        wp post meta update $page_id site-sidebar-layout "no-sidebar"
        
        # Also add theme-specific layout settings
        wp post meta update $page_id _astra_content_layout_flag "disabled"
        wp post meta update $page_id ast-featured-img "disabled"
        wp post meta update $page_id ast-title-bar-display "disabled"
    fi
done

# List updated pages
echo -e "\nUpdated pages:"
wp post list --post_type=page --meta_key=ast-site-content-layout --meta_value=no-sidebar --fields=ID,post_title --format=table

# Clear all caches
wp cache flush
wp breeze purge --cache=all
wp opcache reset

echo "Full width layout forced successfully!"
EOF