function perspectives_project_detail_page() { global $wpdb; $project_id = isset($_GET['project_id']) ? intval($_GET['project_id']) : 0; $projects_table = $wpdb->prefix . 'perspectives_projects'; $perspectives_table = $wpdb->prefix . 'perspectives'; // Check if perspectives table exists $perspectives_table_exists = ($wpdb->get_var("SHOW TABLES LIKE '$perspectives_table'") == $perspectives_table); // Handle add perspective form if ( $perspectives_table_exists && isset($_POST['add_perspective']) && !empty($_POST['perspective_name']) && !empty($_POST['perspective_type']) ) { $name = sanitize_text_field($_POST['perspective_name']); $type = sanitize_text_field($_POST['perspective_type']); $states = isset($_POST['perspective_states']) ? sanitize_text_field($_POST['perspective_states']) : null; $is_default = !empty($_POST['perspective_default']) ? 1 : 0; $target_project_id = $is_default ? null : $project_id; // Only allow user to add non-fixed perspectives if ($type === 'fixed') { echo '
Cannot add new fixed perspectives.
Failed to add perspective: ' . esc_html($wpdb->last_error) . '
Perspective added.
Invalid project.
Project not found.