@@ -15,6 +15,10 @@ public static function run(): void
1515
1616 public static function init (): void
1717 {
18+ # Always extract &iframely={serialized options} that we append to URLs
19+ # and add these options into the oEmbed endpoint's query-string parameters
20+ add_filter ('oembed_fetch_url ' , [self ::class, 'maybe_add_iframely_url_options ' ], 20 , 3 );
21+
1822 if (!current_user_can ('edit_posts ' )) {
1923 return ;
2024 }
@@ -58,6 +62,29 @@ public static function maybe_add_gutenberg_1($provider, $url, $args)
5862 return $ provider ;
5963 }
6064
65+ public static function maybe_add_iframely_url_options ($ provider , $ url , $ args )
66+ {
67+ # Options are added to URL the URL in utils.js this way:
68+ # 'iframely=' + encodeURIComponent(window.btoa(JSON.stringify(query)));
69+ if (Utils::stringContains ($ provider , 'iframe.ly ' ) && Utils::stringContains ($ url , 'iframely= ' )) {
70+ $ parsed_url = parse_url ($ url );
71+ if (isset ($ parsed_url ['query ' ])) {
72+ $ params = array ();
73+ parse_str ($ parsed_url ['query ' ], $ params );
74+
75+ if (isset ($ params ['iframely ' ])) {
76+ $ options_str = base64_decode (urldecode ($ params ['iframely ' ]));
77+ $ options_query = json_decode ($ options_str );
78+
79+ foreach ($ options_query as $ key => $ value ) {
80+ $ provider = add_query_arg ($ key , $ value , $ provider );
81+ }
82+ }
83+ }
84+ }
85+ return $ provider ;
86+ }
87+
6188 public static function inject_events_proxy_to_gutenberg ($ html , $ url , $ args )
6289 {
6390 $ html = str_replace ('"//cdn.iframe.ly ' , '"https://cdn.iframe.ly ' , $ html );
0 commit comments