PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / integrations / imagify / push-cdn.php

push-cdn.php in Media Cloud Sync 1.4.1, at includes/integrations/imagify/push-cdn.php

84 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Dudlewebs\WPMCS;
3
4 defined( 'ABSPATH' ) || exit;
5
6 /**
7 * Imagify Push CDN adapter for offloaded media.
8 *
9 * Implements Imagify's PushCDNInterface the same way an official offload-plugin integration does.
10 * Loaded by the autoloader when `register_cdn()` runs for an offloaded attachment.
11 *
12 * @since 1.3.12
13 */
14 if ( ! interface_exists( '\Imagify\CDN\PushCDNInterface' ) ) {
15 return;
16 }
17
18 class ImagifyPushCDN implements \Imagify\CDN\PushCDNInterface {
19 /**
20 * Attachment ID.
21 *
22 * @var int
23 */
24 protected $id;
25
26 /**
27 * Constructor.
28 *
29 * @param int $media_id Attachment ID.
30 */
31 public function __construct( $media_id ) {
32 $this->id = (int) $media_id;
33 }
34
35 /**
36 * @inheritDoc
37 */
38 public function is_ready() {
39 return Utils::is_service_enabled();
40 }
41
42 /**
43 * @inheritDoc
44 */
45 public function media_is_on_cdn() {
46 return Imagify::instance()->media_is_on_provider( $this->id );
47 }
48
49 /**
50 * @inheritDoc
51 */
52 public function get_files_from_cdn( $file_paths ) {
53 return Imagify::instance()->copy_files_from_cdn( $this->id, $file_paths );
54 }
55
56 /**
57 * @inheritDoc
58 */
59 public function remove_files_from_cdn( $file_paths ) {
60 return Imagify::instance()->remove_files_from_cdn( $this->id, $file_paths );
61 }
62
63 /**
64 * @inheritDoc
65 */
66 public function send_to_cdn( $is_new_upload ) {
67 return Imagify::instance()->send_attachment_to_cdn( $this->id, $is_new_upload );
68 }
69
70 /**
71 * @inheritDoc
72 */
73 public function get_file_url( $file_name = '' ) {
74 return Imagify::instance()->get_provider_file_url( $this->id, $file_name );
75 }
76
77 /**
78 * @inheritDoc
79 */
80 public function get_file_path( $file_name = '' ) {
81 return Imagify::instance()->get_local_file_path( $this->id, $file_name );
82 }
83 }
84