Gary Jones https://garyjones.io Enterprise Engineer at WordPress VIP Mon, 30 Sep 2019 10:00:54 +0000 en-GB hourly 1 https://wordpress.org/?v=5.4.1 https://garyjones.io/wp-content/uploads/sites/2/2018/03/cropped-gary-jones-2017-32x32.jpg Gary Jones https://garyjones.io 32 32 152858125 Press This Podcast Transcript https://garyjones.io/press-this-transcript https://garyjones.io/press-this-transcript#respond Sat, 03 Nov 2018 10:47:42 +0000 https://garyjones.io/?p=9920 I was invited by David Vogelpohl to appear as a guest on the PressThis podcast, to talk about the Genesis Framework. Here is the transcript.

The post Press This Podcast Transcript appeared first on Gary Jones.

]]>
I was invited by David Vogelpohl to appear as a guest on the PressThis podcast, to talk about the Genesis Framework:

The rise and rise of the Genesis Framework with Genesis core contributor Gary Jones

The transcript is below.


Introduction Welcome to Press This, the WordPress community podcast featuring exclusive content and interviews with leaders in the WordPress community. Covering everything from development to integrating your digital marketing strategy with WordPress. Join host David Vogelpohl of WP Engine and special guests from across the community as they keep you up to speed on the latest advancements in WordPress. Let’s get started.

David Everyone, welcome to the Press This, WordPress community podcast on webmaster radio. This is your host, David Vogelpohl, and I support the WordPress community through my role at WP Engine, and I love to bring the best of the community to you here every week on Press This. As a reminder, you can always subscribe on iTunes or iHeartRadio or download the latest episodes at WebmasterRADIO.FM. In this episode, I’m really excited for this one, we’re gonna be covering the rise and rise of the Genesis framework. And in order to do that we brought a very special guest to the show, core contributor to Genesis and general community leader, Mr. Gary Jones. Gary, welcome to the show.

Gary Thank you much for the invite. How are you doing, David?

David Doing great. So glad to talk to you here today. I know, you and I spoke shortly after WP Engine acquired StudioPress and the Genesis framework, and I really enjoyed that opportunity to get to know you then. But also enjoying this opportunity today to get to know you a little bit better and share a little bit about the Genesis framework with those that are unfamiliar with it. So basically what we’re gonna be covering today are Gary’s thoughts on the kind of history and evolution of Genesis, the power of the community behind Genesis, which is really quite large and impressive, and then at the end really how brands and agencies use Genesis kind of in their day to day to scale the work they do and frankly to build better experiences. So fun, fun stuff. And if you’re unfamiliar with the Genesis framework, you’re on the right podcast. Gary’s quite an informed person. Gary, you have history, right? It’s not just like you picked up the Genesis framework last week.

Gary No, no. I’ve been using Genesis for about eight years now and contributing to it for all that time as well. So yeah, fairly in depth usage and knowledge of the code base and the community and everything that surrounds Genesis.

David Awesome. Well I know and I actually ran a Genesis agency for five years and was involved with the community. But you know, one of the roles I have at WP Engine was leading the acquisition team behind StudioPress, and your name just kept coming up over and over and over again. So again, super excited to have you here today to talk about these things. But you also have some big news. You just accepted a position. Is that correct, Gary?

Gary Yeah, it’s correct. After 10 years of running my own agency, which was a predominately Genesis-based agency as well, I have accepted an offer to be a VIP Developer at Automattic. I start as of the date of recording, next week. But as I think when this recording goes live, then it will be tomorrow.

David Yeah.

Gary Yep.

David There you go, you’re talking to future Gary now. But congratulations on that. Such a good company to get aligned with and glad you found a home there.

Gary Yeah, thank you very much, yeah.

David Awesome. You told us your Genesis origin story a little bit there, but I’m kind of curious. What is your WordPress origin story? How did you first get connected to the WordPress world?

Gary So I started many moons ago. My first real experience with writing code for the web was when I went to university back in 1998. The IT suites were available all night, and that was my first chance to experience kind of permanently connected web. The IT suites were rocking the latest in the browsers or Netscape Navigator and IE4 at that time. I soon found some online chat rooms. They’re not live now unfortunately, but they were a fairly simple affair. You type some text into a field, you hit submit, and every few seconds a page would reload with the updated chat from yourself and others.

Gary Some of the folks had color text, though, so I was wondering how they did that. And how they had different sized text and depending which browser you were using, the text scrolled across or the text flashed. When I found out how to do that, then it was the HML, and so my first introduction to coding was the font, marquee and blink tags. So it was a promising start. From there, I moved onto Geocities and as every self respecting new developer did in the ’90s. It was just static HTML pages. I later discovered that you had server-side includes and then CSS appeared and so I didn’t have to spend my days updating thirty different files just because I changed the photo for instance.

Gary During the eight years or so I graduated from university, I started teaching in schools and prisons. Moved my sites over to some proper hosting. The design still sucked, I’ve never claimed to be a designer. And it wasn’t yet WordPress but all that time it was just a hobby. Around 2007 I had to go to, went to Malaysia, my wife was sent on work out there. And because I wasn’t allowed to work out there then I started playing and discovered WordPress around then and started playing with it, experimenting and customizing. From that point I was definitely hooked into WordPress. It was right about version 2.3 at that time.

David You touched on a lot of bases there. You got IE4, you got flashing text, you got Geocities, you’re really building your resume up. I see why VIP at Automatic hired you Gary.

Gary Absolutely, I’m kind of top drawer. [crosstalk 00:05:31]

David … Just absolutely stellar resume here.

Gary I’m good. I mean and it’s fun to think of the history that someone like myself has gone through who’s completely self taught. We didn’t have the Zacs and the Weses around at the time to offer the courses on the latest and greatest within web development. If you didn’t go to university and learn it there, I mean my degree was in teaching so I was all self taught, and that for me has been the best way of doing it. I’ve taken the long way around, it’s taken twenty years. Eleven years of WordPress and ten years running an agency but that’s a lot of experiences and cases to come across. And be, not necessarily a better developer but an all-round developer because of that experience.

David Well, I’m with you there, coming up in the nineties having to be self taught. Because there certainly wasn’t, certainly college material but definitely even the courses and things we enjoy today so fun times. Now, shifting gears a little bit, kind of the topic of the podcast, is kind of around Genesis and what it is and why people use it and that kind of stuff. And obviously your role as a open source contributor to Genesis I think for all this time puts you in a unique position to answer these questions. You know this question comes up a lot to me but what benefits does Genesis afford to a business or agency? Why choose a theme framework like Genesis or any other of the theme frameworks out there?

Gary There’s a few different reasons but for me as business it was a chance to grow. Be able to grow my business because it was a tool that I could make use of, but also for my own brand and reputation that I wanted to establish myself. Not just in the WordPress niche of web development, but in the Genesis niche of the WordPress community. So it was my chance to be part of the community, to get involved. And if this was a tool that I was going to be basing my business on then I wanted to see it always be continued to be improved. By contributing to the code base I got exposure and referrals from Brian Gardner. People who were contacting him, somebody who wanted a website, wanted to a Genesis developer, he would pass those on to me.

Gary Also spending time in the forums and helping people in the Genesis … There was originally a Skype group and then there’s a Facebook group. There was a LinkedIn group. On Twitter at the moment obviously you’ve got a Slack workspace. I was getting referrals from other developers for projects that they couldn’t manage and doing code audits for them. Which helped to improve their coding abilities as well as whatever project they were working on. So even before you actually start looking at the code and how that can help speed development then the community is a big factor of why use Genesis.

David Yeah. It’s so funny, I asked you the question like what benefits did it provide and you didn’t talk about, in the beginning, around workflows. You didn’t talk about capabilities, you didn’t talk about features. You talked almost exclusively about the community. And I think, you know I think that’s one of the powers I think of WordPress, but then also certainly the Genesis sub-community. And you know as I’ve engaged with the community more, having been involved with it more, seeing that sub-community and how people help each other, how people help each other to succeed, and the benefits that they extract from participating and contributing, has really been really awe inspiring. And then to hear you have that be your first response was testament to that.

David Then if we switch gears a little bit, if the primary driver benefit for you is the strength of the community and how you were able to both contribute but then also extract value and benefit from participating, what is the more technical reasons? Why do people use Genesis and theme frameworks?

Gary It’s, I mentioned it briefly before, it’s the speed of development. The way Genesis is built and can be customized it’s makes use of the action and filter hooks rather than the template parts. And that benefits me. You don’t have to edit multiple files to make the same change in different contexts. And if you look at the latest Twenty Theme I think the main element appears seven times across various different files and templates. So if you want add an attribute to it it means editing seven files. Whereas Genesis, being a little bit more abstracted, means it’s four lines of code for me to add an attribute in there. The snippets to do any of those customizations or templates but also, you can have text or keyboard shortcuts in your IDE that makes dropping in the logic easier.

Gary For developers you’ve got the same code base to work on, whatever the site looks like. The visual design of what the child theme has to be to meet the requirements for the client is completely decoupled from Genesis itself and how you go about doing those customizations. You get built-in value for the client so you can let them choose the layout per page. Or it’s got the basic SEO field supports. And then there’s a ton of plugins that will allow them to choose what the footer or the hooked in content will contain. So it’s flexible for advanced developers but also for other, perhaps less-knowledgeable people.

David Novice people yeah, [crosstalk 00:10:54] I do want to touch on that, absolutely. I do want to touch on that. It’s interesting, but to just kind of recap, it’s efficiency because you’re working within a framework so you kind of have a bit of a common language. It’s abstracted or in a sense kind of decoupling the notion of your theme settings with your theme itself in some ways. So it enhances things like theme portability. But it was interesting to hear your observations on some of the benefits on the engineering side.

David And you started to talk about the novice side and what I want to do is after this quick break we’re going to come back and I want to kind of dig into a little bit of that kind of dual personality of Genesis. So everybody hang tight and we’ll be right back.

PART 1 OF 3 ENDS [00:12:04]

David Hello everyone, welcome back to The Press This, WordPress community podcast on WebmasterRADIO. This is your host David Vogelpohl and I’m interviewing Gary Jones, one of the core contributors to the Genesis Framework. And right before the break, Gary, you were sharing some of the benefits that Genesis provides to development teams. And you started to kind of get into a little bit about how Genesis can also be beneficial for the novice user, and you know, Genesis is kind of funny and the community is kind of funny because it has this duel personality, right? It helps novice people build better sites, but it also helps advanced teams build sites faster and more performant. So how do you think … you kind of share your thoughts on Genesis’s role for the advanced developer, what are your thoughts for, say, the more novice website user or person building their own site? What are the benefits of leveraging something like Genesis?

Gary The benefits, it comes from the same origin as the fact that Genesis is built on the Hooks API. So the same way that advanced teams can hook their customizations in directly is the same way that you can get tools like Design Palette PRO, or Genesis Extender, Genesis Layout Extras, Genesis Super Customizer. These are all plugins that are either free or premium in the WordPress space, either from StudioPress or from third parties that allow Genesis users, who are not comfortable in the command line or with code to make the changes that they want to do. It’s very easy to see, I mean, there’s so many Genesis specific plugins, it’s easy to see how Genesis acts a bit like a PostCSS or Remarq with all of their kind of respective, separate customization packages. It is the framework, it is the hub and there’s a lot of ways to extend that, that you aren’t just relying on the main Genesis itself. I think the main issue of this duel personality comes down to the marketing, is gonna be the tricky bit of the duel personality. It’s gonna be a fine line to balance.

Gary I mean, have a look at the plugin page on the StudioPress website, it mentions kind of 15 plugins that StudioPress has built and there’s only one from a third party there, yet there’s many free and open source plugins that exist on WordPress.org and GitHub.

David I think there’s 219 at my last count that are specific to Genesis on WordPress.org. And then countless-

Gary And there will be many more. I mean, I know I’ve got some on GitHub that I’ve not put on WordPress.org. But again, down to the marketing issue is that if you look on the main Genesis page it includes some words, ’cause I was looking at it earlier today, of “schema.org” and “microdata” and “turnkey designs”. Now, for some audiences that’s just gonna be jargon. As novice users, they’re not gonna know what that is, necessarily care what that is. And perhaps there’s some sort of level of education there, that they will benefit from this if they understood what it is. But yet, for other perhaps more advanced people, that might be exactly the type of features that they’re looking for. And so marketing, this duel personality kind of package is where the trick is, I think.

David Yeah, it certainly can be challenging speaking to both audiences. For me, I don’t know, if you think about the WordPress context for a minute, it also has this same issue or the same duel personality, where it’s used by novice, non web-developers, non-WordPress developers, extensively and millions of times. And then it’s also used by advanced teams of huge agencies building super complex things. And I don’t know, it’s almost like the flexibility of WordPress, but also in the Genesis context of flexibility of Genesis allows you to use tools that make it easy as a novice, but then also allows, say, your engineering team or your developer, or your agency to build crazy stuff, but build it in a way that makes it easy for you as a novice to then work with and deal with. Have you found that to be true?

Gary Yeah, absolutely. I mean, yeah, there’s definitely stuff that for client work that I’ve been part of, that we’ve gone over and above where anybody ever thought Genesis would be able to do, just because we’ve done some customizations and we’ve moved parts of the page around, and we’ve added in more semantics or moved bits and pieces where it needed. So yeah, it’s very flexible for those who need it, but it’s that same flexibility that allows these extra tools to be used as well.

David Yeah, great, great point. And again, kind of parallel to the power of WordPress itself, which I think is really interesting. So earlier you talked about kind of the role that the community played in your business and the Genesis community in particular. And I know that there’ve been … you know, I’ve talked to half a dozen people that have talked about their journey as a WordPress developer and Genesis, and other framework’s role in that in helping them build complex experiences, build things kind of above their punching weight a little bit. And a lot of that value came from the community as well, help them figure out problems, learn new things. But how do you think of the overall benefit to the community? Explain how it affected you, but when you engage with people in the community, when you see others engage with them, what benefits do you think people are getting from participating?

Gary Predominantly support. For those who want to do customizations, there’s a ton of tutorials out there. And I know that for the kind of upcoming versions of Genesis, where we might be looking to change some bits and pieces, one of the key factors is, well let’s not break things so much that these tutorials no longer work. So that’s very important. You could kind of look at Slack, there’s the community support forums, there’s groups on other platforms, there’s Genesis meetup. There’s lots of ways to find interact with other Genesis users, who you can ask about how to do X or find the best plugin to do Y. One prominent member of the community, a gentleman called Sridar, and he went along the forums, and he was answering just for everyone’s benefit. But instead of just answering the forum question specifically, he was putting it onto his own website and then actually could build up a business from that because he built up all these tutorials, 300-400 tutorials, a link back to them from the support forum, the person who asked the question and from there he was able to turn it into a premium website.

Gary So that community aspect has allowed him to develop kind of a subscription business model. In terms of other support, I mean, we had a Genesis Camp, which was like a virtual conference. A bit like the WordSesh Conference in the wider WordPress environment. And that was 2015 and we had some 36, 38 videos and it was covering development workflows or how to deal with clients, or understanding Genesis hooks, or selling maintenance plans, internationalization. I was part of the UK Genesis kind of set up there, we did a podcast episode. There was Troy Dean doing about recurring revenue, so there’s a lot of things that isn’t just relative to how do you do X with the code in Genesis, but how do you run your business. How do you as a freelancer or a small agency kind of make best use of Genesis to grow your situation.

David I love that you called that out and specifically Sridar, and the work that he did. I got a chance to talk to him the other day and learned more about his backstory. And it was really kind of inspiring to see that he started all that, not starting a business, but helping others and then through that was able to establish a business that provides a good stream of income. And so it’s so interesting to see that, but then even if you go to the Genesis WordPress Facebook group and look at people’s questions in there, and they’re very particular. Like you said, support is a key part of this. And they’ll say, how in this way do I do this thing, or using this feature, how do I accomplish this objective. And there’ll be half a dozen, you know, multiple dozens of responses helping them, thinking about it, offering options and then again, just to see that and see that level of assistance from the community I thought was also really inspiring. And then as you pointed out, all the different businesses that have kind of popped up in that ecosystem, and really kind of the sense of community, or the analogy of stone soup, right? I’ll bring a little something, you bring a little something and we’ll walk away with a good meal.

David But to see that kind of expressed, I thought was really interesting. And of course, we see that in the broader WordPress context, but to live that on the edges and my Genesis agency, and then kind of come more into the center as we’ve worked with the community and worked with the products, I think was even a little bit surprising to me. I don’t know if I’ve participated in a group that’s active with helping people.

Gary Yeah and I know Brian Gardner was very key in … There might be, I come in and say perhaps we need an advanced sample theme, perhaps we need this, perhaps we need that. And he’d say well, look, if we’re not doing it at StudioPress, you go ahead in the community, and you do it because we will support you to do that. And if you come up with a subscription model that does this or some other service, I think there’s so many people doing services from converting from the HTML 5, no sorry, the XHTML Genesis Child Theme into HTML 5 Child Themes. And it was a particular service, particular kind of niche. It wasn’t something that was gonna be automated from StudioPress, so people could do that as a business, and StudioPress and the Genesis community would support that. So yeah, very interesting to see that happen as well.

David Excellent. I certainly feel the yolk of that heritage, as I participate in helping to support the community moving forward. And you know, the kind of principles that Brian set down and operated by, that the community then kind of reacted to and oriented around, to me is a great degree of responsibility, that we feel in necessary to honor and to support and to grow and expand. I think these are fun things to do. And glad also to have Brian Gardner as our partner in still doing that and continuing that legacy. So, I do have some more questions Gary. This is fun, interesting stuff, but we’re going to take a quick break. When we come back we’re going to dig more into Genesis in the community. So, everybody hang tight and we’ll be right back.

PART 2 OF 3 ENDS [00:24:30]

David Everyone, welcome back to Press This, the WordPress Community Podcast on WebMaster Radio. This is your host David Vogelpohl talking about the Genesis framework with Genesis core contributor and Automattician, Mr. Gary Jones.

David Gary, before the break we were talking a little bit about the power of the community and the role that it plays in supporting others and even things like spawning businesses and all of that cool stuff. But, I wanted to wind back the clock a little bit because, at a point in time you had discovered Genesis, you had discovered the community, you wanted to participate and be part of its future and be a contributor. But, what was that moment? What was that moment you decided, for example, and I mentioned earlier I ran a Genesis agency. I never bothered with learning how to contribute or having my staff contribute. I never bothered with really participating in the community, I think, to my detriment. But you did. You did bother with that. You did lean into that. What was that moment for you where you said: Look, this isn’t going to directly drive revenue for me, but I still feel the need to do it. How did you make that transition?

Gary My story starts even further back than that. When I first started getting into WordPress, somebody suggested the Thesis theme, and I used that for a couple of years. That served well for the time, it allowed me to create client projects and client websites. But, where I got frustrated with it was … I mean, two parts. One, it seemed to work against WordPress. It has very opinionated concepts and approaches, whereas Genesis tends to work with WordPress. But the second was that I really wanted to help improve the code base, be through documentation, through a new feature, through better code standards, whatever it might be, and just found that I was being blocked on doing that. There just was no interest in me being part of that.

Gary I then was introduced to Genesis. A lady called Darcy, she was in Thesis community and had moved over to Genesis and she told me about it. I looked at it and then she, very quickly, introduced me to Brian Gardner via email … very standard introduction email. He said, “Ooh well, if there’s any suggestions for Genesis then please let me know.” I sent him a big long email list of items that I think could be improved and he was like: “Wow. Okay. We need to get you onboard here.” It was that willingness to be open and to listen and to request and require … Not require. But to request contributions or allow contributions to be made.

Gary That was the turning point. It was like: Yes. Somebody wants to listen. I don’t know it all, but I probably know some things different, so if they’re wanting to listen, I’ll go ahead. As I said before, if it can help improve my business because that’s what I’m going to base my client work around, let alone my brand and reputation, then that’s what I want to help with.

Gary It was only later that I realized that helping so much on the forums, for instance, well, being part of the forums allowed me to not only answer those questions and build the knowledge base of the code, but also to help individuals improve theirs, while at the same time improving my brand and reputation.

David That’s really great thoughts. So, basically the gist is, that this was an important tool for you and that without having that voice and the ability to help improve it, maybe felt a little powerless. But by having the voice and the ability to contribute and make it better, you ultimately made your own product better. And in the process, benefited from all the ancillary benefits of the community, in terms of your business and so on and so forth. Really, really interesting to think about those things.

David I have a friend, actually, who runs a conference. I remember he was telling me this story. Back in the day he went to someone who ran the industry’s biggest conference at the time, and said, “Hey, we have some ideas and think it would be fun to do this.” And that person flat out rejected those ideas. So he and his partner went out and started their own conference, and now that is the industry-leading conference in that particular industry. But it was that moment where, if that person had just listened. If that person would just have been thoughtful about those suggestions, they could have had allies in helping them in their mission, rather than someone that might be going out elsewhere. Not that you would have done that per se, but to have that outlook with Genesis was helpful for you to make sure that you could rely on the product and have a voice in its future.

Gary Yeah, absolutely, yeah.

David So, last question here and maybe a real quick one. What is one fun story from the history of Genesis? As quick as you can.

Gary Not so much with Genesis. The only one I could think of is that, back in 2013 WordCamp Europe in Leiden. It was lunchtime, I was standing outside. I was chatting to Joost de Valk, obviously head of Yoast. We were just having a conversation, it was the first time I’d met him. I was still very starry-eyed, as one of these WordPress heroes. Somebody came up to interrupt, said: “Oh I’m really sorry to disturb you guys.” Then started talking to me. He said, “Gary, I just want to thank you for the work you’ve done in Genesis. For everything you’ve done, it’s been really helpful. I’ve learned a lot.” And so on and so forth. Really complimentary towards me, then he effectively just walked off.

Gary The fact that he did just interrupted myself and Joost de Valk, and I think: Well, hang on, he’s talking to me and not Joost. Now perhaps he knew Joost already. Perhaps he already spoken, I don’t know. But it was interesting or I found it mindblowing that somebody would, at that point, come and talk to me and thank me for the stuff I’ve done on Genesis, even though the very famous, even back then, Joost de Valk was standing there as well.

David Ah, that is a fun story. Well I definitely thank you Gary for your contributions. I don’t know if you know this or not, but Joost actually used to host this podcast, and then-

Gary I didn’t know that.

David Yeah. And so now I have the helm, but funny story to hear. Gary, I wanted to thank you so much for joining the show today. This has been really enlightening and interesting and I really appreciate your time.

Gary Oh, thank you for inviting me.

David Awesome. Well thanks everyone else for listening to Press This, the WordPress Community Podcast on Webmaster Radio. Just a reminder, you can always subscribe on iTunes, iHeartRadio or download the latest episodes at WebmasterRADIO.FM. Again, this has been your host, David Vogelpohl, and I support the WordPress community through my role at WP Engine, and I love to bring the best of the community to you here every week, on Press This.

PART 3 OF 3 ENDS [00:33:33]

The post Press This Podcast Transcript appeared first on Gary Jones.

]]>
https://garyjones.io/press-this-transcript/feed 0 9920
Be Like Bill – How To Start The Engine Like A Genesis Expert https://garyjones.io/dont-start-the-engine https://garyjones.io/dont-start-the-engine#comments Wed, 22 Aug 2018 10:02:16 +0000 https://gamajo.com/?p=5314 There's a line in the Genesis Sample theme, commented with "Start the engine". All of the child themes by StudioPress have it. So do most child themes in the community.

This article looks at the drawbacks of this start the engine approach while exploring some of the advantages an alternative setup function may provide.

The post Be Like Bill – How To Start The Engine Like A Genesis Expert appeared first on Gary Jones.

]]>
There’s a line in the Genesis Sample theme, commented with “Start the engine”. All of the child themes by StudioPress have it. So do most child themes in the community.

However, it’s not needed.

More specifically, it doesn’t have to be needed.

It seems innocuous enough, so what’s the problem?

This article looks at the drawbacks of this start the engine approach while exploring some of the advantages an alternative setup function may provide.

Start The Engine

Let’s start at the beginning.

Child themes for the Genesis Framework by StudioPress, typically have a functions.php file that attempts to Start the engine:

View this code snippet on GitHub.

This line has been present since the very first version of Sample, and as such, it’s in every single StudioPress theme, and by a de facto standard, many child themes in the Genesis community.

Most people who have a passing understanding of PHP within WordPress themes should understand the code snippet above. Line one takes us into PHP mode, line two is a single-line comment, and line three is where the fun starts. It includes, once, a file called init.php within the lib/ sub-directory of the template directory (that’s the parent theme, aka Genesis, to you and me).

What Does init.php Do?

The init.php file within Genesis is the initialisation file. Here’s what it does (in Genesis 2.6 at least):

  • Sets up an autoloader for Genesis class files.
  • Calls a genesis_pre action hook.
  • Defines a genesis_i18n() function for loading Genesis language files, and hooks it into the genesis_init hook.
  • Defines a genesis_theme_support() function for adding theme support for Genesis and WordPress features, and hooks it into the genesis_init() hook.
  • Defines a genesis_post_type_support() function for enabling certain Genesis functionality for Posts and Pages, and hooks it into the genesis_init() hook.
  • Defines a genesis_post_type_support_post_meta() function for enabling Genesis functionality for post meta on public post types that are not Pages, and hooks it into the genesis_init() hook.
  • Defines a genesis_constants() function for defining PHP constants that Genesis uses within itself, and available to plugins and themes, and hooks it into the genesis_init() hook.
  • Defines a genesis_load_framework() function for loading in all the files, and hooks it into the genesis_init() hook.
  • Calls a genesis_init action hook, which therefore triggers calls to each function referenced above.
  • Calls a genesis_setup action hook.

Basically, that start the engine line makes every single bit of Genesis Framework load up straight away.

Advantages of the Start the Engine Approach

Let’s briefly discuss what some might say are the advantages of this method:

  • It’s one line. It’s easy to copy and paste, and even to remember, but you should know that lines of code are not an indicator of the quality of the code.
  • It loads all of Genesis up-front. The rest of the code in the functions.php file can reference Genesis functions, and the theme author doesn’t have to worry whether they are defined or not.

That’s probably about it.

Before going through the disadvantages, I want to introduce an alternative, so that we can make a comparison.

The Alternative: A Setup Function

The alternative is a setup function. Credit where credit is due, I call this the Bill Erickson Approach, as it was Genesis legend Bill Erickson who I first saw suggest this (though he may have got it elsewhere).

Here’s a trimmed example from Utility Pro by Carrie Dils. We’ll go through the reasoning in a moment:

View this code snippet on GitHub.

Now that we’ve seen an example, let’s explain what it is.

What is a Setup Function?

A setup function is one (or more) function(s) that includes much of the theme’s setup code, such as adding or removing theme support, adding or removing post type support, adding image sizes, defining menus for Genesis, registering widget areas, etc.

It’s not just for child themes, either. All of the default Twenty* themes have their own setup function (here’s TwentySeventeen’s), and Justin Tadlock has written about creating a theme setup function for themes in general.

For Genesis, we don’t call the setup function immediately, rather we hook it into the action hook that only fires after Genesis has finished loading, genesis_setup. Since Genesis itself also hooks into genesis_setup, we use a later priority of 15, to make sure the child theme adjustments come last.

While the example shows a single function, it would be equally possible to have multiple functions that organise the code into logical groups of function calls, and hook them all into the same hook and priority.

Advantages of the Setup Function Approach

There are a few advantages with this suggested approach that are worthy of explanation. These are:

  • Not including a file from another code base.
  • Honouring the default WordPress load order.
  • Fewer function calls in the global scope / everything is hooked in.
  • Allows functionality to be hooked in before Genesis loads.

Not including a file from another code base

Our code is inherently coupled to the file name of another code base (Genesis), and this is a bad idea. If it ever gets renamed (and with Genesis 3.x, that is a possibility), your code will throw a fatal error. You could do a file_exists() check, but if doesn’t exist, how will the rest of your code behave? Your code is still coupled to looking for that specific file name.

The solution brings us to our next point.

Honouring the Default WordPress Load Order

The whole point of child themes historically requiring that Genesis file, is so all of Genesis loads up first and we can use the Genesis functions.

But here’s a little secret.

The default behaviour for WordPress is to load the parent theme after the child theme. It will happen automatically. We should honour that behaviour.

The reason for letting this happen is simple. We stick to the expected behaviour for parent and child themes. We let WordPress load the Genesis functions.php file, which in turn loads the file we would have tried to load in our code.

If we don’t call any Genesis functions in the global scope (i.e. outside of a function hooked into a hook), then we don’t need Genesis to load first.

Fewer Function Calls in the Global Scope

PHP has scopes. Here, we’re considering two scopes: function scope and global scope.

Function scope is where we assign a variable, or make a function call, from inside a function.

Global scope is where the same thing might happen, but outside of a function.

View this code snippet on GitHub.

Any function call in the global scope is called when the file is first loaded – that is, required or included by another file. In the case of a child theme functions.php file, that would be when WordPress is loading the (child) theme.

So why is this bad?

As plugin developers, we might want to alter how a theme runs, but if the theme makes a function call before we have a chance to intercept, we can’t make those changes.

However, if the critical function calls are all inside another (setup) function, which is hooked in to be called at a known time later, we can write plugin code to handle that; we can unhook that (setup) function, or have the plugin code run at an earlier or later priority as needed.

With a setup function, the theme itself could also handle specific edge cases that need a different setup i.e. for landing page templates.

It’s worth noting that this setup function approach isn’t for performance optimisation, but it certainly won’t noticeably impact performance either. The increase in executed byte-code is negligible within the request.

Allows Functionality to be Hooked in Before Genesis Loads

Delaying our code until after Genesis loads is all well, but can we use it to our advantage? Yes, we can.

As an example, let’s consider widget areas. By default, WordPress admin shows widget areas in the order they were registered, so all of our custom widget areas would typically appear below Header Right, Primary Sidebar and Secondary Sidebar.

If we create another setup function, but hook that into an earlier hook, or with a different priority, we can set things up before Genesis does. For example, if we display a Utility Bar widget area at the top of the site’s front-end, we could register it to appear in the Widgets admin page before Header Right. This may be more intuitive for users since the widget areas then follow the order they do on the front end.

Utility Bar widget area registered before the Header Right widget area from Genesis.

What Should You Put Into Your Setup Function?

So, should you put all of your global function calls into the setup function?

No, and here’s why.

Action and Filter Additions

Most add_action() and add_filter() can stay outside. There’s nothing special about these functions that has anything to do with Genesis, even if the callback they reference does. Keeping these by the callback function definitions makes code considerably easier to read, rather than having the function in one place and the context (hook) under which that function is called several hundred lines away or in a different file.

Could we move the add_action() call and the function definition into the setup function? This would create nested functions.

Nested Functions

Technically, PHP allows nested user-defined function. That is:

View this code snippet on GitHub.

However, we should generally avoid nested functions, since you can’t call foo() more than once. Calling it a second time would make PHP attempt to define bar() again. Since a function by that name already exists from when foo() was first called, this would cause a fatal error.

In this case, it stops functions from being re-usable and should be avoided.

Action And Filter Removals

Unlike their add counterparts, the global remove_action() and remove_filter() calls may need to be in the setup function. One of the common gotchas is calling a remove_action() in the global scope, before Genesis has had a chance to add_action() in the first place. By including the remove_action() in the setup function, which in turn is not called until we know Genesis has finished setting up, the remove_action() intent will work.

WordPress Functions

WordPress functions like add_image_size(), add_theme_support() and setting the global $content_width don’t need to be in the setup function, but equally, it makes sense to have them there, since they are part of setting up the theme behaviour.

Summary

Since the majority of customisations in Genesis Framework child themes require a hooked-in function, it makes perfect sense to add some of those global calls into one or more functions and hook them in as well.

Next time you’re editing a theme, consider not starting the engine by tying your code to Genesis internal file structure. Instead, take advantage of the WordPress event system and hook in your changes after WordPress automatically loads Genesis.

The post Be Like Bill – How To Start The Engine Like A Genesis Expert appeared first on Gary Jones.

]]>
https://garyjones.io/dont-start-the-engine/feed 1 5314
Changes in Genesis – Birthday Discount https://garyjones.io/changes-genesis-birthday-discount https://garyjones.io/changes-genesis-birthday-discount#comments Wed, 06 Aug 2014 13:30:19 +0000 http://gamajo.com/?p=3220 Brief summary of the first year of the Changes in Genesis series of books, how I wrote them, and a discount code for the Gamajo Store to celebrate.

The post Changes in Genesis – Birthday Discount appeared first on Gary Jones.

]]>
It’s one year tomorrow since I released the first Changes in Genesis book, on the same day as Genesis 2.0 came out. This was my first experience of selling a product. I’ve not made my millions off of it, unfortunately, but I wanted to share some numbers anyway.

Leanpub

I launched the book via Leanpub. This is both an authoring / self-publishing and selling platform. I wrote the book in Markdown as Leanpub supports this and most parts of kramdown too). The files are saved to a Dropbox folder shared with Leanpub, and then I hit a button on the website to have it generate the PDF, EPUB and MOBI for both the main book and sample book. It then emailed me with the results, including any errors. Leanpub takes 10% + $0.50 per sale, so that leaves me with roughly 90% of the sale price. Amazon gives 70% at best and traditional book publishers are much lower.

According to Leanpub:

  • Number of Happy Readers: 183
  • Number of Happy Paid Purchases: 138
  • Number of Free Purchases: 45
  • Number of Refunds: 5 (2.7%)
  • Total Author Royalties: USD $3,729.44 (approximately GBP £2,214.84)

The large amount of free purchases are due to me promising my mailing list that they would get it free. This was a mistake on my part, but a promise is a promise, so I followed through with it.

The refunds are from customers who didn’t understand what the content of the book covered. This was despite there being a free Sample book available that gives a good indication. Some wanted information on specific aspects of Genesis, beginner or advanced, and not a list of changes between one version and the next.

Leanpub allow a variable price to be set. The book was priced at a minimum of $29.99, with a suggested price of $34.99. The highest I got was $50! With the use of discount codes (some for 100% discount) the average royalty (i.e. after Leanpub takes it’s cut) per sale was just over $20. Without the 100% discounts, but including the launch offer and mailing list special offer discounts, the average was just over $27 per sale.

Leanpub gives it’s own summary of numbers too:

Your minimum price is $29.99, which produces a royalty of $26.49. You have 138 happy paying readers. If everyone had paid the minimum price (excluding any coupons), the book would have earned $3,655.76 in royalties. Instead, the book has earned $3,729.44 in royalties. This is $73.68 extra earned because of the Leanpub variable price feature, in which your book has a minimum price, suggested price and sliders. This additional amount is 1.98% extra!

Put another way: the total amount of revenue (subtracting nothing!) your book would have earned if everyone had paid the minimum price would have been $4,138.62. Instead, the total royalties are $3,729.44. Pretty good, if you ask us!

What about Apple and Amazon? Well, the best you can earn there is 70%* royalty, and they don’t have variable pricing. So, if you had earned a 70% royalty on your minimum price, you would have earned **$2,897.03, which is $832.41 less than the royalties which have been earned on Leanpub!

But what about refunds? Well, you’ve had 5 refunds because of our unconditional 45-day refund policy. This is a minimum of $132.46 of royalties given up, at the royalty based on the minimum price. But you’ve earned $73.68 extra because of the Leanpub variable price feature. So, when you think about the Leanpub storefront experience as a whole package, you could have 2 refunds before our 45-day refund policy would start actually “costing” you anything on the next refund, even with the (probably false) assumption that there would have been no chargebacks or other types of refunds on other platforms.)

Gamajo Store

As I launched Changes in Genesis 2.1, I started selling from my own site instead. I’m using Easy Digital Downloads with several premium and free extensions. I tried several different methods of generating the book file formats from Markdown, but eventually settled on Pandoc. That’s a program written in Haskell which is run via the command line. I had some difficulty in getting it setup how I wanted it, but the upshot is that I have more control over the final appearance of each format (Leanpub is relatively limited in the designs of the PDF for instance), and I don’t have to give 10% of each sale away. I could also then use my own affiliate setup (Affiliate WP) and run discount codes on whatever combination of products I wanted. With the plan to be selling more books in the future, I considered this investment in time and structure to be worthwhile.

Naturally I started selling Changes in Genesis 2.0 on my site as well, both as a single product, and as part of a Changes in Genesis Bundle along with the latest book. I wasn’t sure how much the Bundle was going to sell, but with a significant discount compared to the sum of the individual books, I’ve sold a few since I opened the store last month (12 to be exact). None of the individual 2.0 book have sold so far, which makes sense as Genesis 2.1 is now out, so the information is somewhat redundant (though still useful).

Discount Code

To celebrate the first birthday of the Changes in Genesis series of guides, I’m offering a discount of 30% for all three products in the Changes in Genesis series (2.0, 2.1 and the Bundle) that is valid for today and tomorrow only! Use the code CHANGESBIRTHDAY at the checkout to receive the discount.

The post Changes in Genesis – Birthday Discount appeared first on Gary Jones.

]]>
https://garyjones.io/changes-genesis-birthday-discount/feed 1 3220
Comment Author Link Bug in Genesis 2.1.0 https://garyjones.io/comment-author-link-bug-genesis https://garyjones.io/comment-author-link-bug-genesis#respond Mon, 14 Jul 2014 12:56:46 +0000 http://gamajo.com/?p=2602 There's a bug with the Comment Author Link in Genesis 2.1.0 and 2.1.1. (fixed in Genesis 2.1.2). This explains the problem and how you can fix it yourself to include the missing attributes. Without it, your site will have invalid markup and will be telling search engines that comment author links from your site to elsewhere should be included for ranking purposes.

The post Comment Author Link Bug in Genesis 2.1.0 appeared first on Gary Jones.

]]>
It’s come to my attention about a bug in Genesis 2.1.0. It wasn’t spotted until after Genesis 2.1.1 was released, and since that’s the latest release, it still exists in sites with Genesis 2.1.0 or 2.1.1.

This post explains the problem and how to fix it, so you’re not waiting until Genesis 2.1.2 or 2.2.0 comes out.

If you’re competent, you can skip to the TL;DR Fix.

Update 2014-07-15: This has now been fixed in Genesis 2.1.2, so ensure you’re running at least that version to not be affected.

The Background

In 2.0.*, for a HTML5 child theme, a comment author link would appear something like:

<a href="https://genesischangelog.com" rel="external nofollow" itemprop="url">
    Gary Jones</a>

Simple enough – an anchor link, that links my name to my site, and includes two attributes. The first is the rel attribute, with the important value of nofollow. This value has been recognised by Google et al for nearly 10 years. They introduced it as a way to prevent comment spam. Since search engine take into account which sites link to the one being ranked, the intent was to negate the benefit from someone posting spam comments all over the web, just to apparently have those high-ranking websites link to their little site. Google says:

From now on, when Google sees the attribute (rel=”nofollow”) on hyperlinks, those links won’t get any credit when we rank websites in our search results.

The second attribute is itemprop. This has a value of url here, and is microdata for marking-up a Person. Not having it present is not as critical as the missing rel attribute.

The Comment Author Link Problem

The problem can be clearly seen in the comment author link markup for Genesis 2.1.0 and 2.1.1. It produces markup like:

<a href="https://genesischangelog.com/" comment-author-link="">Gary Jones</a>

The link still points my name to my site, but the attributes have changed. Gone are the important rel and itemprop attributes. There’s an attribute called comment-author-link instead, and this makes the markup for the page invalid.

So what’s going on here?

The comment-author-link is our clue as to where to find the problem. In Genesis 2.1.0, one of the changes was to make more of the comment markup was passed through the Genesis Markup API. This is made up of two functions – genesis_markup() and genesis_attr(). They allow developers to filter markup and attributes as needed. The bug looks to be related to this.

The Fix

At this moment in time, it’s not actually been confirmed as a bug and a bug fix by Copyblogger, but it’s so clearcut I have no problems with recommending that everyone who is able to edit a file go ahead and do the fix below. Obviously, take a backup first and know how to restore it if you’re not confident.

If you open the file at wp-content/themes/genesis/lib/structure/comments.php and look at line 294, then you’ll see this:

$author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), esc_attr( 'comment-author-link' ), $author );

Let me write that another way to make it clearer to reference:

$author = sprintf(
    '<a href="%s" %s>%s</a>',
    esc_url( $url ),
    esc_attr( 'comment-author-link' ),
    $author
);

What we have here is a variable, $author, being assigned a value from a sprintf() call. That call might look odd if you’ve not seen it before. For the simple case here, take the %s in the first argument (second line) as placeholders which are replaced with the corresponding values in the next three lines.

The important bit here is the second %s, that with the current code is replaced with esc_attr(). The esc_attr() is a WordPress function that escapes attribute values (the bit inside the double quotes). The esc_url() function is a special case that handles attribute values which are URLs, so you can see how it replaces the first %s correctly.

However, we don’t want to put an attribute value in that second placeholder – we want a list of all the attributes and their values that have been filtered in!

Remember that genesis_attr() function I mentioned? That takes two arguments, the first of which is a string that provides the context. The second argument is optional and not important here.

What we really wanted then was:

$author = sprintf(
    '<a href="%s" %s>%s</a>',
    esc_url( $url ),
    genesis_attr( 'comment-author-link' ), // This line changed
    $author
);

or in the original format:

$author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author );

That will replace the second %s placeholder with a list of all the attributes and their values (already escaped) for the comment-author-link context. Elsewhere in Genesis (lib/functions/markup.php:619 if you’re curious) is a function which uses this context to filter in our rel and itemprop attributes.

Conclusion

If you’re competent in editing code, I’d say go ahead and make this comment author link change to your copy of Genesis. While it’s not usually advised to edit Genesis files, in this case, it’s applying the same change as will likely be in the next version of Genesis anyway, so your change will be overwritten with the correct (and likely same) change anyway.

If you’re using a custom callback for comments (advanced customisation), then you may not be affected by this bug. If your custom callback started off as a copy of genesis_html5_comment_callback(), then you probably are.


TL;DR Fix

At this moment in time, it’s not actually been confirmed as a bug and a bug fix by Copyblogger, but it’s so clearcut I have no problems with recommending that everyone who is able to edit a file go ahead and do the fix below. Obviously, take a backup first and know how to restore it if you’re not confident.

In lib/structure/comments.php, line 294, replace:

$author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), esc_attr( 'comment-author-link' ), $author );

with

$author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author );

The post Comment Author Link Bug in Genesis 2.1.0 appeared first on Gary Jones.

]]>
https://garyjones.io/comment-author-link-bug-genesis/feed 0 2602
Changes in Genesis 2.1 Launched https://garyjones.io/changes-in-genesis-2.1-launched https://garyjones.io/changes-in-genesis-2.1-launched#comments Mon, 07 Jul 2014 12:10:40 +0000 http://gamajo.com/?p=2377 Announcing the new Changes in Genesis 2.1 guide, and the launch of the Gamajo Store. Free sample guides are available in the store.

The post Changes in Genesis 2.1 Launched appeared first on Gary Jones.

]]>
Screenshot  of the Gamajo Store at launch
The Gamajo Store at launch

Genesis 2.1 was released a week ago, and Genesis 2.1.1 followed a day later. As I’m in a privileged position to see a list of all the changes in Genesis 2.1, I’ve written them up in a new guide called Changes in Genesis 2.1.

Changes in 2.1 give detailed explanations, screenshots and code snippets for 84 changes in 2.1.0 and a further four critical fixes in 2.1.1. This is the only resource where these changes are detailed.

This is the second in the series, after my previous guide, Changes in Genesis 2.0. This listed a total of 151 changes covering 2.0.0, 2.0.1 and 2.0.2.

The post Changes in Genesis 2.1 Launched appeared first on Gary Jones.

]]>
https://garyjones.io/changes-in-genesis-2.1-launched/feed 2 2377
Pre-launch of UK Genesis https://garyjones.io/prelaunch-uk-genesis https://garyjones.io/prelaunch-uk-genesis#respond Mon, 17 Feb 2014 13:39:27 +0000 http://gamajo.com/?p=2131 Introducing the UK Genesis project - boosting the visibility of UK-based developers and designers who use the Genesis Framework.

The post Pre-launch of UK Genesis appeared first on Gary Jones.

]]>
Genesis Framework 2.0.0 logo

At the time of writing, over 112,000 website owners use the Genesis Framework as their base WordPress theme. These people come from over 40 countries, and the UK, of course, is one of those countries.

I’m a developer who works a lot with, and on, the Genesis Framework. I’d say I’m known within the Genesis developer community, more-so after I released my first Genesis guide. Many of the leads I get have come from searches that include a reference to “UK”.

Yet other than a small handful of people, I don’t know that many UK-based web professionals who only work with Genesis. I’m sure they exist, but I haven’t seen them in the Genesis communities on Twitter, Facebook, Google+ or LinkedIn. There isn’t an existing UK Genesis community.

UK Genesis

One of those handful who I do know about is Jo, and we’ve started off UK Genesis. At the moment, it is a resource for designers and developers who want to be found because they use Genesis. Once launched, the site will be for clients who want to find a developer or designer because they use Genesis. It may also support the community side, with optional meet ups, and a handy list of people to refer to if a lead warrants it.

A few of us are getting together for a meeting at the end of February 2014, which will help shape how this project will go ahead. Some initial suggestions said it could be a directory of profiles. These would show where the professional is, the type of clients they work with and the price-range they work within. This could be a paid listing, so that those who contribute to maintaining the site can justify their voluntary time.

There is a separate project to do something similar for the wider UK-based WordPress developers. I’m hoping we can collaborate with them so that we end up with the best of both camps. I’m not aware of any other country-specific communities for Genesis, but if there are, please let me know.

If you’d like to find out more or become involved in UK Genesis, then sign-up at ukgenesis.co.uk.

The post Pre-launch of UK Genesis appeared first on Gary Jones.

]]>
https://garyjones.io/prelaunch-uk-genesis/feed 0 2131
How To Add A Split Sidebar in the Genesis Framework https://garyjones.io/split-sidebar-genesis https://garyjones.io/split-sidebar-genesis#comments Tue, 24 Sep 2013 12:00:44 +0000 http://code.garyjones.co.uk/?p=2051 Learn how you can enable automatic updates for your WordPress plugin (or theme) direct from GitHub, with just one line of code.

The post How To Add A Split Sidebar in the Genesis Framework appeared first on Gary Jones.

]]>
This tutorial was originally posted to https://code.garyjones.co.uk on 2011-08-12. The comments have been carried across to this site. It has been updated here with a more detailed description and improved code.

Visually splitting the primary sidebar in a Genesis Framework child theme into two smaller sidebars is a powerful design feature. It allows prominent important areas to apparently span a double width, before breaking down into narrower columns for other widget content.

Get A Split Sidebar

If you’re thinking “How did I get a widget to span two sidebars?” or “What CSS do I use to split a sidebar?”, then you’re over-thinking the problem. We don’t actually split a sidebar, but we introduce two new widget areas that are completely independent, and then just display them below the main one instead. Kudos to Brian Gardner for originally suggesting this approach after I was trying to recreate the Custom Content Box above the two sidebars as it appeared in Thesis.

By using new widget areas, users get clear guidance on where their widget will appear without having to work out if the new widget will appear in the normal sidebar, or in one of the split sidebar areas.

Here’s what we’re trying to achieve (screenshot from an client site I did):

Screenshot showing a split sidebar, with one sidebar split into two narrower sidebars
One sidebar, split into two (each with their own widget area)

Ready for some code?

PHP

Add the following to your child theme function.php file:

The first function registers the two widget areas. For more info about genesis_register_sidebar() see the StudioPress tutorial on How to Register a Widget Area (login needed).

The function is attached to the after_setup_theme action hook at priority 5 so that the split sidebar widget areas appear after Genesis has registered the Primary and Secondary sidebars, but before the footer widget areas.

Screenshot showing a list of widget areas
Sensible registration of the widget areas can determine the order in which they appear on the Widgets screen.

The second function handles the output of the widget areas. Here we use the genesis_widget_area() function. This function is a wrapper for the WordPress function dynamic_sidebar() but it sets up the default markup for before and after the widget area and calls two contextually-named action hooks before and after the dynamic_sidebar() call, making it more flexible for plugins or later code. You can see that the single argument being passed to each call is just the ID of the widget areas we registered in the first function.

The second function is attached to the genesis_after_sidebar_widget_area hook, which is what determines the location of the split sidebar output (after the Primary sidebar). If it was attached to the genesis_before_sidebar_widget_area then the split sidebar would be above the Primary sidebar.
Attaching it to genesis_before_sidebar_alt_widget_area or genesis_before_sidebar_alt_widget_area would make it appear before or after the Secondary sidebar instead.

CSS

The CSS is relatively trivial but might need adapting to fit in to your existing theme styles. We give each widget area half of the available width, and float them so they fill in the space instead of the second one stacking underneath the first.

If you need to target the left sidebar you can use the .split-sidebars > .widget-area:first-child {} selector, and .split-sidebars > .widget-area:last-child {} for the right sidebar.

Conclusion

You can now register new widget areas, and output them above or below the primary and secondary sidebars, giving a “split sidebar” appearance. If you have any questions, let me know in the comments.

The post How To Add A Split Sidebar in the Genesis Framework appeared first on Gary Jones.

]]>
https://garyjones.io/split-sidebar-genesis/feed 22 2051
Move the Floating Social Bar Outside of Entry Content in Genesis https://garyjones.io/move-floating-social-bar-genesis https://garyjones.io/move-floating-social-bar-genesis#comments Tue, 10 Sep 2013 12:00:30 +0000 http://gamajo.com/?p=2092 How to move the Floating Social Bar, a great sharing plugin, in Genesis so that it doesn't impact on your microdata or design.

The post Move the Floating Social Bar Outside of Entry Content in Genesis appeared first on Gary Jones.

]]>
The Floating Social Bar plugin is a way for readers to easily share posts on their social networks – the key difference is that it’s very fast, and doesn’t front-load the loading of the all of the scripts for the social sites.

In actual fact, it’s in a very slightly different place to where it would be by default. You see, to make the plugin work for all themes, Thomas and Syed appended the FSB output to the top of the post content. And that’s fine for most cases.

Looking at a page with the Floating Social Bar enabled, in the Google Structured Data Testing Tool, I could see that the textual output from the Floating Social Bar was being included within the blogPosting item text.

Screenshot of Google Structured Data Testing Tool showing the text value includes the textual output from the Floating Social Bar
The text value includes the textual output from the Floating Social Bar

I didn’t want this. I’m not sure if Google actually uses this microdata value in any specific way, but I wanted to at least try and clear it up.

Moving the Floating Social Bar in Genesis

Here’s the solution for Genesis child themes (add to functions.php). Other themes could do the same, except they’ll need to pick their own specific action hook on which to add the Floating Social Bar back in.

The code itself is documented with a couple of notes.

In Genesis child themes then, it simply moves the Floating Social Bar output from immediately after the <div class="entry-content" itemprop="text"> tag to immediately before it. Unless your entry-content has a background colour or a top border (which might be another reason for moving it anyway), you shouldn’t notice any visual difference.

Plugin

Since I’m going to be using this across all the sites where I use Floating Social Bar and Genesis, I’ve turned this into a plugin. Feel free to fork and improve or tweak to your own preference.

Move Floating Social Bar in Genesis plugin on GitHub

The post Move the Floating Social Bar Outside of Entry Content in Genesis appeared first on Gary Jones.

]]>
https://garyjones.io/move-floating-social-bar-genesis/feed 2 2092
How to Style a Comment Count Number in the Genesis Framework https://garyjones.io/style-comment-count-number https://garyjones.io/style-comment-count-number#comments Mon, 09 Sep 2013 12:00:07 +0000 http://dev.studiopress.com/?p=299 Add a background image or other styles to improve the appearance of the comment count number in the post info in a Genesis child theme.

The post How to Style a Comment Count Number in the Genesis Framework appeared first on Gary Jones.

]]>

This tutorial was originally posted to http://code.garyjones.co.uk on 2010-08-25. The comments have been carried across to this site. It has been updated here for HTML5 child themes.

If you’re using a Genesis child theme and need to style the comment count number for a post so that it’s different from the word “Comment(s)”, then there are two steps we need to take. First, we need to add some extra markup around the number part, and second, add some CSS to style that markup.

Comment Count Number?

The comment count is the link and number that appear in the byline for each post in most Genesis Framework child themes, after the date and author. It acts as a shortcut to jump straight down to the comments for people who have already read the post, but want to see what new feedback there might be.

Markup

Add the following to your functions.php file:

What we’re doing here is editing the Genesis [post_comments] shortcode output that you may be using within another function, or in use by your child theme already. We use a regular expression to target the right bit of output, then replace it with similar code that has the extra markup in it. We then finish the filter by returning our amended output.

The output would be something like:

Styles

Now that’s done, we can use that extra span to target the CSS.

In this case, we’ve simply made the text larger for the comment count number, but you can add in other styles as needed. You can even give the number a background image, and not the “Comment” part:

Screenshot of a comment count number with a speech bubble background image

It’s Not Working For Zero Comments!

The default output for more than one comment in Genesis is “<number> Comments”.

The default output for exactly one comment is “1 Comment”.

The default output for exactly one comment is “Leave a Comment”.

Can you spot the problem?

The inconsistent lack of a comment count number when there are no comments means that the regular expression in the first PHP function won’t match and therefore won’t do the replacement that adds in our markup. Luckily, the [post_comments] shortcode has an attribute that allows you to set the format when there are zero comments. (You can also do it for one comment and more than one comment). You can add this attribute via Genesis Simple Edits plugin, or just filter in it via the functions.php file:

Conclusion

You can now add markup around the comment count number, and let your creative juices flow about how interesting you can make it look.

The post How to Style a Comment Count Number in the Genesis Framework appeared first on Gary Jones.

]]>
https://garyjones.io/style-comment-count-number/feed 8 299
Explanation of the Genesis Framework 2.0.0 Type Hint Bug https://garyjones.io/type-hint-bug https://garyjones.io/type-hint-bug#comments Thu, 08 Aug 2013 11:09:54 +0000 http://gamajo.com/?p=869 An explanation and suggested fix for the type hint bug in Genesis 2.0.0 that causes a fatal error in the admin (white screen) for old themes that use their own style selector instead of the one built in to Genesis.

The post Explanation of the Genesis Framework 2.0.0 Type Hint Bug appeared first on Gary Jones.

]]>
The first bug that was reported for Genesis 2.0 can serve as a learning opportunity for lots of developers to understand a little more about Genesis. It’s about a bug caused by a type hint.

What’s Affected

Typically tends to be old themes that include a colour or style selector, and have been updated since Genesis 1.7 (July 2011), when the Sanitization class was introduced, but maybe not since Genesis 1.8, when the style selector setting was then added to Genesis itself.

Child themes thought to be affected include Associate, Copyblogger, Generate and News. If you know of another one, please let me know in the comments below.

However, it’s really any theme or plugin which is calling the genesis_add_option_filter() with a string as the third argument.

The Problem

While the front-end of the site is still accessible, updating to Genesis 2.0 will result in the admin dashboard giving out a fatal error like:

Catchable fatal error: Argument 3 passed to Genesis_Settings_Sanitizer::add_filter() must be an array, string given, called in .../wp-content/themes/genesis/lib/classes/sanitization.php on line 287 and defined in .../wp-content/themes/genesis/lib/classes/sanitization.php on line 69

If you have WP_DEBUG set to false, or otherwise have error messages disabled in PHP, then you may just see a white screen.

The Bug

One of the improvements Genesis 2.0 made was to add type hints where possible. Here’s my explanation about the this change from my Changes in Genesis 2.0 book:

Type hinting means functions are able to force parameters to be a certain type. If the parameter is a different type, then a catchable fatal error occurs, the benefit being that unexpected data shows up easier than trying to work through some incorrect logic. The other benefit is that code editors can use the type hint information – it might help with writing the @param type for DocBlocks, or it might help with autocomplete of variables or properties within the function or method itself.

While lots of functions within Genesis accept arrays, not all of them can be type hinted. Methods with the same name in classes that are extended from WordPress class can’t have them (since the type hint is not on the original method, and the signatures must match), nor can methods which accept array or strings arguments.

In this case, we need to look at the functions to see what is going on. Line 287 of lib/classes/sanitization.php refers to:

View this code snippet on GitHub.

This is fairly simple – the genesis_add_option_filter() is a wrapper for an add_filter() method in the Genesis_Settings_Sanitizer class, and the parameters are passed directly through. Note that their is no type hint (correct) for the suboption parameter, since the documentation for it says that it can accept a string or an array.

Line 69 refers to the add_filter() method:

View this code snippet on GitHub.

It’s not important to understand how this method works, but it basically tells a setting to pass through a sanitizing filter before it is saved. For instance, for checkboxes, it should pass through the one_zero filter, which means that if the value is not a 1 or a 0, it is rejected and not saved.

You’ll notice that there’s an array type hint on the third parameter. Yet the body of the function checks that $suboption to see if it’s an array, but also handles the case when it isn’t! That means that while strings are handled perfectly fine within the function, the presence of a type hint means that PHP doesn’t let any strings get that far.

When I created the pull request in January 2013 that added type hints, I went through the project and looked for the string “@param array”, and this was one of the results. So yes, the bug is my fault (sorry!). In this case, the documentation was wrong. To make matters worse, the incorrect documentation was added in September 2011 by … me.

The Fix

There are several ways of fixing the problem so that the admin dashboard comes back, but the method I strongly recommend is below. I’ve heard that the StudioPress Support team are suggesting other methods from just stopping the style selector code from running, to replacing it with data to enable the one built-in to Genesis. My opinion is that the less non-developers have to do with fixing code, the better, but each to their own.

Remove The Type Hint

Since that type hint is the cause of the bug, we can just remove it. We’ll be editing Genesis core files, which is usually a big no-no, but since this amendment has already been made to Genesis development code, you can be sure that the fix will be persisted once the next version of Genesis is released.

  1. Open up genesis/lib/classes/sanitization.php at line 69.
  2. Change:
    function add_filter( $filter, $option, array $suboption = null ) {
    to
    function add_filter( $filter, $option, $suboption = null ) {
  3. Save and upload to your website. Refresh your admin page, and it should all be working again.

The advantage of doing this method over the others is that:

  • It’s the removal of 6 characters – not too tricky.
  • It fixes the cause of the problem, and not the symptoms.
  • Doing this fix once means that all of your themes (perhaps on a multisite) don’t need fixing individually.
  • It will also fix it for any active plugins that call genesis_add_option_filter() as well.
  • It’s the same fix, for whatever theme you’re using, unlike the theme-specific style selector code.
  • The next version of Genesis applies the same fix.

Final Words

The bug itself is relatively small, and only known to affect a limited number of cases – those running old versions of the affected child themes for instance. Even so, it can be frustrating if you’re one of the ones affected, so follow the instructions above and get back into your site.

The post Explanation of the Genesis Framework 2.0.0 Type Hint Bug appeared first on Gary Jones.

]]>
https://garyjones.io/type-hint-bug/feed 9 869