Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Fix Undefined index notice in Dashboard: Scheduled Posts plugin WordPress

  • SOLVED

Hello,

Currently I'm using a somewhat modified version of the Dashboard: Scheduled Posts plugin.
Running WordPress 3.1.3 it seems to be a bit out of date giving me an Undefined index notice.

The code:
<?php
/*
Plugin Name: Dashboard: Scheduled Posts
Plugin URI: http://www.viper007bond.com/wordpress-plugins/dashboard-scheduled-posts/
Description: Displays scheduled posts on your WordPress 2.7+ dashboard.
Author: Viper007Bond
Version: 2.0.0
Author URI: http://www.viper007bond.com/
*/
class DashboardScheduledPosts {
function DashboardScheduledPosts() {
if (!current_user_can('edit_posts'))
return;
load_plugin_textdomain('dashboard-scheduled-posts', FALSE, '/dashboard-scheduled-posts');
add_action('admin_head', array(&$this, 'css'));
add_action('wp_dashboard_setup', array(&$this, 'register_widget'));
add_filter('wp_dashboard_widgets', array(&$this, 'add_widget'));
}
function register_widget() {
wp_register_sidebar_widget('dashboard_scheduled_posts', __('Scheduled', 'dashboard-scheduled-posts'), array(&$this, 'widget'));
}
function css() {
?>
<style type="text/css">
#dashboard_scheduled_posts ul {
margin: 0;
padding: 0;
list-style: none;
}
#dashboard_scheduled_posts ul li {
margin-bottom: 0.6em;
}
#dashboard_scheduled_posts h4 {
font-weight: normal;
}
#dashboard_scheduled_posts h4 abbr {
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
font-size: 11px;
color: #999;
margin-left: 3px;
}
#dashboard_scheduled_posts p {
margin: 0;
padding: 0;
}
</style>
<?php
}
function add_widget($widgets) {
global $wp_registered_widgets;
if (!isset($wp_registered_widgets['dashboard_scheduled_posts']))
return $widgets;
$widgets[] = 'dashboard_scheduled_posts';
return $widgets;
}
function widget() {
$futures_query = new WP_Query(array(
'post_type' => array(
'post',
'page'
),
'what_to_show' => 'posts',
'post_status' => 'future',
'posts_per_page' => 5,
'orderby' => 'date',
'order' => 'ASC'
));
$futures =& $futures_query->posts;
if ($futures && is_array($futures)) {
$list = array();
foreach ($futures as $future) {
$url = get_edit_post_link($future->ID);
$title = _draft_or_post_title($future->ID);
$item = "<h4><a href='$url' title='" . sprintf(__('Edit "%s"'), esc_attr($title)) . "'>$title</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $future) . "'>" . get_the_time(get_option('date_format'), $future) . '</abbr></h4>';
if ($the_content = preg_split('#\s#', strip_tags($future->post_content), 11, PREG_SPLIT_NO_EMPTY))
$item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
$list[] = $item;
}
?>
<ul>
<li><?php echo join("</li>\n<li>", $list); ?></li>
</ul>
<p class="textright"><a href="edit.php?post_status=future&post_type=post" class="button"><?php _e('View all scheduled posts'); ?></a> <a href="edit.php?post_status=future&post_type=page" class="button"><?php _e('View all scheduled pages'); ?></a></p>
<?php
} else {
_e('There are no scheduled posts at the moment', 'dashboard-scheduled-posts');
}
}
}
add_action('plugins_loaded', create_function('', 'global $DashboardScheduledPosts; $DashboardScheduledPosts = new DashboardScheduledPosts();'));
?>


The notice:
Notice: Undefined index: dashboard_scheduled_posts in /home/design24/public_html/klanten/23/wp-admin/includes/dashboard.php on line 120
A fix for this would be more than appreciated.

Answers (3)

2011-06-12

Utkarsh Kukreti answers:

Try changing

wp_register_sidebar_widget('dashboard_scheduled_posts', __('Scheduled', 'dashboard-scheduled-posts'), array(&$this, 'widget'));

to

wp_add_dashboard_widget('dashboard_scheduled_posts', __('Scheduled', 'dashboard-scheduled-posts'), array(&$this, 'widget'));


cor comments:

Which is the correct answer (: Thanks Utkarsh!

2011-06-12

Fahad Murtaza answers:

Check if your wp-config.php has this

define('WP_DEBUG',false);

if not, please add.


cor comments:

Hello Fahd,

I am aware it's possible to <em>hide</em> errors. They'll still remain as errors though.
The reason I'm asking for paid support is to have these fixed.

2011-06-12

Julian Lannigan answers:

I installed this plugin on my sandbox environment with no error. I suggest trying this plugin: [[LINK href="http://wordpress.org/extend/plugins/future-dashboard-widget/"]]Future Dashboard Widget[[/LINK]]. This one hasn't been updated in a awhile either but, it's last update was more recent then the [[LINK href="http://wordpress.org/extend/plugins/dashboard-scheduled-posts/"]]Dashboard: Scheduled Posts[[/LINK]].


cor comments:

Hi Julian,

Thank you for your reply, but having define('WP_DEBUG',false); I'm getting this notice:
Notice: Use of undefined constant futurewidget_init - assumed 'futurewidget_init' in /home/design24/public_html/klanten/23/wp-content/plugins/future-dashboard-widget/futurewidget.php on line 26


cor comments:

Sorry, I did mean define('WP_DEBUG',true);