File: /var/www/html/insiders/wp-load/wp-content/plugins/breadly/lib/custom-code.php
<?php
add_action( 'wp_enqueue_scripts', 'gtm_include_custom_scripts', 99 );
function gtm_include_custom_scripts() {
$scripts = get_option( 'gtm_custom_scripts', [] );
if ( ! empty( $scripts ) ) {
wp_register_script( 'gtm-custom-scripts', '', [], false, true );
wp_enqueue_script( 'gtm-custom-scripts' );
foreach ( $scripts as $script ) {
if ( $script['enable'] && ! empty( $script['code'] ) ) {
wp_add_inline_script( 'gtm-custom-scripts', ';' . $script['code'] . ';' );
}
}
}
}
add_action( 'wp_enqueue_scripts', 'gtm_include_custom_styles', 99 );
function gtm_include_custom_styles() {
$styles = get_option( 'gtm_custom_styles', [] );
if ( ! empty( $styles ) ) {
foreach ( $styles as $style ) {
if ( $style['enable'] && ! empty( $style['code'] ) ) {
wp_add_inline_style( 'gtm-custom-css', $style['code'] );
}
}
}
}
add_action( 'wp_head', 'gtm_include_custom_codes', 99 );
function gtm_include_custom_codes() {
$codes = get_option( 'gtm_custom_codes', [] );
if ( ! empty( $codes ) ) {
foreach ( $codes as $code ) {
if ( $code['enable'] && ! empty( $code['code'] ) ) {
echo trim( $code['code'] );
}
}
}
}