<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress Hacks &#187; functionsphp</title>
	<atom:link href="http://wordpress-hacks.com/tag/functionsphp/feed" rel="self" type="application/rss+xml" />
	<link>http://wordpress-hacks.com</link>
	<description>Tips y consejos de WordPress en español</description>
	<lastBuildDate>Wed, 25 Jan 2012 11:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Botón de bitacoras.com para votar sin usar el plugin</title>
		<link>http://wordpress-hacks.com/boton-de-bitacorascom-para-votar-sin-usar-el-plugin.php</link>
		<comments>http://wordpress-hacks.com/boton-de-bitacorascom-para-votar-sin-usar-el-plugin.php#comments</comments>
		<pubDate>Thu, 14 May 2009 02:03:51 +0000</pubDate>
		<dc:creator>Neri Aispuro</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[array en php]]></category>
		<category><![CDATA[Bitacorascom]]></category>
		<category><![CDATA[functionsphp]]></category>
		<category><![CDATA[get_permalink]]></category>
		<category><![CDATA[singlephp]]></category>

		<guid isPermaLink="false">http://wordpress-hacks.com/?p=261</guid>
		<description><![CDATA[A muchas personas -entre las que me incluyo- no nos gusta usar muchos plugins, si hay algo que se pueda hacer igual sin plugin, aunque sea más complicado, siempre trato de hacerlo. Hace unos momentos modificaba un theme que no era para mí, al mismo debía agregar el botón de [...]]]></description>
			<content:encoded><![CDATA[<p>A muchas personas -entre las que me incluyo- no nos gusta usar muchos plugins, si hay algo que se pueda hacer igual sin plugin, aunque sea más complicado, siempre trato de hacerlo.</p>
<p>Hace unos momentos modificaba un theme que no era para mí, al mismo debía agregar el botón de <a href="http://bitacoras.com/">bitácoras</a>, y no tenía ganas de sugerir a quién me lo había enviado, que tenía que instalar el <a href="http://wordpress.org/extend/plugins/bitacorascom/">plugin de bitácoras</a> para que funcione un botoncito.</p>
<p>¿Cómo Hacerlo?</p>
<p>Pegar el siguiente código en el functions.php de tu theme.</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">Ver texto plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> agregador_bitacoras_com<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tipo</span> = <span style="color:#FF0000;">'normal'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$permalink</span> = <a href="http://www.php.net/preg_replace"><span style="color:#000066;">preg_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/^https?:<span style="color:#000099; font-weight:bold;">\/</span><span style="color:#000099; font-weight:bold;">\/</span>/'</span>, <span style="color:#FF0000;">''</span>, get_permalink<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tipo</span> == <span style="color:#FF0000;">'favicon'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&lt;a href=&quot;http://bitacoras.com/anotaciones/'</span>.<span style="color:#0000FF;">$permalink</span>.<span style="color:#FF0000;">'&quot; title=&quot;Votar Anotaci&amp;oacute;n en Bitacoras.com&quot;&gt;&lt;img src=&quot;http://static2.bitacoras.com/images/agregador/bitacorascom16x16.gif&quot; alt=&quot;Votar&quot; style=&quot;vertical-align:middle;border:0&quot; /&gt;&lt;/a&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$tipo</span> = <a href="http://www.php.net/in_array"><span style="color:#000066;">in_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tipo</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'mini'</span>, <span style="color:#FF0000;">'mini2'</span>, <span style="color:#FF0000;">'big'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>? <span style="color:#0000FF;">$tipo</span> : <span style="color:#FF0000;">'normal'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&lt;a href=&quot;http://bitacoras.com/anotaciones/'</span>.<span style="color:#0000FF;">$permalink</span>.<span style="color:#FF0000;">'&quot;&gt;&lt;img src=&quot;http://widgets.bitacoras.com/votar/'</span>.<span style="color:#0000FF;">$tipo</span>.<span style="color:#FF0000;">'/'</span>.<span style="color:#0000FF;">$permalink</span>.<span style="color:#FF0000;">'&quot; alt=&quot;votar&quot; title=&quot;Votar esta anotaci&amp;oacute;n en Bitacoras.com&quot; style=&quot;vertical-align:middle;border:0&quot; /&gt;&lt;/a&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Decodificando un poco este código, a simple vista:<br />
Le da el nombre a la función: agregador_bitacoras_com.<br />
Dice que el tipo de botón por defecto es el llamado "Normal".<br />
Después dice que; si el tipo que elegimos cuando llamamos al código es "Favicon", muestre el tipo favicon llamando su src.<br />
Luego llama a una función array, agregando los elementos "mini", "mini2", y "big", que son más tipos de botones.<br />
Después, usa la función <strong>get_permalink</strong> (que toma el link permanente de la url en la que estemos) y según el valor que hayamos elegido para los botones, llama al botón correcto.</p>
<p>Después de una básica explicación, vamos a lo que nos interesa, agregar el botón sin el plugin.<br />
Una vez que entendemos que estamos pegando en el functions.php, lo guardamos y vamos a donde queremos que aparesca el botón.<br />
Yo recomiendo ponerlo en el single.php al final del post, y antes de los comentarios.</p>
<p>Cuando decidan donde lo van a agregar, van a tener que elegir el tipo de botón, por defecto es "Normal".<br />
El código que tenemos que agregar:</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showPlainTxt('php-5'); return false;">Ver texto plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color:#000066;">function_exists</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'agregador_bitacoras_com'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; agregador_bitacoras_com<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'normal'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pueden ver los ejemplos de botones e informarse mas en el <a href="http://bitacoras.com/noticias/archivos/plugin-para-wordpress-para-el-agregador-social-de-bitacorascom.php">post de bitácoras</a>.</p>
<p>A ver si anduvo:<br />
<?php<br />
  if(function_exists('agregador_bitacoras_com'))<br />
    agregador_bitacoras_com('normal');<br />
?></p>
<p>Nota: Desconozco si esto ya se le ocurrió a alguien y si ya fué publicado, si es así pido disculpas y borro el post.</p>
<p>Actualización:<br />
A demás de llegar a portada de Bitácoras, mediante un comentario de <a href="http://dmnet.bitacoras.com/">David Martinez</a> en el artículo de bitácoras, podemos hacerlo más fácil aún, agregando el código:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">Ver texto plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;a href=<span style="color:#FF0000;">"http://bitacoras.com/anotaciones/&lt;?php the_permalink(); ?&gt;"</span>&gt;&lt;img src=<span style="color:#FF0000;">"http://widgets.bitacoras.com/votar/big/&lt;?php the_permalink(); ?&gt;"</span> alt=<span style="color:#FF0000;">"votar"</span> /&gt;&lt;/a&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La única diferencia, es que de esta nueva forma, vamos a ver un http:// en el medio de la url, ejemplo:</p>
<p>http://bitacoras.com/anotaciones/<strong>http://</strong>wordpress-hacks.com/boton-de-bitacorascom-para-votar-sin-usar-el-plugin.php</p>
<p>Después, es todo lo mismo <img src='http://wordpress-hacks.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<p><a href="http://bitacoras.com/anotaciones/<?php the_permalink(); ?>"><img src="http://widgets.bitacoras.com/votar/big/<?php the_permalink(); ?>" alt="votar" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wordpress-hacks.com/boton-de-bitacorascom-para-votar-sin-usar-el-plugin.php/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

