PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 4.2.8
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v4.2.8
4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 All 134 releases
optimole-wp / inc / compatibilities / jetpack.php

jetpack.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 4.2.8, at inc/compatibilities/jetpack.php

67 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_jetpack
5 *
6 * @reason Add support for Jetpack plugin custom endpoints.
7 */
8 class Optml_jetpack extends Optml_compatibility {
9
10 /**
11 * Should we load the integration logic.
12 *
13 * @return bool Should we load.
14 */
15 public function should_load() {
16 include_once ABSPATH . 'wp-admin/includes/plugin.php';
17
18 return is_plugin_active( 'jetpack/jetpack.php' );
19 }
20
21 /**
22 * Register integration details.
23 *
24 * @return void
25 */
26 public function register() {
27 add_filter(
28 'jetpack_sync_before_send_jetpack_published_post',
29 function ( $data ) {
30 if ( ! is_array( $data ) ) {
31 return $data;
32 }
33
34 foreach ( $data as &$value ) {
35 if ( ! $value instanceof \WP_Post ) {
36 continue;
37 }
38
39 if ( ! empty( $value->post_content ) ) {
40 $value->post_content = Optml_Main::instance()->manager->replace_content( $value->post_content );
41 }
42
43 if ( ! empty( $value->post_excerpt ) ) {
44 $value->post_excerpt = Optml_Main::instance()->manager->replace_content( $value->post_excerpt );
45 }
46
47 if ( isset( $value->featured_image ) && ! empty( $value->featured_image ) ) {
48 $value->featured_image = apply_filters( 'optml_content_url', $value->featured_image );
49 }
50 }
51
52 return $data;
53 },
54 10
55 );
56 }
57
58 /**
59 * Should we early load the compatibility?
60 *
61 * @return bool Whether to load the compatibility or not.
62 */
63 public function should_load_early() {
64 return true;
65 }
66 }
67