@@ -51,9 +51,9 @@ public function __construct( CMB2 $cmb ) {
5151 $ this ->cmb = $ cmb ;
5252 self ::$ boxes [ $ cmb ->cmb_id ] = $ cmb ;
5353
54- $ show_value = $ this ->cmb ->prop ( 'show_in_rest ' );
55- $ this ->can_read = 'write_only ' !== $ show_value ;
56- $ this ->can_write = in_array ( $ show_value , array ( 'read_and_write ' , 'write_only ' ), true );
54+ $ show_value = $ this ->cmb ->prop ( 'show_in_rest ' );
55+ $ this ->cmb -> rest_read = 'write_only ' !== $ show_value ;
56+ $ this ->cmb -> rest_write = in_array ( $ show_value , array ( 'read_and_write ' , 'write_only ' ), true );
5757 }
5858
5959 public function universal_hooks () {
@@ -100,7 +100,7 @@ protected function prepare_read_write_fields() {
100100 }
101101
102102 protected function maybe_add_read_field ( $ field_id , $ show_in_rest ) {
103- $ can_read = $ this ->can_read
103+ $ can_read = $ this ->cmb -> rest_read
104104 ? 'write_only ' !== $ show_in_rest
105105 : in_array ( $ show_in_rest , array ( 'read_and_write ' , 'read_only ' ), true );
106106
@@ -110,7 +110,7 @@ protected function maybe_add_read_field( $field_id, $show_in_rest ) {
110110 }
111111
112112 protected function maybe_add_write_field ( $ field_id , $ show_in_rest ) {
113- $ can_update = $ this ->can_write
113+ $ can_update = $ this ->cmb -> rest_write
114114 ? 'read_only ' !== $ show_in_rest
115115 : in_array ( $ show_in_rest , array ( 'read_and_write ' , 'write_only ' ), true );
116116
@@ -237,7 +237,7 @@ public function field_can_update( $field_id ) {
237237
238238 $ field = $ this ->cmb ->get_field ( $ field_id );
239239 $ show_in_rest = $ field ? $ field ->args ( 'show_in_rest ' ) : 'no ' ;
240- $ can_update = $ this ->can_write
240+ $ can_update = $ this ->cmb -> rest_write
241241 ? 'read_only ' !== $ show_in_rest
242242 : in_array ( $ show_in_rest , array ( 'read_and_write ' , 'write_only ' ), true );
243243
0 commit comments