Archive | Wodpress Plugins RSS feed for this section

Overriding pluggable functions in a plugin

21 Dec

There is a small detail you need to remember when trying to override a pluggable function in a wordpress plugin – The original function will not be overridden in plugin activation time, which means that the following code will make the plugin activation to fail with a redeclaration error message


function override() {
...
}

What you actually have to do to take care of this situation is to protect the function declaration by checking whether the function is already declared


if (!function_exists('override') {

function override() {
...
}

}

Author slug plugin

5 Nov

The author slug wordpress plugin adds the ability to control the slug associated with an author, in a similar way in which you can control the slug of a category.

It is not compatible with wordpress MU.

Usage

After activation a new field titled “Slug” will be added in the user profile page when an administrator is editing the profile. To change the slug just enter the new slug and submit.

If the requested slug already exists, a slug will be generated in the form slug-n.

if the slug field is empty, the slug will be reset to the wordpress defualt.

If you find it useful, don’t be to shy to

License

GPLv3

WordPress version compatibility

Was tested against 2.8, but should work with earlier versions

Installation

1. Download the plugin and unzip it (or not, if you are going to use the built in wordpress plugin installer)
2. Upload the unzipped folder authorslug to your plugins directory.
3. Activate the plugin through the ‘Plugins’ menu in WordPress

Changelog

  • 1.0

Initial release.

Searchbox plugin – Add search to posts and pages

28 Sep

The searchbox wordpress plugin adds a seachbox short code which generates a search form when the page or post is displayed.

It is wordpress MU compatible both when used as regular plugin and as an MU plugin.

Typical usage: [searchbox]

If you find it useful, don’t be to shy to

Parameters

  • class

    Can be used to add a name of a CSS class for the form
    Example: [searchbox class=search]

  • plugins

    Can be used to apply the get_search_form filter to the form. Might be useful if you have some plugins which add extra functionality to the search widget.
    Example: [searchbox plugins=1]

  • Full shortcode format

    Can be used to inser text (or any HTML) in the form above the input fields. Usefull if you want that text to be styled differently.
    Example: [searchbox]Use the search Lok[/searchbox]

styling

The form do not reuse the id’s of the normal seach form and therefor it should result in a bare form for most themes.
If you wish to style the form you should specify your own class for the form with the class attribute.

The classes specified for the different sections of the form are

  • searchtext – The class of the text
  • searchbox – The class of the input box
  • searchsubmit – The class of the submit bottun

Installation

1. Download the plugin and unzip it (or not, if you are going to use the built in wordpress plugin installer)
2. Upload the unzipped folder searchbox to your plugins directory.
3. Activate the plugin through the ‘Plugins’ menu in WordPress

Changelog

  • 1.0

Initial release.

Control Outbound RSS plugin for wordpress

18 Sep

This plugin will handle several aspects of RSS feeds generated by wordpress

  1. Reduce the amount of bandwidth required to transmit the RSS by sending only the items which were had not being already sent to the specific RSS reader.
  2. Better control on the amount of items which are included in the feed. For sites with very frequent posts or comments the default of 10 might not be enough.
  3. If it is possible at all, add a feed per a comment thread.

The first version handles only the bandwidth reduction issue. Just download it, put it into your wordpress plugin directory, if you use it for a stand alone wordpress, or at the mu-plugins directory for wordpressmu.

It was tested in wordpress 2.8, but it should work for wordpress 2.2 and above.

What content plugins should genrate in an RSS feed?

11 Sep

Plugins should add content to the RSS feed but only if that is there main function, otherwise they probably should not. Why not? because the main functionality of the RSS feed is to notify a subscriber about new content, while giving him a glimpse of what the content is about.

Most of the plugins which add something to the content displayed on the web page, such as the social bookmarks icons, do not add any new content to the post itself, and therefor they should not be adding anything to the RSS feed.

A typical social bookmarking plugin code looks like

function handle_content($content) {

 $content = $content.'<div><a href="url1"><img src="src1" /></a><a href="url2"><img src="src2" /></a></div>
';
 return $content;
}

Which looks good on the web page, but in the RSS the result will depend on the number of words in the original post. If the original post contained less than 55 words, the extra html which was added by the plugin will be sent as part of the RSS.

The result might be (due to some cleaning that WordPress does)


Original content

<a href="url1"><img src="src1" /></a>
<a href="url2"><img src="src2" /></a>

Which adds two links which are not part of the content. Actually it can be even worse with the extra content being split up and the result is something that resembles junk. That is why the plugin code should look like


function handle_content($content) {

 if  (is_feed()) // do nothing if we are generating a feed
   return $content;

 $content = $content.'<div><a href="url1"><img src="src1" /></a><a href="url2"><img src="src2" /></a></div>
';
 return $content;
}

This way the changes made by the plugin are not seen in the RSS feed. But there always should be an exception, and if the RSS has the full post maybe it does make sense to add the same content to the feed and the post. Add a check of the value of the rss_use_excerpt option, which indicates whether the RSS is full, and the code becomes


function handle_content($content) {

 if  (is_feed() && (get_option('rss_use_excerpt') == 1)) // do nothing if we are generating a feed of excerpts
   return $content;

 $content = $content.'<div><a href="url1"><img src="src1" alt="" /></a><a href="url2"><img src="src2" alt="" /></a></div>
';
 return $content;
}

But what should be done with shortcodes?