<?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>best practices Archives - Developry Plugins</title>
	<atom:link href="https://developryplugins.com/tag/best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>https://developryplugins.com/tag/best-practices/</link>
	<description></description>
	<lastBuildDate>Mon, 24 Nov 2025 11:18:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://developryplugins.com/wp-content/uploads/2025/11/cropped-favicon-32x32.png</url>
	<title>best practices Archives - Developry Plugins</title>
	<link>https://developryplugins.com/tag/best-practices/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Theme Development Best Practices: Following WordPress Standards</title>
		<link>https://developryplugins.com/theme-development-best-practices-following-wordpress-standards/</link>
		
		<dc:creator><![CDATA[Krasen Slavov]]></dc:creator>
		<pubDate>Wed, 15 Apr 2026 09:00:00 +0000</pubDate>
				<category><![CDATA[WordPress Theme Development]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding standards]]></category>
		<category><![CDATA[theme review]]></category>
		<category><![CDATA[wordpress standards]]></category>
		<category><![CDATA[wpcs]]></category>
		<guid isPermaLink="false">https://developryplugins.com/?p=156</guid>

					<description><![CDATA[<p>WordPress theme development best practices ensure code quality, security, and compatibility through coding standards, template organization, and performance optimization. From WPCS compliance and escaping output to accessibility requirements and translation...</p>
<p>The post <a href="https://developryplugins.com/theme-development-best-practices-following-wordpress-standards/">Theme Development Best Practices: Following WordPress Standards</a> appeared first on <a href="https://developryplugins.com">Developry Plugins</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><!-- @format --></p>
<p>WordPress theme development best practices ensure code quality, security, and compatibility through coding standards, template organization, and performance optimization. From WPCS compliance and escaping output to accessibility requirements and translation readiness, professional themes follow established guidelines preventing common vulnerabilities and maintenance issues. This comprehensive guide teaches WordPress coding standards, security best practices, performance optimization, accessibility compliance, and theme review requirements creating maintainable production-ready themes.</p>
<h2 id="wordpress-coding-standards">WordPress Coding Standards</h2>
<p><strong>PHP Coding Standards</strong>:</p>
<div class="sourceCode" id="cb1">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a><span class="co">/**</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true"></a><span class="co"> * Theme Functions</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true"></a><span class="co"> *</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true"></a><span class="co"> * </span><span class="an">@package</span><span class="co"> </span><span class="cv">MyTheme</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true"></a><span class="co"> */</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true"></a></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true"></a><span class="co">// Exit if accessed directly.</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span> ! <span class="fu">defined</span><span class="ot">(</span> <span class="st">&#39;ABSPATH&#39;</span> <span class="ot">)</span> <span class="ot">)</span> {</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a>    <span class="kw">exit</span><span class="ot">;</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a>}</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a><span class="co">/**</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true"></a><span class="co"> * Setup theme defaults and register support for WordPress features.</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true"></a><span class="co"> */</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true"></a><span class="kw">function</span> mytheme_setup<span class="ot">()</span> {</span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true"></a>    <span class="co">// Add theme support features.</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;title-tag&#39;</span> <span class="ot">);</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;post-thumbnails&#39;</span> <span class="ot">);</span></span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;html5&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true"></a>        <span class="st">&#39;search-form&#39;</span><span class="ot">,</span></span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true"></a>        <span class="st">&#39;comment-form&#39;</span><span class="ot">,</span></span>
<span id="cb1-23"><a href="#cb1-23" aria-hidden="true"></a>        <span class="st">&#39;comment-list&#39;</span><span class="ot">,</span></span>
<span id="cb1-24"><a href="#cb1-24" aria-hidden="true"></a>        <span class="st">&#39;gallery&#39;</span><span class="ot">,</span></span>
<span id="cb1-25"><a href="#cb1-25" aria-hidden="true"></a>        <span class="st">&#39;caption&#39;</span><span class="ot">,</span></span>
<span id="cb1-26"><a href="#cb1-26" aria-hidden="true"></a>        <span class="st">&#39;style&#39;</span><span class="ot">,</span></span>
<span id="cb1-27"><a href="#cb1-27" aria-hidden="true"></a>        <span class="st">&#39;script&#39;</span><span class="ot">,</span></span>
<span id="cb1-28"><a href="#cb1-28" aria-hidden="true"></a>    <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb1-29"><a href="#cb1-29" aria-hidden="true"></a></span>
<span id="cb1-30"><a href="#cb1-30" aria-hidden="true"></a>    <span class="co">// Register navigation menus.</span></span>
<span id="cb1-31"><a href="#cb1-31" aria-hidden="true"></a>    register_nav_menus<span class="ot">(</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb1-32"><a href="#cb1-32" aria-hidden="true"></a>        <span class="st">&#39;primary&#39;</span> =&gt; esc_html__<span class="ot">(</span> <span class="st">&#39;Primary Menu&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">),</span></span>
<span id="cb1-33"><a href="#cb1-33" aria-hidden="true"></a>    <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb1-34"><a href="#cb1-34" aria-hidden="true"></a>}</span>
<span id="cb1-35"><a href="#cb1-35" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;after_setup_theme&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_setup&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<p><strong>Key Standards</strong>:</p>
<ul>
<li>Spaces, not tabs (4 spaces for indentation)</li>
<li>Yoda conditions: <code>if ( true === $var )</code></li>
<li>Single quotes for strings unless interpolation needed</li>
<li>Braces on same line for control structures</li>
<li>Space after function name: <code>function_name( $param )</code></li>
</ul>
<h2 id="escaping-output">Escaping Output</h2>
<p><strong>Always Escape Output</strong>:</p>
<div class="sourceCode" id="cb2">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a>&lt;!-- Text --&gt;</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a>&lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_html<span class="ot">(</span> <span class="kw">$text</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true"></a><span class="kw">&lt;?php</span> <span class="kw">echo</span> esc_html__<span class="ot">(</span> <span class="st">&#39;Translatable text&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true"></a></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true"></a>&lt;!-- Attributes --&gt;</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true"></a>&lt;div <span class="kw">class</span>=<span class="st">&quot;&lt;?php echo esc_attr( </span><span class="kw">$class</span><span class="st"> ); ?&gt;&quot;</span>&gt;</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true"></a>&lt;a href=<span class="st">&quot;&lt;?php echo esc_url( </span><span class="kw">$url</span><span class="st"> ); ?&gt;&quot;</span>&gt;</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true"></a></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true"></a>&lt;!-- URLs --&gt;</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true"></a>&lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_url<span class="ot">(</span> home_url<span class="ot">(</span> <span class="st">&#39;/&#39;</span> <span class="ot">)</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true"></a></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true"></a>&lt;!-- <span class="kw">HTML</span> content <span class="ot">(</span>when intentional<span class="ot">)</span> --&gt;</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true"></a>&lt;<span class="ot">?</span>php <span class="kw">echo</span> wp_kses_post<span class="ot">(</span> <span class="kw">$content</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true"></a></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true"></a>&lt;!-- JavaScript --&gt;</span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true"></a>&lt;script&gt;</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true"></a><span class="er">var</span> siteUrl = &lt;<span class="ot">?</span>php <span class="kw">echo</span> wp_json_encode<span class="ot">(</span> home_url<span class="ot">()</span> <span class="ot">);</span> <span class="kw">?&gt;</span><span class="ot">;</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true"></a>&lt;/script&gt;</span></code></pre>
</div>
<p><strong>Common Escaping Functions</strong>:</p>
<ul>
<li><code>esc_html()</code> &#8211; Plain text</li>
<li><code>esc_attr()</code> &#8211; Attributes</li>
<li><code>esc_url()</code> &#8211; URLs</li>
<li><code>esc_js()</code> &#8211; JavaScript strings</li>
<li><code>wp_kses_post()</code> &#8211; HTML with allowed tags</li>
</ul>
<h2 id="sanitizing-input">Sanitizing Input</h2>
<p><strong>Sanitize All Input</strong>:</p>
<div class="sourceCode" id="cb3">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true"></a><span class="co">// Text fields</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a><span class="kw">$text</span> = sanitize_text_field<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;user_input&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a><span class="co">// Textarea</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true"></a><span class="kw">$textarea</span> = sanitize_textarea_field<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;description&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true"></a></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true"></a><span class="co">// Email</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true"></a><span class="kw">$email</span> = sanitize_email<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;email&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true"></a></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true"></a><span class="co">// URL</span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true"></a><span class="kw">$url</span> = esc_url_raw<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;website&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true"></a></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true"></a><span class="co">// Integer</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true"></a><span class="kw">$number</span> = absint<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;count&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true"></a></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true"></a><span class="co">// HTML content</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true"></a><span class="kw">$content</span> = wp_kses_post<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;content&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true"></a></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true"></a><span class="co">// Checkboxes</span></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true"></a><span class="kw">$checkbox</span> = <span class="kw">isset</span><span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;option&#39;</span><span class="ot">]</span> <span class="ot">)</span> &amp;&amp; <span class="st">&#39;1&#39;</span> === <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;option&#39;</span><span class="ot">];</span></span></code></pre>
</div>
<h2 id="nonce-verification">Nonce Verification</h2>
<p><strong>Always Verify Nonces for Forms</strong>:</p>
<div class="sourceCode" id="cb4">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true"></a><span class="co">// Create nonce</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a>&lt;form method=<span class="st">&quot;post&quot;</span>&gt;</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php wp_nonce_field<span class="ot">(</span> <span class="st">&#39;mytheme_action&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_nonce&#39;</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a>    &lt;input type=<span class="st">&quot;text&quot;</span> name=<span class="st">&quot;user_field&quot;</span> /&gt;</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true"></a>    &lt;input type=<span class="st">&quot;submit&quot;</span> value=<span class="st">&quot;Submit&quot;</span> /&gt;</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true"></a>&lt;/form&gt;</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true"></a></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true"></a><span class="co">// Verify nonce</span></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span> <span class="kw">isset</span><span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;mytheme_nonce&#39;</span><span class="ot">]</span> <span class="ot">)</span> &amp;&amp; wp_verify_nonce<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;mytheme_nonce&#39;</span><span class="ot">],</span> <span class="st">&#39;mytheme_action&#39;</span> <span class="ot">)</span> <span class="ot">)</span> {</span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true"></a>    <span class="co">// Process form</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true"></a>    <span class="kw">$user_input</span> = sanitize_text_field<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;user_field&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true"></a>} <span class="kw">else</span> {</span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true"></a>    wp_die<span class="ot">(</span> <span class="st">&#39;Security check failed&#39;</span> <span class="ot">);</span></span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true"></a>}</span></code></pre>
</div>
<p><strong>AJAX Nonces</strong>:</p>
<div class="sourceCode" id="cb5">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true"></a><span class="co">// Create nonce for AJAX</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true"></a>wp_localize_script<span class="ot">(</span> <span class="st">&#39;mytheme-ajax&#39;</span><span class="ot">,</span> <span class="st">&#39;mythemeAjax&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true"></a>    <span class="st">&#39;ajax_url&#39;</span> =&gt; admin_url<span class="ot">(</span> <span class="st">&#39;admin-ajax.php&#39;</span> <span class="ot">),</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true"></a>    <span class="st">&#39;nonce&#39;</span>    =&gt; wp_create_nonce<span class="ot">(</span> <span class="st">&#39;mytheme_ajax_nonce&#39;</span> <span class="ot">),</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true"></a><span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true"></a></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true"></a><span class="co">// Verify AJAX nonce</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true"></a><span class="kw">function</span> mytheme_ajax_handler<span class="ot">()</span> {</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true"></a>    check_ajax_referer<span class="ot">(</span> <span class="st">&#39;mytheme_ajax_nonce&#39;</span><span class="ot">,</span> <span class="st">&#39;nonce&#39;</span> <span class="ot">);</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true"></a></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true"></a>    <span class="co">// Process AJAX request</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true"></a>    <span class="kw">$data</span> = sanitize_text_field<span class="ot">(</span> <span class="kw">$_POST</span><span class="ot">[</span><span class="st">&#39;data&#39;</span><span class="ot">]</span> <span class="ot">);</span></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true"></a></span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true"></a>    wp_send_json_success<span class="ot">(</span> <span class="kw">array</span><span class="ot">(</span> <span class="st">&#39;message&#39;</span> =&gt; <span class="st">&#39;Success&#39;</span> <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true"></a>}</span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;wp_ajax_mytheme_action&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_ajax_handler&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="proper-enqueueing">Proper Enqueueing</h2>
<p><strong>Enqueue Scripts and Styles Correctly</strong>:</p>
<div class="sourceCode" id="cb6">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true"></a><span class="kw">function</span> mytheme_scripts<span class="ot">()</span> {</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true"></a>    <span class="co">// Enqueue stylesheet</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true"></a>    wp_enqueue_style<span class="ot">(</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true"></a>        <span class="st">&#39;mytheme-style&#39;</span><span class="ot">,</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true"></a>        get_stylesheet_uri<span class="ot">(),</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(),</span></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true"></a>        wp_get_theme<span class="ot">()</span>-&gt;get<span class="ot">(</span> <span class="st">&#39;Version&#39;</span> <span class="ot">)</span></span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true"></a>    <span class="ot">);</span></span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true"></a></span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true"></a>    <span class="co">// Enqueue custom CSS</span></span>
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true"></a>    wp_enqueue_style<span class="ot">(</span></span>
<span id="cb6-12"><a href="#cb6-12" aria-hidden="true"></a>        <span class="st">&#39;mytheme-custom&#39;</span><span class="ot">,</span></span>
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true"></a>        get_template_directory_uri<span class="ot">()</span> . <span class="st">&#39;/css/custom.css&#39;</span><span class="ot">,</span></span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span> <span class="st">&#39;mytheme-style&#39;</span> <span class="ot">),</span></span>
<span id="cb6-15"><a href="#cb6-15" aria-hidden="true"></a>        <span class="st">&#39;1.0.0&#39;</span></span>
<span id="cb6-16"><a href="#cb6-16" aria-hidden="true"></a>    <span class="ot">);</span></span>
<span id="cb6-17"><a href="#cb6-17" aria-hidden="true"></a></span>
<span id="cb6-18"><a href="#cb6-18" aria-hidden="true"></a>    <span class="co">// Enqueue JavaScript with dependencies</span></span>
<span id="cb6-19"><a href="#cb6-19" aria-hidden="true"></a>    wp_enqueue_script<span class="ot">(</span></span>
<span id="cb6-20"><a href="#cb6-20" aria-hidden="true"></a>        <span class="st">&#39;mytheme-navigation&#39;</span><span class="ot">,</span></span>
<span id="cb6-21"><a href="#cb6-21" aria-hidden="true"></a>        get_template_directory_uri<span class="ot">()</span> . <span class="st">&#39;/js/navigation.js&#39;</span><span class="ot">,</span></span>
<span id="cb6-22"><a href="#cb6-22" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span> <span class="st">&#39;jquery&#39;</span> <span class="ot">),</span></span>
<span id="cb6-23"><a href="#cb6-23" aria-hidden="true"></a>        <span class="st">&#39;1.0.0&#39;</span><span class="ot">,</span></span>
<span id="cb6-24"><a href="#cb6-24" aria-hidden="true"></a>        <span class="kw">true</span> <span class="co">// Load in footer</span></span>
<span id="cb6-25"><a href="#cb6-25" aria-hidden="true"></a>    <span class="ot">);</span></span>
<span id="cb6-26"><a href="#cb6-26" aria-hidden="true"></a></span>
<span id="cb6-27"><a href="#cb6-27" aria-hidden="true"></a>    <span class="co">// Localize script for AJAX</span></span>
<span id="cb6-28"><a href="#cb6-28" aria-hidden="true"></a>    wp_localize_script<span class="ot">(</span></span>
<span id="cb6-29"><a href="#cb6-29" aria-hidden="true"></a>        <span class="st">&#39;mytheme-navigation&#39;</span><span class="ot">,</span></span>
<span id="cb6-30"><a href="#cb6-30" aria-hidden="true"></a>        <span class="st">&#39;mythemeData&#39;</span><span class="ot">,</span></span>
<span id="cb6-31"><a href="#cb6-31" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb6-32"><a href="#cb6-32" aria-hidden="true"></a>            <span class="st">&#39;ajax_url&#39;</span> =&gt; admin_url<span class="ot">(</span> <span class="st">&#39;admin-ajax.php&#39;</span> <span class="ot">),</span></span>
<span id="cb6-33"><a href="#cb6-33" aria-hidden="true"></a>            <span class="st">&#39;nonce&#39;</span>    =&gt; wp_create_nonce<span class="ot">(</span> <span class="st">&#39;mytheme_nonce&#39;</span> <span class="ot">),</span></span>
<span id="cb6-34"><a href="#cb6-34" aria-hidden="true"></a>        <span class="ot">)</span></span>
<span id="cb6-35"><a href="#cb6-35" aria-hidden="true"></a>    <span class="ot">);</span></span>
<span id="cb6-36"><a href="#cb6-36" aria-hidden="true"></a></span>
<span id="cb6-37"><a href="#cb6-37" aria-hidden="true"></a>    <span class="co">// Conditional loading</span></span>
<span id="cb6-38"><a href="#cb6-38" aria-hidden="true"></a>    <span class="kw">if</span> <span class="ot">(</span> is_singular<span class="ot">()</span> &amp;&amp; comments_open<span class="ot">()</span> &amp;&amp; get_option<span class="ot">(</span> <span class="st">&#39;thread_comments&#39;</span> <span class="ot">)</span> <span class="ot">)</span> {</span>
<span id="cb6-39"><a href="#cb6-39" aria-hidden="true"></a>        wp_enqueue_script<span class="ot">(</span> <span class="st">&#39;comment-reply&#39;</span> <span class="ot">);</span></span>
<span id="cb6-40"><a href="#cb6-40" aria-hidden="true"></a>    }</span>
<span id="cb6-41"><a href="#cb6-41" aria-hidden="true"></a>}</span>
<span id="cb6-42"><a href="#cb6-42" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;wp_enqueue_scripts&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_scripts&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<p><strong>Never Hardcode Assets</strong>:</p>
<div class="sourceCode" id="cb7">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true"></a>&lt;!-- <span class="kw">BAD</span> --&gt;</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true"></a>&lt;<span class="fu">link</span> rel=<span class="st">&quot;stylesheet&quot;</span> href=<span class="st">&quot;/wp-content/themes/mytheme/style.css&quot;</span>&gt;</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true"></a>&lt;script src=<span class="st">&quot;/wp-content/themes/mytheme/js/script.js&quot;</span>&gt;&lt;/script&gt;</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true"></a></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true"></a>&lt;!-- <span class="kw">GOOD</span> --&gt;</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true"></a>&lt;<span class="ot">?</span>php wp_head<span class="ot">();</span> <span class="kw">?&gt;</span> &lt;!-- Enqueued styles/scripts output here --&gt;</span></code></pre>
</div>
<h2 id="translation-ready">Translation Ready</h2>
<p><strong>Make All Strings Translatable</strong>:</p>
<div class="sourceCode" id="cb8">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true"></a><span class="co">// Simple string</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true"></a><span class="kw">__</span><span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true"></a></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true"></a><span class="co">// Echo string</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true"></a>_e<span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true"></a></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true"></a><span class="co">// With HTML escaping</span></span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true"></a>esc_html__<span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true"></a>esc_html_e<span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true"></a></span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true"></a><span class="co">// Attribute escaping</span></span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true"></a>esc_attr__<span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true"></a>esc_attr_e<span class="ot">(</span> <span class="st">&#39;Hello World&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true"></a></span>
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true"></a><span class="co">// Plurals</span></span>
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true"></a>_n<span class="ot">(</span> <span class="st">&#39;%s item&#39;</span><span class="ot">,</span> <span class="st">&#39;%s items&#39;</span><span class="ot">,</span> <span class="kw">$count</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span>
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true"></a></span>
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true"></a><span class="co">// Context-specific</span></span>
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true"></a>_x<span class="ot">(</span> <span class="st">&#39;Read&#39;</span><span class="ot">,</span> <span class="st">&#39;past tense&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<p><strong>Load Text Domain</strong>:</p>
<div class="sourceCode" id="cb9">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true"></a><span class="kw">function</span> mytheme_load_textdomain<span class="ot">()</span> {</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true"></a>    load_theme_textdomain<span class="ot">(</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">,</span> get_template_directory<span class="ot">()</span> . <span class="st">&#39;/languages&#39;</span> <span class="ot">);</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true"></a>}</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;after_setup_theme&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_load_textdomain&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="template-organization">Template Organization</h2>
<p><strong>Proper File Structure</strong>:</p>
<pre><code>mytheme/
├── style.css
├── functions.php
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── single.php
├── page.php
├── archive.php
├── search.php
├── 404.php
├── comments.php
├── template-parts/
│   ├── content.php
│   ├── content-page.php
│   └── content-none.php
├── inc/
│   ├── template-tags.php
│   └── template-functions.php
├── js/
│   └── navigation.js
├── css/
│   └── custom.css
└── languages/
    └── mytheme.pot</code></pre>
<p><strong>Use Template Parts</strong>:</p>
<div class="sourceCode" id="cb11">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true"></a><span class="co">// Include template part</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true"></a>get_template_part<span class="ot">(</span> <span class="st">&#39;template-parts/content&#39;</span><span class="ot">,</span> get_post_type<span class="ot">()</span> <span class="ot">);</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true"></a></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true"></a><span class="co">// With custom data</span></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true"></a>get_template_part<span class="ot">(</span> <span class="st">&#39;template-parts/content&#39;</span><span class="ot">,</span> <span class="st">&#39;page&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true"></a>    <span class="st">&#39;custom_data&#39;</span> =&gt; <span class="kw">$data</span><span class="ot">,</span></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true"></a><span class="ot">)</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="performance-best-practices">Performance Best Practices</h2>
<p><strong>Optimize Database Queries</strong>:</p>
<div class="sourceCode" id="cb12">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true"></a><span class="co">// BAD - Multiple queries in loop</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true"></a><span class="kw">while</span> <span class="ot">(</span> have_posts<span class="ot">()</span> <span class="ot">)</span> {</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true"></a>    the_post<span class="ot">();</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true"></a>    <span class="kw">$author</span> = get_user_by<span class="ot">(</span> <span class="st">&#39;id&#39;</span><span class="ot">,</span> <span class="kw">$post</span>-&gt;post_author <span class="ot">);</span> <span class="co">// Query per post</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true"></a>}</span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true"></a><span class="co">// GOOD - Single query before loop</span></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true"></a><span class="kw">$author_ids</span> = wp_list_pluck<span class="ot">(</span> <span class="kw">$posts</span><span class="ot">,</span> <span class="st">&#39;post_author&#39;</span> <span class="ot">);</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true"></a><span class="kw">$authors</span> = get_users<span class="ot">(</span> <span class="kw">array</span><span class="ot">(</span> <span class="st">&#39;include&#39;</span> =&gt; <span class="fu">array_unique</span><span class="ot">(</span> <span class="kw">$author_ids</span> <span class="ot">)</span> <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true"></a></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true"></a><span class="kw">while</span> <span class="ot">(</span> have_posts<span class="ot">()</span> <span class="ot">)</span> {</span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true"></a>    the_post<span class="ot">();</span></span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true"></a>    <span class="kw">$author</span> = <span class="kw">$authors</span><span class="ot">[</span> <span class="kw">$post</span>-&gt;post_author <span class="ot">];</span></span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true"></a>}</span></code></pre>
</div>
<p><strong>Lazy Load Images</strong>:</p>
<div class="sourceCode" id="cb13">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true"></a><span class="co">// Add loading attribute to images</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true"></a>add_filter<span class="ot">(</span> <span class="st">&#39;wp_get_attachment_image_attributes&#39;</span><span class="ot">,</span> <span class="kw">function</span><span class="ot">(</span> <span class="kw">$attr</span> <span class="ot">)</span> {</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true"></a>    <span class="kw">$attr</span><span class="ot">[</span><span class="st">&#39;loading&#39;</span><span class="ot">]</span> = <span class="st">&#39;lazy&#39;</span><span class="ot">;</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true"></a>    <span class="kw">return</span> <span class="kw">$attr</span><span class="ot">;</span></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true"></a>} <span class="ot">);</span></span></code></pre>
</div>
<p><strong>Limit Post Queries</strong>:</p>
<div class="sourceCode" id="cb14">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true"></a><span class="co">// Set default posts per page</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true"></a><span class="kw">function</span> mytheme_posts_per_page<span class="ot">(</span> <span class="kw">$query</span> <span class="ot">)</span> {</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true"></a>    <span class="kw">if</span> <span class="ot">(</span> ! is_admin<span class="ot">()</span> &amp;&amp; <span class="kw">$query</span>-&gt;is_main_query<span class="ot">()</span> &amp;&amp; is_home<span class="ot">()</span> <span class="ot">)</span> {</span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true"></a>        <span class="kw">$query</span>-&gt;set<span class="ot">(</span> <span class="st">&#39;posts_per_page&#39;</span><span class="ot">,</span> <span class="dv">12</span> <span class="ot">);</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true"></a>    }</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true"></a>}</span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;pre_get_posts&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_posts_per_page&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="accessibility">Accessibility</h2>
<p><strong>Semantic HTML</strong>:</p>
<div class="sourceCode" id="cb15">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true"></a>&lt;!-- Proper heading hierarchy --&gt;</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true"></a>&lt;h1&gt;&lt;<span class="ot">?</span>php the_title<span class="ot">();</span> <span class="kw">?&gt;</span>&lt;/h1&gt;</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true"></a>&lt;h2&gt;&lt;<span class="ot">?</span>php _e<span class="ot">(</span> <span class="st">&#39;Related Posts&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span> <span class="kw">?&gt;</span>&lt;/h2&gt;</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true"></a></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true"></a>&lt;!-- Skip links --&gt;</span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true"></a>&lt;a <span class="kw">class</span>=<span class="st">&quot;skip-link screen-reader-text&quot;</span> href=<span class="st">&quot;#primary&quot;</span>&gt;</span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php esc_html_e<span class="ot">(</span> <span class="st">&#39;Skip to content&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true"></a>&lt;/a&gt;</span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true"></a></span>
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true"></a>&lt;!-- <span class="kw">ARIA</span> labels --&gt;</span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true"></a>&lt;button <span class="kw">class</span>=<span class="st">&quot;menu-toggle&quot;</span> aria-controls=<span class="st">&quot;primary-menu&quot;</span> aria-expanded=<span class="st">&quot;false&quot;</span>&gt;</span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php esc_html_e<span class="ot">(</span> <span class="st">&#39;Menu&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true"></a>&lt;/button&gt;</span>
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true"></a></span>
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true"></a>&lt;!-- Alt text <span class="kw">for</span> images --&gt;</span>
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true"></a>&lt;<span class="ot">?</span>php</span>
<span id="cb15-17"><a href="#cb15-17" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span> has_post_thumbnail<span class="ot">()</span> <span class="ot">)</span> {</span>
<span id="cb15-18"><a href="#cb15-18" aria-hidden="true"></a>    the_post_thumbnail<span class="ot">(</span> <span class="st">&#39;large&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb15-19"><a href="#cb15-19" aria-hidden="true"></a>        <span class="st">&#39;alt&#39;</span> =&gt; get_the_title<span class="ot">(),</span></span>
<span id="cb15-20"><a href="#cb15-20" aria-hidden="true"></a>    <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb15-21"><a href="#cb15-21" aria-hidden="true"></a>}</span>
<span id="cb15-22"><a href="#cb15-22" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<p><strong>Keyboard Navigation</strong>:</p>
<div class="sourceCode" id="cb16">
<pre class="sourceCode css"><code class="sourceCode css"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true"></a><span class="co">/* Focus styles */</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true"></a>a<span class="in">:focus</span><span class="op">,</span></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true"></a>button<span class="in">:focus</span><span class="op">,</span></span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true"></a>input<span class="in">:focus</span> {</span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true"></a>    <span class="kw">outline</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">#0073aa</span><span class="op">;</span></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true"></a>    <span class="kw">outline-offset</span>: <span class="dv">2</span><span class="dt">px</span><span class="op">;</span></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true"></a>}</span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true"></a></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true"></a><span class="co">/* Skip link visible on focus */</span></span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true"></a><span class="fu">.skip-link</span><span class="in">:focus</span> {</span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true"></a>    <span class="kw">position</span>: <span class="dv">static</span><span class="op">;</span></span>
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true"></a>    <span class="kw">clip</span>: <span class="bu">auto</span><span class="op">;</span></span>
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true"></a>    <span class="kw">height</span>: <span class="bu">auto</span><span class="op">;</span></span>
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true"></a>    <span class="kw">width</span>: <span class="bu">auto</span><span class="op">;</span></span>
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true"></a>}</span></code></pre>
</div>
<h2 id="security-best-practices">Security Best Practices</h2>
<p><strong>Capability Checks</strong>:</p>
<div class="sourceCode" id="cb17">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true"></a><span class="co">// Check user capabilities</span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span> current_user_can<span class="ot">(</span> <span class="st">&#39;edit_posts&#39;</span> <span class="ot">)</span> <span class="ot">)</span> {</span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true"></a>    <span class="co">// Show edit link</span></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true"></a>    edit_post_link<span class="ot">(</span> <span class="kw">__</span><span class="ot">(</span> <span class="st">&#39;Edit&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span> <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true"></a>}</span></code></pre>
</div>
<p><strong>Direct File Access Prevention</strong>:</p>
<div class="sourceCode" id="cb18">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true"></a><span class="co">/**</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true"></a><span class="co"> * Theme Functions</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true"></a><span class="co"> */</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true"></a></span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true"></a><span class="co">// Prevent direct file access</span></span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span> ! <span class="fu">defined</span><span class="ot">(</span> <span class="st">&#39;ABSPATH&#39;</span> <span class="ot">)</span> <span class="ot">)</span> {</span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true"></a>    <span class="kw">exit</span><span class="ot">;</span></span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true"></a>}</span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true"></a></span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true"></a><span class="co">// Rest of functions.php</span></span></code></pre>
</div>
<p><strong>SQL Injection Prevention</strong>:</p>
<div class="sourceCode" id="cb19">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true"></a><span class="kw">global</span> <span class="kw">$wpdb</span><span class="ot">;</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true"></a></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true"></a><span class="co">// BAD - Direct variable in query</span></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true"></a><span class="kw">$results</span> = <span class="kw">$wpdb</span>-&gt;get_results<span class="ot">(</span> <span class="st">&quot;SELECT * FROM </span><span class="kw">{$wpdb-&gt;posts}</span><span class="st"> WHERE post_author = </span><span class="kw">{$author_id}</span><span class="st">&quot;</span> <span class="ot">);</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true"></a></span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true"></a><span class="co">// GOOD - Prepared statement</span></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true"></a><span class="kw">$results</span> = <span class="kw">$wpdb</span>-&gt;get_results<span class="ot">(</span> <span class="kw">$wpdb</span>-&gt;prepare<span class="ot">(</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true"></a>    <span class="st">&quot;SELECT * FROM </span><span class="kw">{$wpdb-&gt;posts}</span><span class="st"> WHERE post_author = %d&quot;</span><span class="ot">,</span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true"></a>    <span class="kw">$author_id</span></span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true"></a><span class="ot">)</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="prefixing">Prefixing</h2>
<p><strong>Prefix All Functions and Variables</strong>:</p>
<div class="sourceCode" id="cb20">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true"></a><span class="co">// Function names</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true"></a><span class="kw">function</span> mytheme_setup<span class="ot">()</span> {}</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true"></a></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true"></a><span class="co">// Global variables</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true"></a><span class="kw">global</span> <span class="kw">$mytheme_options</span><span class="ot">;</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true"></a></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true"></a><span class="co">// Custom database tables</span></span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true"></a><span class="kw">$wpdb</span>-&gt;mytheme_custom_table</span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true"></a></span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true"></a><span class="co">// Handles for scripts/styles</span></span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true"></a>wp_enqueue_style<span class="ot">(</span> <span class="st">&#39;mytheme-style&#39;</span> <span class="ot">);</span></span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true"></a></span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true"></a><span class="co">// Hook names</span></span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true"></a>do_action<span class="ot">(</span> <span class="st">&#39;mytheme_before_header&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="theme-review-requirements">Theme Review Requirements</h2>
<p><strong>Required Features</strong>:</p>
<div class="sourceCode" id="cb21">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true"></a><span class="kw">function</span> mytheme_setup<span class="ot">()</span> {</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true"></a>    <span class="co">// Title tag (required)</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;title-tag&#39;</span> <span class="ot">);</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true"></a></span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true"></a>    <span class="co">// Automatic feed links (required)</span></span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;automatic-feed-links&#39;</span> <span class="ot">);</span></span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true"></a></span>
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true"></a>    <span class="co">// HTML5 support (recommended)</span></span>
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;html5&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true"></a>        <span class="st">&#39;search-form&#39;</span><span class="ot">,</span></span>
<span id="cb21-11"><a href="#cb21-11" aria-hidden="true"></a>        <span class="st">&#39;comment-form&#39;</span><span class="ot">,</span></span>
<span id="cb21-12"><a href="#cb21-12" aria-hidden="true"></a>        <span class="st">&#39;comment-list&#39;</span><span class="ot">,</span></span>
<span id="cb21-13"><a href="#cb21-13" aria-hidden="true"></a>        <span class="st">&#39;gallery&#39;</span><span class="ot">,</span></span>
<span id="cb21-14"><a href="#cb21-14" aria-hidden="true"></a>        <span class="st">&#39;caption&#39;</span><span class="ot">,</span></span>
<span id="cb21-15"><a href="#cb21-15" aria-hidden="true"></a>        <span class="st">&#39;style&#39;</span><span class="ot">,</span></span>
<span id="cb21-16"><a href="#cb21-16" aria-hidden="true"></a>        <span class="st">&#39;script&#39;</span><span class="ot">,</span></span>
<span id="cb21-17"><a href="#cb21-17" aria-hidden="true"></a>    <span class="ot">)</span> <span class="ot">);</span></span>
<span id="cb21-18"><a href="#cb21-18" aria-hidden="true"></a></span>
<span id="cb21-19"><a href="#cb21-19" aria-hidden="true"></a>    <span class="co">// Post thumbnails (recommended)</span></span>
<span id="cb21-20"><a href="#cb21-20" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;post-thumbnails&#39;</span> <span class="ot">);</span></span>
<span id="cb21-21"><a href="#cb21-21" aria-hidden="true"></a></span>
<span id="cb21-22"><a href="#cb21-22" aria-hidden="true"></a>    <span class="co">// Custom logo (recommended)</span></span>
<span id="cb21-23"><a href="#cb21-23" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;custom-logo&#39;</span> <span class="ot">);</span></span>
<span id="cb21-24"><a href="#cb21-24" aria-hidden="true"></a></span>
<span id="cb21-25"><a href="#cb21-25" aria-hidden="true"></a>    <span class="co">// Selective refresh (recommended)</span></span>
<span id="cb21-26"><a href="#cb21-26" aria-hidden="true"></a>    add_theme_support<span class="ot">(</span> <span class="st">&#39;customize-selective-refresh-widgets&#39;</span> <span class="ot">);</span></span>
<span id="cb21-27"><a href="#cb21-27" aria-hidden="true"></a>}</span>
<span id="cb21-28"><a href="#cb21-28" aria-hidden="true"></a>add_action<span class="ot">(</span> <span class="st">&#39;after_setup_theme&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_setup&#39;</span> <span class="ot">);</span></span></code></pre>
</div>
<p><strong>Prohibited</strong>:</p>
<ul>
<li>No hardcoded links (except WordPress.org)</li>
<li>No analytics/tracking code</li>
<li>No advertisements</li>
<li>No encoded/obfuscated code</li>
<li>No external dependencies without user permission</li>
<li>No upselling in theme options</li>
</ul>
<h2 id="testing">Testing</h2>
<p><strong>Use Theme Check Plugin</strong>:</p>
<p>Install Theme Check plugin to identify issues before submission.</p>
<p><strong>Test With</strong>:</p>
<ul>
<li>Fresh WordPress installation</li>
<li>Default content (Theme Unit Test)</li>
<li>Multiple browsers</li>
<li>Various screen sizes</li>
<li>Accessibility validators</li>
<li>PHP error reporting enabled</li>
</ul>
<p><strong>Enable Debugging</strong>:</p>
<div class="sourceCode" id="cb22">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true"></a><span class="co">// wp-config.php</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true"></a><span class="fu">define</span><span class="ot">(</span> <span class="st">&#39;WP_DEBUG&#39;</span><span class="ot">,</span> <span class="kw">true</span> <span class="ot">);</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true"></a><span class="fu">define</span><span class="ot">(</span> <span class="st">&#39;WP_DEBUG_LOG&#39;</span><span class="ot">,</span> <span class="kw">true</span> <span class="ot">);</span></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true"></a><span class="fu">define</span><span class="ot">(</span> <span class="st">&#39;WP_DEBUG_DISPLAY&#39;</span><span class="ot">,</span> <span class="kw">false</span> <span class="ot">);</span></span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true"></a><span class="fu">define</span><span class="ot">(</span> <span class="st">&#39;SCRIPT_DEBUG&#39;</span><span class="ot">,</span> <span class="kw">true</span> <span class="ot">);</span></span></code></pre>
</div>
<h2 id="conclusion">Conclusion</h2>
<p>WordPress theme development best practices ensure quality through coding standards compliance, security measures, and accessibility requirements. Follow WPCS formatting guidelines, escape all output with esc_html/esc_attr/esc_url functions, sanitize user input preventing XSS vulnerabilities, implement proper script/style enqueueing, make themes translation-ready, and meet theme review requirements. Professional themes prioritize maintainability, performance, security, and user experience through established WordPress development standards.</p>
<h2 id="external-links">External Links</h2>
<ol type="1">
<li><a href="https://developer.wordpress.org/coding-standards/wordpress-coding-standards/">WordPress Coding Standards</a></li>
<li><a href="https://make.wordpress.org/themes/handbook/review/">Theme Review Guidelines</a></li>
<li><a href="https://developer.wordpress.org/plugins/security/data-validation/">Data Validation</a></li>
<li><a href="https://wordpress.org/plugins/theme-check/">Theme Check Plugin</a></li>
<li><a href="https://make.wordpress.org/accessibility/handbook/">Accessibility Handbook</a></li>
</ol>
<h2 id="call-to-action">Call to Action</h2>
<p>Professional themes need reliable backups. <a href="https://backupcopilotplugin.com/">Backup Copilot Pro</a> protects your WordPress theme files and development work automatically. Safeguard your code—start your free 30-day trial today!</p>
<p>The post <a href="https://developryplugins.com/theme-development-best-practices-following-wordpress-standards/">Theme Development Best Practices: Following WordPress Standards</a> appeared first on <a href="https://developryplugins.com">Developry Plugins</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
