Interrupting Web Developers
A Theme Framework, Child Themes, & Grandchild Themes
Grandchild themes? Really? Yes, they are possible but not popular with many lead developers arguing against this practice. Justin Tadlock, for example, writes an excellent post against the argument of creating grandchild themes, which PostStatus concurs with an apt statement: Grandchild themes solve "a problem to a bad architecture." While I am not sure that it is "a bad architecture" per se, but more a bad practice that creates a bad architecture.
Are grandchild themes possible? Yes. Are they maintainable? Yes with some great difficulty though not scalable. Is there ever an instance where it should be used? Possibly. The only scenario I can conceive is as part of an internal multi-site/sub-sub-site but besides this rare occasion, at the moment I cannot think of any that would justify the use of a grandchild theme over developing via branches.
So, let's look at these four: theme frameworks, parent themes, child themes, and grandchild themes a bit more closely.
Theme Frameworks
Justin Tadlock defines a theme framework as...
a set of conventions to use for developing WordPress [parent] themes.
Yet, I would differentiate between a a framework from a theme framework using the former in its more pure scope meaning "a reusable set of libraries, functions, classes for a system" or as Justin defines it "a set of conventions." A theme framework, on the other hand, is a parent theme that implements a framework. A framework displays nothing on the front-end or the back-end. In WordPress terms, a framework does not include or require to contain a functions.php
or a style.css
, as Hybrid Core. If I carry this to other themes or theme frameworks, I believe that "themes" like Genesis are theme frameworks as their primary purpose is to be extended and serve as a framework, yet there is a front-end and a back-end that is ready to be used and customized out-of-the box.
In other words, a theme framework is a parent theme or an advanced parent theme, as some call theme. Genesis, a theme framework, is an advanced parent theme.
Parent Themes
A theme is a completely new front-end layout of a WordPress site. While theme frameworks are always parent themes, not all parent themes are theme frameworks. Just like how all squares are rectangles ut not all rectangles are squares. Suares are a specific subset of rectangles.
Parent themes can be a fork of a theme framework as part of its core, and a parent theme can be a theme that sits on a framework within itself. Simply, parent themes use the WordPress installation and adds various forms of presentations and formats.
Child Themes
A Child Themes is:
a theme that inherits the functionality of another theme, called the parent theme. Child themes allow you to modify, or add to the functionality of that parent theme. A child theme is the safest and easiest way to modify an existing theme, whether you want to make a few tiny changes or extensive changes. Instead of modifying the theme files directly, you can create a child theme and override within.
As Justin later notes, child themes solve the problem of safe upgradability, which is imperative. For example, if you update and customize Twenty Eleven or Twenty Twelve, every time WordPress upgrades, you get in danger of losing all or some your theme customizations. However, if you use a child theme of those, then you can easily update without thinking twice. This is one reason why the upgrades of Genesis go so smoothly!
Child themes are typically done as a WordPress theme, and there are two plugins which assist you in making child themes:
- Child Themify (Downloads: [plugin_info slug="child-themify" data="downloaded"]): [plugin_info slug="child-themify" data="short_description"]
- Orbisius Child Theme Creator (Downloads: [plugin_info slug="child-themify" data="downloaded"]): [plugin_info slug="child-themify" data="short_description"]
Grandchild Themes
By default, WordPress cannot create a grandchild theme even though Smashing Magazine wrongly states this. However, Mark Barnes and AppThemes write a great tutorials on how to create a grandchild theme.
So why do some people believe they need to have grandchild themes? Theme shops like StudioPress focus on creating child themes that modify Genesis, the parent theme framework, with a few different functions, etc. Recently, Genesis has been updating some of these themes (e.g., Lifestyle, Outreach). However, in these updates, many have a new slug which forces people to properly upgrade a site manually. However, Lifestyle (among others), for example, did upgrade with the same folder slug. So having a site created based on this child theme that implemented a grandchild theme workflow would make maintenance, err upgrading, easier. However, in my opinion, this complicates the workflow, harms the client (who would just click upgrade without thinking through the ramifications and implications as would some novice developers), and is a lazy approach to keeping up code on a site. Furthermore, the upgrade in a Genesis child theme is never security as that is 100% addressed in the advanced parent theme. Instead, these upgrades are purely aesthetic.
In the comments of Mark Barnes's article, Eric Mann gives a great rationale and better workflow to editing a child theme than using grandchild themes stating:
If you are using a child theme for a system like Genesis, then you should fork it rather than try to hack your presentation into a plugin. Throw the current version of the child theme into Git or SVN, then create a dev branch to contain your customizations. If (and this is a big “if” since most won’t) the child theme is update, you can create a diff between the original and the new version using your VCS and apply the diff to your branch.
Is it more work? Yes. Is it an ugly hack using a plugin? No. Work with what you have, but don’t advocate a system like this that introduces a third level of moving parts into the theme’s presentation
Eric previously gives these reasons against Grandchild themes:
- Arbitrary limitation would need to be imposed on theming.
- A difficult, near impossible troubleshooting workflow
- Multiple developers, multiple development patterns
- Theme distribution of a grandchild theme is untenable
Conclusion
Personally, I don't believe grandchild themes will ever be implemented or supported in WordPress core, and rightly so. I believe that developers should seriously consider the relationships between their theme frameworks and child themes and possibily create a workflow that resembles a true framework, multiple advanced parent themes, allowing their customers to implement with child themes. However, with theme shops like Genesis or Thesis, this is more difficult as the advanced parent themes generate a lot of revenue. So, besides being a change within a development model, it would be a change in revenue and business models for them. And both models work well and address different user/client needs. I think StudioPress has created an excellent model which Nathan Rice, the lead developer behind Genesis, writes:
I was convinced that users would have a hard time with the Genesis concept, but to my surprise, we've evidently stumbled on something that users really love. My guess is that grandchild themes, or any attempt to synthesize that concept, would disturb the balance of an otherwise extremely popular methodology.
Have you ever used grandchild themes? Ever heard of them? Think they are a good idea? bad idea?
Beginner Developer Series: Setting Up Your Computer: Mac v. Windows
Computer setup is essential. But before we can get to the software, we must talk about the essential computer parts or the hardware. If you have the liberty to purchase a new computer, you need to decide whether you should get a Windows machine or a Mac (or even a Linux): the Mac v. Windows debate.
If you are struggling with this decision, and you are like me, the struggle is between a Windows machine and a Mac. For me, I am a Mac wannabe; however, with the hype of Macs, the beautiful design and Mac user experience, your reputation with your peers and colleagues who are die-hard Mac lovers, and the financial burden Macs impose, I struggle deeply. Read this article from Lifehacker: Mac vs. Windows: Your Best Arguments. But if I may, let me do a brief comparision.
Design
Macs branded all their products well with a streamlined, expected, beautiful, crisp, clean, and near perfect design. Steve Jobs's passion for an awesome design was paralleled by no other, and this has resulted in Apple's current reputation as being more hip and advanced than that of its competitor: the Windows PC. Yet, the Windows PC, due to its open philosophy, has a multitude of designs, brands, and looks. Because of this, neither has an edge and it comes down to preference 100%.
Price
To me, this is the biggest issue I have with Apple products. Yet from a business perspective, I cannot argue with them. Yet, one cannot compare base prices with one another because they are truly incomparable due to the two machines containing different hardware (processor, RAM, hard drive capacity, graphics card, USB ports, etc) and software (Mac OS, Mac Software v. Windows OS, Microsoft Software).
Software
While there is an abundance of great software for designers and developers, Macs tend to lack in this area especially as it pertains to normal business applications and even gaming. Most gamers prefer some sort of serious customization, which is not as easily attainable with a Mac. Since Microsoft doesn't make hardware like Apple does, it only makes sense that there
Yet, since we are talking about WordPress design and development, I personally do not believe that there is an edge either way. But we will talk more about this in the next post.
Security
Here is a another difference between Macs and PCs. Some of this is more pereception than reality as many would say that Macs never get viruses. There is no doubt or debtae that a Mac user is less likely to be infected by a computer virus because the iOS, a UNIX-based system, is more compartmentalized than a Windows machine. Because the majority share of computers tend to run Microsoft Windows, most viral attacks focus on Windows-based operating machines with malware like Trojans, fake antivirus programs and bots, and other spyware. Yet, these are rarely found on Macs; however, this is not due to Macs having a better security system. Personally, Mac users can be more vulnerable since they often take this notion for granted and don't protect themselves with some sort of anti-virus.
Conclusion
It really, 100% boils down to preference, choice, value, and finances. Simply, if you have the finances, aren't a serious gamer, or don't care about massive customization, then Macs are a great choice. Besides the obvious differences above, Apple provides a much better customer experience both in support and computer setup than a Windows PC. And if you like this and are willing to pay for it because of the provided value, then by all means go for it. However, since I have been a Windows user since DOS and Windows 3.0, it is better the devil I know... However, read this great article by the NextWeb from Owen Williams who documents his thoughts on switching from Windows to Mac.
Popular WordPress SQL Scripts: User Administration
Here are some of the most common WordPress SQL user administration scripts that I run.
Backup! Backup! Backup!
First and foremost, before manipulating the database, ALWAYS back it up!
I am going to assume that you have access via a WordPress SQL Plugin or phpMyAdmin.
Remember, if you are like me and change the prefix, be sure to change the wp_ prefixes below to whatever your prefix is. I have added myprefix_ to help demonstrate where this change would be.
Change Default Administrator Name
UPDATE wp_users SET user_login = 'NewName' WHERE user_login = 'Admin'; | |
UPDATE myprefix_users SET user_login = 'NewName' WHERE user_login = 'Admin'; |
Reset User Password
UPDATE wp_users SET user_pass =md5('newpassword') WHERE user_login = 'yourusername'); | |
UPDATE myprefix_users SET user_pass =md5('newpassword') WHERE user_login = 'yourusername'); |
Delete Orphaned User Meta
DELETE FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users) | |
DELETE FROM myprefix_usermeta WHERE user_id NOT IN (SELECT ID FROM myprefix_users) |
Replace User Meta
UPDATE wp_usermeta SET meta_key = REPLACE (meta_key, 'old_name', 'new_name'); | |
UPDATE myprefix_usermeta SET meta_key = REPLACE (meta_key, 'old_name', 'new_name'); |
Add New Admin User
In the example below, I am using an ID of 2. Change this number to the next user available, or some safe high number.
INSERT INTO databasename.wp_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES ('2', 'admin_demo', MD5('demo_password'), 'Travis Smith', '[email protected]', 'http://wpsmith.net/', '2014-02-15 00:00:00', '', '0', 'Travis Smith'); | |
INSERT INTO databasename.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); | |
INSERT INTO databasename.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'wp_user_level', '10'); | |
INSERT INTO databasename.myprefix_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES ('2', 'admin_demo', MD5('demo_password'), 'Travis Smith', '[email protected]', 'http://wpsmith.net/', '2014-02-15 00:00:00', '', '0', 'Travis Smith'); | |
INSERT INTO databasename.myprefix_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'myprefix_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); | |
INSERT INTO databasename.myprefix_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'myprefix_user_level', '10'); |
Delete Unknown Users
This will delete users not found in comments or as an author of a post. Do not use this script for community sites or sites with Subscribers.
DELETE FROM wp_users WHERE ID > 1 AND ID NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND ID NOT IN (SELECT DISTINCT user_id FROM wp_comments); | |
DELETE FROM wp_usermeta WHERE user_id > 1 AND user_id NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND user_id NOT IN (SELECT DISTINCT user_id FROM wp_comments); | |
DELETE FROM wp_links WHERE link_owner > 1 AND link_owner NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND link_owner NOT IN (SELECT DISTINCT user_id FROM wp_comments); | |
DELETE FROM myprefix_users WHERE ID > 1 AND ID NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND ID NOT IN (SELECT DISTINCT user_id FROM myprefix_comments); | |
DELETE FROM myprefix_usermeta WHERE user_id > 1 AND user_id NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND user_id NOT IN (SELECT DISTINCT user_id FROM myprefix_comments); | |
DELETE FROM myprefix_links WHERE link_owner > 1 AND link_owner NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND link_owner NOT IN (SELECT DISTINCT user_id FROM myprefix_comments); |
Get All Admins
SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u INNER JOIN wp_usermeta m ON m.user_id = u.ID WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%admin%' ORDER BY u.user_registered | |
SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM myprefix_users u INNER JOIN myprefix_usermeta m ON m.user_id = u.ID WHERE m.meta_key = 'myprefix_capabilities' AND m.meta_value LIKE '%admin%' ORDER BY u.user_registered |
- « Previous Page
- 1
- …
- 6
- 7
- 8
- 9
- 10
- …
- 60
- Next Page »