Plugin Directory

Changeset 120599


Ignore:
Timestamp:
05/26/2009 04:13:25 PM (17 years ago)
Author:
brockangelo
Message:

Fixed cron not executing after activation.

Location:
delete-spam-daily
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • delete-spam-daily/trunk/delete-spam-daily.php

    r120453 r120599  
    44Plugin URI: http://brockangelo.com/wordpress/plugins/delete-spam-daily/
    55Description: Uses wp_cron to delete comments each day that are marked "spam" in the database.
    6 Version: 1.0
     6Version: 1.0.1
    77Author: Brock Angelo
    88Author URI: http://brockangelo.com
     
    2424*/
    2525
     26# uncomment the next line if you want it to delete spam upon activation.
     27# register_activation_hook(__FILE__, 'delete_spam_daily');
     28
     29add_action('delete_spam_daily', 'delete_spam_now');
    2630
    2731function dsd_start_schedule() {
     
    3943   
    4044    echo $dsd_spam_count;
     45}
     46
     47function reschedule_delete_spam() {
     48    wp_reschedule_event( (time()+60), 'daily', 'delete_spam_daily');
    4149}
    4250
     
    5967            dsd_stop_schedule();
    6068        }
     69        if(isset($_REQUEST['reschedule_delete_spam_button'])) {
     70            reschedule_delete_spam();
     71        }
    6172    }
    62   ?> 
    6373 
    64 <?php if ( !empty($_POST ) ) : ?>
    65 <div id="message" class="updated fade">
    66 <strong>Settings updated</strong>
    67 </div>
    68 <?php endif; ?>
    69 
     74    if ( !empty($_POST ) ) : ?>
     75    <div id="message" class="updated fade">
     76    <strong>Settings updated</strong>
     77    </div>
     78    <?php endif; ?>
    7079
    7180    <div class="wrap">
     
    7382   
    7483    <p><?php if (wp_next_scheduled('delete_spam_daily') == NULL)
    75     {   echo "The schedule has not been started."; }
    76         else { ?>
    77         Next Spam Delete: <?php echo date("l, F j, Y @ h:i a",(wp_next_scheduled('delete_spam_daily'))); ?></p>
     84        {   
     85            echo "The schedule has not been started.";
     86        }
     87        else
     88        { ?>
     89            Next Spam Delete: <?php echo date("l, F j, Y @ h:i a",(wp_next_scheduled('delete_spam_daily'))); ?></p>
    7890        <?php
    79     } ?>
     91        } ?>
    8092    <p>Current Spam Count: <?php get_spam_count(); ?></p><br /><br />
    81    
    8293   
    8394    <?php
     
    89100    echo '<div><input id="delete_spam_now_button" type="submit" value="Delete spam now &raquo;" /></div>';
    90101    echo "</form>\n<br />";
    91    
    92102   
    93103    if (wp_next_scheduled('delete_spam_daily') == NULL)
     
    110120        echo '<div><input id="stop_deleting_spam_button" type="submit" value="Stop Deleting Spam &raquo;" /></div>';
    111121        echo "</form>\n";
     122   
     123   
     124        echo '<form name="reschedule_delete_spam_button" action="" method="post">';
     125        if ( function_exists('wp_nonce_field') )
     126        wp_nonce_field('delete_spam_daily');
     127
     128        echo '<input type="hidden" name="reschedule_delete_spam_button" value="update" />';
     129        echo '<div><input id="reschedule_delete_spam_button" type="submit" value="Reschedule to start in 1 minute &raquo;" /> <i>Helpful for testing cron</i></div>';
     130        echo "</form>\n<br />";
     131       
    112132    }
    113 
    114    
    115 
    116    
    117133    ?>
    118        
    119134    <br />
    120135    <br />
    121136    Deactivating this plugin will stop the schedule. <br />
    122    
    123137    </div>
    124 <?php
    125 }
     138
     139    <?php
     140    }
    126141
    127142register_deactivation_hook(__FILE__, 'dsd_stop_schedule');
  • delete-spam-daily/trunk/readme.txt

    r120453 r120599  
    55Requires at least: 2.1.0
    66Tested up to: 2.7.1
    7 Stable tag: 1.0
     7Stable tag: 1.0.1
    88
    99Uses wp_cron to delete comments each day that are marked "spam" in the database.
Note: See TracChangeset for help on using the changeset viewer.