<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>themeforest Archives - Alexandros Georgiou</title>
	<atom:link href="https://www.alexgeorgiou.gr/tag/themeforest/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.alexgeorgiou.gr/tag/themeforest/</link>
	<description>Balancing brackets for a living</description>
	<lastBuildDate>Mon, 22 Apr 2024 10:19:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.alexgeorgiou.gr/wp-content/uploads/2021/07/cropped-alexgeorgiou-icon-32x32.png</url>
	<title>themeforest Archives - Alexandros Georgiou</title>
	<link>https://www.alexgeorgiou.gr/tag/themeforest/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>💩 Your WordPress PHP code stinks! Here&#8217;s why.</title>
		<link>https://www.alexgeorgiou.gr/wordpress-php-code-quality/</link>
					<comments>https://www.alexgeorgiou.gr/wordpress-php-code-quality/#comments</comments>
		
		<dc:creator><![CDATA[alexg]]></dc:creator>
		<pubDate>Mon, 22 Jul 2019 18:12:52 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[code quality]]></category>
		<category><![CDATA[code style]]></category>
		<category><![CDATA[envato]]></category>
		<category><![CDATA[grunt]]></category>
		<category><![CDATA[grunt-phpcs]]></category>
		<category><![CDATA[phan]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpcbf]]></category>
		<category><![CDATA[phpcs]]></category>
		<category><![CDATA[phpdoc]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[requirements]]></category>
		<category><![CDATA[themeforest]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress.org]]></category>
		<guid isPermaLink="false">https://www.alexgeorgiou.gr/?p=282</guid>

					<description><![CDATA[<p>Developing a WordPress theme or plugin? Learn how to use phan and phpcs to improve the quality of your WordPress PHP code.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/wordpress-php-code-quality/">💩 Your WordPress PHP code stinks! Here&#8217;s why.</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In software development, as in all forms of engineering, we strive to produce results that satisfy a multitude of constraints, some more obvious than others. High <em>code quality</em> should be in your list of constraints when you write WordPress PHP code. And there are tools out there that can help you!</p>



<h3 class="wp-block-heading">First, some theory</h3>



<p>In a fantasy world where unicorns poop chocolate fudge and everything is awesome, it all goes down somewhat like this: You talk with the client or end user, and you gather up a list of things they want. You collect and number these in a <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://en.wikipedia.org/wiki/User_requirements_document" target="_blank">requirements document</a>, braking them up into <strong>Functional</strong> requirements, <strong>Non-functional</strong> requirements, and other <strong>Design constraints</strong>. Then, you design a solution, write your tests, and implement your code. Once all of the requirements in the document are met, you are <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.agilealliance.org/glossary/definition-of-done/" target="_blank">done</a>, and you get paid. Easy! Deviate from this simple methodology <strong>at your own peril.</strong> (Oh, and you also then need to maintain, fix and improve the code you&#8217;ve written.)</p>



<p>As a software engineer, you should know that in addition to what the client asks for, there are always <em>implicit</em> requirements. For example, your code must be <strong>readable</strong> and <strong>maintainable</strong>, and it must be <strong>reliable</strong> (read: not too buggy). All of these are aspects of <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://en.wikipedia.org/wiki/Software_quality" target="_blank">code quality</a>. A client or end user will never ask you for these, but you should have them in your list of non-functional requirements.</p>



<p>Professional developers write simple, clear code where a novice would write complex, intricate code to solve that same problem. Sure, a lot of this is just a matter of practice and experience.</p>



<p>Dev tools can help you with code quality whether you&#8217;re novice or pro. They help you discover issues that you don&#8217;t know about, and they help you discover issues that you do know about, faster!</p>



<p>If you are developing themes or plugins, here&#8217;s two tools that you definitely want to use as a professional WordPress developer:</p>



<h3 class="wp-block-heading">Improve WordPress PHP <a href="https://en.wikipedia.org/wiki/Code_smell" target="_blank" rel="noreferrer noopener" aria-label="code smell (opens in a new tab)">code smell</a> with CodeSniffer</h3>



<p>There are some <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://codex.wordpress.org/WordPress_Coding_Standards" target="_blank">styling guidelines</a> that all WordPress developers should follow. Especially if you are aspiring to upload your code to wordpress.org, or to the Envato Market (ThemeForest or CodeCanyon), then you definitely want to follow these guidelines. Generally, these get encoded into your muscle memory pretty quickly, but it&#8217;s always a great idea to have a tool like <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/squizlabs/PHP_CodeSniffer" target="_blank">PHP CodeSniffer</a> that double-checks your code style.</p>



<p>On my Ubuntu machine, I was able to install PHP CodeSniffer easily with:</p>



<pre class="wp-block-preformatted">sudo apt install php-codesniffer</pre>



<p>Then, it&#8217;s just a matter of loading the <a href="https://github.com/WordPress/WordPress-Coding-Standards" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">WordPress-specific set of rules</a>. Go to your home directory and clone the project:</p>



<pre class="wp-block-preformatted">git clone https://github.com/WordPress/WordPress-Coding-Standards ~/wpcs</pre>



<p>And tell CodeSniffer the location of these rules:</p>



<pre class="wp-block-preformatted">sudo phpcs --config-set installed_paths ~/wpcs</pre>



<p>Check that <a href="https://github.com/WordPress/WordPress-Coding-Standards#standards-subsets" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">the new rules</a> are added into CodeSniffer with:</p>



<pre class="wp-block-preformatted">phpcs -i</pre>



<p>Congratulations! You can now check your plugin for code style with a command such as:</p>



<pre class="wp-block-preformatted">phpcs --standard=Wordpress-Core /path/to/source/code/root/dir</pre>



<p>If, <a href="https://www.alexgeorgiou.gr/increasingly-verbose-gruntfile/">like me</a>, you&#8217;re using <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://gruntjs.com/" target="_blank">grunt</a> for your build process, then there&#8217;s a nifty Grung plugin, <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/SaschaGalley/grunt-phpcs" target="_blank">grunt-phpcs</a>. Just make sure to specify <code>WordPress-core</code> as the rule set. Here&#8217;s a <code>grunt</code> target that you might use:</p>



<pre class="wp-block-preformatted">phpcs: {
    plugin: {
        src: ['src/**/*.php']
    },
    options: {
        bin: '/usr/bin/phpcs',
        standard: 'WordPress-core'
    }
}</pre>



<p>Run it against your code and you will get a number of improvement suggestions. Some of these can be applied automatically with <code>PHPCBF</code> (the <strong>PHP Code Beautifier and Fixer</strong>), or you can go through the list manually and apply each suggestion as you see fit. Many of the suggestions will be related to code indentation, but you will also see a large number of other suggestions that are more critical.</p>



<h3 class="wp-block-heading">Improve WordPress PHP code correctness with phan</h3>



<p>PHP is a very lenient language. It will let you get away with murder. This is something that novice programmers often enjoy. For professionals it&#8217;s a nightmare, as it makes spotting errors harder. PHP has thus gained somewhat of a notoriety for being a bad language, and is the butt of some <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://www.reddit.com/r/ProgrammerHumor/comments/6k40cb/working_at_pornhub/" target="_blank">clever jokes</a>.</p>



<p>This isn&#8217;t something to worry about. It has happened to many respectable languages, including JavaScript. So nowadays we have <code>use strict</code>, which lets us only use <a rel="noreferrer noopener" aria-label="The Good Parts (opens in a new tab)" href="http://shop.oreilly.com/product/9780596517748.do" target="_blank">The Good Parts</a> of the language. You can do something similar with PHP.</p>



<p>My point is that <a href="https://en.wikipedia.org/wiki/Static_program_analysis">static code analysis</a> is not the hero you want, but it&#8217;s definitely the hero you deserve. Enter <code><a rel="noreferrer noopener" aria-label="phan (opens in a new tab)" href="https://github.com/phan/phan" target="_blank">phan</a></code>:</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="PHP in 2018 by the Creator of PHP" width="840" height="473" src="https://www.youtube.com/embed/rKXFgWP-2xQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div><figcaption><a href="https://en.wikipedia.org/wiki/Rasmus_Lerdorf">Rasmus Lerdorf</a>, the creator of PHP, discusses static code analysis with phan</figcaption></figure>



<p>First, install it. It&#8217;s straightforward to install <code>phan</code> with <code>composer</code>:</p>



<pre class="wp-block-preformatted">composer require phan/phan</pre>



<p>Now <code>phan</code> lives in your project&#8217;s <code>vendor/</code> dir.</p>



<p>Next, create a configuration under your project dir, in <code>.phan/config.php</code>. This will tell <code>phan</code> what settings you want to run it with. Start with the <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/phan/phan/wiki/Getting-Started#creating-a-config-file" target="_blank">example given here</a>, and set your source code directories.</p>



<p>You will also want to point to some third-party code, including the directory of your WordPress installation, since your code will invariably use WordPress functions and types.</p>



<p>You can also use this config file to exclude some rules, so that <code>phan</code> does not check for them. <a href="https://github.com/phan/phan/blob/master/.phan/plugins/README.md">Here&#8217;s the complete list of <code>phan</code> <em>plugins</em></a>.</p>



<p>When all is set, you can call <code>phan</code> on your code with:</p>



<pre class="wp-block-preformatted">vendor/bin/phan</pre>



<p>I don&#8217;t care how pro you are, you will definitely get a list of suggestions on how to improve your code.</p>



<h3 class="wp-block-heading">Conclusion</h3>



<p>Using <code>phpcs</code> and <code>phan</code> together, you will avoid a large number of errors that would otherwise likely go undetected. These include errors with translator comments over strings, <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://phpdoc.org/" target="_blank">phpDoc</a> formatting errors, variable type errors, errors related to sentinel values such as <code>null</code>, and array indexing errors.</p>



<p>Always use these two tools together with <code>phpunit</code> when you write code. You will write more readable, maintainable, correct and robust code that you can feel confident about.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/wordpress-php-code-quality/">💩 Your WordPress PHP code stinks! Here&#8217;s why.</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.alexgeorgiou.gr/wordpress-php-code-quality/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>☑ WordPress checklists to go through before publishing a theme or plugin</title>
		<link>https://www.alexgeorgiou.gr/wordpress-checklists-publish-theme-plugin/</link>
					<comments>https://www.alexgeorgiou.gr/wordpress-checklists-publish-theme-plugin/#respond</comments>
		
		<dc:creator><![CDATA[alexg]]></dc:creator>
		<pubDate>Mon, 07 Nov 2016 11:48:55 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[checklist]]></category>
		<category><![CDATA[codecanyon]]></category>
		<category><![CDATA[coding standards]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[envato]]></category>
		<category><![CDATA[publish]]></category>
		<category><![CDATA[quality assurance]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[themeforest]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress.org]]></category>
		<guid isPermaLink="false">http://www.alexgeorgiou.gr/?p=142</guid>

					<description><![CDATA[<p>In this meta-article I will list eight WordPress checklists and a book that you will want to go through, before you publish a theme or plugin.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/wordpress-checklists-publish-theme-plugin/">☑ WordPress checklists to go through before publishing a theme or plugin</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this meta-article I will list <em>eight WordPress checklists</em> and a book that you will want to go through, before you publish a theme or plugin. So before committing to the <em>wordpress.org</em> SVN or uploading to <em>Envato</em>, bookmark this page and start double-checking all the resources listed here!</p>
<h2><a title="Read 'Ten Things Every WordPress Plugin Developer Should Know'" href="https://www.smashingmagazine.com/2011/03/ten-things-every-wordpress-plugin-developer-should-know/" target="_blank" rel="bookmark noopener noreferrer">Ten Things Every WordPress Plugin Developer Should Know</a></h2>
<p>Actually you&#8217;ll probably want to read this before even starting your project; but better late than never! It&#8217;s packed with essential info that you should know. If you&#8217;ve missed any of the info in this article, go back to your code and fix it. There&#8217;s stuff about common practices, coding standards, etc.</p>
<h2 class="handbook-page-title"><a href="https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/" target="_blank" rel="noopener noreferrer">PHP Coding Standards</a></h2>
<p>This is a list of PHP coding standards that WordPress developers follow, both in core and in themes and plugins. It&#8217;s a requirement for submission to <em>wordpress.org</em> but it would be really nice to follow as many of these as possible even if you&#8217;re not planning to submit your code there.</p>
<p>Ideally you&#8217;ll want to use some tools for this. A quick search on <em>GitHub</em> reveals a number of syntax checkers. Here&#8217;s one that I use with <em>Eclipse</em>: <a href="https://github.com/edpittol/wordpress-eclipse-formatter" target="_blank" rel="noopener noreferrer">https://github.com/edpittol/wordpress-eclipse-formatter</a>, and another one for <em>CodeSniffer</em> (which can integrate nicely with a number of IDEs): <a href="https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards" target="_blank" rel="noopener noreferrer">https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards</a>.</p>
<p>Whatever you use, it doesn&#8217;t hurt to double check your code one last time. In <em>Eclipse Formatter</em> for instance, there is no way to check for <a href="https://en.wikipedia.org/wiki/Yoda_conditions" target="_blank" rel="noopener noreferrer">&#8220;Yoda&#8221; conditions</a> as far as I know, so you&#8217;ll want to manually check for those if you&#8217;re using it.</p>
<h2 class="handbook-page-title"><a href="https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/">JavaScript Coding Standards</a></h2>
<p>Have you checked your PHP code for compliance to the coding standards? Good! Get ready to do it again, this time for your JavaScript files; at least the unminified copies of them. Here&#8217;s a project that uses <em>ESLint</em> to help you enforce the standards: <a href="https://www.npmjs.com/package/eslint-plugin-wordpress" target="_blank" rel="noopener noreferrer">https://www.npmjs.com/package/eslint-plugin-wordpress</a>. If you have a lot of JavaScript in your code, it might pay to integrate this into your pre-build checks, but as with PHP, always have one last look using your eyeballs.</p>
<h2><a href="https://wordpress.org/plugins/about/" target="_blank" rel="noopener noreferrer">WordPress plugins</a></h2>
<p>If you&#8217;re writing a plugin, this is a short list of conditions that your project must meet before you publish to <em>WordPress.org</em>. It has more to do with functionality than standards, and essentially it&#8217;s about not being evil with your code.</p>
<h2><a href="https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/" target="_blank" rel="noopener noreferrer">Detailed Plugin Guidelines</a></h2>
<p>This is essentially a longer version of the above. A definite must read if you&#8217;re publishing to <em>WordPress.org</em>. It&#8217;s about licensing, versioning, what you can and can&#8217;t do, etc.</p>
<h2 id="theme-review-process" class="toc-heading" tabindex="-1"><a href="https://make.wordpress.org/themes/handbook/review/#theme-review-process" target="_blank" rel="noopener noreferrer">Theme Review Process</a></h2>
<p>If you&#8217;re writing a theme that you plan to publish to <em>WordPress.org</em>, check that it at least conforms to all the <a href="https://make.wordpress.org/themes/handbook/review/required/" target="_blank" rel="noopener noreferrer">required items</a> and try to conform to as many <a href="https://make.wordpress.org/themes/handbook/review/recommended/" target="_blank" rel="noopener noreferrer">recommended items</a> as possible. The write-up for the recommended guidelines is not complete as of the writing of this article, but there&#8217;s some very useful guidelines in there.</p>
<h2><a href="https://codex.wordpress.org/Theme_Unit_Test" target="_blank" rel="noopener noreferrer">Theme Unit Test</a></h2>
<p>Again, if you&#8217;re writing a theme for <em>WordPress.org</em>, you will also want to check a number of things against the provided <a href="https://codex.wordpress.org/Theme_Unit_Test" target="_blank" rel="noopener noreferrer">Theme Unit Test</a>. It&#8217;s probably a good idea to do this even if you&#8217;re publishing elsewhere.</p>
<h2><a href="https://help.market.envato.com/hc/en-us/articles/202500774-ThemeForest-General-File-Preparation-Guidelines" target="_blank" rel="noopener noreferrer">ThemeForest General File Preparation Guidelines</a></h2>
<p>If you&#8217;re publishing to <em>ThemeForest</em>, you will have to follow these guidelines on how to bundle your files.</p>
<h2><a href="https://help.market.envato.com/hc/en-us/articles/202501494-WordPress-Phase-1-Submission-Requirements-Q-A" target="_blank" rel="noopener noreferrer">WordPress Phase 1 Submission Requirements &#8211; Q&amp;A</a></h2>
<p>This is a list of guidelines to follow before submitting to <em>ThemeForest</em>. There&#8217;s a number of things listed that are not allowed, so make sure to check.</p>
<h2><a href="https://help.market.envato.com/hc/en-us/articles/203269650-A-step-by-step-guide-to-the-upload-process" target="_blank" rel="noopener noreferrer">A step-by-step guide to the upload process</a></h2>
<p>When uploading to <em>ThemeForest</em>, you will also want to follow these guidelines. They are mostly about the upload process but also include some information about how to bundle your files.</p>
<h2>Professional WordPress: Design and Development</h2>
<p><a style="width: 120px; height: 240px; float: right; margin-left: 1em;" href="https://amzn.to/3W4EePm" width="300" height="150"><br />
<img decoding="async" src="https://m.media-amazon.com/images/I/71OD8C2NZNL._SY466_.jpg" /><br />
</a><br />
Finally, this is a book, not an actual checklist, but still I recommend that you at least glance through the table of contents. I&#8217;ve found this book very helpful. It covers all topics related to WordPress development and it&#8217;s very likely that whatever it is you&#8217;re trying to do, there might be a better way of doing it. WordPress is a complex system and it&#8217;s only getting more complex by the day.</p>
<p>My recommendation is that you go through the table of contents and read any chapter that talks about things you do in your theme or plugin. There are things you might have missed.</p>
<div style="clear: right;"></div>
<hr />
<p>Too meta? Perhaps! But no matter what and where you&#8217;re publishing, if you want to be professional about it, don&#8217;t assume you know everything. At least glance through all of these guidelines.</p>
<p>The post <a href="https://www.alexgeorgiou.gr/wordpress-checklists-publish-theme-plugin/">☑ WordPress checklists to go through before publishing a theme or plugin</a> appeared first on <a href="https://www.alexgeorgiou.gr">Alexandros Georgiou</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.alexgeorgiou.gr/wordpress-checklists-publish-theme-plugin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
