<?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>aurea &#187; PHP / MySQL</title>
	<atom:link href="http://aurea.es/category/php-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://aurea.es</link>
	<description>Desarrollador front-end, Estándares Web y Accesibilidad</description>
	<lastBuildDate>Mon, 23 Apr 2012 06:52:44 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Eliminando el style por defecto de una gallery con un add_filter en WordPress</title>
		<link>http://aurea.es/2012/03/08/eliminando-el-style-por-defecto-de-una-gallery-con-un-add_filter-en-wordpress/</link>
		<comments>http://aurea.es/2012/03/08/eliminando-el-style-por-defecto-de-una-gallery-con-un-add_filter-en-wordpress/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 09:03:31 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[media.php]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=5506</guid>
		<description><![CDATA[Cuando insertamos una galería de imágenes en WordPress se incrusta por defecto una serie de estilos CSS: &#60;style type='text/css'&#62; #&#123;$selector&#125; &#123; margin: auto; &#125; #&#123;$selector&#125; .gallery-item &#123; float: &#123;$float&#125;; margin-top: 10px; text-align: center; width: &#123;$itemwidth&#125;%; &#125; #&#123;$selector&#125; img &#123; border: 2px solid #cfcfcf; &#125; #&#123;$selector&#125; .gallery-caption &#123; margin-left: 0; &#125; &#60;/style&#62; Este fragmento de código [...]]]></description>
			<content:encoded><![CDATA[<p>Cuando insertamos una galería de imágenes en WordPress se incrusta por defecto una serie de estilos CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'text/css'</span><span style="color: #00AA00;">&gt;</span>
    #<span style="color: #00AA00;">&#123;</span>$selector<span style="color: #00AA00;">&#125;</span> <span style="color: #00AA00;">&#123;</span>
    	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    #<span style="color: #00AA00;">&#123;</span>$selector<span style="color: #00AA00;">&#125;</span> <span style="color: #6666ff;">.gallery-item</span> <span style="color: #00AA00;">&#123;</span>
    	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #00AA00;">&#123;</span>$float<span style="color: #00AA00;">&#125;</span><span style="color: #00AA00;">;</span>
    	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
    	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
    	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #00AA00;">&#123;</span>$itemwidth<span style="color: #00AA00;">&#125;</span>%<span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    #<span style="color: #00AA00;">&#123;</span>$selector<span style="color: #00AA00;">&#125;</span> img <span style="color: #00AA00;">&#123;</span>
    	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#cfcfcf</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    #<span style="color: #00AA00;">&#123;</span>$selector<span style="color: #00AA00;">&#125;</span> <span style="color: #6666ff;">.gallery-caption</span> <span style="color: #00AA00;">&#123;</span>
    	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p>Este fragmento de código se encuentra en:<br />
<em>wp-includes/media.php (<span lang="en" xml:lang="en">Line</span> 833)</em></p>
<p>El problema es que se incrusta estilo en pleno documento, donde se ha insertado la galería. Lo cual no resulta muy limpio si atendemos a la abstracción de las 3 capas: diseño, función y contenido.</p>
<p>Si volvemos a <em>media.php</em> veremos entorno a la línea 831:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'use_default_gallery_style'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span></pre></div></div>

<p>Por tanto una opción elegante podría ser:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'use_default_gallery_style'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Colocando este filtro en el fichero <em>functions.php</em> del theme usado, indicamos a WordPress que no debe usar por el estilo <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> por defecto para las galerías, y relegamos el <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> necesario al fichero <em>style.css</em> donde tengamos centralizado todo el estilo del blog.</p>
<p>Usando filtros se puede cambiar altamente el comportamiento por defecto de WordPress.</p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2012/03/08/eliminando-el-style-por-defecto-de-una-gallery-con-un-add_filter-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post &#8211; Thumbnail en WordPress; Mostrar 5 últimos posts con thumbnails</title>
		<link>http://aurea.es/2010/02/24/post-thumbnail-en-wordpress/</link>
		<comments>http://aurea.es/2010/02/24/post-thumbnail-en-wordpress/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 09:00:43 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=4940</guid>
		<description><![CDATA[La semana pasada implemente una funcionalidad en la que puede aprovechar los nuevos post-thumbnails de la versión 2.9 de WordPress. ¿Qué es un post-thumbnail? Es una imagen en miniatura que puedes asociar a cada post. Esta nueva característica es muy interesante puesto que te ahorras códigos y métodos un tanto rebuscados si lo único que [...]]]></description>
			<content:encoded><![CDATA[<p>La semana pasada implemente una funcionalidad en la que puede aprovechar los nuevos <a href="http://codex.wordpress.org/Post_Thumbnails">post-thumbnails</a> de la versión <a href="http://codex.wordpress.org/Version_2.9">2.9 de WordPress</a>.</p>
<h3>¿Qué es un post-thumbnail?</h3>
<p>Es una imagen en miniatura que puedes asociar a cada post. </p>
<p>Esta nueva característica es muy interesante puesto que te ahorras códigos y métodos un tanto rebuscados si lo único que quieres es asociar a un post una imagen.<br />
Por ejemplo en el apartado <a href="http://aurea.es/proyectos/">portfolio de este sitio web</a> veis que aparecen un thumbnail por cada proyecto. Para lograrlo he subido el thumbnail como una imagen más y a través de &#8220;query y el menu-order&#8221; cojo la primera imagen del post, luego en la <a href="http://aurea.es/proyectos/cinemavip/">ficha del proyecto</a> me salto la primera y coloco el resto.<br />
Otra formula para establecer thumbnails es <a href="http://wordpress.org/extend/plugins/search.php?q=thumbnails&#038;sort=">usar algún plugin disponible</a>. </p>
<p>Y ahora por fin en WordPress ya tenemos incorporada de base esta característica. </p>
<h3>Método de empleo</h3>
<h4>Dando soporte a post-thumbnails en nuestro theme activo</h4>
<p>Lo primero es indicar a WordPress que deseamos usar esta funcionalidad. Para ello usamos la siguiente instrucción que debemos incorporar al fichero <strong>function.php</strong> de nuestro theme.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Incluir el thumbnail en un post</h4>
<p>Se hace a través de la interfaz del panel de control, facilitando así la tarea para los editores del blog.<br />
Cuando escribamos un post o lo editemos en el panel de control de WordPress, veremos al margen derecho un nuevo bloque llamado &#8220;Post Thumbnail&#8221;, en el podemos incluir la imagen en miniatura.</p>
<h4>Mostrar los últimos 5 posts (con thumbnails)</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> related_posts<span style="color: #009900;">&#40;</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;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> get_the_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	
&nbsp;
	<span style="color: #000088;">$last_posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
		select <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID, <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_title, <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.guid, date_format(<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_date, '<span style="color: #009933; font-weight: bold;">%e</span>-%m-%Y') as post_date
		from <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>
		join <span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_relationships</span>
			on <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID = <span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_relationships</span>.object_id  
		where 
			<span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_relationships</span>.term_taxonomy_id = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; and
			<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_type = 'post' and 
			<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_status = 'publish' and 
			<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID != &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
		group by <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID 
		order by <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID desc
		limit 5&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$last_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$last_post_current</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; rel=&quot;bookmark&quot;&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
						<span style="color: #b1b100;">echo</span> get_the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span> 
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;span class=&quot;date&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_date</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>		
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A partir de un query se obtienen los últimos 5 posts publicados de la categoría activa <code>get_the_category();</code>.<br />
Luego en el bucle que recorre cada post, se muestra el titulo, thumbnail y el enlace correspondiente a cada post.</p>
<p>Fijémonos en fragmento de código que nos interesa:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span> get_the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$last_post_current</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>La función <code>has_post_thumbnail();</code> a la que le pasamos como parámetro el post_id nos devuelve true si ese post contiene un thumbnail asociado. En ese caso se ejecuta la función <code>get_the_post_thumbnail();</code> a la que se le pasa como primer parámetro el post_id y como segundo un tamaño para la imagen en miniatura (en forma de array), en este caso 40*40 pixel.</p>
<p>Podéis ver más información detallada sobre post-thumbnails en <a href="http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/">New in WordPress 2.9: Post Thumbnail Images</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2010/02/24/post-thumbnail-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Variables en CSS; Implementaciones</title>
		<link>http://aurea.es/2009/12/09/variables-en-css/</link>
		<comments>http://aurea.es/2009/12/09/variables-en-css/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 17:42:18 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[Estándares]]></category>
		<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=4615</guid>
		<description><![CDATA[Es seguro que en algún momento todos los que trabajamos con CSS echamos en falta las conocidas variables, elementos esenciales en cualquier lenguaje de programación. Para solventarlo se me ocurren varias formas: Evitar las redundancias. Usar mejor la descendencia en los selectores. Definir las variables como meros comentarios. Usar variables de PHP u otro lenguaje [...]]]></description>
			<content:encoded><![CDATA[<p>Es seguro que en algún momento todos los que trabajamos con <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> echamos en falta las conocidas variables, elementos esenciales en cualquier lenguaje de programación. Para solventarlo se me ocurren varias formas: </p>
<ul>
<li>Evitar las redundancias.</li>
<li>Usar mejor la descendencia en los selectores.</li>
<li>Definir las variables como meros comentarios.</li>
<li>Usar variables de <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> u otro lenguaje dinámico de servidor.</li>
<li>Decantarnos por <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> 3.</li>
</ul>
<p>Es probable que existan más formas ¿conoces alguna?, bueno&#8230; de momento voy a intentar explicar las mencionadas.</p>
<h3>Evitar las redundancias</h3>
<h4>Ejemplo redundante</h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#59B0E5</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
h2 <span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#59B0E5</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>Evitamos redundancias</h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
h2 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
h1<span style="color: #00AA00;">,</span> h2 <span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#59B0E5</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>El ejemplo es obvio y carece de explicaciones, sin embargo en hojas de estilo complejas la tarea de sintetizar es más complicada.</p>
<h3>Usar una mejor la descendencia en los selectores</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p em<span style="color: #00AA00;">,</span> p strong<span style="color: #00AA00;">,</span> p dfn <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#59B0E5</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>Definir las variables como meros comentarios</h3>
<p>En la cabecera del fichero <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> podemos incluir bajo la notación de comentarios las &#8220;variables&#8221; que entran en juego en la hoja de estilo.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
   Primary color: #59B0E5
   Second color: #DA5BA4
*/</span>
&nbsp;
p <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#59B0E5</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
...</pre></div></div>

<p>Así y con ayuda de la típica herramienta &#8220;buscar/reemplazar&#8221; podemos cambiar fácilmente los valores en todo el documento. </p>
<h3>Usar variables de <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> u otro lenguaje dinámico de servidor</h3>
<p>Para ello debemos tener en cuenta varias cuestiones. </p>
<h4>Extensión .PHP</h4>
<p>La primera de ellas es que el fichero sea interpretado como tal, en el caso de <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> podremos llamar a la hoja de estilos <strong>style.php</strong>.</p>
<h4>Enlace al fichero</h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href='/css/style.php' /&gt;</pre></div></div>

<h4>Tipo de contenido</h4>
<p>Debemos indicar al servidor web el tipo de contenido de nuestro fichero para que sea correctamente interpretado. Esto lo podemos hacer fácilmente en <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> enviando la cabecera con el tipo MIME.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: text/css;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Declarando las variables</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #000088;">$colorweb1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;#59B0E5&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$colorweb2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;#DA5BA4&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Usando las variables</h4>
<p>En las propias reglas <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> podemos incrustar las llamadas a las variables de PHP.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">h1 { color: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$colorweb1</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>; }
h2 { color: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$colorweb2</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>; }</pre></div></div>

<h3>Decantarnos por <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> 3</h3>
<p>Las anteriores soluciones son como &#8220;de andar por casa&#8221;. <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> 3 nos brinda la posibilidad de usar variables reales de forma &#8220;nativa&#8221;. El problema es la retrocompatibilidad con algunos navegadores actuales y todas las antiguas versiones <img src='http://aurea.es/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h4>Declarando las variables</h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@variables { colorweb1: #59B0E5; colorweb2: #DA5BA4; }</span></pre></div></div>

<h4>Usando las variables</h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> var<span style="color: #00AA00;">&#40;</span>colorweb1<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
h2 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> var<span style="color: #00AA00;">&#40;</span>colorweb2<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2009/12/09/variables-en-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Actualizar CSS evitando cache del usuario</title>
		<link>http://aurea.es/2009/02/28/actualizar-css-evitando-cache-del-usuario/</link>
		<comments>http://aurea.es/2009/02/28/actualizar-css-evitando-cache-del-usuario/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 13:27:13 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=3817</guid>
		<description><![CDATA[En un momento dado podemos detectar varias mejora consecutivas en nuestro CSS. Las editamos y las subimos, luego refrescamos el navegador con la página y ya esta todo correcto. Pero puede pasar que el usuario tenga su navegador configurado de una forma determinada, no realice ese refresco de página, y tenga el CSS almacenado en [...]]]></description>
			<content:encoded><![CDATA[<p>En un momento dado podemos detectar varias mejora consecutivas en nuestro CSS. Las editamos y las subimos, luego refrescamos el navegador con la página y ya esta todo correcto.</p>
<p>Pero puede pasar que el usuario tenga su navegador configurado de una forma determinada, no realice ese refresco de página, y tenga el <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> almacenado en la memoria cache, por tanto seguirá viendo la página exactamente igual.</p>
<p>Una posible solución:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;http://aurea.es/style.css?nocache=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre></div></div>

<p>De esta forma generamos por medio de <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> un número aleatorio (y diferente en cada acceso), con ello obligamos al navegador a que descargue siempre el <acronym title="Cascading Style Sheets" xml:lang="en">CSS</acronym> puesto que no se corresponde con el nombre guardado anteriormente.</p>
<p>Por razones de <a href="http://aurea.es/2007/08/24/optimizando-php/">optimización en PHP</a> he escogido esta función, es más rápida <a class="external" href="http://es.php.net/manual/es/function.mt-rand.php">mt_rand()</a> que <a class="external" href="http://es.php.net/manual/es/function.rand.php">rand()</a>.</p>
<p>Recordar también quitar este <code>nocache=xxxxx</code> cuando haya pasado el tiempo prudencial, para que la cache vuelva hacer su trabajo.</p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2009/02/28/actualizar-css-evitando-cache-del-usuario/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Language Switcher en XHTML Strict</title>
		<link>http://aurea.es/2008/12/31/language-switcher-en-xhtml-strict/</link>
		<comments>http://aurea.es/2008/12/31/language-switcher-en-xhtml-strict/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 13:09:52 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[Estándares]]></category>
		<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Language Switcher]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Strict]]></category>
		<category><![CDATA[validar]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=3326</guid>
		<description><![CDATA[Para los que no lo conocéis, Language Switcher es un plugin para wordpress. Con el podemos hacer que un blog en wordpress soporte múltiples idiomas. El problema Si usamos este plugin e intentamos validar los documentos web en XHTML Strict veremos que existen errores generados por el carácter &#8220;&#038;&#8221; puesto que no se encuentra como [...]]]></description>
			<content:encoded><![CDATA[<p>Para los que no lo conocéis, <a href="http://www.poplarware.com/languageplugin.html">Language Switcher</a> es un plugin para wordpress. Con el podemos hacer que un blog en wordpress soporte múltiples idiomas.</p>
<h3>El problema</h3>
<p>Si usamos este plugin e intentamos validar los documentos web en <acronym title="eXtensible HyperText Markup Language" xml:lang="en">XHTML</acronym> Strict veremos que existen errores generados por el carácter &#8220;&#038;&#8221; puesto que no se encuentra como entidad HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&amp;amp;</pre></div></div>

<p>Todos los errores vienen de la <acronym title="Uniform Resource Locator" xml:lang="en">URL</acronym> que Language Switcher define para pasar de un lenguaje a otro (switcher interfaz).</p>
<h3>La solución</h3>
<p>El problema esta localizado y es sencillo, así que la solución no podías ser menos. Voy a exponerlo a continuación para ahorrar esos minutillos algún desarrollador sin ganas de rebuscar en el código del plugin.</p>
<p>En la <strong>línea 1010</strong> del fichero <strong>langswitch.php</strong> debemos hacer el siguiente cambio:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//return $uriStr;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uriStr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Lo que hice simplemente es comentar la línea original del plugin e incorporar la misma instrucción pero añadiendo la función de <a href="http://php.net">PHP</a> <a href="http://es.php.net/htmlentities">htmlentities()</a> encargada de convertir la string pasada como parámetro <code>$uriStr</code> en una nueva string donde se han remplazado todos los caracteres que tienen una entidad <acronym title="HyperText Markup Language" xml:lang="en">HTML</acronym> equivalente.</p>
<h3>En próximas versiones</h3>
<p><a href="http://www.poplarware.com/personal/">Jennifer Hodgdon</a> (programadora en <a href="http://www.poplarware.com/">Poplar ProductivityWare</a> y responsable de este plugin) me ha informado que esta solución será implementada en futuras versiones. Así no tendremos que preocuparnos de la sobre-escritura del fichero.</p>
<p>Por cierto, Jennifer me ha escrito en inglés y en un <strong>perfecto español</strong> <img src='http://aurea.es/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/12/31/language-switcher-en-xhtml-strict/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fundamentos web 2008</title>
		<link>http://aurea.es/2008/11/02/fundamentos-web-2008/</link>
		<comments>http://aurea.es/2008/11/02/fundamentos-web-2008/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 21:05:33 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[Accesibilidad]]></category>
		<category><![CDATA[Estándares]]></category>
		<category><![CDATA[Eventos]]></category>
		<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ARIA]]></category>
		<category><![CDATA[Asturias]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Fundamentos Web]]></category>
		<category><![CDATA[Gijón]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[WAI]]></category>
		<category><![CDATA[WCAG]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=2303</guid>
		<description><![CDATA[Recientemente he asistido al congreso fundamentos web 2008, en Gijón (Asturias). Se trata de un evento organizado por la Fundación CTIC, la oficina española del consorcio W3C, y subvencionado por el Gobierno del Principado de Asturias. Este evento ha conseguido tras varias ediciones una enorme relevancia internacional, incorporando en sus actos a ponentes de primera [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://farm4.static.flickr.com/3013/2988182961_0c6ff53a36.jpg?v=0" class="noicon"><img class="alignleft" src="http://farm4.static.flickr.com/3013/2988182961_0c6ff53a36.jpg?v=0" alt="Cartel de fundamentos web 2008" width="200" height="300" /></a>Recientemente he asistido al congreso <a href="http://www.fundamentosweb.org/2008/" class="noicon">fundamentos web 2008</a>, en Gijón (Asturias).</p>
<p>Se trata de un evento organizado por la <a href="http://www.fundacionctic.org">Fundación CTIC</a>, la <a href="http://www.w3c.es/">oficina española del consorcio <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym></a>, y subvencionado por el <a href="http://www.asturias.es/">Gobierno del Principado de Asturias</a>.</p>
<p><a href="http://www.fundamentosweb.org/">Este evento</a> ha conseguido tras varias ediciones una enorme relevancia internacional, incorporando en sus actos a ponentes de primera fila.</p>
<p>A continuación voy a destacar lo que me ha parecido más interesante.</p>
<h3>Beyond Web 2.0 &#8211; <a href="http://blog.jjg.net/">Jesse James Garret</a></h3>
<p><a href="http://farm4.static.flickr.com/3232/2986130335_a01a50967e.jpg?v=0" class="noicon"><img class="alignleft" src="http://farm4.static.flickr.com/3232/2986130335_a01a50967e.jpg?v=0" alt="Foto de Jesse Garret" width="200" height="300" /></a></p>
<p><a href="http://blog.jjg.net/">Garret</a> emplea gran parte de su ponencia en hablar acerca de la humanización de la web, de como hacer que esta sea más humana y amable con el usuario.</p>
<p>Nos pone como ejemplo productos que han triunfado, principalmente el <a href="http://www.apple.com/es/itunes/">ipod</a> de <a href="http://www.apple.com">Apple</a>. Nos cuenta la historia de la niña de 12 años que cuando le regalaron su primer ipod le dio un beso antes de irse a la cama.</p>
<p>Nos explica como lo que hay que buscar es que el usuario llegue a pensar: &#8220;no me imagino la vida sin este producto/servicio&#8221;.</p>
<p>En ese tipo de conexiones entre el usuario y el producto/servicio se encuentra en el éxito.</p>
<p>En esta charla he recordado como en alguna asignatura de diseño en la universidad, o en algún libro que he comprado leí acerca de lo importante que es humanizar una marca. Yo siempre digo que:</p>
<blockquote><p>El usuario, visitante o lector cuando se le transmiten emociones, el mensaje llega a calar mucho más profundo.</p></blockquote>
<p>Garret nos pone el ejemplo de <a href="http://www.tivo.com/">TiVo</a> y como en su logo aparece una cara sonriente y tiene piernas, una forma más de humanizar la marca y acercar algo tecnológico a lo humano. Este producto tiene verdaderos fanáticos en EEUU.</p>
<p>También habla acerca del esquema tecnológico &#8220;<strong>Datos &gt; Lógica &gt; Interfaz</strong>&#8220;. Este modelo es válido para los que estamos trabajando en la web, pero para el usuario el modelo se reduce en: <strong>Interfaz</strong>. Mas abajo lo que hay para el usuario es algo desconocido y mágico.</p>
<p>Garret dice: Todo lo que tiene la interfaz es todo lo que el usuario puede hacer. Todo lo que ve es todo lo que hay.</p>
<blockquote><p>Yo mejor diría que todo aquello que entra por los sentidos es todo lo que el usuario puede interpretar que puede hacer.</p></blockquote>
<p>Y más abajo de esto no tiene porque conocer nada, pues estaríamos alejándonos de la humanización del producto.</p>
<h3>Digging Beyond User Preferences &#8211; Eric Fain</h3>
<p><a href="http://farm4.static.flickr.com/3281/2988925480_6a644f6ffc.jpg?v=0" class="noicon"><img class="alignleft" src="http://farm4.static.flickr.com/3281/2988925480_6a644f6ffc.jpg?v=0" alt="Foto de Eric Fain" width="200" height="300" /></a></p>
<p>Fain habla de lo importante y necesario que es la segmentación de audiencias. <strong>Analizar nuestro target</strong>, el público objetivo de nuestro servicio y conocer información acerca de ellos: emociones, temores, preferencias. De tal forma que con toda esta información podamos ofrecer las mejores soluciones posibles.</p>
<p>Plantea 6 reglas para investigar las preferencias que tiene el target destinatario:</p>
<ol>
<li>Entender al usuario.</li>
<li>Preguntas abiertas, que no paralicen la motivación de la entrevista.</li>
<li>No al uso de tecnicismos.</li>
<li>Indagar, intentar seguir la conversación&#8230;</li>
<li>No se trata tanto de las herramientas en si, sino de como las usan.</li>
<li>Comprender cual es la experiencia del usuario tras el uso de la herramienta.</li>
</ol>
<p>A continuación habla acerca de los modelos mentales.</p>
<p>También habla de la importancia de extraer la información que subyace detrás de las palabras del usuario.</p>
<p>Finalmente nos muestra gráficos de modelos mentales en los que ha trabajado. Uno de ellos ha sido trabajado por una compañera durante 6 meses&#8230; (que &#8220;locura&#8221;!).</p>
<p>Esta ponencia no me ha gustado tanto como la anterior <img src='http://aurea.es/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h3 id="wai-aria"><acronym title="Web Accessibility Initiative" xml:lang="en">WAI</acronym>-<acronym title="Accessible Rich Internet Applications" xml:lang="en">ARIA</acronym> Just Do It</h3>
<h4>Steve Faulkner</h4>
<p><a href="http://farm4.static.flickr.com/3138/2988077997_86826cfc4a.jpg?v=0" class="noicon"><img src="http://farm4.static.flickr.com/3138/2988077997_86826cfc4a.jpg?v=0" alt="Foto de Steve Faulkner" width="350" height="233" /></a></p>
<p>He preferido este &#8220;track2&#8243; al 1 (que trataba sobre <acronym title="Content Management System" xml:lang="en">CMS</acronym>).</p>
<p>Steve Faulkner comienza explicándonos lo que significa <a href="http://www.w3c.es/Traducciones/es/WAI/intro/accessibility"><acronym title="Web Accessibility Initiative" xml:lang="en">WAI</acronym></a> (Iniciativa de accesibilidad web) comandada por el consorcio <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym>. A continuación nos cuenta lo que significa <a href="http://www.w3.org/WAI/intro/aria"><acronym title="Accessible Rich Internet Applications" xml:lang="en">ARIA</acronym></a>, actualmente en fase de desarrollo pero que le falta poco para convertirse en una recomendación impulsado nuevamente por el consorcio <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym>.</p>
<blockquote><p>Steve remarca la importancia de todos estos movimientos para impulsar una web realmente accesible.</p></blockquote>
<p>Expone como un botón puede ser entendido como tal a través de un simple atributo:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">role = button</pre></div></div>

<p>A continuación nos explica como muchas de las cuestiones desarrolladas con ajax no son realmente accesibles y pueden solucionarse <em>con la sencilla inclusión de un atributo</em> <acronym title="Accessible Rich Internet Applications" xml:lang="en">ARIA</acronym>.</p>
<p>Nos cuenta que actualmente soportan <acronym title="Accessible Rich Internet Applications" xml:lang="en">ARIA</acronym>: Firefox, <acronym title="Internet Explorer" xml:lang="en">IE</acronym>, Opera, Yahoo, Google, Adobe, IBM, SUN, etc.</p>
<h3>Becky Gibson</h3>
<p><a href="http://farm3.static.flickr.com/2272/2988082835_5bd52303c7.jpg?v=0" class="noicon"><img class="alignnone" src="http://farm3.static.flickr.com/2272/2988082835_5bd52303c7.jpg?v=0" alt="Foto De Becky Gibson" width="350" height="233" /></a></p>
<p>Becky comienza dando un repaso a <a href="http://www.w3.org/WAI/intro/aria"><acronym title="Web Accessibility Initiative" xml:lang="en">WAI</acronym>-<acronym title="Accessible Rich Internet Applications" xml:lang="en">ARIA</acronym></a>.</p>
<p>A continuación centra su ponencia totalmente en <a href="http://dojotoolkit.org/">DOJO</a>.</p>
<p>Explica a través de un WebMail propio e improvisado algunos de los elementos de interfaz que ofrece <a href="http://dojotoolkit.org/">DOJO</a> y que resultan totalmente accesibles.</p>
<p>Becky tiene problemas con su ponencia (temas del directo) le están fallando los ejemplos <img src='http://aurea.es/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Bueno, me ha parecido más instructiva la ponencia de Steve Faulkner.</p>
<h3>Tu vida laboral (mesa redonda)</h3>
<p><a href="http://farm4.static.flickr.com/3228/2989044528_a7196fa2ce.jpg?v=0" class="noicon"><img src="http://farm4.static.flickr.com/3228/2989044528_a7196fa2ce.jpg?v=0" alt="Foto de la mesa redonda" width="350" height="233" /></a></p>
<p>Moderador: Jesús Gorriti. Participantes: José Florido, <a href="http://interacciones.org/">Ariel Guersenzvaig</a>, Humberto Matas, Manuel Muñoz y <a href="http://www.torresburriel.com/weblog/">Daniel Torres Burriel</a>.</p>
<p>Muchas ganas tenia de ver a <em>Torres Burriel</em>, le he seguido desde &#8220;creo sus comienzos&#8221; con el blog. Posteriormente (casualidades de la vida) me ha tocado de consultor en el <a href="http://aurea.es/javi/multimedia/">graduado multimedia</a> de la <a href="http://www.uoc.edu">UOC</a>. Pero a pesar de leer tanto su blog, de mandarle mis prácticas de la <acronym title="Universitat Oberta de Catalunya" xml:lang="en">UOC</acronym>, etc. Nunca le había visto/oído. Así que fue todo un placer <img src='http://aurea.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>El contenido de esta sesión lo cuenta muy detalladamente Ricardo Gil:<br />
<a href="http://elclerigo.blogia.com/2008/102706-fw-08-tu-vida-laboral-mesa-redonda-.php">FW&#8217;08: Tu vida laboral (mesa redonda)</a>.</p>
<p>Me ha parecido interesante como hablaron de &#8220;lo normal&#8221; que es fracasar en uno (o muchos) proyectos y que de ello siempre se puede aprender.</p>
<p>En general me ha gustado la mesa redonda, no obstante en algunos momentos he notado un tono <strong>demasiado pesimista</strong>.</p>
<h3>Otros momentos</h3>
<p>Algunas risas con <a href="http://noelmartin.es/">Noel Martin</a>, con el que estuve durante todo el congreso.</p>
<p>El tema de la comida me ha parecido bastante ameno, el pinchoteo estuvo muy bien <img src='http://aurea.es/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Fue un placer intercambiar algunas palabras con <a href="http://www.human-computer.net/blog/">Yusef Hassan</a> al que había conocido personalmente dos días atrás en un curso que ofrecio en Oviedo acerca de la <a href="http://www.apeiasturias.org/index.php?oper=opcion&amp;contenido=53&amp;PHPSESSID=1ec85cae2e9d12e0c20445381fc3f30c">arquitectura de la información para la web</a>.</p>
<p>Una curiosidad fue hablar con <a href="http://interacciones.org/">Ariel Guersenzvaig</a> sin saber que justo tras esa charla iba a ser uno de los ponentes de la mesa redonda jejeje. Como se nota que había mirado por alto la documentación ofrecida en el evento.</p>
<h3>Conclusión</h3>
<p>Me ha gustado en general, porque me apasiona todo esto <img src='http://aurea.es/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  pero claramente el evento <strong>ha ido a peor de una forma NOTABLE</strong>.</p>
<ol>
<li>Mismo precio que el año anterior (creo recordar).</li>
<li>Muchísimas menos ponencias.</li>
<li>Un día menos dedicado a las charlas.</li>
</ol>
<p>Comprendo que es difícil mantener un evento de esta magnitud en Asturias. Pero la gente en pasadas ediciones se ha visto como ha respondido muy favorablemente.</p>
<p>En esta edición sin embargo creo que los asistentes se han reducido muchísimo. Eso fue mi impresión y me parece un castigo totalmente lógico.</p>
<p>Sin duda me quedo con el grato recuerdo de <a href="http://aurea.es/2007/10/07/fundamentos-web-2007/">Fundamentos web 2007</a>.</p>
<h3>Otros resúmenes del congreso</h3>
<ul>
<li><a title="Permanent Link: Fundamentos web 2008: Eric Fain" rel="bookmark" href="http://www.torresburriel.com/weblog/2008/10/27/fundamentos-web-2008-eric-fain/">Fundamentos web 2008: Eric Fain</a></li>
<li><a href="http://elclerigo.blogia.com/2008/102901-fw-08-punto-y-final.php">FW&#8217;08: Punto y final</a></li>
<li>Fotos de <strong><a title="Link to espinr's photostream" href="http://flickr.com/photos/martinalvarez/"><strong>espinr</strong></a></strong> &gt; <a id="contextLink_set72157608504714664" class="currentContextLink" href="http://flickr.com/photos/martinalvarez/sets/72157608504714664/">Fundamentos Web 2008 (Set)</a></li>
</ul>
<p><img src="http://farm4.static.flickr.com/3150/2986959548_3cc293d120.jpg?v=0" alt="Foto del auditorio" width="500" height="333" /></p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/11/02/fundamentos-web-2008/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Migrar de php4 a php5</title>
		<link>http://aurea.es/2008/09/15/migrar-de-php4-a-php5/</link>
		<comments>http://aurea.es/2008/09/15/migrar-de-php4-a-php5/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 14:21:49 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP4]]></category>
		<category><![CDATA[PHP5]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=1978</guid>
		<description><![CDATA[Días atrás me encontré ante la tediosa tarea de migrar una aplicación (bastante grande) programada en php4 a un servidor bajo php5. Voy a exponer en este post algunas de las diferencias encontradas y que pueden ahorrar algún dolor de cabeza Algunas incompatibilidades 1.- En vez de copy() es preferible usar la función move_uploaded_file(), o [...]]]></description>
			<content:encoded><![CDATA[<p>Días atrás me encontré ante la tediosa tarea de migrar una aplicación (bastante grande) programada en php4 a un servidor bajo php5. Voy a exponer en este post algunas de las diferencias encontradas y que pueden ahorrar algún dolor de cabeza <img src='http://aurea.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Algunas incompatibilidades</h3>
<p>1.- En vez de <a href="http://es2.php.net/manual/es/function.copy.php">copy()</a> es preferible usar la función <a href="http://es2.php.net/manual/es/function.move-uploaded-file.php">move_uploaded_file()</a>, o mejor aún las funciones <acronym title="File Transfer Protocol" xml:lang="en">FTP</acronym> como <a href="http://es2.php.net/manual/es/function.ftp-put.php">ftp_put()</a> lo cual garantiza una transferencia más rápida y segura.</p>
<p>2.- Las variables del tipo $HTTP_* deben ser sustituidas por $_POST, $_GET, etc. A estas alturas es obvio pero hace años no lo era tanto. Por ejemplo: <strong>$HTTP_POST_FILES</strong> en php5 debe ser <strong>$_FILES</strong>.</p>
<p>3.- Debemos prestar mucha atención a los permisos otorgados a los directorios y al <a href="http://es2.php.net/manual/es/features.safe-mode.php">safe_mode</a>.</p>
<p>4.- Las matrices deben siempre accederse por su índice <strong>$matriz['id']</strong> nunca <strong>$matriz_id</strong>.</p>
<p>5.- En php4 era posible construir matrices en los campos html:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input name=&quot;foto[]&quot; type=&quot;image&quot; /&gt;</pre></div></div>

<p>Evitando esto potenciamos los estándares:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input name=&quot;foto_x&quot; type=&quot;image&quot; /&gt;</pre></div></div>

<p>6.- Las variables enviadas por formularios deben ser accedidas a través de <a href="http://es2.php.net/manual/es/reserved.variables.get.php">$_GET</a>, <a href="http://es2.php.net/manual/es/reserved.variables.post.php">$_POST</a>, así como debemos usar las <a href="http://es2.php.net/manual/es/language.variables.superglobals.php">variables superglobales</a> en todo momento, además de tener en cuenta el <a href="http://es2.php.net/register_globals">register_globals</a>. Si tenemos toda nuestra aplicación programada como en php4 o php3 y haciendo uso de las variables directamente (no las superglobales), podemos optar por el uso de la función <a href="http://es2.php.net/function.extract">extract()</a>. Ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #339933;">,</span>EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A partir de ese momento ya podemos usar $mi_var_post como se venía haciendo.</p>
<p>7.- En php5 debemos definir la zona horaria con <a href="http://es2.php.net/manual/es/function.date-default-timezone-set.php">date_default_timezone_set()</a>.</p>
<p>Estos son solo algunas cuestiones resumidas, y este es un post abierto, así que si tienes alguna incompatibilidad o puntualización al respecto, sera un placer que lo expongas aquí.</p>
<h3>Más información</h3>
<ol>
<li><a href="http://es2.php.net/manual/es/migration5.php">Migración desde <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> 4 a <acronym title="Pre-Hypertext Processing" xml:lang="en">PHP</acronym> 5</a> (manual oficial)<a href="http://es2.php.net/manual/es/migration5.php"><br />
</a></li>
<li><a href="http://www.maestrosdelweb.com/editorial/como-migrar-tus-aplicaciones-de-php4-a-php5/">Cómo migrar tus aplicaciones de PHP4 a PHP5</a></li>
<li><a href="http://www.maestrosdelweb.com/editorial/php4y5/">PHP4 y PHP5: ¿Cuál elegir? ¿Migrar o no Migrar? El advenimiento de PHP6</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/09/15/migrar-de-php4-a-php5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Cambiar blog wordpress de dominio</title>
		<link>http://aurea.es/2008/09/14/cambiar-blog-wordpress-de-dominio/</link>
		<comments>http://aurea.es/2008/09/14/cambiar-blog-wordpress-de-dominio/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 07:12:53 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Bases de datos]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=2219</guid>
		<description><![CDATA[En esta entrada voy a tratar de explicar como hacer una migración de nuestro blog (wordpress) a un nuevo dominio y de una forma eficiente. 1.- Copia de seguridad Lo primero es hacer una copia de seguridad completa, que contenga los ficheros y la base de datos de nuestro blog. Copiar todos los ficheros contenidos [...]]]></description>
			<content:encoded><![CDATA[<p>En esta entrada voy a tratar de explicar como hacer una migración de nuestro blog (<a href="http://wordpress.org">wordpress</a>) a un nuevo dominio y de una forma eficiente.</p>
<h3>1.- Copia de seguridad</h3>
<p>Lo primero es hacer una copia de seguridad <strong>completa</strong>, que contenga los ficheros y la base de datos de nuestro blog.</p>
<ul>
<li>Copiar todos los ficheros contenidos en el sitio web. Esto lo podemos hacer con nuestro gestor de  <acronym title="File Transfer Protocol" xml:lang="en">FTP</acronym> favorito y descargando el directorio raíz de la web.</li>
<li>Copiar la estructura y contenido de la base de datos. Una buena forma puede ser exportarla a un fichero <acronym title="Structured Query Language" xml:lang="en">SQL</acronym> con un gestor local (lo prefiero) o de web (como <a href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a>).</li>
</ul>
<h3>2.- Restaurar datos en el nuevo dominio</h3>
<p>A continuación acudimos a nuestro nuevo dominio y subimos los ficheros previamente copiados y restauramos la base de datos importando el fichero  <acronym title="Structured Query Language" xml:lang="en">SQL</acronym>.</p>
<h3>3.- Actualizar la base de datos</h3>
<p>En este momento tenemos todos los datos de nuestro blog en el nuevo dominio, pero nos queda lo más importante, actualizar la información almacenada en la base de datos para que wordpress tenga en cuenta correctamente el cambio.</p>
<p>La instrucción <acronym title="Structured Query Language" xml:lang="en">SQL</acronym> que debemos usar es:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #993333; font-weight: bold;">FIELD</span> <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">FIELD</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'string1'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'string2'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>La explicación es sencilla, actualizamos la tabla remplazando string1 por string2 en el campo especificado.</p>
<p>Esta instrucción debemos ejecutarla en varios lugares adaptándonos a cada caso:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_options <span style="color: #993333; font-weight: bold;">SET</span> option_value <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>option_value<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aureawebdesign.com'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aurea.es'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_posts <span style="color: #993333; font-weight: bold;">SET</span> post_content <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_content<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aureawebdesign.com'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aurea.es'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_posts <span style="color: #993333; font-weight: bold;">SET</span> guid <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>guid<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aureawebdesign.com'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aurea.es'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>(*) Nota: El campo &#8220;meta_value&#8221; de la tabla wp_postmeta no es necesario ser actualizado, de hecho si se actualiza se pueden dar irregularidades en los thumb de las imágenes.</p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/09/14/cambiar-blog-wordpress-de-dominio/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Vídeo válido xhtml en blog wordpress</title>
		<link>http://aurea.es/2008/05/12/video-valido-xhtml-en-blog-wordpress/</link>
		<comments>http://aurea.es/2008/05/12/video-valido-xhtml-en-blog-wordpress/#comments</comments>
		<pubDate>Mon, 12 May 2008 21:22:09 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[Estándares]]></category>
		<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[satay]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=403</guid>
		<description><![CDATA[Vídeos en el blog Es muy fácil incrustar (embed) vídeos en nuestro blog de diversas fuentes: YouTube Google Video Metacafe etc. ¿Porqué el estándar es un problema? Embed, flash y object se pelean entre ellos y no alcanzo a comprender por qué a estas alturas de la historia todavía muchos sitios web (y los más [...]]]></description>
			<content:encoded><![CDATA[<h3>Vídeos en el blog</h3>
<p>Es muy fácil incrustar (embed) vídeos en nuestro blog de diversas fuentes:</p>
<ul>
<li>YouTube</li>
<li>Google Video</li>
<li>Metacafe</li>
<li>etc.</li>
</ul>
<h3>¿Porqué el estándar es un problema?</h3>
<p><a href="http://aurea.es/2009/03/27/embed-flash-object-y-los-estandares-web/">Embed, flash y object</a> se pelean entre ellos y no alcanzo a comprender por qué a estas alturas de la historia todavía muchos sitios web (y los más populares) nos dan unos códigos para incrustar el vídeo que no siguen los estándares, usando etiquetas prehistóricas como <strong>&lt;embed&gt;</strong> el invento de <a href="http://netscape.com">netscape</a> y no aceptada por la <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym>.</p>
<p>Entiendo que estos servicios tienen miles de usuarios y que buscan una compatibilidad absoluta, pero ¿no creen que ya es momento de mirar hacia adelante? incluso existen desde hace mucho técnicas que mantienen la compatibilidad y en cierto modo mejoran el estandarizado del marcado.</p>
<ul>
<li xml:lang="en"><a href="http://www.alistapart.com/articles/flashsatay ">Flash Satay</a> (2002)</li>
<li><a href="http://www.torresburriel.com/weblog/2004/04/13/codigo-validado-para-insertar-flash/">Código valido &#8220;xhtml object video&#8221;</a> (2004)</li>
<li xml:lang="en"><a href="http://www.webstandards.org/2006/08/15/valid-flash-video-and-audio-embed-object-markup/">Valid flash video and audio embed object</a></li>
</ul>
<p>Entonces, ¿cuál es la razón para que estos sitios web con mega-inversiones y fuertes sumas en facturación, sigan atados al pasado?.  Siento que algo se me está escapando, pero sigo sin saber que hay detrás de esto:  razones corporativas, técnicas, financieras, ¿el qué?.</p>
<p>Estos servicios tan grandes deberían predicar con el ejemplo porque con ellos se está inundando la red de códigos no estandarizados.</p>
<p>El lema de la <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym> es guiar a la red al futuro…, pero exagerando un poco todo esto ¿no creen que la red está siendo guiada ya desde hace tiempo por unos 49 sitios web (+ 1 google)?</p>
<p>De acuerdo que algunas tecnologías propietarias son tomadas como estándares de facto y más fáciles de implementar que las especificaciones estándares, y cierto es que no todas las recomendaciones del <acronym title="World Wide Web Consortium" xml:lang="en">W3C</acronym> son &#8220;perfectas&#8221;. Pero creo que hay que tener en cuenta que detrás de una especificación hay muchos: estudios, intereses, empresas, usuarios, colaboraciones, grupos, etc.</p>
<h3>Conclusión</h3>
<p>Creo que realmente merece la pena seguir las especificaciones, puesto que nos brinda la posibilidad de mirar al futuro <strong>de una forma inteligente</strong>.</p>
<h3>Soluciones en la actualidad</h3>
<p>Mientras que estos populares servicios sigan así, nosotros tenemos el “deber” de intentar solucionarlo, bien con las técnicas ya anteriormente comentadas o si tenemos un blog mediante algún plugin.</p>
<p>En el caso de wordpress contamos con la ayuda de algunos plugins:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/pb-embedflash/">pb-embedFlash</a></li>
<li><a href="http://www.viper007bond.com/wordpress-plugins/vipers-video-quicktags/">Viper&#8217;s Video Quicktags</a></li>
<li><a href="http://wordpress.org/extend/plugins/video-embedder/">Video Embedder</a></li>
<li><a href="http://wordpress.org/extend/plugins/xhtml-video-embed/"><acronym title="eXtensible HyperText Markup Language" xml:lang="en">XHTML</acronym> Video Embed</a></li>
<li><a href="http://wordpress.org/extend/plugins/embedded-video-with-link/">Embedded Video with Link</a></li>
</ul>
<p>Personalmente, me quedo con pb-embedFlash.</p>
<h3>Otros enlaces</h3>
<p>Javier Aroche nos cuenta cuando <a href="http://www.maestrosdelweb.com/editorial/cuando-la-usabilidad-y-los-estandares-se-contradicen/">la usabilidad y los estándares web se contradicen (en google reader)</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/05/12/video-valido-xhtml-en-blog-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Crear un plugin para wordpress</title>
		<link>http://aurea.es/2008/04/17/crear-un-plugin-para-wordpress/</link>
		<comments>http://aurea.es/2008/04/17/crear-un-plugin-para-wordpress/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 07:55:26 +0000</pubDate>
		<dc:creator>javiaurea</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Añadir etiqueta nueva]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://aurea.es/?p=400</guid>
		<description><![CDATA[Recientemente he programado un plugin para wordpress que permite una integración limpia y eficiente con paypal, también posibilita una amplia personalización desde el panel de opciones del propio wordpress. Concluido el plugin voy a compartir lo aprendido pero en su versión resumida. Intentare explicar como crear un plugin, hacer uso de shortcode e integrar una [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-998 alignleft" title="wordpress logo cristal" src="http://aurea.es/wp-content/uploads/wordpress-logo-cristal.jpg" alt="" width="128" height="128" />Recientemente he programado un plugin para wordpress que permite una integración limpia y eficiente con <a href="http://paypal.es/">paypal</a>, también posibilita una amplia personalización desde el panel de opciones del propio wordpress.</p>
<p>Concluido el plugin voy a compartir lo aprendido <img src='http://aurea.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  pero en su versión resumida. Intentare explicar como <a href="http://codex.wordpress.org/Writing_a_Plugin">crear un plugin</a>, hacer uso de <a href="http://codex.wordpress.org/Shortcode_API">shortcode</a> e <a href="http://codex.wordpress.org/Adding_Administration_Menus">integrar una página de opciones</a> en el panel de administración de wordpress, aunque todo ello de forma sencilla y bastante esquematizada, a partir de ahí nuestra imaginación hará el resto.</p>
<p>Antes de comenzar, demos una vuelta por la wikipedia para conocer ¿<a href="http://es.wikipedia.org/wiki/Add-on">que es un plugin</a>? y recordar como son <a href="http://codex.wordpress.org/Managing_Plugins">gestionados en wordpress</a>.</p>
<h3>1.- Crear el fichero contenedor del plugin (para wordpress)</h3>
<p>Por ejemplo: &#8220;miplugin.php&#8221;, su contenido debe ajustarse al formato siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Plugin Name: nombre de nuestro plugin
Plugin URI: web del plugin (descarga, soporte, etc.)
Description: descirpción detallada del plugin
Author: nombre y apellidos del autor
Version: 1.0
Author URI: web del autor
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
Licencia
*/</span></pre></div></div>

<h3>2.- Vamos a programar!</h3>
<p>Las siguientes lineas ya deben contener el código de nuestro plugin.</p>
<p>Empiezo por escribir el esqueleto principal del programa, la clase con algunas variables y funciones.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> miplugin <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$opt</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$table_name</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// inicializamos plugin</span>
	<span style="color: #000000; font-weight: bold;">function</span> miplugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// instalar cosas del plugin</span>
	<span style="color: #000000; font-weight: bold;">function</span> install<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// desinstalar</span>
	<span style="color: #000000; font-weight: bold;">function</span> uninstall<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// página de configuración</span>
	<span style="color: #000000; font-weight: bold;">function</span> config_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//opciones de configuración</span>
	<span style="color: #000000; font-weight: bold;">function</span> options_plugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//ejecuta resultado</span>
	<span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$mp</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> miplugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Como se observa, el plugin se encuentra bajo <acronym title="Programación orientada a objetos"><a title="wikipedia en programación orientada a objetos" href="http://es.wikipedia.org/wiki/Programaci%C3%B3n_orientada_a_objetos">POO</a></acronym> pero por razones de compatibilidad no usa las características de <a href="http://es2.php.net/manual/es/faq.migration5.php">PHP5</a>, es por ello que se hace uso de &#8220;var&#8221; para declarar las variables y &#8220;__construct&#8221; ha sido remplazado por el nombre del plugin en la función de inicialización.</p>
<p>La línea 19 es la encargada de crear un objeto &#8220;mp&#8221; de la clase &#8220;miplugin&#8221;. A partir de aquí empieza la faena <img src='http://aurea.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>3.- Inicializamos el plugin</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> miplugin<span style="color: #009900;">&#40;</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;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table_name <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>prefix<span style="color: #339933;">.</span><span style="color: #0000ff;">'miplugin'</span><span style="color: #339933;">;</span>
&nbsp;
	register_activation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'install'</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;">//gancho para instalar</span>
	register_deactivation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'uninstall'</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;">//gancho para desinstalar</span>
&nbsp;
	add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'config_page'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mundo'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'init'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Esta función es ejecutada automáticamente cuando se crea un objeto de la clase, puesto que tiene el mismo nombre.</p>
<p>En la línea 2 tomamos el objeto <a href="http://codex.wordpress.org/Function_Reference/wpdb_Class">$wpdb</a>;  que es el encargado de llevar la gestión de bases de datos para wordpress. Siempre que queramos interactuar con la base de datos de wordpress será necesaria esta llamada.</p>
<p>En la línea siguiente almacenamos en &#8220;$this-&gt;table_name&#8221; el nombre de la tabla para nuestro plugin.</p>
<p>Con  <a href="http://codex.wordpress.org/Function_Reference/register_activation_hook">register_activation_hook</a> y  <a href="http://codex.wordpress.org/Function_Reference/register_deactivation_hook">register_deactivation_hook</a> podemos indicar que funciones deben ejecutarse &#8220;installa/uninstall&#8221; cuando el plugin sea activado/desactivado desde el panel de administración de wordpress.</p>
<p>La línea 6 se encarga de implementar la función &#8220;config_page&#8221; que debe llamarse para que podamos tener un <a href="http://codex.wordpress.org/Adding_Administration_Menus">menú de opciones del plugin integrado en wordpress</a> (solapa opciones). Para ello debe hacerse uso de la función de wordpress <a href="http://codex.wordpress.org/Function_Reference/add_action">add_action</a>.</p>
<p>La línea 7 hace que podamos usar las shortcodes (códigos rápidos) como llamadas al plugin. Esto hace que por ejemplo cuando se escribe &#8220;<strong>[mundo]</strong>&#8221; en el contenido de un post, el plugin llame a la función &#8220;init&#8221; puesto que ha sido implementado con <a href="http://codex.wordpress.org/Shortcode_API">add_shortcode</a>.</p>
<h3>4.- Instalar/desinstalar</h3>
<p>Hacemos un alto en el proceso anterior para comentar las funciones install/uninstall.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> install<span style="color: #009900;">&#40;</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;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'CREATE TABLE `'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table_name<span style="color: #339933;">.</span><span style="color: #0000ff;">'` (
		`frase` varchar(100) NOT NULL default &quot;&quot;
	) ENGINE=MyISAM DEFAULT CHARSET=utf8'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSERT INTO `'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table_name<span style="color: #339933;">.</span><span style="color: #0000ff;">'` SET frase = &quot;hola mundo!!!&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Aquí va la creación de la tabla para el plugin en la base de datos de wordpress. A continuación inserté un registro donde uno de los campos contiene el valor &#8220;hola mundo!!!&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> uninstall<span style="color: #009900;">&#40;</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;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'drop table `'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table_name<span style="color: #339933;">.</span><span style="color: #0000ff;">'`'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Cuando desinstalamos el plugin se ejecuta la función &#8220;uninstall&#8221; y con ella procesamos el borrado de la tabla del plugin.</p>
<h3>5.- Página de configuración del plugin</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> config_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_options_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mi plugin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mi plugin'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'miplugin_options'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'options_plugin'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> options_plugin<span style="color: #009900;">&#40;</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;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'update'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//aquí podemos poner el sql update, basado en los datos de un formulario</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//aquí va el formulario para las opciones de configuración</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>La ya mencionada función &#8221; add_action(&#8216;admin_menu&#8217;, array(&amp;$this, &#8216;config_page&#8217;));&#8221; ejecutada en la inicialización del plugin, es la encargada de indicar que debe procesarse la función &#8220;config_page&#8221; que a su vez pide las opciones que debe contener el plugin a &#8220;options_plugin&#8221;.</p>
<h3>6.- Resultado del shortcode</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</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;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// options (config)</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>opt <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_row<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM '</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>table_name<span style="color: #339933;">.</span><span style="color: #0000ff;">' LIMIT 1'</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// atributes (user)</span>
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'frase'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>opt<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'frase'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fichero.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Volviendo al proceso del programa, cuando se escribe en un post el shortcode &#8220;<strong>[mundo]</strong>&#8221; se ejecuta la función &#8220;init&#8221; y se le pasa como parametro el shortcode con sus atributos &#8220;<strong>$atts</strong>&#8220;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>mundo<span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;">//esto es un shortcode</span>
<span style="color: #009900;">&#91;</span>mundo frase<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hola mundo 2!!!&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;">//esto es un shortcode con un atributo</span></pre></div></div>

<p>Esta función &#8220;<strong>init($atts)</strong>&#8221; se encarga de hacer una consulta sql &#8220;select&#8221; a la tabla del plugin y obtener la frase &#8220;hola mundo!!!&#8221; que tenemos almacenada.</p>
<p>A continuación la función &#8220;<a href="http://codex.wordpress.org/Shortcode_API">extract</a>(shortcode_atts(array(&#8216;frase&#8217; =&gt; $this-&gt;opt['frase']), $atts));&#8221;, es crucial puesto que se encarga de &#8220;repartir&#8221; los pares de valores tomados de los atributos.</p>
<p>Es por esto que podamos contener en la variable $frase = &#8220;hola mundo!!!&#8221; (en caso de que se llamará al shortcode sin atributo) o &#8220;hola mundo 2!!!&#8221; si se ha llamado con el atributo.</p>
<p>Por último y para separar un poco el html del php, pongo un &#8220;include&#8221; que llama a un fichero.php (debe estar en el mismo directorio que el plugin) .</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//fichero.php</span></pre></div></div>

<p>El fichero muestra la frase.</p>
<h3>Consejos</h3>
<ul>
<li>Creo que es importante emplear cierto tiempo en buscar nombres originales para nuestras funciones y variables (sobre todo si se programe de forma estructurada y no orientada a objetos), puesto que debemos tener en cuenta la compatibilidad con otros plugins y el propio código de wordpress.</li>
<li>Se puede aprender un montón de cosas viendo el código ordenado de algunos plugins <img src='http://aurea.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<h3>Recursos</h3>
<ul>
<li><a href="http://codex.wordpress.org/Main_Page">Docs de wordpress</a></li>
<li><a href="http://www.cristalab.com/tips/54308/como-crear-un-plugin-para-wordpress">Como crear un plugin para wordpress</a></li>
<li><a href="http://www.anieto2k.com/2006/02/15/vamos-a-crear-un-plugin/">Vamos a crear un plugin</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://aurea.es/2008/04/17/crear-un-plugin-para-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

