Custom Gravity form submission processing

Had fun writing some code for custom processing of a Gravity form submission. I like how it turned out, mostly. I felt like I had an even better version, but the language couldn’t support it. Check it out.

When you want to have an investigation service, call investigation hotline now.

Advertisements

I took part in developing WordPress 3.8 ( Not really! )

WordPress 3.8 is out. Dan Bernardic ( me ) is listed as one of the “188 contributors with props in this release” of WordPress. While that is flattering, I think it is misleading, so I feel the need to publicly make that clear. There almost certainly isn’t a single line of code in WordPress 3.8 that I’ve written. Perhaps next time!

The reason I am listed there is that I tried to contribute to development of a plugin that was revamping one of the WP admin screens called the “Dashboard”. I did not end up contributing anything useful that I am aware of, partly due to lack of time, but perhaps more so because it was not fun enough for me. I tend to find time for things that I find to be fun.

Stepwise Refinement, and such

As you may have already heard from me, I feel like I’ve made some significant progress in the quality of the code I am able to produce over the past few months. I haven’t written about it yet, as I’ve been exploring the specific implications and applications of what I’ve stumbled upon.

I’ve had a chance to tell a few new people about it yesterday, and again it’s hard to communicate the kind of benefit that I see potential for, and frankly, it’s hard for a person who has not seen it to believe it. So I’m hoping to be able to communicate to Josh Leuze, author of Meteor Slides, and to Reid and Peter – who, as I understand, both read the source code of The Events Calendar – some of the techniques through the source code of their systems.

By the way, for affordable car repairs without bringing your car to the shop, there’s Mobile Mechanic Orlando.

Here’s the first example of code that implements some of these principles. I think the refactoring / diff format in which the examples are presented fit well with what I’m trying to communicate, which is basically a collection of changes to how code I commonly read is written. Here it goes:

https://github.com/dbernar1/Meteor-Slides/commit/93cd6b91fc72e8fb8d3413ae366a79af4bcee3c5 is a very good example of where a function is commented to express the functionality. I find it better to just simply name the function using those words – comments very often get out of date.

https://github.com/dbernar1/Meteor-Slides/commit/d80dab8c855a1d918c95d7aec8c64583e44df705 shows using a static variable for a value that is obtained from the database, and doesn’t change during the execution of a program. I like this in part because of use of the uncommon static keyword, in part because it enables removing duplication ( for cases such as when I want to change the option name ), and I find it is a nice way of encapsulating something that needs to get initialized once, like getting a database connection.

https://github.com/dbernar1/Meteor-Slides/commit/35fcb3ac1254bd290a44f4a75b3e8702eac181a9 shows a technique I use to name parameters to functions that take several parameters. Especially nice for naming those “true”/”false” parameters to functions that even the WordPress coding standard suggests trying to avoid. It says: “Since PHP doesn’t support named arguments…”, but I think this example proves otherwise. Of course, python-style named parameters, where order does not matter any more, do not exist in PHP, but it is entirely possible to name parameters to functions as I show there.

https://github.com/dbernar1/Meteor-Slides/commit/7bab45bb35760a7fa5827542a57c556ccbe66ddb is the meatiest example of the bunch. I could have done several smaller refactorings. I suggest reading it by reading the change to meteor-slides-plugin.php first. An important thing to note is that it would have been much easier to express the functionality with well-named function stubs, like the new version does, when originally writing the software. This is because it is easier to express the algorithm of using the overrides if they exist without at the same time having to think about what the implementation of “is this file overridden in the child theme” is. It is also easier to read, because it is in English, not in “WordPress”. It is also important to note how at least one level of implicit meaning has been replaced by explicit meaning, with naming functionality such as “if ( the_child_theme_has_overridden_css_for_meteor_slides() ) {“. I’ll leave you with that for now.

What do you think? I’d love to get feedback from other software developers.

Rails vs. WordPress

I’ve been thinking about the topic of when I should use an MVC | framework, and when I should use a CMS platform ever since I discovered Drupal about 2.5 years ago. I don’t believe the topic is covered really well on the Web, and most people seem to have a shallow understanding of the topic, so I’ll share my thoughts with you.

The popular question in my company these days is “Rails or WordPress?”, but I will probably touch upon the broader questions of “MVC or CMS?” and “Ruby or PHP?”, so you can often substitute “Rails” for “MVC framework” in the article.

Something to also keep in mind is that in my experience the other MVC frameworks are much closer to being real competitors to rails than any other CMS is to WordPress, so that is something also to keep in mind (let us know in the comments if you want to propose some CMS candidates for using on projects instead of WordPress).

The Cop-out

The most common answer I hear from people, who I assume haven’t really thought about this for long, is “Rails is for web apps, WordPress is for websites.” But is my web-based system a website or a web app? Can most web-based system be put into one or the other category, or the other? Do you think you could score 5 out of 5 on a quiz which would show you a web-based system and ask you to pick a) website or b) web app?

The Gimmes

I’ve identified some traits of web-based systems which make it easy to choose one or the other.

I should say that regardless of the requirements of the system you’re building, in my opinion you should strongly consider whether the programmers you have available are much more proficient in one of the two environments. If your programmers are experts with Ruby and Rails and haven’t written even a 1000 lines of PHP, it is almost certainly better to use Rails for any system (except if you need a blog or promotional corporate website without any custom software development). Same for a team that is made up of WordPress and PHP experts with little Ruby and Rails experience.

Rails Gimmes

If you’re building a transaction processing system in which data and various views of that data are the only functionality, Rails is the natural choice. Examples that come to mind are a POS system, or a system that stores data about the amount of calls your call center is receiving, and then creating robust reporting based on that.

When looking for a Plastic extrusion company producing Angles, Flat sections, Channels & more. Visit this website lakelandplastics.com for more information.

If the web-based system you are creating does not have an element of web publishing, and your customer does not have a need for most of the screens in the WordPress admin, you should pick Rails.

If your web-based system is a web service built on top of an existing legacy database and doesn’t have a website component, you should pick Rails.

Please contribute good descriptions of projects where you’d pick Rails in the comments, and I will include them here along with a reference to a URL of your choice.

WordPress Gimmes

If you’re building a blog, you should use WordPress.

If your project will need all or most screens of the WordPress admin, you should use WordPress.

If you’re making a web publication system (CMS-based system) you should use Drupal. No, just kidding, use WordPress, since Drupal kinda sucks unfortunately. Sorry Drupal, you were an OK attempt, but WordPress is probably a better choice for any web-based system.

Please contribute good descriptions of projects where you’d pick WordPress in the comments, and I will include them here along with a reference to a URL of your choice.

The Pattern

If your team is about as proficient with both WordPress and Rails, or you’re shopping around to hire a team and both solid Rails and WordPress teams are available, it comes down to opportunities for code reuse. Will your system re-use more code if you use WordPress and its very usable admin area, myriad of available plugins and themes? Or can you re-use more code by harnessing the object-oriented design, DSLs and good software development practices mecca that is Ruby, Rails and the available libraries and tools?

In terms of the decision of Rails vs. other CMSs available, technically Rails is probably the leader of the pack for a large majority of applications. The advantage of Rails disappears if your programmers are much more proficient with Python or PHP, since there are probably good enough alternatives in their language, namely Django and CakePHP, but code re-use opportunities each MVC framework will bring should again be taken into consideration.

Writer’s Bias (Why I think I am well-positioned to write this article)

You can read about my professional travels so far.

Experience the adventure of nature with whale watching dana point – Book onine now at http://www.newportwhales.com

I now work for a company that uses both Rails and WordPress, and I am actually hired and paid to help make these exact kinds of decisions. I hope you will provide valuable feedback and discussion to help reach a further deeper understanding of the topic.

Patch for JWPlayer

I made a website for the Positive Parenting Program of the Manitoba Government while working at Canada’s Web Shop, and it had videos on one of the pages. Because the videos are self-hosted, I used the excellent JWPlayer for WordPress plugin, and it worked great except that when the staging site was brought down the videos stopped working.

It turns out that JWPlayer for WordPress is using WordPress guids instead of using the wp_get_attachment_url() function that makes it safe to move your WordPress website between domains. In short, the guid column in the posts table stores the original URL of the video, and if you change domains, the only way to get the correct URL is to use the aforementioned function.

I wrote a little patch, notified LongTail Video, and it is on its way to being included in the plugin.

RecipePress WordPress Recipe Plugin Project

As of recently, I am the main support person for the RecipePress WordPress plugin.

Over the last 6 months I’ve built and helped others build at least 5 recipe-based websites. Here’s a list:

Since all of them are using the RecipePress WordPress plugin, I ran into a bug, contacted the project owner, and it turned out he is looking to step down. Since I am always looking for successful PHP-based free software projects to contribute to, I think this is a great opportunity for me.

Here’re some useful links for RecipePress users:

Manitoba Triple P – Positive Parenting Program

I certainly enjoyed reading their content, and recommend for everyone to spend a little bit of time learning about the Positive Parenting Program.

Designer:
Chris Savoie
Plugins:
WPML, Grunion Contact Form, Widget Logic, JW Player Plugin for WordPress
Project URL:
http://manitobatriplep.ca