No estoy muy seguro de lo que estás preguntando. ¿Necesita saber cómo escribir realmente un complemento? Si este es el caso, hay muchos tutoriales que cubren este tema. Algunos buenos recursos relacionados con esto:
- https://developer.wordpress.org/plugins/
- https://developer.wordpress.org/plugins/hooks/
- https://developer.wordpress.org/reference/hooks/wp_footer/
Agregar algo bueno podría ser verificar cómo está estructurado un complemento existente que hace esto, por ejemplo:
https://wordpress.org/plugins/insert-headers-and-footers/#developers
Agregue algo en el pie de página en cada página, haría algo como esto, este archivo debe agregarse debajo del wp-content/plugins
directorio:
<?php
/**
* Plugin Name: Footer plugin
* Description: Adds text to footer
* Version: 1.0.0
* Requires at least: 3.0
* Tested up to: 6.0
* Author: Author
* Text Domain: footer-plugin
**/
class FooterPlugin
{
public function __construct()
{
// hook into wp_footer
add_action('wp_footer', [$this, 'addFooter']);
}
public function addFooter()
{
echo '<span>footer text</span>';
}
}
// initialize the plugin when everything is loaded
add_action('plugins_loaded', function () {
new FooterPlugin();
});
Otra forma de hacerlo sería reemplazar el contenido del pie de página del resultado generado para la página:
class FooterPlugin
{
/** @var string */
private $replacement="SOME TEXT";
public function __construct()
{
add_action('template_redirect', [$this, 'templateRedirect']);
}
/**
* @var string $content
**/
public function templateRedirect(string $content)
{
ob_start([$this, 'handleBuffer']);
}
/**
* Replace everything in the footer tag
* @param string $buffer
* @return string
**/
public function handleBuffer(string $buffer): string
{
return preg_replace('/(<footers*.*>)((.|n)*)(</footer>)/', '$1' . $this->replacement . '$3', $buffer);
}
}
.