mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 10:46:11 +09:00
Update Ultimate Member to version 2.10.2 with filesystem fixes
Introduced `maybe_init_wp_filesystem` for better WP_Filesystem initialization and added new utility methods like `remove_dir`. Improved cache handling and documentation annotations for several methods. These changes enhance file management and ensure smoother integration.
This commit is contained in:
@@ -59,6 +59,13 @@ class Filesystem {
|
||||
$this->temp_upload_url = $this->get_upload_url( 'ultimatemember/temp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Files Age in the temp folder. By default, it's 24 hours.
|
||||
*
|
||||
* @return int Temp file age in seconds.
|
||||
* @since 2.8.7
|
||||
*
|
||||
*/
|
||||
public function files_age() {
|
||||
/**
|
||||
* Filters the maximum file age in the temp folder. By default, it's 24 hours.
|
||||
@@ -73,6 +80,17 @@ class Filesystem {
|
||||
return apply_filters( 'um_filesystem_max_file_age', 24 * HOUR_IN_SECONDS ); // Temp file age in seconds
|
||||
}
|
||||
|
||||
/**
|
||||
* Image MIME Types
|
||||
*
|
||||
* Retrieves a list of image MIME types based on the context.
|
||||
*
|
||||
* @param string $context The context in which the MIME types are needed ('list' or 'allowed').
|
||||
*
|
||||
* @return array List of image MIME types based on the context.
|
||||
*
|
||||
* @since 2.8.7
|
||||
*/
|
||||
public static function image_mimes( $context = 'list' ) {
|
||||
$mimes = array();
|
||||
|
||||
@@ -148,12 +166,7 @@ class Filesystem {
|
||||
public function clear_temp_dir() {
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
$credentials = request_filesystem_credentials( site_url() );
|
||||
WP_Filesystem( $credentials );
|
||||
}
|
||||
self::maybe_init_wp_filesystem();
|
||||
|
||||
if ( ! $wp_filesystem->is_dir( $this->temp_upload_dir ) ) {
|
||||
return;
|
||||
@@ -197,12 +210,7 @@ class Filesystem {
|
||||
// Please add define('FS_METHOD', 'direct'); to avoid question about FTP.
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
$credentials = request_filesystem_credentials( site_url() );
|
||||
WP_Filesystem( $credentials );
|
||||
}
|
||||
self::maybe_init_wp_filesystem();
|
||||
|
||||
if ( ! $blog_id ) {
|
||||
$blog_id = get_current_blog_id();
|
||||
@@ -290,4 +298,46 @@ class Filesystem {
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Probably define global $wp_filesystem.
|
||||
*
|
||||
* @since 2.10.2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function maybe_init_wp_filesystem() {
|
||||
global $wp_filesystem;
|
||||
|
||||
// If you need to fix this issue on the localhost
|
||||
// https://stackoverflow.com/questions/30688431/wordpress-needs-the-ftp-credentials-to-update-plugins
|
||||
// Please add define('FS_METHOD', 'direct'); to avoid question about FTP.
|
||||
if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
$credentials = request_filesystem_credentials( site_url() );
|
||||
WP_Filesystem( $credentials );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a directory using WP Filesystem.
|
||||
*
|
||||
* @param string $dir The directory path to be removed. Should end with DIRECTORY_SEPARATOR.
|
||||
*
|
||||
* @return bool True on success, false on failure or if directory doesn't exist.
|
||||
*
|
||||
* @since 2.10.2
|
||||
*/
|
||||
public static function remove_dir( $dir ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
self::maybe_init_wp_filesystem();
|
||||
|
||||
if ( ! $wp_filesystem->is_dir( $dir ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $wp_filesystem->delete( $dir, true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,8 @@ class Users {
|
||||
/**
|
||||
* Reset User cache
|
||||
*
|
||||
* @since 2.8.7
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
*/
|
||||
public function remove_cache( $user_id ) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: Ultimate Member
|
||||
* Plugin URI: http://ultimatemember.com/
|
||||
* Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
||||
* Version: 2.10.1
|
||||
* Version: 2.10.2
|
||||
* Author: Ultimate Member
|
||||
* Author URI: http://ultimatemember.com/
|
||||
* Text Domain: ultimate-member
|
||||
|
||||
Reference in New Issue
Block a user