Mentor Themeforest Plugin Errors: script tags on functions.php

Dear Experts,

I put the following jQuery plugin activation code in functions.php as there is Redux dynamic php code.

function p_service_owl_carosel_activation(){ 
 
global $ p_redux_option; 
$p_service_content_layout = $p_redux_option['p_service_content_layout'];
?>
	<script>
		jQuery(document).ready(function(){
			jQuery('#service_owl_carousel').owlCarousel({
					autoplay: true,
					dots: false,
					responsive:{
						0:{
							items:1,
							nav:true
						},
						767:{
							items:2,
							nav:true
						},
						991:{
							items:<?php echo $p_service_content_layout; ?>,
							nav:true
						}
					}
				});
		});	
	</script>

<?php }

add_action( 'wp_footer', 'p_service_owl_carosel_activation' );

But Mentor Themeforest theme check plugin show the following error.

  1. Script tags should be included on wp_enqueue_scripts or admin_enqueue_scripts instead of embedded directly at file inc/scripts-styles.php, line 140: script”
  2. All dynamic data must be correctly escaped for the context where it is rendered. at file inc/scripts-styles.php, line 155: items:<?php echo $p_service_content_layout; ?>,

Is this error considerable?
If yes, then how can I include this script on wp_enqueue_scripts?
And how can I escape this dynamic data ( line 155: items:<?php echo $p_service_content_layout; ?> )

Moreover, this plugin also shows an error for a code that is taken from twentyseventeen theme.

  • The code handles JavaScript detection.
    And adds a js class to the root <html> element when JavaScript is detected.

And the error is below.

“Script tags should be included on wp_enqueue_scripts or admin_enqueue_scripts instead of embedded directly at file functions.php, line 150: echo “script(function(html){html.className = html.className.replace(/\bno-js\b/,‘js’)})(document.documentElement);script\n”;”

Thanks much for your time.
Regards,
Mohammad Shohel Rana

Mentor Themeforest plugin : https://github.com/Ataurr/Theme-Mentor-For-Themeforest/