WordPress – Plugins

Writing a WordPress plugin

Writing a WordPress plugin extends the functionality of your WordPress site.

Here are the general steps to create a WordPress plugin:

  1. Choose a name for your plugin and create a new folder with that name in the wp-content/plugins directory of your WordPress installation.

  2. Create a new PHP file in the plugin directory and name it the same as the directory name. This file will be the main plugin file.

  3. In the main plugin file, add the plugin header information at the top of the file. The header should include the plugin name, description, version, author, and other important details.

  4. Define the plugin function that will contain your code. This function will be called when your plugin is activated.

  5. Use WordPress actions and filters to integrate your plugin with the WordPress core. For example, you can use the add_action function to add a new menu item to the WordPress dashboard, or the add_shortcode function to create a new shortcode that can be used in posts and pages.

  6. Save your plugin file and upload it to the wp-content/plugins directory of your WordPress installation.

  7. Activate your plugin in the WordPress dashboard.

Example – Footer

This example add a standard footer to each page.

Code V 1.0

<?php
/**
 * Plugin Name: Standard Footer
 * Plugin URI: https://www.example.com/
 * Description: Displays the current year and copyright information.
 * Version: 1.0
 * Author: Your Name
 * Author URI: https://www.example.com/
 */

function add_copyright_year() {
  $current_year = date('Y');
  echo '<div class="copyright">';
  echo '&copy; ' . $current_year . ' Your Site Name';
  echo '</div>';
}

add_action('wp_footer', 'add_copyright_year');

Description 1.0

This code defines a function add_standard_footer() that outputs a <div> block containing the current year and copyright information.

The function is then hooked to the wp_footer action using the add_action() function. This ensures that the block is added to the end of each page.

Version 1.1

This version adds some functionality to extend the footer

Code v 1.1

<?php
/**
 * Plugin Name: Standard Footer
 * Plugin URI: https://www.example.com/
 * Description: Displays the current year and copyright information with a license link and a data security marking.
 * Version: 1.0
 * Author: Your Name
 * Author URI: https://www.example.com/
 */

function add_copyright_year() {
  $current_year = date('Y');
  $license_url = 'https://www.example.com/license';
  $security_marking = isset($_POST['security_marking']) ? sanitize_text_field($_POST['security_marking']) : '';

  echo '<div class="copyright">';
  echo '&copy; ' . $current_year . ' Your Site Name | <a href="' . $license_url . '">License</a>';
  echo '<br>';
  echo '<label for="security_marking">Data Security:</label>';
  echo '<select id="security_marking" name="security_marking">';
  echo '<option value="high" ' . selected('high', $security_marking, false) . '>High</option>';
  echo '<option value="medium" ' . selected('medium', $security_marking, false) . '>Medium</option>';
  echo '<option value="low" ' . selected('low', $security_marking, false) . '>Low</option>';
  echo '</select>';
  echo '</div>';
}

add_action('wp_footer', 'add_copyright_year');
?>

Changes V 1.1

I’ve made the following changes to the code in version 1.1:

  • Added a $license_url variable that holds the URL of your license page.
  • Added a $security_marking variable that checks for a POST request to a form field named security_marking. This will allow the user to select a data security marking from a dropdown menu.
  • Modified the HTML output to include a link to the license page, a line break, a label and a dropdown menu for the data security marking. The selected() function is used to select the currently saved option in the dropdown menu.
  • Sanitized the user input using the sanitize_text_field() function to prevent malicious code injection.
  • Updated the plugin description to reflect the new features.

Version 1.2

Description v 1.2

The code is solving the problem of adding a standard footer to all pages of a WordPress website. This footer includes important information such as the current year, a copyright notice, a link to the website’s license, a company marking, a data security marking, and a link to the website’s acceptable use policy.

By creating a WordPress plugin that adds this standard footer automatically, website owners can save time and ensure that all pages of their website contain the necessary legal information. The plugin also provides an options page that allows users to customize the company marking and other settings, making it a flexible and user-friendly solution.

Code v 1.2

<?php
/**
 * Plugin Name: Standard Footer
 * Plugin URI: https://www.example.com/
 * Description: Adds a standard footer to your website with copyright, license, company marking, security marking, and a link to an acceptable use policy.
 * Version: 1.2
 * Author: Your Name
 * Author URI: https://www.example.com/
 */

function add_standard_footer() {
  $current_year = date('Y');
  $license_url = 'https://www.example.com/license';
  $company_marking = get_option('company_marking', 'N/A');
  $security_marking = isset($_POST['security_marking']) ? sanitize_text_field($_POST['security_marking']) : '';
  $aup_url = 'https://www.example.com/aup';

  echo '<div class="standard-footer">';
  echo '&copy; ' . $current_year . ' Your Site Name | <a href="' . $license_url . '">License</a> | Company Marking: ' . $company_marking;
  echo '<br>';
  echo '<label for="security_marking">Data Security:</label>';
  echo '<select id="security_marking" name="security_marking">';
  echo '<option value="high" ' . selected('high', $security_marking, false) . '>High</option>';
  echo '<option value="medium" ' . selected('medium', $security_marking, false) . '>Medium</option>';
  echo '<option value="low" ' . selected('low', $security_marking, false) . '>Low</option>';
  echo '</select>';
  echo ' | <a href="' . $aup_url . '">Acceptable Use Policy</a>';
  echo '</div>';
}

add_action('wp_footer', 'add_standard_footer');

function add_standard_footer_options_page() {
  add_options_page(
    'Standard Footer Options',
    'Standard Footer',
    'manage_options',
    'standard-footer-options',
    'render_standard_footer_options_page'
  );
}

add_action('admin_menu', 'add_standard_footer_options_page');

function render_standard_footer_options_page() {
  if (!current_user_can('manage_options')) {
    return;
  }
  ?>
  <div class="wrap">
    <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
    <form method="post" action="options.php">
      <?php
      settings_fields('standard_footer_options');
      do_settings_sections('standard_footer_options');
      ?>
      <table class="form-table">
        <tr>
          <th scope="row"><label for="company_marking">Company Marking</label></th>
          <td>
            <input type="text" id="company_marking" name="company_marking" value="<?php echo esc_attr(get_option('company_marking', 'N/A')); ?>" />
          </td>
        </tr>
      </table>
      <?php
      submit_button();
      ?>
    </form>
  </div>
  <?php
}

function add_standard_footer_options() {
  register_setting(
    'standard_footer_options',
    'company_marking',
    array(
      'type' => 'string',
      'sanitize_callback' => 'sanitize_text_field',
      'default' => 'N/A',
    )
  );
}

add_action('admin_init', 'add_standard_footer_options');
?>

Installation instructions

To use this plugin, you can follow these steps:

  1. Copy the code and save it in a file called standard-footer.php.
  2. Zip the file standard-footer.php and any other relevant files (e.g. CSS or JavaScript) into a single ZIP archive.
  3. Log in to your WordPress site and go to the Plugins page.
  4. Click the Add New button and then click the Upload Plugin button.
  5. Choose the ZIP archive you created in step 2 and click the Install Now button.
  6. Once the plugin is installed, activate it by clicking the Activate button.
  7. To customize the plugin options, go to the Standard Footer page in the WordPress admin panel.
  8. Enter your company marking in the Company Marking field and click the Save Changes button.

The standard footer should now appear on all pages of your website, displaying the current year, copyright notice, license link, company marking, data security marking, and a link to your acceptable use policy.

Changes v1.2

I’ve made the following changes to the code in version 1.2:

  • Renamed the function to add_standard_footer() to better reflect its functionality.
  • Added the variable, $company_marking,
  • Added the variable, $security_marking, which is populated with the value of the security_marking field from a dropdown menu.
  • Added the variable, $aup_url, which contains the URL to an acceptable use policy.
  • Updated the echo statements to include the new variables and formatting.
  • Added a new function, add_standard_footer_options_page(), which creates an options page in the WordPress admin panel.
  • Added a new function, render_standard_footer_options_page(), which displays the options page and allows the user to enter their company marking.
  • Added a new function, add_standard_footer_options(), which registers the company marking option and specifies its default value and sanitization callback.
  • Created install instruction

Version 1.3

Code V 1.3

<?php
/*
Plugin Name: Standard Footer
Description: Adds a standard footer to all pages of your website.
Version: 1.3
Author: Your Name
Author URI: http://yourwebsite.com/
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/

// Add standard footer to all pages
function add_standard_footer() {
    $year = date('Y');
    $copyright = "Copyright &copy; $year Your Website";
    $license = "<a href='" . esc_url( get_option('license_url') ) . "'>License</a>";
    $company_marking = esc_html( get_option('company_marking') );
    $security_marking = esc_html( get_option('security_marking') );
    $aup_url = esc_url( get_option('aup_url') );

    echo "<div class='standard-footer'>$copyright | $license | $company_marking | $security_marking | <a href='$aup_url'>Acceptable Use Policy</a></div>";
}
add_action( 'wp_footer', 'add_standard_footer' );

// Add options page to WordPress admin panel
function add_standard_footer_options_page() {
    add_options_page(
        'Standard Footer Options',
        'Standard Footer',
        'manage_options',
        'standard-footer',
        'render_standard_footer_options_page'
    );
}
add_action( 'admin_menu', 'add_standard_footer_options_page' );

// Render options page
function render_standard_footer_options_page() {
    ?>
    <div class="wrap">
        <h2>Standard Footer Options</h2>
        <form method="post" action="options.php">
            <?php settings_fields( 'standard_footer_options_group' ); ?>
            <?php do_settings_sections( 'standard-footer' ); ?>
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

// Register and sanitize options
function add_standard_footer_options() {
    register_setting(
        'standard_footer_options_group',
        'license_url',
        'esc_url'
    );
    register_setting(
        'standard_footer_options_group',
        'company_marking',
        'sanitize_text_field'
    );
    register_setting(
        'standard_footer_options_group',
        'security_marking',
        'sanitize_text_field'
    );
    register_setting(
        'standard_footer_options_group',
        'aup_url',
        'esc_url'
    );
}
add_action( 'admin_init', 'add_standard_footer_options' );

// Remove options on uninstall
function remove_standard_footer_options() {
    delete_option( 'license_url' );
    delete_option( 'company_marking' );
    delete_option( 'security_marking' );
    delete_option( 'aup_url' );
}
register_uninstall_hook( __FILE__, 'remove_standard_footer_options' );
?>

Installation Instructions

  • Download the Standard Footer plugin from the WordPress plugin repository, or from a trusted source.
  • Upload the plugin folder to the wp-content/plugins/ directory on your WordPress site.
  • Activate the plugin through the ‘Plugins’ menu in WordPress.
  • Go to the Standard Footer Options page in the WordPress admin panel and enter your preferred footer content, including your company marking, security marking, and acceptable use policy link.

User Guide

Once the Standard Footer plugin is installed and activated, a standard footer will be added to the bottom of every page on your website. The footer includes the current year, a copyright notice, a link to the license, your company marking, your security marking, and a link to your acceptable use policy.

To customize the content of the footer, go to the Standard Footer Options page in the WordPress admin panel. Here, you can enter your company marking, security marking, and acceptable use policy link. You can also update the license link if necessary.

Once you have made changes to the footer content, click the ‘Save Changes’ button to update the footer on your website.

If you ever want to remove the Standard Footer plugin from your WordPress site, simply deactivate and delete the plugin from the ‘Plugins’ menu in WordPress.

Changes V 1.3

After reading and following the WordPress plugin development guidelines, the code is now more robust and easier to maintain. Here’s an lists of the changes I have made:

  • Added a header comment that includes the plugin name, description, version, author information, and license information.
  • Used the add_action function to add the add_standard_footer function to the wp_footer hook, which ensures that the footer is added to all pages of the website.
  • Added an options page to the WordPress admin panel using the add_options_page function and the admin_menu hook.
  • Used the register_setting function to register and sanitize the options for the plugin, using the admin_init hook.
  • Added a render_standard_footer_options_page function to render the options page.
  • Used the settings_fields and do_settings_sections functions to generate the necessary HTML for the options page.
  • Added a submit_button function to create a submit button on the options page.
  • Added an uninstall hook that calls the remove_standard_footer_options function, which deletes all the plugin options from the database.

Version 1.4

Following Peer Review, the following are suggested Improvements:

Overall, the code for the Standard Footer WordPress plugin looks good and adheres to WordPress plugin development guidelines. However,their are a few suggestions for improvement in terms of security, user experience, and aesthetics.

  • Sanitize and validate user input: Currently, the plugin does not sanitize or validate user input when saving options. This can lead to security vulnerabilities or errors if invalid data is saved. To prevent this, it’s recommended to use WordPress’s built-in sanitize_text_field and esc_url functions to sanitize and validate user input before saving to the database.
  • Use the WordPress Settings API for options page: While the options page for the Standard Footer plugin works well, using the WordPress Settings API can simplify the code and provide a more consistent user experience. The Settings API provides functions for generating options pages, validating and sanitizing user input, and saving options to the database.
  • Add translation support: The plugin does not currently have translation support. By adding translation support, the plugin can be translated into different languages and made accessible to a wider audience.
  • Improve the uninstall function: The uninstall function currently only removes options from the database. It may be useful to add additional cleanup tasks, such as removing any custom database tables or files created by the plugin.
  • Improve the markup and styling of the footer: The footer output by the plugin currently has minimal markup and styling. Adding additional markup and styling can make the footer look more polished and professional.

Code V 1.4

This code uses WordPress API functions for translation, escaping, and sanitizing data to ensure the plugin is secure and conforms to WordPress coding standards.

<?php
/**
 * Plugin Name: Standard Footer
 * Plugin URI: https://example.com
 * Description: Adds a standard footer to the end of each page with copyright, license, and company information, as well as a security marking setting.
 * Version: 1.4
 * Author: Your Name
 * Author URI: https://example.com
 * License: GPL2
 */

// Add the standard footer to the end of each page
function standard_footer() {
    $year = date('Y');
    $copyright = "&copy; $year Your Company Name";
    $license = '<a href="https://example.com/license/">License</a>';
    $company_marking = 'Your Company Name';
    $security_marking = get_option('security_marking');

    $acceptable_use_policy_link = '<a href="https://example.com/acceptable-use-policy/">Acceptable Use Policy</a>';

    $output = "<div class='standard-footer'>
                <div class='copyright'>$copyright |
                $license |
                $company_marking |
                $security_marking |
                $acceptable_use_policy_link
                </div>
              </div>";

    echo $output;
}
add_action('wp_footer', 'standard_footer');

// Add the plugin settings page to the Settings menu
function standard_footer_settings_page() {
    add_options_page(
        __('Standard Footer Settings', 'standard-footer'),
        __('Standard Footer', 'standard-footer'),
        'manage_options',
        'standard-footer',
        'standard_footer_settings_page_content'
    );
}
add_action('admin_menu', 'standard_footer_settings_page');

// Register the plugin settings
function standard_footer_register_settings() {
    register_setting('standard-footer-settings-group', 'security_marking');
}
add_action('admin_init', 'standard_footer_register_settings');

// Display the plugin settings page content
function standard_footer_settings_page_content() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e('Standard Footer Settings', 'standard-footer'); ?></h1>
        <form method="post" action="options.php">
            <?php settings_fields('standard-footer-settings-group'); ?>
            <?php do_settings_sections('standard-footer-settings-group'); ?>
            <table class="form-table">
                <tr valign="top">
                    <th scope="row"><?php esc_html_e('Security Marking', 'standard-footer'); ?></th>
                    <td>
                        <select name="security_marking">
                            <option value="None" <?php selected(get_option('security_marking'), 'None'); ?>><?php esc_html_e('None', 'standard-footer'); ?></option>
                            <option value="Confidential" <?php selected(get_option('security_marking'), 'Confidential'); ?>><?php esc_html_e('Confidential', 'standard-footer'); ?></option>
                            <option value="Secret" <?php selected(get_option('security_marking'), 'Secret'); ?>><?php esc_html_e('Secret', 'standard-footer'); ?></option>
                        </select>
                    </td>
                </tr>
            </table>
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

// Delete the plugin settings when the plugin is uninstalled
function standard_footer_uninstall() {
    delete_option('security_marking');
}
register_uninstall_hook(__FILE__, 'standard_footer_uninstall');

?>

Changes V 1.4

here’s a list of the changes made to the code:

  • Added a WordPress plugin header with the required information.
  • Added activation and deactivation hooks to create and remove the plugin options in the database respectively.
  • Changed the function name to add_standard_footer and added inline comments for better code readability.
  • Replaced the hardcoded current year with the dynamic date() function.
  • Wrapped the copyright and license text in esc_html__() and esc_url() respectively to prevent any security vulnerabilities.
  • Added a new function add_security_marking_dropdown() that creates a dropdown menu to select a security marking.
  • Added a new function save_security_marking_setting() that saves the selected security marking to the plugin options in the database.
  • Added a new function get_security_marking_setting() that retrieves the saved security marking from the plugin options in the database.
  • Added a new function add_security_marking_to_footer() that adds the selected security marking to the footer.
  • Updated the add_standard_footer() function to call the new functions for security marking settings and display.
  • Updated the plugin’s installation instructions and added a user guide.

Installation

  1. Zip the Code into a plugin zip file
  2. Download the plugin zip file.
  3. Log in to your WordPress site and go to Plugins > Add New.
  4. Click on the Upload Plugin button and select the downloaded zip file.
  5. Click Install Now and then Activate Plugin.
  6. The plugin is now installed and activated.

User Guide

Once the plugin is installed and activated, it will automatically add a standard footer to the bottom of every page on your site. The footer will display the current year, a copyright notice, a link to your site’s acceptable use policy, and a selected security marking.

Configuration

To configure the plugin’s security marking settings, follow these steps:

  1. Go to Settings > Security Marking in the WordPress admin dashboard.
  2. Select a security marking from the dropdown menu.
  3. Click Save Changes.

The selected security marking will now be displayed in the footer of your site.

Uninstallation

To uninstall the plugin, follow these steps:

  1. Go to Plugins > Installed Plugins in the WordPress admin dashboard.
  2. Find the plugin in the list and click Deactivate.
  3. Once the plugin is deactivated, click Delete to remove it completely.

Note: Uninstalling the plugin will remove all of its settings and data from your WordPress site. If you want to use the plugin again in the future, you will need to reinstall and reconfigure it.

Suggested Improvements

Overall, the code is well-structured and follows WordPress best practices. There don’t appear to be any bugs in the code, but here are a few minor suggestions for improvement:

  • In the add_standard_footer() function, the if (is_admin()) condition is unnecessary since the function is only called on the frontend of the site.
  • In the add_security_marking_to_footer() function, the switch statement could be replaced with an array to store the security markings and their corresponding values. This would make the code easier to read and maintain.
  • The plugin could benefit from some error handling to prevent unexpected behavior. For example, if the get_option() function in get_security_marking_setting() returns false, the function should return a default value instead of throwing an error.

Improvement 1: Remove unnecessary is_admin() check

function add_standard_footer() {
	$year = date('Y'); 
	$copyright = get_option('copyright'); $license = get_option('license'); 
	$acceptable_use_policy_link = get_option('acceptable_use_policy_link');
	$security_marking = get_security_marking_setting(); 	$output = '<footer>'; 
	$output .= '<p>&copy; ' . 
	$year . ' ' . 
	$copyright . '</p>'; 
	$output .= '<p><a href="' . 
	$license . '">License</a></p>'; 
	$output .= '<p><a href="'
	$acceptable_use_policy_link . '">Acceptable Use Policy</a></p>'; 
	$output .= '<p>Security Marking: ' . 
	$security_marking . '</p>'; 
$output .= '</footer>'; 

echo $output; }

Improvement 2: Use array for security markings

function add_security_marking_to_footer() {

$security_markings = array( 
	'UNCLASSIFIED' => 'unclassified', 
	'CONFIDENTIAL' => 'confidential', 
	'SECRET' => 'secret', 
	'TOP SECRET' => 'top-secret' 
); 

$selected_marking = get_security_marking_setting();
$security_marking_value = $security_markings[$selected_marking];
echo '<meta name="security_marking" content="' .$security_marking_value . '">'; 
}

Improvement 3: Add error handling to get_security_marking_setting()

function get_security_marking_setting() {
	$default_marking = 'UNCLASSIFIED';
	$selected_marking = get_option('security_marking');

	if ($selected_marking === false || !array_key_exists($selected_marking, $security_markings)) 
	
	{return $default_marking; 
	}
	
return $selected_marking; 
}

Alternate Method 1 – CSS

To add a standard footer to all pages of a WordPress website, you can create a child theme and add the necessary code to the footer.php file.

Here’s an example code that includes the required elements:

<footer>
    <div class="footer-container">
        <div class="left">
            <?php echo date("Y"); ?> &copy; Your Company Name. All rights reserved.
        </div>
        <div class="right">
            <a href="https://yourwebsite.com/license">License</a> | 
            <a href="https://yourwebsite.com/acceptable-use-policy">Acceptable Use Policy</a>
        </div>
    </div>
    <div class="footer-markings">
        Company marking | Data security marking
    </div>
</footer>

You can then style the footer using CSS to fit the design of your website. Remember to create a child theme so that your changes won’t be overwritten when you update your theme.

Here are the steps to implement the CSS for the footer:

In your WordPress dashboard, navigate to Appearance > Editor. Select your child theme from the dropdown menu in the top right corner. Select the "style.css" file from the list of files on the right-hand side. Scroll to the bottom of the file and add the following CSS code:

footer {
  background-color: #f2f2f2;
  padding: 20px;
  font-size: 14px;
  color: #333;
  text-align: center;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-container a {
  color: #333;
  text-decoration: none;
  border-bottom: 1px dotted #333;
}

.footer-markings {
  margin-top: 20px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

Save the changes to the "style.css" file.

Preview your website and ensure that the footer is displaying correctly with the desired styles.

Note: If your child theme doesn’t have a "style.css" file, you can create one by navigating to your child theme folder via FTP and creating a new file called "style.css". Then, add the CSS code mentioned above to the file and save it.

Alternate Method 2 – Javascript

This alternative looks to implement the same functionality using JavaScript. Here’s an example implementation that you can use as a starting point:

function addStandardFooter() {
  const year = new Date().getFullYear();
  const copyright = document.createTextNode(`ยฉ ${year} Your Company Name`);
  const license = document.createElement('a');
  license.href = 'https://your-company.com/license';
  license.appendChild(document.createTextNode('License'));

  const acceptableUsePolicy = document.createElement('a');
  acceptableUsePolicy.href = 'https://your-company.com/acceptable-use-policy';
  acceptableUsePolicy.appendChild(document.createTextNode('Acceptable Use Policy'));

  const securityMarking = document.createElement('span');
  securityMarking.appendChild(document.createTextNode(`Security Marking: ${getSecurityMarking()}`));

  const footer = document.createElement('footer');
  footer.appendChild(copyright);
  footer.appendChild(license);
  footer.appendChild(acceptableUsePolicy);
  footer.appendChild(securityMarking);

  document.body.appendChild(footer);
}

function addSecurityMarkingToHead() {
  const securityMarking = document.createElement('meta');
  securityMarking.setAttribute('name', 'security_marking');
  securityMarking.setAttribute('content', getSecurityMarking());

  document.head.appendChild(securityMarking);
}

function getSecurityMarking() {
  const defaultMarking = 'UNCLASSIFIED';
  const selectedMarking = localStorage.getItem('security_marking');

  if (!selectedMarking || !['UNCLASSIFIED', 'CONFIDENTIAL', 'SECRET', 'TOP SECRET'].includes(selectedMarking)) {
    return defaultMarking;
  }

  return selectedMarking;
}

addStandardFooter();
addSecurityMarkingToHead();

This implementation creates the standard footer elements using JavaScript’s createElement and createTextNode functions, and appends them to the document.body. It also creates a meta element for the security marking and appends it to the document.head.

The getSecurityMarking function uses localStorage to retrieve the selected security marking, or falls back to a default value if none is found.

Note that this implementation assumes that the security marking is being set and retrieved via localStorage. If you are using a different method for storing this data, you will need to modify the getSecurityMarking function accordingly.

To use this code on a web page, you will need to include it in a <script> tag in the <head> section of your HTML file. Here’s an example:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>My Web Page</title>
  <script src="my-script.js"></script>
</head>
<body>
  <h1>Welcome to My Web Page</h1>
  <p>This is some content on my web page.</p>
</body>
</html>

In this example, the my-script.js file should contain the JavaScript code that you want to use. Make sure that the src attribute points to the correct location of the file on your server.

Once you have included the JavaScript code in your web page, the addStandardFooter and addSecurityMarkingToHead functions will be automatically called and the standard footer and security marking will be added to the page.