File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,23 @@ export const Hooks = ( { data }: PanelProps<DataTypes['hooks']> ) => {
113113 if ( ! row . callback ) {
114114 return '' ;
115115 }
116- const text = row . callback . name || row . callback . display_file || '' ;
116+
117+ let text : string ;
118+
119+ if ( 'closure' === row . callback . callback_type ) {
120+ text = sprintf (
121+ /* translators: A closure is an anonymous PHP function. 1: Line number, 2: File name */
122+ __ ( 'Closure on line %1$d of %2$s' , 'query-monitor' ) ,
123+ row . callback . start_line ?? 0 ,
124+ row . callback . display_file ?? ''
125+ ) ;
126+ } else if ( 'unknown_closure' === row . callback . callback_type ) {
127+ /* translators: A closure is an anonymous PHP function */
128+ text = __ ( 'Unknown closure' , 'query-monitor' ) ;
129+ } else {
130+ text = row . callback . name || row . callback . display_file || '' ;
131+ }
132+
117133 if ( ! text ) {
118134 return '' ;
119135 }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ test.describe( 'Callback Types in Hooks & Actions', () => {
3333 test ( 'Closure callback should be displayed' , async ( { QueryMonitor } ) => {
3434 await QueryMonitor . amOnAPageThatTriggersCallbackType ( 'closure' ) ;
3535 await QueryMonitor . seeQMMenu ( ) ;
36- await QueryMonitor . seeInQMPanel ( 'Hooks & Actions' , 'Closure: ' ) ;
36+ await QueryMonitor . seeInQMPanel ( 'Hooks & Actions' , 'Closure on line ' ) ;
3737 await QueryMonitor . seeInQMPanel ( 'Hooks & Actions' , 'acceptance.php' ) ;
3838 await QueryMonitor . seeInQMPanel ( 'Hooks & Actions' , 'qm_test_hook' ) ;
3939 } ) ;
You can’t perform that action at this time.
0 commit comments