<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2spanishfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Sentido Web</title><link>http://sentidoweb.com</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sentidoweb" /><description>Publicación dirigida a los desarrolladores web e internautas apasionados por la programación, diseño, negocios y todo lo que ocurre en Internet.</description><language>en-US</language><lastBuildDate>Thu, 11 Oct 2012 06:48:58 PDT</lastBuildDate><generator>http://wordpress.org/?v=3.4.2</generator><sy:updatePeriod xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">hourly</sy:updatePeriod><sy:updateFrequency xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">1</sy:updateFrequency><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sentidoweb" /><feedburner:info uri="sentidoweb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/2.0/</creativeCommons:license><feedburner:emailServiceId>sentidoweb</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>Añadir contenido a los datepicker de jQuery UI</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/dQWBqB4Fflo/anadir-contenido-a-los-datepicker-de-jquery-ui.php</link><category>Javascript</category><category>datepicker</category><category>jquery</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Thu, 11 Oct 2012 06:48:58 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2774</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>En algunas ocasiones es necesario añadir contenido al calendario que te ofrecer el datepicker de jQuery UI, por ejemplo añadir un combo que indice &#8220;horario mañanas/tarde&#8221;. Para conseguirlo será necesario &#8216;toquetear&#8217; un poco el objeto <em>jQuery.datepicker</em>.</p>
<p>Tendremos que hacer dos cosas: primero deberemos evitar que cuando se selecciona un día se cierre automáticamente el popup con el calendario y después tendremos que modificar el HTML que devuelve la clase.</p>
<p>Para evitar el auto-cierre tenemos que añadir la opción <em>showButtonPanel</em> ya que nos ofrecerá el botón &#8220;Close&#8221; que nos permitirá cerrar el popup cuando hayamos indicado todos los campos necesarios. También es necesario modificar la función <em>jQuery.datepicker._selectDate</em> tal y como lo indican en <a href="http://stackoverflow.com/a/1762378/1714096">StackOverflow</a>:</p>
<pre><code><pre class="javascript"><span style="color: #009900; font-style: italic;">// A&Atilde;&plusmn;adimos datepicker al input que queremos</span>
jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.fecha'</span><span style="color: #66cc66;">&#41;</span>
  .<span style="color: #006600;">datepicker</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
    showButtonPanel: <span style="color: #003366; font-weight: bold;">true</span>,
    dateFormat: <span style="color: #3366CC;">"DD, d MM, yy"</span> 
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">// Modificamos la funcion _selectDate</span>
jQuery.<span style="color: #006600;">datepicker</span>._selectDateOverload = jQuery.<span style="color: #006600;">datepicker</span>._selectDate;
jQuery.<span style="color: #006600;">datepicker</span>._selectDate = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>id, dateStr<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> target = jQuery<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #003366; font-weight: bold;">var</span> inst = <span style="color: #000066; font-weight: bold;">this</span>._getInst<span style="color: #66cc66;">&#40;</span>target<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
    inst.<span style="color: #006600;">inline</span> = <span style="color: #003366; font-weight: bold;">true</span>;
    jQuery.<span style="color: #006600;">datepicker</span>._selectDateOverload<span style="color: #66cc66;">&#40;</span>id, dateStr<span style="color: #66cc66;">&#41;</span>;
    inst.<span style="color: #006600;">inline</span> = <span style="color: #003366; font-weight: bold;">false</span>;
    <span style="color: #000066; font-weight: bold;">this</span>._updateDatepicker<span style="color: #66cc66;">&#40;</span>inst<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #009900; font-style: italic;">// Usar el .html() para luego usar el .text() es porque si usas el regional de datepicker, te salen entidades html en vez de letras acentuadas</span>
    <span style="color: #009900; font-style: italic;">// Se le a&Atilde;&plusmn;ade el valor del nuevo campo select que hemos incluido</span>
    target.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span>jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;div /&gt;'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span>dateStr<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #3366CC;">' @ '</span>+jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#horario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Bien, ya tenemos el evento onSelect modificado, ahora nos falta cambiar el HTML que se dibuja, para ello modificaremos la función <em>jQuery.datepicker._generateHTML</em>:</p>
<pre><code><pre class="javascript">jQuery.<span style="color: #006600;">datepicker</span>._generateHTMLExtended = jQuery.<span style="color: #006600;">datepicker</span>._generateHTML;
jQuery.<span style="color: #006600;">datepicker</span>._generateHTML = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>inst<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> html = jQuery.<span style="color: #006600;">datepicker</span>._generateHTMLExtended<span style="color: #66cc66;">&#40;</span>inst<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #003366; font-weight: bold;">var</span> div = jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;div /&gt;'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span>html<span style="color: #66cc66;">&#41;</span>;
  div.<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'table:first'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">after</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;Horario:&lt;/p&gt;&lt;select id=&quot;horario&quot;&gt;&lt;option value=&quot;ma&Atilde;&plusmn;anas&quot;&gt;ma&Atilde;&plusmn;anas&lt;/option&gt;&lt;option value=&quot;tardes&quot;&gt;tardes&lt;/option&gt;&lt;/select&gt;'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000066; font-weight: bold;">return</span> div.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Incluimos tambien un evento para que cuando se seleccione el horario, se modifique el campo input</span>
jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#horario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">live</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'change'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> $obj = jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.fecha'</span><span style="color: #66cc66;">&#41;</span>;
  $obj.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span>$obj.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/@.*/</span>, <span style="color: #3366CC;">'@ '</span>+jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=dQWBqB4Fflo:CJ66X15a-pg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=dQWBqB4Fflo:CJ66X15a-pg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=dQWBqB4Fflo:CJ66X15a-pg:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>En algunas ocasiones es necesario añadir contenido al calendario que te ofrecer el datepicker de jQuery UI, por ejemplo añadir un combo que indice &amp;#8220;horario mañanas/tarde&amp;#8221;. Para conseguirlo será necesario &amp;#8216;toquetear&amp;#8217; un poco el objeto jQuery.datepicker. Tendremos que hacer dos cosas: primero deberemos evitar que cuando se selecciona un día se cierre automáticamente el popup [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2012/10/11/anadir-contenido-a-los-datepicker-de-jquery-ui.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">3</slash:comments><feedburner:origLink>http://sentidoweb.com/2012/10/11/anadir-contenido-a-los-datepicker-de-jquery-ui.php</feedburner:origLink></item><item><title>Listar posts de dos categorías en WordPress</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/3fiXit4NKIA/listar-posts-de-dos-categorias-en-wordpress.php</link><category>PHP</category><category>categorias</category><category>doble</category><category>WordPress</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Fri, 20 Jul 2012 09:05:26 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2772</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>¿Qué pasa si queremos mostrar los posts que pertenezcan a dos categorías a la vez? por ejemplo, mostrar los posts que sean de &#8220;PHP&#8221; y de &#8220;Noticias&#8221; o &#8220;PHP&#8221; y &#8220;Ejemplos&#8221;.</p>
<p>La forma de hacerlo es fácil, primero debemos crearnos la estructura del permalink y que WordPress lo reconozco, en este caso será <em>/categories/slug-category-A/slug-category-B</em>. Para ello tenemos que dar de alta esta estructura el el <em>$wp_rewrite</em> y añadir la variable <em>cats</em> en los parámetros tratados por WordPress.</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// Crea la estructura para el rewrite</span>
<span style="color: #000000; font-weight: bold;">function</span> categories_rewrite_rules<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$wp_rewrite</span>;
  <span style="color: #3E6D8F;">$rewrite_tag</span> = <span style="color: #ff0000;">'%categories%'</span>;
  <span style="color: #808080; font-style: italic;">// En la variable cats se almacenar&Atilde;&iexcl; 'slug-category-A/slug-category-B' que luego trataremos</span>
  <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">add_rewrite_tag</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$rewrite_tag</span>, <span style="color: #ff0000;">'categories/([^/]+/[^/]+)'</span>, <span style="color: #ff0000;">'cats='</span> <span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$rewrite_keywords_structure</span> = <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">root</span> . <span style="color: #ff0000;">"$rewrite_tag/"</span>;
  <span style="color: #3E6D8F;">$new_rule</span> = <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">generate_rewrite_rules</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$rewrite_keywords_structure</span> <span style="color: #66cc66;">&#41;</span>;
  <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">rules</span> = <span style="color: #3E6D8F;">$new_rule</span> + <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">rules</span>;
  <span style="color: #723b00;">return</span> <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">rules</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Permitimos que la variable cats se tenga en cuenta en las queries (URL) de WordPress</span>
<span style="color: #000000; font-weight: bold;">function</span> categories_variables<span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$public_query_vars</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #3E6D8F;">$public_query_vars</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'cats'</span>;
  <span style="color: #723b00;">return</span> <span style="color: #3E6D8F;">$public_query_vars</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Hacemos un flush para que tenga en cuenta la nueva regla en el rewrite</span>
<span style="color: #000000; font-weight: bold;">function</span> me_flush_rewrite_rules<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$wp_rewrite</span>;
  <span style="color: #3E6D8F;">$wp_rewrite</span>-&gt;<span style="color: #006600;">flush_rules</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
add_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'init'</span>, <span style="color: #ff0000;">'me_flush_rewrite_rules'</span> <span style="color: #66cc66;">&#41;</span>;
add_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'generate_rewrite_rules'</span>, <span style="color: #ff0000;">'categories_rewrite_rules'</span> <span style="color: #66cc66;">&#41;</span>;
add_filter<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'query_vars'</span>, <span style="color: #ff0000;">'categories_variables'</span> <span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p>Vale, ya tenemos creada la estructura, ahora solo falta modificar la query para que tenga en cuenta la nueva condición: que el post tenga la categoría A y la categoría B, para lo cual modificaremos el join de la query añadiendo un <em>left join</em> para cada categoría</p>
<pre><code><pre class="php">add_filter<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'posts_join'</span> , <span style="color: #ff0000;">'categories_join'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> categories_join<span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$join</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$wpdb</span>, <span style="color: #3E6D8F;">$wp_query</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span>get_query_var<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'cats'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// Recuperamos los slugs de las categorias</span>
    <span style="color: #3E6D8F;">$cats</span> =  <a href="http://www.php.net/explode"><span style="color: #000066;">explode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/'</span>, <span style="color: #3E6D8F;">$wp_query</span>-&gt;<span style="color: #006600;">query_vars</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cats'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$ids</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// Por cada slug recuperamos la categor&Atilde;&shy;a y a&Atilde;&plusmn;adimos left join</span>
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$cats</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$i</span>=&gt;<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #3E6D8F;">$obj</span> = get_category_by_slug<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$obj</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #3E6D8F;">$ids</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3E6D8F;">$obj</span>-&gt;<span style="color: #006600;">term_id</span>;
        <span style="color: #3E6D8F;">$join</span> .= <span style="color: #ff0000;">" JOIN {$wpdb-&gt;term_relationships} r{$i} on r{$i}.object_id = {$wpdb-&gt;posts}.ID and r{$i}.term_taxonomy_id = {$obj-&gt;term_id} "</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #723b00;">return</span> <span style="color: #3E6D8F;">$join</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Y ya está, si accedieramos a nuestro blog http://miblog.com/categories/php/noticias veríamos los posts que están dentro de PHP y Noticias, con su paginación y demás.</p>
<p>Si por un casual queremos utilizar una template en particular para esto, tan solo deberemos añadir lo siguiente a nuestro <em>functions.php</em>:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> categories_template<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span>get_query_var<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'cats'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #723b00;">include</span> <span style="color: #66cc66;">&#40;</span>TEMPLATEPATH . <span style="color: #ff0000;">'/category-videos.php'</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'template_redirect'</span>, <span style="color: #ff0000;">'categories_template'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p>O si queremos obtener el título de las categorías, podremos crearnos una función que nos lo devuelva:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> get_cats_names<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span>get_query_var<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'cats'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #3E6D8F;">$cats</span> =  <a href="http://www.php.net/explode"><span style="color: #000066;">explode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/'</span>, get_query_var<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'cats'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$names</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$cats</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$i</span>=&gt;<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #3E6D8F;">$obj</span> = get_category_by_slug<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$obj</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #3E6D8F;">$names</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3E6D8F;">$obj</span>-&gt;<span style="color: #006600;">name</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #723b00;">return</span> <a href="http://www.php.net/implode"><span style="color: #000066;">implode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">' | '</span>, <span style="color: #3E6D8F;">$names</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #723b00;">return</span> <span style="color: #ff0000;">''</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=3fiXit4NKIA:dhhOeHpwyOg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=3fiXit4NKIA:dhhOeHpwyOg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=3fiXit4NKIA:dhhOeHpwyOg:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>¿Qué pasa si queremos mostrar los posts que pertenezcan a dos categorías a la vez? por ejemplo, mostrar los posts que sean de &amp;#8220;PHP&amp;#8221; y de &amp;#8220;Noticias&amp;#8221; o &amp;#8220;PHP&amp;#8221; y &amp;#8220;Ejemplos&amp;#8221;. La forma de hacerlo es fácil, primero debemos crearnos la estructura del permalink y que WordPress lo reconozco, en este caso será /categories/slug-category-A/slug-category-B. Para [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2012/07/20/listar-posts-de-dos-categorias-en-wordpress.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">5</slash:comments><feedburner:origLink>http://sentidoweb.com/2012/07/20/listar-posts-de-dos-categorias-en-wordpress.php</feedburner:origLink></item><item><title>Evitar problemas de sesión con IE y las aplicaciones Facebook en iframe</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/x8JhAT7sFWc/evitar-problemas-de-sesion-con-ie-y-las-aplicaciones-facebook-en-iframe.php</link><category>PHP</category><category>cookies</category><category>facebook</category><category>header</category><category>IE</category><category>iframe</category><category>internet explorer</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Fri, 08 Jun 2012 01:49:28 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2767</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Si desarrollais aplicaciones para Facebook y os encontráis con que Internet Explorer pierde la sesión, esto es debido a que Internet Explorer se hace un lío con las cookies y los iframes (que usa Facebook para incluir tu aplicación).</p>
<p>La solución es muy sencilla: meter un javascript comprobando si usa IE y en ese caso, mostrar un banner diciendo que si no cambias de navegador y usas Firefox o Chrome te enviaremos un par de matones a tu casa que lo harán por ti. Desgraciadamente, el kilo de matón sale muy caro, y hay mucho usuario que ni sabe que es Firefox o Chrome, así que nos tocará añadir esto a nuestro código:</p>
<pre><code><pre class="php"><a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'P3P: CP=&quot;CAO PSA OUR&quot;'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre>
<p>Así de simple.</p>
<p>Odio el Internet Explorer</p>
<p>Vía / <a href="http://stackoverflow.com/questions/4111990/facebook-ie8-session-is-not-being-persisted">Stack Overflow</a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=x8JhAT7sFWc:Vjm7W2YALxI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=x8JhAT7sFWc:Vjm7W2YALxI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=x8JhAT7sFWc:Vjm7W2YALxI:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Si desarrollais aplicaciones para Facebook y os encontráis con que Internet Explorer pierde la sesión, esto es debido a que Internet Explorer se hace un lío con las cookies y los iframes (que usa Facebook para incluir tu aplicación). La solución es muy sencilla: meter un javascript comprobando si usa IE y en ese caso, [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2012/06/08/evitar-problemas-de-sesion-con-ie-y-las-aplicaciones-facebook-en-iframe.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">3</slash:comments><feedburner:origLink>http://sentidoweb.com/2012/06/08/evitar-problemas-de-sesion-con-ie-y-las-aplicaciones-facebook-en-iframe.php</feedburner:origLink></item><item><title>Añadir tus propias opciones en Theme Customizer de WordPress 3.4</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/MEJdFBv4yl8/anadir-tus-propias-opciones-en-theme-customizer-de-wordpress-3-4.php</link><category>PHP</category><category>theme customizer</category><category>themes</category><category>WordPress</category><category>wordpress 3.4</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Mon, 09 Apr 2012 18:02:09 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2763</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>WordPress 3.4 ha añadido la opción de <a href="http://www.wpmods.com/wordpress-3-4-preview/">theme customizer</a>, la cual permite modificar las opciones del theme y darle el aspecto que deseas de forma muy visual y sencilla. En estos momentos, por lo que he podido ver, solo permite modificar el background y poco más. Pero viendo y pegándome con el código he podido ver cómo añadir mis propias opciones.</p>
<p>El ejemplo que voy a poner permite elegir entre tres tipos de fuente de Google Webfonts y modificar las css para usar ese tipo de letra.</p>
<a href="http://sentidoweb.com/wp-content/uploads/2012/04/theme-customizer.png"><img src="http://sentidoweb.com/wp-content/uploads/2012/04/theme-customizer.png" alt="" title="theme-customizer" width="550" height="388" class="alignnone size-full wp-image-2764" /></a>
<p><strong>Aviso que el código quizás no sea el mejor</strong>, pero realizar ingeniería inversa no siempre es fácil y tampoco he visto otro sitio donde lo hagan.</p>
<p>Lo primero que se tiene que hacer es crear las opciones en el panel de customizer. Para ello hay que crear una sección (<em>section</em> &#8220;Fuente&#8221;) y asignarle unas opciones (<em>settings</em>) y añadirle unos controles (control) a las opciones. Existen controles por defecto, el de elegir el color está muy bien, pero en mi caso me he creado uno personalizado que muestra un control <em>radio</em> modificado para que el label del radio muestre la tipo de letra en cuestión.</p>
<pre><code><pre class="php">add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'customize_register'</span>, <span style="color: #ff0000;">'mi_theme_customizer'</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> mi_theme_customizer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$customize</span>;
&nbsp;
  <span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$customize</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// La seccion</span>
    <span style="color: #3E6D8F;">$customize</span>-&gt;<span style="color: #006600;">add_section</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'mi_font'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
      <span style="color: #ff0000;">'title'</span>=&gt;<span style="color: #ff0000;">'Fuente'</span>
    <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// La opcion</span>
    <span style="color: #3E6D8F;">$customize</span>-&gt;<span style="color: #006600;">add_setting</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'mi_font_family'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
      <span style="color: #ff0000;">'control'</span> =&gt; <span style="color: #ff0000;">'color'</span>, <span style="color: #808080; font-style: italic;">// esto ni idea de para que sirve, realmente no es un control tipo color y funciona</span>
      <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'option'</span>
    <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #3E6D8F;">$customize</span>-&gt;<span style="color: #006600;">add_control</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'mi_font_family'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
      <span style="color: #ff0000;">'settings'</span> =&gt; <span style="color: #ff0000;">'mi_font_family'</span>,
      <span style="color: #ff0000;">'section'</span>  =&gt; <span style="color: #ff0000;">'mi_font'</span>,
      <span style="color: #ff0000;">'type'</span>     =&gt; <span style="color: #ff0000;">'font_radio'</span>,
      <span style="color: #ff0000;">'choices'</span>  =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Trocchi'</span>, <span style="color: #ff0000;">'Great Vibes'</span>, <span style="color: #ff0000;">'Bad Script'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// las fuentes de google</span>
     <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
        
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Una vez creado los controles, añado el código que dibuja (render) mi control personalizado, primero añado los css para que dibuje las fuentes de Google y luego dibujo el control en sí. He usado Javascript en vez de PHP porque parece ser que el código no está del todo completo, y no hay un filtro para crear tu propio control, por lo que tengo que añadirlo mediante jQuery a un elemento para que el Javascript del customizer tenga en cuenta cuando selecciono una opción y refresque el preview del theme.</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// A&Atilde;&plusmn;ado los css de google webfonts mediante javascript para tener luego el nombre de las fuentes y usarlo para crear los radio buttons</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'customize_controls_print_scripts'</span>, <span style="color: #ff0000;">'mi_customize_scripts'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> mi_customize_scripts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #3E6D8F;">$fonts</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Trocchi'</span>, <span style="color: #ff0000;">'Great Vibes'</span>, <span style="color: #ff0000;">'Bad Script'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;script type=<span style="color: #ff0000;">"text/javascript"</span>&gt;
  <span style="color: #000000; font-weight: bold;">var</span> mi_fonts = <span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> json_encode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fonts</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>;
  WebFontConfig = <span style="color: #66cc66;">&#123;</span>
    google: <span style="color: #66cc66;">&#123;</span> families: <span style="color: #66cc66;">&#91;</span> 
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fonts</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$i</span>=&gt;<span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$i</span>&gt;<span style="color: #cc66cc;">0</span>?<span style="color: #ff0000;">', '</span>:<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">"'"</span>.urlencode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'::latin'</span>.<span style="color: #ff0000;">"'"</span>; <span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>        
      <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>;
  <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> wf = document.createElement<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'script'</span><span style="color: #66cc66;">&#41;</span>;
    wf.src = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'https:'</span> == document.location.protocol ? <span style="color: #ff0000;">'https'</span> : <span style="color: #ff0000;">'http'</span><span style="color: #66cc66;">&#41;</span> +
      <span style="color: #ff0000;">'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'</span>;
    wf.type = <span style="color: #ff0000;">'text/javascript'</span>;
    wf.async = <span style="color: #ff0000;">'true'</span>;
    <span style="color: #000000; font-weight: bold;">var</span> s = document.getElementsByTagName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'script'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
    s.parentNode.insertBefore<span style="color: #66cc66;">&#40;</span>wf, s<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">// Este c&Atilde;&sup3;digo es copy/paste del c&Atilde;&sup3;digo de WP, pero convertido a JS, </span>
<span style="color: #808080; font-style: italic;">// ya que el elemento al que a&Atilde;&plusmn;ado el c&Atilde;&sup3;digo es el que se usa para a&Atilde;&plusmn;adir</span>
<span style="color: #808080; font-style: italic;">// los eventos que refrescan el preview del theme</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'customize_render_control'</span>, <span style="color: #ff0000;">'mi_render_fonts_control'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> mi_render_fonts_control<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$control</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// Solo lo modifico si es mi control personalizado</span>
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">type</span> == <span style="color: #ff0000;">'font_radio'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">choices</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
      <span style="color: #723b00;">return</span>;
&nbsp;
    <span style="color: #3E6D8F;">$name</span> = <span style="color: #ff0000;">'_customize-font-radio-'</span> . <span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">id</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;span <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"customize-control-title"</span>&gt;&lt;?php <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> esc_html<span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">label</span> <span style="color: #66cc66;">&#41;</span>; ?&gt;&lt;/span&gt;
    &lt;div&gt;
    &lt;script type=<span style="color: #ff0000;">"text/javascript"</span>&gt;
      <span style="color: #000000; font-weight: bold;">var</span> mi_font_checked = <span style="color: #66cc66;">&#91;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #3E6D8F;">$cont</span> = <span style="color: #cc66cc;">0</span>; 
  <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">choices</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$value</span> =&gt; <span style="color: #3E6D8F;">$label</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$cont</span>&gt;<span style="color: #cc66cc;">0</span>?<span style="color: #ff0000;">', '</span>:<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"'"</span>.checked<span style="color: #66cc66;">&#40;</span> <span style="color: #3E6D8F;">$control</span>-&gt;<span style="color: #006600;">value</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #3E6D8F;">$value</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">"'"</span>;
    <span style="color: #3E6D8F;">$cont</span>++;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>      
        <span style="color: #66cc66;">&#93;</span>
      <span style="color: #000000; font-weight: bold;">var</span> html = <span style="color: #ff0000;">''</span>;
      <span style="color: #723b00;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i=<span style="color: #cc66cc;">0</span>; i&lt;mi_fonts.length; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        html += <span style="color: #ff0000;">'&lt;label style=&quot;font-family: '</span>+mi_fonts<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>+<span style="color: #ff0000;">';&quot;&gt;'</span>;
        html += <span style="color: #ff0000;">'&lt;input type=&quot;radio&quot; value=&quot;'</span>+mi_fonts<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>+<span style="color: #ff0000;">'&quot; name=&quot;&lt;?php echo esc_attr( $name ); ?&gt;&quot; &lt;?php $control-&gt;link(); ?&gt; '</span>+mi_font_checked<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>+<span style="color: #ff0000;">' /&gt;'</span>;
        html += mi_fonts<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>+<span style="color: #ff0000;">'&lt;br/&gt;'</span>;
        html += <span style="color: #ff0000;">'&lt;/label&gt;'</span>;
        <span style="color: #808080; font-style: italic;">// Lo dicho, tengo que a&Atilde;&plusmn;adir el codigo mediante jQuery porque no hay un filtro que me permita modificarlo</span>
        jQuery<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.ready<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>jQuery<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#customize-control-&lt;?php echo $control-&gt;id; ?&gt;'</span><span style="color: #66cc66;">&#41;</span>.html<span style="color: #66cc66;">&#40;</span>html<span style="color: #66cc66;">&#41;</span>;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
    &lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Y ya por último solo falta usar la opción guardada para mostrarla en el theme</p>
<pre><code><pre class="php">add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'wp_head'</span>, <span style="color: #ff0000;">'mi_custom_styles'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> mi_custom_styles<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #3E6D8F;">$option</span> = get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'mi_font_family'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #808080; font-style: italic;">// El customizer modifica este filtro para refrescar el preview</span>
  <span style="color: #3E6D8F;">$option</span> = apply_filters<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'option_mi_font_family'</span>, <span style="color: #3E6D8F;">$option</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$option</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"&lt;link href='http://fonts.googleapis.com/css?family="</span>.urlencode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$option</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">"' rel='stylesheet' type='text/css'&gt;"</span>;
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;style type=&quot;text/css&quot;&gt;html * {font-family: <span style="color: #000099; font-weight: bold;">\'</span>'</span>.<span style="color: #3E6D8F;">$option</span>.<span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\'</span>;} &lt;/style&gt;'</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Y esto es todo, no sé si hay una forma mejor de hacerlo, estoy abierto a sugerencias.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=MEJdFBv4yl8:l_PucoGIO8U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=MEJdFBv4yl8:l_PucoGIO8U:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=MEJdFBv4yl8:l_PucoGIO8U:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>WordPress 3.4 ha añadido la opción de theme customizer, la cual permite modificar las opciones del theme y darle el aspecto que deseas de forma muy visual y sencilla. En estos momentos, por lo que he podido ver, solo permite modificar el background y poco más. Pero viendo y pegándome con el código he podido [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2012/04/10/anadir-tus-propias-opciones-en-theme-customizer-de-wordpress-3-4.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://sentidoweb.com/2012/04/10/anadir-tus-propias-opciones-en-theme-customizer-de-wordpress-3-4.php</feedburner:origLink></item><item><title>Progreso de subida de ficheros únicamente con HTML5</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/eDqsa4UW138/progreso-de-subida-de-ficheros-unicamente-con-html5.php</link><category>Javascript</category><category>html5</category><category>progress</category><category>subir ficheros</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Sat, 19 Nov 2011 13:03:58 PST</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2757</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Uno de los mayores problemas con los que nos hemos encontrado a la hora de hacer aplicaciones que suben ficheros, es mostrar al usuario cuánto se ha subido y así poder saber cuánto queda. Ahora con HTML5 y XMLHttpRequest Level 2 podemos mostrarlo sin necesidad de parte del servidor.</p>
<p>El script hace uso de <a href="http://www.w3.org/TR/progress-events/">Evento de Progreso</a> de HTML5 para poder mostrar:</p>
<ul><li><strong>total</strong>: total de bytes</li>
<li><strong>loaded</strong>: bytes subidos</li>
<li><strong>lengthComputable</strong>: indica si el tamaño del fichero es conocido</li>
<li><strong>transferSpeed</strong>: velocidad de transferencia</li>
<li><strong>timeRemaining</strong>: tiempo que falta (en formato Date)</li>
</ul>
<p>Por ahora solo es compatible con Firefox, Chrome y Safari.</p>
<p>En el post lo explican con gran detalle.</p>
<p><a href="http://www.matlus.com/html5-file-upload-with-progress/">Html5 File Upload with Progress</a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eDqsa4UW138:irE5sNJUMJY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eDqsa4UW138:irE5sNJUMJY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eDqsa4UW138:irE5sNJUMJY:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Uno de los mayores problemas con los que nos hemos encontrado a la hora de hacer aplicaciones que suben ficheros, es mostrar al usuario cuánto se ha subido y así poder saber cuánto queda. Ahora con HTML5 y XMLHttpRequest Level 2 podemos mostrarlo sin necesidad de parte del servidor. El script hace uso de Evento [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/11/19/progreso-de-subida-de-ficheros-unicamente-con-html5.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/11/19/progreso-de-subida-de-ficheros-unicamente-con-html5.php</feedburner:origLink></item><item><title>Enlaces de navegación en edición de posts en WordPress</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/ZQOOJMr80U0/enlaces-de-navegacion-en-edicion-de-posts-en-wordpress.php</link><category>PHP</category><category>edicion</category><category>functions</category><category>navegacion</category><category>post</category><category>WordPress</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Tue, 25 Oct 2011 09:32:10 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2755</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Algo que me desespera es tener que editar varios posts seguidos en WP (sobre todo antes del lanzamiento) y tener que ir del post actual, a la lista de post y elegir el siguiente post que necesito editar. Por ello he hecho este pequeño script que incluido en el functions.php incluye dos enlaces en la cabecera que apuntan a la edición del post anterior y al siguiente:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> add_navigation_edit_posts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#wp-admin/post<span style="color: #000099; font-weight: bold;">\.</span>php#'</span>, <span style="color: #3E6D8F;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"SCRIPT_NAME"</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'post'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp;  <a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'action'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'action'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'edit'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$post</span>;
    <span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$post</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #3E6D8F;">$post</span>-&gt;<span style="color: #006600;">post_type</span> == <span style="color: #ff0000;">'post'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$prev</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #3E6D8F;">$p</span> = get_adjacent_post<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #ff0000;">''</span>, <span style="color: #3E6D8F;">$prev</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$p</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;script type=&quot;text/javascript&quot;&gt;'</span>;
          <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'jQuery(document).ready(function() {jQuery(&quot;.wrap h2&quot;).append(<span style="color: #000099; font-weight: bold;">\'</span>&lt;a class=&quot;add-new-h2&quot; href=&quot;'</span>.admin_url<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'post.php?action=edit&amp;post='</span>.<span style="color: #3E6D8F;">$p</span>-&gt;<span style="color: #006600;">ID</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'&quot; title=&quot;'</span>.__<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Edit'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">' '</span>.<span style="color: #3E6D8F;">$p</span>-&gt;<span style="color: #006600;">post_title</span>.<span style="color: #ff0000;">'&quot;&gt;'</span>.<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$prev</span>?<span style="color: #ff0000;">'&amp;laquo; '</span>:<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #3E6D8F;">$p</span>-&gt;<span style="color: #006600;">post_title</span>.<span style="color: #66cc66;">&#40;</span>!<span style="color: #3E6D8F;">$prev</span>?<span style="color: #ff0000;">' &amp;raquo;'</span>:<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'&lt;/a&gt;<span style="color: #000099; font-weight: bold;">\'</span>);});'</span>;
          <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;/script&gt;'</span>;
        <span style="color: #66cc66;">&#125;</span>  
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_head'</span>, <span style="color: #ff0000;">'add_navigation_edit_posts'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=ZQOOJMr80U0:XPQ32LABqrs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=ZQOOJMr80U0:XPQ32LABqrs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=ZQOOJMr80U0:XPQ32LABqrs:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Algo que me desespera es tener que editar varios posts seguidos en WP (sobre todo antes del lanzamiento) y tener que ir del post actual, a la lista de post y elegir el siguiente post que necesito editar. Por ello he hecho este pequeño script que incluido en el functions.php incluye dos enlaces en la [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/10/25/enlaces-de-navegacion-en-edicion-de-posts-en-wordpress.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">5</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/10/25/enlaces-de-navegacion-en-edicion-de-posts-en-wordpress.php</feedburner:origLink></item><item><title>Actualiza tu theme de WordPress desde SVN</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/hFIBcN9UWHg/actualiza-tu-theme-de-wordpress-desde-svn.php</link><category>PHP</category><category>plugin</category><category>svn</category><category>WordPress</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Mon, 17 Oct 2011 14:58:14 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2752</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Si trabajas realizando proyectos en WordPress en el que el código se aloja en un servidor usando SVN, una forma sencilla de actualizar tu theme con los últimos cambios es mediante este sencillo y no-seguro plugin.</p>
<p>El plugin añade una opción de menú al Settings del Dashboard de WP, el cual te servirá para indicar el servidor SVN, usuario, contraseña y el path que corresponde a la carpeta <em>themes</em> de WP. El plugin se conectará al repositorio SVN y recuperará las carpetas que se encuentran en el path anterior y comprobará si las carpetas corresponden a themes instalados, mostrarás una lista con los themes encontrados junto a un botón que permite actualizar todo el theme.</p>
<p>Digo que no es seguro porque no controlo los permisos de los usuarios ni otras cuestiones, pero si estás interesado en ello supongo que no te costará mucho meterle mano al código:</p>
<pre><code><pre class="php"><span style="color: #808080; font-style: italic;">// Adding Admin menu</span>
<span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span> is_admin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_menu'</span>, <span style="color: #ff0000;">'svn_update_menu'</span><span style="color: #66cc66;">&#41;</span>;
  add_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'admin_init'</span>, <span style="color: #ff0000;">'svn_update_register_settings'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_register_settings<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_username'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_password'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_repository'</span> <span style="color: #66cc66;">&#41;</span>;
  register_setting<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'svn_up_option-group'</span>, <span style="color: #ff0000;">'svn_theme_path'</span> <span style="color: #66cc66;">&#41;</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'page'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'svn-update/svn-update.php'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #723b00;">require</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'phpsvnclient/phpsvnclient.php'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$phpsvnclient</span> = <span style="color: #000000; font-weight: bold;">new</span> phpsvnclient<span style="color: #66cc66;">&#40;</span>get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_repository'</span><span style="color: #66cc66;">&#41;</span>, get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_username'</span><span style="color: #66cc66;">&#41;</span>, get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$files</span> = <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getDirectoryFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #3E6D8F;">$svn_themes</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #3E6D8F;">$themes</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span>get_themes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$k</span>=&gt;<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#41;</span> <span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'Template'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$k</span>, <span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"Template Dir"</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'directory'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #3E6D8F;">$svn_themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#91;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>;
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    update_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_themes'</span>, <span style="color: #3E6D8F;">$svn_themes</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'svn_update'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #3E6D8F;">$path</span> = <span style="color: #3E6D8F;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'svn_update'</span><span style="color: #66cc66;">&#93;</span>;
      <span style="color: #3E6D8F;">$theme_path</span> = WP_CONTENT_DIR . <span style="color: #ff0000;">'/themes/'</span>;
      <span style="color: #3E6D8F;">$files</span> = <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getDirectoryFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$path</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$files</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">'file'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          file_put_contents<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$theme_path</span>.<span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #3E6D8F;">$phpsvnclient</span>-&gt;<span style="color: #006600;">getFile</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$f</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'path'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
      add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_notices'</span>, <span style="color: #ff0000;">'showSVNUpdated'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> showSVNUpdated<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;&lt;p&gt;&lt;strong&gt;Theme updated&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;'</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_menu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  add_options_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SVN Update Options'</span>, <span style="color: #ff0000;">'SVN Update'</span>, <span style="color: #cc66cc;">8</span>, <span style="color: #000000; font-weight: bold;">__FILE__</span>, <span style="color: #ff0000;">'svn_update_options'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> svn_update_options<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"wrap"</span>&gt;
&lt;h2&gt;SVN Update Options&lt;/h2&gt;
&lt;form method=<span style="color: #ff0000;">"post"</span> action=<span style="color: #ff0000;">"options.php"</span>&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> settings_fields<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_up_option-group'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;table <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"form-table"</span>&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Username&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_username"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_username'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span>/&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_username"</span>&gt;Write your SVN username&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Password&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_password"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_password'); ?&gt;"</span> type=<span style="color: #ff0000;">"password"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_password"</span>&gt;Write your SVN password&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Repository&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_repository"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_repository'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_reposotoy"</span>&gt;for example: &lt;em&gt;http:<span style="color: #808080; font-style: italic;">//domain.com/svn_path/project&lt;/em&gt;&lt;/label&gt;</span>
     &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
     &lt;th scope=<span style="color: #ff0000;">"row"</span> valign=<span style="color: #ff0000;">"top"</span>&gt;Theme path&lt;/th&gt;
     &lt;td&gt;
         &lt;input id=<span style="color: #ff0000;">"svn_username"</span> name=<span style="color: #ff0000;">"svn_theme_path"</span> value=<span style="color: #ff0000;">"&lt;?php echo get_option('svn_theme_path'); ?&gt;"</span> type=<span style="color: #ff0000;">"text"</span> /&gt;
           &lt;label <span style="color: #723b00;">for</span>=<span style="color: #ff0000;">"svn_theme_path"</span>&gt;for example: &lt;em&gt;/trunk/my_project/themes&lt;/em&gt;&lt;/label&gt;
     &lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
&lt;p <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"submit"</span>&gt;
&lt;input type=<span style="color: #ff0000;">"submit"</span> <span style="color: #000000; font-weight: bold;">class</span>=<span style="color: #ff0000;">"button-primary"</span> value=<span style="color: #ff0000;">"&lt;?php _e('Save Changes') ?&gt;"</span> /&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;h3&gt;Available Themes&lt;/h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #3E6D8F;">$themes</span> = get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'svn_themes'</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;p&gt;No themes found in SVN repository instaled in WordPress&lt;/p&gt;'</span>;
  <span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;ul&gt;'</span>;
    <span style="color: #723b00;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$themes</span> <span style="color: #723b00;">as</span> <span style="color: #3E6D8F;">$k</span>=&gt;<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;li&gt;/'</span>.<span style="color: #3E6D8F;">$k</span>.<span style="color: #ff0000;">' =&gt; '</span>.<span style="color: #3E6D8F;">$t</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">' &lt;a href=&quot;'</span>.admin_url<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'options-general.php?page=svn-update%2Fsvn-update.php&amp;svn_update=/'</span>.<span style="color: #3E6D8F;">$k</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'&quot; class=&quot;button-primary&quot;&gt;Update&lt;/a&gt;&lt;/li&gt;'</span>;
    <span style="color: #66cc66;">&#125;</span>
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;/ul&gt;'</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>Este plugin necesita la librería <a href="http://code.google.com/p/phpsvnclient/">PHP SVN Client</a> para acceder al SVN, tan solo hay que meterlo en el mismo directorio que el plugin. Le faltan muchas cosas al plugin, pero ni tengo ganas ni tengo tiempo.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=hFIBcN9UWHg:i5vuJXl7B74:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=hFIBcN9UWHg:i5vuJXl7B74:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=hFIBcN9UWHg:i5vuJXl7B74:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Si trabajas realizando proyectos en WordPress en el que el código se aloja en un servidor usando SVN, una forma sencilla de actualizar tu theme con los últimos cambios es mediante este sencillo y no-seguro plugin. El plugin añade una opción de menú al Settings del Dashboard de WP, el cual te servirá para indicar [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/10/17/actualiza-tu-theme-de-wordpress-desde-svn.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/10/17/actualiza-tu-theme-de-wordpress-desde-svn.php</feedburner:origLink></item><item><title>JSZip: crear ficheros ZIP mediante Javascript</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/9Ve4tgb2xzY/jszip-crear-ficheros-zip-mediante-javascript.php</link><category>Javascript</category><category>jszip</category><category>zip</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Thu, 06 Oct 2011 01:26:58 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2750</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Interesante librería que nos permite crear ficheros ZIP desde Javascript, con unas simples líneas de código podemos crear zips con ficheros de texto, imágenes, crear directorios&#8230;</p>
<pre><code><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> zip = <span style="color: #003366; font-weight: bold;">new</span> JSZip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
zip.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"Hello.txt"</span>, <span style="color: #3366CC;">"Hello World<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;
img = zip.<span style="color: #006600;">folder</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"images"</span><span style="color: #66cc66;">&#41;</span>;
img.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"smile.gif"</span>, imgData, <span style="color: #66cc66;">&#123;</span>base64: <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
content = zip.<span style="color: #006600;">generate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
location.<span style="color: #006600;">href</span>=<span style="color: #3366CC;">"data:application/zip;base64,"</span>+content;</pre></code></pre>
<p>El único problema que hay es a la hora de generar el nombre del fichero: Firefox crea un fichero con un nombre extraño y acabado en .part, Safari lo nombra &#8220;Unknown&#8221; sin extensión, Chrome &#8220;download.zip&#8221; e IE directamente ni funciona la librería.</p>
<p><a href="http://jszip.stuartk.co.uk/">JSZip</a></p>
<p>Vía / <a href="https://twitter.com/#!/devongovett/status/121656042483499008">@devongovett</a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=9Ve4tgb2xzY:t0ygPplRHbk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=9Ve4tgb2xzY:t0ygPplRHbk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=9Ve4tgb2xzY:t0ygPplRHbk:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Interesante librería que nos permite crear ficheros ZIP desde Javascript, con unas simples líneas de código podemos crear zips con ficheros de texto, imágenes, crear directorios&amp;#8230; var zip = new JSZip&amp;#40;&amp;#41;; zip.add&amp;#40;"Hello.txt", "Hello World\n"&amp;#41;; img = zip.folder&amp;#40;"images"&amp;#41;; img.add&amp;#40;"smile.gif", imgData, &amp;#123;base64: true&amp;#125;&amp;#41;; content = zip.generate&amp;#40;&amp;#41;; location.href="data:application/zip;base64,"+content; El único problema que hay es a la hora de [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/10/06/jszip-crear-ficheros-zip-mediante-javascript.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/10/06/jszip-crear-ficheros-zip-mediante-javascript.php</feedburner:origLink></item><item><title>Acceder a Streaming API de PHP</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/eTFhjyIyUYU/acceder-a-streaming-api-de-php.php</link><category>PHP</category><category>API</category><category>streaming</category><category>twitter</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Thu, 29 Sep 2011 04:13:34 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2746</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Para aquellos que necesiten realizar aplicaciones sobre Twitter que tiren de la Streaming API, por ejemplo monitorear o que se dice de una marca, les va a venir muy bien este código:</p>
<pre><code><pre class="php"><a href="http://www.php.net/set_time_limit"><span style="color: #000066;">set_time_limit</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
 
<span style="color: #3E6D8F;">$query_data</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'track'</span> =&gt; <span style="color: #ff0000;">'lo que quieres buscar'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #3E6D8F;">$user</span> = <span style="color: #ff0000;">'username'</span>;	<span style="color: #808080; font-style: italic;">// replace with your account</span>
<span style="color: #3E6D8F;">$pass</span> = <span style="color: #ff0000;">'password'</span>;	<span style="color: #808080; font-style: italic;">// replace with your account</span>
 
<span style="color: #3E6D8F;">$fp</span> = <a href="http://www.php.net/fsockopen"><span style="color: #000066;">fsockopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"stream.twitter.com"</span>, <span style="color: #cc66cc;">80</span>, <span style="color: #3E6D8F;">$errno</span>, <span style="color: #3E6D8F;">$errstr</span>, <span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">"$errstr ($errno)<span style="color: #000099; font-weight: bold;">\n</span>"</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #723b00;">else</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #3E6D8F;">$request</span> = <span style="color: #ff0000;">"GET /1/statuses/filter.json?"</span> . http_build_query<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$query_data</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">" HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<span style="color: #3E6D8F;">$request</span> .= <span style="color: #ff0000;">"Host: stream.twitter.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<span style="color: #3E6D8F;">$request</span> .= <span style="color: #ff0000;">"Authorization: Basic "</span> . <a href="http://www.php.net/base64_encode"><span style="color: #000066;">base64_encode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$user</span> . <span style="color: #ff0000;">':'</span> . <span style="color: #3E6D8F;">$pass</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>;
	<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span>, <span style="color: #3E6D8F;">$request</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #723b00;">while</span><span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/feof"><span style="color: #000066;">feof</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #3E6D8F;">$json</span> = <a href="http://www.php.net/fgets"><span style="color: #000066;">fgets</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #3E6D8F;">$data</span> = json_decode<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$json</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #723b00;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//</span>
			<span style="color: #808080; font-style: italic;">// Do something with the data!</span>
			<span style="color: #808080; font-style: italic;">//</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$fp</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></code></pre>
<p>El parámetro <em>track</em> se puede cambiar por <em>follow</em> (usando IDs numéricos) para saber que dice algún usuario y que dicen los que le mencionan o retuitean.</p>
<p>Vía / <a href="http://af-design.com/blog/2010/12/17/reading-the-twitter-stream-api-with-php/">AF-Design</a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eTFhjyIyUYU:vWQmVaR_SMk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eTFhjyIyUYU:vWQmVaR_SMk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=eTFhjyIyUYU:vWQmVaR_SMk:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Para aquellos que necesiten realizar aplicaciones sobre Twitter que tiren de la Streaming API, por ejemplo monitorear o que se dice de una marca, les va a venir muy bien este código: set_time_limit&amp;#40;0&amp;#41;; $query_data = array&amp;#40;'track' =&amp;#62; 'lo que quieres buscar'&amp;#41;; $user = 'username'; // replace with your account $pass = 'password'; // replace with [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/09/29/acceder-a-streaming-api-de-php.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">9</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/09/29/acceder-a-streaming-api-de-php.php</feedburner:origLink></item><item><title>Añadir clase a la imagen destacada de WordPress según el tamaño</title><link>http://feedproxy.google.com/~r/sentidoweb/~3/foL-_j6_QfA/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php</link><category>PHP</category><category>WordPress</category><category>class</category><category>filter</category><category>post_thumbnail_html</category><category>thumbnail</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">displaynone</dc:creator><pubDate>Wed, 14 Sep 2011 10:07:07 PDT</pubDate><guid isPermaLink="false">http://sentidoweb.com/?p=2739</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Hace bastante que no escribía, sobre todo por falta de tiempo, pero quería escribir sobre este pequeño truco de WordPress. Cuando añadimos una imagen destacada en un post de WordPress nos podemos encontrar con que la imagen ocupa todo el ancho (lo más normal) o que no ocupa tanto, con lo que nos encontramos que la imagen queda muy sola y el diseño queda feo.</p>
<p>Para solucionar esto, deberemos añadir un filtro, comprobar el tamaño de la imagen y el del ancho del contenido y en el caso de que creamos que es conveniente (por ejemplo la mitad del ancho del contenido) añadir una clase a la imagen:</p>
<pre><code><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> mi_post_thumbnail_html<span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$html</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// Se suele recomendar definir la variable $content_width para ocasiones como esta</span>
  <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #3E6D8F;">$content_width</span>;
  <a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#width=&quot;([^&quot;]+)&quot;#'</span>, <span style="color: #3E6D8F;">$html</span>, <span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #3E6D8F;">$s</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> &lt; <span style="color: #3E6D8F;">$content_width</span>/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.php.net/preg_match"><span style="color: #000066;">preg_match</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#class=&quot;([^&quot;]+)&quot;#'</span>, <span style="color: #3E6D8F;">$html</span>, <span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #723b00;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">"right"</span><span style="color: #66cc66;">&#41;</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #723b00;">return</span> <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'class=&quot;'</span>.<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">'&quot;'</span>, <span style="color: #ff0000;">'class=&quot;'</span>.<span style="color: #3E6D8F;">$c</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">' right&quot;'</span>, <span style="color: #3E6D8F;">$html</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #723b00;">return</span> <span style="color: #3E6D8F;">$html</span>;
<span style="color: #66cc66;">&#125;</span>
add_filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'post_thumbnail_html'</span>, <span style="color: #ff0000;">'mi_post_thumbnail_html'</span><span style="color: #66cc66;">&#41;</span>;</pre></code></pre><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sentidoweb?a=foL-_j6_QfA:C5bjv89UKys:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=foL-_j6_QfA:C5bjv89UKys:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sentidoweb?a=foL-_j6_QfA:C5bjv89UKys:tKBiNdHYW3c"><img src="http://feeds.feedburner.com/~ff/sentidoweb?d=tKBiNdHYW3c" border="0"></img></a>
</div>]]></content:encoded><description>Hace bastante que no escribía, sobre todo por falta de tiempo, pero quería escribir sobre este pequeño truco de WordPress. Cuando añadimos una imagen destacada en un post de WordPress nos podemos encontrar con que la imagen ocupa todo el ancho (lo más normal) o que no ocupa tanto, con lo que nos encontramos que [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sentidoweb.com/2011/09/14/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://sentidoweb.com/2011/09/14/anadir-clase-a-la-imagen-destacada-de-wordpress-segun-el-tamano.php</feedburner:origLink></item></channel></rss>
