' . t('About') . ''; $output .= '

' . t('This module allows you to add style and scripts in your site or , You do not need to open any file for this purpose.') . '

'; $output .= '

' . t('Uses') . '

'; $output .= '

' . t('Header and Footer Scripts provides you the capability to quickly add the style and scripts in your site. It provides you 3 regions (Header, Body, and Footer) of the page on which you can add the style and script. You can add custom style/script file, add Google or other Analytics code, inline css, inline js and so on. You can configure them from the Administer -> Configuration -> Development -> Header Footer Scripts') . '

'; return $output; } } /** * Implements hook_page_top(). * * Add scripts after the body tag on overall the site * which are defined on the settings page. */ function header_and_footer_scripts_page_top(array &$page_top) { $body_section = \Drupal::config('header_and_footer_scripts.body.settings')->get(); if (isset($body_section['styles']) && !empty($body_section['styles'])) { $output_styles = preg_split("/(<\/style>|\/>)/", $body_section['styles']); $i = 1; foreach ($output_styles as $row) { if (empty($row)) { continue; } $style_tag = 'style'; $style_attr = []; $value = ''; $style_attributes = preg_replace('/()/', $style_attributes, 2); if (isset($get_style_attr[1])) { $value = $get_style_attr[1]; } $get_style_tag = preg_split('/ 'html_tag', '#tag' => $style_tag, '#value' => $value, ]; if (!empty($style_attr)) { $page_top['top_styles_' . $i]['#attributes'] = $style_attr; } $i++; } } if (isset($body_section['scripts']) && !empty($body_section['scripts'])) { $output_scripts = preg_split("/(<\/script>|<\/noscript>)/", $body_section['scripts']); $i = 1; foreach ($output_scripts as $row) { if (empty($row)) { continue; } $script_tag = 'script'; $script_attr = []; $value = ''; $script_attributes = preg_replace('/()/', $script_attributes, 2); if (isset($get_script_attr[1])) { $value = $get_script_attr[1]; } $get_script_tag = preg_split('/