Articles - Page 2 of 4 - Ryan Kienstra

JavaScript modules

JavaScript Modules In WordPress

By: Ryan Kienstra on: January 25, 2015  in: JavaScript

Most JavaScript files in WordPress¬†are actually modules. This makes all of the variables and functions private. And lets you control what should be public. JavaScript modules are: More secure Easier to change Creating A Module Wrap the entire file in a function. ( function( $ ) { // file contents } )( jQuery ); This […] Read more

JavaScript variable declaration

JavaScript Variable Declaration

By: Ryan Kienstra on: January 24, 2015  in: JavaScript

Good PHP developers can learn basic JavaScript quickly. But JavaScript variable declaration is different from PHP. And forgetting declarations will cause subtle bugs, not errors. Variable Declaration Declare all variables by using var var myVariable = 'foo_string'; If you don’t, you’ll make the variable global. var scopeTest = function() { accidentalGlobal = 'The value inside […] Read more

oop inheritance icon

OOP Inheritance For WordPress

By: Ryan Kienstra on: January 20, 2015  in: OOP For WordPress

OOP inheritance allows powerful, reusable code. If you haven’t already, you might read my guides: OOP Fundamentals For WordPress OOP: Instance Vs. Static Rationale: Reusing Code Programming is largely about reusing code. Functions execute the same code every time they’re called. The only difference is the arguments. But inheritance in object-oriented programming is much more […] Read more


OOP: Instance Vs. Static

By: Ryan Kienstra on: January 18, 2015  in: OOP For WordPress

By understanding instance vs. static properties, you can write flexible code. And build complex object-oriented programs. If you aren’t familiar with classes and instances, you might read OOP Fundamentals For WordPress. Properties: Instance Vs. Static Instances can store variables called instance properties. They aren’t connected to properties of other instances. But instances can also access […] Read more

OOP Fundamentals

OOP Fundamentals For WordPress

By: Ryan Kienstra on: January 11, 2015  in: OOP For WordPress

You program for WordPress using PHP functions and variables. But you’d like to use object-oriented programming. Maybe you’ve read my guide, OOP With WordPress: Why? In writing functions, you’ve already used: OOP Fundamentals Abstraction Code Reuse Abstraction Functions often have private variables. They can be abstracted from the local scope. Nothing else can access them, […] Read more

OOP With WordPress gears

OOP With WordPress: Why?

By: Ryan Kienstra on: January 9, 2015  in: OOP For WordPress

You’ve been programming with functions and variables. And most of WordPress doesn’t use OOP. So why do you need object-oriented programming? Store variables between functions Reduce arguments Show structure Plugin Example My WordPress plugin Bootstrap Widget Styling filters the markup of widgets. Here’s how to do it without object-oriented PHP: add_filter( 'wp_list_pages' , 'bws_filter_pages_widget_markup' ); […] Read more

Fast WordPress Searches

Fast WordPress Searches

By: Ryan Kienstra on: January 8, 2015  in: WordPress VIP

If you have a lot of content on WordPress, you’ll need a fast way to search it. Maybe you have a directory with an advanced search. WordPress VIP agency 10up recently released their Engineering Best Practices. These have many techniques for fast WordPress searches. Prefer WP_Query To get_posts 10up explains that the get_posts function actually […] Read more

WordPress VIP Unique Standards

WordPress VIP: Unique Standards

By: Ryan Kienstra on: January 6, 2015  in: WordPress VIP

Many of the VIP coding standards are different from self-hosted WP standards. The size and structure of VIP multi-sites often require different coding. Users There’s a single database for all users in So you can’t do any CRUD operations on it: create, read, update, or delete. To parse the users, call get_users() and operate […] Read more