plugin updates

This commit is contained in:
Tony Volpe
2024-10-11 13:25:50 -04:00
parent 5e5b879a68
commit a6fc17dcaa
391 changed files with 6812 additions and 4326 deletions

View File

@@ -15,7 +15,30 @@ class WpMediaFolder
* @var integer
*/
public $folderRootId = 0;
/**
* Init option configuration variable
*
* @var string
*/
private static $option_google_drive_config = '_wpmfAddon_cloud_config';
/**
* Init option configuration variable
*
* @var string
*/
private static $option_dropbox_config = '_wpmfAddon_dropbox_config';
/**
* Init option configuration variable
*
* @var string
*/
private static $option_one_drive_config = '_wpmfAddon_onedrive_config';
/**
* Init option configuration variable
*
* @var string
*/
private static $option_one_drive_business_config = '_wpmfAddon_onedrive_business_config';
/**
* Check user full access
*
@@ -93,6 +116,7 @@ class WpMediaFolder
add_filter('wp_insert_post_empty_content', array($this, 'disableSave'), 999999, 2);
add_action('pre-upload-ui', array( $this, 'selectFolderUpload'));
add_filter('add_attachment', array($this, 'moveFileUploadToSelectFolder'), 0, 1);
add_action('wp_enqueue_media', array($this, 'removeDatabaseWhenCloudDisconnected'));
}
/**
@@ -5725,7 +5749,7 @@ class WpMediaFolder
*/
public function moveFileUploadToSelectFolder($attachment_id)
{
if (isset($_POST['id_category'])) {
if (isset($_POST['id_category']) && isset($_POST['wpmf_nonce'])) {
if (empty($_POST['wpmf_nonce']) || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) {
die();
}
@@ -5788,4 +5812,43 @@ class WpMediaFolder
}
}
}
/**
* Delete files and folders information in database if cloud was disconnected
*
* @return void
*/
public function removeDatabaseWhenCloudDisconnected()
{
//on Google Drive
$option_cloud_google_drive = get_option(self::$option_google_drive_config);
$folder_google_drive = get_terms(array('name' => 'Google Drive', 'parent' => 0, 'hide_empty' => false, 'taxonomy' => WPMF_TAXO));
if (!is_wp_error($folder_google_drive) && $folder_google_drive && (!isset($option_cloud_google_drive['connected']) || $option_cloud_google_drive['connected'] !== 1)) {
$this->doRemoveFolders($folder_google_drive[0]->term_id);
}
//on Dropbox
$option_cloud_dropbox = get_option(self::$option_dropbox_config);
$folder_dropbox = get_terms(array('name' => 'Dropbox', 'parent' => 0, 'hide_empty' => false, 'taxonomy' => WPMF_TAXO));
if (!is_wp_error($folder_dropbox) && $folder_dropbox && empty($option_cloud_dropbox['dropboxToken'])) {
$this->doRemoveFolders((int)$folder_dropbox[0]->term_id);
}
//on One Drive
$option_cloud_one_drive = get_option(self::$option_one_drive_config);
$folder_one_drive = get_terms(array('name' => 'Onedrive', 'parent' => 0, 'hide_empty' => false, 'taxonomy' => WPMF_TAXO));
if (!is_wp_error($folder_one_drive) && $folder_one_drive && !isset($option_cloud_one_drive['connected'])) {
$this->doRemoveFolders((int)$folder_one_drive[0]->term_id);
}
//on One Drive business
$option_cloud_one_drive_business = get_option(self::$option_one_drive_business_config);
$folder_one_drive_business = get_terms(array('name' => 'Onedrive Business', 'parent' => 0, 'hide_empty' => false, 'taxonomy' => WPMF_TAXO));
if (!is_wp_error($folder_one_drive_business) && $folder_one_drive_business && !isset($option_cloud_one_drive_business['connected'])) {
$this->doRemoveFolders((int)$folder_one_drive_business[0]->term_id);
}
//on Next Cloud
$connect_nextcloud = wpmfGetOption('connect_nextcloud');
$folder_next_cloud = get_terms(array('name' => 'Nextcloud', 'parent' => 0, 'hide_empty' => false, 'taxonomy' => WPMF_TAXO));
if (!is_wp_error($folder_next_cloud) && $folder_next_cloud && empty($connect_nextcloud)) {
$this->doRemoveFolders((int)$folder_next_cloud[0]->term_id);
}
}
}