Skip to content

Commit

Permalink
Merge pull request #423 from wpCloud/develop-alim
Browse files Browse the repository at this point in the history
v2.3.2
  • Loading branch information
Md. Alimuzzaman Alim authored Dec 12, 2019
2 parents 49521f1 + 20d07d0 commit 43b37bb
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 24 deletions.
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
== Changelog ==
= 2.3.2 =
* FIX - Fixed video file doesn't get deleted from the server in `Stateless` mode. GitHub issue [#418](https://github.com/wpCloud/wp-stateless/issues/418).
* FIX - Fixed file size doesn't show under attachment details in `Stateless` mode. GitHub issue [#413](https://github.com/wpCloud/wp-stateless/issues/413).
* FIX - Fixed Cache-Busting feature works even if the Mode is `Disabled`. GitHub issue [#405](https://github.com/wpCloud/wp-stateless/issues/405).
* COMPATIBILITY - Fixed Gravity Form Post Image didn't include `Bucket Folder`. GitHub issue [#421](https://github.com/wpCloud/wp-stateless/issues/421).
* COMPATIBILITY - Fixed Divi Builder Export. GitHub issue [#420](https://github.com/wpCloud/wp-stateless/issues/420).
* COMPATIBILITY - Fixed BuddyBoss pages breaking after updating to 2.3.0. GitHub issue [#417](https://github.com/wpCloud/wp-stateless/issues/417).

= 2.3.1 =
* Fix - Fixed fatal error, undefined function `is_wp_version_compatible`. GitHub issue [#414](https://github.com/wpCloud/wp-stateless/issues/414).

Expand Down
8 changes: 8 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#### 2.3.2 ####
* FIX - Fixed video file doesn't get deleted from the server in `Stateless` mode. GitHub issue [#418](https://github.com/wpCloud/wp-stateless/issues/418).
* FIX - Fixed file size doesn't show under attachment details in `Stateless` mode. GitHub issue [#413](https://github.com/wpCloud/wp-stateless/issues/413).
* FIX - Fixed Cache-Busting feature works even if the Mode is `Disabled`. GitHub issue [#405](https://github.com/wpCloud/wp-stateless/issues/405).
* COMPATIBILITY - Fixed Gravity Form Post Image didn't include `Bucket Folder`. GitHub issue [#421](https://github.com/wpCloud/wp-stateless/issues/421).
* COMPATIBILITY - Fixed Divi Builder Export. GitHub issue [#420](https://github.com/wpCloud/wp-stateless/issues/420).
* COMPATIBILITY - Fixed BuddyBoss pages breaking after updating to 2.3.0. GitHub issue [#417](https://github.com/wpCloud/wp-stateless/issues/417).

#### 2.3.1 ####
* Fix - Fixed fatal error, undefined function `is_wp_version_compatible`. GitHub issue [#414](https://github.com/wpCloud/wp-stateless/issues/414).

Expand Down
35 changes: 19 additions & 16 deletions lib/classes/class-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class Bootstrap extends \UsabilityDynamics\WP\Bootstrap_Plugin {
* @property $version
* @type {Object}
*/
public static $version = '2.3.1';
public static $version = '2.3.2';

/**
* Singleton Instance Reference.
Expand Down Expand Up @@ -140,13 +140,6 @@ public function init() {
*/
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );

/**
* Hashify file name if option is enabled
*/
if ( $this->get( 'sm.hashify_file_name' ) == 'true' ) {
add_filter('sanitize_file_name', array( 'wpCloud\StatelessMedia\Utility', 'randomize_filename' ), 10);
}

/**
* Delete table when blog is deleted.
*/
Expand All @@ -155,14 +148,6 @@ public function init() {
/* Initialize plugin only if Mode is not 'disabled'. */
if ( $this->get( 'sm.mode' ) !== 'disabled' ) {

/**
* Override Cache Control is option is enabled
*/
$cacheControl = trim($this->get( 'sm.cache_control' ));
if ( !empty($cacheControl) ) {
add_filter( 'sm:item:cacheControl', array( $this, 'override_cache_control' ) );
}

/**
* Determine if we have issues with connection to Google Storage Bucket
* if SM is not disabled.
Expand Down Expand Up @@ -190,6 +175,21 @@ public function init() {
*/
if( !$this->has_errors() ) {

/**
* Hashify file name if option is enabled
*/
if ( $this->get( 'sm.hashify_file_name' ) == 'true' ) {
add_filter('sanitize_file_name', array( 'wpCloud\StatelessMedia\Utility', 'randomize_filename' ), 10);
}

/**
* Override Cache Control is option is enabled
*/
$cacheControl = trim($this->get( 'sm.cache_control' ));
if ( !empty($cacheControl) ) {
add_filter( 'sm:item:cacheControl', array( $this, 'override_cache_control' ) );
}

if( $this->get( 'sm.mode' ) === 'cdn' || $this->get( 'sm.mode' ) === 'stateless' ) {
add_filter( 'wp_get_attachment_image_attributes', array( $this, 'wp_get_attachment_image_attributes' ), 20, 3 );
add_filter( 'wp_get_attachment_url', array( $this, 'wp_get_attachment_url' ), 20, 2 );
Expand Down Expand Up @@ -624,6 +624,9 @@ public function handle_root_dir( $current_path, $use_root = true ) {
$upload_dir = wp_upload_dir();
$current_path = str_replace( wp_normalize_path( trailingslashit( $upload_dir[ 'basedir' ] ) ), '', wp_normalize_path( $current_path ) );
$current_path = str_replace( wp_normalize_path( trailingslashit( $upload_dir[ 'baseurl' ] ) ), '', wp_normalize_path( $current_path ) );
$current_path = str_replace( trailingslashit( $this->get_gs_host() ), '', $current_path );

$current_path = str_replace( trailingslashit( $root_dir ), '', $current_path );

// skip adding root dir if it's already added.
if ( $use_root && !empty( $root_dir ) && strpos($current_path, $root_dir) !== 0 ) {
Expand Down
5 changes: 5 additions & 0 deletions lib/classes/class-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public function __construct(){
*/
new BuddyPress();

/**
* Support for BuddyBoss
*/
new BuddyBoss();

/**
* LiteSpeed Cache
*/
Expand Down
20 changes: 19 additions & 1 deletion lib/classes/class-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ public static function add_media( $metadata, $attachment_id, $force = false, $ar
'sizes' => array(),
));

/**
* Storing file size to sm_cloud first,
* Because assigning directly to $metadata['filesize'] don't work.
* Maybe filesize gets removed in first run (when file exists).
*/
if ( file_exists( $fullsizepath ) ) {
$cloud_meta['filesize'] = filesize( $fullsizepath );
}
// Getting file size from sm_cloud.
if(!empty($cloud_meta['filesize'])){
$metadata['filesize'] = $cloud_meta['filesize'];
}

/**
*
*/
Expand Down Expand Up @@ -576,7 +589,12 @@ public static function can_delete_attachment($attachment_id, $args){
){
// checks whether it's WP 5.3 and 'intermediate_image_sizes_advanced' is passed.
// To be sure that we don't delete full size image before thumbnails are generated.
if(is_wp_version_compatible('5.3-RC4-46673') && !in_array($attachment_id, self::$can_delete_attachment)){
if(
wp_attachment_is_image($attachment_id) &&
function_exists('is_wp_version_compatible') &&
is_wp_version_compatible('5.3-RC4-46673') &&
!in_array($attachment_id, self::$can_delete_attachment)
){
return false;
}
return true;
Expand Down
41 changes: 41 additions & 0 deletions lib/classes/compatibility/buddyboss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Plugin Name: BuddyBoss
* Plugin URI: https://www.buddyboss.com/platform/
*
* Compatibility Description: Ensures compatibility with BuddyBoss.
*
*/

namespace wpCloud\StatelessMedia {

if(!class_exists('wpCloud\StatelessMedia\BuddyBoss')) {

class BuddyBoss extends ICompatibility {
protected $id = 'buddyboss';
protected $title = 'BuddyBoss';
protected $constant = 'WP_STATELESS_COMPATIBILITY_BUDDYBOSS';
protected $description = 'Ensures compatibility with BuddyBoss.';
protected $plugin_file = ['buddyboss-platform/bp-loader.php'];

public function module_init($sm){
add_filter( 'stateless_skip_cache_busting', array($this, 'skip_cache_busting'), 10, 2 );
}

/**
* skip cache busting for template file name.
*/
public function skip_cache_busting($return, $filename){
$info = pathinfo($filename);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8);
if(empty($info['extension']) && strpos($backtrace[6]['file'], '/buddyboss-platform/') !== false){
return $filename;
}
return $return;
}

}

}

}
9 changes: 7 additions & 2 deletions lib/classes/compatibility/divi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ class Divi extends ICompatibility {
protected $theme_name = 'Divi';

public function module_init($sm){
// exclude randomize_filename from wpforms page
if(wp_doing_ajax() && !empty($_POST['et_core_portability_export']) && $_POST['et_core_portability_export'] == 'et_core_portability_export') {
// exclude randomize_filename from export
if(
!empty($_GET['et_core_portability']) ||
wp_doing_ajax() &&
(!empty($_POST['action']) && $_POST['action'] == 'et_core_portability_export') ||
(!empty($_POST['et_core_portability_export']) && $_POST['et_core_portability_export'] == 'et_core_portability_export')
) {
remove_filter( 'sanitize_file_name', array( "wpCloud\StatelessMedia\Utility", 'randomize_filename' ), 10 );
}

Expand Down
2 changes: 1 addition & 1 deletion lib/classes/compatibility/gravity-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function gform_save_field_value( $value, $lead, $field, $form, $input_id
$name = apply_filters( 'wp_stateless_file_name', $name);
do_action( 'sm:sync::syncFile', $name, $absolutePath);

$value = ud_get_stateless_media()->get_gs_host() . '/' . $_name;
$value = ud_get_stateless_media()->get_gs_host() . '/' . $name;
// Todo add filter.
if(version_compare($this->plugin_version, '2.3', '<')){ // older version
$result = $wpdb->update( $lead_detail_table, array( 'value' => $value ), array( 'lead_id' => $lead_detail_id, 'form_id' => $form['id'], 'field_number' => $field['id'], ), array( '%s' ), array( '%d' ) );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wp-stateless",
"title": "WP-Stateless",
"description": "wpCloud Stateless Media for GCE",
"version": "2.3.1",
"version": "2.3.2",
"homepage": "https://usabilitydynamics.com",
"author": {
"name": "UsabilityDynamics, Inc.",
Expand Down
12 changes: 10 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Donate link: https://www.usabilitydynamics.com
Tags: google, google cloud, google cloud storage, cdn, uploads, media, stateless, backup
License: GPLv2 or later
Requires PHP: 5.5
Requires at least: 4.0
Requires at least: 4.7.0
Tested up to: 5.3
Stable tag: 2.3.1
Stable tag: 2.3.2

Upload and serve your WordPress media files from Google Cloud Storage.

Expand Down Expand Up @@ -103,6 +103,14 @@ To ensure new releases cause as little disruption as possible, we rely on a numb
Fixed fatal error, undefined function `is_wp_version_compatible`.

== Changelog ==
= 2.3.2 =
* FIX - Fixed video file doesn't get deleted from the server in `Stateless` mode. GitHub issue [#418](https://github.com/wpCloud/wp-stateless/issues/418).
* FIX - Fixed file size doesn't show under attachment details in `Stateless` mode. GitHub issue [#413](https://github.com/wpCloud/wp-stateless/issues/413).
* FIX - Fixed Cache-Busting feature works even if the Mode is `Disabled`. GitHub issue [#405](https://github.com/wpCloud/wp-stateless/issues/405).
* COMPATIBILITY - Fixed Gravity Form Post Image didn't include `Bucket Folder`. GitHub issue [#421](https://github.com/wpCloud/wp-stateless/issues/421).
* COMPATIBILITY - Fixed Divi Builder Export. GitHub issue [#420](https://github.com/wpCloud/wp-stateless/issues/420).
* COMPATIBILITY - Fixed BuddyBoss pages breaking after updating to 2.3.0. GitHub issue [#417](https://github.com/wpCloud/wp-stateless/issues/417).

= 2.3.1 =
* Fix - Fixed fatal error, undefined function `is_wp_version_compatible`. GitHub issue [#414](https://github.com/wpCloud/wp-stateless/issues/414).

Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'wpCloud\\StatelessMedia\\API' => $baseDir . '/lib/classes/class-api.php',
'wpCloud\\StatelessMedia\\Ajax' => $baseDir . '/lib/classes/class-ajax.php',
'wpCloud\\StatelessMedia\\Bootstrap' => $baseDir . '/lib/classes/class-bootstrap.php',
'wpCloud\\StatelessMedia\\BuddyBoss' => $baseDir . '/lib/classes/compatibility/buddyboss.php',
'wpCloud\\StatelessMedia\\BuddyPress' => $baseDir . '/lib/classes/compatibility/buddypress.php',
'wpCloud\\StatelessMedia\\CompatibilityAcfImageCrop' => $baseDir . '/lib/classes/compatibility/acf-image-crop.php',
'wpCloud\\StatelessMedia\\CompatibilityWooExtraProductOptions' => $baseDir . '/lib/classes/compatibility/woo-extra-product-options.php',
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ComposerStaticInitc00cd3c666f8dfa818cb7edfd488ed20
'wpCloud\\StatelessMedia\\API' => __DIR__ . '/../..' . '/lib/classes/class-api.php',
'wpCloud\\StatelessMedia\\Ajax' => __DIR__ . '/../..' . '/lib/classes/class-ajax.php',
'wpCloud\\StatelessMedia\\Bootstrap' => __DIR__ . '/../..' . '/lib/classes/class-bootstrap.php',
'wpCloud\\StatelessMedia\\BuddyBoss' => __DIR__ . '/../..' . '/lib/classes/compatibility/buddyboss.php',
'wpCloud\\StatelessMedia\\BuddyPress' => __DIR__ . '/../..' . '/lib/classes/compatibility/buddypress.php',
'wpCloud\\StatelessMedia\\CompatibilityAcfImageCrop' => __DIR__ . '/../..' . '/lib/classes/compatibility/acf-image-crop.php',
'wpCloud\\StatelessMedia\\CompatibilityWooExtraProductOptions' => __DIR__ . '/../..' . '/lib/classes/compatibility/woo-extra-product-options.php',
Expand Down
2 changes: 1 addition & 1 deletion wp-stateless-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://www.usabilitydynamics.com
* Description: Upload and serve your WordPress media files from Google Cloud Storage.
* Author: Usability Dynamics, Inc.
* Version: 2.3.1
* Version: 2.3.2
* Text Domain: stateless-media
* Author URI: https://www.usabilitydynamics.com
*
Expand Down

0 comments on commit 43b37bb

Please sign in to comment.