<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Php on jpcercal.com</title><link>https://jpcercal.com/en/categories/php/</link><description>Recent content in Php on jpcercal.com</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 22 Oct 2013 12:05:38 +0000</lastBuildDate><atom:link href="https://jpcercal.com/en/categories/php/index.xml" rel="self" type="application/rss+xml"/><item><title>WordPress Tip: How to use Shortcodes</title><link>https://jpcercal.com/en/wordpress-tip-how-to-use-shortcodes/</link><pubDate>Tue, 22 Oct 2013 12:05:38 +0000</pubDate><guid>https://jpcercal.com/en/wordpress-tip-how-to-use-shortcodes/</guid><description>&lt;p&gt;Since version &lt;em&gt;2.5+&lt;/em&gt;, &lt;em&gt;WordPress&lt;/em&gt; has had a feature known as &lt;em&gt;shortcodes&lt;/em&gt;, it works similarly to&#10;filters, because they accept parameters (attributes) and return a result.&lt;/p&gt;&#10;&lt;p&gt;Well, shortcodes are extremely useful and easy to use, allowing developers to create&#10;custom content for users to add to their pages.&lt;/p&gt;&#10;&lt;p&gt;Next we&amp;rsquo;ll see how simple it is to add a shortcode to your theme. So we&amp;rsquo;ll get to know the&#10;&lt;code&gt;do_shortcode()&lt;/code&gt; function.&lt;/p&gt;&#10;&lt;p&gt;To use this function, just add the following code to your theme:&lt;/p&gt;</description></item><item><title>WordPress Tip: How to check whether a plugin is active?</title><link>https://jpcercal.com/en/wordpress-tip-how-to-check-whether-a-plugin-is-active/</link><pubDate>Wed, 28 Aug 2013 17:40:54 +0000</pubDate><guid>https://jpcercal.com/en/wordpress-tip-how-to-check-whether-a-plugin-is-active/</guid><description>&lt;p&gt;When you&amp;rsquo;re developing a theme or a &lt;em&gt;plugin&lt;/em&gt; for the &lt;em&gt;WordPress&lt;/em&gt; platform, you may need to check&#10;whether a specific &lt;em&gt;plugin&lt;/em&gt; is activated. Well, here&amp;rsquo;s a simple &lt;em&gt;script&lt;/em&gt; to check whether a &lt;em&gt;plugin&lt;/em&gt;&#10;is activated or not in the &lt;em&gt;wordpress&lt;/em&gt; administration panel.&lt;/p&gt;&#10;&lt;p&gt;You&amp;rsquo;ll only need to change line 4 to your &lt;em&gt;plugin&amp;rsquo;s&lt;/em&gt; directory name.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;Plugins&lt;/em&gt; are located in the directory: &lt;code&gt;/wp-content/plugins/&lt;/code&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Adicione esta linha se este pedaço de código&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// não estiver sendo executado no painel administrativo&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;require_once&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ABSPATH&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/wp-admin/includes/plugin.php&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Verifica se o plugin está ativado...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;is_plugin_active&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;plugin-directory/plugin-file.php&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;// o plugin está ativado...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;// O plugin está desativado...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That was another tip for the &lt;em&gt;WordPress&lt;/em&gt; platform.&lt;/p&gt;</description></item><item><title>How and Why you should include jQuery from Google CDN in WP</title><link>https://jpcercal.com/en/how-and-why-you-should-include-jquery-from-google-cdn-in-wp/</link><pubDate>Mon, 26 Aug 2013 17:30:19 +0000</pubDate><guid>https://jpcercal.com/en/how-and-why-you-should-include-jquery-from-google-cdn-in-wp/</guid><description>&lt;p&gt;&lt;em&gt;jQuery&lt;/em&gt; is a library widely used for web development, and in &lt;em&gt;WordPress&lt;/em&gt; we have this library included in the &lt;em&gt;default&lt;/em&gt; installation package.&lt;/p&gt;&#10;&lt;p&gt;In this article, I&amp;rsquo;ll show you how and why you should replace &lt;em&gt;WordPress&amp;rsquo;s&lt;/em&gt; &lt;em&gt;default&lt;/em&gt; &lt;em&gt;jQuery&lt;/em&gt; with &lt;em&gt;jQuery&lt;/em&gt; from &lt;em&gt;Google CDN (Content Distribution Network)&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;But why should you replace it?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Generally speaking, you should do this so the script loads faster for the end user.&lt;/p&gt;&#10;&lt;p&gt;Here are the points that should lead you to adopt this practice.&lt;/p&gt;</description></item><item><title>Installing PHPUnit on OSX 10.8 Mountain Lion</title><link>https://jpcercal.com/en/installing-phpunit-on-osx-10-8-mountain-lion/</link><pubDate>Sat, 24 Aug 2013 15:00:39 +0000</pubDate><guid>https://jpcercal.com/en/installing-phpunit-on-osx-10-8-mountain-lion/</guid><description>&lt;p&gt;Hello, today I&amp;rsquo;ll demonstrate how to install PHPUnit on &lt;em&gt;Apple&amp;rsquo;s&lt;/em&gt; operating system. This guide should also be&#10;compatible with earlier operating systems in the apple family, such as &lt;em&gt;Snow Leopard&lt;/em&gt; and &lt;em&gt;Lion&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;If you use the Microsoft Windows operating system, you can read this other tutorial:&#10;&lt;a href="https://jpcercal.com/en/installing-phpunit-on-windows/" title="Installing PHPUnit on Windows"&gt;Installing PHPUnit on Windows&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Well, let&amp;rsquo;s install PHPUnit on OSX.&lt;/p&gt;&#10;&lt;p&gt;Open the Terminal and check whether &lt;em&gt;PEAR&lt;/em&gt; is already installed with the following command.&lt;/p&gt;</description></item><item><title>WordPress Hack: How to get a Post's content by ID</title><link>https://jpcercal.com/en/wordpress-hack-how-to-get-a-posts-content-by-id/</link><pubDate>Fri, 23 Aug 2013 14:52:26 +0000</pubDate><guid>https://jpcercal.com/en/wordpress-hack-how-to-get-a-posts-content-by-id/</guid><description>&lt;p&gt;When you&amp;rsquo;re building a theme for WordPress, you may need to get the content of a specific post&#10;using the &lt;strong&gt;ID&lt;/strong&gt; as a filter. Most of the time you get a post&amp;rsquo;s content through the &lt;em&gt;get_post_content&lt;/em&gt; function&#10;inside a &lt;em&gt;Loop&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;However, when you need to retrieve a post&amp;rsquo;s information outside the &lt;em&gt;loop&lt;/em&gt; context or at a separate point&#10;in the application, the best solution is to use the &lt;code&gt;get_post_field('field-name'), $postId)&lt;/code&gt; function.&lt;/p&gt;</description></item><item><title>Installing PEAR on OSX 10.8 Mountain Lion</title><link>https://jpcercal.com/en/installing-pear-on-osx-10-8-mountain-lion/</link><pubDate>Thu, 04 Apr 2013 22:28:01 +0000</pubDate><guid>https://jpcercal.com/en/installing-pear-on-osx-10-8-mountain-lion/</guid><description>&lt;p&gt;Folks, this time we&amp;rsquo;ll learn to install &lt;em&gt;PEAR&lt;/em&gt; on &lt;em&gt;Apple&amp;rsquo;s&lt;/em&gt; operating system. This guide should also be compatible&#10;with earlier operating systems in the apple family, such as &lt;em&gt;Snow Leopard&lt;/em&gt; and &lt;em&gt;Lion&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;Well, let&amp;rsquo;s share the recipe.&lt;/p&gt;&#10;&lt;p&gt;Open the Terminal and check whether &lt;em&gt;PEAR&lt;/em&gt; is already installed with the following command.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ pear version&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it isn&amp;rsquo;t installed, the command&amp;rsquo;s output should look like:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pear: &lt;span class="nb"&gt;command&lt;/span&gt; not found&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If you saw the message above, then we can install pear, because it isn&amp;rsquo;t on your operating system.&lt;/p&gt;</description></item><item><title>How to get a Page Permalink</title><link>https://jpcercal.com/en/how-to-get-a-page-permalink/</link><pubDate>Sat, 09 Feb 2013 10:17:18 +0000</pubDate><guid>https://jpcercal.com/en/how-to-get-a-page-permalink/</guid><description>&lt;p&gt;Today we needed to get the &lt;strong&gt;permalink&lt;/strong&gt; of a page in &lt;em&gt;WordPress&lt;/em&gt; whose &lt;em&gt;post_type&lt;/em&gt; is &amp;ldquo;&lt;em&gt;page&lt;/em&gt;&amp;rdquo;. To do this, we had to&#10;combine two functions, which are: &lt;code&gt;get_permalink()&lt;/code&gt; and &lt;code&gt;get_page_by_path()&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;How to Get a Page Permalink using the Page Name:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&amp;lt;?php echo get_permalink( get_page_by_path(&amp;#39;Eventos&amp;#39;) ); ?&amp;gt;&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt; &lt;span class="nx"&gt;_e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Eventos&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;jpcercal.com&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="err"&gt;&amp;lt;/a&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;How to Get a Page Permalink using the Page Slug:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&amp;lt;?php echo get_permalink( get_page_by_path(&amp;#39;cadastrar-cliente&amp;#39;) ); ?&amp;gt;&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt; &lt;span class="nx"&gt;_e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Cadastrar Cliente&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;jpcercal.com&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="err"&gt;&amp;lt;/a&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note About Page Hierarchy and Slugs.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Excerpts on WordPress 3.0+ pages</title><link>https://jpcercal.com/en/excerpts-on-wordpress-3-0-pages/</link><pubDate>Sun, 09 Dec 2012 03:12:27 +0000</pubDate><guid>https://jpcercal.com/en/excerpts-on-wordpress-3-0-pages/</guid><description>&lt;p&gt;If you&amp;rsquo;ve ever needed to add excerpts to pages in WordPress 3.0+, you can be happy because the tip is&#10;very simple. Just add the following code to a file that wordpress loads automatically.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt;/**&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; * @param string $post_type&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; * @param string|array $supports&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="sd"&gt; */&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;add_post_type_support&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;search&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;excerpt&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Usually the code above is placed in an &amp;ldquo;init&amp;rdquo; &lt;em&gt;action hook&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;This will enable a new field in the administration panel, letting you add an &lt;strong&gt;excerpt&lt;/strong&gt; to your&#10;&lt;strong&gt;pages&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Installing PHPUnit on Windows</title><link>https://jpcercal.com/en/installing-phpunit-on-windows/</link><pubDate>Wed, 06 Jun 2012 21:07:19 +0000</pubDate><guid>https://jpcercal.com/en/installing-phpunit-on-windows/</guid><description>&lt;p&gt;Hello person(s), today I&amp;rsquo;ll present a step-by-step guide to installing PHPUnit on Uncle Bil Gates&amp;rsquo; famous&#10;operating system, Microsoft Windows 7 (Seven), before continuing with the tutorial I wanted to talk a little about unit&#10;tests and test-driven development (the famous TDD – Test Driven Development).&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;So, what is TDD?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;TDD is a method for building software, not just testing it. Through the &amp;ldquo;Red&amp;rdquo;, &amp;ldquo;Green&amp;rdquo;,&#10;&amp;ldquo;Refactoring&amp;rdquo; process, you notice that the code becomes clean, organized and best of all, working!&lt;/p&gt;</description></item><item><title>PHP 5.4 Release</title><link>https://jpcercal.com/en/php-5-4-release/</link><pubDate>Fri, 02 Mar 2012 04:26:38 +0000</pubDate><guid>https://jpcercal.com/en/php-5-4-release/</guid><description>&lt;p&gt;Hey folks! I&amp;rsquo;ve just seen, this very moment, that &lt;strong&gt;PHP 5.4&lt;/strong&gt; is fresh out of the oven, which you can check&#10;directly on the official &lt;a href="http://php.net/releases/5_4_0.php"&gt;PHP&lt;/a&gt; website.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="php.jpg" alt="PHP 5.4 Released" loading="lazy" decoding="async" title="PHP"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This version includes a large number of new features and bug fixes. If you&amp;rsquo;re not familiar with PHP yet,&#10;read the following post: &lt;a href="https://jpcercal.com/en/introduction-to-php/" title="Introduction&#10;to PHP"&gt;Introduction to PHP&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Among the main new features are:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Traits&lt;/li&gt;&#10;&lt;li&gt;Built-in web server&lt;/li&gt;&#10;&lt;li&gt;Better performance and reduced memory consumption&lt;/li&gt;&#10;&lt;li&gt;Small improvements in various extensions&lt;/li&gt;&#10;&lt;li&gt;Short Tags are now always available&lt;/li&gt;&#10;&lt;li&gt;Array dereferencing (being able to use square brackets on elements that return an array)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Exemplo:&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Short syntax for arrays&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Exemplo:&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;um&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;dois&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;];&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;</description></item><item><title>CakePHP problem with mod_rewrite</title><link>https://jpcercal.com/en/cakephp-problem-with-mod_rewrite/</link><pubDate>Thu, 23 Feb 2012 03:10:27 +0000</pubDate><guid>https://jpcercal.com/en/cakephp-problem-with-mod_rewrite/</guid><description>&lt;p&gt;Hello, good evening. Today I had problems with &lt;a href="http://cakephp.org/"&gt;CakePHP&lt;/a&gt; URL rewriting, and decided to share&#10;the error and how I solved it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="CakePHP.png" alt="CakePHP problem with mod rewrite" loading="lazy" decoding="async" title="CakePHP problem with mod rewrite"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The problem was that when I tried to access the application&amp;rsquo;s URL through the browser, it returned the following&#10;error &lt;strong&gt;404 – Not Found&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Well, first, after looking for inconsistencies in controller and action names, clearing the cache,&#10;checking whether URL rewriting was enabled in Apache, etc, I turned to Google. After some research,&#10;I found the solution in &lt;em&gt;Cake&amp;rsquo;s&lt;/em&gt; own documentation.&lt;/p&gt;</description></item><item><title>Zend disable the layout and view renderer</title><link>https://jpcercal.com/en/zend-disable-the-layout-and-view-renderer/</link><pubDate>Tue, 29 Nov 2011 16:54:51 +0000</pubDate><guid>https://jpcercal.com/en/zend-disable-the-layout-and-view-renderer/</guid><description>&lt;p&gt;Some people have been asking me how to disable the layout and view renderer in&#10;&lt;strong&gt;Zend Framework&lt;/strong&gt; so an &lt;em&gt;action&lt;/em&gt; in a given &lt;em&gt;controller&lt;/em&gt; returns only &lt;strong&gt;JSON&lt;/strong&gt;.&#10;Well, to do this, just use two lines of code, as you can see below.&lt;/p&gt;&#10;&lt;p&gt;This first approach disables the layout and view renderer for all &lt;em&gt;actions&lt;/em&gt; in a given&#10;&lt;em&gt;controller&lt;/em&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;preDispatch&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;_helper&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;disableLayout&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;_helper&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;viewRenderer&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;setNoRender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;However, this second approach disables the layout and view renderer for only one &lt;em&gt;action&lt;/em&gt;,&#10;in this case &lt;em&gt;&amp;ldquo;index&amp;rdquo;&lt;/em&gt;:&lt;/p&gt;</description></item><item><title>Custom Fields in the Joomla panel</title><link>https://jpcercal.com/en/custom-fields-in-the-joomla-panel/</link><pubDate>Mon, 10 Oct 2011 17:32:40 +0000</pubDate><guid>https://jpcercal.com/en/custom-fields-in-the-joomla-panel/</guid><description>&lt;p&gt;Hello, today I needed to add a custom field to the&#10;&lt;a href="http://www.joomla.org/" title="Joomla"&gt;Joomla&lt;/a&gt; 1.6 administration panel for a component I was developing, and decided to share&#10;the &lt;em&gt;&amp;ldquo;recipe&amp;rdquo;&lt;/em&gt; here on my blog.&lt;/p&gt;&#10;&lt;p&gt;This tutorial was developed based on the&#10;&lt;a href="http://docs.joomla.org/Creating_a_custom_form_field_type" title="Official Joomla Documentation"&gt;Official Joomla Documentation&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;To create a &lt;strong&gt;custom field&lt;/strong&gt; type for &lt;em&gt;Joomla 1.6&lt;/em&gt;, you must create a class that extends a field type&#10;already defined by &lt;em&gt;Joomla&lt;/em&gt; itself (&lt;em&gt;media&lt;/em&gt;, &lt;em&gt;text&lt;/em&gt;, etc), or else the base class for this functionality,&#10;which is &lt;em&gt;&amp;ldquo;JFormField&amp;rdquo;&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>The CamelCase Convention</title><link>https://jpcercal.com/en/the-camelcase-convention/</link><pubDate>Wed, 08 Dec 2010 17:03:07 +0000</pubDate><guid>https://jpcercal.com/en/the-camelcase-convention/</guid><description>&lt;p&gt;&lt;strong&gt;CamelCase&lt;/strong&gt; (&lt;em&gt;camel case&lt;/em&gt;) is the practice of writing compound words or phrases with their elements joined,&#10;without spaces, and the first letter of each element capitalized, meaning the uppercase letters &amp;ldquo;&lt;em&gt;jump&lt;/em&gt;&amp;rdquo; out among the&#10;lowercase ones like a camel&amp;rsquo;s humps.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="camelcase.jpg" alt="The CamelCase Convention" loading="lazy" decoding="async" title="The CamelCase Convention"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Example: &amp;ldquo;&lt;em&gt;meuComputador&lt;/em&gt;, &amp;ldquo;&lt;em&gt;jogoDeFutebol&lt;/em&gt;&amp;rdquo; or &amp;ldquo;&lt;em&gt;linguagemProgramacao&lt;/em&gt;&amp;rdquo;.&lt;/p&gt;</description></item><item><title>Introduction to PHP</title><link>https://jpcercal.com/en/introduction-to-php/</link><pubDate>Thu, 07 Oct 2010 14:09:50 +0000</pubDate><guid>https://jpcercal.com/en/introduction-to-php/</guid><description>&lt;p&gt;&lt;a href="https://jpcercal.com/introducao-a-linguagem-php/php.jpg"&gt;&lt;img src="php.jpg" alt="Introduction to PHP" loading="lazy" decoding="async" title="PHP"&gt;&#10;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;PHP&lt;/strong&gt;, or &lt;em&gt;Hypertext Preprocessor&lt;/em&gt;, is simply the most widely used server-side language on the web.&lt;/p&gt;&#10;&lt;p&gt;In 1994, thanks to its potential and simplicity, it gained wide acceptance in the &lt;em&gt;webmaster&lt;/em&gt; community.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;PHP&lt;/strong&gt; allows easy integration with &lt;a href="https://jpcercal.com/en/introduction-to-html/" title="Introduction to HTML"&gt;HTML&lt;/a&gt; markup. Numerous functions for exploring databases easily, without complications.&lt;/p&gt;&#10;&lt;p&gt;We could make the comparison that &lt;strong&gt;PHP&lt;/strong&gt; and &lt;strong&gt;ASP&lt;/strong&gt; are similar languages in terms of power and&#10;difficulty, although the syntax can differ considerably. Some main differences can still&#10;be mentioned:&lt;/p&gt;</description></item></channel></rss>