The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




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


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.
Reply
#2
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?).
Reply




Users browsing this thread: 1 Guest(s)