Example #1
0
 public static function schedule()
 {
     $options = red_get_options();
     if ($options['expire_redirect'] > 0 || $options['expire_404'] > 0) {
         if (!wp_next_scheduled(self::DELETE_HOOK)) {
             wp_schedule_event(time(), self::DELETE_FREQ, self::DELETE_HOOK);
         }
     } else {
         Red_Flusher::clear();
     }
 }
 function admin_screen_options()
 {
     if (isset($_POST['regenerate']) && check_admin_referer('redirection-update_options')) {
         $options = red_get_options();
         $options['token'] = md5(uniqid());
         update_option('redirection_options', $options);
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['update']) && check_admin_referer('redirection-update_options')) {
         $options['monitor_post'] = stripslashes($_POST['monitor_post']);
         $options['auto_target'] = stripslashes($_POST['auto_target']);
         $options['support'] = isset($_POST['support']) ? true : false;
         $options['token'] = stripslashes($_POST['token']);
         $options['expire_redirect'] = min(intval($_POST['expire_redirect']), 60);
         $options['expire_404'] = min(intval($_POST['expire_404']), 60);
         if (trim($options['token']) == '') {
             $options['token'] = md5(uniqid());
         }
         update_option('redirection_options', $options);
         Red_Flusher::schedule();
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['delete']) && check_admin_referer('redirection-delete_plugin')) {
         $this->plugin_uninstall();
         $current = get_option('active_plugins');
         array_splice($current, array_search(basename(dirname(REDIRECTION_FILE)) . '/' . basename(REDIRECTION_FILE), $current), 1);
         update_option('active_plugins', $current);
         $this->render_message(__('Redirection data has been deleted and the plugin disabled', 'redirection'));
         return;
     } elseif (isset($_POST['import']) && check_admin_referer('redirection-import')) {
         $count = Red_FileIO::import($_POST['group'], $_FILES['upload']);
         if ($count > 0) {
             $this->render_message(sprintf(_n('%d redirection was successfully imported', '%d redirections were successfully imported', $count, 'redirection'), $count));
         } else {
             $this->render_message(__('No items were imported', 'redirection'));
         }
     }
     $groups = Red_Group::get_for_select();
     $this->render('options', array('options' => red_get_options(), 'groups' => $groups));
 }
Example #3
0
 public function clean_redirection_logs()
 {
     $flusher = new Red_Flusher();
     $flusher->flush();
 }