コード例 #1
0
 public function test_meta_box_save_rejects_invalid_before_or_after_setting()
 {
     $cpt = new CPT();
     WP_Mock::wpFunction('wp_verify_nonce', array('times' => 1, 'args' => array('nonce-value', 'itelic-renewal-reminders-metabox'), 'return' => true));
     WP_Mock::wpFunction('update_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_days', 3), 'return' => true));
     WP_Mock::wpFunction('update_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_boa', 'before'), 'return' => true));
     $cpt->do_save(1, array('itelic_reminder_nonce' => 'nonce-value', 'itelic_reminder' => array('days' => 3, 'boa' => 'garbage')));
 }
コード例 #2
0
 /**
  * Send the notifications.
  *
  * @return Notification[]
  */
 public function get_notifications()
 {
     $reminders = Reminder\CPT::get_reminders();
     if (empty($reminders)) {
         return array();
     }
     $date_to_reminder = array();
     $table = Manager::get('itelic-keys');
     $tn = $table->get_table_name($GLOBALS['wpdb']);
     // retrieve key information and just the date value ( no time ) of when the key expires
     $sql = "SELECT *, Date(`expires`) AS EXP_DAY FROM {$tn} WHERE ";
     // START manual first record
     $sql .= $this->convert_interval_to_between($reminders[0]->get_interval());
     $date_to_reminder[$this->convert_interval_to_date($reminders[0]->get_interval())->format("Y-m-d")] = $reminders[0];
     unset($reminders[0]);
     // END manual first record
     foreach ($reminders as $reminder) {
         $interval = $reminder->get_interval();
         $date = $this->convert_interval_to_date($interval);
         // search for keys that expire any time during the day of the current reminder.
         $sql .= " OR " . $this->convert_datetime_to_between($date);
         // store a reference of that entire day to the reminder object for later use.
         $date_to_reminder[$date->format("Y-m-d")] = $reminder;
     }
     /*
      * SQL generated is similar to:
      * SELECT *, Date(`expires`) AS EXP_DAY FROM wp_itelic_keys WHERE
      * (`expires` BETWEEN '2015-03-08' AND '2015-03-08 23:59:59') OR
      * (`expires` BETWEEN '2017-03-01' AND '2017-03-01 23:59:59')
      */
     $result = $GLOBALS['wpdb']->get_results($sql);
     if (empty($result)) {
         return array();
     }
     $expire_to_key = array();
     foreach ($result as $record) {
         $expire_to_key[$record->EXP_DAY] = itelic_get_key_from_data($record);
     }
     $notifications = array();
     $manager = Factory::make('itelic-renewal-reminder');
     foreach ($expire_to_key as $expire => $key) {
         $notification = $this->make_notification($date_to_reminder[$expire], $key, $manager);
         if ($notification) {
             $notifications[] = $notification;
         }
     }
     return $notifications;
 }
コード例 #3
0
/**
 * Load the renewal reminders scripts.
 *
 * @author    Iron Bound Designs
 * @since     1.0
 * @license   AGPL
 * @copyright Iron Bound Designs, 2015.
 */
namespace ITELIC\Renewal\Reminder;

use ITELIC\Key;
use IronBound\WP_Notifications\Template\Listener;
use IronBound\WP_Notifications\Template\Manager;
use ITELIC\Renewal\Discount;
$cpt = new CPT();
$cpt->add_hooks();
new Sender();
/**
 * Register listeners for renewal reminders.
 *
 * @since 1.0
 *
 * @param Manager $manager
 */
function register_listeners(Manager $manager)
{
    $shared = \ITELIC\get_shared_tags();
    foreach ($shared as $listener) {
        $manager->listen($listener);
    }