| 1 |
<?php |
| 2 |
namespace epiphyt\Embed_Privacy\integration; |
| 3 |
|
| 4 |
/** |
| 5 |
* Instagram Feed integration for Embed Privacy. |
| 6 |
* |
| 7 |
* @author Epiphyt |
| 8 |
* @license GPL2 |
| 9 |
* @package epiphyt\Embed_Privacy |
| 10 |
* @since 1.10.9 |
| 11 |
*/ |
| 12 |
final class Instagram_Feed { |
| 13 |
/** |
| 14 |
* Initialize functionality. |
| 15 |
*/ |
| 16 |
public static function init() { |
| 17 |
\add_filter( 'embed_privacy_should_replace_match', [ self::class, 'should_replace_match' ], 10, 3 ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Check the matched content whether it comes from Instagram Feed. |
| 22 |
* |
| 23 |
* @param bool $should_replace Whether the replacement should take place |
| 24 |
* @param string $matched_content Actual matched content |
| 25 |
* @param \epiphyt\Embed_privacy\embed\Provider $provider Provider object |
| 26 |
* @return bool Whether the replacement should take place |
| 27 |
*/ |
| 28 |
public static function should_replace_match( $should_replace, $matched_content, $provider ) { |
| 29 |
if ( ! $should_replace ) { |
| 30 |
return $should_replace; |
| 31 |
} |
| 32 |
|
| 33 |
if ( $provider->get_name() !== 'instagram' ) { |
| 34 |
return $should_replace; |
| 35 |
} |
| 36 |
|
| 37 |
return ! \str_contains( $matched_content, 'class="sbi_' ); |
| 38 |
} |
| 39 |
} |
| 40 |
|