• Resolved karmeljuk

    (@karmeljuk)


    Hello

    I used this code to capture errors from current child theme only, but I still see many error from parent theme

    		foreach ( $stacktrace->getFrames() as $frame ) {
    			// Check the the frame happened inside our theme or plugin
    			// Change THEME_NAME and PLUGIN_NAME to whatever is required
    			// And / or modify this <code>if</code> statement to detect other variables
    			if ( $strContainsHelper( $frame->getFile(), 'themes/brooklyn-child' )
    			) {
    				// Send the event to Sentry
    				return $event;
    			}
    		}
    

    Is it possible to ignore the parent theme?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author stayallive

    (@stayallive)

    Since it’s a child theme it makes sense errors from the parent theme occur from code within the child theme.

    But you can for sure modify that code to do anything you want, you could for example look if a frame is from the parent them and then ignore the event if there is a frame from the parent theme in there although I would be careful with that since you might ignore more than you wanted.

    Just be careful when using the $strContainsHelper because themes/brooklyn also matches themes/brooklyn-child of course so you might want to look for themes/brooklyn/ assuming (that is the directory the parent theme lives in).

    I have no code ready for you to copy paste because this is highly specific for your use case, but you should be able to write your own condition to ingore the even when you want it to be ignored. Good luck!

    Thread Starter karmeljuk

    (@karmeljuk)

    Thanks, Alex
    I wrote code in this way:

    		foreach ( $stacktrace->getFrames() as $frame ) {
    			// Check the the frame happened inside our theme or plugin
    			// Change THEME_NAME and PLUGIN_NAME to whatever is required
    			// And / or modify this <code>if</code> statement to detect other variables
    			if ( $strContainsHelper( $frame->getFile(), 'themes/brooklyn-child' ) ) {
                    // Exclude parent theme Brooklyn
                    if ( $strContainsHelper( $frame->getFile(), 'themes/brooklyn/' ) {
                        return;
                    }
    				// Send the event to Sentry
    				return $event;
    			}
    		}
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ignore for parent theme’ is closed to new replies.