Chief Alchemist - Business Consulting For The 21st Century Via A Holistic & Intelligent Approach
Share ChiefAlchemist.com. RSS 2.0 feed for ChiefAlchemist.com. Sign up for the mailing list. Follow Chief Alchemist on Twitter. 'Like' the Chief Alchemist's page on Facebook. See what Chief Alchemist has been Q&A'ing on Quora. Chief Alchemist bookmarks & highlights on Diigo.com. Follow the Chief Alchemist on Digg.com. Chief Alchemist channel on Last.fm. Chief Alchemist on Flickr. Mark 'Chief Alchemist' Simchock on LinkedIn. Free Initial Consultation. Email Chief Alchemist. Phone Chief Alchemist.
  • Mark ‘Chief Alchemist’ Simchock
  • 'Email me.Email => ca .at. ChiefAlchemist .dot. com
  • 'Phone me.Alchemy United => 732 997-0028
  •  
  • Free initial consultation.Free => Initial Consultation
  • Please be sure to subscribe to your communication channels of choice.
  • Click To Close => The small green (consultation), red (email) or blue (phone) icons in the top upper right.
CURRENT “TOP 10” TOPICS TOOLS CLIENTS & PROJECTS SOURCES SEARCH HIDE
Business Consulting For The 21st Century Via A Holistic & Intelligent Approach

AU_WPing 0.8.1 (and why WordPress annoys me)

FYI => After doing some additional reading on writing/distributing press releases it became apparent AU_WPing was in need of another round of enhancements. The annoyance came when I decided I also wanted to validate some of the user entered post meta data the plugin used to work its social media updating magic.

For example, there’s a field for entering the URL of the image that will be posted (to Facebook) along with the status update. Basically, AU_WPing is doing a photo update and the message becomes the caption. I wanted to let the user know if this URL was in fact valid or not. It seems simple enough, right? Wrong!

To cut a long story short, in order to display any errors I tried using add_action ‘admin_notices’. The first snag was that action will display a notice across all admin pages. I was only interested in the new/edit post page. After crafting a conditional that checked the page and the post type I was able to keep the notice on the new/edit post page.

Unfortunately, I was not able to set the add_action priority such that the action would run and the notice would be created after the sever side validation but prior to the page being rendered. It was a classic WP annoyance—obscure but needed feature with very little documentation and/or the feature not working as the documentation promised. I should mention that (as far I could tell) WordPress doesn’t really have anything build in to do such things. The work around is to save any messages to the post meta data and then pull it back out when you need it. If there’s a better way I’d like to know.

Along with that add_action I was also using the built in WordPress CSS class=”error”. What’s interesting is that class doesn’t display where you put it in the markup, WP moves it and displays it in the header area below Add New Post/Edit Post. I stumbled upon this quirk when I tried putting the error message in the AU_WPing meta box and it would automatically move to the top of the page. Best I can tell that placement is done with javascript (but I could be mistaken on that point.) What annoyed me is this auto-placement wasn’t mentioned in anything I read. It was almost by error that I figured it out.

In short, I didn’t need add_action ‘admin_notices’. Instead I saved the error message with update_post_meta and then spit it back out in the post meta box I was already using. From there class=”error” moved that div to the top of the page where it was easy for the user to see.

The good news is I learned a couple new tricks today. That bad news is (once again) WordPress ate up more of my time than it should have. And I still have to do some extensive testing to make sure all is well again with AU_WPing.

Innovation is such a pain in the ass sometimes, eh? C’est la vie.

Required.
Will not be published. Required.
Please include http://