Skip to content

Instantly share code, notes, and snippets.

@oscarandreu
Last active December 13, 2015 22:38
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 oscarandreu/4985437 to your computer and use it in GitHub Desktop.
Save oscarandreu/4985437 to your computer and use it in GitHub Desktop.
Blogger_Articles_Snippets
<?php
/*
Plugin Name: Plugin práctica 1
Plugin URI: http://www.whatsgoingon.es/
Version: 0.1
Author: scar Andreu Martínez
Description: Plugin como práctica docente.
License: GPL2
*/
/* Copyright 2012 Óscar Andreu (email : oscarandreu at gmail dot com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
add_filter('the_content', 'func_contar_palabras');
function func_contar_palabras($content)
{
$num_words = str_word_count($content, 0); //Referncia de la función: http://www.php.net/manual/en/function.str-word-count.php
$content .= "<p><h2 style='background-color:grey;'>Este artículo consta de $num_words palabras.</h2>";
return $content;
}
add_action('wp_footer', 'func_completar_footer');
function func_completar_footer()
{
echo "<p><h2 style='background-color:grey;'>Plugin creado por Óscar Andreu.</h2>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment