Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Plugin to add META tag to header
It is recommended to add the following META tag to the HTML header, so that the content is better displayed on a mobile device.

<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:
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
    $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
    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.
Easier is just putting that line in the website theme.

But kudos that you made a plugin for it. I guess it's also a nice example plugin, for people that like to learn making plugins.

Btw. if theme already has this line in it, it would be doubled, right? So then there should be a check if the line exist or not (if statement?).

Users browsing this thread: 1 Guest(s)