0 ) { include PCFB_PLUGIN_DIR . 'admin/page-form-builder.php'; } else { include PCFB_PLUGIN_DIR . 'admin/page-form-builder.php'; } } public function render_all_forms_page() { include PCFB_PLUGIN_DIR . 'admin/page-all-forms.php'; } public function render_responses_page() { $form_id = isset( $_GET['form_id'] ) ? intval( $_GET['form_id'] ) : 0; $response_id = isset( $_GET['response_id'] ) ? intval( $_GET['response_id'] ) : 0; if ( $response_id > 0 ) { include PCFB_PLUGIN_DIR . 'admin/page-response-detail.php'; } elseif ( $form_id > 0 ) { include PCFB_PLUGIN_DIR . 'admin/page-form-responses.php'; } else { include PCFB_PLUGIN_DIR . 'admin/page-responses.php'; } } public function handle_form_actions() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( ! isset( $_POST['pcfb_action'] ) ) { return; } if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'pcfb_admin_action' ) ) { return; } $action = sanitize_text_field( $_POST['pcfb_action'] ); switch ( $action ) { case 'save_form': $this->handle_save_form(); break; case 'delete_form': $this->handle_delete_form(); break; case 'toggle_status': $this->handle_toggle_status(); break; } } private function handle_save_form() { $form_data = isset( $_POST['form'] ) ? $_POST['form'] : array(); $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : array(); $handler = PC_Form_Handler::get_instance(); $form_id = $handler->save_form( $form_data, $fields ); if ( $form_id ) { $edit_url = admin_url( 'admin.php?page=pcfb-form-builder&form_id=' . $form_id ); $shortcode = '[pcfb-form id="' . $form_id . '"]'; add_action( 'admin_notices', function() use ( $edit_url, $shortcode ) { echo '
'; echo sprintf( __( 'Form saved successfully!', 'pc-form-builder-xyz123' ) ); echo '
' . esc_html__( 'Shortcode:', 'pc-form-builder-xyz123' ) . ' ' . esc_html( $shortcode ) . '
' . esc_html__( 'Go to Form Builder', 'pc-form-builder-xyz123' ) . '
'; echo esc_html__( 'Failed to save form. Please try again.', 'pc-form-builder-xyz123' ); echo '
'; echo esc_html__( 'Form deleted successfully.', 'pc-form-builder-xyz123' ); echo '
'; echo esc_html__( 'Failed to delete form. Please try again.', 'pc-form-builder-xyz123' ); echo '