name ?? ''; $content = $ad->content ?? ''; $position = $ad->position ?? ''; $description = $ad->description ?? ''; } else { // If somthing is posted, try to save input data. try { $input_keys = array( 'id', 'name', 'content', 'position', 'description' ); // Loop all input keys and sanitize and verify them. foreach ( $input_keys as $key ) { $html_allowed = false; if ( 'content' === $key ) { $html_allowed = true; } ${$key} = Sanitize::get( $key, 'post', $html_allowed ); // If input value is false, throw an error. if ( false === ${$key} ) { throw new Exception( ${$key} . 'has invalid characters' ); } } // Save the record to the DB. $ad = new ZumiFixedAd(); // Put values. if ( '' !== $id ) { $ad->id = $id; } else { // If $id is empty, put null and let DB to use auto increments. $ad->id = null; } $ad->name = $name; $ad->content = $content; $ad->position = $position; $ad->description = $description; $ad->save(); // Show a complete message. echo '' . esc_html( $lan->saved ) . ''; } catch ( Exception $e ) { // Show an error message. echo '' . esc_html( $e->getMessage() ) . ''; } } // Create nounce. $nonce = wp_create_nonce( 'zumi-nonce' ); ?>