Exemplo n.º 1
0
 static function OnActivateOrVerChange($old_ver = null)
 {
     global $wpdb;
     // make sure that either wp-filebase or wp-filebase pro is enabled bot not both!
     if (!function_exists('is_plugin_active')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     if (is_plugin_active('wp-filebase-pro/wp-filebase.php')) {
         deactivate_plugins('wp-filebase/wp-filebase.php');
     }
     wpfb_loadclass('Admin', 'File', 'Category');
     self::SetupDBTables($old_ver);
     $old_options = get_option(WPFB_OPT_NAME);
     self::AddOptions();
     self::AddTpls($old_ver);
     $new_options = get_option(WPFB_OPT_NAME);
     WPFB_Admin::SettingsUpdated($old_options, $new_options);
     self::ProtectUploadPath();
     $sync_data_file = WPFB_Core::UploadDir() . '/._sync.data';
     is_file($sync_data_file) && unlink($sync_data_file);
     WPFB_Admin::WPCacheRejectUri(WPFB_Core::$settings->download_base . '/', $old_options['download_base'] . '/');
     // TODO, do this in background
     if (WPFB_Category::GetNumCats() < self::MANY_CATEGORIES && WPFB_File::GetNumFiles() < self::MANY_FILES) {
         // avoid long activation time
         wpfb_loadclass('Sync');
         WPFB_Sync::SyncCats();
         WPFB_Sync::UpdateItemsPath();
     }
     if (!wp_next_scheduled(WPFB . '_cron')) {
         wp_schedule_event(time() + 20, 'hourly', WPFB . '_cron');
     }
     if (!get_option('wpfb_install_time')) {
         add_option('wpfb_install_time', ($ft = (int) mysql2date('U', $wpdb->get_var("SELECT file_mtime FROM {$wpdb->wpfilebase_files} ORDER BY file_mtime ASC LIMIT 1"))) > 0 ? $ft : time(), null, 'no');
     }
     $wp_upload = wp_upload_dir();
     // move old css
     if (file_exists(WPFB_Core::GetOldCustomCssPath())) {
         $wp_upload_ok = empty($wp_upload['error']) && is_writable($wp_upload['basedir']);
         if ($wp_upload_ok && @rename(WPFB_Core::GetOldCustomCssPath(), $wp_upload['basedir'] . '/wp-filebase.css')) {
             update_option('wpfb_css', $wp_upload['baseurl'] . '/wp-filebase.css?t=' . time());
         }
     }
     // refresh css URL (in case upload_dir changed or upgrade from free to pro)
     update_option('wpfb_css', trailingslashit(file_exists($wp_upload['basedir'] . '/wp-filebase.css') ? $wp_upload['baseurl'] : WPFB_PLUGIN_URI) . 'wp-filebase.css?t=' . time());
     flush_rewrite_rules();
     // change mapping of file browser folder icons (2340897_sdf.svg => svg-.....svg!)
     $image_mappings = array('1449888880_folder.svg' => 'svg-folder.svg', '1449888883_folder.svg' => 'svg-folder-blue.svg', '1449888885_folder-blue.svg' => 'svg-folderblue.svg', '1449888886_folder-green.svg' => 'svg-folder-green.svg');
     $folder_icons_base = '/plugins/wp-filebase/images/folder-icons/';
     $folder_icon = substr(WPFB_Core::$settings->folder_icon, strlen($folder_icons_base));
     if (isset($image_mappings[$folder_icon])) {
         WPFB_Core::UpdateOption('folder_icon', $folder_icons_base . $image_mappings[$folder_icon]);
     }
     //delete_option('wpfilebase_dismiss_support_ending');
     // fixes files that where offline
     if ($old_ver === "3.4.2") {
         $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_offline = '0' WHERE 1");
         wpfb_loadclass('Sync');
         WPFB_Sync::list_files(WPFB_Core::UploadDir());
     }
 }
Exemplo n.º 2
0
 static function OnActivateOrVerChange($old_ver = null)
 {
     global $wpdb;
     // make sure that either wp-filebase or wp-filebase pro is enabled bot not both!
     if (!function_exists('is_plugin_active')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     if (is_plugin_active('wp-filebase-pro/wp-filebase.php')) {
         deactivate_plugins('wp-filebase/wp-filebase.php');
     }
     wpfb_loadclass('Admin', 'File', 'Category');
     self::SetupDBTables($old_ver);
     $old_options = get_option(WPFB_OPT_NAME);
     self::AddOptions();
     self::AddTpls($old_ver);
     $new_options = get_option(WPFB_OPT_NAME);
     WPFB_Admin::SettingsUpdated($old_options, $new_options);
     self::ProtectUploadPath();
     WPFB_Admin::WPCacheRejectUri(WPFB_Core::$settings->download_base . '/', $old_options['download_base'] . '/');
     $ncats = WPFB_Category::GetNumCats();
     $nfiles = WPFB_File::GetNumFiles();
     if ($ncats < self::MANY_CATEGORIES && $nfiles < self::MANY_FILES) {
         // avoid long activation time
         wpfb_loadclass('Sync');
         WPFB_Sync::SyncCats();
         WPFB_Sync::UpdateItemsPath();
     }
     if (!wp_next_scheduled(WPFB . '_cron')) {
         wp_schedule_event(time(), 'hourly', WPFB . '_cron');
     }
     if (!get_option('wpfb_install_time')) {
         add_option('wpfb_install_time', ($ft = (int) mysql2date('U', $wpdb->get_var("SELECT file_mtime FROM {$wpdb->wpfilebase_files} ORDER BY file_mtime ASC LIMIT 1"))) > 0 ? $ft : time(), null, 'no');
     }
     // move old css
     if (file_exists(WPFB_Core::GetOldCustomCssPath())) {
         $wp_upload = wp_upload_dir();
         $wp_upload_ok = empty($wp_upload['error']) && is_writable($wp_upload['basedir']);
         if ($wp_upload_ok && @rename(WPFB_Core::GetOldCustomCssPath(), $wp_upload['basedir'] . '/wp-filebase.css')) {
             update_option('wpfb_css', $wp_upload['baseurl'] . '/wp-filebase.css?t=' . time());
         }
     }
     flush_rewrite_rules();
     //delete_option('wpfilebase_dismiss_support_ending');
 }