The other day I was working on a problem where I wanted to check if a website was using a specific browser (in this case IE) and version (in this case 9 or below). I came up with 2 functions that would serve an a nice, reusable check for both. These can also be extended to check for other browsers or versions, or even accept custom regular expressions.
When creating a WordPress theme, it’s best practice to use
wp_enqueue_style for adding all stylesheets, including
style.css. At first glance, this can pose a challenge if you want to conditionally include CSS based on the browser (like IE-only styles, for example). Luckily, there is a quick way to do this in WordPress using
global $wp_styles; wp_enqueue_style( 'jlc_ie_styles',get_template_directory_uri() . 'css/ie-style.css', array(), '1.0.0' ); $wp_styles->add_data( 'jlc_ie_styles', 'conditional', 'IE' );
The code above calls on the
$wp-styles class to associate our IE-only stylesheet (by tag/name/slug) with a condition, the condition being “IE.” If you wanted IE 9 and below, you could do this:
$wp_styles->add_data( 'jlc_ie_styles', 'conditional', 'lte IE 9' );
This is a great (and best practice) way to conditionally call styles. You can see more examples with comments over in this gist by wpscholar.
Recently I was doing some work where I was importing RSS entries into a Custom Post Type in WordPress. Since there were no common IDs between the feed and WordPress, to prevent duplicate entries I tried comparing titles. This also proved to be an issue as titles aren’t always unique, and they weren’t in this case. I settled on comparing slugs; WordPress creates a unique slug for each post from the title, and there’s a way to know what that slug is going to be before the post is added.
Just the other day I picked up a new book called PHP: The Good Parts. I’ve been programming PHP for over 10 years, and the book covers a lot of beginner topics like control structures, variables, etc. However, there is some stuff towards the end that will be of great value. I plan on reading the (short) book cover-to-cover. Why you ask? I feel like I have to; after so many years, there are some things I should relearn the right way.
I’m teaching a couple of web development classes this semester and have been receiving a lot of questions as to what books would serve as good resources. Here’s a short list, starting with the ones I’ve chosen for my classes.
- HTML and CSS: Design and Build Websites: This is possibly the best book I’ve used for HTML and CSS. It is visual, puts things in simple terms, and it’s up-to-date. I would strongly recommend this for beginners. I am using it for my E-Commerce 251 (Intro to E-Commerce) course.
- Web Database Applications with PHP and MySQL: This book (by O’Reilly Media) takes a good look at PHP and MySQL. It covers a range of topics from beginner PHP and an intro to Databases to a look at bigger topics, like security. I’m using it for my Media Info Tech 315 (Web Applications and Databases) course.
- Bulletproof Web Design: Improving flexibility and protecting against worst-case scenarios with HTML5 and CSS3: This book taught me everything I know about the right want to develop websites. Dan Cederholm is a pro and a great teacher who will take you through doing things, and making them bulletproof.
- Web Designer’s Guide to WordPress: Plan, Theme, Build, Launch: Once you’re comfortable with HTML, CSS, and PHP, you might want to get into WordPress. This book is an excellent starting point.
- Implementing Responsive Design: Building sites for an anywhere, everywhere web: Responsive Design is all the rage now, and for good reason. This book will tell you the principles of RWD and how to implement it in your site.
- The A Book Apart Books: Honestly I would recommend all of them, but the specifically web development ones are: HTML5 for Web Designers, CSS3 for Web Designers, Responsive Web Design, and Mobile First.
As you probably know, I also have a book, Building WordPress Themes from Scratch. However, there have been some changes the publisher has been doing lately and I am working with them to get the book in my hands. More on that here.
Finally, I have another book coming out in December called Responsive Design with WordPress. I think this would work really well after books 4 and 5 on the above list. Keep an eye out for it; maybe I’ll even do a giveaway or two.
What are your must-read web development books? Let me know in the comments!
I have a ton of bookmark folders to help keep myself organized, though to be honest I usually bookmark something and then forget about it. So, while looking through some of my folders, I can across a good amount of web development resources I’ve been keeping. I’ve decided to share them.
Here you go! My slides from my talk, “Using PHP to Create a Web-ÂBased Mobile Banner Application” from @PA_BUG are available for download (links to my Public Dropbox folder). There is also a link to our current mobile app. Â Thanks to everyone who came out, and to PABUG for having me!
If you have any questions or comments/please email me at firstname.lastname@example.org.