How to Remove Schema Pro Comments Added to Source Code?

When you enable schema on the page, the JSON-LD schema markup is added to the source code. Schema Pro plugin adds comments for this code just to indicate the starting and ending point. In the source code, comments will look like –

In case you want to remove these comments from the source code, use the following filter. This filter will remove comments with the suffix – Schema optimized by Schema Pro.  

Note: Add the following code to your child theme’s functions.php file.

add_filter( 'wp_schema_pro_comment_before_markup_enabled', 'my_function', 10, 1 );
function my_function( $bool ) {
  return false;