Tag: ‘ Wordpress

Template for Writing Your First Wordpress Plug-in

It seems like only yesterday, I set out to build my first ever Wordpress Plug-in. Bright eyed and bushy tailed, I poured over the Wordpress Codex, putting together the pieces of the process until I finally got the big picture. The Wordpress Codex is an amazing resource for anyone looking to get into Wordpress development; I strongly recommend any new developer read through the “Writing a Plugin” section.

While learning, I had a difficult time finding a straightforward template I could use as a base for my plug-ins. I wanted something that was clean and well-organized but also provided examples of more complex behaviours, such as: Internationalization, Widgets and Front and Back-End Ajax. I wanted to ensure my plug-in functionality was encapsulated inside a class structure so my functions and variables wouldn’t conflict with the Wordpress Core, or other plug-ins.

I’ve finally gotten around to writing this template plug-in, and I thought I would share it with the community to get your feedback and improvements, and hopefully save new developers some time. If you are interested in learning how to build a plug-in, and have a strong programming background, you can look through my sample code, read the comments and pretty much piece together how everything works. If you want a more thorough description of what is going on, read through this article.

You can download the plug-in from the Wordpress Plugin directory.

Getting Familiar With the Brolly Template Plug-in

  1. Download the template plug-in.
  2. Place the files in the plug-ins directory of your development installation of Wordpress.
  3. Come up with a unique name for your plug-in, such as MyPlugin. Check the Wordpress Plug-in directory to ensure this name hasn’t been used.
  4. Rename the plug-in folder from B2Template to your plug-in name (i.e. MyPlugin). Do not use spaces or special characters.
  5. Rename the file B2Template.php to MyPlugin.php
  6. Rename the file B2Template.class.php to MyPlugin.class.php
  7. Rename the class inside MyPlugin.class.php from B2Template to MyPlugin
  8. Rename the constructor function inside MyPlugin.class.php from B2Template() to MyPlugin()
  9. Activate the plugin from the Wordpress Plugin Administration Panel
  10. Add the Template widget to your sidebar from the Wordpress Appearance Administration Panel
  11. View your site, and interact with the widget to observe it’s behaviour
  12. From the Wordpress Administration page, click on Settings, and select MyPlugin.
  13. Interact with the plugin from this page, to view its behaviour.

How to Write a Plugin Using the Brolly Template Plug-in

Note: Substitute B2Template in the instructions below, to whatever you named your plugin (i.e. MyPlugin).

There are two main files in the Brolly Wordpress Plug-in Template. The first, B2Template.php, is used to initialize the plugin and route various Wordpress actions and filters to class methods in the second file, B2Template.class.php. Keeping all our plug-in functions inside a class gives us greater flexibility to reuse the code we write for the plugin. It also prevents naming conflicts from occuring when multiple plug-ins use the same function or variable names.

Continue reading.. ›

Mayfair Theatre Case Study: Holy APIs Batman!

We’ve just rolled out a new project, here at Brolly. Our client is, the Mayfair Theatre, a local independently run movie theatre in Ottawa, Ontario. The theatre recently closed down for renovations and is now under new ownership. Their web site was in serious need of an update, so we took the opportunity to do some really new and exciting things. We have been very excited about this project – it gave us great freedom to further develop our experience in social media and focus on providing meaningful interaction between our client and their customers.

Mayfair Theatre Case Study

Like many of our other projects, the website is built upon the WordPress platform. We built a custom plugin for them to manage their upcoming movie listings. This plugin has some great features:

IMDB Integration

The Wordpress plugin allows the Mayfair Theatre to manage their upcoming movies and showtimes. Instead of forcing the administrator to enter in details for each movie that’s playing, we interfaced with a very neat movie database api, called The Movie Database, to allow them to import upcoming movie information, YouTube trailers and high quality artwork. This feature will saves huge amounts of time.

Twitter Integration

We set up the theatre with a twitter account, @mayfairtheatre, and used the Twitter API to automatically broadcast what movies are playing on a daily basis. We are encouraging users to follow the theatre’s Twitter account with a series of giveaways including: movie passes, free concession coupons and movie posters. We believe that keeping people informed of show times on a daily basis will greatly improve attendance.

Google Calendar

Another way we are keeping users up-to-date on the movie schedule is by integrating show times with Google Calendar using the Google API. This calendar stays synchronized with the online schedule and allows users to add the calendar to their computer and mobile devices.

By leveraging existing APIs we were able to build a lot of great functionality into the site, within a limited budget and short development cycle. It seems like every day we are finding new and exciting ways to expand WordPress to accommodate the diversity of our clients. Look for more exciting plugins and services coming soon!

Q/A: How do I add multiple WordPress widget sidebars?

I’m putting together my first WordPress theme which requires three dynamic sidebars (don’t ask!!). For some reason I can’t figure out how to add the other two dynamic sidebars.. Could you help me please?

Adding in multiple sidebars is fairly straightforward and you can create as many as you need.

Locate your functions.php file in your theme and add the following code:

1
2
3
4
5
6
7
8
9
10
<?php
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Sidebar One', // The sidebar name to register
          'before_widget' => '<div class="widget">',
          'after_widget' => '</div>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
?>

Continue reading.. ›

Blogging 101: Wrap Up!

We completed our series on practical tips for writing a successful blog.

The entries from start to finish are linked below:

Blogging 101: Final Thoughts

You may be surprised at some rewarding benefits of blogging that you may experience:

  • Research that you do from blogging on different topics will be well archived for later retrieval.
  • Making your business more transparent, open and honest improves client relations.
  • Future clients can assess your expertise by consulting the blog in which you have articulated your approach and complex ideas clearly and effectively.
  • Feedback from readers will give you valuable information with which to improve your business approach.
  • Participation in a community of professional peers will give you valuable business resources.

All this and more can result from a blog that works for you. So, to summarize, some of our most important recommendations for developing a successful business blog:

1. Cultivate a writing style that is characterized by an honest and authentic perspective that demonstrates your passion and expertise. Potential clients reading the blog will be drawn to authenticity above all else - they are not interested in reading promotional writing from the cold voice of a seemingly large business. They would like to support businesses run by people who love what they do and who are able to express their knowledge effectively.

2. Commit to regular posting to encourage loyal readers. Readers subscribe to blogs that are active with regular posts - the frequency of posting will reflect on the activity and vigour of the business itself.

3. Write posts that are on topic and of reasonable length (500 words is a good number to aim for).

4. Link abundantly to helpful resources for your readers and the posts of other blogs. If you make your site rich with resources in your industry, it will help to establish your business’ reputation and attract new clients and like-minded thinkers to help your business grow.

Continue reading.. ›

Blogging 101: Networking Tips (Part: 2)

Monitoring Blogging Success

Once blogging on a regular basis and beginning to build new relationships, it can be helpful to keep track of the progress of your blog. Statistics are easy to review for ongoing measurable information about the readers of your blog.

Recommended tools for monitoring statistics are:

  • A Google Analytics account that will give you detailed information on who is visiting your site.
  • A Feedburner account that will keep track of the number of subscribers.

You can also visit major blog search engines to find link citations to your site made by other bloggers. A few popular blog search engines are: Technorati, Feedster, Blogpulse and Bloglines.

In measuring your overall ROI and blog success, there are several metrics it can be helpful to review:

Continue reading.. ›

Blogging 101: Networking Tips

Blogging is not only about writing content effectively, but also about building relationships and expanding your professional network. Quality posts come first; promotion of these posts comes second. Both are essential to becoming a blogging success.

Managing Comments

Responding to comments is essential. You should think of commenters, as well as your readers, as potential clients or sources of referrals. With this in mind, take the time to reply to their comments in a thoughtful and respectful manner. Responding in a timely manner will show that you appreciate their feedback and set you on track to building a relationship with them.

Responding to negative feedback can be a sensitive area for any business. The advantage of the blog is that these comments happen where you can easily respond to them as opposed to on other sites or through word of mouth to other potential clients. You can use every comment as an opportunity to learn more about your existing or potential clients and their needs.

1. Make sure you are really listening. Read the comment or email carefully before setting out to respond to it.

2. While it may be rare, there is a time when comments can get out of hand. There are people often nicknamed “trolls” who deliberately seek to ignite controversy and will blatantly say offensive things to achieve this. Let your readers know how you will handle unreasonable comments in advance, so that when you take action you have the support of your initial ‘policy.’ While some bloggers do not censor any comments, the level of control you have over them is entirely up to you. Take a position on what you consider an unacceptable comment, and explain this to your readers openly and honestly.

3. Acknowledge the comment with kindness, openness and a willingness to understand. Ask them questions to find out more and if possible, take immediate action to demonstrate you have taken their feedback seriously. Apologize if in error.

4. Consider involving them in the solution to their problem. In most cases they are readers who want to help your business improve - so take advantage of their criticism in order to find out more about how your business can grow through learning about their needs.

Commenting on other blogs is the first step in building out your online network. It is also important for you to give feedback by commenting on the blogs of those you read and respect - this will help to develop relationships and ultimately serve to increase visibility to your blog. Readers will consult the comments section of certain key posts, and if they read a response that is especially well thought out and helpful, there is a good chance they will visit the site. Commenting can also help to build relationships with other bloggers, who may become long term correspondents supporting your business. Effective comments demonstrate careful thought about the post, and do not come across as promotional or self-serving.

Continue reading.. ›

Congrats! Wordpress 2.7 Officially Released

Photo by crystalflickr.

It’s official WordPress 2.7 code name “Coltrane” has been released. Congratulations to the WordPress development team on another successful release.

The widely anticipated version 2.7 features a totally redesigned dashboard, comment threading, sticky posts, no hassle upgrading and much more.

This was interesting to us, a blogging software release we actually blogged about, but the process was hugely informative. Prior to its release today Crazyhorse and 2.7 had been tested by tens of thousands of people on their blogs, hundreds of thousands of you count .com. The volume of feedback was so high that we decided to push back the release date a month to take time to incorporate it all and do more revisions based on what you guys said.

Photo by: crystalflickr

Blogging 101: Writing Tips

Once you’ve started writing - keep them reading. It has been said many times that “Content is King.” Content will become the most important thing that draws in your readers on the blog, creating trust and building loyalty as they learn from your expertise. Through the use of several techniques you can encourage and maintain this readership.

What should I write about? Several topics and post ideas

A benchmark for effective content is that you are creating something of value for potential clients. Put yourself in the position of the reader to understand what kind of writing would be useful, and consider what blogging qualities keep you reading and entice you to subscribe to blogs you read.

Here is a list of basic blogging ideas for you to consider. We encourage you to brainstorm additional ideas on your own or with your colleagues before your blog launch, and every few months from there after. This way, you will always have a list of ideas to reference when having difficulty with content development or audience engagement.

Continue reading.. ›

Q/A: How can I add threaded comments to WordPress 2.7?

We’ve received our first question from a reader who asks how to incorporate threaded commenting into his WordPress 2.7 blog.

The latest version of WordPress includes lots of new functionality, including the ability for threaded commenting (also know as: nested comments). The option to enable threaded commenting is built into WordPress, however your theme must be compatible with WordPress 2.7 and support threaded commenting.

Threaded comments with WordPress

There’s already been several step by step tutorials on how to incorporate this new functionality, so rather than reinvent the wheel read this post by Otto.

Got a WordPress related question for us? Ask us here.

line