diff --git a/includes/activity/class-base-object.php b/includes/activity/class-base-object.php index dd3d093..9b9f044 100644 --- a/includes/activity/class-base-object.php +++ b/includes/activity/class-base-object.php @@ -746,5 +746,37 @@ class Base_Object { return $this; } + public function check_jsonld_completeness() { + // Just a debugging helper function + $vars = get_object_vars( $this ); + $total_var_count = count( $vars ); + $unset_var_array = array(); + + foreach ( $vars as $key => $value ) { + // ignore all _prefixed keys. + if ( '_' === substr( $key, 0, 1 ) ) { + --$total_var_count; + continue; + } + + // if value is empty, try to get it from a getter. + if ( ! $value ) { + $value = call_user_func( array( $this, 'get_' . $key ) ); + } + + // if value is still empty, ignore it for the array and continue. + if ( ! isset( $value ) ) { + $unset_var_array[] = $key; + } + } + $unset_var_count = count( $unset_var_array ); + + return array( + 'total_var_count' => $total_var_count, + 'unset_var_count' => $unset_var_count, + 'set_var_count' => $total_var_count - $unset_var_count, + 'unset_vars' => $unset_var_array, + ); + } }