<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Referência própria do wordpress</title>
	<atom:link href="http://meucodex.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://meucodex.wordpress.com</link>
	<description>SWX Sistemas ( swx.com.br ) - Vinicius AC</description>
	<lastBuildDate>Wed, 21 Dec 2011 20:05:42 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='meucodex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/af81d710804ba9ab594231e694e5eb8e?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Referência própria do wordpress</title>
		<link>http://meucodex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://meucodex.wordpress.com/osd.xml" title="Referência própria do wordpress" />
	<atom:link rel='hub' href='http://meucodex.wordpress.com/?pushpress=hub'/>
		<item>
		<title>add_action add_filter</title>
		<link>http://meucodex.wordpress.com/2011/12/21/add_action-add_filter/</link>
		<comments>http://meucodex.wordpress.com/2011/12/21/add_action-add_filter/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 20:04:24 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[API Wordpress]]></category>
		<category><![CDATA[add_action add_filter hooks]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=182</guid>
		<description><![CDATA[Hooks: Actions e Filters Classes e Funções usadas: actions, add_action, add_filter, filters, hooks, the_content Categoria: Codex &#124; Nenhum comentário Um importante recurso a ser explorado para o desenvolvimento de soluções no WordPress é a utilização dosHooks que o sistema disponibiliza. Os Hooks são certas funções e identificadores que servem como ganchos (dada sua nomenclatura) para execução de instruções personalizadas. Significa dizer que através do uso dos hooks é [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=182&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Hooks: Actions e Filters</h1>
<p>Classes e Funções usadas: <a href="http://www.guiawp.com.br/ref/actions/" rel="tag">actions</a>, <a href="http://www.guiawp.com.br/ref/add_action/" rel="tag">add_action</a>, <a href="http://www.guiawp.com.br/ref/add_filter/" rel="tag">add_filter</a>, <a href="http://www.guiawp.com.br/ref/filters/" rel="tag">filters</a>, <a href="http://www.guiawp.com.br/ref/hooks/" rel="tag">hooks</a>, <a href="http://www.guiawp.com.br/ref/the_content/" rel="tag">the_content</a></p>
<p>Categoria: <a title="Ver todos os posts em Codex" href="http://www.guiawp.com.br/codex/" rel="category tag">Codex</a> | Nenhum comentário</p>
<p>Um importante recurso a ser explorado para o desenvolvimento de soluções no <a href="http://www.guiawp.com.br/">WordPress</a> é a utilização dos<strong>Hooks</strong> que o sistema disponibiliza. Os <strong>Hooks</strong> são certas funções e identificadores que servem como ganchos (dada sua nomenclatura) para execução de instruções personalizadas. Significa dizer que através do uso dos hooks é possível informar ao sistema quando e como ele deve chamar determinada função.</p>
<p>Existem dois tipos de ganchos oferecidos pelo WordPress: <strong>Actions</strong> e <strong>Filters</strong>. As <strong>Actions</strong>, são ações executadas em determinados momentos pelo sistema; são atividades executadas mediante o disparar de um evento, como por exemplo o publicar de um post.</p>
<p>Os <strong>Filters</strong>, são os filtros da informação; através de suas aplicações o desenvolvedor consegue modificar ou como o próprio nome diz, filtrar os dados enviados pelo usuário ou resgatados do banco de dados antes que estes sejam exibidos ou armazenados.</p>
<h2>Motivos para utilização dos Hooks</h2>
<p>Em alguns casos quando se faz necessário alterar o modo de funcionamento do <strong>WordPress</strong>, é comum desenvolvedores realizarem tais alterações diretamente no código-fonte do CMS. No entanto essa prática é pouco recomendada, pois assim que o sistema for atualizado é bem provável que as alterações se percam e tenham que ser realizadas novamente. Usar os ganchos do WordPress é um jeito seguro de alterar o comportamento e as atividades executadas pela ferramenta.</p>
<p>A própria programação do sistema é realizada em grande parte com base nos Hooks. Veja por exemplo a utilização das <a title="Include Tags do WordPress" href="http://www.guiawp.com.br/codex/include-tags-wordpress/">Include Tags</a> que se baseiam nesse princípio, assim como a incorporação de <a title="Trabalhar com JavaScript no WordPress" href="http://www.guiawp.com.br/codex/javascript-wordpress/">scripts ao WordPress</a> que ocorre em razão do uso de ganchos.</p>
<h2>Actions – Eventos do WordPress</h2>
<p>Para adicionar ações ao WordPress é preciso fazer uso da função <strong>add_action</strong> via programação PHP com os seguintes parâmetros:</p>
<pre>add_action ( 'nome_do_gancho', 'sua_funcao', [prioridade], [argumentos_aceitos] );</pre>
<ul>
<li><strong>Nome do gancho</strong> – Um evento fornecido pelo sistema (veja a <a href="http://codex.wordpress.org/Plugin_API/Action_Reference">Referência de ações</a> no Codex), a ele será incorporada sua função;</li>
<li><strong>Sua função</strong> – Ao disparar do referido evento, a função aqui atribuída será executada;</li>
<li><strong>Prioridade</strong> – Determina a ordem de execução das funções associadas ao gancho, por padrão seu valor é 10. Números menores são executados primeiro, e em caso de valores iguais respeita-se a ordem de adição das funções;</li>
<li><strong>Argumentos aceitos</strong> – Número inteiro que determina a quantidade de argumentos a serem passados para a função, possui valor 1 como padrão.</li>
</ul>
<h3>Estilo personalizado para a tela de login</h3>
<p>Em um exemplo de aplicação, é possível editar a tela de login do seu template incorporando uma folha de estilo específica na página de entrada do sistema mediante o uso de:</p>
<pre>function add_login_style() {
	wp_enqueue_style( 'login' );
}
add_action( 'login_head', 'add_login_style' );</pre>
<p>Os parâmetros <em>Prioridade</em> e <em>Argumentos aceitos</em> são opcionais, caso não os informe, os valores padrões serão adotados para a ação criada.</p>
<h2>Filters – Filtrando informação</h2>
<p>De maneira semelhante a incorporação de ações ao sistema, para se incluir um filtro a ele é preciso fazer uso da função <strong>add_filter</strong> e seus respectivos parâmetros:</p>
<pre>add_filter ( 'nome_do_gancho', 'sua_funcao', [prioridade], [argumentos_aceitos] );</pre>
<p>Uma grande diferença na função a ser utilizada é que ela deverá possuir um valor de retorno ou de impressão usando os recursos <strong>return</strong> ou <strong>echo</strong> do PHP, por exemplo. Assim como para as <strong>Actions</strong>, os valores <em>Prioridade</em> e<em>Argumentos aceitos</em> da função que adiciona os <strong>Filters</strong>, são opcionais.</p>
<h3>Alterando a exibição do conteúdo</h3>
<p>Para demonstrar a utilização dos filtros, o exemplo abaixo irá suprimir todas as tags HTML do conteúdo dos posts resgatados antes de exibí-los para o visitante:</p>
<pre>function content_only_text( $content ) {
	return strip_tags( $content );
}
add_filter( 'the_content', 'content_only_text' );

<strong>Fonte: <a href="http://www.guiawp.com.br/codex/hooks-actions-filters/">http://www.guiawp.com.br/codex/hooks-actions-filters/</a></strong></pre>
<h1>=================================================</h1>
<h1>=================================================</h1>
<h1>=================================================</h1>
<h1>Michael Fields</h1>
<pre>Hi Betsy, I hope this explains everything!</pre>
<blockquote><p>So, are filters a subset of actions?</p></blockquote>
<p>They are basically the same function applied to different contexts. If you take a peek into the core, you will see that add_action is actually a wrapper function for add_filter:</p>
<pre><code>function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return add_filter($tag, $function_to_add, $priority, $accepted_args); }</code></pre>
<blockquote><p>it seems I could use an action to change the text of the post for instance, instead of a filter?</p></blockquote>
<p>Actually, you would use a filter for this situation. Let&#8217;s pretend that WordPress is a Mexican restaurant and we have ordered a taco as illustrated by the following code&#8230;</p>
<p><code>&lt;?php $taco = 'chicken'; ?&gt;</code></p>
<p>Basically, we have no choice&#8230; we will always be served a <em>chicken taco</em>. However, the same expression could be stated using the <a href="http://codex.wordpress.org/Function_Reference/apply_filters">apply_filters()</a> function. It is like ordering a taco and having the server ask you <em>&#8220;well what kind of taco would you like?&#8221;</em></p>
<pre><code>&lt;?php $taco = apply_filters( 'get_taco', 'chicken' ); ?&gt;</code></pre>
<p>The above code gives us access to the type of taco that we would like to have served. We can create a function which hooks into WordPress an changes the default value of<code>$taco</code>.</p>
<pre><code>&lt;?php add_filter( 'get_taco', 'my_special_order' ); function my_special_order( $content ) { return 'shredded beef'; } ?&gt;</code></pre>
<p>By adding the above code to you theme&#8217;s functions.php file or to a custom plugin, you are able to change the value of the variable <code>$taco</code> to whatever you like. Notice that the function <em>&#8220;my_special_order&#8221;</em> accepts one value. In this situation the value of<code>$content</code> is equal to the value of the second argument passed to the apply_filters() function. In this example it would be &#8220;chicken&#8221;.</p>
<pre><code>&lt;?php add_filter( 'get_taco', 'my_special_order' ); function my_special_order( $content ) { return $content . ' and avocado'; } ?&gt;</code></pre>
<p>The above code appends a string to the end of &#8220;chicken&#8221; resulting in a value of &#8220;chicken and avocado&#8221;.</p>
<blockquote><p>what would be a good example of correctly using filters while actions would be inappropriate for the situation?</p></blockquote>
<p>Basically, there usually is no choice for a plugin or theme developer as to which method they can use. The WordPress core is filled with calls to <a href="http://codex.wordpress.org/Function_Reference/apply_filters">apply_filters()</a> and<a href="http://codex.wordpress.org/Function_Reference/do_action">do_action()</a>. If I need to change the value of a piece of data, I will search through the core until I locate the file where that data is defined and see if it is possible to filter it&#8217;s value.</p>
<p>If I need to <em>do something</em> at a certain time, I will look for calls to the do_action() hook. A simple example would be if I wanted to print custom css to the head of the document. I could easily add the following code to my theme&#8217;s functions.php file:</p>
<pre><code>&lt;?php add_action( 'wp_head', 'print_my_custom_scripts' ); function print_my_custom_scripts(){ print '&lt;style type="text/css"&gt;.red{color:#f00;}&lt;/style&gt;'; } ?&gt;</code></pre>
<p>Notice how this time, the function did not return a value &#8211; it <em>did something</em> -&gt; it printed text to the browser.</p>
<p>Filters change data while actions allow us to do stuff.</p>
<blockquote><p>when should I use an action and when a filter?</p></blockquote>
<p>You would want to use an action where you need to do something at a certain point in time&#8230; add options to the database or print css or javascript.</p>
<p>You should use a filter where you would want to alter the value of some data that WordPress has passed through the apply_filters() function.</p>
<blockquote><p>do the &#8216;hooks&#8217; for actions and filters overlap? -can I add a either a filter or an action to the same hook?</p></blockquote>
<p>Actually, both filters and actions <em>are</em> hooks. That being said, the answer is &#8220;no&#8221;.</p>
<p style="padding-left:30px;text-align:right;"><a href="http://wordpress.org/support/topic/fliters-vs-actions-from-a-newbe">http://wordpress.org/support/topic/fliters-vs-actions-from-a-newbe</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/182/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=182&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2011/12/21/add_action-add_filter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>Formato em português da hora e data no WordPress</title>
		<link>http://meucodex.wordpress.com/2011/11/17/formato-em-portugues-da-hora-e-data-no-wordpress/</link>
		<comments>http://meucodex.wordpress.com/2011/11/17/formato-em-portugues-da-hora-e-data-no-wordpress/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 13:38:58 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[API Wordpress]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[hora]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=175</guid>
		<description><![CDATA[Tutorial do formato em português da hora e data no WordPress Sem muita enrolação vou explicar nesse tutorial quais são os formatos de hora aceitos no WordPress que segue o padrão do PHP e dar alguns exemplos para facilitar a vida das pessoas que, como eu, se enrolaram todas para conseguir informação tão simples. Data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=175&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Tutorial do formato em português da hora e data no WordPress</h1>
<div id="HOTWordsTxt">
<p>Sem muita enrolação vou explicar nesse tutorial quais são os formatos de hora aceitos no WordPress que segue o padrão do PHP e dar alguns exemplos para facilitar a vida das pessoas que, como eu, se enrolaram todas para conseguir informação tão simples.</p>
<p><strong>Data</strong><br />
d – Dia do mês, 2 dígitos com zero<br />
D – Apresentação em texto do dia com três letras<br />
j – Dia do mês sem zero<br />
l (letra L minúscula) – Apresentação por extenso do dia da semanarepresentation<br />
F – Apresentação por extenso do dia do mês<br />
m – Apresentação numérica do mês, com zero<br />
M – Apresentação abreviada do mês com três letras<br />
n – Apresentação numérica do mês, sem zero<br />
Y – Apresentação completa do ano, com quatro dígitos<br />
y – Apresentação curta do ano, com dois dígitos</p>
<p><strong>Hora</strong><br />
a – Mostra am/pm em letras minúsculas<br />
A – Mostra AM/PM em letras maiúsculas<br />
g – Formato 12 horas sem zeros<br />
G – Formato 24 horas sem zeros<br />
h – Formato 12 horas com zeros<br />
H – Formato 24 horas com zeros<br />
i – Minutos com zeros<br />
s – Segundos com zeros</p>
<p>Para alterar a forma como a data e hora são exibidas no seu blog, no menu da administração, clique em <em><strong>“Opções”</strong></em>, depois em <em><strong>“Geral”</strong></em>.</p>
<p>Procure uma caixa chamada <em><strong>“Formato de hora predefinido”</strong></em> e coloque sua formatação, conforme seu gosto.</p>
<p>Após clique no botão <em><strong>“Atualizar Opções”</strong></em> no final da página.</p>
<p>Bom, no meu caso essa explicação não funcionou!</p>
<p>Tive que alterar diretamente nos arquivos <strong>archive.php</strong>, <strong>index.php</strong> e <strong>single.php</strong>.</p>
<p>Localizei a linha com o codigo abaixo:</p>
<blockquote><p><strong>&lt;”?php the_time(…”&gt;</strong></p></blockquote>
<p>dependendo do layout, o código pode variar e substituí por este:</p>
<blockquote><p><strong>&lt;?php the_time(__(‘j \d\e F \d\e Y’, ‘kubrick’)) ?&gt;</strong></p></blockquote>
<p>deixando o formato assim: <strong>20 de abril de 2009</strong>.</p>
<p><strong>Alguns exemplos de data:</strong><br />
D d M Y – esta formação resulta em: Dom 18 Nov 2007<br />
l d F Y – esta formação resulta em: Domingo 18 Novembro 2007<br />
j \d\e F \d\e Y – esta formatação resulta em: 18 de Novembro de 2007<br />
d/m/Y – esta formação resulta em: 18/11/2007<br />
d-m-Y – esta formação resulta em: 18-11-2007</p>
<p><strong>Alguns exemplos de hora:</strong><br />
g:i a – esta formação resulta em: 8:30 am<br />
h:i a – esta formação resulta em: 08:30 am<br />
g-i A – esta formação resulta em: 8-30 AM</p>
<p>Créditos: <a href="http://radbox.info/" rel="nofollow" target="_blank">radboxdocs</a></p>
</div>
<p>Publicado em <strong>20 de abril de 2009. </strong>Autor do artigo: <strong>Denis F. Moreia</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=175&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2011/11/17/formato-em-portugues-da-hora-e-data-no-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>Personalizar Dashboard Widgets</title>
		<link>http://meucodex.wordpress.com/2011/08/01/personalizar-dashboard-widgets/</link>
		<comments>http://meucodex.wordpress.com/2011/08/01/personalizar-dashboard-widgets/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 23:52:20 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[Área Administrativa]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Dashboard]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=170</guid>
		<description><![CDATA[Para customizar a página inicial do Painel, chamada de Dashboard Widgets, use o seguinte: // disable default dashboard widgets function disable_default_dashboard_widgets() { remove_meta_box(&#8216;dashboard_right_now&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_recent_comments&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_incoming_links&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_plugins&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_quick_press&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_recent_drafts&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_primary&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); remove_meta_box(&#8216;dashboard_secondary&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;); } add_action(&#8216;admin_menu&#8217;, &#8216;disable_default_dashboard_widgets&#8217;); Do jeito que está acima, a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=170&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Para customizar a página inicial do Painel, chamada de Dashboard Widgets,<br />
use o seguinte:</p>
<blockquote><p>// disable default dashboard widgets<br />
function disable_default_dashboard_widgets() {</p>
<p>remove_meta_box(&#8216;dashboard_right_now&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_recent_comments&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_incoming_links&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_plugins&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);</p>
<p>remove_meta_box(&#8216;dashboard_quick_press&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_recent_drafts&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_primary&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);<br />
remove_meta_box(&#8216;dashboard_secondary&#8217;, &#8216;dashboard&#8217;, &#8216;core&#8217;);</p>
<div id="qhide_557286">}</div>
<p>add_action(&#8216;admin_menu&#8217;, &#8216;disable_default_dashboard_widgets&#8217;);</p></blockquote>
<p>Do jeito que está acima, a ação ocorrerá para TODOS os usuários. Se quiser<br />
customizar para um grupo de usuários específico ou para um usuário em<br />
específico, use a função abaixo como base&#8230;. Sendo que &#8220;manage_options&#8221; é<br />
uma função administrativa&#8230; Depois estude mais sobre as funções (Roles &amp;<br />
Capabilities)</p>
<blockquote><p>if (!current_user_can(&#8216;manage_options&#8217;)) {<br />
add_action(&#8216;wp_dashboard_setup&#8217;,<br />
&#8216;disable_default_dashboard_widgets&#8217;);</p>
<div id="qhide_557287">}</div>
</blockquote>
<p>outro exemplo:</p>
<p>Efetuarei a customização apenas pros usuários &#8220;Editores&#8221;:</p>
<blockquote><p>if (current_user_can(&#8216;editor&#8217;)) {        add_action(&#8216;wp_dashboard_setup&#8217;,<br />
&#8216;disable_default_dashboard_widgets&#8217;);</p>
<div id="qhide_557288">}</div>
</blockquote>
<p>Exemplos acima retirados do seguinte link:<br />
<a href="http://www.google.com/url?sa=D&amp;q=http://digwp.com/2010/10/customize-wordpress-dashboard/" rel="nofollow" target="_blank">http://digwp.com/2010/10/customize-wordpress-dashboard/</a></p>
<p>Outro link interessante:</p>
<p><a href="http://www.google.com/url?sa=D&amp;q=http://www.catswhocode.com/blog/10-wordpress-dashboard-hacks" rel="nofollow" target="_blank">http://www.catswhocode.com/blog/10-wordpress-dashboard-hacks</a></p>
<p>No link acima, há como remover alguns menus do painel.</p>
<p style="text-align:right;"><em>Fonte: Drika(Lista WordPress Brasil)</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=170&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2011/08/01/personalizar-dashboard-widgets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>Destaques nos posts/pages</title>
		<link>http://meucodex.wordpress.com/2011/07/23/s/</link>
		<comments>http://meucodex.wordpress.com/2011/07/23/s/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 16:15:10 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[destaques]]></category>
		<category><![CDATA[radios]]></category>
		<category><![CDATA[seleções]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=161</guid>
		<description><![CDATA[Opções de seleção na publicação do post/page para marcar publicações destacadas<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=161&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Muito útil para  para atribuir características diferenciadas a um post qualquer. Ex: marcar um post como &#8220;Destaque&#8221;</p>
<p>Neste caso vamos adicionar um box com alguns radios abaixo da caixa do editor de texto do wordpress.</p>
<p><strong>PARTE 1</strong></p>
<p>Supondo que colocamos o código num arquivo &#8220;/lib/destaques.php&#8221; será preciso dar carga no mesmo, incluindo uma linha no arquivo &#8220;functions.php&#8221; do seu tema. A linha será</p>
<blockquote><p>&#8220;require_once(STYLESHEETPATH.&#8217;/lib/destaques.php&#8217;);&#8221;</p></blockquote>
<p>O código abaixo cuida do box.</p>
<blockquote><p>add_action(&#8216;admin_menu&#8217;, &#8216;rpbr_add_inpost_box_destaque&#8217;);</p>
<p>function rpbr_add_inpost_box_destaque() {<br />
add_meta_box(&#8216;<em>rpbr_inpost_box_destaque_page</em>&#8216;, &#8216;<strong>Destaque da página inicial</strong>&#8216;, &#8216;<strong>rpbr_inpost_box_destaque</strong>&#8216;, &#8216;<strong>page</strong>&#8216;, &#8216;normal&#8217;, &#8216;high&#8217;);<br />
add_meta_box(&#8216;<em>rpbr_inpost_box_destaque_post</em>&#8216;, &#8216;<strong>Destaque da página inicial</strong>&#8216;, &#8216;<strong>rpbr_inpost_box_destaque</strong>&#8216;, &#8216;<strong>post</strong>&#8216;, &#8216;normal&#8217;, &#8216;high&#8217;);<br />
}</p></blockquote>
<p>O próximo código cuida da criação do conteúdo dos boxs, ou seja, cria os radios.</p>
<blockquote><p>function rpbr_inpost_box_destaque() { ?&gt;<br />
&lt;?php wp_nonce_field( plugin_basename(__FILE__), &#8216;rpbr_inpost_destaque_nonce&#8217; ); ?&gt;<br />
&lt;?php $_rpbr_destaque = rpbr_get_custom_field(&#8216;_rpbr_destaque&#8217;); ?&gt;<br />
&lt;br style=&#8221;clear: both;&#8221; /&gt;<br />
&lt;input type=&#8221;radio&#8221; name=<strong>&#8220;_rpbr_destaque</strong>&#8221; id=&#8221;rpbr_destaque&#8221; value=&#8221;ok_principal&#8221; &lt;?php checked(&#8216;ok_principal&#8217;, rpbr_get_custom_field(&#8216;_rpbr_destaque&#8217;));?&gt; /&gt;<strong>Destaque Principal</strong> &amp;nbsp; &amp;nbsp; &amp;nbsp;<br />
&lt;input type=&#8221;radio&#8221; name=&#8221;<strong>_rpbr_destaque</strong>&#8221; id=&#8221;rpbr_destaque&#8221; value=&#8221;ok&#8221; &lt;?php checked(&#8216;ok&#8217;, rpbr_get_custom_field(&#8216;_rpbr_destaque&#8217;));?&gt; /&gt;<strong>Destaque Menor </strong> &amp;nbsp; &amp;nbsp; &amp;nbsp;<br />
&lt;input type=&#8221;radio&#8221; name=&#8221;<strong>_rpbr_destaque</strong>&#8221; id=&#8221;rpbr_destaque&#8221; value=&#8221;" &lt;?php checked(&#8221;, rpbr_get_custom_field(&#8216;_rpbr_destaque&#8217;));?&gt; /&gt;<strong>Nenhum Destaque</strong><br />
&lt;br style=&#8221;clear: both;&#8221; /&gt;<br />
&lt;?php<br />
}</p></blockquote>
<p>Para terminar, uma ação que salva o radio selecionado, sempre que a página/post for salvo.</p>
<blockquote><p>add_action(&#8216;save_post&#8217;, &#8216;<strong>rpbr_inpost_destaque_save</strong>&#8216;, 1, 2);<br />
function <strong>rpbr_inpost_destaque_save</strong>($post_id, $post) {</p>
<p>//    verify the nonce<br />
if ( !isset($_POST['rpbr_inpost_destaque_nonce']) || !wp_verify_nonce( $_POST['rpbr_inpost_destaque_nonce'], plugin_basename(__FILE__) ) )<br />
return $post-&gt;ID;</p>
<p>//    don&#8217;t try to save the data under autosave, ajax, or future post.<br />
if ( defined(&#8216;DOING_AUTOSAVE&#8217;) &amp;&amp; DOING_AUTOSAVE ) return;<br />
if ( defined(&#8216;DOING_AJAX&#8217;) &amp;&amp; DOING_AJAX ) return;<br />
if ( defined(&#8216;DOING_CRON&#8217;) &amp;&amp; DOING_CRON ) return;</p>
<p>//    is the user allowed to edit the post or page?<br />
if ( (&#8216;page&#8217; == $_POST['post_type'] &amp;&amp; !current_user_can(&#8216;edit_page&#8217;, $post-&gt;ID)) || !current_user_can(&#8216;edit_post&#8217;, $post-&gt;ID ) )<br />
return $post-&gt;ID;</p>
<p>$rpbr_destaque_value = $_POST[<strong>'_rpbr_destaque</strong>'];</p>
<p>if ( $rpbr_destaque_value ) {<br />
//    save/update<br />
update_post_meta($post_id, <strong>&#8216;_rpbr_destaque</strong>&#8216;, $rpbr_destaque_value);<br />
} else {<br />
//    delete if blank<br />
delete_post_meta($post_id, &#8216;<strong>_rpbr_destaque</strong>&#8216;);<br />
}</p>
<p>}</p></blockquote>
<p><strong>FIM DA PRIMEIRA PARTE</strong></p>
<p><strong>PARTE 2 </strong></p>
<p>A parte 2 diz respeito a exibição das publicações marcadas como destaque.</p>
<p>O valor do radio selecionado é gravado como uma meta_key do post/page.</p>
<p>Desta forma é possível filtrar consultas.</p>
<p>O código abaixo pega a última publicação marcada como <strong>destaque principal</strong>:</p>
<blockquote><p>$args = array(&#8216;post_type&#8217; =&gt; &#8216;any&#8217;,<br />
&#8216;showposts&#8217; =&gt; 1,<br />
&#8216;orderby&#8217;=&gt;&#8217;date&#8217;,<br />
&#8216;meta_key&#8217;=&gt;&#8217;<strong>_rpbr_destaque</strong>&#8216;,<br />
&#8216;meta_value&#8217;=&gt;&#8217;<strong>ok_principal</strong>&#8216;,<br />
&#8216;post_status&#8217; =&gt; &#8216;publish&#8217;,<br />
&#8216;post__not_in&#8217; =&gt; get_option( &#8216;sticky_posts&#8217; ));<br />
$recent = new WP_Query($args);</p></blockquote>
<p>O código abaixo pega as últimas 6 publicações marcadas como <strong>destaque</strong>:</p>
<blockquote><p>$args = array (<br />
&#8216;post_type&#8217; =&gt; &#8216;any&#8217;,&#8217;<br />
showposts&#8217; =&gt; 6,<br />
&#8216;orderby&#8217;=&gt;&#8217;date&#8217;,<br />
&#8216;meta_key&#8217;=&gt;<strong>&#8216;_rpbr_destaque&#8217;</strong>,<br />
&#8216;meta_value&#8217;=&gt;&#8217;<strong>ok</strong>&#8216;,<br />
&#8216;post_status&#8217; =&gt; &#8216;publish&#8217;,<br />
&#8216;post__not_in&#8217; =&gt; get_option( &#8216;sticky_posts&#8217; ));<br />
$recent = new WP_Query($args);</p></blockquote>
<p><strong>PASSO 3</strong></p>
<p>No caso acima, o destaque principal pode aparecer no post associado a uma imagem. Neste caso, é interessante adicionar ao function.php do seu tema, o seguinte:</p>
<blockquote><p>add_image_size( &#8216;destaque-principal&#8217;, 340, 230 );//destaque principal, home</p></blockquote>
<p>Para finalizar, no corpo da página onde a chamada ao destaque principal será exibida, você coloca:</p>
<blockquote><p>&lt;div&gt;<br />
&lt;?php if ( has_post_thumbnail() ) { ?&gt; &lt;a href=&#8221;&lt;?php the_permalink(); ?&gt;&#8221;&gt;&lt;?php the_post_thumbnail( &#8216;destaque-principal&#8217; ); ?&gt;&lt;/a&gt; &lt;?php } ?&gt;<br />
&lt;/div&gt;</p>
<p>&nbsp;</p></blockquote>
<p>FUNÇÕES ÚTEIS</p>
<blockquote><p>function rpbr_custom_field($field) {<br />
echo rpbr_get_custom_field($field);<br />
}<br />
function rpbr_get_custom_field($field) {<br />
global $post;</p>
<p>if ( null === $post ) return FALSE;</p>
<p>$custom_field = get_post_meta($post-&gt;ID, $field, true);</p>
<p>if ( $custom_field ) {<br />
// sanitize and return the value of the custom field<br />
return wp_kses_stripslashes( wp_kses_decode_entities( $custom_field ) );<br />
}<br />
else {<br />
// return FALSE if custom field is empty<br />
return FALSE;<br />
}<br />
}</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=161&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2011/07/23/s/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>10 Useful WordPress Security Tweaks</title>
		<link>http://meucodex.wordpress.com/2010/11/23/10-useful-wordpress-security-tweaks/</link>
		<comments>http://meucodex.wordpress.com/2010/11/23/10-useful-wordpress-security-tweaks/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 01:23:40 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[segurança]]></category>
		<category><![CDATA[comérico eletrônico]]></category>
		<category><![CDATA[criptografia]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[falha]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=157</guid>
		<description><![CDATA[http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/ By Jean-Baptiste Jung Security has always been a hot topic. Offline, people buy wired homes, car alarms and gadgets to bring their security to the max. Online, security is important, too, especially for people who make a living from websites and blogs. In this article, we’ll show you some useful tweaks to protect your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=157&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><a href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/">http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/</a></h2>
<h2>By <a title="Posts by Jean-Baptiste Jung" href="http://www.smashingmagazine.com/author/jean-baptiste-jung/">Jean-Baptiste Jung</a></h2>
<div>
<div id="mediumrectangletarget">
<div id="mediumrectangle"><img src="http://auslieferung.commindo-media-ressourcen.de/www/delivery/lg.php?bannerid=372&amp;campaignid=210&amp;zoneid=22&amp;loc=http%3A%2F%2Fwww.smashingmagazine.com%2F2010%2F07%2F01%2F10-useful-wordpress-security-tweaks%2F&amp;referer=http%3A%2F%2Fwww.google.com.br%2Fsearch%3Fq%3Dwordpress+security+e+commerce+problem%26hl%3Dpt-BR%26safe%3Doff%26client%3Dfirefox-a%26hs%3D1n2%26tbo%3D1%26rlz%3D1R1GGLL_pt-BR%26output%3Dsearch%26source%3Dlnt%26tbs%3Dqdr%3Ay%26sa%3DX%26ei%3DHBTrTOLVLMP78AaY4sjLDQ%26ved%3D0CAwQpwU&amp;cb=33819594bb" alt="" width="0" height="0" /></div>
</div>
</div>
<p>Security has  always been a hot topic. Offline, people buy wired homes, car alarms and  gadgets to bring their security to the max. Online, security is  important, too, especially for people who make a living from websites  and blogs. In this article, we’ll show you some useful tweaks to protect  your WordPress-powered blog.</p>
<h3>1. Prevent Unnecessary Info From Being Displayed</h3>
<p><strong>The problem</strong><br />
When you fail to log into a WordPress blog, the CMS displays some info  telling you what went wrong. This is good if you’ve forgotten your  password, but it might also be good for people who want to hack your  blog. So, why not prevent WordPress from displaying error messages on  failed log-ins?</p>
<p><strong>The solution</strong><br />
To remove log-in error messages, simply open your theme’s <em>functions.php</em> file, and paste the following code:</p>
<div id="highlighter_411270">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>add_filter(</code><code>'login_errors'</code><code>,create_function(</code><code>'$a'</code><code>, </code><code>"return null;"</code><code>));</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Save the file, and see for yourself: no more messages are displayed if you fail to log in.</p>
<p>Please note that there are several <em>functions.php</em> files. Be sure to change the one in your <em>wp-content</em> directory.</p>
<p><strong>Code explanation</strong><br />
With this code, we’ve added a simple hook to overwrite the <code>login_errors()</code> function. Because the custom function that we created returns only <code>null</code>, the message displayed will be a blank string.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://themeplayground.com/2009/tutorials/for-wordpress-users/security-tips/">Tips for Securing WordPress</a><sup>2</sup></li>
<li><a href="http://www.wprecipes.com/wordpress-security-hide-login-error-messages">WordPress Security: Hide Log-In Error Messages</a><sup>3</sup></li>
</ul>
<h3>2. Force SSL Usage</h3>
<p><strong>The problem</strong><br />
If you worry about your data being intercepted, then you could  definitely use SSL. In case you don’t know what it is, SSL is a  cryptographic protocol that secures communications over networks such as  the Internet.</p>
<p>Did you know that forcing WordPress to use SSL is  possible? Not all hosting services allow you to use SSL, but if you’re  hosted on <a href="http://www.catswhocode.com/blog/wpwebhost.html">Wp WebHost</a><sup>4</sup> or <a href="http://www.catswhocode.com/blog/hostgator.html">HostGator</a><sup>5</sup>, then SSL is enabled.</p>
<p><strong>The solution</strong><br />
Once you’ve checked that your Web server can handle SSL, simply open your <em>wp-config.php</em> file (located at the root of your WordPress installation), and paste the following:</p>
<div id="highlighter_155389">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>define(</code><code>'FORCE_SSL_ADMIN'</code><code>, true);</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Save the file, and you’re done!</p>
<p><strong>Code explanation</strong><br />
Nothing hard here. WordPress uses a lot of constants to configure the software. In this case, we have simply defined the <code>FORCE_SSL_ADMIN</code> constant and set its value to <code>true</code>. This results in WordPress using SSL.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://www.wprecipes.com/how-to-force-using-ssl-on-wp-admin-directory">How To: Force Using SSL on wp-admin Directory</a><sup>6</sup></li>
</ul>
<h3>3. Use .htaccess To Protect The wp-config File</h3>
<p><strong>The problem</strong><br />
As a WordPress user, you probably know how important the <em>wp-config.php</em> file is. This file contains all of the information required to access  your precious database: username, password, server name and so on.  Protecting the <em>wp-config.php</em> file is critical, so how about exploiting the power of Apache to this end?</p>
<p><strong>The solution</strong><br />
The <em>.htaccess</em> file is located at the root your WordPress installation. After creating  a back-up of it (it’s such a critical file that we should always have a  safe copy), open it up, and paste the following code:</p>
<div id="highlighter_200356">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;files wp-config.php&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>2</code></td>
<td><code>order allow,deny</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>3</code></td>
<td><code>deny from all</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>4</code></td>
<td><code>&lt;/files&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
<em>.htaccess</em> files are powerful and one of the best tools to prevent unwanted access  to your files. In this code, we have simply created a rule that  prevents any access to the <em>wp-admin.php</em> file, thus ensuring that no evil bots can access it.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://www.catswhocode.com/blog/10-easy-ways-to-secure-your-wordpress-blog">10 Easy Ways to Secure Your WordPress Blog</a><sup>7</sup></li>
</ul>
<h3>4. Blacklist Undesired Users And Bots</h3>
<p><img src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm4.jpg" alt="Sm4 in 10 Useful WordPress Security Tweaks" /></p>
<p><strong>The problem</strong><br />
This is as true online as it is in real life: someone who pesters you  today will probably pester you again tomorrow. Have you noticed how many  spam bots return to your blog 10 times a day to post their annoying  comments? The solution to this problem is quite simple: forbid them  access to your blog.</p>
<p><strong>The solution</strong><br />
Paste the following code in your <em>.htaccess</em> file, located at the root of your WordPress installation. As I said, <strong>always back up the <em>.htaccess</em> file</strong> before editing it. Also, don’t forget to change <code>123.456.789</code> to the IP address you want to ban.</p>
<div id="highlighter_203060">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;Limit GET POST PUT&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>2</code></td>
<td><code>order allow,deny</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>3</code></td>
<td><code>allow from all</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>4</code></td>
<td><code>deny from 123.456.789</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>5</code></td>
<td><code>&lt;/LIMIT&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
Apache is powerful and can easily be used to ban undesirable people and  bots from your website. With this code, we’re telling Apache that  everyone is allowed to visit our blog except the person with the IP  address <code>123.456.789</code>.</p>
<p>To ban more people, simply repeat line 4 of this code on a new line, using another IP address, as shown below:</p>
<div id="highlighter_113583">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;Limit GET POST PUT&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>2</code></td>
<td><code>order allow,deny</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>3</code></td>
<td><code>allow from all</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>4</code></td>
<td><code>deny from 123.456.789</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>5</code></td>
<td><code>deny from 93.121.788</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>6</code></td>
<td><code>deny from 223.956.789</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>7</code></td>
<td><code>deny from 128.456.780</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>8</code></td>
<td><code>&lt;/LIMIT&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://perishablepress.com/press/2008/02/24/over-150-of-the-worst-spammers-scrapers-and-crackers-from-2007/">Over 150 of the Worst Spammers, Scrapers and Crackers from 2007</a><sup>8</sup></li>
</ul>
<h3>5. Protect Your WordPress Blog From Script Injections</h3>
<p><strong>The problem</strong><br />
Protecting dynamic websites is especially important. Most developers always protect their <code>GET</code> and <code>POST</code> requests, but sometimes this is not enough. We should also protect our  blog against script injections and any attempt to modify the PHP <code>GLOBALS</code> and <code>_REQUEST</code> variables.</p>
<p><strong>The solution</strong><br />
The following code blocks script injections and any attempts to modify the PHP <code>GLOBALS</code> and <code>_REQUEST</code> variables. Paste it in your <em>.htaccess</em> file (located in the root of your WordPress installation). <strong>Make sure to always back up the <em>.htaccess</em> file</strong> before modifying it.</p>
<div id="highlighter_388688">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>Options +FollowSymLinks</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>2</code></td>
<td><code>RewriteEngine On</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>3</code></td>
<td><code>RewriteCond %{QUERY_STRING} (\&lt;|%3C).*script.*(\&gt;|%3E) [NC,OR]</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>4</code></td>
<td><code>RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>5</code></td>
<td><code>RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>6</code></td>
<td><code>RewriteRule ^(.*)$ index.php [F,L]</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
Using the power of the <em>.htaccess</em> file, we can check requests. What we’ve done here is check whether the  request contains a &lt;script&gt; and whether it has tried to modify the  value of the PHP <code>GLOBALS</code> or <code>_REQUEST</code> variables. If any of these conditions are met, the request is blocked and a 403 error is returned to the client’s browser.</p>
<p><strong>Sources</strong></p>
<ul>
<li><a href="http://blog.galerie-cesar.com/proteger-son-site-avec-fichier-htaccess/">Protéger Son Site Avec Un Fichier .htaccess</a><sup>9</sup></li>
<li><a href="http://www.wprecipes.com/protect-your-wordpress-blog-using-htaccess">Protect Your WordPress Blog Using .htaccess</a><sup>10</sup></li>
</ul>
<h3>6. Fight Back Against Content Scrapers</h3>
<p><strong>The problem</strong><br />
If your blog is the least bit known, people will no doubt try to use  your content on their own websites without your consent. One of the  biggest problems is hot-linking to your images, which saps your server’s  bandwidth.</p>
<p><strong>The solution</strong><br />
To protect your website against hot-linking and content scrapers, simply paste the following code in your <em>.htaccess</em> file. As always, don’t forget to back up when modifying the <em>.htaccess</em> file.</p>
<div id="highlighter_311453">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>RewriteEngine On</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>2</code></td>
<td><code>#Replace ?mysite\.com/ with your blog url</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>3</code></td>
<td><code>RewriteCond %{HTTP_REFERER} !^http:</code><code>//(.+\.)?mysite\.com/ [NC]</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>4</code></td>
<td><code>RewriteCond %{HTTP_REFERER} !^$</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>5</code></td>
<td><code>#Replace /images/nohotlink.jpg with your </code><code>"don't hotlink"</code> <code>image url</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>6</code></td>
<td><code>RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Once you’ve saved the file, only your website will be able to link to your images, or, to be more correct, no one <em>would link</em> to your images, because it would be way too complicated and time-consuming. Other websites will automatically display the <em>nohotlink.jpg</em> image. Note that you can also specify a non-existent image, so websites  that try to hot-link to you would display a blank space.</p>
<p><strong>Code explanation</strong><br />
With this code, the first thing we’ve done is check the referrer to see  that it matches our blog’s URL and it is not empty. If it doesn’t, and  the file has a JPG, GIF, BMP or PNG extension, then the nohotlink image  is displayed instead.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://www.catswhoblog.com/how-to-protect-your-blog-from-content-thieves">How to Protect Your Blog from Content Thieves</a><sup>11</sup></li>
</ul>
<h3>7. Create A Plug-In To Protect Your Blog From Malicious URL Requests</h3>
<p><img src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm7.jpg" alt="Sm7 in 10 Useful WordPress Security Tweaks" /></p>
<p><strong>The problem</strong><br />
Hackers and evil-doers often use malicious queries to find and attack a  blog’s weak spots. WordPress has good default protection, but enhancing  it is possible.</p>
<p><strong>The solution</strong><br />
Paste the following code in a text file, and save it as <em>blockbadqueries.php</em>. Once you’ve done that, upload it to your <code>wp-content/plugins</code> directory and activate it as you would any other plug-in. Now your blog is protected against malicious queries.</p>
<div id="highlighter_723280">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>01</code></td>
<td><code>&lt;?php</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>02</code></td>
<td><code>/*</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>03</code></td>
<td><code>Plugin Name: Block Bad Queries</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>04</code></td>
<td><code>Plugin URI: <a href="http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/">http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/</a></code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>05</code></td>
<td><code>Description: Protect WordPress Against Malicious URL Requests</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>06</code></td>
<td><code>Author URI: <a href="http://perishablepress.com/">http://perishablepress.com/</a></code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>07</code></td>
<td><code>Author: Perishable Press</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>08</code></td>
<td><code>Version: 1.0</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>09</code></td>
<td><code>*/</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>10</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>11</code></td>
<td><code>global</code> <code>$user_ID</code><code>; </code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>12</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>13</code></td>
<td><code>if</code><code>(</code><code>$user_ID</code><code>) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>14</code></td>
<td><code> </code><code>if</code><code>(!current_user_can(</code><code>'level_10'</code><code>)) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>15</code></td>
<td><code> </code><code>if</code> <code>(</code><code>strlen</code><code>(</code><code>$_SERVER</code><code>[</code><code>'REQUEST_URI'</code><code>]) &gt; 255 ||</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>16</code></td>
<td><code> </code><code>strpos</code><code>(</code><code>$_SERVER</code><code>[</code><code>'REQUEST_URI'</code><code>], </code><code>"eval("</code><code>) ||</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>17</code></td>
<td><code> </code><code>strpos</code><code>(</code><code>$_SERVER</code><code>[</code><code>'REQUEST_URI'</code><code>], </code><code>"CONCAT"</code><code>) ||</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>18</code></td>
<td><code> </code><code>strpos</code><code>(</code><code>$_SERVER</code><code>[</code><code>'REQUEST_URI'</code><code>], </code><code>"UNION+SELECT"</code><code>) ||</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>19</code></td>
<td><code> </code><code>strpos</code><code>(</code><code>$_SERVER</code><code>[</code><code>'REQUEST_URI'</code><code>], </code><code>"base64"</code><code>)) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>20</code></td>
<td><code> </code><code>@header(</code><code>"HTTP/1.1 414 Request-URI Too Long"</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>21</code></td>
<td><code> </code><code>@header(</code><code>"Status: 414 Request-URI Too Long"</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>22</code></td>
<td><code> </code><code>@header(</code><code>"Connection: Close"</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>23</code></td>
<td><code> </code><code>@</code><code>exit</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>24</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>25</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>26</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table>
<tbody>
<tr>
<td><code>27</code></td>
<td><code>?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
What this code does is pretty simple. It checks for excessively long  request strings (more than 255 characters) and for the presence of  either the <code>eval</code> or <code>base64</code> PHP functions in the URI. If one of these conditions is met, then the plug-in sends a 414 error to the client’s browser.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/">Protect WordPress Against Malicious URL Requests/</a><sup>12</sup></li>
</ul>
<h3>8. Remove Your WordPress Version Number… Seriously!</h3>
<p><strong>The problem</strong><br />
As you may know, WordPress automatically displays the version you are  using in the head of your blog files. This is pretty harmless if your  blog is always up to date with the latest version (which is certainly  what you should be doing anyway). But if for some reason your blog isn’t  up to date, WordPress still displays it, and hackers will learn this  vital piece of information.</p>
<p><strong>The solution</strong><br />
Paste the following line of code in the <em>functions.php</em> file of your theme. Save it, refresh your blog, and voila: no more WordPress version number in the header.</p>
<div id="highlighter_304623">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>remove_action(</code><code>'wp_head'</code><code>, </code><code>'wp_generator'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
To execute certain actions, WordPress uses a mechanism called “hooks,” which allow you to hook one function to another. The <code>wp_generator</code> function, which displays the WordPress version, is hooked. We can remove this hook and prevent it from executing by using the <code>remove_action()</code> function.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://digwp.com/2009/07/remove-wordpress-version-number/">How to Remove the WordPress Version Number (the Right Way)</a><sup>13</sup></li>
</ul>
<h3>9. Change The Default “Admin” Username</h3>
<p><img src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm9.jpg" alt="Sm9 in 10 Useful WordPress Security Tweaks" /></p>
<p><strong>The problem</strong><br />
Brute force is one of the easiest ways to break a password. The method  is simple: try as many different passwords as possible until the right  one is found. Users of the brute force method use dictionaries, which  give them a lot of password combinations.</p>
<p>But knowing your  username certainly makes it easier for them to guess the right  combination. This is why you should always change the default “admin”  username to something harder to guess.</p>
<p>Note that WordPress 3.0 let  you choose your desired username by default. Therefore, this tip is  still usefull if you still use the old “admin” account from older  WordPress versions.</p>
<p><strong>The solution</strong><br />
If you  haven’t changed the “admin” username yet, simply run the following SQL  query to your database to change it for good. Don’t forget to specify  your desired username.</p>
<div id="highlighter_904970">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>UPDATE</code> <code>wp_users </code><code>SET</code> <code>user_login = </code><code>'Your New Username'</code> <code>WHERE</code> <code>user_login = </code><code>'Admin'</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
Usernames are stored in the database. To change one, a simple <code>UPDATE</code> query is enough. Note that this query will not transfer posts written  by “admin” to your new username; the source post below shows you how to  easily do that.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://www.onextrapixel.com/2010/01/30/13-useful-wordpress-sql-queries-you-wish-you-knew-earlier/">13 Useful WordPress SQL Queries You Wish You Knew Earlier/</a><sup>14</sup></li>
</ul>
<h3>10. Prevent Directory Browsing</h3>
<p><strong>The problem</strong><br />
By default, most hosts allow directory listing. So, if you type <code>www.yourblog.com/wp-includes</code> in the browser’s address bar, you’ll see all of the files in that  directory. This is definitely a security risk, because a hacker could  see the last time that files were modified and access them.</p>
<p><strong>The solution (Updated)</strong><br />
Just add the following to the Apache configuration or your .htaccess file:</p>
<div id="highlighter_602374">
<div>
<div><a title="view source" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#viewSource">view source</a><a title="print" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#printSource">print</a><a title="?" href="http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/#about">?</a></div>
</div>
<div>
<div>
<table>
<tbody>
<tr>
<td><code>1</code></td>
<td><code>Options -Indexes</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><strong>Code explanation</strong><br />
Please note that it’s not enough to update the blog’s <em>robots.txt</em> file with <code>Disallow: /wp*</code>. This would prevent the wp-directory from being indexed, but will not prevent users from seeing it.</p>
<p><strong>Source</strong></p>
<ul>
<li><a href="http://www.makeuseof.com/tag/18-useful-plugins-and-hacks-to-protect-your-wordpress-blog/">18 WordPress Security Plug-ins and Tips to Secure Your Blog</a><sup>15</sup></li>
</ul>
<p><em>(al)</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=157&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/11/23/10-useful-wordpress-security-tweaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>

		<media:content url="http://auslieferung.commindo-media-ressourcen.de/www/delivery/lg.php?bannerid=372&#38;campaignid=210&#38;zoneid=22&#38;loc=http%3A%2F%2Fwww.smashingmagazine.com%2F2010%2F07%2F01%2F10-useful-wordpress-security-tweaks%2F&#38;referer=http%3A%2F%2Fwww.google.com.br%2Fsearch%3Fq%3Dwordpress+security+e+commerce+problem%26hl%3Dpt-BR%26safe%3Doff%26client%3Dfirefox-a%26hs%3D1n2%26tbo%3D1%26rlz%3D1R1GGLL_pt-BR%26output%3Dsearch%26source%3Dlnt%26tbs%3Dqdr%3Ay%26sa%3DX%26ei%3DHBTrTOLVLMP78AaY4sjLDQ%26ved%3D0CAwQpwU&#38;cb=33819594bb" medium="image" />

		<media:content url="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm4.jpg" medium="image">
			<media:title type="html">Sm4 in 10 Useful WordPress Security Tweaks</media:title>
		</media:content>

		<media:content url="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm7.jpg" medium="image">
			<media:title type="html">Sm7 in 10 Useful WordPress Security Tweaks</media:title>
		</media:content>

		<media:content url="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/03/sm9.jpg" medium="image">
			<media:title type="html">Sm9 in 10 Useful WordPress Security Tweaks</media:title>
		</media:content>
	</item>
		<item>
		<title>10 ótimos shortcodes para WordPress</title>
		<link>http://meucodex.wordpress.com/2010/10/12/10-otimos-shortcodes-para-wordpress/</link>
		<comments>http://meucodex.wordpress.com/2010/10/12/10-otimos-shortcodes-para-wordpress/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 18:15:00 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[API Wordpress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[shortcodes]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[artigos relacionados]]></category>
		<category><![CDATA[blank lines]]></category>
		<category><![CDATA[conteúdo privado]]></category>
		<category><![CDATA[controle de acesso]]></category>
		<category><![CDATA[formatação]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[gráficos]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=154</guid>
		<description><![CDATA[CTRL+C,CTRL+V from http://imasters.com.br/artigo/15146/wordpress/10_otimos_shortcodes_para_wordpress Os shortcodes do WordPress foram introduzidos na versão 2.5. Estes códigos são uma forma muito simples de &#8216;puxar&#8217; a informação desejada, recorrendo a poucas linhas de código. Neste artigo, vou mostrar-lhe os 10 shortcodes mais incríveis para WordPress, que você poderá começar a utilizar imediatamente no seu blog! 01. Apresentar artigos relacionados [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=154&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>CTRL+C,CTRL+V from <a href="http://imasters.com.br/artigo/15146/wordpress/10_otimos_shortcodes_para_wordpress">http://imasters.com.br/artigo/15146/wordpress/10_otimos_shortcodes_para_wordpress</a></h2>
<div id="strConteudo">
<p>Os shortcodes do WordPress foram introduzidos na versão 2.5.  Estes códigos são uma forma muito simples de &#8216;puxar&#8217; a informação  desejada, recorrendo a poucas linhas de código. Neste artigo, vou  mostrar-lhe os 10 shortcodes mais incríveis para WordPress, que você  poderá começar a utilizar imediatamente no seu blog!</p>
<h4>01. Apresentar artigos relacionados</h4>
<p>Os artigos relacionados são uma forma muito eficiente de manter os  leitores por mais tempo no seu blog, ocupados com a visitação de novas  páginas constantemente. Isso aumenta o número de páginas vistas  gradualmente, ao mesmo tempo que aumenta o potencial de rentabilidade do  seu blog. Existem dezenas de plugins para executar esta função, mas por  que não utilizar um shortcode que o faça automaticamente?</p>
<div>
<pre><code>   function related_posts_shortcode( $atts ) {
    extract(shortcode_atts(array(
    'limit' =&gt; '5,
    ), $atts));

    global $wpdb, $post, $table_prefix;

    if ($post-&gt;ID) {
    $retval = '&lt;ul&gt;';
    // Get tags
    $tags = wp_get_post_tags($post-&gt;ID);
    $tagsarray = array();
    foreach ($tags as $tag) {
    $tagsarray[] = $tag-&gt;term_id;
    }
    $tagslist = implode(',', $tagsarray);

    // Do the query
    $q = "SELECT p.*, count(tr.object_id) as count
    FROM $wpdb-&gt;term_taxonomy AS tt, $wpdb-&gt;term_relationships AS tr, $wpdb-&gt;posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id  = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post-&gt;ID
    AND p.post_status = 'publish'
    AND p.post_date_gmt &lt; NOW()
    GROUP BY tr.object_id
    ORDER BY count DESC, p.post_date_gmt DESC
    LIMIT $limit;";

    $related = $wpdb-&gt;get_results($q);
    if ( $related ) {
    foreach($related as $r) {
    $retval .= '&lt;li&gt;&lt;a title="'.wptexturize($r-&gt;post_title).'" href="'.get_permalink($r-&gt;ID).'"&gt;'.wptexturize($r-&gt;post_title).'&lt;/a&gt;&lt;/li&gt;';
    }
    } else {
    $retval .= '
    &lt;li&gt;Nenhum artigo relacionado encontrado&lt;/li&gt;';
    }
    $retval .= '&lt;/ul&gt;';
    return $retval;
    }
    return;
    }
    add_shortcode('related_posts', 'related_posts_shortcode');</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code> [related_posts]</code></pre>
</div>
<h4>02. Apresentar um gráfico Google</h4>
<p>A Google Chart API é, provavelmente, a ferramenta mais interessante  da internet para apresentar gráficos dinâmicos em páginas e blogs. Aqui  fica um shortcode para tornar essa utilização ainda mais simples no seu  blog WordPress:</p>
<div>
<pre><code>    function chart_shortcode( $atts ) {
    extract(shortcode_atts(array(
    'data' =&gt; ",
    'colors' =&gt; ",
    'size' =&gt; '400×200,
    'bg' =&gt; 'ffffff',
    'title' =&gt; ",
    'labels' =&gt; ",
    'advanced' =&gt; ",
    'type' =&gt; 'pie'
    ), $atts));

    switch ($type) {
    case 'line' :
    $charttype = 'lc'; break;
    case 'xyline' :
    $charttype = 'lxy'; break;
    case 'sparkline' :
    $charttype = 'ls'; break;
    case 'meter' :
    $charttype = 'gom'; break;
    case 'scatter' :
    $charttype = 's'; break;
    case 'venn' :
    $charttype = 'v'; break;
    case 'pie' :
    $charttype = 'p3; break;
    case 'pie2d' :
    $charttype = 'p'; break;
    default :
    $charttype = $type;
    break;
    }

    if ($title) $string .= '&amp;chtt='.$title.";
    if ($labels) $string .= '&amp;chl='.$labels.";
    if ($colors) $string .= '&amp;chco='.$colors.";
    $string .= '&amp;chs='.$size.";
    $string .= '&amp;chd=t:'.$data.";
    $string .= '&amp;chf='.$bg.";

    return '&lt;img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.".$string.$advanced.'" alt="'.$title.'" /&gt;';
    }
    add_shortcode('chart', 'chart_shortcode');</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>    [chart data="41.52,37.79,20.67,0.03" bg="F7F9FA" labels="Reffering+sites|Search+Engines|Direct+traffic|Other" colors="058DC7,50B432,ED561B,EDEF00" size="488x200" title="Traffic Sources" type="pie"]</code></pre>
</div>
<h4>03. Integrar anúncios no AdSense</h4>
<p>O Adsense é, provavelmente, a forma mais simples e eficaz de  rentabilizar um website ou um blog. Utilizando widgets, é relativamente  simples colocar anúncios Adsense no seu blog. No entanto, a melhor forma  de rentabilizar um blog é, seguramente, utilizando Adsense dentro dos  seus posts. Este processo torna-se extremamente simples e mágico,  recorrendo aos shortcodes para WordPress. Vejamos:</p>
<div>
<pre><code>  function showads() {
    return '&lt;script type="text/javascript"&gt;&lt;!
    google_ad_client = "pub-3637220125174754;
    google_ad_slot = "4668915978;
    google_ad_width = 468;
    google_ad_height = 60;
    //&gt;
    &lt;/script&gt;
    &lt;script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
    &lt;/script&gt;
    ';
    }

    add_shortcode('adsense', 'showads');</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>    [adsense]  </code></pre>
</div>
<h4>04. Mostrar conteúdo privado para membros premium</h4>
<p>Cada vez mais os blog e blogueiros adotam os chamados &#8216;conteúdos  premium&#8217;, onde determinados grupos de usuários têm de pagar para ter  acesso a conteúdos privilegiados. Sabe como apresentar conteúdos premium  apenas para os seus &#8216;usuários premium&#8217;? Utilize este shortcode:</p>
<div>
<pre><code>    function access_check_shortcode( $attr, $content = null ) {
    extract( shortcode_atts( array( 'capability' =&gt; 'read' ), $attr ) );
    if ( current_user_can( $capability ) &amp;&amp; !is_null( $content ) &amp;&amp; !is_feed() )
    return $content;

    return 'Desculpe, apenas membros registados podem ter acesso a estes conteúdos.';
    }

    add_shortcode( 'access', 'access_check_shortcode' );</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>    [access capability="switch_themes"]</code></pre>
</div>
<h4>05. Como integrar seus conteúdos de RSS feed</h4>
<p>Entre outras coisas fantásticas, o WordPress tem um leitor de RSS  Feeds integrado no seu código, que possibilita a leitura dos feeds no  painel de controle do blog wordpress. No entanto, recorrendo a um  shortcode, é possível colocar esses mesmos RSS Feeds onde você desejar,  incluindo nos seus posts.</p>
<div>
<pre><code>    //This file is needed to be able to use the wp_rss() function.
    include_once(ABSPATH.WPINC.'/rss.php');

    function readRss($atts) {
    extract(shortcode_atts(array(
    "feed" =&gt; 'http://',
    "num" =&gt; '1,
    ), $atts));

    return wp_rss($feed, $num);
    }

    add_shortcode('rss', 'readRss');</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>    <ul><li>Ocorreu um erro. É provável que o feed esteja indisponível. Tente mais tarde.</li></ul></code></pre>
</div>
<h4>06. Encurtar um endereço URL para o twitter</h4>
<p>Uma das vantagens que o Twitter tem é de utilizar no seu código o  core da TinyURL para encurtar os endereços URL presentes nos posts dos  seus usuários. No entanto, é possível facilitar a vida dos leitores com  um shortcut que faça isso automaticamente:</p>
<div>
<pre><code>function subzane_shorturl($atts) {
extract(shortcode_atts(array(
'url' =&gt; ",
'name' =&gt; ",
), $atts));
$request = 'http://u.nu/unu-api-simple?url=' . urlencode($url);
$short_url = file_get_contents($request);
if (substr($short_url, 0, 4) == 'http')    {
$name = empty($name)?$short_url:$name;
return '&lt;a href="'.$short_url.'"&gt;'.$name.'&lt;/a&gt;';
} else {
$name = empty($name)?$url:$name;
return '&lt;a href="'.$url.'"&gt;'.$name.'&lt;/a&gt;';
}
}
add_shortcode('shorturl', 'subzane_shorturl');</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>[shorturl name="shortcode" url="http://codex.wordpress.org/Shortcode_API"]</code></pre>
</div>
<h4>07. Apresente a última imagem anexada a um post</h4>
<p>Em vez de utilizar custom fields ou endereços URL para puxar as  imagens anexadas aos seus posts, por que não recorrer a um shortcode que  o faça automaticamente?</p>
<div>
<pre><code>function sc_postimage($atts, $content = null) {
extract(shortcode_atts(array(
"size" =&gt; 'thumbnail',
"float" =&gt; 'none'
), $atts));
$images =&amp; get_children( 'post_type=attachment&amp;post_mime_type=image&amp;post_parent=' . get_the_id() );
foreach( $images as $imageID =&gt; $imagePost )
$fullimage = wp_get_attachment_image($imageID, $size, false);
$imagedata = wp_get_attachment_image_src($imageID, $size, false);
$width = ($imagedata[1]+2);
$height = ($imagedata[2]+2);
return '&lt;div style="width: '.$width.'px; height: '.$height.'px; float: '.$float.';"&gt;'.$fullimage.'&lt;/div&gt;';
}
add_shortcode("postimage", "sc_postimage");</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>[postimage]</code></pre>
</div>
<h4>8. Adicione notas administrativas aos seus posts</h4>
<p>Quando se trabalha com blogs multi-editor, é extremamente importante  notificar outros escritores de problemas que existam nos seus posts. E  se pudesse adicionar notas a esses mesmos posts, que só pudessem ser  lidas por outros administradores? Nada como usar um shortcode para  resolver esse problema:</p>
<div>
<pre><code>add_shortcode( 'note', 'sc_note' );
function sc_note( $atts, $content = null ) {
if ( current_user_can( 'publish_posts' ) )
return '&lt;div&gt;'.$content.'&lt;/div&gt;';
return ";
}</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>[note]Esta é uma nota pessoal que só pode ser lida por administradores![/note]</code></pre>
</div>
<h4>09. Remova a formatação automática do WordPress</h4>
<p>Se você é um programador ou desenvolvedor, e costuma colocar porções  de código no seu blog WordPress, provavelmente já reparou que a  formatação automática do WordPress pode ser um verdadeiro problema. No  entanto, existe um shortcode que o ajuda a resolver esse problema em  determinadas porções de texto. Vejamos:</p>
<div>
<pre><code>function my_formatter($content) {
$new_content = ";
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}

return $new_content;
}

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

add_filter('the_content', 'my_formatter', 99);</code></pre>
</div>
<p><strong>Código de utilização:</strong></p>
<div>
<pre><code>[raw]Esta porção de texto não será formatada automaticamente pelo WP.[/raw]</code></pre>
</div>
<h4>10. Apresente as estatísticas do seu blog com shortcodes</h4>
<p>Sempre gostou da possibilidade de mostrar as estatísticas do seu blog  em tempo real? Graças ao Wesley e ao seu plugin &#8220;Blog Stats&#8221;, é  possível  apresentar de forma dinâmica, e através de shortcodes, todas  as estatísticas do seu blog. Faça download do plugin Blog Stats e,  depois de instalado, utilize os seguintes shortcodes:</p>
<div>
<pre><code>[pagerank]
[feedburner_subscribers]
[alexa_rank]
[technorati_authority]
[technorati_rank]
[user_count]
[post_count]
[page_count]
[comment_count]
[trackback_count]
[avg_comments_per_post]
[category_count]
[tag_count]
[link_count]
[google_backlinks]
[yahoo_backlinks]
[delicious_bookmarks]</code></pre>
</div>
<p>Até a próxima!!</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=154&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/10/12/10-otimos-shortcodes-para-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>10 Useful WordPress Search Code Snippets</title>
		<link>http://meucodex.wordpress.com/2010/09/25/10-useful-wordpress-search-code-snippets-september-19-2010-14-comments-web-designwordpress-create-a-free-website-rss-del-icio-us-stumbleupon-digg-twitthis-mixx/</link>
		<comments>http://meucodex.wordpress.com/2010/09/25/10-useful-wordpress-search-code-snippets-september-19-2010-14-comments-web-designwordpress-create-a-free-website-rss-del-icio-us-stumbleupon-digg-twitthis-mixx/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 00:33:19 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=146</guid>
		<description><![CDATA[Post Ctrl+C,Ctrl+V from http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/ It is no secret that the standard search within WordPress is not very accurate. The problem is that WordPress takes your search term far too literally, meaning, that if you were to type “search+code+wordpress” in to our search box above, it would return every post that contains those terms (in this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=146&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><span style="color:rgb(255,0,0);"><b>Post Ctrl+C,Ctrl+V from <a href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/">http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/</a></b></span></h2>
<p>It is no secret that the standard search within WordPress is not very  accurate. The problem is that WordPress takes your search term far too  literally, meaning, that if you were to type “search+code+wordpress” in  to our search box above, it would return every post that contains those  terms (in this case over 30 posts), even though we have no such post  with in our database. So, in actual fact even though there are over 30+  results, our reader will never actually find what they are looking for.  We have to improve this.</p>
<p>In this post we have 10 really useful code snippets that will help improve your WordPress Search functionality.</p>
<h2>How To Exclude Posts or Pages from Search Results</h2>
<p>If  you would like to be able to control which posts or pages should be  excluded from WordPress search results, all you have to do is copy and  paste the code below into your <code><b>functions.php</b></code> file.</p>
<p>In this snippet, posts with the IDs <b><code>0</code></b> and <b><code>1</code></b> will be excluded. Edit accordingly to suit your needs.</p>
<div id="highlighter_574978">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>function</code> <code>SearchFilter(</code><code>$query</code><code>) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>2</code></td>
<td><code> </code><code>if</code> <code>(</code><code>$query</code><code>-&gt;is_search) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>3</code></td>
<td><code> </code><code>$query</code><code>-&gt;set(</code><code>'cat'</code><code>,</code><code>'0,1'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>4</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>5</code></td>
<td><code> </code><code>return</code> <code>$query</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>6</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>7</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>8</code></td>
<td><code>add_filter(</code><code>'pre_get_posts'</code><code>,</code><code>'SearchFilter'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://www.wprecipes.com/how-to-exclude-posts-or-pages-from-search-results">wprecipes.com →</a></p>
<h2>WordPress Drop-Down Category Search Form</h2>
<p>A  useful function you could give to your WordPress search would be to  allow your readers to filter the search results by targeting a specific  category. This can be achieved by using a simple drop-down containing  all of the category titles.</p>
<p>All you have to do is replace the standard WordPress search form (found within the <code><b>searchform.php</b></code>) with the snippet below:</p>
<div id="highlighter_413015">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;form role=</code><code>"search"</code> <code>method=</code><code>"get"</code> <code>id=</code><code>"searchform"</code> <code>action=</code><code>"&lt;?php bloginfo('siteurl'); ?&gt;"</code><code>&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>2</code></td>
<td><code> </code><code>&lt;div&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>3</code></td>
<td><code> </code><code>&lt;label </code><code>class</code><code>=</code><code>"screen-reader-text"</code> <code>for</code><code>=</code><code>"s"</code><code>&gt;Search </code><code>for</code><code>:&lt;/label&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>4</code></td>
<td><code> </code><code>&lt;input type=</code><code>"text"</code> <code>value=</code><code>""</code> <code>name=</code><code>"s"</code> <code>id=</code><code>"s"</code> <code>/&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>5</code></td>
<td><code> </code><code>in &lt;?php wp_dropdown_categories( </code><code>'show_option_all=All Categories'</code> <code>); ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>6</code></td>
<td><code> </code><code>&lt;input type=</code><code>"submit"</code> <code>id=</code><code>"searchsubmit"</code> <code>value=</code><code>"Search"</code> <code>/&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>7</code></td>
<td><code> </code><code>&lt;/div&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>8</code></td>
<td><code>&lt;/form&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://www.melandri.net/2009/08/05/add-a-category-filter-to-wordpress-search-form/">www.melandri.net →</a></p>
<h2>Dynamically Search Categories and Child Categories Only</h2>
<p>This  search form snippet could be useful within the category archive to  allow your readers to search the child categories from any given parent  category.</p>
<p>In this snippet, all child categories from category ID <b><code>1</code></b> will be searched. Edit accordingly to suit your needs.</p>
<div id="highlighter_585804">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>01</code></td>
<td><code>&lt;form method=”get” id=”searchform” action=”&lt;?php bloginfo(‘home’); ?&gt;/”&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>02</code></td>
<td><code>&lt;div id=”search”&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>03</code></td>
<td><code>&lt;input type=”text” value=”Search… ” onclick=”this.value=”;” name=”s” id=”s” /&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>04</code></td>
<td><code>&lt;?php </code><code>$categories</code> <code>= get_categories(‘child_of=1′);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>05</code></td>
<td><code>$catlist</code> <code>= ”;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>06</code></td>
<td><code>foreach</code> <code>(</code><code>$categories</code> <code>as</code> <code>$cat</code><code>) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>07</code></td>
<td><code>$catlist</code><code>.= </code><code>$cat</code><code>-&gt;cat_ID.’,';</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>08</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>09</code></td>
<td><code>$catlist</code><code>.’5′;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>10</code></td>
<td><code>?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>11</code></td>
<td><code>&lt;input type=”hidden” name=”cat” value=”&lt;?php </code><code>echo</code> <code>“</code><code>$catlist</code><code>”?&gt;” /&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>12</code></td>
<td><code>&lt;input name=”" type=”image” src=”&lt;?php bloginfo(‘stylesheet_directory’); ?&gt;/styles/&lt;?php </code><code>echo</code> <code>“</code><code>$style_path</code><code>”; ?&gt;/search.gif” value=”Go” </code><code>class</code><code>=”btn” /&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>13</code></td>
<td><code>&lt;/div&gt;&lt;!–/search –&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>14</code></td>
<td><code>&lt;/form&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://wpgarage.com/code-snippets/how-to-hack-the-wordpress-search-function-search-categories-and-child-categories/">wpgarage.com →</a></p>
<h2>Search a Specific Post Type</h2>
<p>WordPress gives you the ability to search specific post types by using this small snippet.</p>
<p>All you have to do is copy and paste the code below into your <code><b>functions.php</b></code> file.</p>
<div id="highlighter_156036">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>01</code></td>
<td><code>function</code> <code>SearchFilter(</code><code>$query</code><code>) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>02</code></td>
<td><code> </code><code>if</code> <code>(</code><code>$query</code><code>-&gt;is_search) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>03</code></td>
<td><code> </code><code>// Insert the specific post type you want to search</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>04</code></td>
<td><code> </code><code>$query</code><code>-&gt;set(</code><code>'post_type'</code><code>, </code><code>'feeds'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>05</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>06</code></td>
<td><code> </code><code>return</code> <code>$query</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>07</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>08</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>09</code></td>
<td><code>// This filter will jump into the loop and arrange our results before they're returned</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>10</code></td>
<td><code>add_filter(</code><code>'pre_get_posts'</code><code>,</code><code>'SearchFilter'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://www.ashbluewebdesign.com/2010/06/wordpress-search-tips-and-security-flaws/">ashbluewebdesign.com →</a></p>
<h2>Display the Number of Search Results Returned</h2>
<p>If you would like to show your readers how many results have been found per search term, you could use this helpful snippet.</p>
<p>Open <code><b>search.php</b></code> and locate the following:</p>
<div id="highlighter_252973">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;h2 </code><code>class</code><code>=</code><code>"pagetitle"</code><code>&gt;Search Results&lt;/h2&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>And replace it with this code:</p>
<div id="highlighter_77207">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;h2 </code><code>class</code><code>=</code><code>"pagetitle"</code><code>&gt;Search Result </code><code>for</code> <code>&lt;?php </code><code>/* Search Count */</code> <code>$allsearch</code> <code>= &amp;</code><code>new</code> <code>WP_Query(</code><code>"s=$s&amp;showposts=-1"</code><code>); </code><code>$key</code> <code>= wp_specialchars(</code><code>$s</code><code>, 1); </code><code>$count</code> <code>= </code><code>$allsearch</code><code>-&gt;post_count; _e(</code><code>''</code><code>); _e(</code><code>'&lt;span&gt;'</code><code>); </code><code>echo</code> <code>$key</code><code>; _e(</code><code>'&lt;/span&gt;'</code><code>); _e(</code><code>' &amp;mdash; '</code><code>); </code><code>echo</code> <code>$count</code> <code>. </code><code>' '</code><code>; _e(</code><code>'articles'</code><code>); wp_reset_query(); ?&gt;&lt;/h2&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://www.problogdesign.com/wordpress/3-codes-for-a-far-better-wordpress-search-page/">problogdesign.com →</a></p>
<h2>Highlight WordPress Search Terms with jQuery</h2>
<p>To  help make your search results that little bit clearer to your readers,  you could use this snippet which will highlight the searched term within  the results.</p>
<p>Copy and paste the following code into your theme’s <code><b>functions.php</b></code> file:</p>
<div id="highlighter_658939">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>01</code></td>
<td><code>function</code> <code>hls_set_query() {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>02</code></td>
<td><code> </code><code>$query</code> <code>= attribute_escape(get_search_query());</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>03</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>04</code></td>
<td><code> </code><code>if</code><code>(</code><code>strlen</code><code>(</code><code>$query</code><code>) &gt; 0){</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>05</code></td>
<td><code> </code><code>echo</code> <code>'</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>06</code></td>
<td><code> </code><code>&lt;script type=</code><code>"text/javascript"</code><code>&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>07</code></td>
<td><code> </code><code>var</code> <code>hls_query&nbsp; = </code><code>"'.$query.'"</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>08</code></td>
<td><code> </code><code>&lt;/script&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>09</code></td>
<td><code> </code><code>';</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>10</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>11</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>12</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>13</code></td>
<td><code>function</code> <code>hls_init_jquery() {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>14</code></td>
<td><code> </code><code>wp_enqueue_script(</code><code>'jquery'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>15</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>16</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>17</code></td>
<td><code>add_action(</code><code>'init'</code><code>, </code><code>'hls_init_jquery'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>18</code></td>
<td><code>add_action(</code><code>'wp_print_scripts'</code><code>, </code><code>'hls_set_query'</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>And then add this code into your <code><b>header.php</b></code> file, just before the <code><b>/head</b></code> tag:</p>
<div id="highlighter_933010">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>01</code></td>
<td><code>&lt;style type=</code><code>"text/css"</code> <code>media=</code><code>"screen"</code><code>&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>02</code></td>
<td><code> </code><code>.hls { background: #D3E18A; }</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>03</code></td>
<td><code> </code><code>&lt;/style&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>04</code></td>
<td><code> </code><code>&lt;script type=</code><code>"text/javascript"</code><code>&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>05</code></td>
<td><code> </code><code>jQuery.fn.extend({</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>06</code></td>
<td><code> </code><code>highlight: </code><code>function</code><code>(search, insensitive, hls_class){</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>07</code></td>
<td><code> </code><code>var</code> <code>regex = </code><code>new</code> <code>RegExp(</code><code>"(&lt;[^&gt;]*&gt;)|(\\b"</code><code>+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,</code><code>"\\$1"</code><code>) +</code><code>")"</code><code>, insensitive ? </code><code>"ig"</code> <code>: </code><code>"g"</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>08</code></td>
<td><code> </code><code>return</code> <code>this.html(this.html().replace(regex, </code><code>function</code><code>(a, b, c){</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>09</code></td>
<td><code> </code><code>return</code> <code>(a.charAt(0) == </code><code>"&lt;"</code><code>) ? a : </code><code>"&lt;strong class=\""</code><code>+ hls_class +</code><code>"\"&gt;"</code> <code>+ c + </code><code>"&lt;/strong&gt;"</code><code>;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>10</code></td>
<td><code> </code><code>}));</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>11</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>12</code></td>
<td><code> </code><code>});</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>13</code></td>
<td><code> </code><code>jQuery(document).ready(</code><code>function</code><code>($){</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>14</code></td>
<td><code> </code><code>if</code><code>(typeof(hls_query) != </code><code>'undefined'</code><code>){</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>15</code></td>
<td><code> </code><code>$(</code><code>"#post-area"</code><code>).highlight(hls_query, 1, </code><code>"hls"</code><code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>16</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>17</code></td>
<td><code> </code><code>});</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>18</code></td>
<td><code> </code><code>&lt;/script&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/">weblogtoolscollection.com →</a></p>
<h2>Disable WordPress Search</h2>
<p>If you are looking for a way to disable all of WordPress’ search functionality, you could use this small snippet.</p>
<p>All you have to do is copy and paste the code below into your <code><b>functions.php</b></code> file.</p>
<div id="highlighter_232890">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>01</code></td>
<td><code>function</code> <code>fb_filter_query( </code><code>$query</code><code>, </code><code>$error</code> <code>= true ) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>02</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>03</code></td>
<td><code> </code><code>if</code> <code>( is_search() ) {</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>04</code></td>
<td><code> </code><code>$query</code><code>-&gt;is_search = false;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>05</code></td>
<td><code> </code><code>$query</code><code>-&gt;query_vars[s] = false;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>06</code></td>
<td><code> </code><code>$query</code><code>-&gt;query[s] = false;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>07</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>08</code></td>
<td><code> </code><code>// to error</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>09</code></td>
<td><code> </code><code>if</code> <code>( </code><code>$error</code> <code>== true )</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>10</code></td>
<td><code> </code><code>$query</code><code>-&gt;is_404 = true;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>11</code></td>
<td><code> </code><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>12</code></td>
<td><code>}</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>13</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>14</code></td>
<td><code>add_action( </code><code>'parse_query'</code><code>, </code><code>'fb_filter_query'</code> <code>);</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>15</code></td>
<td><code>add_filter( </code><code>'get_search_form'</code><code>, create_function( </code><code>'$a'</code><code>, </code><code>"return null;"</code> <code>) );</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://wpengineer.com/1042/disable-wordpress-search/">wpengineer.com →</a></p>
<h2>Make your WordPress Search Results Unlimited</h2>
<p>Sometimes  you may not want your search results to be limited by the confines of  the standard WordPress Loop. This snippet allows your search to return  unlimited results.</p>
<p>In <code><b>search.php</b></code> you can add the following code <b>above</b> the loop for this functionality.</p>
<p>First of all find this code within <code><b>search.php</b></code>:</p>
<div id="highlighter_930943">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;?php </code><code>if</code> <code>(have_posts()) : ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>2</code></td>
<td><code>&lt;?php </code><code>while</code> <code>(have_posts()) : the_post(); ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>And then add this code:</p>
<div id="highlighter_892548">
<div>
<div><a title="view source" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#viewSource">view source</a><a title="print" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#printSource">print</a><a title="?" href="http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/#about">?</a></div>
</div>
<div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>1</code></td>
<td><code>&lt;?php </code><code>$posts</code><code>=query_posts(</code><code>$query_string</code> <code>. </code><code>'&amp;posts_per_page=-1'</code><code>); ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>2</code></td>
<td><code>&lt;?php </code><code>if</code> <code>(have_posts()) : ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="mceItemTable">
<tbody>
<tr>
<td><code>3</code></td>
<td><code>&lt;?php </code><code>while</code> <code>(have_posts()) : the_post(); ?&gt;</code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>Source: <a href="http://wphacks.com/how-to-make-wordpress-search-results-unlimited/">wphacks.com →</a></p>
<h2><a href="http://davidwalsh.name/google-ajax-search">Implement Google AJAX Search API</a><br /></h2>
<p><a href="http://davidwalsh.name/google-ajax-search"><img src="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_01.jpg" alt="Implement Google AJAX Search API"></a><a href="http://davidwalsh.name/google-ajax-search">Implement Google AJAX Search API →</a><br />
<a href="http://davidwalsh.name/dw-content/google-ajax-search.php">Demo →</a><br />
Google provides an awesome method in which you can use their search for  your own site: the Google AJAX Search API. In this advanced tutorial  you will be shown how to implement this awesome API within your own  website.<br />
Google&#8217;s AJAX Search API requires that you sign up for an API key, you can get it here: <a href="http://code.google.com/apis/ajaxsearch/key.html">Google AJAX Search API</a></p>
<h2><a href="http://wphacks.com/how-to-create-an-ajax-based-autocompleting-search-field-for-your-wordpress-theme/">Create an Ajax-based Auto-completing Search Field for WordPress</a><br /></h2>
<p><a href="http://wphacks.com/how-to-create-an-ajax-based-autocompleting-search-field-for-your-wordpress-theme/"><img src="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_02.jpg" alt="Create an Ajax-based Auto-completing Search Field for WordPress"></a><a href="http://wphacks.com/how-to-create-an-ajax-based-autocompleting-search-field-for-your-wordpress-theme/">Create an Ajax-based Auto-completing Search Field for WordPress →</a><br />
When someone starts to type with the search field they will be  presented with a drop-down box offering suggestions. This tutorial will  show you how to implement thsi on your own site.<br />
Please note that even if this code is fully functional, this is an experimentation, and the SQL query isn’t really optimized.</p>
<h2><a href="http://www.divisionbyzero.co.uk/2010/07/23/add-a-google-custom-search-engine-to-your-wordpress-blog/">How To Add Google Custom Search To WordPress</a><br /></h2>
<p><a href="http://www.divisionbyzero.co.uk/2010/07/23/add-a-google-custom-search-engine-to-your-wordpress-blog/"><img src="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_03.jpg" alt="How To Add Google Custom Search To WordPress"></a><a href="http://www.google.com/cse/">Google Custom Search Engine →</a><br />
In this tutorial you will be shown how to integrate Google’s Custom  Search Engine into your blog, making it easier for your readers to find  content and allow you to make some money with Adsense.<br />
<a href="http://www.divisionbyzero.co.uk/2010/07/23/add-a-google-custom-search-engine-to-your-wordpress-blog/">How To Add Google Custom Search To WordPress →</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=146&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/09/25/10-useful-wordpress-search-code-snippets-september-19-2010-14-comments-web-designwordpress-create-a-free-website-rss-del-icio-us-stumbleupon-digg-twitthis-mixx/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>

		<media:content url="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_01.jpg" medium="image">
			<media:title type="html">Implement Google AJAX Search API</media:title>
		</media:content>

		<media:content url="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_02.jpg" medium="image">
			<media:title type="html">Create an Ajax-based Auto-completing Search Field for WordPress</media:title>
		</media:content>

		<media:content url="http://speckyboy.com/wp-content/uploads/2010/09/wp_search_03.jpg" medium="image">
			<media:title type="html">How To Add Google Custom Search To WordPress</media:title>
		</media:content>
	</item>
		<item>
		<title>Esconder informações sobre a versão do wordpress e sobre o tema em uso</title>
		<link>http://meucodex.wordpress.com/2010/08/21/esconder-informacoes-sobre-a-versao-do-wordpress-e-sobre-o-tema-em-uso/</link>
		<comments>http://meucodex.wordpress.com/2010/08/21/esconder-informacoes-sobre-a-versao-do-wordpress-e-sobre-o-tema-em-uso/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 09:04:12 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[templates]]></category>
		<category><![CDATA[Versão]]></category>
		<category><![CDATA[customização]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[manha]]></category>
		<category><![CDATA[versão]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=144</guid>
		<description><![CDATA[O objetivo é esconder informações sobre a versão do wordpress e sobre o tema em uso No arquivo wp-admin/includes/dashboard.php Comenta a linha 367 (versão 3.0.1) //printf(_n(&#8216;Theme &#60;span&#62;%1$s&#60;/span&#62; with &#60;span&#62;%2$s Widget&#60;/span&#62;&#8217;, &#8216;Theme &#60;span&#62;%1$s&#60;/span&#62; with &#60;span&#62;%2$s Widgets&#60;/span&#62;&#8217;, $num_widgets), $switch_themes, $num);} para não exibir o thema atual Na linha 378 (versão 3.0.1) Acrescenta um if para que usuários [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=144&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>O objetivo é esconder informações sobre a versão do wordpress e sobre o tema em uso</p>
<p><strong>No arquivo wp-admin/includes/dashboard.php</strong></p>
<ul>
<li>Comenta a linha 367 (versão 3.0.1)<br />
//printf(_n(&#8216;Theme &lt;span&gt;%1$s&lt;/span&gt; with &lt;span&gt;%2$s Widget&lt;/span&gt;&#8217;, &#8216;Theme &lt;span&gt;%1$s&lt;/span&gt; with &lt;span&gt;%2$s Widgets&lt;/span&gt;&#8217;, $num_widgets), $switch_themes, $num);}<br />
para não exibir o thema atual</li>
</ul>
<ul>
<li> Na linha 378 (versão 3.0.1)<br />
Acrescenta um if para que usuários pouco privilegiados não vejam  a mensagem que o wordpress precisa ser atualizado<br />
if ( current_user_can( &#8216;switch_themes&#8217;) ) {<br />
update_right_now_message();<br />
}</li>
</ul>
<p>===============================================================</p>
<p>http://wordpress.org/extend/plugins/hide-update-reminder/</p>
<h2>Hide Update Reminder</h2>
<p>Hides the Update Reminder in the Admin for all non Admin users.</p>
<p>This plugin allows you to hide the update WordPress reminder from  all users that are not assumed Administrators (cannot upgrade plugins).</p>
<p>If you have multiple users then this means those who are not admins  don&#8217;t need to see the message. Useful for CMS based sites, so the client  doesn&#8217;t see the notice.</p>
<div><strong>Author:</strong> sarahg111</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=144&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/08/21/esconder-informacoes-sobre-a-versao-do-wordpress-e-sobre-o-tema-em-uso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>
	</item>
		<item>
		<title>15 fantásticos comandos SQL para WordPress</title>
		<link>http://meucodex.wordpress.com/2010/08/08/15-fantasticos-comandos-sql-para-wordpress/</link>
		<comments>http://meucodex.wordpress.com/2010/08/08/15-fantasticos-comandos-sql-para-wordpress/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 16:04:12 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[banco de dados]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[dicas]]></category>
		<category><![CDATA[migrar wordpress]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=135</guid>
		<description><![CDATA[Para quem faz uso um pouco mais avançado do WordPress, especialmente quem trabalha desenvolvendo sites com a plataforma, é bem comum aparecerem situações um tanto complexas. Para estas questões, seguem 13 fantásticos comandos SQL para WordPress!
Este é um artigo traduzido do original “13 Useful WordPress SQL Queries You Wish You Knew Earlier“, do blog Onextrapixel, e sofreu algumas adaptações.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=135&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Você encontra este artigo, mais bonito e organizado, e quem sabe até mais atualizado em: <a href="http://desenvolvimentoparaweb.com/wordpress/15-comandos-sql-wordpress/" target="_blank">http://desenvolvimentoparaweb.com/wordpress/15-comandos-sql-wordpress/</a></strong></p>
<p>Para quem faz uso um pouco mais avançado do <a href="http://desenvolvimentoparaweb.com/categoria/wordpress/">WordPress</a>,  especialmente quem trabalha desenvolvendo sites com a plataforma, é bem  comum aparecerem situações um tanto complexas. Para estas questões,  seguem <strong>13 fantásticos comandos SQL para WordPress</strong>!</p>
<div>Este é um artigo traduzido do original “<a title="Ler o artigo original" href="http://www.onextrapixel.com/2010/01/30/13-useful-wordpress-sql-queries-you-wish-you-knew-earlier/">13  Useful WordPress SQL Queries You Wish You Knew Earlier</a>“, do blog <a href="http://www.onextrapixel.com/">Onextrapixel</a>, e sofreu algumas  adaptações.</div>
<p>Uma maneira prática de executar comandos SQL é através do phpMyAdmin.  Até a hospedagem mais básica dá acesso à ferramenta de banco de dados,  então não há dificuldades nisso. Uma vez no sistema, você deve  selecionar aba “SQL” e escrever/colar a instrução SQL que deseja  executar.</p>
<p><img src="http://desenvolvimentoparaweb.com/wp-content/uploads/2010/05/13-comandos-sql-wordpress-phpmyadmin.jpg" alt="13 fantásticos comandos SQL para WordPress: aba SQL do phpMyAdmin" width="580" height="263" /></p>
<div>Os comandos SQL para WordPress a seguir são para o  prefixo padrão do WordPress “wp_”. Caso o prefixo de suas tabelas seja  diferente (o que é recomendado, por questões de segurança), faça os  devidos complementos necessários às queries.</div>
<h3 id="alterar-siteurl-e-homeurl">1. Alterar siteurl e homeurl</h3>
<p>WordPress armazena o caminho absoluto da URL do site (“siteurl”) e  URL da home (“homeurl”) no banco de dados. Portanto, se você transferir o  seu site WordPress do localhost para o servidor, por exemplo, o site  não vai carregar! Isso ocorre porque o caminho absoluto ainda está  apontando para o seu localhost. Você vai precisar executar um comando  para resolver isso.</p>
<div>
<div>
<pre>UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://www.enderecoantigo.com', 'http://www.endereconovo.com')
WHERE option_name = 'home'
OR option_name = 'siteurl';</pre>
</div>
</div>
<h3 id="alterar-guid">2. Alterar GUID</h3>
<p>Depois de migrar seu blog a partir de, por exemplo, localhost, para o  servidor ou de um outro domínio para um novo domínio, você terá que  corrigir as URLs para o campo GUID na tabela wp_posts. Isto é crucial,  porque GUID é usado para montar o slug de seu post do caminho absoluto  do artigo correto.</p>
<div>
<div>
<pre>UPDATE wp_posts
SET guid = REPLACE (guid, 'http://www.enderecoantigo.com', 'http://www.endereconovo.com');</pre>
</div>
</div>
<h3 id="alterar-url-no-contedo">3. Alterar URL no conteúdo</h3>
<p>O WordPress utiliza caminhos absolutos no URL ao invés de um caminho  relativo quando vai armazená-los no banco de dados. Dentro do conteúdo  de cada registro de artigo, ele armazena todas as URLs antigas  referenciando as fontes antigas. Portanto, você precisará alterar todas  essas URLs com o endereço do novo domínio.</p>
<div>
<div>
<pre>UPDATE wp_posts
SET post_content = REPLACE (post_content, 'http://www.enderecoantigo.com', 'http://www.endereconovo.com');</pre>
</div>
</div>
<h3 id="alterar-apenas-o-caminho-das-imagens">4. Alterar apenas o  caminho das imagens</h3>
<p>Caso seja preciso alterar o domínio das imagens inseridas nas páginas  e artigos, esta solução vai ajudar você a fazer isso de forma simples.</p>
<div>
<div>
<pre>UPDATE wp_posts
SET post_content = REPLACE (post_content, 'src="http://www.enderecoantigo.com', 'src="http://www.endereconovo.com');</pre>
</div>
</div>
<p>Também é preciso atualizar o GUID para o tipo “attachment” com a  seguinte instrução SQL:</p>
<div>
<div>
<pre>UPDATE wp_posts
SET guid = REPLACE (guid, 'http://www.enderecoantigo.com', 'http://www.endereconovo.com') WHERE post_type = 'attachment';</pre>
</div>
</div>
<h3 id="atualizar-post-meta">5. Atualizar Post Meta</h3>
<p>Atualizar Post Meta funciona quase da mesma maneira como atualizar a  URL no conteúdo do post. Se você tiver dados extras para cada post, você  pode usar a seguinte instrução para alterar todos eles.</p>
<div>
<div>
<pre>UPDATE wp_postmeta
SET meta_value = REPLACE (meta_value, 'http://www.enderecoantigo.com','http://www.endereconovo.com');</pre>
</div>
</div>
<h3 id="alterar-o-nome-usurio-padro-admin">6. Alterar o nome usuário  padrão “admin”</h3>
<p>Apesar de que na versão 3 do WordPress o usuário “admin” poderá ser  alterado no momento da instalação, não custa deixar para a posteridade a  dica de como alterar o nome do “admin”.</p>
<div>
<div>
<pre>UPDATE wp_users
SET user_login = 'nomequevocequiser'
WHERE user_login = 'Admin';</pre>
</div>
</div>
<h3 id="resetar-password">7. Resetar password</h3>
<p>Já quis resetar sua senha no WordPress mas, por algum motivo, não  conseguiu usar a seção para resetar o password? Eis a solução:</p>
<div>
<div>
<pre>UPDATE wp_users
SET user_pass = MD5('senha')
WHERE user_login = 'login';</pre>
</div>
</div>
<h3 id="transferir-artigos-de-um-autor-para-outro">8. Transferir artigos  de um autor para outro</h3>
<p>Para transferir os artigos de um autor para outro, você gasta um  tempo enorme se fizer isso manualmente. Com o comando SQL a seguir, é  possível fazer isso facilmente. Para a dica, é preciso <a href="http://www.google.com.br/search?q=obtain+author+id+wordpress">saber  o ID dos autores</a>.</p>
<div>
<div>
<pre>UPDATE wp_posts
SET post_author = 'id_novo_autor'
WHERE post_author = 'id_autor_antigo';</pre>
</div>
</div>
<h3 id="apagar-revises">9. Apagar revisões</h3>
<p>Quando se está editando um artigo no WordPress, é comum cópias de  segurança serem feitas para garantir o trabalho feito. São as chamadas  “revisões”. Com o tempo, o número de registros de revisões fica grande e  isso pode comprometer a performance do banco de dados. Para apagar  todas as revisões de artigos, dê o seguinte comando SQL:</p>
<div>
<div>
<pre>DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'</pre>
</div>
</div>
<h3 id="apagar-post-meta">10. Apagar post meta</h3>
<p>Instalar e remover plugins é algo corriqueiro quando se trabalha com  WordPress. Alguns plugins precisam de criar alguns post meta para  funcionarem corretamente e, para esses casos, não é raro o acontecimento  de, mesmo depois de o plugin ser desinstalado, algum “garbage meta”  ficar enchendo o BD desnecessariamente. Uma limpeza em algum valor de  post meta, às vezes, se faz necessária.</p>
<div>
<div>
<pre>DELETE FROM wp_postmeta
WHERE meta_key = 'nome-chave-meta';</pre>
</div>
</div>
<h3 id="exportar-todos-os-emails-de-comentrios">11. Exportar todos os  e-mails de comentários</h3>
<p>Quanto mais tempo seu blog/site fica no ar, é provável que mais  comentários receba nos artigos publicados. Se, por algum motivo, for  preciso uma listagem com e-mail de todas as pessoas que já comentaram  até então, basta executar o seguinte comando:</p>
<div>
<div>
<pre>SELECT DISTINCT comment_author_email
FROM wp_comments;</pre>
</div>
</div>
<p>Uma vez que a listagem esteja concluída, exporte tudo através do  phpMyAdmin.</p>
<h3 id="apagar-todos-pingbacks">12. Apagar todos pingbacks</h3>
<p>A medida que o site/blog fica no ar – e se você tiver bom conteúdo a  oferecer – o número de pingbacks começa a influenciar a qualidade do  banco de dados. Para apagar todos pingbacks, proceda da seguinte  maneira:</p>
<div>
<div>
<pre>DELETE FROM wp_comments WHERE comment_type = 'pingback';</pre>
</div>
</div>
<h3 id="apagar-todos-comentrios-de-spam">13. Apagar todos comentários de  SPAM</h3>
<p>Sem maiores explicações, eis a maneira de deletar todos os  comentários marcados como SPAM:</p>
<div>
<div>
<pre>DELETE FROM wp_comments
WHERE comment_approved = 'spam';</pre>
</div>
</div>
<h3 id="identificar-tags-no-usadas">14. Identificar tags não usadas</h3>
<p>Num banco de dados WordPress, se você executar alguma query SQL para  apagar posts, as tags relacionadas não serão apagadas e continuarão  aparecendo na nuvem de sugestão de tags e listagem de tags. Para  identificar esse tipo de tag, execute a seguinte instrução SQL:</p>
<div>
<div>
<pre>SELECT * FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt
ON wt.term_id=wtt.term_id
WHERE wtt.taxonomy='post_tag'
AND wtt.count=0;</pre>
</div>
</div>
<div>Lembre-se: é sempre bom fazer um backup completo de  seu banco de dados antes de executar queries SQL (principalmente se  você não souber muito bem o que está fazendo)!</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=135&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/08/08/15-fantasticos-comandos-sql-para-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>

		<media:content url="http://desenvolvimentoparaweb.com/wp-content/uploads/2010/05/13-comandos-sql-wordpress-phpmyadmin.jpg" medium="image">
			<media:title type="html">13 fantásticos comandos SQL para WordPress: aba SQL do phpMyAdmin</media:title>
		</media:content>
	</item>
		<item>
		<title>headers already sent</title>
		<link>http://meucodex.wordpress.com/2010/07/19/headers-already-sent/</link>
		<comments>http://meucodex.wordpress.com/2010/07/19/headers-already-sent/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 15:21:40 +0000</pubDate>
		<dc:creator>Vinicius Castro</dc:creator>
				<category><![CDATA[erro]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[headers]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://meucodex.wordpress.com/?p=131</guid>
		<description><![CDATA[Maldito &#8220;Warning: session_start() [function.session-start]: Cannot send session cache limiter &#8211; headers already sent&#8221; Usando o notepad++ marcando a opção mostrada na imagem abaixo, o maldito warning sumiu. Entenda melhor: http://kasolutions.wordpress.com/2009/07/14/fix-warning-session_start-function-session-start-cannot-send-session-cache-limiter-headers-already-sent/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=131&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Maldito &#8220;Warning</strong>:  session_start() [function.session-start]:  Cannot send session cache limiter &#8211; headers already sent&#8221;</p>
<p>Usando o notepad++ marcando a opção mostrada na imagem abaixo, o maldito warning sumiu.</p>
<p><a href="http://meucodex.files.wordpress.com/2010/07/headers-sents-error.jpg"><img class="aligncenter size-full wp-image-132" title="headers already sent" src="http://meucodex.files.wordpress.com/2010/07/headers-sents-error.jpg?w=600&#038;h=225" alt="" width="600" height="225" /></a></p>
<p>Entenda melhor: <a href="http://kasolutions.wordpress.com/2009/07/14/fix-warning-session_start-function-session-start-cannot-send-session-cache-limiter-headers-already-sent/" target="_blank">http://kasolutions.wordpress.com/2009/07/14/fix-warning-session_start-function-session-start-cannot-send-session-cache-limiter-headers-already-sent/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/meucodex.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/meucodex.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/meucodex.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=meucodex.wordpress.com&amp;blog=5755414&amp;post=131&amp;subd=meucodex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://meucodex.wordpress.com/2010/07/19/headers-already-sent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>-10.909542 -37.074773</georss:point>
		<geo:lat>-10.909542</geo:lat>
		<geo:long>-37.074773</geo:long>
		<media:content url="http://0.gravatar.com/avatar/0f85cbc25d8dbd257f9099da2225e020?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viniciusac</media:title>
		</media:content>

		<media:content url="http://meucodex.files.wordpress.com/2010/07/headers-sents-error.jpg" medium="image">
			<media:title type="html">headers already sent</media:title>
		</media:content>
	</item>
	</channel>
</rss>
