Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active August 13, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/7bbd1fa4b3724220c556f5d6761b7714 to your computer and use it in GitHub Desktop.
Save parzibyte/7bbd1fa4b3724220c556f5d6761b7714 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Insertar publicidad entre párrafos
Plugin URI: https://parzibyte.me/blog
Description: Insertar publicidad entre párrafos
Version: 1.0
Author: Luis Cabrera Benito a.k.a Parzibyte
Author URI: https://parzibyte.me/blog
*/
defined("ABSPATH") or die("No es permitido el acceso directo al archivo");
if (!class_exists("ParzibytePublicidad")) {
class ParzibytePublicidad
{
public static function iniciar()
{
add_filter("the_content", "ParzibytePublicidad::agregar_publicidad");
}
public function agregar_publicidad($contenido)
{
if (is_single() && in_the_loop() && is_main_query()) {
return "<p>Al inicio</p>" . $contenido . "<p>Al final</p>";
}
return $contenido;
}
}
ParzibytePublicidad::iniciar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment