updated plugin GP Premium
version 2.3.0
This commit is contained in:
@ -107,3 +107,46 @@ function generate_premium_remove_featured_image_class( $classes, $remove_class )
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global $wp_filesystem with credentials set.
|
||||
* Returns null in case of any errors.
|
||||
*
|
||||
* @return WP_Filesystem_Base|null
|
||||
*/
|
||||
function generate_premium_get_wp_filesystem() {
|
||||
global $wp_filesystem;
|
||||
|
||||
$success = true;
|
||||
|
||||
// Initialize the file system if it has not been done yet.
|
||||
if ( ! $wp_filesystem ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
|
||||
$constants = array(
|
||||
'hostname' => 'FTP_HOST',
|
||||
'username' => 'FTP_USER',
|
||||
'password' => 'FTP_PASS',
|
||||
'public_key' => 'FTP_PUBKEY',
|
||||
'private_key' => 'FTP_PRIKEY',
|
||||
);
|
||||
|
||||
$credentials = array();
|
||||
|
||||
// We provide credentials based on wp-config.php constants.
|
||||
// Reference https://developer.wordpress.org/apis/wp-config-php/#wordpress-upgrade-constants.
|
||||
foreach ( $constants as $key => $constant ) {
|
||||
if ( defined( $constant ) ) {
|
||||
$credentials[ $key ] = constant( $constant );
|
||||
}
|
||||
}
|
||||
|
||||
$success = WP_Filesystem( $credentials );
|
||||
}
|
||||
|
||||
if ( ! $success || $wp_filesystem->errors->has_errors() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $wp_filesystem;
|
||||
}
|
||||
|
Reference in New Issue
Block a user