PluginProbe
Embed Privacy / 1.11.2
Embed Privacy v1.11.2
1.14.0 1.13.0 trunk 0.1 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.10 1.10.2 1.10.3 1.10.4 1.10.5 1.10.6 1.10.7 1.10.8 1.10.9 1.11.0 1.11.1 1.11.2 All 68 releases
embed-privacy / inc / handler / class-feed.php

class-feed.php in Embed Privacy 1.11.2, at inc/handler/class-feed.php

55 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace epiphyt\Embed_Privacy\handler;
3
4 /**
5 * Feed handler.
6 *
7 * @author Epiphyt
8 * @license GPL2
9 * @package epiphyt\Embed_Privacy
10 * @since 1.11.2
11 */
12 final class Feed {
13 /**
14 * Initialize functionality.
15 */
16 public static function init() {
17 \add_filter( 'embed_privacy_template_markup', [ self::class, 'replace_template' ], 10, 3 );
18 }
19
20 /**
21 * Replace template in feeds with a link.
22 *
23 * @param string $markup Embed overlay markup
24 * @param \epiphyt\Embed_Privacy\embed\Provider $provider Embed provider
25 * @param array $attributes Embed attributes
26 * @return string Link markup
27 */
28 public static function replace_template( $markup, $provider, $attributes ) {
29 if ( ! \is_feed() ) {
30 return $markup;
31 }
32
33 return self::get_link_markup( $attributes, $provider );
34 }
35
36 /**
37 * Get link markup for the embedded content.
38 *
39 * @param mixed[] $attributes Embed attributes
40 * @param \epiphyt\Embed_Privacy\embed\Provider $provider Embed provider
41 * @return string Link markup
42 */
43 public static function get_link_markup( $attributes, $provider ) {
44 return \sprintf(
45 '<span class="embed-privacy-url"><a href="%1$s">%2$s</a></span>',
46 \esc_url( $attributes['embed_url'] ),
47 \sprintf(
48 /* translators: embed provider title */
49 \esc_html__( 'Open embedded content from %s', 'embed-privacy' ),
50 \esc_html( $provider->get_title() )
51 )
52 );
53 }
54 }
55