| 1 |
<?php |
| 2 |
namespace epiphyt\Embed_Privacy\integration; |
| 3 |
|
| 4 |
use epiphyt\Embed_Privacy\data\Replacer; |
| 5 |
use epiphyt\Embed_Privacy\System; |
| 6 |
|
| 7 |
/** |
| 8 |
* wpForo Embeds integration for Embed Privacy. |
| 9 |
* |
| 10 |
* @author Epiphyt |
| 11 |
* @license GPL2 |
| 12 |
* @package epiphyt\Embed_Privacy |
| 13 |
* @since 1.11.0 |
| 14 |
*/ |
| 15 |
final class Wpforo_Embeds { |
| 16 |
/** |
| 17 |
* Initialize functionality. |
| 18 |
*/ |
| 19 |
public static function init() { |
| 20 |
\add_action( 'embed_privacy_print_assets', [ self::class, 'enqueue_assets' ] ); |
| 21 |
\add_action( 'embed_privacy_register_assets', [ self::class, 'register_assets' ], 10, 2 ); |
| 22 |
\add_filter( 'wpforo_content_after', [ self::class, 'replace' ], 10 ); // use _after filter to process data after wpautop() |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Enqueue assets. |
| 27 |
*/ |
| 28 |
public static function enqueue_assets() { |
| 29 |
if ( System::is_plugin_active( 'wpforo-embeds/wpforoembeds.php' ) ) { |
| 30 |
\wp_enqueue_style( 'embed-privacy-wpforo-embeds' ); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Register assets. |
| 36 |
* |
| 37 |
* @param bool $is_debug Whether debug mode is enabled |
| 38 |
* @param string $suffix A filename suffix |
| 39 |
*/ |
| 40 |
public static function register_assets( $is_debug, $suffix ) { |
| 41 |
$css_file_url = \EPI_EMBED_PRIVACY_URL . 'assets/style/wpforo-embeds' . $suffix . '.css'; |
| 42 |
$file_version = $is_debug ? (string) \filemtime( \EPI_EMBED_PRIVACY_BASE . 'assets/style/wpforo-embeds' . $suffix . '.css' ) : \EMBED_PRIVACY_VERSION; |
| 43 |
|
| 44 |
\wp_register_style( 'embed-privacy-wpforo-embeds', $css_file_url, [], $file_version ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Replace activity stream content. |
| 49 |
* |
| 50 |
* @param string $content Current activity stream content |
| 51 |
* @return string Updated activity stream content |
| 52 |
*/ |
| 53 |
public static function replace( $content ) { |
| 54 |
return Replacer::replace_embeds( $content ); |
| 55 |
} |
| 56 |
} |
| 57 |
|