I’ve been using Foundation for a long time as my go-to front-end framework. I’ve been very grateful for the Foundation Press starter theme. While some starter themes are stripped too bare and others come loaded with too much, Ole Fredrik’s theme strikes the Goldilocks zone. I’m also a big fan of how quickly the folks over at Zurb keep pushing Foundation. Bootstrap is great but moves a lot more slowly because of its immense popularity.
But when I build a custom theme for a client I want every detail to be just right. That includes the names of functions, the textdomain, and lots of other little details. Unfortunately, it’s a little tricky to replace all the references to “foundationpress” with the new theme name. However, the fine folks over a Automattic solved this problem for their Underscores theme and were kind enough to open source the plugin they wrote.
So I’ve adapted that plugin here so you can make your own customized FoundationPress theme. Just head over to the Generator page and fill out the form and you’ll get the latest version of FoundationPress custom-named to start your next project.
I mostly use the Git version control system in my workflow. The one exception is for WordPress.org plugin repos that still use SVN. Since I rarely use it I just spent a ton of time re-learning how to deal with it to update my Featured Authors Widget plugin. Here are my notes. This is mostly to jog my own memory later but maybe someone will find this helpful.
- Spin up a local development environment.
- Navigate to the plugins directory in terminal
- Check out trunk into an appropriately named directory with
svn co http://plugins.svn.wordpress.org/example-plugin/trunk example-plugin
(that URL comes from the plugin repo on wordpress.org)
- Update the plugin as necessary
- Commit your changes back to the repo with
svn ci -m ‘updated readme after testing on WP 4.0.1’
- Go enjoy another cup of coffee.
I’ve posted up a plugin to the WordPress.org repository, Featured Authors Widget. I built it for Article-3.com but it’s a useful plugin for anyone with a multi-author WordPress site that wants to showcase particular authors.
I had a job that required creating a custom input filter for Drupal. It turns out to be pretty easy but I had a heck of a time finding documentation on it that made much sense to me so here’s my explanation of how to do it. The magic is all done by the PHP function preg_replace_callback() which takes as its arguments a regular expression (pattern) to search for, a callback function to take the stuff the expression finds and return you altered text to put in its place, and the big honking block of text to search through. So let’s start simple:
$world = 'world'; return $world;
All this will do is scan through $text and for each instance of hello with world. You can just use preg_replace for that. But it gets a lot more interesting when you start adding options to your regex like the very useful collapsible text module for Drupal:
$text = <a href="http://www.php.net/preg_replace_callback">preg_replace_callback</a>('/
\[ # look for an opening bracket collapse # followed by the word `collapse`
(\ collapsed)? # followed by (optionally) a space and the word `collapsed` (captured)
(?:\ style=([^\] ]*))? # followed by (optionally) a space and a style, consisting of any # characters except a close bracket (captured)
(?:\ title=([^\]]*))? # followed by (optionally) a space and a title, consisting of any # characters except a close bracket (captured)
\] # followed by a closing bracket (.+?)
# then capture as few characters as possible until \[\/collapse\]
# a closing "tag", which is a slash followed by `collapse` in brackets
#and then after the regex delimiter, we'll turn on 3 regex options
#s so dot matches all characters, m to match embedded newlines
#x so we can do free spacing and add these wonderful comments
/smx', "_collapse_text_replace_callback", $text);
We’ll pause a second to review that regex. What this means is that editors can do all sorts of things from the simple
to the complete
Hello World [/collapse]
The result is passed to your callback function, _collapse_text_replace_callback as an array. Element 0 is the full match. So
global $base_url; $collapsed = ($matches == ' collapsed');
$style = <a href="http://www.php.net/trim">trim</a>($matches); $title = <a href="http://www.php.net/trim">trim</a>($matches);
$interior = $matches;
//the authors of this module do lots of cool stuff in here, check it out.
So in the simple use case, the first element doesn’t contain collapsed so that’s false so do x. In the more complicated use, it does so do y. Likewise, the more complex use strings for $style, and $title.
I just posted a first pass at updating the Galleria module http://drupal.org/node/802206 for Drupal to use the new Galleria 1.2 code. If you’re a Galleria user, have a look. I’m not sure that it makes any sense to continue it as a module since it’s so easy to implement it in your Drupal Theme and all the magic happens in your Galleria Theme now.