diff --git a/header_and_footer_scripts.module b/header_and_footer_scripts.module index f53c1f7..dcb416e 100644 --- a/header_and_footer_scripts.module +++ b/header_and_footer_scripts.module @@ -2,8 +2,8 @@ /** * @file - * Enables Drupal to add scripts and styles from frontend - * on all over the site. + * Add scripts and styles from the frontend on all over the site. + * Attach the Scripts and Styles as per your need. */ /** @@ -54,7 +54,8 @@ function header_and_footer_scripts_page_top(array &$page_top) { $attr_key_value = explode('=', $attr); if (isset($attr_key_value[0]) && isset($attr_key_value[1])) { $style_attr[$attr_key_value[0]] = $attr_key_value[1]; - } else { + } + else { $style_attr[$attr_key_value[0]] = $attr_key_value[0]; } } @@ -111,7 +112,8 @@ function header_and_footer_scripts_page_top(array &$page_top) { $attr_key_value = explode('=', $attr); if (isset($attr_key_value[0]) && isset($attr_key_value[1])) { $script_attr[$attr_key_value[0]] = $attr_key_value[1]; - } else { + } + else { $script_attr[$attr_key_value[0]] = $attr_key_value[0]; } } @@ -123,7 +125,7 @@ function header_and_footer_scripts_page_top(array &$page_top) { '#value' => $value, ]; if (is_array($script_attr)) { - $page_top['top_scripts_'.$i]['#attributes'] = $script_attr; + $page_top['top_scripts_' . $i]['#attributes'] = $script_attr; } $i++; } @@ -151,7 +153,7 @@ function header_and_footer_scripts_page_bottom(array &$page_bottom) { $style_attr = ''; $value = ''; - $style_attributes = preg_replace('/()/', $style_attributes, 2); if (isset($get_style_attr[1])) { @@ -178,7 +180,8 @@ function header_and_footer_scripts_page_bottom(array &$page_bottom) { $attr_key_value = explode('=', $attr); if (isset($attr_key_value[0]) && isset($attr_key_value[1])) { $style_attr[$attr_key_value[0]] = $attr_key_value[1]; - } else { + } + else { $style_attr[$attr_key_value[0]] = $attr_key_value[0]; } } @@ -200,13 +203,15 @@ function header_and_footer_scripts_page_bottom(array &$page_bottom) { $i = 1; foreach ($output_scripts as $row) { - if (empty($row)) continue; + if (empty($row)) { + continue; + } $script_tag = 'script'; $script_attr = ''; $value = ''; - $script_attributes = preg_replace('/()/', $script_attributes, 2); if (isset($get_script_attr[1])) { @@ -233,7 +238,8 @@ function header_and_footer_scripts_page_bottom(array &$page_bottom) { $attr_key_value = explode('=', $attr); if (isset($attr_key_value[0]) && isset($attr_key_value[1])) { $script_attr[$attr_key_value[0]] = $attr_key_value[1]; - } else { + } + else { $script_attr[$attr_key_value[0]] = $attr_key_value[0]; } } diff --git a/src/Form/BodyForm.php b/src/Form/BodyForm.php index 0e3c985..bed69b2 100644 --- a/src/Form/BodyForm.php +++ b/src/Form/BodyForm.php @@ -7,10 +7,10 @@ use Symfony\Component\HttpFoundation\Request; use Drupal\Core\Form\FormStateInterface; /** - * This Class Provides the settings page for adding CSS/JS after the body tag on the site. + * Provide settings page for adding CSS/JS after the start of body tag. */ class BodyForm extends ConfigFormBase { - + /** * Implements FormBuilder::getFormId. */ @@ -33,8 +33,8 @@ class BodyForm extends ConfigFormBase { $form['hfs_body'] = [ '#type' => 'fieldset', - '#title' => t('Add Scripts and Styles in body'), - '#description' => t('All the defined scripts and styles in this section would be added next to body tag.'), + '#title' => $this->t('Add Scripts and Styles in body'), + '#description' => $this->t('All the defined scripts and styles in this section would be added next to body tag.'), ]; $form['hfs_body']['styles'] = [ diff --git a/src/Form/FooterForm.php b/src/Form/FooterForm.php index 8ee8bae..c31f4ee 100644 --- a/src/Form/FooterForm.php +++ b/src/Form/FooterForm.php @@ -7,7 +7,7 @@ use Symfony\Component\HttpFoundation\Request; use Drupal\Core\Form\FormStateInterface; /** - * This Class Provides the settings page for adding CSS/JS before the end of body tag on the site. + * Provide settings page for adding CSS/JS before the end of body tag. */ class FooterForm extends ConfigFormBase { @@ -29,7 +29,7 @@ class FooterForm extends ConfigFormBase { * Implements FormBuilder::buildForm. */ public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) { - $footer_section = $this->config('hfs_footer_scripts.settings')->get(); + $footer_section = $this->config('hfs_footer_scripts.settings')->get(); $form['hfs_footer'] = [ '#type' => 'fieldset',