$caller_function, 'class' => $caller_class, 'file' => $caller_file, 'line' => $caller_line, 'type' => $source['type'], 'name' => $source['name'], ]; return $res; } private static function get_source( $filename ) { $name = 'Unknown'; $type = ''; if ( str_contains( $filename, WP_CONTENT_DIR ) ) { $file = str_replace( WP_CONTENT_DIR, '', $filename ); $short_path = explode( '/', $file ); if ( count( $short_path ) >= 3 ) { $type = $short_path[1]; $name = $short_path[2]; } } return [ 'name' => $name, // plugin/theme name. 'type' => $type, // is it a plugin or a theme. ]; } }