Category Archives: Function

Plugin or hack? How to get the best functionality in your WordPress installation.

The Legacy Of Simple:Press

There are many tips on Shrewdies for making the most of Simple:Press. I’ve saved the best until last – leave it.

If you use it, switch to Question2Answer. If you are contemplating using it, contemplate Question2Answer. It is better, faster, and much easier to integrate with WordPress, despite being a standalone system.

I got a compliment from one of the Simple:Press founders – Wow! what a busy forum!

Not this site of course, but I have success elsewhere on the net, and I needed forum support. Simple:Press was broken, and upsetting some of my thousands of daily visitors. I tried to get support, but now you have to pay for it. Don’t get me wrong – people who give good support deserve to get paid. But if a piece of software is broken, you should not have to pay to get it fixed.

Continue to read how to deal with the legacy of Simple:Press forum software for WordPress

Best WordPress WYSIWYG Editor

When I explained how NicEdit has become my personal best WordPress WYSIWYG editor, I mentioned some issues.

Whilst the best solution would be to delve into the NicEdit code, and change the parts that present problems, I have found workarounds that mean I can get by without this for now.

In fact, I am not certain if this is truly a NicEdit issue, or the way WordPress builds it’s comments forms. I’ll leave the strict coding debate until I’ve fully investigated why it works in FireFox but not in MicroSoft Internet Explorer (MSIE).

In my first investigation I explained how wrapping elements in HTML Paragraph tags will break NicEdit under MSIE. The symptom is a small disabled NicEdit toolbar that renders it useless. I explained in that article about modifying the comments.php to remove the paragraph tags (or change them to DIV tags) re-enabled NicEdit. However, WordPress 3 has changed the way the comments form is built.

The good news is that there is no need to hack the WordPress core that serves the form. All that is needed is a simple change to the way the comments form is called in your theme.

Restore NicEdit As Your MSIE WordPress WYSIWYG Editor

If you are using a pre-WordPress 3 theme, your comments form is built directly in comments.php. Current themes replace many lines of code with a simple call to a new function – comment_form().

This is much tidier, but the default settings are very NicEdit unfriendly. Not only does it retain the MSIE-breaking paragraph tags, but default width settings do not get passed to MSIE at the toolbar rendering stage.

Additionally, the default form displays the allowed HTML tags. This is something very dear to my heart in a normal comments textarea. Visitors should be told which tags are allowed to save those frustrating times when you type a long and interesting comment, only to see it posted as garbled rubbish because the pre or code tags are not allowed. With NicEdit, such vital information is unnecessary, as the tags are all processed before the code is saved, and you can even configure which buttons are available.

So how do we get the comments form to display NicEdit properly?

The call to comment_form() is near the end of comments.php in the theme editor area. If you are not happy with editing themes, get in touch with the theme author and ask them to add comment form parameters in the theme options. Or if the theme is not supported, then let me know, and I’ll produce a NicEdit enabled version of it.

If you cannot find comment_form() then chances are that you have an older theme, in which case search for the textarea line, and adapt the following.

The comment_form() function allows most aspects of the comment form to be changed by passing an array of parameters. More details are in the WordPress codex, but all you need to do is paste the following between the brackets() of the comment_form function:

array('comment_field'=>'<div class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" style="width:350px" rows="8" aria-required="true"></textarea></div>','comment_notes_after'  => 'Thank you.')

This simply changes 2 settings, comment_field and comment_notes_after by slightly changing the default WordPress code. I’ve cheated a little by including an inline style statement – my site is about getting things done quickly, and then we can argue with the purists to find more elegantly coded solutions. The important thing is that the following 3 NicEdit defeating issues are overcome:

  1. p is replaced with div to prevent MSIE “Unknown runtime error Line: 8 Char: 721”
  2. cols=”45″ is replaced with a width setting. Alternatively, you could probably set this in the style sheet, but I have not tested this.
  3. The allowed tags are replaced with a simple ‘Thank you’ message. You could change this to something else, or just the quotes to remove it entirely.

Change Defaults To Make NicEdit Your Best WordPress WYSIWYG Editor

In my previous article I explained the quick way to enable NicEdit to be your editor for WordPress comments or Question2Answer questions, answers and comments. Posting the default code certainly works, but you are at risk of losing the editor if the NicEdit site is unavailable.

The first thing you should do is copy NicEdit to your own server, and amend the first NicEdit line in your header.php to:

<script src="path-to-your-nicedit/nicEdit.js" type="text/javascript"></script>

If you like to keep images in a separate folder from js files, you will also need to change the NicEdit defaults. You will probably need to do this anyway to change the default buttons and add extra features. So, amend the second NicEdit line to:

<script type="text/javascript">bkLib.onDomLoaded(function() {nicEditors.allTextAreas({iconsPath : 'path-to-your-nicedit/nicEditorIcons.gif'})});</script>

In this instance we are only changing the iconsPath, but any nicEdit parameters can be amended in a comma separated list.

If you’ve implemented these improvements and still have unresolved issues, please let me know below. As I mentioned earlier, I will soon publish complete step-by-step guides for NicEdit enabling Question2Answer and WordPress, combined and in isolation. I’d appreciate your help in making it as complete as possible by clarifying any issues you may still have.

WordPress Default WYSIWYG Editor

My search for the perfect WordPress Default WYSIWYG editor is far from over, but at least I have a stable solution that works.

I’ve switched between NicEdit and TinyMCE for a few months. I like the simplicity of NicEdit, and had it working nicely on WordPress sites.

Then all sorts of weirdness started happening when I tried the beta of Q2A on a development site. I’d taken what I thought were sensible precautions. The site in question was new and had no visitors. I prefer to experiment with this sort of site if possible, as running development sites under localhost on my PC is not always a good representation of the real world. I had an absolute nightmare with this, and suspected all the new stuff I was trying out (beta Q2A and beta WordPress 3.0!)

Turned out it was nothing to do with the beta software, and everything to do with lousy server configuration backed up by lousy tech support from Bl** Host.

In the process of trying to get back to something that worked, I tried different settings on this site. I didn’t realize that I’d left WYSIWYG turned off here until vince told me.

For now, I’ve left tinyMCE alone. It looked like a good solution, but there are a whole bunch of formatting issues, so I’ve decided to focus on NicEdit.

I use it to make WordPress commenting better, and for Q2A. Within those setups (either of Q2A, WP, or both) there are installation and configuration options, so I’ll try to cover all the permutations.

Preparing Q2A

Q2A strips out any html code from multi-line text, so we have to tweak it. If you are uncomfortable with tweaking code, raise the issue on the Q2A site, and ask for an Admin option to disable it.

We have to edit the qa_html() function in qa-base.php, which sits in the qa-include folder. Find (Ctrl-F) qa_html, and you should see lines similar to those below. They change $html, but we want it to stay as entered. I simply comment out the string manipulation, and set the return value to the string that was passed in:
if ($multiline) {
// $html=preg_replace('/rn?/', "n", $html);
// $html=preg_replace('/(?<=s) /', ' ', $html);
// $html=str_replace("t", '    ', $html);
// $html=nl2br($html);
$html=$string;
}

If you do not do this, NicEdit will still work, but the HTML tags will get stripped before your questions, answers, or comments get saved.

This change will need to be reapplied whenever you upgrade or reinstall Q2A.

WYSIWYG Question2Answer

The simplest implementation is to copy the from NicEdit front page:

<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>

Then paste it into the Question2Answer Admin area. All you do is go to the Layout settings, and paste the above code into the ‘Custom HTML in <HEAD> section of every page:’ and save the settings.

You should see that all your multi-line text boxes have a WYSIWYG display with edit buttons across the top. The buttons are disabled until you click into the textarea.

Now check that NicEdit works OK on your question, answer and comment boxes. The easiest way is to edit existing items.

This has worked successfully every time I have tried it, but there may be some formatting issues on some browsers. I will cover these in my next article.

WordPress Default WYSIWYG Editor

For most of my sites, I want both WYSIWYG for Question2Answer and for WordPress. I always wrap my Q2A theme inside the WordPress theme, so it makes sense to apply NicEdit to the WordPress header. In this setup, you do not have to also apply it to NicEdit, unless you want different editor configurations in each area.

So to make NicEdit the WordPress Default WYSIWYG Editor and also apply it to Question2Answer, simply post the NicEdit code into header.php within the HEAD tags. This also applies if you just use WordPress without Question2Answer.

Test your comments both at the article level, and (if you use threaded comments) the reply to comment level. NicEdit should work nicely, but there may be issues in some browsers. You really need to try as many browsers as possible, but certainly common ones that your visitors use. See your server logs or analytics program – Google Analytics is very good – to get a list of browsers that your visitors use.

In my next article, I will look at some of the issues that WordPress themes can cause, especially with MSIE. I’ll explain how to overcome these issues, and approaches to investigating problems. I will also explain how to avoid the pitfalls associated with simply pasting the NicEdit code from their site. You will see how to create the best WordPress WYSIWYG editor.

You might notice that I do not use the NicEdit/WordPress default WYSIWYG editor that I have described on this site. That is because I intend to move all the interactive features to a separate site, and add more discussion and feedback tools. When I’ve done that, I will produce a complete step-by-step guide for integrating NicEdit and Question2Answer under a WordPress theme.

Let me know if you want to see it in action before you commit to these changes, and I will show you sites where it works so that you can see the improved front end.

WordPress Plugin: Promotion Tool

Many of you looking for a WordPress plugin promotion tool have stumbled across my Happiness Today plugin.

You seem disappointed that the next version is where the real promotion potential lies, but the good news is that you do not need to wait.

If you have downloaded and activated Happiness Today, then you already have a tool for displaying random (or selected) promotion messages in your WordPress posts, pages or sidebar.

The main appeal of Pods is the way it makes extending the WordPress database so easy. But stored data is of little use if you cannot present it to your visitors. My first release of Happiness Today was just to prove that, like Hello Dolly does for standard WordPress, it is very easy to build a basic plugin. That basic plugin instantly demonstrates how Pods stores and displays data. In keeping with the Hello Dolly tradition, I displayed random lyrics in the Admin area – but the real life potential was always to be able to produce something simple yet useful, that can display random promotion messages to visitors.

Those promotional features are included in the current release, just not obvious. Here’s how to use Pods inbuilt features to get more from the Happiness Today plugin. Start your marketing campaign now. Continue reading

WordPress Pods: Food For Thought

The data-presentation link is vital. To get the best out of WordPress Pods, it pays to study the sample that is packaged with the Pods CMS plugin, and the more advanced examples in the Pods Packages directory.

It is also vital to have a clear plan of the presentation outcomes that you need.

When describing the data aspect of my first plugin, I wrote of the importance of thoroughly analyzing the relationship between the presentation of content required, and the structure of data needed to support it. Recently, I saw a question on the Pods Support Forum that seemed to relate to this area. I was particularly interested in it because the issues seemed to be similar to matters I had encountered with my shrewdBar WordPress menu bar plugin.

The difficulty with forum discussions is fully understanding what the issues are. If one is sat with a client, or even on a video link, it is easy to mock up a quick display and discuss what the presentation should actually look like. Difficulties are compounded with cultural and time-zone differences. But, “All is one in their own way,” and the power of the Internet allows the following attempt at understanding the problem and suggesting a solution.

I hope it solves the problem it tries to address, but even if it doesn’t, I’ve learned a neat CSS trick that I’ll be using again.

Basic Pods Data Display

First, create the Pod (Pods – Setup – Pods – Add new pod) using the data supplied.WordPress Pods Table
Second, Continue reading

Pods WordPress Plugins Double Overnight

Today, the number of WordPress Pods plugins in the plugin database doubled.

My Happiness Today plugin release joins the Pods UI plugin to double the number of examples of Pods CMS use.

Though this is released as a teaching tool, you should not assume it is perfect. Though it works perfectly, there are a few rough edges in the implementation. But that is the point of Open Source tools – we can improve all aspects of Happiness Today, collectively.

I like the idea of the Hello Dolly plugin as a teaching tool. Though it is criticized for it’s limited usefulness, the WordPress developers have defended it, by rightly explaining:

I think Hello Dolly is a good little example plugin. Users can turn it on, see that it does something, turn it off, see that it doesn’t do it anymore. Plugin functionality exemplified.

This is perfectly true, and useful for novice WordPress users who want to understand what a plugin is, without being intimidated by reams of PHP code. But Pods developers are a different breed. We have varying PHP & HTML skills, but we are bound by a common desire to learn and extend WordPress functionality.

So Happiness Today goes beyond the remit of Hello Dolly, and achieves useful outcomes. Using the simple Pods data edit screens, you can transform Hello Dolly into a client support tool, or promotion tool for any campaign where short messages to WordPress website builders are going to win you a click or three.

Simple Pods WordPress Plugin Output

Simple Pods WordPress Plugin Output

Though I have used plain text in the distributed plugin, the data is stored as rich text, so you can easily include images and hyperlinks in the message display. This is in addition to the included customizable link buttons. After editing the data files with whatever text you need, you can easily import it as a Pods Package for your client sites.

I prepared the plugin in minutes using the Pods Plugin Builder that is the real goal of this project. In fact, most of the time is spent writing the readme.txt file that is generated as part of the plugin distribution package. That tool is still under development, but when available, it will make distribution of your own version of Happiness Today, or any other Pods Package, a very simple process.

Happiness Today Next Steps

Please contribute ideas to the wishlist. Also, if you are a superb PHP programmer, I would love to here your thoughts on code improvement.

I would also like to you to rate the Happiness Today Pods WordPress plugin, but if you cannot give it a 5 star, at least give me the opportunity to fix any problems you have before you vote.

WordPress Pods Projects Going For A Song

When I introduced my WordPress Pods Plugin Builder yesterday, I hinted at an example project to test the builder with.

I can reveal that this will be an homage to the ubiquitous Hello Dolly plugin – with some extras, and some Pods magic.

Just to remind you. I love Pods as it is intended to be used – a Content Management System that extends WordPress Pages and Posts to allow developers to provide new content styles. This is extremely important to me as I develop new tools for webmasters, and new web applications to extend my health sites.

But for the moment, I’m hooked (pun intended) on using Pods to hook rapidly developed packages into WordPress as plugins. This series of articles explains the Pods features used to create WordPress plugin files complete with readme.txt. WordPress explains what a plugin is by way of the Hello Dolly example. In a similar way, I needed a very simple plugin application to test and demonstrate my WordPress Pods Plugin Builder.

Enter Soft Charisma, the music company run by Scott Kingsley Clark, one of Pods lead developers. Scott has written the perfect song to complement Hello Dolly – Think Of Happiness Today.

Happiness Today Plugin

Happiness Today Plugin - click for large size

My plugin, Happiness Today, displays random lyrics from the song on the admin pages. So far, so Hello Dolly, but there are extras: Continue reading

WordPress Pods Plugin Builder Taking Shape

WordPress Pods CMS plugin is fantastic for adding new content to websites that do not easily fit the standard Page or Post styles.

With it’s easy to use interface, it is good for novice writers, but it also stands on a very powerful data management platform.

This makes it a real candidate for Rapid Application Development, but how to package and distribute those applications?

Before I present my latest project for building structured WordPress plugins, packaged with properly formatted readme file, straight from the Pods interface let me explain what Pods is.
Continue reading

Make Microformats Work For You – Ignore Them

Microformats are the latest topic to confuse budding webmasters.

But are they relevant to WordPress website owners, and will they help or hinder your marketing efforts.

More to the point – what are they?

The buzz for webmasters is that microformats help you on Google. But there are one or two fairly large points missing from that.

Before we look into those, let me explain what microformats are. They are tags in your web page, similar in operation to HTML tags. Whereas HTML tags change the appearance of text, microformats tell search engines and other robots what your text means. More specifically they describe the context of your text as structured data.

Whoopi-f-ing-doo you cry, or at least “so what.”

But wait, this is important.

If a search engine can interpret the type of information you are presenting, it can list you better. It puts your information into the right context. You can explicitly distinguish the author of a work from a work about an author.

Your words, with these descriptive tags, are known as rich snippets. If you currently earn money by providing content that includes reviews, people, businesses, organizations, events or video, then you need these snippets to help you get richer.

Why Microformats?

A search engine that might have sent you a little traffic from time to time has more information on rich snippets (including a validation tool), but before you investigate that, consider what is missing from the “Google & Microformats: Drive More Traffic” article. Continue reading

WordPress WYSIWYG Made Easy

What you see is not always what you get with WordPress.

WordPress WYSIWYG

  • Easily add site-wide WYSIWYG textareas
  • Beware the Internet Explorer trap
  • Download to avoid losing service
  • Configure options for best results

By default, the standard WordPress WYSIWYG editor is TinyMCE – but it is a non-standard implementation, and it is only used in new posts, not comments.

There are many plugins that extend both the functionality and application of TinyMCE. Life can get very complicated checking all the options, but I stopped looking when I road tested Front-end Editor. This uses the NicEdit WYSIWYG editor, which is very easy to implement.

I looked at the WP NicEdit plugin, but it is no longer supported. Anyway, I checked out the NicEdit site, and it only needs a couple of lines of code, so I just added them to my footer. Being short of time, I took the lazy option of linking direct to the NicEdit site, using the two lines of code on the NicEdit homepage, instead of installing on my own server. I regretted that, but it was easily fixed, with some interesting options, which I will explain soon.

First let me mention a terrible problem (with a praise-winning fix) I found when I tested in Internet Explorer instead of my faithful Firefox. Continue reading