function postExpiratorMenuDiagnostics() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!isset($_POST['_postExpiratorMenuDiagnostics_nonce']) || !wp_verify_nonce($_POST['_postExpiratorMenuDiagnostics_nonce'], 'postExpiratorMenuDiagnostics')) { print 'Form Validation Failure: Sorry, your nonce did not verify.'; exit; } if (isset($_POST['debugging-disable'])) { update_option('expirationdateDebug', 0); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Disabled', 'post-expirator'); echo "</p></div>"; } elseif (isset($_POST['debugging-enable'])) { update_option('expirationdateDebug', 1); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Enabled', 'post-expirator'); echo "</p></div>"; } elseif (isset($_POST['purge-debug'])) { require_once plugin_dir_path(__FILE__) . 'post-expirator-debug.php'; $debug = new postExpiratorDebug(); $debug->purge(); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied', 'post-expirator'); echo "</p></div>"; } } $debug = postExpiratorDebug(); ?> <form method="post" id="postExpiratorMenuUpgrade"> <?php wp_nonce_field('postExpiratorMenuDiagnostics', '_postExpiratorMenuDiagnostics_nonce'); ?> <h3><?php _e('Advanced Diagnostics', 'post-expirator'); ?> </h3> <table class="form-table"> <tr valign-"top"> <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:', 'post-expirator'); ?> </label></th> <td> <?php if (POSTEXPIRATOR_DEBUG) { echo __('Status: Enabled', 'post-expirator') . '<br/>'; echo '<input type="submit" class="button" name="debugging-disable" id="debugging-disable" value="' . __('Disable Debugging', 'post-expirator') . '" />'; } else { echo __('Status: Disabled', 'post-expirator') . '<br/>'; echo '<input type="submit" class="button" name="debugging-enable" id="debugging-enable" value="' . __('Enable Debugging', 'post-expirator') . '" />'; } ?> <br/> <a href="<?php echo admin_url('options-general.php?page=post-expirator.php&tab=viewdebug'); ?> ">View Debug Logs</a> </td> </tr> <tr valign-"top"> <th scope="row"><?php _e('Purge Debug Log:', 'post-expirator'); ?> </th> <td> <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log', 'post-expirator'); ?> " /> </td> </tr/> <tr valign-"top"> <th scope="row"><?php _e('WP-Cron Status:', 'post-expirator'); ?> </th> <td> <?php if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true) { _e('DISABLED', 'post-expirator'); } else { _e('ENABLED - OK', 'post-expirator'); } ?> </td> </tr/> <tr valign-"top"> <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:', 'post-expirator'); ?> </label></th> <td> <?php _e('The below table will show all currently scheduled cron events with the next run time.', 'post-expirator'); ?> <br/> <table> <tr> <th style="width: 200px;"><?php _e('Date', 'post-expirator'); ?> </th> <th style="width: 200px;"><?php _e('Event', 'post-expirator'); ?> </th> <th style="width: 500px;"><?php _e('Arguments / Schedule', 'post-expirator'); ?> </th> </tr> <?php $cron = _get_cron_array(); foreach ($cron as $key => $value) { foreach ($value as $eventkey => $eventvalue) { print '<tr>'; print '<td>' . date_i18n('r', $key) . '</td>'; print '<td>' . $eventkey . '</td>'; $arrkey = array_keys($eventvalue); print '<td>'; foreach ($arrkey as $eventguid) { print '<table><tr>'; if (empty($eventvalue[$eventguid]['args'])) { print '<td>No Arguments</td>'; } else { print '<td>'; $args = array(); foreach ($eventvalue[$eventguid]['args'] as $key => $value) { $args[] = "{$key} => {$value}"; } print implode("<br/>\n", $args); print '</td>'; } if (empty($eventvalue[$eventguid]['schedule'])) { print '<td>' . __('Single Event', 'post-expirator') . '</td>'; } else { print '<td>' . $eventvalue[$eventguid]['schedule'] . ' (' . $eventvalue[$eventguid]['interval'] . ')</td>'; } print '</tr></table>'; } print '</td>'; print '</tr>'; } } ?> </table> </td> </tr> </table> </form> <?php }
function postExpiratorMenuDiagnostics() { if (isset($_POST['debugging-disable'])) { update_option('expirationdateDebug', 0); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Disabled', 'post-expirator'); echo "</p></div>"; } elseif (isset($_POST['debugging-enable'])) { update_option('expirationdateDebug', 1); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Enabled', 'post-expirator'); echo "</p></div>"; } elseif (isset($_POST['purge-debug'])) { require_once plugin_dir_path(__FILE__) . 'post-expirator-debug.php'; $debug = new postExpiratorDebug(); $debug->purge(); echo "<div id='message' class='updated fade'><p>"; _e('Debugging Table Emptied', 'post-expirator'); echo "</p></div>"; } $status = postExpiratorCronEventStatus(); if ($status) { $cronstatus = '<span style="color:green">' . __('OK', 'post-expirator') . '</span>'; } else { $cronstatus = '<span style="color:red">' . __('RESET NEEDED', 'post-expirator') . '</span>'; } $schedule = postExpiratorCronScheduleStatus(); if ($schedule) { $cronschedulestatus = '<span style="color:green">' . __('OK', 'post-expirator') . '</span>'; } else { $cronschedulestatus = '<span style="color:red">' . __('ERROR WITH FILTER', 'post-expirator') . '</span>'; } $debug = postExpiratorDebugEnabled(); ?> <form method="post" id="postExpiratorMenuUpgrade"> <h3><?php _e('Cron Settings', 'post-expirator'); ?> </h3> <table class="form-table"> <tr valign-"top"> <th scope="row"><label for="reset-cron-event"><?php _e('Reset Cron Event:', 'post-expirator'); ?> </label></th> <td> <input type="submit" class="button" name="reset-cron-event" id="reset-cron-event" value="<?php _e('Reset', 'post-expirator'); ?> " /> <?php _e('Status:', 'post-expirator'); ?> <?php echo $cronstatus; ?> <br/> <?php _e('Resets the cron event and removes any old or stray entries.', 'post-expirator'); ?> </td> </tr> <tr valign-"top"> <th scope="row"><label for="reset-cron-schedule"><?php _e('Reset Cron Schedule:', 'post-expirator'); ?> </label></th> <td> <?php _e('Status:', 'post-expirator'); ?> <?php echo $cronschedulestatus; ?> <br/> <?php _e('Displays the cron minute schedule status for post expirator.', 'post-expirator'); ?> </td> </tr> </table> <h3><?php _e('Advanced Diagnostics', 'post-expirator'); ?> </h3> <table class="form-table"> <tr valign-"top"> <th scope="row"><label for="postexpirator-log"><?php _e('Post Expirator Debug Logging:', 'post-expirator'); ?> </label></th> <td> <?php if ($debug) { echo __('Status: Enabled', 'post-expirator') . '<br/>'; echo '<input type="submit" class="button" name="debugging-disable" id="debugging-disable" value="' . __('Disable Debugging', 'post-expirator') . '" />'; } else { echo __('Status: Disabled', 'post-expirator') . '<br/>'; echo '<input type="submit" class="button" name="debugging-enable" id="debugging-enable" value="' . __('Enable Debugging', 'post-expirator') . '" />'; } ?> <br/> <a href="<?php echo admin_url('options-general.php?page=post-expirator.php&tab=viewdebug'); ?> ">View Debug Logs</a> </td> </tr> <tr valign-"top"> <th scope="row"><?php _e('Purge Debug Log:', 'post-expirator'); ?> </th> <td> <input type="submit" class="button" name="purge-debug" id="purge-debug" value="<?php _e('Purge Debug Log', 'post-expirator'); ?> " /> </td> </tr/> <tr valign-"top"> <th scope="row"><label for="cron-schedule"><?php _e('Current Cron Schedule:', 'post-expirator'); ?> </label></th> <td> <?php _e('The below table will show all currently scheduled cron events with the next run time.', 'post-expirator'); ?> <br/> <?php if (postExpirator_is_wpmu()) { printf(__('There should be an event named expirationdate_delete_blogid (where the blogid is replaced with the numeric id of the blog) with a schedule of %s.', 'post-expirator'), '<em>' . get_option('expirationdateCronSchedule', POSTEXPIRATOR_CRONSCHEDULE) . '</em>'); } else { printf(__('There should be an event named expirationdate_delete with a schedule of %s.', 'post-expirator'), '<em>' . get_option('expirationdateCronSchedule', POSTEXPIRATOR_CRONSCHEDULE . '</em>')); } ?> <br/> <table> <tr> <th><?php _e('Date', 'post-expirator'); ?> </th> <th><?php _e('Event', 'post-expirator'); ?> </th> <th><?php _e('Schedule', 'post-expirator'); ?> </th> <th><?php _e('Interval (seconds)', 'post-expirator'); ?> </th> </tr> <?php $cron = _get_cron_array(); foreach ($cron as $key => $value) { foreach ($value as $eventkey => $eventvalue) { print '<tr>'; print '<td>' . date_i18n('r', $key) . '</td>'; print '<td>' . $eventkey . '</td>'; $arrkey = array_keys($eventvalue); print '<td>' . $eventvalue[$arrkey[0]]['schedule'] . '</td>'; print '<td>' . $eventvalue[$arrkey[0]]['interval'] . '</td>'; print '</tr>'; } } ?> </table> </td> </tr> </table> </form> <?php }