Home Français A propos Contact rss
WordPress from the beginning
Articles de fond, tests de plugins, modes d'emploi et astuces sur ce CMS

Publishing a plugin at WordPress

Here's the follow-up to the series "creating a plugin". What's on the menu? widget parameters, adding a cron and publishing your plugin.

Here’s a recap of the previous episodes:

In creating a plugin, we learnt:

  • how to create the plugin’s folder and its main php file
  • that we could add functions()
  • about filters and actions
  • how to create a widget
  • the plugin’s initialisation
  • how to integrate several languages
  • the use of options

In creating a plugin part 2:

  • the plugin’s activation
  • the filter to add content into the body of the article, or into the page
  • how to create admin pages

Widget parameters’ formular

When you add a widget, you’ve noticed that you have a little formular where to add a few parameters. To get it, you must call the register_widget_control() function; it uses as parameter the name you gave the widget, the name of the callback function that will post the formular and will obtain the data, width and length.

register_widget_control('Name of your widget', 'my_plugin_widget_control', 300, 200);
 
function my_plugin_widget_control() {
	if ( $_POST['bar'] == 'foo' ) {
	  // réception des données
	}
       // les champs du formulaire, sans la balise form
	echo '...';
}

Further info about widgets’ apis on http://codex.wordpress.org/Plugins/WordPress_Widgets_Api

Adding a cron

If your plugin needs to execute actions at regular intervals and automatically (without the blogger’s intervention), you need to add a cron. Here’s a method:

First, upon plugin activation, create a new action (watch out: action = event. This is not a function!) via the function wp_schedule_event, which takes as paremeters: the time of first release, repetition frequence and name of action.

wp_schedule_event(time(), 'hourly', 'my_plugin_cron_action');

From then on, wordpress will regularly start your action. You then link function calls (as many as you want) with this new action, through the usual add_action() function.

add_action('my_plugin_cron_action', 'my_plugin_cron_job');
function my_plugin_cron_job() {
  // do something each hour
}

Last, upon plugin deactivation, you deprogram the cron with wp_clear_scheduled_hook():

wp_clear_scheduled_hook('my_plugin_cron_action');

Other infos on how to manage crons in this article.

Publishing your plugin

Your plugin’s finished, it’s been tested on your blog, you’ve tried to install and uninstall it on other blogs and everything’s rolling. Now’s the hardest part… :-D

Here’s all you need to do to publish your plugin at http://wordpress.org/extend/plugins/, and as an introduction: http://wordpress.org/extend/plugins/about/

The master php file

This is the file with your php code; at the very beginning, it must include comments with the plugin’s name, the url of your blog’s article that summarizes everything about your plugin, its current version, a short description, your name and the url of the article that introduces who you are:

/*
Plugin Name: All last viewed posts
Plugin URI: http://www.woodymood-dev.net/cms/wordpress/
Description: This plugin is usefull if you want to display the last views from your human traffic.
Version: 0.1
Author: Anthony Dubois
Author URI: http://www.woodymood-dev.net/cms/wordpress/en/lauteur/
*/

It must also include comments that include the GPL license with your name, again, and your email address:

/*  Copyright 2009  ANTHONY DUBOIS  (email : xxx)
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

We went through this in the first article of the series, “creating a plugin”, therefore this shouldn’t be breaking news to you!

The readme.txt file

Here’s the news: you must obligatorily provide a readme.txt file, at first level, in your plugin folder. Its content will be posted on your plugin’s pages at http://wordpress.org/extend/plugins/.

Its syntax is outlined here: http://wordpress.org/extend/plugins/about/readme.txt and you can even test your file with http://wordpress.org/extend/plugins/about/validator/.

The beginning of the file is what’s most important. That’s where you’ll indicate which wordpress versions it supports, and the plugin’s latest stable version: it’s important so surfers may download the latest version.

=== Plugin Name ===
Contributors: markjaquith, mdawaffe
Donate link: http://example.com/
Tags: comments, spam
Requires at least: 2.0.2
Tested up to: 2.1
Stable tag: 4.3

The readme must then explain what your plugin does, and how to install it. If you want, you can add an FAQ and screenshots as well. But the best is to post, on your own blog, a detailed article that explains all of the above and to include links into the readme.txt.

Writing an article that presents the plugin

More writing work! You must obligatorily write an article, common to all versions, that gives all the info about your plugin: what it does, how to install it, how to use it, how to integrate it, what changes from one version to the next etc. Everything you already wrote in the readme.txt in fact, except it should be more detailed and user-friendly!

The article will also be used as support to its users, via the comments. Provided you do support!

This article is compulsory, as wordpress people will look for it when you submit your plugin. It must therefore include a link to your plugin’s zip archive.

Submitting your plugin

The submit page is here: http://wordpress.org/extend/plugins/add/… but you’ll need an account at wordpress.org to get the formular!

addplugin

http://wordpress.org/extend/plugins/add/

As you can see, all you’re doing is submitting the url of the article written in the previous chapter.

More explanations at http://codex.wordpress.org/Plugin_Submission_and_Promotion

Provided everything runs smoothly, you will receive an email that tells you your plugin was accepted and that you may publish it at subversion, the server which hosts all plugins and their versions. In fact http://wordpress.org/extend/plugins/ is just a shopwindow; storage is done at http://svn.wp-plugins.org/

Subversion

Subversion is a freeware that has the same role as CVS for those who know it, i.e. a client system server to manage versions.

If http://svn.wp-plugins.org/ is the server, you are the client! WordPress provides documentation to access subversion if you have a client command-line.

If, like me, you’re not keen on command-line, there are graphic clients such as subcommander. The details of its usage are in this other article.

To summarize, after you’ve installed subcommander you must dedicate a repertory to your plugin’s versions on your harddrive. Create one folder for each plugin, and at this point leave it empty.

Its first fill-up will happen upon the first “checkout” of the svn http://svn.wp-plugins.org/your-plugin/ server, with the effect that it will create trunk, tags and branches folders (empty, at this stage).

Then, copy your files into the trunk folder using the windows explorer.

After that, do an “add” of your new files from subcommander’s menu, so they are effectively added to the local repertory.

Last, do a “checkin”, or “commit” in subcommander’s jargon, in order to actually send your content to wordpress’ svn server. It’ll ask for a message and login/password, which is identical to the one used on wordpress.org.

The mirror site is updated every 15 minutes, so be patient… and soon enough you’ll see your plugin appear, including all the content of your readme.txt file, at http://wordpress.org/extend/plugins/your-plugin

When you launch new versions of your plugin, you’ll need to put them in tags subfolders, naming them 1.0, 1.1, 1.2 etc. Make sure you always indicate in the trunk folder’s readme.txt your plugin’s latest stable version number (stable tag).

Spread this post over the world!

Share/Bookmark

How did you like this post?

Please don't go without leaving a mark!
5 vote(s) 1 Etoile2 Etoiles3 Etoiles4 Etoiles5 Etoiles Loading ... Loading ...

Reactions

comments 9 comments
  1. November 25th, 2009 at 17:18

    et au fait c’est lequel votre plugin ?

    Like or Dislike: Thumb up 0 Thumb down 0

  2. Alex
    November 25th, 2009 at 15:51

    Re bonjour, je viens de m’apercevoir que le nom de mon plugin est présent sur cette url http://svn.wp-plugins.org/. Je pourrai enfin publier mon plugin, il fallait attendre tout simplement (pour moi environ 3 jours et plus).
    Je trouve tout particulièrement bizarre que WordPress.org ne m’ai pas envoyer de mail me disant que le svn était prêt, en tout cas je vous remercie.

    Like or Dislike: Thumb up 0 Thumb down 0

  3. Alex
    November 19th, 2009 at 14:28

    Je pense avoir bien suivi les étapes, en ce qui me concerne, le plugin est déjà fait donc j’ai créé un compte sur wordpress.org.
    Après réception de mon mot de passe, je me suis connecté (sans cela le formulaire de la section “Soumettre le plugin” n’est pas visible) puis j’ai soumis ma requête avec une description light du plugin ainsi que l’url où trouver plus d’information sur celui-ci.
    Je vais attendre encore quelques jours puis je vous tiens au courant.

    Like or Dislike: Thumb up 0 Thumb down 0

  4. November 19th, 2009 at 13:22

    @Alex
    Quelques heures, voir moins….
    Es tu sur d’avoir tout fait comme il faut ?

    Like or Dislike: Thumb up 0 Thumb down 0

  5. November 19th, 2009 at 13:20

    pour moi ça a mis bien 2 jours effectivement, 2 ou 3 je ne sais plus exactement.

    Like or Dislike: Thumb up 1 Thumb down 0

  6. Alex
    November 19th, 2009 at 11:20

    Article très bien fait! C’est ma référence pour avoir les étapes de publication de plugin.
    Par contre je suis bloqué à l’étape “Soumettre le plugin” :p
    Ca fait 2 jours que j’ai envoyé mon formulaire et toujours rien.
    Quelqu’un peut me dire le temps que ça prend pour qu’il me réponde et si il m’envoie des informations comme mon compte sur leurs Subversion et l’adresse pour la connexion?
    Je suis ravi de recevoir tout information complémentaire (ou expérience) de votre part :)

    Like or Dislike: Thumb up 0 Thumb down 0

  7. May 6th, 2009 at 08:10

    Bien vu, c’est loin d’être aussi clair sur le site de wordpress.

    Like or Dislike: Thumb up 0 Thumb down 0

Top
Choisissez vos widgets

About this post

  • About this weblog

    "WordPress From the beginning" is written by a French web developer and teacher currently based in Switzerland.

    Originally planned in french, both blog and its functions were developped in this language. This explains why not all functions are available in the English version.

    However, new translated articles are regularly posted for use by the wordpress' web community.

Wordpress from the beginning is a production of Woodymood
Performance Optimization WordPress Plugins by W3 EDGE