1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
final class Papi_Admin_Option_Handler extends Papi_Core_Data_Handler {
public function save_properties() {
if ( ! papi_is_method( 'post' ) || papi_get_meta_type() !== 'option' ) {
return;
}
if ( ! wp_verify_nonce( papi_get_sanitized_post( 'papi_meta_nonce' ), 'papi_save_data' ) ) {
return;
}
$data = $this->get_post_data();
$data = $this->prepare_properties_data( $data, 0 );
foreach ( $data as $key => $value ) {
papi_update_property_meta_value( [
'id' => 0,
'slug' => $key,
'type' => 'option',
'value' => $value
] );
}
}
protected function setup_actions() {
add_action( 'admin_init', [$this, 'save_properties'] );
}
}
if ( is_admin() ) {
new Papi_Admin_Option_Handler;
}