2021-02-19, 14:57:14
(This post was last modified: 2021-02-19, 14:57:54 by David Singleton.)
It is recommended to add the following META tag to the HTML header, so that the content is better displayed on a mobile device.
The question is: how to do this in Get-Simple?
I have found a way using a simple plugin, as follows:
The plugin should be installed in the 'plugins' directory. The plugin registers an action 'theme-header', which is then called automatically from the Get-Simple framework. The result is the required, inserted META tag.
Code:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
The question is: how to do this in Get-Simple?
I have found a way using a simple plugin, as follows:
Code:
<?php
/*
Plugin Name: Innovation Theme Settings
Description: Adds a META tag to the HTML header
Version: 1.2
Author: David Singleton
Author URI: -
*/
# get correct id for plugin
$thisfile_name=basename(__FILE__, ".php");
# register plugin
register_plugin(
$thisfile_name, # ID of plugin, should be filename minus php
'HeaderMetaTagPlugin', # Title of plugin
'0.1', # Version of plugin
'David Singleton', # Author of plugin
'', # Author URL
'Inserts a meta-tag in the HTML header', # Plugin Description
'theme', # Page type of plugin
'theme_header' # Function that displays content
);
# and add an action for it
add_action ('theme-header', 'theme_header', array (false));
function theme_header() {
# Insert tag: <meta name="viewport" content="width=device-width, initial-scale=1.0">
# Recommendation from https://www.w3schools.com/css/css_rwd_viewport.asp
echo ("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
}
?>
The plugin should be installed in the 'plugins' directory. The plugin registers an action 'theme-header', which is then called automatically from the Get-Simple framework. The result is the required, inserted META tag.