<?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:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel><title>emenia.es</title> <link>http://www.emenia.es</link> <description>Marketing online | Diseño y creación de páginas web</description> <lastBuildDate>Wed, 01 Feb 2012 07:42:31 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Emeniaes" /><feedburner:info uri="emeniaes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/content?lg=es&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://eur.i1.yimg.com/eur.yimg.com/i/es/my/addto1.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.feedness.com/alta/http://feeds.feedburner.com/Emeniaes" src="http://www.feedness.com/ayuda/wp-content/square_b_sh_feed.gif">Subscribe with Feedness</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Emeniaes" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsalloy.com/?rss=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.newsalloy.com/subrss3.gif">Subscribe with NewsAlloy</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://download.attensa.com/app/get_attensa.html?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.attensa.com/blogs/attensa/WindowsLiveWriter/BadgeredintoBadges_10C02/attensa_feed_button5.gif">Subscribe with Attensa for Outlook</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item><title>Personaliza el área de administración de WordPress</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/X79qBTxzx8c/</link> <comments>http://www.emenia.es/personaliza-wordpress-admin/#comments</comments> <pubDate>Mon, 16 Jan 2012 07:01:30 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[Wordpress]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3223</guid> <description><![CDATA[Hay ocasiones en las que necesitamos variar el área de administración de WordPress para hacerlo más amigable, o para incluir (o excluir) funcionalidades con vistas a su uso por un cliente o una tercera persona. Vamos a ver una serie &#8230; <a
href="http://www.emenia.es/personaliza-wordpress-admin/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Hay ocasiones en las que necesitamos variar el área de administración de WordPress para hacerlo más amigable, o para incluir (o excluir) funcionalidades con vistas a su uso por un cliente o una tercera persona.</p><p>Vamos a ver una serie de funciones que nos permitirán precisamente eso: adaptar un poco el gestor de WordPress. Vamos a verlas una a una.</p><h3>Cambia el logo de la pantalla de login</h3><p>En la pantalla de login del gestor sale el logo de WordPress encima del formulario. Podemos poner el logo que queramos en su lugar. Para ello añadimos esta función en el archivo functions.php de nuestro tema:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Logo personalizado en la página de login</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_login_logo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;style type=&quot;text/css&quot;&gt;
        h1 a { background-image: url('</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/logo.png) !important; }
        &lt;/style&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'login_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_login_logo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>La imagen (en este caso logo.png) la guardaríamos en el directorio &#8220;images&#8221; de nuestro tema.</p><h3>Cambia el pie de página del panel de administración</h3><p>El código iría igualmente en el archivo functions.php de vuestro tema. Esto os permite poner la frase que queráis, por ejemplo:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Cambiar el pie de pagina del panel de Administración</span>
<span style="color: #000000; font-weight: bold;">function</span> change_footer_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&amp;copy;2011 Copyright NOMBRE DE LA EMPRESA. Todos los derechos reservados - Web creada por &lt;a href=&quot;http://www.emenia.es&quot;&gt;Emenia&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_footer_text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'change_footer_admin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><h3>Borra opciones del menú de administración</h3><p>Igualmente, pegamos el código en functions.php.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Borrar opciones de admin</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_remove_menu_pages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> my_remove_menu_pages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Entradas</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Multimedia</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'link-manager.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Enlaces</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit.php?post_type=page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Páginas</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit-comments.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Comentarios</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'themes.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Apariencia</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'plugins.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Plugins</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Usuarios</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tools.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Herramientas</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'options-general.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Ajustes</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Incluso podemos quitarlo sólo si no eres administrador, por ejemplo. En este caso quitamos &#8220;Multimedia&#8221;:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Eliminamos Multimedia si no eres Administrador        </span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_options'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'more_remove_menu_page'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> more_remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            remove_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Multimedia         </span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h3>Elimina metaboxes de las entradas</h3><p>A la hora de crear una entrada en WordPress aparecen un montón de ventanas para introducir contenido o para mostrar información. Muchas veces nos sobran muchas de ellas y sólo generan confusión a usuarios que no sean conocedores de WordPress. Poniendo este código en functions.php podemos eliminar las que nos parezcan prescindibles:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">/////////////////////////////////////////////////////////////////////////////////////////</span>
    <span style="color: #666666; font-style: italic;">// Eliminamos metaboxes de los posts</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
        <span style="color: #000000; font-weight: bold;">function</span> my_remove_meta_boxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linktargetdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linkxfndiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linkadvanceddiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postexcerpt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trackbacksdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentstatusdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postcustom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentstatusdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentsdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'revisionsdiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authordiv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sqpt-meta-tags'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_remove_meta_boxes'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Como veis la función <a
href="http://codex.wordpress.org/Function_Reference/remove_meta_box" title="Ir al codex de WordPress">remove_meta_box</a> tiene tres parámetros: el primero es el &#8220;id&#8221; de la ventana que queremos eliminar, el segundo puede ser &#8220;page&#8221;, &#8220;post&#8221; o &#8220;link&#8221; dependiendo donde estemos y el tercero &#8220;normal&#8221;, &#8220;advanced&#8221; o &#8220;side&#8221; dependiendo dónde esté la ventana. En esta función sólo se quitan si no eres administrador. Si elimináis ese condicional se quitarán en todos los casos. Podéis ver qué es cada ventana en función de su &#8220;id&#8221; en el código HTML.</p><h3>Elimina metaboxes del escritorio</h3><p>También en el escritorio hay unas cuantas ventanas que nos pueden sobrar. También para functions.php el código sería:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
   <span style="color: #666666; font-style: italic;">// Eliminamos metaboxes del Dashboard</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> example_remove_dashboard_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_quick_press'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_recent_drafts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_primary'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_secondary'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_incoming_links'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_recent_comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_right_now'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_plugins'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            remove_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'dashboard_browser_nag'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_remove_dashboard_widgets'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Aquí igualmente las podéis identificar por el ID de la ventana que queráis eliminar.</p><h3>Fuerza el escritorio a una sola columna</h3><p>Puede ser que hayáis quitado tantas cosas del escritorio que os queden las dos columnas originales pero tengáis sólo una ocupada. Podéis forzar al escritorio a que tenga una sola columna con esta función:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
   <span style="color: #666666; font-style: italic;">// Forzamos el escritorio a una sola columna</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> so_screen_layout_columns<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$columns</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$columns</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$columns</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'screen_layout_columns'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'so_screen_layout_columns'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> so_screen_layout_dashboard<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'get_user_option_screen_layout_dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'so_screen_layout_dashboard'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><h3>Crea una ventana nueva en el escritorio</h3><p>Como no siempre es sólo quitar, hay veces que también hay que añadir. Si queréis introducir una nueva ventana en el escritorio con algún texto (por ejemplo un texto de bienvenida), podéis poner en functions.php:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">    //////////////////////////////////////////////////////////////////////////////////////////
    // Widget para el Dashboard
&nbsp;
    function custom_dashboard_widget() { ?&gt;
            &lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/logo.png&quot; /&gt;
            &lt;h1&gt;¡Hola! Este es tu área personal en la web XXXX&lt;/h1&gt;
            &lt;p&gt;Aquí va todo el texto que quieras, con todo el HTML que precises&lt;/p&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">function</span> add_custom_dashboard_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            wp_add_dashboard_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom_dashboard_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bienvenido al editor de la web de XXXX'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_dashboard_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_custom_dashboard_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Como veis utilizamos la función de WordPress <a
href="http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget" title="Ir al Codex de WordPress.">wp_add_dashboard_widget</a>. Lamentablemente no parece que podamos elegir la ubicación de nuestro widget dentro del escritorio. Aparecerá abajo de todo. Si la posición es importante, podéis sustituir esta función por la normal de &#8220;add_meta_box&#8221;:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">    //////////////////////////////////////////////////////////////////////////////////////////
    // Widget para el Dashboard
&nbsp;
    function custom_dashboard_widget() { ?&gt;
            &lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/logo.png&quot; /&gt;
            &lt;h1&gt;¡Hola! Este es tu área personal en la web XXXX&lt;/h1&gt;
            &lt;p&gt;Aquí va todo el texto que quieras, con todo el HTML que precises&lt;/p&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_dashboard_setup_function'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_dashboard_setup_function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    add_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_dashboard_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bienvenido al editor de la web de XXXXX'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_dashboard_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dashboard'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'high'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Esto está muy bien, pero quizás queramos añadir estilos propios para este código HTML que hemos añadido. ¿Cómo lo haríamos? Podemos crear un plugin. Añadimos una carpeta en la carpeta wp-content/plugins que vamos a llamar admin-escritorio. Dentro de esta carpeta creamos dos archivos, uno que se llame admin-escritorio.php y el otro admin-escritorio.css.</p><p>El primero, admin-escritorio.php sería:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Estilos personalizados Widget Escritorio Admin
Plugin URI: http://www.emenia.es
Description: Añade una hoja de estilo para el Escritorio del Admin de Wordpress
Author: Emenia
Version: 1.0
Author URI: http://www.emenia.es
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_admin_head<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;'</span> <span style="color: #339933;">.</span>plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin-escritorio.css'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_admin_head'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div><p>A continuación podéis poner la función que vimos más arriba, que contiene el código HTML. Como veis hemos incluido la hoja de estilo, que tendrá el nombre admin-escritorio.css:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
    Document   : admin-escritorio
    Created on : 11-ene-2012, 8:06:12
    Author: Emenia
    Author URI: http://www.emenia.es
    Email: info@emenia.es
    Description: Estilos para el admin de Wordpress
*/</span>
<span style="color: #339933;">.</span>icon32<span style="color: #339933;">.</span>icon<span style="color: #339933;">-</span>dashboard<span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">#icon-index,
</span><span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php h2<span style="color: #339933;">,</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php h3<span style="color: #339933;">.</span>hndle <span style="color: #009900;">&#123;</span> display<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">.</span>bienvenido h1 <span style="color: #009900;">&#123;</span>
    font<span style="color: #339933;">-</span>family<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;HelveticaNeue-Light&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Helvetica Neue Light&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Helvetica Neue&quot;</span><span style="color: #339933;">,</span>sans<span style="color: #339933;">-</span>serif<span style="color: #339933;">;</span>
    font<span style="color: #339933;">-</span>size<span style="color: #339933;">:</span> 32px<span style="color: #339933;">;</span>
    font<span style="color: #339933;">-</span>weight<span style="color: #339933;">:</span> normal<span style="color: #339933;">;</span>
    line<span style="color: #339933;">-</span>height<span style="color: #339933;">:</span> <span style="color:#800080;">1.2</span><span style="color: #339933;">;</span>
    margin<span style="color: #339933;">:</span> <span style="color: #339933;">.</span>1em <span style="color: #cc66cc;">0</span> <span style="color: #339933;">.</span>8em<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside h1<span style="color: #339933;">,</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside h2<span style="color: #339933;">,</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside p<span style="color: #339933;">,</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside <span style="color: #339933;">.</span>button<span style="color: #339933;">-</span>primary <span style="color: #009900;">&#123;</span> margin<span style="color: #339933;">-</span>left<span style="color: #339933;">:</span> 15px<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside h2 <span style="color: #009900;">&#123;</span> display<span style="color: #339933;">:</span> block<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #339933;">.</span>index<span style="color: #339933;">-</span>php <span style="color: #339933;">.</span>inside h2 <span style="color: #009900;">&#123;</span> margin<span style="color: #339933;">:</span> 10px <span style="color: #cc66cc;">0</span> 10px 15px<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Bueno, esos estilos no tendrán mucho sentido en este caso. Son de una web que he hecho recientemente. Podréis cambiarlos por otros que necesitéis en función del código HTML que hayáis puesto en la función que vimos más arriba.</p><p>A propósito, una vez añadido el código del plugin no os olvidéis de activarlo!</p><h3>Elimina y añade opciones de la barra de Administración</h3><p>Desde la versión 3.3 de WordPress podemos personificar la barra de administración de una manera distinta a como se hacía hasta ahora. Hay un <a
href="http://www.sitepoint.com/change-wordpress-33-toolbar" title="Cómo modificar la barra de administración">artículo muy bueno de Craig Buckler</a> que nos lo muestra. Como veis se usan los métodos &#8220;remove_node&#8221; para eliminar y &#8220;add_node&#8221; para añadir. En este último caso hay que pasar un array con varios parámetros:</p><ul><li>id — el id que aparecerá en el elemento HTML y que lo identifica</li><li>title — el texto que aparecerá en el menú de la barra</li><li>parent — el ID de la opción superior del menú, para el caso de submenú (opcional)</li><li>href — el enlace hacia donde irá el usuario al hacer click (opcional)</li><li>group — true (verdadero) si es un grupo (opcional)</li><li>meta — un array que incluye otras etiquetas, como: html, class, onclick, target, title, tabindex</li></ul><p>Pondremos en el archivo functions.php;</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////    </span>
    <span style="color: #666666; font-style: italic;">// Eliminar opciones de la barra del administrador</span>
    <span style="color: #000000; font-weight: bold;">function</span> change_toolbar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_toolbar</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$instrucciones</span> <span style="color: #339933;">=</span> get_admin_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/admin.php?page=instrucciones'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$ver_prendas</span> <span style="color: #339933;">=</span> get_admin_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'//edit.php?post_type=ropa'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$anadir_prendas</span> <span style="color: #339933;">=</span> get_admin_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'//post-new.php?post_type=ropa'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$volver</span> <span style="color: #339933;">=</span> esc_url<span style="color: #009900;">&#40;</span> get_author_posts_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove_node</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-logo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove_node</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove_node</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'new-content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove_node</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'site-name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_node</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'volver_web'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Ir a mi p&amp;aacute;gina en la web'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$volver</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'meta'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'target'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'volver'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_node</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'myhelp'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Ayuda'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$instrucciones</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'meta'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'target'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'help'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_node</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'prendas'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Mi ropa'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ver_prendas</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'meta'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'target'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ver'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wp_toolbar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_node</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nueva_prenda'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Añadir ropa'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$anadir_prendas</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'meta'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'target'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'anadir'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_bar_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'change_toolbar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">999</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Como veréis hemos añadido varias opciones. Una es una pestaña que crearemos más adelante que llamamos &#8220;Ayuda&#8221;. Otras dos que son de posibles entradas personalizadas de &#8220;Ropa&#8221; y la última que lleva al usuario a su página de autor de la web (quizás estos ejemplos no os valgan de nada, pero al provenir de un caso real quizás os den alguna idea). Por otro lado hemos eliminado con remove_node las opciones que vienen por defecto.</p><p>También podemos mostrar la barra sólo a los administradores:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_options'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'show_admin_bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'__return_false'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h3>Crear una nueva pestaña en el menú de administración</h3><p>Imagina que quieres crear una nueva pestaña en el menú que está a la izquierda en el panel de administración de WordPress. Vamos a suponer que queremos crear una página de instrucciones para nuestro cliente. Para ello podemos crear un plugin. Abrimos en wp-content/plugins una carpeta que se llame &#8220;instrucciones&#8221; y dentro creamos un archivo que se llame &#8220;instrucciones.php&#8221; que sería así:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Instrucciones de uso
Plugin URI: http://www.emenia.es
Description: Para añadir una nueva opción en el menú con instrucciones
Version: 1.0
Author: Emenia
Author URI: http:www.emenia.es
License: GPLv2
*/</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_plugin_menu'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_plugin_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        add_menu_page<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Instrucciones'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Instrucciones'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'edit_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'instrucciones'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_plugin_options'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_plugin_options<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
		wp_die<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No tiene suficientes permisos para acceder a esta página.'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;div class=&quot;wrap&quot;&gt;
        &lt;h1&gt;Instrucciones&lt;/h1&gt;
&nbsp;
        &lt;!-- Aquí va todo el código HTML que preciséis --&gt;
	&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div><p>Si queréis que tenga estilos podéis incluirlos en el propio archivo HTML en el caso de que no sean muy complejos para ganar sencillez. Podéis también aprovechar la hoja de estilos que creamos anteriormente.</p><p>No os olvidéis de activar el plugin.</p><h3>Pon iconos personalizados en el menú del panel de administración</h3><p>Si quieres puedes cambiar los iconos del panel de administración por otros más de tu gusto. Esto es especialmente útil para las entradas personalizadas. Necesitarás poner en functions.php esta función:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">    /////////////////////////////////////////////////////////////////////////////////////////
    // Iconos personalizados para la entrada personalizada
&nbsp;
    add_action( 'admin_head', 'wpt_portfolio_icons' );
&nbsp;
    function wpt_portfolio_icons() {
        ?&gt;
        &lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
            #menu-posts-ropa .wp-menu-image {
                background: url(<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/nuevo-icono.png) no-repeat 6px 6px !important;
            }
            #menu-posts-ropa:hover .wp-menu-image, #menu-posts-ropa.wp-has-current-submenu .wp-menu-image {
                background-position:6px -16px !important;
            }
            #icon-edit.icon32-posts-ropa {background: url(<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/nuevo-icono-32.png) no-repeat;}
        &lt;/style&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Como veis, en este caso el icono que ponemos se llama &#8220;nuevo-icono.png&#8221;. El icono debería tener un tamaño de 28&#215;28 píxeles. El icono interior (una vez se ha hecho click y entramos en su página) tiene 32&#215;32. Ambos se guardan, en este caso, en el directorio &#8220;images&#8221; de tu tema. En esta función tendréis que cambiar los id (que en el ejemplo son #menu-posts-ropa, #menu-posts-ropa:hover y #icon-edit.icon32-posts-ropa) por los correspondientes a la opción para la cual queréis cambiar el icono.</p><h3>Campos personalizados, entradas personalizadas, cambios en el perfil de usuarios&#8230;..</h3><p>Hay muchos más cambios que puedes realizar en el administrador de WordPress, aparte de los que acabamos de comentar, y que afectan a las entradas, a las páginas y a los perfiles de usuario.<br
/> Como los hemos visto en artículos anteriores, no voy a entrar en ellos. Haced click en la nube de etiquetas en &#8220;WordPress&#8221; y veréis artículos sobre los Usuarios, Taxonomías, Campos Personalizados, Entradas Personalizadas, etc..</p><p>¡Espero que este artículo os haya sido útil! ¡Os animo a que aportéis más trucos para personalizar el administrador de WordPress!</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/X79qBTxzx8c" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/personaliza-wordpress-admin/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.emenia.es/personaliza-wordpress-admin/</feedburner:origLink></item> <item><title>Plugin para subir imágenes en un campo personalizado de WordPress</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/VmRLEhccAmE/</link> <comments>http://www.emenia.es/plugin-subir-imagenes-campo-personalizado-wordpress/#comments</comments> <pubDate>Mon, 12 Dec 2011 07:00:42 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[Wordpress]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3127</guid> <description><![CDATA[Es sencillo crear en WordPress campos personalizados para entradas y páginas usando la función add_metabox. Esta función te permite añadir nuevas secciones a las páginas de creación y edición de Entradas y de Páginas. Ya hemos hablado sobre esta función &#8230; <a
href="http://www.emenia.es/plugin-subir-imagenes-campo-personalizado-wordpress/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Es sencillo crear en WordPress campos personalizados para entradas y páginas usando la función <a
href="http://codex.wordpress.org/Function_Reference/add_meta_box" title="Ir al Codex de WordPress">add_metabox</a>. Esta función te permite <strong>añadir nuevas secciones</strong> a las páginas de creación y edición de Entradas y de Páginas. Ya hemos hablado sobre esta función en este artículo sobre <a
href="http://www.emenia.es/campos-personalizados-para-las-entradas-personalizadas-en-wordpress/" title="Ir al artículo sobre Campos Personalizados en WordPress">Campos personalizados para las Entradas personalizadas en WordPress</a>. Un buen artículo no tan enfocado a las estradas personalizadas es <a
href="http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/" title="Ir a Wptuts+">este de Wptuts+</a>.</p><p>Pero <strong>¿qué hacer cuando queremos que se pueda subir una imagen desde el campo personalizado?</strong> Supongamos que las entradas de nuestra página de WordPress son &#8220;Productos&#8221;, y que cada producto tiene tres imágenes. Podemos subir las imágenes desde el apartado &#8220;Multimedia&#8221; y luego crear tres campos personalizados de texto y escribir en ellos el nombre de cada archivo. Puede ser que para nosotros sea más que suficiente. Pero, ¿y si le estás haciendo la página a un cliente no experto en WordPress? La primera vez que le explicas el proceso de subir la imagen del producto puede ser que veas que no se está enterando de nada&#8230;</p><p>En estos casos es mejor que <strong>el campo personalizado sea directamente un botón para subir la imagen</strong>. Al hacer click en crear o editar una entrada queremos que nos salga esto:</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/12/wordpress-campos-personalizados-subir-imagenes1.jpg" alt="Campos personalizados en WordPress para subir imágenes" title="wordpress-campos-personalizados-subir-imagenes" width="600" height="664" class="alignnone size-full wp-image-3179" /></p><p>Y una vez subimos una imagen queremos que esta se vea para ser más sencillo saber qué es lo que hemos subido (por cierto, una pulsera de <a
href="http://www.tiendateresaldama.com" title="Teresa Aldama">Teresa Aldama</a>)</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/12/wordpress-campos-personalizados-subir-imagenes22.jpg" alt="Campos personalizados en WordPress para subir imágenes" title="wordpress-campos-personalizados-subir-imagenes2" width="600" height="857" class="size-full wp-image-3183" /></p><p><strong>Vamos a crear un sencillo plugin que nos va a crear tres campos personalizados para subir tres imágenes diferentes</strong> (siguiendo el ejemplo del &#8220;Producto&#8221;). Hay muchos plugins de WordPress que nos permiten hacer esto, pero muchas veces son tan completos y complejos que lo que queremos es una solución simple y propia, que podamos editar sin problemas según nuestras necesidades y a nuestro antojo.</p><p>Para crear este plugin hay muchos artículos y discusiones que me han servido de fuente, como estos:<br
/> - <a
href="http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/" title="Using the WordPress Uploader in Your Plugin or Theme">Using the WordPress Uploader in Your Plugin or Theme</a><br
/> - <a
href="http://www.theenglishguy.co.uk/2010/01/24/multiple-media-uploads-in-wordpress-functions-php/" title="Multiple Media Uploads in WordPress’ Functions.php">Multiple Media Uploads in WordPress’ Functions.php</a><br
/> - Y sobre todo la ayuda del gran libro <a
href="http://justintadlock.com/plugindevbook" title="Professional WordPress Plugin Development">Professional WordPress Plugin Development</a></p><p>Vamos a crear dos archivos, uno al que llamaremos<strong> <em>imagenes-meta-box.php</em></strong>, donde estará toda la lógica del plugin, y otro al que llamaremos <strong><em>imagenes-meta-box.js</em></strong>, donde estará el código javascript para que salga el cargador de medios de WordPress. <strong>Creamos una carpeta en wp-content/plugins</strong> que se llame &#8220;imagenes-meta-box&#8221; y guardamos ahí los dos archivos.</p><p><strong>Vamos con el primer archivo, imagenes-meta-box.php.</strong> Vamos a verlo poco a poco, sólo tendréis que unir las partes que vayamos viendo en el mismo orden ( bajaros el plugin completo al final del artículo).</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Imágenes en campos personalizados
Plugin URI: http://www.emenia.es/plugin-subir-imagenes-campo-personalizado-wordpress
Description: Para añadir imágenes en Entradas, Páginas o Entradas personalizadas
Version: 1.0
Author: Emenia
Author URI: http:www.emenia.es
License: GPLv2
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//hook para crear el meta box</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'add_meta_boxes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_crear'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> em_mtbx_img_crear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Creamos el meta box personalizado</span>
	add_meta_box<span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'em-img-meta'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// atributo ID</span>
                <span style="color: #0000ff;">'&lt;h2&gt;&lt;strong&gt;FOTOS&lt;/strong&gt;: Fotos del Producto&lt;/h2&gt;'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Título</span>
                <span style="color: #0000ff;">'em_mtbx_img_function'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Función que muestra el HTML que aparecerá en la pantalla</span>
                <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Tipo de entrada. Puede ser 'post', 'page', 'link', o 'custom_post_type'</span>
                <span style="color: #0000ff;">'normal'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Parte de la pantalla donde aparecerá. Puede ser 'normal', 'advanced', o 'side'</span>
                <span style="color: #0000ff;">'default'</span> <span style="color: #666666; font-style: italic;">// Prioridad u orden en el que aparecerá. Puede ser 'high', 'core', 'default' o 'low'</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>La primera parte, como veis, <strong>utiliza la función de WordPress add_metabox</strong> para crear el meta-box personalizado. Aqui hay varias opciones que podéis personalizar según vuestras necesidades, como el tipo de entrada donde van a salir (&#8216;post&#8217;, &#8216;page&#8217;, &#8216;link&#8217;, o &#8216;custom_post_type&#8217;, en este último caso poned el nombre de la entrada personalizada), la parte de la pantalla donde aparecerá y en qué posición.<br
/> Como veis se llama a la función <em><strong>em_mtbx_img_function</strong></em> que es la que mostrará los campos en la pantalla agregando el código HTML</p><p>Seguimos con la siguiente parte, que será precisamente esa función:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">function em_mtbx_img_function( $post ) {
&nbsp;
    echo '&lt;h2&gt;&lt;strong&gt;FOTOS DE PRODUCTO&lt;/strong&gt;&lt;br /&gt;En rojo el tamaño que debe de tener cada una.&lt;/h2&gt;';
&nbsp;
	$em_mtbx_img1 = get_post_meta( $post-&gt;ID, '_em_mtbx_img1', true );
	?&gt;
        &lt;h4&gt;Foto 1 del producto - &lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;TAMAÑO: 600px por 667 píxeles&lt;/span&gt;:&lt;/h4&gt;
        &lt;input id=&quot;em_mtbx_img1&quot; class=&quot;em_mtbx_img&quot; type=&quot;text&quot; size=&quot;75&quot; name=&quot;em_mtbx_img1&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
    	  &lt;input id=&quot;img_boton1&quot; type=&quot;button&quot; value=&quot;Seleccionar imagen&quot; class=&quot;img_boton button-secondary&quot;  /&gt;
          &lt;br /&gt;&lt;br /&gt;
          <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; width=&quot;300&quot; height=&quot;333&quot; alt=&quot;&quot; /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
          &lt;br /&gt;&lt;hr /&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">//si ya existe esa imagen obtemos su valor</span>
	<span style="color: #000088;">$em_mtbx_img2</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img2'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;h4&gt;Foto 2 del producto - &lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;TAMAÑO: 600px por 667 píxeles&lt;/span&gt;:&lt;/h4&gt;
        &lt;input id=&quot;em_mtbx_img2&quot; class=&quot;em_mtbx_img&quot; type=&quot;text&quot; size=&quot;75&quot; name=&quot;em_mtbx_img2&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
    	  &lt;input id=&quot;img_boton2&quot; type=&quot;button&quot; value=&quot;Seleccionar imagen&quot; class=&quot;img_boton button-secondary&quot;  /&gt;
          &lt;br /&gt;&lt;br /&gt;
          <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$em_mtbx_img2</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$em_mtbx_img2</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img2</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; width=&quot;300&quot; height=&quot;333&quot; alt=&quot;&quot; /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
          &lt;br /&gt;&lt;hr /&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">//si ya existe esa imagen obtemos su valor</span>
	<span style="color: #000088;">$em_mtbx_img3</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img3'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;h4&gt;Foto 3 del producto - &lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;TAMAÑO: 600px por 667 píxeles&lt;/span&gt;:&lt;/h4&gt;
        &lt;input id=&quot;em_mtbx_img3&quot; class=&quot;em_mtbx_img&quot; type=&quot;text&quot; size=&quot;75&quot; name=&quot;em_mtbx_img3&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img3</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
    	  &lt;input id=&quot;img_boton3&quot; type=&quot;button&quot; value=&quot;Seleccionar imagen&quot; class=&quot;img_boton button-secondary&quot;  /&gt;
          &lt;br /&gt;&lt;br /&gt;
          <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$em_mtbx_img3</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$em_mtbx_img3</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> esc_url<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$em_mtbx_img3</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; width=&quot;300&quot; height=&quot;333&quot; alt=&quot;&quot; /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
          &lt;br /&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Empezamos <strong>en la línea 3 con el título</strong>, que lo podéis cambiar al título que queráis y al tamaño que queráis (yo he puesto como etiqueta h2 por lo que sale bastante grande).</p><p>En la <strong>línea 5 obtenemos el valor del primer campo</strong>, es decir, la URL completa de la primera imagen (en el caso de que ya la hubiéramos subido, claro).</p><p>En las <strong>líneas 7 a 10 </strong>creamos el campo donde se podrá escribir la URL de una imagen o hacer click sobre el botón que abre la ventana característica de WordPress para cargar medios. El funcionamiento de este botón lo gestionaremos mediante el archivo imagenes-meta-box.js, como ya dijimos antes y veremos más tarde. Vemos que si existe ya algún valor previo este se mostrará en su campo respectivo. Podemos además añadir campos de texto explicativos, como en este caso el tamaño que deben tener las imágenes (en ocasiones muy importante si es un tercero el que las va a subir). La clase &#8220;button-secondary&#8221; del botón es propia de la hoja de estilos de WordPress.</p><p>En las <strong>líneas 11 a 13 </strong>comprobamos si existe el valor previo y mostramos la imagen.</p><p>Lo que viene a continuación es una simple repetición para las imágenes dos y tres. <strong>Aquí podéis quitar o añadir en función de las necesidades</strong>, cuidando también de añadir o quitar en la última función en la que se graban los campos.</p><p>Seguimos con una serie de funciones que permiten que el código javascript y el estilo, thickbox, que es el que usa WordPress, <strong>se carguen sólo al crear o editar una entrada</strong>:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//para cargar el archivo imagenes-meta-box.js sólo al crear y editar una entrada</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_print_scripts-post.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_admin_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_print_scripts-post-new.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_admin_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> em_mtbx_img_admin_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'em-image-upload'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'/imagenes-meta-box/imagenes-meta-box.js'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'media-upload'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usando thickbox para subir la imagen al crear o editar una entrada</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_print_styles-post.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_admin_styles'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_print_styles-post-new.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_admin_styles'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> em_mtbx_img_admin_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p><strong>Y acabamos grabando los campos:</strong></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Para grabar los campos. Añadir uno nuevo por cada campo existente, en este caso tres.</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'save_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'em_mtbx_img_save_meta'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> em_mtbx_img_save_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img1'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		update_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img1'</span><span style="color: #339933;">,</span> esc_url_raw<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img1'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img2'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		update_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img2'</span><span style="color: #339933;">,</span> esc_url_raw<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img2'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img3'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		update_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img3'</span><span style="color: #339933;">,</span> esc_url_raw<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'em_mtbx_img3'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Si tenéis más imágenes tendréis que añadir uno por imagen. Como veis comprueba si existe cada entrada y en su caso la graba en la base de datos, limpiándola antes con <a
href="http://codex.wordpress.org/Data_Validation" title="Ir al codex de WordPress para ver esc_url_raw">esc_url_raw</a>.</p><p><strong>Vamos a ver ahora el archivo imagenes-meta-box.js.</strong> Este archivo va a permitir que al hacer click en el botón del formulario aparezca el cargador de medios de WordPress.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ready<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">var</span> formfield <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
   $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.img_boton'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>click<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>addClass<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Image'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      formfield <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>this<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #990000;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.em_mtbx_img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>attr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      tb_show<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'media-upload.php?type=image&amp;TB_iframe=true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   window<span style="color: #339933;">.</span>original_send_to_editor <span style="color: #339933;">=</span> window<span style="color: #339933;">.</span>send_to_editor<span style="color: #339933;">;</span>
   window<span style="color: #339933;">.</span>send_to_editor <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">var</span> fileurl<span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>formfield <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fileurl <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img'</span><span style="color: #339933;">,</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>attr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'src'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#'</span><span style="color: #339933;">+</span>formfield<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>val<span style="color: #009900;">&#40;</span>fileurl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tb_remove<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>removeClass<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Image'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        formfield <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        window<span style="color: #339933;">.</span>original_send_to_editor<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Cada vez que hacemos click en un botón con la clase <em>.img_boton</em> añadimos a la etiqueta <em>&#8220;html&#8221;</em> la clase <em>&#8220;Image&#8221;</em> <strong>(línea 6)</strong> y guardamos en una variable llamada <em>&#8220;formfield&#8221;</em> el valor del atributo <em>&#8220;name&#8221;</em> del elemento anterior con la clase <em>&#8220;em_mtbx_img&#8221;</em> a aquel sobre el que se haya hecho click <em>($this)</em> <strong>(línea 7)</strong>. Esta parte es muy importante porque gracias a ese valor vamos a poder seleccionar en la <strong>línea 18</strong> el <em>ID</em> de dicho input para establecer el valor del mismo en función de la imagen seleccionada. <strong>Por eso es importante que los atributos <em>ID</em> y <em>name</em> de los <em>inputs</em> sean iguales.</strong></p><p>Bueno, pues ya tenemos nuestro plugin. Ya sólo hay que ir a la sección de plugins del administrador y activarlo.</p><p>Ahora viene la segunda parte. <strong>¿Cómo obtenemos las imágenes dentro de nuestro tema?</strong> Pues como si de cualquier otra entrada personalizada se tratara. Supongamos que estamos en single.php de nuestro tema, dentro del loop haríamos:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">..........
// para obtener el valor de la primera imagen
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_em_mtbx_img1'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$em_mtbx_img1</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Si existe el valor ?&gt;</span>
    <span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$em_mtbx_img1</span>; ?&gt;&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
..........</pre></td></tr></table></div><p>Lo mismo sería para las otras dos imágenes.</p><p>Si queréis descargar el plugin, lo podéis hacer aquí:</p><p><a
href="http://www.emenia.es/demos-blog/imagenes-meta-box/imagenes-meta-box.zip" title="Descargar plugin" onClick="_gaq.push(['_trackEvent', 'Botones', 'Click', 'Descarga Plugin Imagenes']);"class="boton_demo">Descargar plugin</a></p><p>A propósito, el plugin lo he probado con el RC2 de WordPress 3.3 y funciona perfectamente con el nuevo cargador de medios.</p><p>¡Espero vuestros comentarios! Seguro que se os ocurren maneras de mejorarlo para que sea más útil para todos.</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/VmRLEhccAmE" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/plugin-subir-imagenes-campo-personalizado-wordpress/feed/</wfw:commentRss> <slash:comments>5</slash:comments> <feedburner:origLink>http://www.emenia.es/plugin-subir-imagenes-campo-personalizado-wordpress/</feedburner:origLink></item> <item><title>Emenia diseña y desarrolla la página web de CVP – Powertrack</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/vdBQnK24sHc/</link> <comments>http://www.emenia.es/emenia-disena-y-desarrolla-pagina-web-cvp-powertrack/#comments</comments> <pubDate>Wed, 07 Dec 2011 11:55:47 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Noticias]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3129</guid> <description><![CDATA[Emenia ha diseñado y desarrollado la página web de CVP, el revolucionario producto de la empresa española Powertrack, empresa tecnológica española dedicada 100% a I+D+i, ganadora de numerosos premios nacionales e internacionales. La web se ha creado utilizando WordPress como &#8230; <a
href="http://www.emenia.es/emenia-disena-y-desarrolla-pagina-web-cvp-powertrack/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Emenia ha diseñado y desarrollado la página web de CVP, el revolucionario producto de la empresa española Powertrack, empresa tecnológica española dedicada 100% a I+D+i, ganadora de numerosos premios nacionales e internacionales.</p><p>La web se ha creado utilizando WordPress como gestor de contenidos, utilizando HTML5.</p><p><a
href="http://www.powertrackcvp.com/" title="Ir a la web de Powertrack">Ir a la web de Powertrack</a></p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/12/cvp.jpg" alt="Web de CVP - Powertrack" title="cvp" width="617" height="401" class="alignnone size-full wp-image-3131" /></p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/vdBQnK24sHc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/emenia-disena-y-desarrolla-pagina-web-cvp-powertrack/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://www.emenia.es/emenia-disena-y-desarrolla-pagina-web-cvp-powertrack/</feedburner:origLink></item> <item><title>Usuarios en WordPress: Funciones y Plugins útiles</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/Rdh3K64XF0E/</link> <comments>http://www.emenia.es/funciones-plugins-usuarios-wordpress/#comments</comments> <pubDate>Mon, 05 Dec 2011 07:01:42 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[Wordpress]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3089</guid> <description><![CDATA[Cuando tienes que realizar una web utilizando WordPress en el que todo gira alrededor de los usuarios y no de las categorías o de las páginas, como en una web normal, necesitaremos lidiar con un aspecto de WordPress que quizás &#8230; <a
href="http://www.emenia.es/funciones-plugins-usuarios-wordpress/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Cuando tienes que realizar una web utilizando WordPress en el que todo gira alrededor de los usuarios y no de las categorías o de las páginas, como en una web normal, necesitaremos lidiar con un aspecto de WordPress que quizás esté menos desarrollado que otros.</p><p>Como sabéis, en WordPress tenemos varios tipos de roles preestablecidos que permiten al dueño de una web determinar lo que cada usuario puede y no puede hacer:</p><ul><li><strong>Super Administrador</strong> &#8211; En el caso de una red de blogs tiene acceso a todas las opciones de administración de dicha red.</li><li><strong>Administrador</strong>: Tiene acceso a todas las opciones de administración de la web</li><li><strong>Editor</strong>: Puede publicar y gestionar entradas y páginas tanto suyos como ajenos.</li><li><strong>Autor</strong>: Puede publicar y gestionar sus propias entradas.</li><li><strong>Colaborador</strong>: Puede escribir y gestionar sus entradas, pero no publicarlas.</li><li><strong>Subscriptor</strong>: Sólo puede gestionar su perfil.</li></ul><p>Vamos a ver una serie de <strong>funciones prácticas</strong> que nos pueden ayudar a mejorar las posibilidades de nuestro tema a la hora de manejar los usuarios de nuestra web.</p><h2>Modificar el perfil del Usuario</h2><p>Una vez demos de alta a un Usuario quizás veamos que <strong>su perfil se nos queda un poco corto</strong>. Quizás necesitamos incorporar nuevos campos y opciones, o una imagen (un logo, por ejemplo), o quizás no queramos que pueda cambiar su contraseña.</p><p>Para ello vamos a tener que abrir el archivo functions.php de nuestro tema. Vamos a ver distintas opciones posibles, aunque hay muchas más (os animo a aportarlas en los comentarios!):</p><p><strong>Ejemplo 1: Vamos a añadir dos nuevos campos personalizados al perfil de usuario.</strong> Para hacerlo lo más genérico posible uno será para elegir entre dos niveles (Nivel 1 o Nivel 2) y el otro será para introducir un campo de texto, por ejemplo el nombre de una imagen que subamos a través de Multimedia (por ejemplo, un logo). para ello me he basado es <a
href="http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields" title="Ir al artículo de Justin Tadlock">este artículo de Justin Tadlock</a>.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">&nbsp;
    add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
    add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
&nbsp;
    function my_show_extra_profile_fields( $user ) { ?&gt;
            &lt;h3&gt;Logo de la empresa&lt;/h3&gt;
            &lt;table class=&quot;form-table&quot;&gt;
                &lt;tr&gt;
                    &lt;th&gt;&lt;label for=&quot;imagen&quot;&gt;Nombre de la imagen (ej. imagen1.jpg):&lt;/label&gt;&lt;/th&gt;
&nbsp;
                    &lt;td&gt;
                        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$imagen</span> <span style="color: #339933;">=</span> esc_attr<span style="color: #009900;">&#40;</span> get_the_author_meta<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'imagen'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                        &lt;input type=&quot;text&quot; name=&quot;imagen&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$imagen</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; id=&quot;imagen&quot; /&gt;
                        &lt;p&gt;Subir el archivo con la opción del menú Multimedia y escribir aquí su nombre.&lt;/p&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
            &lt;h3&gt;Seleccionar Nivel&lt;/h3&gt;
&nbsp;
            &lt;table class=&quot;form-table&quot;&gt;
                &lt;tr&gt;
                    &lt;th&gt;&lt;label for=&quot;nivel&quot;&gt;Tipo de usuario&lt;/label&gt;&lt;/th&gt;
&nbsp;
                    &lt;td&gt;
                        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">=</span> esc_attr<span style="color: #009900;">&#40;</span> get_the_author_meta<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                        &lt;input type=&quot;radio&quot; name=&quot;nivel&quot; value=&quot;Nivel1&quot; id=&quot;nivel1&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Nivel1'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;  Nivel1
                        &lt;input type=&quot;radio&quot; name=&quot;nivel&quot; value=&quot;Nivel2&quot; id=&quot;nivel2&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Nivel2'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;  Nivel2
                    &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'personal_options_update'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_save_extra_profile_fields'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit_user_profile_update'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_save_extra_profile_fields'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_save_extra_profile_fields<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit_user'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user_id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/* Copiar y pegar esta linea para campos adicionales, cambiando el nombre del campo */</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'imagen'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            update_usermeta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'imagen'</span><span style="color: #339933;">,</span> wp_kses<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'imagen'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> none <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'imagen'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
         <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nivel'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            update_usermeta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #339933;">,</span> wp_kses<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nivel'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> none<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nivel'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Vamos a suponer que no queremos que el usuario pueda cambiar el Nivel, que sólo lo pueda cambiar el administrador. Entonces haríamos:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'administrator'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Solo si es administrador  ?&gt; </span>
&nbsp;
            <span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span>Seleccionar Nivel<span style="color: #339933;">&lt;/</span>h3<span style="color: #339933;">&gt;</span>
&nbsp;
            <span style="color: #339933;">&lt;</span>table <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-table&quot;</span><span style="color: #339933;">&gt;</span>
                <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nivel&quot;</span><span style="color: #339933;">&gt;</span>Tipo de usuario<span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;&lt;/</span>th<span style="color: #339933;">&gt;</span>
&nbsp;
                    <span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>
                        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">=</span> esc_attr<span style="color: #009900;">&#40;</span> get_the_author_meta<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                        &lt;input type=&quot;radio&quot; name=&quot;nivel&quot; value=&quot;Nivel1&quot; id=&quot;nivel1&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Nivel1'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;  Nivel1
                        &lt;input type=&quot;radio&quot; name=&quot;nivel&quot; value=&quot;Nivel2&quot; id=&quot;nivel2&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nivel</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Nivel2'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;  Nivel2
                    &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
&nbsp;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// Fin de si es administrador</span></pre></td></tr></table></div><p>Vale, ya tenemos que algunos usuarios son de Nivel 1 y otros de Nivel 2. ¿Cómo usarlo en nuestro tema? Sabiendo el ID del usuario podemos obtener el &#8220;Nivel&#8221; del mismo gracias a la función de WordPress <a
href="http://codex.wordpress.org/Function_Reference/get_the_author_meta" title="Ir al codex de WordPress">get_the_author_meta()</a>:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">// Si estamos dentro del loop podemos obtener el ID del usuario:</span>
<span style="color: #000088;">$usuarioID</span> <span style="color: #339933;">=</span> get_the_author_meta<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;ID&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Una vez tenemos su ID podemos obtener el campo de su perfil que queramos, por ejemplo su Nivel, que acabamos de añadir.</span>
<span style="color: #000088;">$nivel</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span>get_the_author_meta<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$usuarioID</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>También puede ser que queramos obtener fuera del loop el &#8220;Nivel&#8221; que hemos creado (o cualquier otro campo) para añadir, por ejemplo, un &#8220;id&#8221; a la etiqueta body que nos ayude a dar estilos diferentes según a qué opción pertenezca el usuario:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #666666; font-style: italic;">// Para poner un id en Body con el Nivel.</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Obtenemos el usuario actual</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'author_name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
        <span style="color: #000088;">$curauth</span> <span style="color: #339933;">=</span> get_userdatabylogin<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span>
        <span style="color: #000088;">$curauth</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;body <span style="color: #000000; font-weight: bold;">&lt;?php</span> body_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curauth</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curauth</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nivel</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'id=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$curauth</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nivel</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;</pre></td></tr></table></div><p>Otra función interesante de WordPress es <a
href="http://codex.wordpress.org/Function_Reference/get_userdatabylogin" title="Ir al Codex de WordPress">get_userdatabylogin</a>. Sabiendo el nombre de usuario podemos acceder a los valores de su perfil:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_userdatabylogin<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_login</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div><p><strong>ACTUALIZACION:</strong> La función get_userdatabylogin se deja de utilizar a partir de WordPress 3.3.</p><p>Y por ejemplo si queremos obtener una lista de usuarios que sean de Nivel 1 (por seguir con el ejemplo), con su URL y su nombre, entonces podemos usar la función <a
href="http://codex.wordpress.org/Function_Reference/get_users" title="Ir al Codex de WordPress">get_users()</a>, que nos permite incluir en sus parámetros el campo personalizado que hemos creado, y la función que ya hemos visto get_userdatabylogin():</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">        &lt;aside id=&quot;archives&quot; class=&quot;widget&quot;&gt;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #666666; font-style: italic;">// Argumentos para la selección de usuarios. Suponiendo que sólo queremos Colaboradores (Contributors) de Nivel 1</span>
                    <span style="color: #0000ff;">'blog_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'blog_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'role'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'contributor'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'meta_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'meta_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Nivel1'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nicename'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'who'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'contributors'</span>
                     <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Grabamos los usuarios en una variable ?&gt; </span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span>    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$blogusers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Foreach de todos los usuarios</span>
&nbsp;
                    <span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_userdatabylogin<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_login</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Obtenemos el objeto $user a partir de su nombre usando la función que vimos antes</span>
&nbsp;
                    <span style="color: #000088;">$author_url</span> <span style="color: #339933;">=</span> esc_url<span style="color: #009900;">&#40;</span> get_author_posts_url<span style="color: #009900;">&#40;</span> get_the_author_meta<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ID'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Obtenemos la URL del usuario</span>
                    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$author_url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; title=&quot;&quot; &gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Ponemos el enlace con la URL y su nombre</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;/aside&gt;</pre></td></tr></table></div><p><strong>Ejemplo 2: Vamos a eliminar algunos campos del perfil de usuario que pueden sobrarnos</strong>. No sé cómo eliminar gran cantidad de campos como no sea a través de Javascript ocultándolos. Como eso no me gusta demasiado no lo voy a poner aquí. Los que sí sé cómo quitar:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">/// Eliminar selecciones de color del perfil y algunos campos de contacto, añadiendo dos nuevos (Twitter y Facebook)</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin_del_color_options'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> admin_del_color_options<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$_wp_admin_css_colors</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$_wp_admin_css_colors</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> new_contactmethods<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$contactmethods</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$contactmethods</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'twitter'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Twitter'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Add Twitter</span>
  <span style="color: #000088;">$contactmethods</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'facebook'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Facebook'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Add Facebook</span>
  <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contactmethods</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'yim'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Remove Yahoo IM</span>
  <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contactmethods</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'aim'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Remove AIM</span>
  <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contactmethods</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'jabber'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Remove Jabber</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$contactmethods</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_contactmethods'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'new_contactmethods'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p><strong>Ejemplo 3: Que sólo el Administrador pueda cambiar la contraseña de los autores</strong>. Una vez insertado este código al autor no le saldrá el campo de Contraseña y por lo tanto no podrá cambiarla.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Para que sólo el Administrador pueda cambiar la contraseña de los autores</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
  add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'disable_password_fields'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> disable_password_fields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'administrator'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$show_password_fields</span> <span style="color: #339933;">=</span> add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_password_fields'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'__return_false'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Los usuarios en la base de datos</h2><p>Si echas un vistazo a la base de datos de tu instalación de WordPress verá que los datos de los usuarios se encuentran en dos tablas (vamos a suponer que el prefijo que has usado es wp_, aunque esto no sea recomendable):</p><ul><li><strong>wp_users</strong>: Donde tendrás una lista de los usuarios de tu web con los siguientes campos:<ul><li>ID &#8211; El ID del usuario</li><li>user_login &#8211; El nombre de usuario</li><li>user_pass &#8211; La contraseña</li><li>user_nicename &#8211; Es la versión limpia del user_login, que se emplea por ejemplo en las URLs.</li><li>user_email &#8211; El email del usuario</li><li>user_url &#8211; La web del usuario</li><li>user_registered &#8211; Fecha de registro</li><li>user_activation_key &#8211; Utilizado para verificar la cuenta al borrar la contraseña</li><li>user_status &#8211; No parece que se use para nada&#8230;</li><li>display_name &#8211; El nombre introducido al dar de alta al usuario, normalmente el que queremos que aparezca publicamente.</ul></li><li><strong>wp_usermeta:</strong> Almacena la información de cada usuario, llamada meta data. Tiene los siguientes campos:<ul><li>umeta_id: El ID del campo.</li><li>user_id: El ID del usuario.</li><li>meta_key: El nombre del campo.</li><li>meta_value: El valor del campo.</li></ul></li></ul><p>Por ejemplo, los campos personalizados anteriores (&#8220;nivel&#8221; e &#8220;imagen&#8221;), se grabarán en wp_usermeta, siendo meta_key &#8220;nivel&#8221; y meta_value &#8220;Nivel1&#8243; (por ejemplo).</p><p>Hay ocasiones en que las funciones de WordPress se nos pueden quedar limitadas y necesitemos acceder directamente a la base de datos. Veréis que esto no es muy difícil. <a
href="http://wp.smashingmagazine.com/2011/09/21/interacting-with-the-wordpress-database/" title="Ir a Smashing Magazine">En este artículo</a> podéis encontrar más información.</p><h2>Cambios en la lista de Usuarios: Añadiendo los campos personalizados</h2><p>Hemos añadido nuevos campos en el perfil de usuario (<em>nivel</em> e <em>imagen</em>). Cuando hacemos click en Usuarios y nos salen todos los usuarios registrados en la web quizás queramos <strong>incluir los nuevos campos que hemos añadido</strong> en dicha tabla. Vamos a ver cómo hacerlo (como veréis he añadido a la tabla el ID del usuario, que a veces puede ser interesante verlo de forma rápida):</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Añadimos a la lista de usuarios los campos personalizados</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_users_columns'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'manage_users_columns'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_users_custom_column'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'custom_manage_users_custom_column'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> manage_users_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nivel'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Nivel'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'imagen'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Imagen'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID del cliente'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$column_headers</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> custom_manage_users_custom_column<span style="color: #009900;">&#40;</span><span style="color: #000088;">$custom_column</span><span style="color: #339933;">,</span><span style="color: #000088;">$column_name</span><span style="color: #339933;">,</span><span style="color: #000088;">$user_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'nivel'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$user_info</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$nivel</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user_info</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nivel</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$custom_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #006699; font-weight: bold;">{$nivel}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'imagen'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$user_info</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$imagen</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user_info</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imagen</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$custom_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #006699; font-weight: bold;">{$imagen}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$custom_column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #006699; font-weight: bold;">{$user_id}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$custom_column</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_users_columns'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'remove_user_posts_column'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> remove_user_posts_column<span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'role'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$column_headers</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Filtrar por usuario las entradas</h2><p>Si tenéis muchos usuarios diferentes echaréis en falta que en la tabla de entradas se puedan filtrar estas por el Autor. Para ello pegamos este código en nuestro archivo functions.php:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">///////// Para añadir un filtro por el nombre del usuario</span>
&nbsp;
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'administrator'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'restrict_manage_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filtro_autores'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> filtro_autores<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'show_option_all'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Ver todos los autores'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'selected'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    wp_dropdown_users<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Cambios en las capacidades de un determinado rol de usuario</h2><p><strong>Ejemplo 1: Que el Colaborador pueda subir imágenes.</strong> Una crítica que se suele hacer al rol de Colaborador es que no puede subir imágenes. Eso es facilmente modificable:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Para que los contributors puedan subir imágenes</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contributor'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_files'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'allow_contributor_uploads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> allow_contributor_uploads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$contributor</span> <span style="color: #339933;">=</span> get_role<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contributor'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$contributor</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_cap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_files'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p><strong>Ejemplo 2: Que el Colaborador pueda editar sus entradas.</strong> Otra limitación de los Colaboradores es que no pueden editar sus entradas. Podemos también modificar esto manteniendo la necesidad de que una vez editados sean de nuevo enviados para ser autorizados por el Administrador.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Para que el Colaborador pueda editar posts......</span>
<span style="color: #000000; font-weight: bold;">function</span> change_user_permissions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> get_role<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contributor'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Obtiene el rol del usuario</span>
&nbsp;
<span style="color: #000088;">$role</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_cap</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit_published_posts'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// que pueda editar sus propias entradas</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'change_user_permissions'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// ... pero que al editarlos vuelva a tener que pedir permiso</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_insert_post_data'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'re_aprove'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> re_aprove<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">;</span>
    get_currentuserinfo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// comprobar que el usuario actual no es administrador</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_options'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_status'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;publish&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_status'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;pending&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p><strong>Ejemplo 3: Que el Colaborador reciba un email cuando se publique su entrada</strong></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wpr_authorNotification<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> get_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_author</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
      Hola &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,
      Tu entrada, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; ha sido publicada. Gracias.
   &quot;</span><span style="color: #339933;">;</span>
   wp_mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_email</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Tu entrada ha sido publicada&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpr_authorNotification'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p><strong>Ejemplo 4: Que cada autor sólo pueda ver sus entradas</strong></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">// Que cada autor sólo pueda ver sus artículos</span>
    <span style="color: #000000; font-weight: bold;">function</span> query_set_only_author<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_query</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'manage_options'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query_set_only_author'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p><strong>Ejemplo 5: Que sólo el administrador pueda ver los avisos de actualizaciones</strong></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">       <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$user_login</span><span style="color: #339933;">;</span>
       get_currentuserinfo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'update_plugins'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// ver si el usuario puede actualizar plugins</span>
        add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'$a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;remove_action( 'init', 'wp_version_check' );&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'pre_option_update_core'</span><span style="color: #339933;">,</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'$a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;return null;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Saber si un autor tiene o no entradas</h2><p>Imaginémonos que tenemos una lista de autores pero no queremos que salga ninguno que no tenga entradas. Con esta función podemos hacerlo, pasándole el ID del usuario y de manera opcional el tipo de entrada, que puede ser un <a
href="http://www.emenia.es/nuevo-wordpress-3-1-archivos-entradas-personalizadas/" title="Entradas personalizadas en WordPress">tipo de entrada personalizado</a>.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">/* Para saber si un autor tiene productos */</span>
<span style="color: #000000; font-weight: bold;">function</span> wpse31443_author_has_custom_post_type<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_author</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000088;">$post_author</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$post_author</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_post_types</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// If nonexistent post type found return</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">array_intersect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_post_types</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">!=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$post_type</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    static <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Cache the query internally</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT `post_type`, `post_author`, COUNT(*) AS `post_count`&quot;</span><span style="color: #339933;">.</span>
            <span style="color: #0000ff;">&quot; FROM <span style="color: #006699; font-weight: bold;">{$wpdb-&gt;posts}</span>&quot;</span><span style="color: #339933;">.</span>
            <span style="color: #0000ff;">&quot; WHERE `post_type` NOT IN ('revision', 'nav_menu_item')&quot;</span><span style="color: #339933;">.</span>
            <span style="color: #0000ff;">&quot; AND `post_status` IN ('publish', 'pending')&quot;</span><span style="color: #339933;">.</span>
            <span style="color: #0000ff;">&quot; GROUP BY `post_type`, `post_author`&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sql</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_author</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post_author</span>
            and <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$post_type</span> <span style="color: #009900;">&#41;</span>
            and <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_count</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Algunos plugins útiles</h2><p>Para terminar, aparte de las funciones que os he puesto, quizás os sean de utilidad estos plugins:</p><ul><li>Para enviar un email cuando un Colaborador ha enviado una entrada para revisión: <a
href="http://wordpress.org/extend/plugins/wp-status-notifier/" title="WP Status Notifier">WP Status Notifier</a></li><li>Para añadir una foto al perfil de usuario: <a
href="http://wordpress.org/extend/plugins/user-avatar/" title="User Avatar">User Avatar</a></li><li>Igual que el anterior: <a
href="http://wordpress.org/extend/plugins/user-photo/" title="User Photo">User Photo</a></li><li>Plugin para modificar los roles de los usuarios con funcionalidades adicionales: <a
href="http://wordpress.org/extend/plugins/members/" title="Members">Members</a></li><li>Plugin para cambiar el permalink de los usuarios. Si quieres cambiar &#8220;authors&#8221; por cualquier otra cosa: <a
href="http://wordpress.org/extend/plugins/custom-author-base/" title="Custom Author Base">Custom Author Base</a></li></ul> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/Rdh3K64XF0E" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/funciones-plugins-usuarios-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.emenia.es/funciones-plugins-usuarios-wordpress/</feedburner:origLink></item> <item><title>¡Ya tienes disponible el mejor fútbol para tu Smartphone!</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/3hUDPr0jM8w/</link> <comments>http://www.emenia.es/liga-live-html5-smartphone/#comments</comments> <pubDate>Sat, 03 Dec 2011 07:02:07 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Noticias]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3046</guid> <description><![CDATA[Después de superar las 450.000 descargas durante la pasada temporada, a nivel mundial y más de 17.000 seguidores en redes sociales, ya está disponible la nueva y mejorada versión de las apps deportivas “Liga live”, “Premier live” y “Bundesliga live”. &#8230; <a
href="http://www.emenia.es/liga-live-html5-smartphone/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Después de superar las 450.000 descargas durante la pasada temporada, a nivel mundial y más de 17.000 seguidores en redes sociales,  ya está disponible la nueva y mejorada versión de las apps deportivas <strong>“Liga live”, “Premier live” y “Bundesliga live”</strong>.</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/12/ligas.jpg" alt="Liga Live, Premier Live y Bundesliga Live" title="ligas" width="489" height="159" class="alignnone size-full wp-image-3047" /></p><p>Diseñada y desarrollada por <a
href="http://www.pocketwidget.com/small_great_things/" title="Pocket Widget">Pocket Widget</a>, uno de los líderes en desarrollo y comercialización de apps para plataformas móviles y tv, y por <strong>Emenia, que ha desarrollado los frontends en HTML5,</strong> Liga Live, Premier Live y Bundesliga Live permiten al usuario estar al día de la actualidad de fútbol, resultados, calendario, clasificación, narraciones en vivo, noticias y las estadísticas más completas.</p><p><iframe
width="560" height="315" src="http://www.youtube.com/embed/3FQD8KRu4u8?rel=0" frameborder="0" allowfullscreen></iframe></p><p><strong>Descárgate gratis</strong> en tu Smartphone las nuevas apps más completas de las mejores ligas europeas, para seguir las últimas noticias, live, un comparador de jugadores exclusivo y mucho más:</p><p><strong>Apple App Store </strong></p><ul><li><a
href="http://itunes.apple.com/us/app/liga-live/id395226495?l=es&#038;mt=8" title="Liga Live" rel="external nofollow">Liga Live</a></li><li><a
href="http://itunes.apple.com/us/app/premier-live/id395482861?l=es&#038;mt=8" title="Premier Live" rel="external nofollow">Premier Live</a></li><li><a
href="http://itunes.apple.com/us/app/bundesligalive/id395486029?l=es&#038;mt=8" title="Bundesliga Live" rel="external nofollow">Bundesliga Live</a></li></ul><p><strong>Android Market</strong></p><ul><li><a
href="https://market.android.com/details?id=com.pocketwidget.spainleague&#038;feature=search_result" title="Liga Live" rel="external nofollow">Liga Live</a></li><li><a
href="https://market.android.com/details?id=com.pocketwidget.englandleague&#038;feature=search_result" title="Premier Live" rel="external nofollow">Premier Live </a></li><li><a
href="https://market.android.com/details?id=com.pocketwidget.germanyleague&#038;feature=search_result" title="Bundesliga Live" rel="external nofollow">Bundesliga Live</a></li></ul><p><img
src="http://www.emenia.es/wp-content/uploads/2011/12/liga-live.jpg" alt="Liga Live" title="liga-live" width="520" height="297" class="alignnone size-full wp-image-3053" /></p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/3hUDPr0jM8w" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/liga-live-html5-smartphone/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.emenia.es/liga-live-html5-smartphone/</feedburner:origLink></item> <item><title>Web y campaña de marketing online para Nascia</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/DnfYexC9jHo/</link> <comments>http://www.emenia.es/web-y-campana-de-marketing-online-para-nascia/#comments</comments> <pubDate>Wed, 16 Nov 2011 07:47:11 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Noticias]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=3040</guid> <description><![CDATA[Emenia ha diseñado y desarrollado la web de Nascia, empresa madrileña especializada en medición y evaluación psicofisiológica. Cuenta con un equipo profesional de primer nivel y una tecnología propia. Utiliza técnicas de Biofeedback no invasivo y de uso clínico para &#8230; <a
href="http://www.emenia.es/web-y-campana-de-marketing-online-para-nascia/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Emenia ha diseñado y desarrollado la web de Nascia, empresa madrileña especializada en medición y evaluación psicofisiológica. Cuenta con un equipo profesional de primer nivel y una tecnología propia. Utiliza técnicas de Biofeedback no invasivo y de uso clínico para el diseño de tratamientos personalizados de control de estrés.</p><p><a
href="http://www.nascia.com/" title="Web de Nascia">Ir a la web de Nascia</a></p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/11/web-de-nascia.jpg" alt="Web de Nascia" title="web-de-nascia" width="600" height="457" class="alignnone size-full wp-image-3041" /></p><p>La web se ha creado utilizando WordPress como gestor de contenidos y cuenta con gran cantidad de contenido, como un blog propio, sistemas de autoevaluación, noticias o Biblioteca con artículos interesantes sobre el estrés, la ansiedad o el Biofeedback, por ejemplo.</p><p>Además <strong>Emenia gestiona la campaña de Marketing Online de Nascia</strong> que incluye la <strong>gestión de sus redes sociales</strong> (Facebook, Twitter, LinkedIn y You Tube) incluyendo desarrollos personalizados como landing pages o promociones, gestión de Newsletters, posicionamiento natural en buscadores (SEO) o campañas de publicidad en Google y Facebook.</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/DnfYexC9jHo" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/web-y-campana-de-marketing-online-para-nascia/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.emenia.es/web-y-campana-de-marketing-online-para-nascia/</feedburner:origLink></item> <item><title>22 Aplicaciones y plugins útiles en el diseño y desarrollo web</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/fk0B7GpXMNc/</link> <comments>http://www.emenia.es/22-aplicaciones-plugins-utiles-desarrollo-web/#comments</comments> <pubDate>Mon, 19 Sep 2011 06:37:10 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=2929</guid> <description><![CDATA[Todos tenemos nuestra lista de programas, aplicaciones o plugins que usamos mientras diseñamos o desarrollamos páginas web. Las usamos de manera continuada convirtiéndose en imprescindibles. Os voy a dar una lista con las que suelo usar yo. Os invito a &#8230; <a
href="http://www.emenia.es/22-aplicaciones-plugins-utiles-desarrollo-web/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Todos tenemos nuestra lista de programas, aplicaciones o plugins que <strong>usamos mientras diseñamos o desarrollamos páginas web</strong>. Las usamos de manera continuada convirtiéndose en imprescindibles. Os voy a dar una lista con las que suelo usar yo. <strong>Os invito a que pongáis también la vuestra</strong> y así podamos descubrir todos aplicaciones que no conocíamos. No voy a hablar aquí de IDEs, ni de Photoshop ni similares, sino de <strong>pequeños programillas que nos hacen la vida mucho más facil</strong>. No están puestos en ningún orden concreto:</p><h3><a
href="http://www.browserstack.com/" title="Browserstack">Browserstack</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/browserstack.jpg" alt="Browserstack" title="browserstack" width="550" height="250" class="alignnone size-full wp-image-2932" /></p><p>Una de las últimas incorporaciones a mi lista. Al ser usuario de Mac necesito comprobar la compatibilidad de mis desarrollos con las distintas versiones Internet Explorer. Normalmente utilizo VMWare Fusion y MAMP, pero desde que llegó Browserstack no paro de utilizarlo. Permite también comprobar webs que tengas sólo en local y soporta gran cantidad de navegadores diferentes, todos con herramientas tipo Firebug, IE Developer tools, Firebug lite o Web Developer.</p><h3><a
href="http://www.colorzilla.com/gradient-editor/" title="Ultimate CSS Gradient Generator">Ultimate CSS Gradient Generator</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/colorzilla.jpg" alt="CSS Gradient Editor" title="colorzilla" width="550" height="250" class="alignnone size-full wp-image-2935" /></p><p>Este editor de Colorzilla es muy útil para crear gradientes con CSS3 ya que te permite crearlos como si de Photoshop o Fireworks se tratara, pero además te crea las instrucciones de CSS correspondientes que sólo tendrás que copiar y pegar en tu hoja de estilos.</p><h3><a
href="http://my.lovelycharts.com/" title="My Lovely Charts">My Lovely Charts</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/mylovelycharts.jpg" alt="My Lovely Charts" title="mylovelycharts" width="550" height="250" class="alignnone size-full wp-image-2940" /></p><p>Normalmente, y sobre todo si nuestro proyecto tiene complejidad, necesitamos organizar nuestras ideas (y muchas veces las del cliente), tener clara la estructura de nuestra web. Tanto esta aplicación como la que viene a continuación (MindNode Pro) nos ayudan en este fin. Llama la atención la gran cantidad de tipos diferentes de diagramas que ponemos hacer con My Lovely Charts.</p><h3><a
href="http://www.mindnode.com/" title="MindNode Pro">MindNode Pro</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/mindnodepro.jpg" alt="MindNode Pro" title="mindnodepro" width="550" height="250" class="alignnone size-full wp-image-2941" /></p><p>Esta es mi herramienta favorita para crear diagramas rápidos de la estructura de una web, por ejemplo. Mientras analizo con un cliente cómo va a ser su web siempre suelo estar usando este programa que ayuda a visualizar y a organizar mejor lo que se va a hacer. Tiene una gran facilidad de uso. Ojo, es de pago y sólo para Mac, aunque tiene una versión limitada de prueba. Es barata y desde mi punto de vista merece realmente la pena.</p><h3><a
href="http://www.smushit.com/ysmush.it/" title="Smush It">Smush It</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/smushit.jpg" alt="Smush It" title="smushit" width="550" height="250" class="alignnone size-full wp-image-2942" /></p><p>Es importante que las imágenes que subamos a nuestra web estén lo más optimizadas posibles, no digamos ya si estamos sirviendo imágenes para móvil. Smush It, de Yahoo, permite reducir el peso de nuestras imágenes sin pérdida de calidad.</p><h3><a
href="http://pagespeed.googlelabs.com" title="PageSpeed">PageSpeed de Google</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/Page-Speed-Online.jpg" alt="Page Speed Online" title="Page Speed Online" width="550" height="250" class="alignnone size-full wp-image-2945" /></p><p>El tiempo de carga de nuestra web es muy importante para dar un buen servicio a nuestros usuarios. Si queremos tener una web centrada en el usuario tenemos que optimizar los tiempos de carga. Es por ello por lo que buscadores como Google pueden penalizar tu sitio si el tiempo de carga es muy lento. Esta herramienta analiza tu web y te ofrece consejos para mejorar la velocidad de carga.</p><h3><a
href="http://developer.yahoo.com/yslow/" title="YSlow">YSlow</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/yslow.jpg" alt="YSlow" title="yslow" width="550" height="250" class="alignnone size-full wp-image-2946" /></p><p>La alternativa a PageSpeed ofrecida por Yahoo! es YSlow. Está bien utilizar los dos para comparar. YSlow lo puedes instalar en tu navegador.</p><p>Otra buena aplicación online para detectar problemas en la carga de tu página web es <a
href="http://www.webpagetest.org/" title="WebPagetest">WebPagetest</a>.</p><h3><a
href="http://users.skynet.be/mgueury/mozilla/" title="HTML Validator para Firefox">HTML Validator para Firefox</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/htmlvalidator.jpg" alt="HTML Validator para Firefox" title="htmlvalidator" width="550" height="250" class="alignnone size-full wp-image-2949" /></p><p>Lo bueno de este validador de HTML es que funciona desde el propio navegador, en tiempo real y en local, por lo que no necesitas conectarte a ninguna web externa o tener tu web online para poderla validar. El desarrollador está tardando en tener una versión actualizada para Mac y Firefox 6 <a
href="http://www.htmlpedia.org/phpBB/viewtopic.php?f=11&#038;t=990" title="HTML Validator para Firefox 6 y Mac">aunque ya tiene una compilada que funciona bien</a>.</p><h3><a
href="https://github.com/rogerjohansson/html5validator" title="HTML5 Validator">HTML5 Validator</a></h3><p>Estaba acostumbrado al HTML Validator y necesitaba algo igual pero para HTML5 y el desarrollador Roger Johansson lo ha conseguido. Funciona también como extensión de Firefox y en local. Sólo tiene que configurar si para validar lo hace conectándose online o no, dependiendo de si instalas en tu ordenador validator.nu</p><h3><a
href="http://getfirebug.com/" title="Firebug">Firebug</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/firebug.jpg" alt="Firebug" title="firebug" width="550" height="250" class="alignnone size-full wp-image-2950" /></p><p>Qué decir de Firebug que no sepáis ya. Aunque cada vez uso más Chrome y su Inspector sigo pensando que Firebug es superior. Es una pena que su versión de Chrome sea mucho menos potente que la versión de Firefox. Imprescindible.</p><h3><a
href="http://chrispederick.com/work/web-developer/" title="Web Developer">Web Developer</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/Web_Developer1.jpg" alt="Web Developer" title="Web_Developer" width="550" height="250" class="alignnone size-full wp-image-2954" /></p><p>Otro clásico es Web Developer,de la que seguro no hace falta que os hable. Lo podéis tener instalado tanto en Firefox como en Chrome.</p><h3><a
href="http://skitch.com/" title="Skitch">Skitch</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/skitch.jpg" alt="Skitch" title="skitch" width="550" height="250" class="alignnone size-full wp-image-2955" /><br
/> Skitch es gratuita y la utilizo constantemente. Me permite capturar trozos de la pantalla y exportarlos a Photoshop o Fireworks sólo arrastrando la pestaña de la imagen. También te permite escribir o pintar sobre la imagen o sacar fotos usando la cámara del ordenador. La ha adquirido recientemente la gente de Evernote.</p><h3><a
href="http://code.google.com/p/snippely/" title="Snippely">Snippely</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/snippely.jpg" alt="Snippely" title="snippely" width="550" height="250" class="alignnone size-full wp-image-2956" /></p><p>El IDE que uso normalmente es Neatbeans. El sistema que tiene para grabar trozos de código útiles que nos puedan servir para otros proyectos no me gusta nada. Ya podía ser como el de Coda, por ejemplo!<br
/> Es por eso por lo que uso este pequeño programa gratuito para almacenar códigos útiles (aunque muchas veces he de reconocer que se me olvidan los trozos de código que guardo y muchas veces he rehecho cosas que ya tenía almacenados en Snippely&#8230;.)</p><h3><a
href="http://developer.apple.com/devcenter/ios/index.action" title="Simulador iPhone">Emulador iOS</a> y <a
href="http://developer.android.com/sdk/index.html" title="Emulador Android">Emulador Android</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/iphone1.jpg" alt="iPhone Emulator" title="iphone" width="550" height="250" class="alignnone size-full wp-image-2958" /></p><p>Últimamente estoy haciendo frontends para móvil con HTML5 y jQuery Mobile, por lo que estoy continuamente pegado a ambos emuladores. De todas formas siempre viene bien tenerlos a mano para comprobar cómo se ve nuestra web en un móvil, especialmente si hacemos diseños ajustables al ancho de pantalla.</p><h3><a
href="http://foxgui.de/" title="FoxGuide">FoxGuide</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/foxguide.jpg" alt="FoxGuide" title="foxguide" width="550" height="250" class="alignnone size-full wp-image-2960" /></p><p>Esta extensión de Firefox te permite crear una regla y crear guías en el navegador tal y como lo harías en Photoshop o Fireworks. Muy útil para saber si tienes elementos alineados.</p><h3><a
href="http://www.frayd.us/" title="Measure It">MeasureIt</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/measureit.jpg" alt="Measure It" title="measureit" width="597" height="234" class="alignnone size-full wp-image-2965" /></p><p>Extensión para Firefox, Chrome o Safari que te permite medir áreas en la pantalla del navegador. ¿Quieres saber cuánto mide en pixels un rectángulo de una web? Activas MeasureIt y lo mides.</p><h3><a
href="http://www.seomoz.org/seo-toolbar" title="SEOmozToolbar">SEOmoz toolbar</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/seomoz-toolbar.jpg" alt="SEOmoz toolbar" title="seomoz-toolbar" width="597" height="234" class="alignnone size-full wp-image-2966" /></p><p>Como diseñador y desarrollador de webs creo fundamental saber tanto de SEO como te sea posible, tanto desde el punto de vista de la arquitectura óptima de la web que estás creando como de la estrategia de contenidos de la misma. Es por ello por lo que utilizo varias herramientas de SEO. En el navegador tengo varias instaladas (SEOmoz toolbar, Rank Checker, SEO4Firefox, Seoquake).<br
/> Al estar suscrito a SEOmoz Pro utilizo mucho la barra de esta empresa tanto en Firefox como en Chrome. En su versión gratuita tiene varias opciones interesantes. Os podría dar una lista larga de utilidades, pero por ejemplo, una herramienta de pago muy buena para seguir los rankings en buscadores es <a
href="http://www.advancedwebranking.com/" title="Advanced Web Ranking">Advanced Web Ranking</a>.</p><h3><a
href="http://www.dropbox.com/" title="Dropbox">Dropbox</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/dropbox.jpg" alt="Dropbox" title="dropbox" width="597" height="234" class="alignnone size-full wp-image-2967" /></p><p>No entiendo cómo lo hacía antes de conocer Dropbox. Como uso varios ordenadores Dropbox me permite tener sincronizados todos mis archivos de tal manera que si edito un archivo de una web, por ejemplo, tengo esa versión editada en todos los demás. Me sirve también como copia de seguridad externa, así como elemento de comunicación con mis clientes, ya que puedo compatir carpetas con ellos donde me guardan textos, imágenes, etc..</p><p>El único problema es que no encripta los archivos antes de enviarlos a sus servidores, por lo que para ficheros con información sensible utilizo <a
href="http://www.wuala.com/es/" title="Wuala">Wuala</a>.</p><h3><a
href="http://www.fontsquirrel.com/" title="Font Squirrel">Font Squirrel</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/fontsquirrel.jpg" alt="" title="fontsquirrel" width="577" height="259" class="alignnone size-full wp-image-2968" /></p><p>Si quieres usar nuevas fuentes en tus páginas web <a
href="http://www.emenia.es/utilizando-css3-hoy-5-font-face/" title="Utilizando @font-face">utilizando @font-face</a> Font Squirrel es tu sitio. No sólo tienes una gran cantidad de fuentes disponibles, sino que además te crea el código que tienes que pegar en tu hoja de estilos.</p><h3><a
href="http://spriteme.org/" title="Sprite Me">Sprite Me</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/spriteme.jpg" alt="Spriteme" title="spriteme" width="597" height="234" class="alignnone size-full wp-image-2971" /><br
/> Este es una utilidad muy interesante ya que combina todas las imágenes que uses de fondo y te crea un CSS Sprite e incluso te da el código CSS para acceder a cada uno.</p><h3><a
href="http://css-tricks.com/examples/ButtonMaker/" title="CSS-Tricks button maker">CSS-Tricks Button Maker</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/button-maker.jpg" alt="CSS3 button maker" title="button-maker" width="597" height="234" class="alignnone size-full wp-image-2973" /></p><p>Os permite crear botones utilizando gradientes CSS3 con gran facilidad, ya que os crea igualmente el código CSS.</p><h3><a
href="http://colorschemedesigner.com/" title="Color Scheme Designer">Color Scheme Designer</a></h3><p><img
src="http://www.emenia.es/wp-content/uploads/2011/09/color-scheme-designer.jpg" alt="Color Scheme Designer" title="color-scheme-designer" width="577" height="259" class="alignnone size-full wp-image-2974" /></p><p>Te crea un esquema de colores a partir de un color de partida, muy útil para encontrar colores que estén relacionados con uno que vayas a utilizar.</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/fk0B7GpXMNc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/22-aplicaciones-plugins-utiles-desarrollo-web/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.emenia.es/22-aplicaciones-plugins-utiles-desarrollo-web/</feedburner:origLink></item> <item><title>Introducción al Diseño Web Adaptable o Responsive Web Design</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/YYqhfH5Zte4/</link> <comments>http://www.emenia.es/diseno-web-adaptable-o-responsive-web-design/#comments</comments> <pubDate>Tue, 16 Aug 2011 05:37:06 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[CSS3]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=2825</guid> <description><![CDATA[Hoy en día los usuarios de nuestras páginas web o tiendas online pueden acceder a las mismas desde diferentes medios: un ordenador de sobremesa con pantalla panorámica, un móvil, una tableta&#8230; Partiendo de la base de que el diseño de &#8230; <a
href="http://www.emenia.es/diseno-web-adaptable-o-responsive-web-design/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Hoy en día los usuarios de nuestras páginas web o tiendas online <strong>pueden acceder a las mismas desde diferentes medios</strong>: un ordenador de sobremesa con pantalla panorámica, un móvil, una tableta&#8230; Partiendo de la base de que el diseño de una web, para que funcione, <strong>tiene que estar centrada en el usuario</strong> (y no en el diseñador, en el programador o en el dueño de la web), es importante que la experiencia que tiene el usuario con nuestra web sea lo más placentera posible con independencia de qué medio esté usando para verla. Es por ello que últimamente tantos sitios webs están utilizando lo que se llama <strong>Responsive Web Design o Diseño Web adaptable</strong>.</p><h2>¿Qué es el Responsive Web Design o Diseño Web Adaptable?</h2><p>Son una serie de técnicas que <strong>permiten a nuestra página web adaptarse al medio a través del cual un usuario está accediendo a la misma</strong>. Los tamaños de pantalla cambian según el medio con el que se accede (no es lo mismo una pantalla de un iPhone que la de un monitor panorámico de sobremesa) pero el usuario cada vez más exige que su experiencia usando nuestra web sea la óptima en cada caso concreto. Utilizando HTML y principalmente CSS podemos servir al usuario una versión de nuestra web en función del ancho de pantalla utilizado. Es decir, <strong>nuestra web se adapta al ancho de pantalla</strong>, responde ante los cambios del tamaño la misma. Además podemos pensar en mejorar el acceso a formularios, botones, etc&#8230; Eso es Responsive Web Design o Diseño Web Adaptable.</p><h2>¿Por qué es importante el Diseño Web Adaptable?</h2><p>Como nos dice <a
href="http://www.internetretailing.net/2011/07/mobile-web-is-disappointing-consumers-the-world-over-finds-study/" title="Ir al artículo de InternetRetailing" target="_blank">este artículo de InternetRetailing</a> la web a través del móvil está defraudando a los usuarios. ¿La razón? <strong>Los sitios no están optimizados</strong>, no están pensados para verse a través de una pantalla tan pequeña como la del móvil. Como decíamos antes, si el usuario es lo más importante no podemos permitr que esto suceda con nuestra web.</p><p>Además, tal y como explico en el artículo <a
href="http://www.emenia.es/auditoria-seo-a-tu-web/" title="Ir al artículo Haz una auditoría SEO a tu web">Haz una auditoría SEO a tu web</a>, <strong>la experiencia de usuario debe ser prioritaria a la hora de pensar en tu estrategia SEO</strong>. Las webs con mejor experiencia de usuario gustarán más, serán más compartidas, mejor valoradas, más populares. Y eso en SEO es muy importante.</p><p>Dado el gran número de medios y navegadores existentes no es factible crear una versión de nuestra web para cada uno de ellos, por lo que necesitamos <strong>un sistema para que nuestra web se adapte al contexto en el que está siendo vista, optimizándose de manera automática</strong>.</p><h2>Primer paso: El diseño fluido</h2><p>El principal concepto en el que se apoya el Diseño Web Adaptable es en abandonar los anchos fijos de nuestra web. <strong>Estos deberán ser fluidos</strong>. En lugar de diseñar nuestra web basándonos en valores fijos (por ejemplo width: 960px), <strong>el diseño fluido está pensado en términos de proporciones</strong>. De esta manera cuando veamos nuestra web a través de la pequeña pantalla de un móvil todos los elementos de la web se harán más pequeños guardando la proporción entre ellos. Por ejemplo, para saber ahora el ancho de un elemento tendremos que dividir el ancho inicial del mismo entre el ancho del elemento &#8220;padre&#8221;, por llamarlo de alguna manera sencilla. Pongamos que tenemos por ejemplo esta estructura:</p><p><a
href="http://www.emenia.es/wp-content/uploads/2011/08/diseno-web-fluido.jpg" title="Imagen de Diseño web fluido"><img
src="http://www.emenia.es/wp-content/uploads/2011/08/diseno-web-fluido.jpg" alt="Diseño web fluido" title="diseno-web-fluido" width="550" height="344" class="alignnone size-full wp-image-2829" /></a></p><p>En este ejemplo partíamos de unos valores fijos: un contenedor de 960 pixels y dentro del mismo un elemento de 360 pixels de ancho. Si dividimos el segundo entre el primero y multiplicamos el resultado por 100 obtendremos el valor de 37,5%, que será el ancho que aplicaremos a dicho elemento. Es decir, el ancho del elemento interior será siempre el 37,5% del ancho del primero. De esta forma cuando el ancho del elemento &#8220;padre&#8221; se adapta, <strong>todos los anchos de los elementos interiores varían en función de su porcentaje</strong>. Ahora el elemento interno, en la hoja de estilos, tendrá en lugar de un width=&#8221;360px&#8221; un width=&#8221;37,5%&#8221;.</p><p>Lo mismo haremos con los <strong>tamaños de las fuentes</strong> (por ejemplo, si el tamaño general es del 100%, que equivale a 16px, y tenemos un título de 22px, su nuevo tamaño será de 22/16 = 1.375em). ¿Pero, <strong>qué pasa con las imágenes u otros elementos que tienen un ancho fijo</strong>? Podemos adaptar su ancho así:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">img<span style="color: #339933;">,</span> video<span style="color: #339933;">,</span> object <span style="color: #009900;">&#123;</span> max<span style="color: #339933;">-</span>width<span style="color: #339933;">:</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">%;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>De esta manera su ancho <strong>nunca excederá</strong> del ancho del elemento que la contiene. Y si dicho elemento cambia de ancho, también lo hará la imagen en todos los navegadores modernos. ¿He dicho modernos? Efectivamente, IE7 e IE6 no lo soportan. Para estos navegadores lo mejor es incluir en su hoja de estilos específica:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;">img<span style="color: #339933;">,</span> video<span style="color: #339933;">,</span> object <span style="color: #009900;">&#123;</span>width<span style="color: #339933;">:</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">%;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Esta regla es completamente distinta de la anterior: Ahora decimos que la imagen (por ejemplo) <strong>siempre tendrá el mismo ancho</strong> de su contenedor. Es por ello por lo que hay que tener cuidado sobre qué elemento se aplica.</p><p>Esta última opción está aplicada de manera general (no sólo para IE) en nuestra <a
href="http://www.emenia.es/trabajos/" title="Ir a la página de trabajos realizados por Emenia">página de trabajos realizados</a>. Probad a reducir el ancho de la ventana del navegador y veréis como se reduce el tamaño de cada imagen.</p><p>Esto está muy bien hasta que nos encontramos con anchos de pantalla realmente pequeños (por ejemplo un móvil). Si tenemos una web con tres columnas, montones de botones, menú horizontal a la derecha del logo, etc.. al comprimir tanto el tamaño de la pantalla, por mucho que los anchos sean fluidos, puede acabar todo en un caos. Es probable que tengamos que prescindir de ciertos elementos de la web o situarlos en un lugar diferente. Para ello utilizaremos los <strong>Media Queries</strong>.</p><h2>Segundo paso: Los Media Queries</h2><p>Como decíamos <strong>ningún diseño escala de manera adecuada cuando cambia el contexto para el que fue pensado</strong>. Los Media Queries forman parte de <strong>CSS3</strong> e inspeccionan las características físicas del medio que va a mostrar nuestro diseño (no olvidemos que <em>&#8220;query&#8221;</em> equivale a <em>&#8220;pregunta&#8221;</em>, es como preguntar: <em>¿qué medio se está usando?</em>). Si las características del medio utilizado por el usuario están dentro de un condicional establecido con los Media Queries, se aplicarán una serie de instrucciones CSS contenidas dentro del mismo, de esta manera cuando nuestro diseño fluido cambia de tamaño podremos aplicar una serie de instrucciones CSS <strong>pensadas en exclusiva para ese nuevo tamaño</strong>. Vamos a ver un ejemplo.</p><p>El ancho de pantalla actual del iPhone es de 320px. Vamos a suponer que para ese ancho nuestro diseño fluido presenta una serie de dificultades (puede ser desde cambiar el logo, eliminar una columna, cambiar la organización de los elementos de la pantalla, etc&#8230;). Dentro de nuestra hoja de estilos haríamos:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media screen and (max-width: 320px) {</span>
   <span style="color: #808080; font-style: italic;">/* Aquí van las reglas CSS necesarias */</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>Como veis la instrucción se compone de dos partes: el tipo de medio utilizado (o <a
href="http://www.w3.org/TR/CSS2/media.html">Media Type</a>, en este caso &#8220;screen&#8221;, que agrupa a todos los medios que se ven via una pantalla) combinándolo mediante un <em>&#8220;and&#8221;</em> con el Media Query (<em>max-width: 320px</em>). Estamos preguntando: ¿Es un medio con pantalla y tiene un ancho de 320px o menor? Entonces le aplicamos los estilos situados entre los corchetes correspondientes.</p><p>Podemos empezar desde este ancho e ir subiendo a otras posibles opciones. Algunos autores recomiendan optimizar estos anchos de pantalla:</p><ul><li>320px</li><li>480px</li><li>600px</li><li>768px</li><li>900px</li><li>1200px</li></ul><p>La mayor parte de las veces estos son demasiados anchos de pantalla, no hay tiempo suficiente para tanta optimización. Investiga bien cuales serán (o son si tienes ya datos históricos gracias por ejemplo a tu herramienta de analítica web) los anchos usados por tus usuarios y céntrate en ellos. Lo más habitual es, al menos, hacerlo para 480 píxeles.</p><p>También puedes, si quieres, dar una serie de reglas CSS para pantallas superiores a un ancho determinado, usando <em>min-width</em>. Por ejemplo, para anchos superiores a 1.200px:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media screen and (min-width: 1200px) {</span>
   <span style="color: #808080; font-style: italic;">/* Aquí van las reglas CSS necesarias */</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>Como veis podemos tener perfectamente separados los estilos de cada ancho de pantalla para el que queramos optimizar nuestro diseño. <strong>Si queréis incluso separar las hojas de estilo</strong> podéis también hacerlo. Por ejemplo, si queréis cargar una hoja de estilo independiente para anchos de pantalla inferiores a 480 píxeles:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> media<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;screen and (max-device-width: 480px)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;style.css&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div><p>O también:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">@</span>import url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;style.css&quot;</span><span style="color: #009900;">&#41;</span> screen and <span style="color: #009900;">&#40;</span>max<span style="color: #339933;">-</span>device<span style="color: #339933;">-</span>width<span style="color: #339933;">:</span> 480px<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Podéis ir incluso más allá gracias al uso de &#8220;and&#8221; para poner un mínimo y un máximo en los anchos de pantalla donde aplicar los estilos:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@import url(style.css) screen and (min-width:800px) and (max-width:1280px);</span></pre></td></tr></table></div><p>O detectar si es un iPhone 4 (por <a
href="http://thomasmaier.me/blog/2010/06/23/css-for-iphone-4-retina-display/" target=_blank" title="Ir al artículo de Thomas Maier">Thomais Maier</a>):</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> media<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;only screen and (-webkit-min-device-pixel-ratio: 2)&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;iphone4.css&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div><p>O incluso detectar si estamos en un iPad y su orientación (por <a
href="http://www.cloudfour.com/ipad-css/" target="_blank" title="Ir al artículo de Clodfour">Cloudfour</a>):</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> media<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;all and (orientation:portrait)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;portrait.css&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> media<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;all and (orientation:landscape)&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;landscape.css&quot;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div><h2>¿Qué navegadores soportan los Media Query?</h2><p>En general todos los navegadores modernos lo soportan. Eso quiere decir que Internet Explorer 8, 7 y 6 no lo soportan (qué raro!). Afortunadamente hay soluciones utilizando Javascript, por ejemplo <a
href="https://github.com/scottjehl/Respond" target="_blank" title ="Ir a respond.js">respond.js</a>. Tal y como podéis ver (y traduzco) <em>&#8220;respond.js proporciona un script rápido y ligero (3kb minified / 1kb gzipped) que permite utilizar diseños web adaptables en navegadores que no soportan CSS3 Media Queries &#8211; en concreto Internet Explorer 8 e inferiores&#8221;</em>.<br
/> Otra opción (que es la que uso yo normalmente) es usar <a
href="http://www.modernizr.com/" title="Ir a la web de Modernizr">Modernizr</a>.</p><h2>Meta tags</h2><p>Por último, es importante añadir un meta-tag dentro del elemento header de nuestra web que le diga al navegador que use el ancho del medio (por ejemplo, del móvil) como ancho de la web, anulando la escala inicial:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>meta name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;viewport&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div><h2>¿Puedo ver un ejemplo?</h2><p>Hay muchos diseñadores que están ya realizando nuevas versiones de sus webs utilizando media queries y diseño fluido. Creo que un buen ejemplo es el <a
href="http://css-tricks.com/13514-design-v9/" title="Ver el nuevo diseño de CSS-Tricks" target="_blank">nuevo diseño de CSS-Tricks</a>. Si cargáis la página, a medida que reducís el ancho de la ventana del navegador veréis cómo se va adaptando el diseño. Incluso ha introducido animaciones para mover elementos de sitio (como el buscador) a medida que reducimos el ancho de pantalla. Como podéis leer en el artículo, Chris Coyier explica su nuevo diseño, destacando:</p><ul><li>Su diseño por defecto es para navegadores con un ancho superior a 1200px</li><li>Hay dos optimizaciones con media query a 1024 y 860px</li><li>Utiliza <a
href="https://github.com/scottjehl/Respond" title="Ir a Respond.js" target="_blank">Respond.js</a> para hacer funcionar los Media Queries en Internet Explorer</li></ul><p>Otro gran ejemplo es <a
href="http://responsivewebdesign.com/robot/" title="Ir a Robot or Not?" target="_blank">Robot or Not?</a>, utilizado por Ettan Marcotte como ejemplo de su gran libro <a
href="http://www.abookapart.com/products/responsive-web-design" title="Ver libro Responsive Web Design" target="_blank">Responsive Web Design</a>.</p><p>Otro ejemplo, quizás menos efectista que los anteriores, es esta <a
href="http://garretkeizer.com/" title="Ir a la web de Garret Keizer" target="_blank">web sobre Garret Keizer</a>.</p><p>En <a
href="http://mediaqueri.es/" title="mediaquerie.es" target="_blank">Media Queries</a> podéis ver una colección de sitios que usan Diseño web adaptable.</p><h2>Artículos recomendados</h2><p>Os recomiendo que leais el <a
href="http://www.alistapart.com/articles/responsive-web-design/" title="_blank" title="Ver artículo en A List Apart sobre Responsive Web Design">artículo de Ethan Marcotte en A List Apart</a>. Es el que empezó a hablar del &#8220;Responsive Web Design&#8221; o Diseño Web Adaptable.</p><p>También es interesante ver Frameworks que te ayudarán a acelerar tus desarrollos o a aprender más sobre el tema investigando cómo están hechos, como el <a
href="http://stuffandnonsense.co.uk/projects/320andup/" title="Ir a la web de 320 and Up" target="_blank">320 and Up</a>. Otro conocido framework es <a
href="http://lessframework.com/" title="Less Framework 4" target="_blank">Less Framework 4</a>.</p><p><a
href="http://www.broken-links.com/2011/02/21/using-media-queries-in-the-real-world/" title="Using Media Queries in the Real World" target="_blank">Using Media Queries in the Real World</a> es también otro artículo interesante con valiosos consejos.</p><p><a
href="http://www.benjaminkeen.com/misc/bricss/">Para testear tu diseño web adaptable</a> con distintos anchos de pantalla en el mismo navegador. También te puede interesar <a
href="http://elliotjaystocks.com/blog/a-better-photoshop-grid-for-responsive-web-design/" title="Ver plantilla para diseño web adaptable">esta plantilla con ejemplo para Photoshop</a> de Elliot Jay Stocks de 1000px para diseño web adaptable.</p><p>Otro interesante artículo es el de Cloud Four, en el que <a
href="http://www.cloudfour.com/css-media-query-for-mobile-is-fools-gold/" title="Ir al artículo de Cloud Four" target="_blank">nos avisa de que los media queries no son la solución definitiva</a>, especialmente debido al problema de las imágenes y a la mayor lentitud de carga de los móbiles.</p><p>En relación a este último artículo hay que decir que <strong>el Diseño Web Adaptable no es siempre la mejor solución</strong> para llevar un sitio web al móvil. Hay que pensar siempre en el contexto en el que el usuario va a ver nuestra web y qué información va a demandar. Es probable que a través del móvil muchas veces busquemos una información distinta que la que buscamos desde el ordenador de sobremesa, por lo que no vale con servir la misma información a un tamaño diferente. Además, sitios web con más carga de imagen que de texto lo tendrán más dificil, dada la menos velocidad de descarga del móvil. Nota: Es interesante <a
href="http://adaptive-images.com/" title="Adaptative Images" target="_blank">http://adaptive-images.com/</a>, que permite servir una imagen diferente según el ancho de pantalla.</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/YYqhfH5Zte4" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/diseno-web-adaptable-o-responsive-web-design/feed/</wfw:commentRss> <slash:comments>14</slash:comments> <feedburner:origLink>http://www.emenia.es/diseno-web-adaptable-o-responsive-web-design/</feedburner:origLink></item> <item><title>Emenia gestiona las redes sociales y el blog de Smartick</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/M8jcj9FDtTI/</link> <comments>http://www.emenia.es/gestion-redes-sociales-blog-smartick/#comments</comments> <pubDate>Tue, 09 Aug 2011 18:40:18 +0000</pubDate> <dc:creator>Laura Dávila Ponce de León</dc:creator> <category><![CDATA[Noticias]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=2811</guid> <description><![CDATA[Emenia gestiona las redes sociales y el blog de Smartick, un método de aprendizaje único que a través de las matemáticas, incrementa la agilidad mental, capacidad de cálculo y fortalece la concentración y el hábito de estudio, ayudando a tu &#8230; <a
href="http://www.emenia.es/gestion-redes-sociales-blog-smartick/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Emenia gestiona las redes sociales y el blog de Smartick, un método de aprendizaje único que a través de las matemáticas, incrementa la agilidad mental, capacidad de cálculo y fortalece la concentración y el hábito de estudio, ayudando a tu hijo a alcanzar su máximo potencial.</p><p>Emenia gestiona Facebook, Twitter, You Tube y LinkedIn, además de gestionar el blog de la empresa. Esto incluye desde la creación de los perfiles, personalización de los mismos y la labor de Community Manager y estrategia de contenidos.</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/08/youtube-smartick.jpg" title="Smartick en You Tube" /></p><p>Más información sobre Smartick: <a
href="http://www.smartick.es" title="Ir a la web de Smartick">www.smartick.es</a></p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/M8jcj9FDtTI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/gestion-redes-sociales-blog-smartick/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.emenia.es/gestion-redes-sociales-blog-smartick/</feedburner:origLink></item> <item><title>Haz una auditoría SEO a tu web</title><link>http://feedproxy.google.com/~r/Emeniaes/~3/BWiWO8q6LqQ/</link> <comments>http://www.emenia.es/auditoria-seo-a-tu-web/#comments</comments> <pubDate>Tue, 19 Jul 2011 07:11:14 +0000</pubDate> <dc:creator>Juan Díaz-Bustamante</dc:creator> <category><![CDATA[Desarrollo Web]]></category> <category><![CDATA[Marketing Online]]></category> <category><![CDATA[SEO]]></category> <guid isPermaLink="false">http://www.emenia.es/?p=2694</guid> <description><![CDATA[Muchos clientes contactan con nosotros con una web ya existente con el fin de mejorar su arquitectura y optimizarla frente a buscadores como Google, identificando los errores actuales y proponiendo soluciones. Es lo que llamamos una auditoría SEO. Llaman la &#8230; <a
href="http://www.emenia.es/auditoria-seo-a-tu-web/">Continuar leyendo <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Muchos clientes contactan con nosotros con una web ya existente con el fin de mejorar su arquitectura y optimizarla frente a buscadores como Google, identificando los errores actuales y proponiendo soluciones. Es lo que llamamos <strong>una auditoría SEO</strong>. Llaman la atención muchas veces los graves defectos que vemos en algunas páginas web, donde no se han tenido en cuenta ni los mínimos criterios generalmente aceptados.</p><p>Con la finalidad de que podáis <strong>ver si vuestra web cumple al menos con las mejores prácticas desde el punto de vista <em>SEO</em></strong>, podéis seguir los pasos que os indico en este artículo y así hacer una <strong>auditoría SEO</strong> de vuestra web. Aunque lo vayamos a ver resumido (<strong>una auditoría web puede ocupar más de cincuenta hojas</strong>), vamos a ver en este artículo los puntos más importantes.</p><h3>Qué es SEO</h3><p>Antes de nada hemos de saber <strong>qué es SEO</strong>. Significa Search Engine Optimization, es decir, <strong>Optimización frente a buscadores</strong> como Google, Bing o Yahoo!  ¿Qué implica? Toda una serie de técnicas, tácticas y estrategias que tienen a la web como centro con la finalidad de situarnos en los primeros puestos cuando un usuario realiza una búsqueda relacionada con el producto, servicio o contenidos que ofrecemos en nuestra web. Si domináis el inglés os aconsejo este video en el que se nos explica la <a
href="http://www.seomoz.org/blog/the-responsibilities-of-seo-have-been-upgraded" title="Evolución de las tareas de un consultor SEO hacia estratega web" target="_blank">evolución de un consultor SEO moderno hacia la figura del &#8220;estratega web&#8221;</a>.</p><p>Una vez que tenemos esto claro vamos a ver <strong>los puntos más importantes que debe cuidar vuestra web para estar bien optimizada</strong>. Igualmente, si contratáis a un consultor SEO y no os habla de lo que veremos a continuación, mala cosa&#8230;. Empezamos, punto por punto, sin guardar un orden concreto.</p><h3>Google y Bing Webmasters tool &#038; Google Analitycs</h3><p>Si no lo estás ya da de alta tu web en <a
href="http://www.google.com/webmasters/tools/ " title="Ir a Google Webmasters tool" target="_blank">Google Webmasters tool</a>, en <a
href="http://www.bing.com/toolbox/webmaster/" title="Ir a Bing webmasters tool" target="_blank">Herramientas de Administrador Web de Bing</a> y en <a
href="http://www.google.com/intl/es/analytics/" title="Ir a Google Analitycs" target="_blank">Google Analitycs</a>. Las dos primeras te mostrarán <strong>cualquier problema grave que los buscadores vean en tu web</strong>. La segunda te mostrará <strong>el tráfico de tu web y te ayudará a analizarlo</strong>. Ten siempre presente que el tráfico a tu web no se usa para determinar rankings de búsquedas, pero te orientará sobre qué contenidos están gustando más, sobre el porcentaje de rebote de tu web (lo veremos más adelante), sobre las rutas de navegación dentro de tu web, de donde vienen los usuarios y a donde van, etc&#8230;. Un dato importante es que el valor que obtendrás de &#8220;visitantes únicos&#8221; no es un valor cierto, ya que en realidad se refiere a &#8220;navegadores únicos&#8221;. Si un usuario ha visitado con 5 navegadores distintos tu web, contará como cinco. Además cada vez que borre las cookies será un visitante nuevo.</p><h3>Diseño apropiado</h3><p><strong>¿Es el diseño apropiado para el producto o servicio que se ofrece y para el cliente objetivo que va a usar la web?</strong> Quizas sorprenda que comience con algo tan genérico y subjetivo como el diseño de la página, pero realmente el diseño importa. Hacer SEO es cada vez más hacer &#8220;estrategia web&#8221;, y una buena base de partida es que la impresión general de confianza, de comodidad, de satisfacción que siente el usuario al instante de cargar una web sea buena. ¿Cual es el <strong>porcentaje de rebote</strong> de tu página de inicio, o de la web en general? Si no tienes un blog (donde el porcentaje de rebote suele ser muy alto) un porcentaje de rebote alto indica problemas (el porcentaje de rebote indica el % de usuarios que sólo ve una página de tu web y se va sin ver una segunda página). En definitiva, diseño limpio, centrado en el usuario, con un sistema de navegación coherente, que no haga pensar, accesible a todos los navegadores y sistemas (ordenadores, móviles, tabletas&#8230;).</p><h3>Estudio de Palabras clave</h3><p>Si no lo has hecho aún todavía estás a tiempo: <strong>analiza cuales son las palabras clave por las que vas a competir en buscadores</strong> (con herramientas como <a
href="https://adwords.google.com/select/KeywordToolExternal" title="Ir a Google keywords tool" target="_blank">Google keywords tool</a>, <a
href="http://www.google.com/insights/search/" title="Ir a Google Insights" target="_blank">Google Insights</a> y <a
href="http://www.google.com/trends" title="Ir a Google Trends" target="_blank">Google Trends</a>. También Google Analitycs te dirá que palabras clave están usando ya tus usuarios para encontrarte). Podrás ver qué está buscando la gente en buscadores y te ayudará a optimizar los contenidos de tu página.</p><p><strong>Cada palabra clave importante debería tener su página propia dentro de tu web</strong>, optimizada para dicha palabra o frase tal y como veremos más adelante. Si tienes un blog deberías tenerlo en cuenta para cada artículo. Intenta evitar lo que se llama <strong>canibalización</strong>, es decir, cuando dos o más páginas de tu web están centradas en la misma palabra clave.</p><p>No tengas en cuenta sólo la popularidad de una palabra, ten en cuenta también <strong>cual es la competencia por la misma</strong>. Hay herramientas de pago que te permiten verlo. También analizando la autoridad de los que están en las primeras posiciones te puedes hacer una idea. La barrita de competencia que trae Google keywords, aunque se refiere a competencia en los anuncios pagados, te puede dar también una idea.</p><p>También ten en cuenta la <strong>tendencia</strong> en su uso y su <strong>estacionalidad</strong>. Google Insights y Google Trends te puede ayudar.</p><p><strong>No llenes el texto de la página con la palabra clave</strong>, ya que el efecto que conseguirás será el contrario del deseado. Escribe para el usuario, no para los buscadores. Como nos dice SEOmoz &#8220;2-3X en páginas cortas, 4-6X en páginas largas y nunca más de lo que tendría sentido en el contexto del contenido&#8221;. Utiliza además variaciones de la palabra. Al menos una de las veces pon la palabra clave en negrita, en itálica o ambas.</p><h3>Javascript y Flash</h3><p><strong>Los buscadores tienen más problemas a la hora de interpretar Javascript y Flash</strong> que a la hora de interpretar simple HTML. Intenta no utilizar ninguno de los dos (especialmente Flash por los problemas de accesibilidad que puede presentar, ya que no lo soportan el iPhone ni el iPad) a la hora de mostrar <strong>contenidos importantes</strong> de tu web.</p><h3>Jerarquía de la información</h3><p>La imagen que veis a continuación, <a
href="http://www.seomoz.org/blog/perfecting-keyword-targeting-on-page-optimization" title="Ir al artículo de SEOmoz" target="_blank">de Rand Fishkin de SEOmoz</a>, es muy conocida y muestra <strong>la mejor manera de optimizar una URL con una palabra clave o frase</strong>. La palabra clave está presente en todos los elementos SEO de la página, siempre sin sobreusarla. Cada página de nuestra web debería estar optimizada para una palabra clave determinada.</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/pagina-optimizada-seo.jpg" alt="Página optimizada SEO para una palabra clave" title="pagina-optimizada-seo" width="439" height="790" class="size-full wp-image-2703" /></p><h3>Arquitectura de la web</h3><p>Es muy importante que nuestra web esté <strong>bien estructurada</strong>, que el usuario pueda acceder de una forma ordenada a cada área de la web, <strong>que no hayamos creado islas</strong> donde nadie pueda acceder. Normalmente es la página de inicio la que recibe la mayor cantidad de enlaces externos. Tenemos que lograr que el valor de esos enlaces se distribuya de forma armónica por toda la web. Una estructura ordenada puede ser esta:</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/arquitectura-optima.gif" alt="arquitectura web óptima" title="arquitectura-optima" width="500" height="240" class="alignnone size-full wp-image-2698" /></p><p>Como veis en el ejemplo, de la página de inicio salen enlaces a las categorías principales de la web. Estos enlaces están normalmente en el menú de la página, menú que se repite en todas las páginas de la web (ni que decir tiene que el menú tiene que ser el mismo y estar en el mismo sitio en toda la web). En una web pequeña, donde no haya categorías, la página de inicio enlazará directamente con cada página. Las páginas de cada categoría, si están bien optimizadas, suelen funcionar muy bien desde el punto de vista SEO.</p><p><strong>La profundidad a la que llegarán los buscadores en nuestra web dependerá de la popularidad del dominio dado</strong> (popularidad medida en función del número de enlaces y de la calidad de los mismos). Podéis pensar en un ejemplo sencillo: si pensamos en nuestra web como una serie de galerías conectadas que hay que rellenar de agua, dependiendo el volúmen de agua que tenemos de la popularidad que tenga nuestra web, quizás no nos de el agua para rellenar todas las galerías (se pueden quedar páginas sin indexar o a las que no llegue nada del valor de los enlaces que aporta la página de inicio). Es por eso por lo que deberíais pensar también si tenéis <strong>páginas con contenidos poco o nada relevantes que puedan ser eliminadas</strong>, así como en cómo vais a crear la estructura de enlaces (pensad siempre en la cantidad de &#8220;agua&#8221; que puede pasar una página a las demás que tiene enlazadas). También es importante que <strong>desde la página de inicio haya enlaces a las páginas más importantes</strong>, a los que tienen los términos que más nos interesan (por ejemplo los productos más destacados de nuestro catálogo), pero no te pases poniendo enlaces, especialmente si la &#8220;popularidad&#8221; de tu página es baja (puedes usar <a
href="http://www.seomoz.org/seo-toolbar" title="Ir a SEOmoz">la barra de SEOmoz</a>, que te mide la popularidad del dominio y de cada página).</p><p>Cuando hagáis enlaces en los contenidos (al estilo Wikipedia) tened en cuenta que <a
href="http://www.seomoz.org/blog/results-of-google-experimentation-only-the-first-anchor-text-counts" title="Google sólo cuenta el texto del primer enlace" target="_blank">Google sólo tiene en cuenta el texto del primer enlace que se encuentre</a> cuando haya varios que van a la misma URL, por lo que es importante que este sea el que tiene el mejor texto para enlazar.</p><p>Por último, asegúrate de que <strong>todas tus páginas han sido indexadas por los buscadores</strong>. Si no es así analiza las causas.</p><h3>Canonicalización y contenido duplicado</h3><p>Por canonicalización entendemos <strong>evitar que se pueda acceder a una página web con URLs diferentes</strong>. Imaginaros que vuestra web es www.ejemplo.es y que os dais cuenta de que podéis acceder de todas estas maneras:</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/canonalizacion.gif" alt="ejemplos de canonalización en la web" title="canonalizacion" width="300" height="145" class="alignnone size-full wp-image-2696" /></p><p>El problema que se plantea es que podemos estar recibiendo enlaces destinados a una misma página web divididos en varias URLs diferentes, con lo que <strong>la popularidad de la página se divide</strong> a su vez. <strong>Hay que intentar consolidar la popularidad que nos dan los enlaces en una sola URL</strong>. Para solucionarlo redirige usando una <strong>redirección 301</strong> con .htaccess o con PHP a la opción que tenga ya más enlaces. Según algunos estudios con una redirección 301 pierdes entre el uno y el diez por ciento del valor del enlace. ¡Lo malo es que con una redirección 302 lo pierdes todo!. Vamos a ver cómo hacerlo:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Redireccionar un solo fichero o directorio a un dominio diferente</span>
Redirect <span style="color: #cc66cc;">301</span> <span style="color: #339933;">/</span>pagina<span style="color: #339933;">-</span>antigua<span style="color: #339933;">.</span>html  http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.dominio-nuevo/nueva-pagina.html</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Redireccionar http://ejemplo.es a http://www.ejemplo.es en todo el dominio</span>
RewriteEngine on
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_HOST<span style="color: #009900;">&#125;</span>
^ejemplo\<span style="color: #339933;">.</span>es <span style="color: #009900;">&#91;</span>NC<span style="color: #009900;">&#93;</span>
RewriteRule <span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.ejemplo.es/$1 [L,R=301]</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Redirigir el dominio entero a un nuevo dominio</span>
Redirect <span style="color: #cc66cc;">301</span> <span style="color: #339933;">/</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.nuevodominio.es/</span></pre></td></tr></table></div><p><strong>Otro problema que podéis tener es el del contenido duplicado</strong>. Imaginaros que tenéis una tienda online en la que vendéis un tipo de producto determinado. El usuario puede ordenar el producto en función de su precio, de su nombre, de su color, etc&#8230; Eso es perfecto para el usuario, pero lo malo es que <strong>vamos a tener una serie de URLs diferentes para mostrar el mismo contenido</strong>. Para solucionarlo tienes la etiqueta <strong>rel=&#8221;canonical&#8221;</strong>, para decirle a los buscadores cual de las URLs es la que vale. Cuando para solucionar contenido duplicado el redireccionamiento 301 no sea una solución factible, hay que usar rel=&#8221;canonical&#8221;. Hay que ubicarlo dentro de la sección <em>head</em> del código html de la página web. Por ejemplo, si tenemos una página que se llama ejemplo.es/articulo.php y otra ejemplo.es/articulo.php?p=2 y muestran exactamente lo mismo (aunque esté en otro orden, o sea una página para imprimir, etc..) habría que poner <strong>en las dos páginas</strong>:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">....</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;canonical&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.ejemplo.es/articulo.php&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">...</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span></pre></td></tr></table></div><h3>URL de la página</h3><p>En primer lugar las URLs de tu web deberían tener lo que se denomina <strong>&#8220;URLs amigables&#8221;</strong>. Podéis ver en este artículo <a
href="http://www.emenia.es/como-crear-urls-amigables-con-htaccess/" title="Cómo crar URLs amigables con un archivo .htaccess" target="_blank">cómo crear URLs amigables con un archivo .htaccess</a>.</p><p>Una vez tengas URLs amigables, la palabra clave para la que está optimizada cada página de tu web debería estar en la URL, cuidando siempre que la URL no sea muy larga (de hecho, cuanto más corta, mejor). Algunos ejemplos:</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/urls.gif" alt="URLs amigables, ejemplos" title="urls" width="439" height="133" class="alignnone size-full wp-image-2710" /></p><p>Por regla general es siempre <strong>mejor usar carpetas que subdominios</strong>, es decir, siempre mejor ejemplo.es/blog que blog.ejemplo.es</p><h3>Título de la página</h3><p>En estos momentos, y según diversos estudios, <strong>el título de una página web es el factor SEO individual más importante</strong> de dicha página. Es fundamental que cada página tenga su propio título. Dependiendo de si lo realmente importante en tu caso es tu marca o cada palabra clave de las diferentes páginas, lo más recomendado es la siguiente estructura:</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/titulo.gif" alt="Estructura recomendada para el título de una página web" title="titulo" width="439" height="91" class="alignnone size-full wp-image-2711" /></p><p>Si hacéis click con el botón derecho del ratón sobre la web y seleccionáis &#8220;Ver código fuente&#8221; deberíais ver en las primeras líneas el título de la página web entre las etiquetas <strong>title</strong>. Por ejemplo, para este artículo es:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Haz una auditoría SEO a tu web <span style="color: #339933;">|</span> emenia<span style="color: #339933;">.</span>es<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span></pre></td></tr></table></div><p>El título es además muy importante <strong>al ser utilizado por los buscadores y en las redes sociales como enlace a la página</strong>, por lo que debe estar lo suficientemente bien pensado como para favorecer que la gente haga click. Intenta que no tenga más de 60 caracteres para que no salga cortado en los resultados de las búsquedas.</p><h3>Meta descripción</h3><p>Al ver el código de nuestra página web veremos la meta descripción cerca del título. Un ejemplo de una descripción de un artículo de este blog:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>meta name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;description&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Artículos sobre desarrollo web para diseñadores y creadores de páginas web así como artículos sobre marketing online, redes sociales, comercio electrónico.&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div><p><strong>Cada página de tu web tiene que tener su propia meta-descripción</strong>. Puedes pensar en las meta descripciones como publicidad gratuita que aparece en los buscadores cuando estos muestran tu página. En muchas ocasiones el texto que aparece debajo del enlace en el resultado de una búsqueda es el texto de la meta-descripción (cuando las palabras usadas en la búsqueda se encuentren en la meta descripción):</p><p><img
src="http://www.emenia.es/wp-content/uploads/2011/07/meta-descripcion.gif" alt="Meta descripción utilizada por Google en el resultado de una búsqueda" title="meta-descripcion" width="532" height="150" class="alignnone size-full wp-image-2718" /></p><p>Las meta descripciones no son usadas directamente por los buscadores para establecer rankings, por lo que <strong>son más válidas como medio de atraer gente a tu página</strong>. Piensa pues en el usuario cuando la estés redactando. Son un lugar perfecto para incluir tus palabras claves de forma apropiada (saldrán en negrita cuando coincidan en el resultado de una búsqueda). Es importante que la descripción no supere los 160 caracteres para que no salga truncada en los resultados de búsqueda.</p><h3>Meta keywords</h3><p>Incluyo aquí este apartado para desmitificar el uso de esta meta etiqueta. Actualmente la meta keywords ya no se toma en cuenta por los buscadores y sólo sirve para que le muestres a tu competencia cuales son tus palabras clave. <strong>Hay muchos autores que incluso aconsejan no utilizarla</strong>.</p><h3>Titulares html (h1 a h6)</h3><p><strong>Los titulares han dejado de ser factores importantes para los buscadores</strong>. Recientes estudios de SEOmoz han mostrado que hay muy baja correlación de la etiqueta h1 y los rankings en los resultados de las búsquedas (cercana a cero). <strong>Con tener las palabras clave en las primeras 30 o 40 palabras de la página web, vale</strong>. Eso no impide que se recomiende el uso adecuado de los titulares dentro de cada página para lograr una mejor jerarquía de la información.</p><h3>Imágenes</h3><p>Es importante que cada imagen que uses en cada página web <strong>tengan su etiqueta <em>alt</em> propia</strong> donde escribas su descripción, utilizando la palabra clave correspondiente. También es recomendable utilizar texto relevante antes o después de la imagen, así como un pie de foto, para poner más en contexto la imagen. Según estudios de correlación de SEOmoz las descripciones en <strong>las etiquetas alt de las imágenes es un factor importante en los rankings de los resultados de búsqueda</strong>. Intenta también <strong>usar la palabra clave en el nombre del archivo de la imagen</strong> (en vez de usar por ejemplo imagen1.jpg). También es fundamental que <strong>si tienes textos importantes estos no formen parte de una imagen</strong>, sino que sea texto suelto, independiente de la imagen sobre la que pueda estar ubicado. Ten en cuenta que los buscadores no pueden leer el texto que hayas puesto en una imagen.</p><h3>Archivos robots.txt y sitemap.xml</h3><ul><li><strong>El archivo robots.txt</strong> está situado en el directorio raiz de tu web y se utiliza para decirle a los buscadores a qué directorios y archivos no deben acceder. Podéis ver por ejemplo la <a
href="http://perishablepress.com/wordpress-robots-rules/" title="Archivo robots.txt en WordPress" target="_blank">recomendación de Jeff Star para el archivo robots.txt en WordPress</a>.</li><li><strong>El archivo sitemap.xml</strong> indica a los buscadores las URLs que componen tu página web, aparte de ofrecer información sobre su importancia relativa, su frecuencia de actualización, etc.. Para WordPress <a
href="http://wordpress.org/extend/plugins/google-sitemap-generator/" title="XML Sitemap generator para WordPress" target="_blank">hay plugins para crear sitemap de manera dinámica</a>. También hay aplicaciones online que os lo crean como <a
href="http://www.xml-sitemaps.com/" title="Crear un sitemap online" target="_blank">XML-Sitemaps.com</a></li></ul><p>Como norma general ten cuidado de que el archivo robots.txt no esté impidiendo el acceso a páginas que sí deberían ser accesibles por los buscadores. Si se puede <strong>es preferible usar la etiqueta meta robots (noindex, follow)</strong> porque mantiene la URL fuera de los resultados (noindex) pero permite a todos los enlaces de la página enviar el valor del enlace (follow).</p><p>Si puedes crear <strong>varios sitemaps</strong> (uno de imágenes y otro de vídeos si los tuvieras) mejor. Un sitemap no ayuda en los rankings pero sí a que los buscadores conozcan mejor y más rápido cual es la estructura de tu web. Si tienes páginas de tu web sin indexar quizás te pueda ayudar.</p><h3>Velocidad de carga de la página</h3><p>La velocidad de carga de tu web es <strong>un parámetro más que usa Google para realizar los rankings en las búsquedas</strong>. Hay autores que dicen que a no ser que la velocidad sea muy lenta no afecta. De todas formas es mejor que optimices tu página web todo lo que puedas. Lo mejor es que utilices una herramienta como <a
href="https://addons.mozilla.org/en-US/firefox/addon/yslow/" title="YSlow para Firefox">YSlow</a> de Yahoo! o <a
href="http://pagespeed.googlelabs.com/" title="Ir a Pagespeed">Pagespeed de Google</a> y sigas sus indicaciones.</p><h3>Uso de microdata: Schema.org</h3><p>Si no tienes etiquetadas áreas de contenido importante en tu web es el momento de hacerlo. Puedes ver en este mismo blog este artículo sobre <a
href="http://www.emenia.es/optimiza-posicionamiento-buscadores-pagina-web-con-microformatos-schema/" title="Ir a artículo sobre Schema.org">el uso de Schema.org</a></p><h3>Apuntes finales</h3><p>La labor del SEO está cambiando muy rápidamente, sobre todo desde la nuevas actualizaciones de Google (Google Panda) orientadas a dar más relevancia a webs cuyos contenidos sean más &#8220;populares&#8221;. Os recomiendo que veais <a
href="http://www.seomoz.org/blog/how-googles-panda-update-changed-seo-best-practices-forever-whiteboard-friday">este vídeo de SEOmoz</a> (está en inglés, pero tenéis la transcripción debajo que podéis traducir). Veréis los cambios que suponen Google Panda y os dará pistas para posicionar mejor vuestra web.</p><p>Espero que este artículo os haya sido útil. Cualquier comentario sobre el mismo, ampliación, corrección que podáis aportar será bienvenido!!</p> <img src="http://feeds.feedburner.com/~r/Emeniaes/~4/BWiWO8q6LqQ" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.emenia.es/auditoria-seo-a-tu-web/feed/</wfw:commentRss> <slash:comments>8</slash:comments> <feedburner:origLink>http://www.emenia.es/auditoria-seo-a-tu-web/</feedburner:origLink></item> </channel> </rss><!-- Dynamic page generated in 9.603 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-02 04:56:45 --><!-- Compression = gzip -->

