/**
  * Run the activation script.
  *
  * Run the activation script for the current site if we are on a standard
  * WordPress install or for all sites if we are on WordPress Multisite
  * and the plugin is network activated.
  *
  * @since 1.0.0
  * @param bool $network_wide Boolean value with the network-wide activation status.
  */
 public static function activate($network_wide = false)
 {
     if (is_multisite()) {
         if ($network_wide) {
             // Global variables.
             global $wpdb;
             // Variables.
             $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);
             if ($blogs) {
                 foreach ($blogs as $blog) {
                     switch_to_blog($blog['blog_id']);
                     Autoremove_Attachments_Activator::run_activation_script();
                 }
                 restore_current_blog();
             }
         } else {
             Autoremove_Attachments_Activator::run_activation_script();
         }
     } else {
         Autoremove_Attachments_Activator::run_activation_script();
     }
 }
 /**
  * Run activation script for new sites.
  *
  * If we are running WordPress Multisite and our plugin is network activated,
  * run the activation script every time a new site is created.
  *
  * @since 1.0.0
  * @param int    $blog_id Blog ID of the created blog. Optional.
  * @param int    $user_id User ID of the user creating the blog. Required.
  * @param string $domain  Domain used for the new blog. Optional.
  * @param string $path    Path to the new blog. Optional.
  * @param int    $site_id Site ID. Only relevant on multi-network installs. Optional.
  * @param array  $meta    Meta data. Used to set initial site options. Optional.
  */
 public function maybe_activate($blog_id, $user_id, $domain, $path, $site_id, $meta)
 {
     if ($blog_id) {
         if (is_plugin_active_for_network(plugin_basename(AUTOREMOVE_ATTACHMENTS_MAIN_FILE))) {
             switch_to_blog($blog_id);
             require_once AUTOREMOVE_ATTACHMENTS_DIR_PATH . 'includes/class-autoremove-attachments-activator.php';
             Autoremove_Attachments_Activator::run_activation_script();
             restore_current_blog();
         }
     }
 }
/**
 * Activate Autoremove Attachments.
 *
 * Code that runs during the plugin activation.
 *
 * @since 1.0.0
 * @param bool $network_wide Boolean value with the network-wide activation status.
 */
function activate_autoremove_attachments($network_wide)
{
    require_once AUTOREMOVE_ATTACHMENTS_DIR_PATH . 'includes/class-autoremove-attachments-activator.php';
    Autoremove_Attachments_Activator::activate($network_wide);
}