Ejemplo n.º 1
0
 /**
  * Create a new cron job
  *
  * @param string|bool $file Reference to main plugin file
  * @param array       $args List of args:
  *                          string $action OR callback $callback
  *                          string $schedule OR number $interval
  *                          array $callback_args (optional)
  */
 function __construct($file = false, $args)
 {
     // Set time & schedule
     if (isset($args['time'])) {
         $this->time = $args['time'];
     }
     if (isset($args['interval'])) {
         $this->schedule = $args['interval'] . 'secs';
         $this->interval = $args['interval'];
     } elseif (isset($args['schedule'])) {
         $this->schedule = $args['schedule'];
     }
     // Set hook
     if (isset($args['action'])) {
         $this->hook = $args['action'];
     } elseif (isset($args['callback'])) {
         $this->hook = self::_callback_to_string($args['callback']);
         add_action($this->hook, $args['callback']);
     } elseif (method_exists($this, 'callback')) {
         $this->hook = self::_callback_to_string(array($this, 'callback'));
         add_action($this->hook, $args['callback']);
     } else {
         trigger_error('$action OR $callback not set', E_USER_WARNING);
     }
     if (isset($args['callback_args'])) {
         $this->callback_args = (array) $args['callback_args'];
     }
     if ($file && $this->schedule) {
         scbUtil::add_activation_hook($file, array($this, 'reset'));
         register_deactivation_hook($file, array($this, 'unschedule'));
     }
     add_filter('cron_schedules', array($this, '_add_timing'));
 }
Ejemplo n.º 2
0
 /**
 * Create a new cron job
 *
 * @param string Reference to main plugin file
 * @param array List of args:
 		string $action OR callback $callback
 			string $schedule OR number $interval
 			array $callback_args (optional)
 */
 function __construct($file = false, $args)
 {
     extract($args, EXTR_SKIP);
     // Set time & schedule
     if (isset($time)) {
         $this->time = $time;
     }
     if (isset($interval)) {
         $this->schedule = $interval . 'secs';
         $this->interval = $interval;
     } elseif (isset($schedule)) {
         $this->schedule = $schedule;
     }
     // Set hook
     if (isset($action)) {
         $this->hook = $action;
     } elseif (isset($callback)) {
         $this->hook = self::_callback_to_string($callback);
         add_action($this->hook, $callback);
     } elseif (method_exists($this, 'callback')) {
         $this->hook = self::_callback_to_string(array($this, 'callback'));
         add_action($this->hook, array($this, 'callback'));
     } else {
         trigger_error('$action OR $callback not set', E_USER_WARNING);
     }
     if (isset($callback_args)) {
         $this->callback_args = (array) $callback_args;
     }
     if ($file && $this->schedule) {
         scbUtil::add_activation_hook($file, array($this, 'reset'));
         register_deactivation_hook($file, array($this, 'unschedule'));
     }
     add_filter('cron_schedules', array($this, '_add_timing'));
 }
Ejemplo n.º 3
0
 /**
  * Create a new set of options
  *
  * @param string $key Option name
  * @param string $file Reference to main plugin file
  * @param array $defaults An associative array of default values ( optional )
  */
 public function __construct($key, $file, $defaults = '')
 {
     $this->key = $key;
     $this->defaults = $defaults;
     scbUtil::add_activation_hook($file, array($this, '_update_reset'));
     scbUtil::add_uninstall_hook($file, array($this, 'delete'));
 }
Ejemplo n.º 4
0
 /**
  * Create a new set of options
  *
  * @param string $key Option name
  * @param string $file Reference to main plugin file
  * @param array $defaults An associative array of default values (optional)
  */
 public function __construct($key, $file, $defaults = array())
 {
     $this->key = $key;
     $this->defaults = $defaults;
     if ($file) {
         scbUtil::add_activation_hook($file, array($this, '_activation'));
         scbUtil::add_uninstall_hook($file, array($this, 'delete'));
     }
 }
Ejemplo n.º 5
0
 function __construct($name, $file, $columns, $upgrade_method = 'dbDelta')
 {
     global $wpdb;
     $this->name = $wpdb->{$name} = $wpdb->prefix . $name;
     $this->columns = $columns;
     $this->upgrade_method = $upgrade_method;
     scbUtil::add_activation_hook($file, array($this, 'install'));
     scbUtil::add_uninstall_hook($file, array($this, 'uninstall'));
 }
Ejemplo n.º 6
0
 /**
 * Create a new cron job
 *
 * @param string Reference to main plugin file
 * @param array List of args:
 		string $action OR callback $callback
 			string $schedule OR number $interval
 			array $callback_args ( optional )
 * @param bool Debug mode
 */
 function __construct($file, $args, $debug = false)
 {
     $this->_set_args($args);
     scbUtil::add_activation_hook($file, array($this, 'reset'));
     register_deactivation_hook($file, array($this, 'unschedule'));
     add_filter('cron_schedules', array($this, '_add_timing'));
     if ($debug) {
         self::debug();
     }
 }
Ejemplo n.º 7
0
 /**
  * Sets up table.
  *
  * @param string $name Table name.
  * @param string $file Reference to main plugin file.
  * @param string $columns The SQL columns for the CREATE TABLE statement.
  * @param array $upgrade_method (optional)
  *
  * @return void
  */
 public function __construct($name, $file, $columns, $upgrade_method = 'dbDelta')
 {
     $this->name = $name;
     $this->columns = $columns;
     $this->upgrade_method = $upgrade_method;
     scb_register_table($name);
     if ($file) {
         scbUtil::add_activation_hook($file, array($this, 'install'));
         scbUtil::add_uninstall_hook($file, array($this, 'uninstall'));
     }
 }