/** * * @global wpdb $wpdb * @return string */ function edit_persona_page_handler() { try { $action = admin_url('/tools.php?page=rootsPersona&rootspage=edit'); $batch_id = isset($atts['batchid']) ? $atts['batchid'] : '1'; $options = get_option('persona_plugin'); $isSOR = $options['is_system_of_record'] == '1' ? true : false; if (!isset($_POST['submitPersonForm'])) { $persona_id = isset($_GET['personId']) ? trim(esc_attr($_GET['personId'])) : ''; $batch_id = isset($_GET['batchId']) ? $_GET['batchId'] : '1'; if (!empty($persona_id)) { $edit_action = isset($_GET['action']) ? trim(esc_attr($_GET['action'])) : ''; $src_page = isset($_GET['srcPage']) ? trim(esc_attr($_GET['srcPage'])) : ''; if ($edit_action == 'edit') { $options['src_page'] = $src_page; $builder = new RP_Edit_Page_Builder(); $options = $builder->get_persona_options($options); $factory = new RP_Persona_Factory($this->credentials); if ($isSOR == false) { $persona = $factory->get_for_edit($persona_id, $batch_id, $options); } else { $persona = $factory->get_with_options($persona_id, $batch_id, $options); } return $builder->build($persona, $action, $options); } elseif ($edit_action == 'delete') { wp_delete_post($src_page); return RP_Persona_Helper::redirect_to_page($src_page); } } else { if ($isSOR === true) { $builder = new RP_Edit_Page_Builder(); $options = $builder->get_persona_options($options); $persona = new RP_Persona(); $famc = isset($_GET['famc']) ? trim(esc_attr($_GET['famc'])) : ''; $fams = isset($_GET['fams']) ? trim(esc_attr($_GET['fams'])) : ''; $child = isset($_GET['child']) ? trim(esc_attr($_GET['child'])) : ''; $sseq = isset($_GET['sseq']) ? trim(esc_attr($_GET['sseq'])) : ''; $spouse = isset($_GET['spouse']) ? trim(esc_attr($_GET['spouse'])) : ''; if ($famc != '') { $persona->famc = $famc; } else { if ($fams != '') { $persona->fams = $fams; $persona->spouse = $spouse; $persona->sseq = $sseq == '1' ? '2' : '1'; } else { if ($child != '') { //add person as parent of child, no family record exists $persona->fams = -1; $persona->child = $child; $persona->sseq = $sseq == '1' ? '2' : '1'; } } } return $builder->build($persona, $action, $options); } return __('Missing', 'rootspersona') . ' personId:' . $persona_id; } } } catch (Exception $e) { error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0); return '<span style="color:red;margin-top:20px;display:inline-block;">' . $e->getMessage() . "::" . RP_Persona_Helper::trace_caller() . '</span>'; } }