File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 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 ) {
7373 }
7474
7575 /**
76- * Set all of the snippet fields from an array or object.
76+ * Set all snippet fields from an array or object.
7777 * Invalid fields will be ignored
7878 *
7979 * @param array|object $fields List of fields
@@ -149,8 +149,12 @@ public function __get( $field ) {
149149 return call_user_func ( array ( $ this , 'get_ ' . $ field ) );
150150 }
151151
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 ;
154158 }
155159
156160 return $ this ->fields [ $ field ];
@@ -166,7 +170,6 @@ public function __set( $field, $value ) {
166170 $ field = $ this ->validate_field_name ( $ field );
167171
168172 if ( ! $ this ->is_allowed_field ( $ field ) ) {
169-
170173 if ( WP_DEBUG ) {
171174 trigger_error ( 'Trying to set invalid property on Snippets class: ' . esc_html ( $ field ), E_WARNING );
172175 }
You can’t perform that action at this time.
0 commit comments