/**
  * An update is required, do it
  *
  * @param $current_version
  */
 private function do_upgrade($current_version)
 {
     // Upgrade to version 1.7.0
     if (version_compare($current_version, '1.7.0', '<')) {
         // Adding new capabilities
         $installer = new DLM_Installer();
         $installer->init_user_roles();
         // Set default 'No access message'
         $dlm_no_access_error = get_option('dlm_no_access_error', '');
         if ('' === $dlm_no_access_error) {
             update_option('dlm_no_access_error', sprintf(__('You do not have permission to access this download. %sGo to homepage%s', 'download-monitor'), '<a href="' . home_url() . '">', '</a>'));
         }
     }
     // Upgrade to version 1.9.0
     if (version_compare($current_version, '1.9.0', '<')) {
         // Adding new capabilities
         $installer = new DLM_Installer();
         $installer->create_no_access_page();
         // setup no access page endpoints
         $no_access_page_endpoint = new DLM_Download_No_Access_Page_Endpoint();
         $no_access_page_endpoint->setup();
         // flush rules after page creation
         flush_rewrite_rules();
     }
 }
/**
 * Run installer for new blogs on multisite when plugin is network activated
 *
 * @param $blog_id
 * @param $user_id
 * @param $domain
 * @param $path
 * @param $site_id
 * @param $meta
 */
function __download_monitor_mu_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
    // check if plugin is network activated
    if (is_plugin_active_for_network('download-monitor/download-monitor.php')) {
        // DLM Installer
        $installer = new DLM_Installer();
        // switch to new blog
        switch_to_blog($blog_id);
        // run installer on blog
        $installer->install();
        // restore current blog
        restore_current_blog();
    }
}
 /**
  * An update is required, do it
  *
  * @param $current_version
  */
 private function do_upgrade($current_version)
 {
     // Upgrade to version 1.7.0
     if (version_compare($current_version, '1.7.0', '<')) {
         // Adding new capabilities
         $installer = new DLM_Installer();
         $installer->init_user_roles();
         // Set default 'No access message'
         $dlm_no_access_error = get_option('dlm_no_access_error', '');
         if ('' === $dlm_no_access_error) {
             update_option('dlm_no_access_error', sprintf(__('You do not have permission to access this download. %sGo to homepage%s', 'download-monitor'), '<a href="' . home_url() . '">', '</a>'));
         }
     }
 }