$value ) { if ( $value['restriction_id'] == $data['restriction_id'] ) { $settings['restrictions'][$key] = $restriction; } } } if ( user_can( wp_get_current_user(), 'manage_options' ) ) { $is_submitted = update_option( 'all_in_one_content_restriction_settings', apply_filters( 'all_in_one_content_restriction_set_settings', $settings ), true ); if ( $is_submitted ) { $msg['msg'] = Strings::get()[123]; } else { $msg['msg'] = Strings::get()[124]; } $msg = json_encode( $msg ); echo $msg; } } public static function drop( $data ) { $settings = self::get(); if ( 'trash' === $data['action'] ) { foreach ( $settings['restrictions'] as $key => $value ) { if ( in_array( $value['restriction_id'], $data['aiocr_id'] ) ) { unset( $settings['restrictions'][$key] ); } } } else { foreach ( $settings['restrictions'] as $key => $value ) { if ( $value['restriction_id'] == $data['restriction_id'] ) { unset( $settings['restrictions'][$key] ); break; } } } if ( user_can( wp_get_current_user(), 'manage_options' ) ) { update_option( 'all_in_one_content_restriction_settings', $settings, true ); return; } } private static function sanitize_array( $array ) { foreach ( $array as &$value ) { if ( ! is_array( $value ) ) { // Sanitize if value is not an array $value = sanitize_text_field( $value ); } else { // Do inside this function again self::sanitize_array( $value ); } } return $array; } private static function create_restriction_id( $settings ) { $temp_max = 0; if ( isset( $settings['restrictions'] ) && ! empty( $settings['restrictions'] ) ) { foreach ( $settings['restrictions'] as $key => $value ) { $temp_max = max( $value['restriction_id'], $temp_max ); } } return $temp_max + 1; } }