3

I am new to wordpress, I am looking for a plugin which can display days since I have not blogged on my Admin Dashboard.

I found an article here, but could not find any associated wordpress plugin and nor i have skill to create wordpress plugin out of it.

Please suggest plugin.

3
  • maybe a better place to ask and learn things about WordPress: wordpress.stackexchange.com Commented May 15, 2016 at 8:00
  • Posted same question there, and immediately it was marked off topic as I had asked for suggestions on available plugin. :)
    – Harsh
    Commented May 15, 2016 at 10:26
  • 1
    i'm not sure if you will get useful answers here... since it's too specific for one software (as it have to be wordpress?)! - in this case it is better to look for support at the provider/maintainer/community of the dedicated software! - wordpress.org/support Commented May 15, 2016 at 11:36

2 Answers 2

1

Here's a quick WordPress plugin for you, which should be pretty much 'set-and-forget'.

Installation instructions:

  1. Copy the content below into a new file called days-since-last-post.php, and place that file directly in your wp-content/plugins folder.
  2. Go to the Plugins page in your WordPress admin, look for 'Days Since Last Post' in the list, and click Activate

This has been tested on WordPress 4.5.3, which is the latest version available as of this answer.


<?php
/*
Plugin Name: Days Since Last Post
Plugin URI: https://softwarerecs.stackexchange.com/questions/32079/
Description: Displays on the Dashboard the number of days since your last post
Version: 1.0.0
Author: Tim Malone, majick, David Kryzaniak
Author URI: https://softwarerecs.stackexchange.com/questions/32079/
License: GPLv2 or later
*/

add_action( 'wp_dashboard_setup', 'srse32079_add_dashboard_widgets' );

function srse32079_add_dashboard_widgets() {
    wp_add_dashboard_widget( 'srse32079_lastpost', 'Days Since Last Post', 'srse32079_days_since_last_post' );
}

function srse32079_days_since_last_post() {
    $recent = wp_get_recent_posts( array( 'numberposts' => 1, 'author' => get_current_user_id() ) );
    $start = strtotime( $recent[0]['post_date_gmt'] );
    $link = get_the_permalink( $recent[0]["ID"] );
    echo 'There have been <strong>';
    echo ceil( abs( time() - $start ) / 86400 );
    echo ' days</strong> since your <a href="' . $link . '">last post</a>.';
}

Some code sourced from posts by majick and David Kryzaniak.


Changes/enhancements to this plugin are welcome via editing this post. Please include an edit summary, increment the version number, and add your name to the Author list. Most importantly, test your changes on the latest version of WordPress.

0

A quick search found this function here:

https://wordpress.stackexchange.com/questions/123051/get-how-many-days-since-last-post-of-the-current-user

function days_since_last_post(){
    $recent = get_most_recent_post_of_user( get_current_user_id() );
    $start = strtotime($recent['post_date_gmt']);
    echo "Days since last post: ";
    echo ceil(abs(time() - $start) / 86400);
}

All you need to do is use wp_add_dashboard_widget and pass the function:

wp_add_dashboard_widget('lastpost','Days Since Last Post','days_since_last_post');
2
  • Hi majick. Thanks for responding. Sort of solution was provide through a link on my question too, but I was looking for a Plugin. Thanks.
    – Harsh
    Commented Jun 7, 2016 at 15:20
  • This function actually only works on Multisite. I've added a comment to the relevant answer on the post you linked to, and also to the WP Codex page referencing the function. I'll put together a quick plugin which I'll post here as an answer shortly.
    – Tim Malone
    Commented Jun 23, 2016 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.