/** * sets up plugin options and adds some hooks * run by init hook */ public function plugin_init() { //include required files & instantiate classes require_once 'class-sitepush-options.php'; $this->options = SitePushOptions::get_instance(); //add settings to plugin listing page if (!$this->abort) { add_filter('plugin_action_links', array(__CLASS__, 'plugin_links'), 10, 2); } if ($this->options->OK & !$this->abort) { //makes sure correct plugins activated/deactivated for site $this->activate_plugins_for_site(); //clears cache if proper $_GET params set, otherwise does nothing $this->clear_cache(); //override plugin activate/deactivate for plugins we are managing add_filter('plugin_action_links', array(&$this, 'plugin_admin_override'), 10, 2); /* * Content filters - these filters try to catch any instances of URLs for a different site from the one being used, * for example, dev.example.com if you are viewing live.example.com. However, themes, plugins, widgets etc which output HTML * without running it through a filter are hard to catch, so this may not convert all URLs properly. */ if ($this->options->fix_site_urls) { //main post content add_filter('the_content', array(&$this, 'fix_site_urls')); //nav menus add_filter('wp_nav_menu', array(&$this, 'fix_site_urls')); //text widget add_filter('widget_text', array(&$this, 'fix_site_urls')); //catch all - any other URLs which have been run through esc_url or esc_url_raw //includes header image add_filter('clean_url', array(&$this, 'fix_site_urls')); } } //check for debug mode if (SITEPUSH_DEBUG) { SitePushErrors::add_error("Warning: SitePush debug mode is enabled.", 'important'); } //check for SafeMode - SitePush may not work well when safemode is enabled if (ini_get('safe_mode')) { SitePushErrors::add_error("PHP safe mode is enabled. This may prevent SitePush from working properly.", 'options-notice'); } //constant to show if we show multisite features //in future we may allow for not showing multisite features even if running in multisite mode define('SITEPUSH_SHOW_MULTISITE', is_multisite()); }
/** * @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; }