Log in

No account? Create an account
Flea Circus Director [userpic]

Simple wordpress plugin for updating link date

3rd June 2011 (18:09)

As part of another plugin I'm developping I created this test.

The plugin adds a new Meta box on the right of the links form to display the date the field was last modified. There's some code to capture the date that a link is modified. The field already exists in the table so the code ended up very simple.

Suggested changes if you wanted to use this.

1) Wrap the 3 functions into a class
2) Add a function that populates initialise all the data values that are blank when the plugin is activated

Plugin Name: Andys Link Last Edited Meta Box
Plugin URI: #
Description: Updates links to current data/time when edited and then displays that on the edit link admin screen
Version: 0.2
Author: AGC based on the work of Ozh and
Author URI:
// This function tells WP to add a new "meta box"
// N.B. There is no options screens for this plugin

//See http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins
//    http://planetozh.com/blog/2008/02/wordpress-snippet-add_meta_box/
//    http://wordpress.org/extend/plugins/link-updated/
//    http://codex.wordpress.org/Function_Reference/add_meta_box

function LinksAGC_edit_update($link_ID) {
    global $wpdb;
    $sql = "update wp_links set link_updated = NOW() where link_id = " . $link_ID . ";";

function LinksAGC_add_LastMod_box() {
        'linkmodifieddiv', // id of the <div> we'll add
        'Last Modified', //title
        'LinksAGC_add_last_modfied', // callback function that will echo the box content
        'link', // where to add the box: on "post", "page", or "link" page
        'side'  // location, 'normal', 'advanced', or 'side'

// This function echoes the content of our meta box
function LinksAGC_add_last_modfied($link) {
     if (! empty($link->link_id))
    echo "Last Modified Date: ";
    echo $link->link_updated;
    { echo "New Link";}
// Hook things in, late enough so that add_meta_box() is defined
if (is_admin())
    add_action('admin_head', 'LinksAGC_add_LastMod_box');
    add_action('edit_link', 'LinksAGC_edit_update');
    add_action('add_link', 'LinksAGC_edit_update');


Posted by: ((Anonymous))
Posted at: 16th August 2011 20:12 (UTC)
backlink services

Hey There. I found your blog using msn. This is a very well written article. I will be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I'll definitely return.

Posted by: strentasom (strentasom)
Posted at: 3rd November 2011 12:02 (UTC)

excellent articles, useful for me. keep writing and happy blogging.

2 Read Comments