whereRealm($_POST['realm'])->first(); if (empty($char->ID)) { $char = new Character(); $char->name = $_POST['name']; $char->realm = $_POST['realm']; $char->updateFromAPI(); $char->updateMedia(); } } } else { echo "NO"; } } else { echo "NO BUT IN BLACK"; } break; case 'deleteCharacter': if (current_user_can('wowpress_edit_characters')) { if (isset($_POST['deleteCharacter_nonce']) && wp_verify_nonce($_POST['deleteCharacter_nonce'], 'deleteCharacter')) { if (isset($_POST['id'])) { $char = Character::find($_POST['id']); if ($char->ID) { $char->delete(); } } } } break; case 'updateCharacter': if (current_user_can('wowpress_edit_characters')) { if (isset($_POST['updateCharacter_nonce']) && wp_verify_nonce($_POST['updateCharacter_nonce'], 'updateCharacter')) { if (isset($_POST['id'])) { $char = Character::find($_POST['id']); if ($char->ID) { $char->updateFromAPI(); $char->updateMedia(); } } } } break; } header('Location: ' . $_SERVER['HTTP_REFERER']);