Journey

Last night I submitted WP File Hide to WordPress.org. It felt great, second plugin in review. I’ve got my third plugin, WP Name Your Donation, functional and now I just need to clean it up, comment better and submit.

I’ve been pushing hard to become a better WordPress dev. I’ve been forcing myself to do any task the right way even if there is a shortcut that will work just fine (in a small app). For instance including js in a plugin. In WP Name Your Donation one of the gateway options is Stripe. Stripe requires you to include a public api key in javascript. This is a key that I allow the site owner to set in their admin settings. I did some research and realized I had two options.

1) Echo out the javascript in a php function then add it to a hook. From what I could tell, this was the sloppy and easy way. Funnily, this was the first tutorial I found and it was on a WordPress codex page. Same page had the below method as well underneath this first one.

2) Register a .js file and localize it allowing variables to be passed. This seemed a bit more complicated but I opted to go that route after screwing around with option 1 and feeling the sloppiness build up. Final code came out like this:

stripe.php
wp_register_script( 'key', plugin_dir_url( __FILE__ ) . '../../gateways/stripe/key.js', array( 'jquery' ), '1.0', true );

$pubkey = array();
if( isset( $options['wpnyd_stripe-mode'] ) && isset( $options['wpnyd_stripe-tpk'] ) ) {
$pubkey['pubkey'] = trim( esc_attr( $options['wpnyd_stripe-tpk'] ) );
} elseif( isset( $options['wpnyd_stripe-lpk'] ) ) {
$pubkey['pubkey'] = trim( esc_attr( $options['wpnyd_stripe-lpk' ] ) );
}
wp_localize_script( 'key', 'pubkey', $pubkey );
wp_enqueue_script( 'key' );

key.js
Stripe.setPublishableKey(pubkey.pubkey);

SVN What?

I was so proud that my plugin got accepted into WordPress.org last night.  Now, I’m so lost on how to actually get it activated there.  But I’m working on it.

I just started using Git and tools associated.  I’ve figured out the repository system for the most part and mine are with BitBucket.  Wordpress requires you to use their repository which they call an SVN.  I guess SVN is a different kind of repository with features that allow better version tracking .. or something like that.  I’m still a bit lost.

So, after consulting with some dev friends I finally got this TortoiseGit system that I followed a few commands I found online and it seems to be doing something.  This little turtle is being thrown from an icon of earth into a folder.  And it’s taking forever.

My bit of reading indicates that when you do your first commit to activate your plugin, WordPress has to look through every single plugin in their system.  Why? I haven’t the foggiest, but hopefully after a few hours this turtle is completely in his folder and my plugin is active.

Publishing My First Plugin

I submitted my plugin WP People Pop a few days ago to the WordPress.org system.  I waited anxiously to get my response and see if it was approved.  Well, this morning I got my answer, no.  No, it has not been approved yet.

I read through the email and turns out you aren’t supposed to include libraries with your plugin that WordPress already provides in its core.  I was using jQuery UI to handle some interface items and I included the whole UI package in my plugin’s directory.

I checked out the list of included libraries and turns out you can’t just include all of jQuery UI but you have to include each component you need, seperately.  I guess this makes sense, why have more code included than necessary?

I resubmitted with changes.  Oh, they also made sure to mention I need to clear the now unused js files out.  Email below:

There are issues with your plugin code. Please read this ENTIRE email, address all listed issues, and reply to this email with your corrected code attached. It is required for you to read and reply to these emails, and failure to do so will result in your plugin being rejected.

## Including jquery files (or calling them remotely)

WordPress includes its own version of jquery and many other similar JS files, which have all been rigorously tested with WP and many of the most common plugins. In order to provide the best compatibility and experience for our users, we ask that you not package your own (especially not an older version) and instead use wp_enqueue_script() to pull in WordPress’s version.

Please review http://codex.wordpress.org/Function_Reference/wp_enqueue_script and update your plugin accordingly. You need to both change your code to use our jquery as well as remove the unused files. Remember! Keeping unused files out of your plugins makes them smaller and less potentially vulnerable! if you have any jquery files included in your plugin that WP core has, just delete them.

Offloading jquery js, css, and other scripts to Google (or jquery.com or anywhere else frankly) is similarly disallowed for the same reasons, but also because you’re introducing an unnecessary dependency on another site.  If the file you’re trying to use isn’t a part of WordPress Core, then you should include it -locally- in your plugin, not remotely.

If your code doesn’t work with the built-in versions of jquery, it’s most likely a no conflict issue. If you can’t guess, we -really- want you to use our JS files, and if you can’t, we need to know why so we can fix things for everyone. If you’re just including it because you want to support old versions of WP, or because you think they may not have jquery, please don’t. If they don’t have the default jquery, a lot more than your plugin will break. And if they’re on older versions of WordPress, they need to upgrade, and we don’t recommend you support anything except the most recent version of WP and one release back.

WordPress already has jquery and jquery UI included. Do not include your own. The CSS is fine, but the JS is not.

—-

Please make sure you’ve addressed ALL issues brought up in this email. When you’ve corrected your code, reply to this email with the updated code attached as a zip, or provide a link to the new code for us to review. If you have questions, concerns, or need clarification, please reply to this email and just ask us.

Learning WordPress

I’ve been developing websites for nearly twenty years… alone.  I’ve never been on a team with other coders.  My jobs have all been freelance or being a full-time webmaster.  Once for a hospital and now for a school.  All the coding knowledge I have is self taught.

I thought I was good.  My eyes were open when I became interested in possibly working for a company my friend worked for.  I applied, nailed the personality interview then choked on the code samples.  I was a bad programmer.

I understand coding.  I can read code.  I get the logic and what is happening and why.  But I had no structure.  I didn’t take the extra step to keep things clean and prepared for growth.  I’d right nearly the same section of code five times in an app instead of writing an appropriate function.

I decided to level up and I’ve started.  My first goal was to write a plugin from scratch and do it the right way.  As of now it’s being reviewed for addition to WordPress.org.  I have another nearly ready to submit and another half finished.  I’ve built a theme and I’ve been studying the deeper parts of WordPress core.  Onward and upward.

Hello world (again)!

Hi world, my name is Chris Flannagan and I’m an internet developer.  And a musician… and father, and husband, and painter, and writer, and homebrewer, and graphic design and, well, I like to do a lot of stuff.

I’ve bounced my focus in life around quite a bit but at the ripe age of 32 I believe WordPress and php are my true passions.  As I’ve been on a journey to level up my skills in these areas I’ve decided to put together a site to display my work and blog about my life.  This isn’t the first time I’ve done this hence the “(again)” in my title, but I’m going to make it my best.