<?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>Johan de Bruin &#187; header hook wordpress</title>
	<atom:link href="http://www.johandebruin.com/t/header-hook-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johandebruin.com</link>
	<description>Programación en php, tutorial de api wordpress y posicionamiento en buscadores seo.</description>
	<lastBuildDate>Sun, 05 Feb 2012 15:18:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Crear y configurar un widget de wordpress</title>
		<link>http://www.johandebruin.com/crear-y-configurar-un-widget-de-wordpress/</link>
		<comments>http://www.johandebruin.com/crear-y-configurar-un-widget-de-wordpress/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 16:17:42 +0000</pubDate>
		<dc:creator>Johan de Bruin</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Crear widget wordpress]]></category>
		<category><![CDATA[header hook wordpress]]></category>
		<category><![CDATA[Plugin wordpress]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Wordpress API]]></category>
		<category><![CDATA[Wordpress hook]]></category>
		<category><![CDATA[Wordpress widget]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=349</guid>
		<description><![CDATA[Para crear un widget con wordpress solo debemos definirlo en el archivo donde alojemos el plugin de wordpress, no obstante, un widget permite ajustar una serie de opciones, en el siguiente codigo de programación aprenderemos a aprovechar el potencia de widgets de wordpress para que podamos añadir facilmente aplicaciones en los sidebar de tu blog. [...]]]></description>
			<content:encoded><![CDATA[<p>Para <strong>crear un widget con wordpress </strong>solo debemos definirlo en el archivo donde alojemos el plugin de wordpress, no obstante, un widget permite ajustar una serie de opciones, en el siguiente codigo de programación aprenderemos a aprovechar el potencia de <strong>widgets de wordpress </strong>para que podamos añadir facilmente aplicaciones en los <strong>sidebar de tu blog</strong>.<br />
<span id="more-349"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">function</span> miplugin_Widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$user_ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user_identity</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp_wall_plugin_url</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// extract the parameters</span>
      <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// get our options</span>
      <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'miplugin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$titulo</span><span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'miplugin_titulo'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Estas variables son por cuestión de compatibilidad del theme</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$titulo</span><span style="color: #339933;">.</span> <span style="color: #000088;">$after_title</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// El texto y código que inluirá nuestro widget</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;HOLA MUNDO!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Desarrollamos lo que debe hacer el plugin al activarse</span>
<span style="color: #000000; font-weight: bold;">function</span> miplugin_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Nombre plugin'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'miplugin_Widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Nombre plugin'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'miplugin_WidgetControl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//Acción que indica la función de activación del plugin</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'miplugin_init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Con estas lineas de código podemos cambiar las opciones del plugin con tal de que podamos establecer el título del widget que aparecerá en el sidebar.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">function miplugin_WidgetControl()
{
      // Obtenemos los valores preestablecidos
      $options = get_option('miplugin');
      // Cambiamos las opciones en caso de que haya un post
      if ($_POST[&quot;miplugin_submit&quot;]) {
          // retireve wall title from the request
          $options['miplugin_titulo'] = strip_tags(stripslashes($_POST[&quot;miplugin_titulo&quot;]));
          // update the options to database
          update_option('miplugin', $options);
      }
      $titulo = $options['titulo'];
      // Lo que se imprime en las opciones del widget
      ?&gt;
&lt;p&gt;
Titulo: &lt;input  name=&quot;miplugin_titulo&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$titulo</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;input type=&quot;hidden&quot; id=&quot;miplugin_submit&quot; name=&quot;miplugin_submit&quot; value=&quot;1&quot; /&gt;
&lt;/p&gt;
     <span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/crear-y-configurar-un-widget-de-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrar jquery con wordpress</title>
		<link>http://www.johandebruin.com/integrar-jquery-con-wordpress/</link>
		<comments>http://www.johandebruin.com/integrar-jquery-con-wordpress/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 20:01:13 +0000</pubDate>
		<dc:creator>Johan de Bruin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API wordpress]]></category>
		<category><![CDATA[header hook wordpress]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=312</guid>
		<description><![CDATA[WordPress permite gracias a su api usar códigos de jquery, con esta libreria de javascript permitirás establecer una nueva forma de funcionamiento de las páginas web. Para usar jquery tendremos que invocar su código contenido en un archivo .js gracias a una serie de funciones que wordpress nos proporciona. Para poder invocar el directorio del [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress permite gracias a su api usar códigos de jquery, con esta libreria de javascript permitirás establecer una nueva forma de funcionamiento de las páginas web. Para usar jquery tendremos que invocar su código contenido en un archivo .js gracias a una serie de funciones que wordpress nos proporciona.</p>
<p><a href="http://www.johandebruin.com/wp-content/uploads/2010/01/jquerybasico.gif"><img class="size-full wp-image-384 alignnone" title="jquery basico" src="http://www.johandebruin.com/wp-content/uploads/2010/01/jquerybasico.gif" alt="" width="806" height="387" /></a></p>
<p><span id="more-312"></span><br />
Para poder invocar el directorio del plugin, podemos usar el siguiente snnipet de wordpress:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$root_codigo</span> <span style="color: #339933;">=</span> trailingslashit<span style="color: #009900;">&#40;</span> WP_PLUGIN_URL<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ahora que ya tenemos establecida la url de la base donde se mantendrán distintos códigos, (como el .js con el jquery), podemos decir a wordpress que incluya susodicho código entre sus códigos:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> codigo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'un_nombre_script'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$root_codigo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/codigojquery.js'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Linea de código para pasar parametros al jquery</span>
wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'un_nombre_script'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'clase'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'algun_parametro'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'valor'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codigo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Usamos wp_localize_script para pasar los parámetros a la función jquery, en este caso la ruta del plugin, si quisieramos acceder en el jquery a dicho parámetro podemos usar la clase que enviamos asi: <em>clase.algun_parametro</em>.</p>
<p>Por último, un ejemplo de la estructura que podria tener codigojquery.js:</p>

<div class="wp_syntax"><div class="code"><pre class="javascritp" style="font-family:monospace;">$(document).ready(function())
{
     $(&quot;a&quot;).click(function()
     {
          alert(&quot;Gracias por tu visita!&quot;);
     });
});</pre></div></div>

<p>Por último, aquí un video de introducción sobre jquery:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Hk5oXFtYLwE&amp;hl=es_ES&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Hk5oXFtYLwE&amp;hl=es_ES&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/integrar-jquery-con-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Añadir codigos al header en wordpress</title>
		<link>http://www.johandebruin.com/anadir-codigos-al-header-en-wordpress/</link>
		<comments>http://www.johandebruin.com/anadir-codigos-al-header-en-wordpress/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 19:20:57 +0000</pubDate>
		<dc:creator>Johan de Bruin</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[API wordpress]]></category>
		<category><![CDATA[codigo css plugin]]></category>
		<category><![CDATA[header hook wordpress]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=291</guid>
		<description><![CDATA[A menudo querremos integrar dentro de la estructura distintos códigos para poder añadir comportamientos a la página web, (como algo de CSS o Javascript). Si no queremos andar añadiendo código al header.php del theme, podemos añadirselo gracias a un fabuloso hook que integra la API de WordPress. function estilo_css&#40;&#41; &#123; body &#123; background-color:#ffffff !important; } [...]]]></description>
			<content:encoded><![CDATA[<p>A menudo querremos integrar dentro de la estructura <head> distintos códigos para poder añadir comportamientos a la página web, (como algo de CSS o Javascript). Si no queremos andar añadiendo código al header.php del theme, podemos añadirselo gracias a un fabuloso <strong>hook</strong> que integra la <strong>API de WordPress</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> estilo_css<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     body <span style="color: #009900;">&#123;</span> background<span style="color: #339933;">-</span>color<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">#ffffff !important; }
</span><span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'estilo_css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/anadir-codigos-al-header-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

