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

<channel>
	<title>WordPress theming Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/tag/wordpress-theming/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/tag/wordpress-theming/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Sat, 16 Dec 2017 02:09:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">37896774</site>	<item>
		<title>Touring a New(ish) Site</title>
		<link>https://www.rweber.net/projects/touring-new-site/</link>
					<comments>https://www.rweber.net/projects/touring-new-site/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 13 Jun 2016 12:00:34 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress plugins]]></category>
		<category><![CDATA[WordPress theming]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39593</guid>

					<description><![CDATA[<div><img width="185" height="300" src="https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-185x300.png" class="attachment-medium size-medium wp-post-image" alt="illustration of woman pointing, from Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-185x300.png 185w, https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-93x150.png 93w, https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640.png 395w" sizes="(max-width: 185px) 100vw, 185px" /></div>
<p>We recently launched an extensive WordPress site, so let me show you around. This is not a discussion of design, but rather of all of the pieces I put together: CSS, custom functionality, plugins.</p>
<p>The post <a href="https://www.rweber.net/projects/touring-new-site/">Touring a New(ish) Site</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="185" height="300" src="https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-185x300.png" class="attachment-medium size-medium wp-post-image" alt="illustration of woman pointing, from Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-185x300.png 185w, https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640-93x150.png 93w, https://www.rweber.net/wp-content/uploads/2016/04/mademoiselle-307923_640.png 395w" sizes="auto, (max-width: 185px) 100vw, 185px" /></div><p>What turned out to be my last major job before starting at King Arthur was <a href="http://www.secondgrowth.org">a new website for Second Growth</a>, a local nonprofit dedicated to treatment, recovery, and prevention of substance abuse in adolescents and young adults. Before I came on board with Aquilino Arts my partner had set them up with a lovely Joomla site, but it was hard to update in terms of both content and software. It was time to shift to WordPress, and clean up and reorganize a little at the same time. I was involved in the organization &#8211; though we stuck fairly close to the previous structure &#8211; and gave feedback and input on the design, but my main job was the technical aspects. I wanted to discuss them here because it is our most sophisticated site to date and it gives a fairly thorough overview of my methods for site construction.</p>
<p>By the way, I have a <a href="https://www.pinterest.com/aquilinoarts/wordpress-plugins-we-use/">Pinterest board devoted to plugins we use</a>, which you can take as recommendations.</p>
<p><a href="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite.png" rel="attachment wp-att-39690"><img decoding="async" src="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite-453x1024.png" alt="screencap of front page of secondgrowth.org" width="453" height="1024" class="alignleft size-large wp-image-39690" srcset="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite-453x1024.png 453w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite-133x300.png 133w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite-768x1737.png 768w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite-66x150.png 66w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthFullSite.png 905w" sizes="(max-width: 453px) 100vw, 453px" /></a> The front page starts with a mosaic; the left half has a YouTube video and a mini-menu, the right half is split into 3 pieces whose contents can be changed from within the Customizer. The theme is set to use two menus, intended to be the mini-menu and a full menu. The mini-menu includes a link to the full menu; the full menu appears in the footer, which is where the link goes, but if you have JavaScript, it hijacks the link and pops the full menu up in a lightbox (the method is shown almost exactly in <a href="https://www.rweber.net/web-development/wordpress/ajax-in-wp-a-simple-example/">my post about AJAX in WordPress</a>).</p>
<p>Below the mosaic and a divider band, there are three more spots whose contents can be set in the Customizer. In every case the options are a page, a specific blog post, or the latest blog post. The footer includes not only the full menu but a 2-up slider of donor logos. The gallery uses <a href="https://wordpress.org/plugins/media-library-assistant/">Media Library Assistant</a> to allow logos to be selected by categorizing them appropriately on the back end and is set to have two columns and random order. <a href="http://flickity.metafizzy.co/">Flickity</a> applies itself after page load and turns each column into a panel of the slider. All gallery/slider and lightbox functionality (which is via <a href="http://www.jacklmoore.com/colorbox/">Colorbox</a>) is in a custom plugin so it can persist should they change their theme down the road. The choice of Flickity and Colorbox is semi-arbitrary; I&#8217;m familiar with both of them and they do what I want. I&#8217;ve never written about Colorbox here, but <a href="https://www.rweber.net/tag/flickity/">I&#8217;ve written fairly extensively about Flickity</a>.</p>
<p><a href="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage.png" rel="attachment wp-att-39691"><img decoding="async" src="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage-424x1024.png" alt="screencap of blog page of secondgrowth.org" width="424" height="1024" class="alignleft size-large wp-image-39691" srcset="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage-424x1024.png 424w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage-124x300.png 124w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage-768x1853.png 768w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage-62x150.png 62w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthInteriorPage.png 849w" sizes="(max-width: 424px) 100vw, 424px" /></a> On interior pages the mini-menu appears as the top-of-page menu; the logo gets you back home if you don&#8217;t want to use the full menu popup. Certain content is accordion-folded, which is also provided by the custom plugin but is hand-coded. Different pages have different sidebar content via <a href="https://wordpress.org/plugins/display-widgets/">Display Widgets</a>, chosen as the least awkward of the options. Almost all of them have a donate button and contact link; most have a two-column gallery of donor logos; a couple have a still of the home page&#8217;s YouTube video that lightboxes up into a watchable video. One has 1-up slider of photos, chosen via Media Library Assistant&#8217;s tagging system.</p>
<p>The contact form is from <a href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a>, because of the option of <a href="http://contactform7.com/selectable-recipient-with-pipes/">Selectable Recipient with Pipes</a>, including the ability to use the pre-pipe content by prefixing the label with _raw_. The event calendar is <a href="https://wordpress.org/plugins/event-organiser/">Event Organiser</a>, chosen because it does recurring events and is developer-friendly. I didn&#8217;t end up turning off the original CSS, but I found it reassuring that the developer included that option. It provides for per-category colors, which we used to make one-off events stand out from weekly recurring events, and also produces the lists of upcoming events that appear on the home page (set to show only the next instance of any recurring event) and in the sidebar of one of the interior pages.</p>
<p>There are two custom post types aside from contact forms and events, both created and given custom taxonomies using <a href="https://wordpress.org/plugins/custom-post-type-ui/">Custom Post Type UI</a>. One is testimonials, which currently only exist in the sidebar of one page (a single random one selected and shown by <a href="https://wordpress.org/plugins/flexible-posts-widget/">Flexible Posts Widget</a> with a custom template &#8211; and by the way you can get <a href="https://github.com/ReveWeber/flexible-posts-widget">all my custom FPW templates on GitHub</a>). The other is resources. The resources archive and news (blog) archive look similar: they are topped with buttons for each category (or topic, the resource-specific hierarchical taxonomy) and for the whole archive. These buttons are coded into the archive templates. The list of all resources actually excludes one of the categories; resource archives also display alphabetically by title instead of by date and with more allowed per page.</p>
<p>The news archive shows the featured image and an excerpt; the resource archive shows the full content with no image. Featured images aren&#8217;t set to automatically show on any of the individual posts or pages; they are used for the front page featured content and news archive only.</p>
<p><a href="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthNarrow.png" rel="attachment wp-att-39692"><img loading="lazy" decoding="async" src="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthNarrow-154x1024.png" alt="screencap of contact page of secondgrowth.org at a narrow width" width="154" height="1024" class="alignleft size-large wp-image-39692" srcset="https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthNarrow-154x1024.png 154w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthNarrow-45x300.png 45w, https://www.rweber.net/wp-content/uploads/2016/04/SecondGrowthNarrow.png 308w" sizes="auto, (max-width: 154px) 100vw, 154px" /></a> The theme is fully responsive, and below a certain width the two-column donor logo galleries are hidden so as not to make the page infinitely long. When at &#8220;full size&#8221; the right sidebar is positioned and sized via <code>display: table-cell</code>. This caused some problems on Firefox with the pages with the video still in the sidebar, where the sidebar was displaying far wider than it was set to (35%). The fix was to set <code>width: 100%</code> on the still (in addition to the <code>max-width: 100%</code> set on all images in the theme). It was tricky to repair because my browsers have gotten very tenacious about using the old CSS file, regardless of hard refresh or cache clearing, until I change the version number. I&#8217;d switched to CSS tables because I was having the same problem in Flexbox, but since then have determined the same fix would have worked for Flexbox.</p>
<p>Using CSS tables or Flexbox was important for getting the main content and sidebar to be the same height, since the leafy divider is actually a small vertically-repeating background image on the sidebar, transparent beyond the leaves on the sidebar side and with solid white background (covering the translucent green background of the sidebar) on the main content side. When the sidebar drops below we switch the image and its positioning and repeat settings.</p>
<p>Originally the footer used CSS columns, as well as the sidebar when it dropped below but had width enough for multiple widgets, but then I discovered Flickity doesn&#8217;t play well with CSS columns. <em>At all.</em> I had crazy spillover outside the Flexbox viewport that I couldn&#8217;t figure out how to fix. No more CSS columns; they are now done the old fashioned way with percentage width and floating.</p>
<p>The behind the scenes plugins in the site are <a href="https://wordpress.org/plugins/wp-smushit/">WP Smush</a> for image optimization, <a href="https://wordpress.org/plugins/wp-spamshield/">WP-SpamShield</a> for comment spam elimination, <a href="https://wordpress.org/plugins/google-analytics-for-wordpress/">Google Analytics by Yoast</a>, and <a href="https://wordpress.org/plugins/w3-total-cache/">W3 Total Cache</a> for caching. With such an image-heavy site both image optimization and caching are key elements. I didn&#8217;t use <a href="https://wordpress.org/plugins/wp-fastest-cache/">WP Fastest Cache</a> because the free version has to be cleared from the hosting account if you haven&#8217;t just published a post or page &#8211; changing the featured items in the front page won&#8217;t do it. W3TC doesn&#8217;t detect changes in the front page but you can clear its cache from a button at the top of any of its pages.</p>
<p>The post <a href="https://www.rweber.net/projects/touring-new-site/">Touring a New(ish) Site</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/projects/touring-new-site/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39593</post-id>	</item>
		<item>
		<title>WordPress Customizer resources</title>
		<link>https://www.rweber.net/javascript/wordpress-customizer-resources/</link>
					<comments>https://www.rweber.net/javascript/wordpress-customizer-resources/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 21 Mar 2016 12:00:21 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP and MySQL]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Customizer]]></category>
		<category><![CDATA[WordPress theming]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39544</guid>

					<description><![CDATA[<div><img width="199" height="300" src="https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-199x300.jpg" class="attachment-medium size-medium wp-post-image" alt="photo looking down a library aisle" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-199x300.jpg 199w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-768x1158.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280.jpg 679w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-99x150.jpg 99w" sizes="auto, (max-width: 199px) 100vw, 199px" /></div>
<p>Slowly gathered and thoroughly weeded links to tutorials and other resources for incorporating the WordPress Customizer into your own themes - both PHP and JavaScript.</p>
<p>The post <a href="https://www.rweber.net/javascript/wordpress-customizer-resources/">WordPress Customizer resources</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="199" height="300" src="https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-199x300.jpg" class="attachment-medium size-medium wp-post-image" alt="photo looking down a library aisle" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-199x300.jpg 199w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-768x1158.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280.jpg 679w, https://www.rweber.net/wp-content/uploads/2016/03/books-684594_1280-99x150.jpg 99w" sizes="auto, (max-width: 199px) 100vw, 199px" /></div><p>I&#8217;ve spent a lot of time recently in the WordPress Customizer for this theme and a client theme, and have found it slow to locate helpful references and tutorials. Part of that was not learning until recently that you can put a single word in quotation marks to keep Google from helpfully trying other word forms and synonyms to get you more results (&#8220;custom&#8221; and &#8220;customize&#8221; are far from interchangeable with &#8220;Customizer&#8221; in this context, so <a href="http://searchresearch1.blogspot.com/2016/02/answer-how-to-find-compound-concepts.html">thank you SearchReSearch for the trick</a>), but some of it was a lack of good material.</p>
<p><em>On with the show&#8230;</em><br />
The fundamental source is the <a href="https://developer.wordpress.org/themes/advanced-topics/customizer-api/">Customizer page in the WordPress Developer Handbook</a>. What it covers it does well, but it is pretty cursory. In some ways I find the old <a href="https://codex.wordpress.org/Theme_Customization_API">Customizer information in the Codex</a> easier to read.</p>
<h3>Other General Tutorials and Examples</h3>
<p>WPShout is a reliable source for entry-level tutorials that aren&#8217;t shallow, and you may find their <a href="http://wpshout.com/making-themes-more-wysiwyg-with-the-wordpress-customizer/">Customizer introduction and overview</a> helpful.</p>
<p>Tom McFarlin wrote a tutorial series for WPTuts+ that is well-explained. You can find an <a href="https://tommcfarlin.com/wordpress-theme-customizer/">index for the WPTuts+ series</a> on his blog.</p>
<p>The WPTuts+ series is a few years old, as is this <a href="http://themefoundation.com/wordpress-theme-customizer/">Theme Foundation Customizer tutorial</a>, which moves a little faster but is a little more comprehensive. However, the basic syntax is largely unchanged.</p>
<p>There&#8217;s a <a href="http://www.noupe.com/wordpress/wordpress-theme-customizer-first-steps-95423.html">general introduction on Noupe</a> that covers some of the same ground, but in a different way and with some different inclusions.</p>
<p>Tom McFarlin has <a href="https://tommcfarlin.com/wordpress-theme-customizer-maintainability/">suggestions on organizing your code for maintainability</a> that will already be the case if you are working from <a href="http://underscores.me/">Underscores</a>.</p>
<p>Here are two WordPress themes on GitHub that use the Customizer and have authors who know a lot about the Customizer: <a href="https://github.com/justintadlock/hybrid-core/tree/dev/customize">Hybrid Core by Justin Tadlock</a>; <a href="https://github.com/chipbennett/oenology/blob/master/functions/options-customizer.php">Oenology by Chip Bennett</a>.</p>
<h3>Adding Custom Controls</h3>
<p>WordPress provides a number of control types: checkbox, radio button, select box, textarea, dropdown of pages, color picker, and media selector. You can add your own on top of these.</p>
<p>If you are adding controls, whether custom or built-in, the input needs sanitation; <a href="http://themeshaper.com/2013/04/29/validation-sanitization-in-customizer/">ThemeShaper has an article on validation and sanitation</a> for the Customizer.</p>
<p><a href="http://ottopress.com/2012/making-a-custom-control-for-the-theme-customizer/">Otto has a good introduction to custom controls</a> that is a little old but still relevant.</p>
<p><a href="https://premium.wpmudev.org/blog/creating-custom-controls-wordpress-theme-customizer/">WPMU DEV has another intro, including the built-in controls</a>, that might be good for a second explanation.</p>
<p><a href="http://justintadlock.com/archives/2015/06/04/customizer-radio-image-control">Justin Tadlock has a tutorial on a control that replaces radio buttons with images</a> but still acts as a radio button control.</p>
<p>I found it easiest to understand custom controls via example. There are lots of collections of premade custom controls on GitHub that you can use and learn from, with a variety of authors: <a href="https://github.com/WPTRT/code-examples/tree/master/customizer">the WordPress Theme Review Team</a>, <a href="https://github.com/paulund/wordpress-theme-customizer-custom-controls">Paul Underwood</a>, and <a href="https://github.com/bueltge/Wordpress-Theme-Customizer-Custom-Controls">Frank B&uuml;ltge</a> for three (but see <a href="https://www.rweber.net/web-development/wordpress/learn-by-doing-wordpress-customizer/#custom-control">last week&#8217;s post</a> for a caveat). Braad Martin has a control for a <a href="https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker">color picker with alpha</a>. You can also see custom controls in action in the <a href="https://github.com/xwp/wp-customize-posts">WP Customize Posts plugin by Weston Ruter</a>.</p>
<h3>Contextual Controls and Partial Preview Refresh</h3>
<p>Contextual controls are those that appear and disappear based on what you&#8217;re previewing or what choices you&#8217;ve made in other controls. It and partial refresh are frequently covered in the same articles so I grouped them together. I discuss both in <a href="https://www.rweber.net/web-development/wordpress/learn-by-doing-wordpress-customizer/">last week&#8217;s post</a>, for one.</p>
<p><a href="http://ottopress.com/2015/whats-new-with-the-customizer/">Otto talks about active_callback for contextual controls</a> in a post about recent changes to the Customizer as of May, 2015.</p>
<p>In a Stack Exchange answer, <a href="http://wordpress.stackexchange.com/questions/211779/customiser-active-callback-not-working-on-control-with-postmessage-transport/211953#211953">Weston Ruter discusses the JavaScript alternative to active_callback</a>.</p>
<p><a href="http://wpshout.com/polishing-the-wordpress-customizer-experience/">WPShout covers partial refresh and active_callback</a> in their follow-up to the general tutorial.</p>
<h3>The Future: More JavaScript, Less PHP</h3>
<p>Right now you can avoid JavaScript entirely provided you don&#8217;t mind the entire preview refreshing to update and you don&#8217;t want to hide and show controls dynamically. Since WordPress is great about back-compatibility, that probably will always be true. However, the future of the Customizer is in JavaScript. [Since the Customizer is pointless without JavaScript even my progressive-enhancement-obsessed soul can&#8217;t object.] Here are four links about using JavaScript for everything:</p>
<p><a href="https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/">Weston Ruter in Make WordPress Core</a> on how things work and where they&#8217;re going, October 2014.</p>
<p><a href="https://make.wordpress.org/core/2014/11/17/jsunderscore-template-rendered-custom-customizer-controls-in-wordpress-4-1/">Nick Halsey also in Make WordPress Core</a> on rendering custom controls with JavaScript, in particular; November 2014.</p>
<p>Justin Tadlock has also written about <a href="http://justintadlock.com/archives/2015/06/05/javascript-templating-in-the-wordpress-customizer">rendering custom controls with JavaScript</a>.</p>
<p>Finally, if you have a lot of options in the Customizer (the wisdom of that may be debatable) and they are injected with JavaScript, you may find your script is noticeably laggy. Here&#8217;s an article by Layers on <a href="http://www.layerswp.com/2015/07/how-to-speed-up-the-wordpress-customizer/">speeding up the Customizer via delayed loading of controls</a>.</p>
<p>I haven&#8217;t tried to implement a JavaScript-only Customizer in Amalgamation yet, but it&#8217;s on the list.</p>
<p>The post <a href="https://www.rweber.net/javascript/wordpress-customizer-resources/">WordPress Customizer resources</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/wordpress-customizer-resources/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39544</post-id>	</item>
		<item>
		<title>Learn by doing: the WordPress Customizer</title>
		<link>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/</link>
					<comments>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 14 Mar 2016 12:00:22 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP and MySQL]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Customizer]]></category>
		<category><![CDATA[WordPress theming]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39529</guid>

					<description><![CDATA[<div><img width="300" height="214" src="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg" class="attachment-medium size-medium wp-post-image" alt="Marionettes in a museum by Jürgen Howaldt via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-150x107.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85.jpg 512w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>My experience incorporating the WordPress Customizer into my theme Amalgamation; notes and things to watch out for on both the PHP and the JavaScript sides.</p>
<p>The post <a href="https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/">Learn by doing: the WordPress Customizer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="214" src="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg" class="attachment-medium size-medium wp-post-image" alt="Marionettes in a museum by Jürgen Howaldt via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-300x214.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85-150x107.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/03/TheaterFigurenMuseum_85.jpg 512w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>After the basics were in place, I started adding to Amalgamation (this site&#8217;s theme) to make it customizable for someone who might want, say, different pages featured in the front page&#8217;s panels. The correct place to put appearance-affecting settings is now the Customizer, which meant a lot of new learning.</p>
<p>It was not without its <s>swearing</s>difficulties, and for a while I had a nice little hack in place (labeled as such) but I got a handle on it and thought I&#8217;d write a bit about the parts that took me while to figure out or were difficult to find information on. This isn&#8217;t intended as a self-contained tutorial; I&#8217;ll follow this post up with a post of resources. <strong>Edit 3/12:</strong> The <a href="https://www.rweber.net/web-development/wordpress/wordpress-customizer-resources/">Customizer resource post</a> is up now.</p>
<h3>Customizer PHP</h3>
<p>In Amalgamation, this is all in <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/inc/customizer.php">customizer.php</a>.</p>
<p><a href="http://underscores.me/">Underscores</a> is a good start on the Customizer, especially for mimicking JavaScript syntax, but begins quite light on the PHP side. All it does is implement partial refresh for a few of the built-in settings. I wanted to add a bunch of new settings and also remove the irrelevant defaults, which you can see near the beginning of <code>amalgamation_customize_register()</code>.</p>
<p>There were two things I remember giving me pause when adding settings (<a href="http://pastebin.com/fdNX3AZ6">see code on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/fdNX3AZ6"></script></p>
<p>The first was keeping the pieces straight, including what needed the same name. The setup is a little convoluted; sections and controls are UI entities &#8211; they are about what appears and how in the Customizer pane. Settings are data entities &#8211; they hold the values you use controls within sections to select. That&#8217;s why they don&#8217;t exist within sections like controls do, and why the label and description are set within the control definition. They are, however, tightly coupled to controls, which is why they both get the same label as their first parameter.</p>
<p>The other mild slowdown was not knowing how to define a radio button selection, but hopefully my example makes it clear: in the choices array it is &#8216;setting&#8217;s value&#8217; => &#8216;value&#8217;s description&#8217;.</p>
<p><a id="custom-control"></a>WordPress has a page dropdown included, but I wanted to allow posts as well so I needed a custom control. I began by using a post select dropdown from <a href="https://github.com/paulund/wordpress-theme-customizer-custom-controls">Paul Underwood</a>, but changing the selection didn&#8217;t alert the Customizer that a change had been made &#8211; the Save button remained grayed out. Since I didn&#8217;t need the flexibility of that control I switched to one by <a href="https://github.com/tommusrhodus/">Tom Rhodes</a> that has since disappeared from his GitHub. That one worked, and I&#8217;ve since determined that the key was in the <code>select</code> element having the attribute <code>data-customize-setting-link="&lt;?php echo $this->id; ?&gt;"</code>. When I added that attribute to Paulund&#8217;s code, it worked as desired.</p>
<p>Note that the definition of the custom control needs to be accessible from within the function that&#8217;s adding the custom control. The easiest way to do that is to define it within the function, whether directly or via an include statement.</p>
<p>Using the settings in your theme is easy: <code>get_theme_mod( 'setting_name' );</code> returns (rather than echoes) the value.</p>
<h3>Customizer JavaScript</h3>
<p>This is in two files in Amalgamation: <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/js/customizer.js">customizer.js</a> and <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/js/customizer-controls.js">customizer-controls.js</a>; the enqueuings are in <a href="https://github.com/ReveWeber/Amalgamation-WP-theme/blob/master/inc/customizer.php">customizer.php</a>.</p>
<p>JavaScript is currently optional for the Customizer but developers are encouraged to use it for essentially all the functionality. I did not (though I intend to at least try it out in the future) but I made good use of JavaScript for dynamic display of controls in the sidebar and for partial refresh in the preview so a small change did not require the whole thing to reload.</p>
<p>The first thing to note is that there are two different actions to hook your script enqueue functions into, depending on whether the script affects the sidebar or the preview pane. The preview is in an iframe so it is effectively a completely separate website; scripts that live in one location can&#8217;t affect elements in the other.</p>
<p>For dynamic controls, the enqueue command is this (<a href="//pastebin.com/1gwtmpjm">view on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/1gwtmpjm"></script></p>
<p>You can code these as you would any other show/hide commands, but I found I needed to enclose them in an extra <code>$(function(){});</code> to delay execution and prevent them being overridden. The necessary ids for your elements will be generated following a standard pattern and are easy to find in the web inspector.</p>
<p>For preview AJAX, the enqueue command is this (<a href="//pastebin.com/hcfEsHLw">view on Pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/hcfEsHLw"></script></p>
<p>Note that I&#8217;m localizing the script also, as in <a href="https://www.rweber.net/web-development/wordpress/ajax-in-wp-a-simple-example/">my previous post about AJAX in WordPress</a>. This of course is only necessary if you actually plan to make AJAX calls. Within the script you have to follow the pattern</p>
<pre>wp.customize( 'setting_name', function (value) {
    value.bind(function (to) {
        // your css/html change or ajax call
    });
});</pre>
<p>If you leave out value.bind it won&#8217;t work. From what I understand, &#8220;value&#8221; here is the fact of the change, and &#8220;to&#8221; is the result or contents of the change (e.g. the color code, text of the byline, or id of the page you selected from the dropdown). Once you&#8217;re inside you can do whatever you want; it&#8217;s no different from JavaScript written from scratch to enact a change on the page. In particular <a href="https://www.rweber.net/web-development/wordpress/ajax-in-wp-a-simple-example/">AJAX works the same way as in WP at large</a>.</p>
<hr>
<p>There&#8217;s my contribution for now. Stay tuned for the resource post. <strong>Edit 3/21:</strong> <a href="https://www.rweber.net/web-development/wordpress/wordpress-customizer-resources/">My selection of customizer resources</a> is posted now.</p>
<p><small>Marionette photo by Jürgen Howaldt (Own work (selbst erstelltes Foto)) [<a href="http://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC BY-SA 3.0 de</a>], <a href="https://commons.wikimedia.org/wiki/File%3ATheaterFigurenMuseum_85.jpg">via Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/">Learn by doing: the WordPress Customizer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/learn-by-doing-wordpress-customizer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39529</post-id>	</item>
		<item>
		<title>A new and responsive look</title>
		<link>https://www.rweber.net/projects/a-new-and-responsive-look/</link>
					<comments>https://www.rweber.net/projects/a-new-and-responsive-look/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 07 Dec 2015 13:00:07 +0000</pubDate>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theming]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39407</guid>

					<description><![CDATA[<p>Welcome to the beta version of Amalgamation, my custom theme for this site, now the hub of my activities and online presences. Please <a href="/about/#contact">let me know what you think</a> or if you find any problems.</p>
<p>The post <a href="https://www.rweber.net/projects/a-new-and-responsive-look/">A new and responsive look</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Welcome to the beta version of Amalgamation, my custom theme for this site, now the hub of my activities and online presences. There were a few things still on my list to fix up when I impulsively put it up last Thursday evening, but I knew that list would grow anyway once I saw my real content.</p>
<p><a href="https://github.com/ReveWeber/Amalgamation-WP-theme">The code is on GitHub</a>, and once I get through the basic list I&#8217;ll start versioning it so it&#8217;s always safe to download and use.</p>
<p>Meanwhile I would love feedback. There&#8217;s only so much testing one person can do, especially on the local version. If you notice any brokenness or weirdness or just have an opinion, <a href="/about/#contact">please let me know!</a></p>
<p>The post <a href="https://www.rweber.net/projects/a-new-and-responsive-look/">A new and responsive look</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/projects/a-new-and-responsive-look/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39407</post-id>	</item>
	</channel>
</rss>
