PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
jetpack / jetpack_vendor / automattic / jetpack-image-cdn / src / compatibility / activitypub.php

activitypub.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.1, at jetpack_vendor/automattic/jetpack-image-cdn/src/compatibility/activitypub.php

63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compatibility functions for the ActivityPub plugin.
4 *
5 * @since 0.2.2
6 *
7 * @package automattic/jetpack-image-cdn
8 */
9
10 namespace Automattic\Jetpack\Image_CDN\Compatibility;
11
12 use Automattic\Jetpack\Image_CDN\Image_CDN;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit( 0 );
16 }
17
18 /**
19 * Hook the compatibility functions into ActivityPub filters if necessary.
20 *
21 * @since 0.2.2
22 *
23 * @return void
24 */
25 function load_activitypub_compat() {
26 if (
27 /**
28 * Allow disabling Jetpack's image CDN for ActivityPub requests.
29 *
30 * @since 0.2.2
31 *
32 * @param bool $should_disable_photon Should the CDN be disabled for that request. Default to false.
33 */
34 apply_filters( 'jetpack_activitypub_post_disable_cdn', false )
35 ) {
36 add_action( 'activitypub_get_image_pre', __NAMESPACE__ . '\disable_photon' );
37 add_action( 'activitypub_get_image_post', __NAMESPACE__ . '\enable_photon' );
38 }
39 }
40 add_action( 'plugins_loaded', __NAMESPACE__ . '\load_activitypub_compat' );
41
42 /**
43 * Disable Jetpack's Image CDN processing for this request.
44 *
45 * @see https://github.com/pfefferle/wordpress-activitypub/pull/309
46 *
47 * @return void
48 */
49 function disable_photon() {
50 remove_filter( 'image_downsize', array( Image_CDN::instance(), 'filter_image_downsize' ) );
51 }
52
53 /**
54 * Re-enable Jetpack's Image CDN processing after the request.
55 *
56 * @see https://github.com/pfefferle/wordpress-activitypub/pull/309
57 *
58 * @return void
59 */
60 function enable_photon() {
61 add_filter( 'image_downsize', array( Image_CDN::instance(), 'filter_image_downsize' ), 10, 3 );
62 }
63