Skip to content

@franz-josef-kaiser /cron-list.php
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Plugin: List wp cron jobs in wp_footer
<?php
defined( 'ABSPATH' ) OR exit;
/*
Plugin Name: WP Cron Jobs List
Plugin URI: https://github.com/franz-josef-kaiser
Description: List WordPress internal cron jobs (array data) after the footer.
Author: Franz Josef Kaiser
Author URI: https://github.com/franz-josef-kaiser
Version: 0.3.1
License: MIT
*/
add_action ( 'shutdown', 'wpse18017_list_cron' );
/**
* Builds a table to list current wp internal cron job data
*
* @param mixed array $cron_arr
* @return string
*/
function wpse18017_list_cron( $cron_arr )
{
// Load cron jobs and flatten array
foreach ( _get_cron_array() as $key => $data )
{
if ( is_int( $key ) )
{
if ( 1 <= count( $data ) )
{
foreach ( $data as $k => $d )
{
$v = array_values( current( $d ) );
$cron_jobs[ $k ] = $v;
}
continue;
}
$val = array_values( current( $data ) );
$cron_jobs[ key( $data ) ] = $val[0];
}
}
// Nothing to do
if ( empty( $cron_jobs ) )
return;
$results = '';
foreach ( $cron_jobs as $name => $data )
{
list ( $schedule, $args, $interval ) = wp_parse_args(
array_fill( 0, 3, 'not-set' ),
$data
);
$args = var_export( $args, true );
foreach ( wp_get_schedules() as $l10n )
{
if ( $interval === $l10n['interval'] )
{
$schedule = $l10n['display'];
$interval = ( $interval /60 /60 );
}
}
$results .= "<tr><td>{$name}</td><td>{$args}</td><td>{$schedule}</td><td>{$interval}</td></tr>";
}
echo <<< EOF
<div class="clear"></div>
<div class="wrap">
<table class="wp-list-table widefat" style="margin: 10px;">
<caption>Dump of the cron/sheduled events:</caption>
<tr><th>Function</th><th>Arguments</th><th>Shedule</th><th>Time (h)</th></tr>
$results
</table>
</div>
EOF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.