Improvements to Church Admin Plugin

I’ve made some improvements to the Church Admin Plugin in v0.52

Main menu – vastly improved with drag and drop and close

Rota management – the rota now uses autocomplete to store people in their job! You can also email the rota out to participants

Sermons – can now be uploaded and podcasted – mosts hosts have an upload limit of 8MB, so there is a facility to add already uploaded files that perhaps you have ftp’d.

The cache of emails is now stored in a subdirectory the uploads directory – with a redirect in the old directory.

Photos You can upload photos for people, but not much use is made of them yet

Fixes

  • Activation errors
  • Tied up code and initialise all variables more correctly
  • Functions that require people to be in the directory first only show when directory is populated.

Coming Soon

  1. Shortcodes page in the menu to list all the shortcode options
  2. Photos in the directory as an option
  3. Bible passages in the sermon uploader
  4. Rewrite of the calendar module – with ical support
  5. Instruction Manual

Writing and updating the plugin is pretty time consuming but fun and largely fuelled by coffee, so if you like, please thank me with a brew!…


What would you like to see added to the plugin?

Using Meta Boxes on Plugin Admin Pages

Meta Boxes are boxes that appear on the dashboard and for custom features on edit page/post pages. They can also be used in plugins too. Here’s how to create meta boxes on an admin page that will remember whether you have opened/closed them and the order you have dragged them into.

meta-box

They are relatively easy to create!

1) Enqueue the scripts that will allow toggling open and closed and the order to be changed. They need to be hooked in at the ‘init’ stage

2) Create the page the boxes will appear on

Those classes and ids allow the meta box styling to happen

3) Create functions for each meta_box’s content

4) The meta boxes need nonce fields to allow any open/close toggling and order changes to be saved

5) The meta boxes are then “added” and “done”

add_meta_box prepares the meta box and can be placed in your content stream or as in an add_action hook
do_meta_boxes tells wordpress to render the meta box

6) Lastly we need some jquery to initialise previously saved open/close toggles and order

pluginname is your plugin name that you have used above. Other tutorials used pagenow but it didn’t work for me on custom admin pages in v3.5

Here’s the code bundled up…

How to internationalise a wordpress plugin

If you want your plugin to have a greater reach why not internationalise it – hopefully people will soon start translating it for you!

Here’s what to do!

Step 1

set up the plugin to load the translation files with this code, changing “your-plugin-name” as needed.

That means that wordpress will load the right translation file from your plugins languages directory.

Step2

Change all the output text in your plugin to use the internationalised versions

so $foo= ‘Blah Blah’; becomes $foo=__(‘Blah Blah’,’your-plugin-name’);
and
echo ‘Blah Blah’; becomes _e(‘Blah Blah’,’your-plugin-name’);
Thoroughly test your plugin at this stage!

Step 3

Set up the initial default translation file defautlt.po in the languages folder.
Download and install poedit from http://www.poedit.net/download.php
The instructions are about as useful as a chocolate teapot, hence this blog post.

Once you have installed the Poedit program, open it.
poedit-first-screen
Click on File then New catalog…
poedit-new-catlog-first-tab
Fill out the Project Name at least and then click on the Sources Path tab.
This is where everyone goes wrong on Windows computers! The base path needs to be the full path to your plugin root directory not “.” e.g. C:\xampp\htdocs\wordpress\wp-content\plugins\church-admin
Then you can add the sub directories in the paths section by clickingthe second icon from the left (dotted box type icon).

Next click on the Sources Keywords tab and select each of the current ones and delete them.
Add __ and _e and then press ok

With any luck you will not get the annoying “Updating the catalog failed error” which happens when you don’t do the full windows path.
poedit-error

Now you can save the file as default.po in the languages folder of your plugin.

Click on Update at the top and it will search your php files finding words that will need to be translated

poedit-done

Click save to save it!
Then commit the default.po file and language directory using your SVN programme and let your user base now of the update, by announcing it readme.txt, your facebook plugin page, twitter account….

Hope that helps. A future post will be how to translate your favourite wordpress plugin!