File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ public function __construct( $fields = null ) {
73
73
}
74
74
75
75
/**
76
- * Set all of the snippet fields from an array or object.
76
+ * Set all snippet fields from an array or object.
77
77
* Invalid fields will be ignored
78
78
*
79
79
* @param array|object $fields List of fields
@@ -149,8 +149,12 @@ public function __get( $field ) {
149
149
return call_user_func ( array ( $ this , 'get_ ' . $ field ) );
150
150
}
151
151
152
- if ( ! isset ( $ this ->fields [ $ field ] ) ) {
153
- throw new Exception ( sprintf ( 'Snippet field %s does not exist ' , esc_html ( $ field ) ) );
152
+ if ( ! $ this ->is_allowed_field ( $ field ) ) {
153
+ if ( WP_DEBUG ) {
154
+ trigger_error ( 'Trying to access invalid property on Snippets class: ' . esc_html ( $ field ), E_WARNING );
155
+ }
156
+
157
+ return null ;
154
158
}
155
159
156
160
return $ this ->fields [ $ field ];
@@ -166,7 +170,6 @@ public function __set( $field, $value ) {
166
170
$ field = $ this ->validate_field_name ( $ field );
167
171
168
172
if ( ! $ this ->is_allowed_field ( $ field ) ) {
169
-
170
173
if ( WP_DEBUG ) {
171
174
trigger_error ( 'Trying to set invalid property on Snippets class: ' . esc_html ( $ field ), E_WARNING );
172
175
}
You can’t perform that action at this time.
0 commit comments