|
15 | 15 | use Cloudinary\Sync\Push_Sync; |
16 | 16 | use Cloudinary\Sync\Sync_Queue; |
17 | 17 | use Cloudinary\Sync\Upload_Sync; |
| 18 | +use WP_Error; |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * Class Sync |
@@ -298,6 +299,18 @@ public function get_signature( $attachment_id, $cached = true ) { |
298 | 299 | $return = wp_parse_args( $signature, $this->sync_types ); |
299 | 300 | } |
300 | 301 |
|
| 302 | + /** |
| 303 | + * Filter the get signature of the asset. |
| 304 | + * |
| 305 | + * @hook cloudinary_get_signature |
| 306 | + * |
| 307 | + * @param $signature {array} The attachment signature. |
| 308 | + * @param $attachment_id {int} The attachment ID. |
| 309 | + * |
| 310 | + * @return {array} |
| 311 | + */ |
| 312 | + $return = apply_filters( 'cloudinary_get_signature', $signatures[ $attachment_id ], $attachment_id ); |
| 313 | + |
301 | 314 | return $return; |
302 | 315 | } |
303 | 316 |
|
@@ -873,6 +886,23 @@ public function filter_get_cloudinary_folder( $value, $slug ) { |
873 | 886 | return $value; |
874 | 887 | } |
875 | 888 |
|
| 889 | + /** |
| 890 | + * Filter the signature. |
| 891 | + * |
| 892 | + * @param array $signature The signature array. |
| 893 | + * @param int $attachment_id The attachment ID. |
| 894 | + * |
| 895 | + * @return array|bool|string|WP_Error |
| 896 | + */ |
| 897 | + public function get_signature_syncable_type( $signature, $attachment_id ) { |
| 898 | + |
| 899 | + if ( ! $this->is_syncable( $attachment_id ) ) { |
| 900 | + $signature = $this->generate_signature( $attachment_id ); |
| 901 | + } |
| 902 | + |
| 903 | + return $signature; |
| 904 | + } |
| 905 | + |
876 | 906 | /** |
877 | 907 | * Checks if auto sync feature is enabled. |
878 | 908 | * |
@@ -933,6 +963,7 @@ public function setup() { |
933 | 963 | $this->managers['queue']->setup( $this ); |
934 | 964 |
|
935 | 965 | add_filter( 'cloudinary_setting_get_value', array( $this, 'filter_get_cloudinary_folder' ), 10, 2 ); |
| 966 | + add_filter( 'cloudinary_get_signature', array( $this, 'get_signature_syncable_type' ), 10, 2 ); |
936 | 967 | } |
937 | 968 | } |
938 | 969 |
|
|
0 commit comments