/**
  * Singleton instantiator
  * @static
  * @return SitePushOptions
  */
 public static function get_instance()
 {
     if (!self::$instance instanceof SitePushOptions) {
         self::$instance = new SitePushOptions();
     }
     return self::$instance;
 }
 /**
  * Get all sites which are valid given current capability
  *
  * @param string $context only return sites in this context, source or destination
  * @param string $exclude exclude certain sites. current=exclude current site we are on
  *
  * @return array
  */
 public function get_sites($context = '', $exclude = '')
 {
     $sites_list = array();
     $exclude_current = 'current' == $exclude ? $this->options->get_current_site() : '';
     foreach ($this->options->sites as $site => $site_conf) {
         //exclude current site if required
         if ($site == $exclude_current) {
             continue;
         }
         //if not admin, exclude sites limited to only source/dest context
         if (!$this->can_admin()) {
             if ('destination' == $context && !empty($site_conf['source_only'])) {
                 continue;
             }
             if ('source' == $context && !empty($site_conf['destination_only'])) {
                 continue;
             }
         }
         $sites_list[] = $site;
     }
     return $sites_list;
 }
 /**
  * @var string $source name of push source
  * @var string $dest name of push dest
  */
 function __construct($source, $dest)
 {
     //set PHP script timelimit so push has plenty of time to complete
     set_time_limit($this->push_time_limit);
     $this->options = SitePushOptions::get_instance();
     $this->check_requirements();
     $this->source = $source;
     $this->dest = $dest;
     //WP sets this to UTC somewhere which confuses things...
     if ($this->options->timezone) {
         date_default_timezone_set($this->options->timezone);
     }
     //get params for source and dest
     $this->source_params = $this->options->get_site_params($this->source);
     if (!$this->source_params) {
         SitePushErrors::add_error("Unknown site config '{$this->source}'", 'fatal-error');
         return;
     }
     $this->dest_params = $this->options->get_site_params($this->dest);
     if (!$this->dest_params) {
         SitePushErrors::add_error("Unknown site config '{$this->dest}'", 'fatal-error');
         return;
     }
     //create single timestamp for all backups
     $this->timestamp = date('Ymd-His');
     $this->db_prefix = $this->options->db_prefix;
 }