#!/bin/bash # Create HVAC Announcements pages on staging server echo "šŸš€ Creating HVAC Announcements pages on staging..." # Create the PHP script content cat > /tmp/create-pages.php << 'EOF' ID})\n"; echo " - Trainer (ID: {$trainer_parent->ID})\n\n"; // Check if pages already exist $existing_manage = get_page_by_path('master-trainer/manage-announcements'); $existing_view = get_page_by_path('trainer/announcements'); $existing_resources = get_page_by_path('trainer/training-resources'); if ($existing_manage) { echo "āš ļø Manage Announcements page already exists (ID: {$existing_manage->ID})\n"; } else { // Create Manage Announcements page $manage_page = wp_insert_post(array( 'post_title' => 'Manage Announcements', 'post_name' => 'manage-announcements', 'post_content' => '[hvac_announcements_manager]', 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $master_parent->ID, )); if ($manage_page && !is_wp_error($manage_page)) { update_post_meta($manage_page, '_wp_page_template', 'templates/page-master-manage-announcements.php'); echo "āœ… Created: /master-trainer/manage-announcements/ (ID: $manage_page)\n"; } else { echo "āŒ Failed to create manage announcements page\n"; if (is_wp_error($manage_page)) { echo " Error: " . $manage_page->get_error_message() . "\n"; } } } if ($existing_view) { echo "āš ļø Announcements page already exists (ID: {$existing_view->ID})\n"; } else { // Create Announcements view page $view_page = wp_insert_post(array( 'post_title' => 'Announcements', 'post_name' => 'announcements', 'post_content' => '[hvac_announcements_timeline]', 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $trainer_parent->ID, )); if ($view_page && !is_wp_error($view_page)) { update_post_meta($view_page, '_wp_page_template', 'templates/page-trainer-announcements.php'); echo "āœ… Created: /trainer/announcements/ (ID: $view_page)\n"; } else { echo "āŒ Failed to create announcements page\n"; if (is_wp_error($view_page)) { echo " Error: " . $view_page->get_error_message() . "\n"; } } } if ($existing_resources) { echo "āš ļø Training Resources page already exists (ID: {$existing_resources->ID})\n"; } else { // Create Training Resources page $resources_page = wp_insert_post(array( 'post_title' => 'Training Resources', 'post_name' => 'training-resources', 'post_content' => '[hvac_google_drive_embed url="https://drive.google.com/drive/folders/1-G8gICMsih5E9YJ2FqaC5OqG0o4rwuSP"]', 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $trainer_parent->ID, )); if ($resources_page && !is_wp_error($resources_page)) { update_post_meta($resources_page, '_wp_page_template', 'templates/page-trainer-resources.php'); echo "āœ… Created: /trainer/training-resources/ (ID: $resources_page)\n"; } else { echo "āŒ Failed to create training resources page\n"; if (is_wp_error($resources_page)) { echo " Error: " . $resources_page->get_error_message() . "\n"; } } } // Flush rewrite rules and clear cache flush_rewrite_rules(); if (function_exists('wp_cache_flush')) { wp_cache_flush(); } echo "\nšŸŽ‰ HVAC Announcements pages setup complete!\n"; echo "\nPages should be available at:\n"; echo "- https://upskill-staging.measurequick.com/master-trainer/manage-announcements/\n"; echo "- https://upskill-staging.measurequick.com/trainer/announcements/\n"; echo "- https://upskill-staging.measurequick.com/trainer/training-resources/\n"; ?> EOF # Get server details from existing deployment SERVER_IP="146.190.76.204" SERVER_USER="roodev" SERVER_PATH="/home/974670.cloudwaysapps.com/uberrxmprk/public_html" # Check if we can access the server (using the same method as deploy.sh) echo "šŸ“” Connecting to staging server..." # Try to execute the PHP script ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} " echo 'šŸ”§ Executing page creation script on server...' cd ${SERVER_PATH} php /tmp/create-pages.php " 2>/dev/null || { echo "āŒ SSH connection failed. You may need to run this manually on the staging server." echo "šŸ“‹ To run manually, copy this script to the staging server and execute:" echo " php /path/to/create-pages.php" exit 1 } echo "āœ… HVAC Announcements pages creation completed!"