PluginProbe
Embed Privacy / 1.10.7
Embed Privacy v1.10.7
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 / class-migration.php

class-migration.php in Embed Privacy 1.10.7, at inc/class-migration.php

1,326 lines 43.9 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;
3
4 use epiphyt\Embed_Privacy\thumbnail\Thumbnail;
5 use FilesystemIterator;
6 use WP_Post;
7
8 /**
9 * Migration class to update data in the database on upgrades.
10 *
11 * @since 1.2.0
12 *
13 * @author Epiphyt
14 * @license GPL2
15 * @package epiphyt\Embed_Privacy
16 */
17 class Migration {
18 /**
19 * @var \epiphyt\Embed_Privacy\Migration
20 */
21 private static $instance;
22
23 /**
24 * @var array Default embed providers
25 */
26 private $providers = [];
27
28 /**
29 * @var string Current migration version
30 * @since 1.2.2
31 */
32 private $version = '1.10.7';
33
34 /**
35 * Migration constructor.
36 */
37 public function __construct() {
38 self::$instance = $this;
39 }
40
41 /**
42 * Initialize functions.
43 */
44 public function init() {
45 // since upgrader_process_complete hook runs the old plugin code,
46 // it is useless for real migrations, unfortunately
47 // thus, we need to check on every page load in the admin if there are
48 // new migrations
49 \add_action( 'admin_init', [ $this, 'migrate' ], 10, 0 );
50 \add_action( 'admin_notices', [ $this, 'register_migration_failed_notice' ] );
51 }
52
53 /**
54 * Add an embed provider post.
55 *
56 * @param array $embed Embed provider information
57 */
58 private function add_embed( array $embed ) {
59 // since meta_input doesn't work on every multisite (I don't know why)
60 // extract metadata and use add_post_meta() afterwards
61 // see: https://github.com/epiphyt/embed-privacy/issues/14
62 if ( ! empty( $embed['meta_input'] ) ) {
63 $meta_data = $embed['meta_input'];
64 unset( $embed['meta_input'] );
65 }
66
67 $post_id = \wp_insert_post( $embed );
68
69 // add meta data
70 if ( \is_int( $post_id ) && isset( $meta_data ) ) {
71 foreach ( $meta_data as $meta_key => $meta_value ) {
72 \add_post_meta( $post_id, $meta_key, $meta_value );
73 }
74 }
75 }
76
77 /**
78 * Create thumbnails directory.
79 *
80 * @since 1.5.0
81 */
82 private function create_thumbnails_dir() {
83 $directory = Thumbnail::get_directory();
84
85 if ( empty( $directory['base_dir'] ) ) {
86 return;
87 }
88
89 if ( \file_exists( $directory['base_dir'] ) && ! \is_dir( $directory['base_dir'] ) ) {
90 return;
91 }
92
93 if ( ! \is_dir( $directory['base_dir'] ) ) {
94 \wp_mkdir_p( $directory['base_dir'] );
95 }
96 }
97
98 /**
99 * Delete an option either from the global multisite settings or the regular site.
100 *
101 * @param string $option The option name
102 * @return bool True if the option was deleted, false otherwise
103 */
104 private function delete_option( $option ) {
105 return \delete_option( 'embed_privacy_' . $option );
106 }
107
108 /**
109 * Get a unique instance of the class.
110 *
111 * @return \epiphyt\Embed_Privacy\Migration The single instance of this class
112 */
113 public static function get_instance() {
114 if ( self::$instance === null ) {
115 self::$instance = new self();
116 }
117
118 return self::$instance;
119 }
120
121 /**
122 * Get an option either from the global multisite settings or the regular site.
123 *
124 * @param string $option The option name
125 * @param mixed $default_value The default value if the option is not set
126 * @return mixed Value set for the option
127 */
128 private function get_option( $option, $default_value = false ) {
129 return \get_option( 'embed_privacy_' . $option, $default_value );
130 }
131
132 /**
133 * Run migrations.
134 *
135 * @param null $deprecated Deprecated, has no function anymore
136 * @param null $deprecated2 Deprecated, has no function anymore
137 */
138 public function migrate( $deprecated = null, $deprecated2 = null ) {
139 if ( $deprecated !== null ) {
140 \_doing_it_wrong(
141 __METHOD__,
142 \sprintf(
143 /* translators: parameter */
144 \esc_html__( 'The function does not support the parameter "%s" anymore.', 'embed-privacy' ),
145 '$plugin'
146 ),
147 '1.4.0'
148 );
149 }
150
151 if ( $deprecated2 !== null ) {
152 \_doing_it_wrong(
153 __METHOD__,
154 \sprintf(
155 /* translators: parameter */
156 \esc_html__( 'The function does not support the parameter "%s" anymore.', 'embed-privacy' ),
157 '$network_wide'
158 ),
159 '1.4.0'
160 );
161 }
162
163 if ( \wp_doing_ajax() ) {
164 return;
165 }
166
167 // check for active migration
168 if (
169 \is_numeric( $this->get_option( 'is_migrating' ) )
170 && $this->get_option( 'is_migrating' ) !== '1' // possible legacy value
171 && (int) $this->get_option( 'is_migrating' ) > \time() - \MINUTE_IN_SECONDS
172 ) {
173 return;
174 }
175
176 $version = $this->get_option( 'migrate_version', 'initial' );
177
178 // get legacy network option
179 if ( $version === 'initial' && \is_multisite() ) {
180 $version = \get_site_option( 'embed_privacy_migrate_version', 'initial' );
181 }
182
183 if ( $version === $this->version ) {
184 return;
185 }
186
187 // start the migration
188 $this->update_option( 'is_migrating', \time() );
189 $this->update_option( 'migration_count', (int) $this->get_option( 'migration_count' ) + 1 );
190 // load textdomain early for migrations
191 \load_plugin_textdomain( 'embed-privacy', false, \dirname( \plugin_basename( Embed_Privacy::get_instance()->plugin_file ) ) . '/languages' );
192 // make sure all default embed providers are available and translated
193 $this->register_default_embed_providers();
194
195 switch ( $version ) {
196 case $this->version:
197 // most recent version, do nothing
198 break;
199 case '1.10.6':
200 $this->migrate_1_10_7();
201 case '1.10.5':
202 $this->migrate_1_10_7();
203 $this->migrate_1_10_6();
204 break;
205 case '1.8.0':
206 $this->migrate_1_10_7();
207 $this->migrate_1_10_6();
208 $this->migrate_1_10_5();
209 break;
210 case '1.7.3':
211 $this->migrate_1_10_7();
212 $this->migrate_1_10_6();
213 $this->migrate_1_10_5();
214 $this->migrate_1_8_0();
215 break;
216 case '1.7.0':
217 $this->migrate_1_10_7();
218 $this->migrate_1_10_6();
219 $this->migrate_1_10_5();
220 $this->migrate_1_8_0();
221 $this->migrate_1_7_3();
222 break;
223 case '1.6.0':
224 $this->migrate_1_10_7();
225 $this->migrate_1_10_6();
226 $this->migrate_1_10_5();
227 $this->migrate_1_8_0();
228 $this->migrate_1_7_3();
229 $this->migrate_1_7_0();
230 break;
231 case '1.5.0':
232 $this->migrate_1_10_7();
233 $this->migrate_1_10_6();
234 $this->migrate_1_10_5();
235 $this->migrate_1_8_0();
236 $this->migrate_1_7_3();
237 $this->migrate_1_7_0();
238 $this->migrate_1_6_0();
239 break;
240 case '1.4.7':
241 $this->migrate_1_10_7();
242 $this->migrate_1_10_6();
243 $this->migrate_1_10_5();
244 $this->migrate_1_8_0();
245 $this->migrate_1_7_0();
246 $this->migrate_1_6_0();
247 $this->migrate_1_5_0();
248 break;
249 case '1.4.0':
250 $this->migrate_1_10_7();
251 $this->migrate_1_10_6();
252 $this->migrate_1_10_5();
253 $this->migrate_1_8_0();
254 $this->migrate_1_7_0();
255 $this->migrate_1_6_0();
256 $this->migrate_1_5_0();
257 $this->migrate_1_4_7();
258 break;
259 case '1.3.0':
260 $this->migrate_1_10_7();
261 $this->migrate_1_10_6();
262 $this->migrate_1_10_5();
263 $this->migrate_1_8_0();
264 $this->migrate_1_7_0();
265 $this->migrate_1_6_0();
266 $this->migrate_1_5_0();
267 $this->migrate_1_4_0();
268 break;
269 case '1.2.2':
270 $this->migrate_1_10_7();
271 $this->migrate_1_10_6();
272 $this->migrate_1_10_5();
273 $this->migrate_1_8_0();
274 $this->migrate_1_7_0();
275 $this->migrate_1_6_0();
276 $this->migrate_1_5_0();
277 $this->migrate_1_4_0();
278 $this->migrate_1_3_0();
279 break;
280 case '1.2.1':
281 $this->migrate_1_10_7();
282 $this->migrate_1_10_6();
283 $this->migrate_1_10_5();
284 $this->migrate_1_8_0();
285 $this->migrate_1_7_0();
286 $this->migrate_1_6_0();
287 $this->migrate_1_5_0();
288 $this->migrate_1_4_0();
289 $this->migrate_1_3_0();
290 $this->migrate_1_2_2();
291 break;
292 case '1.2.0':
293 $this->migrate_1_10_7();
294 $this->migrate_1_10_6();
295 $this->migrate_1_10_5();
296 $this->migrate_1_8_0();
297 $this->migrate_1_7_0();
298 $this->migrate_1_6_0();
299 $this->migrate_1_5_0();
300 $this->migrate_1_4_0();
301 $this->migrate_1_3_0();
302 $this->migrate_1_2_2();
303 $this->migrate_1_2_1();
304 break;
305 default:
306 // run all migrations
307 $this->migrate_1_2_0();
308 break;
309 }
310
311 // migration done
312 $this->update_option( 'migrate_version', $this->version );
313 $this->delete_option( 'is_migrating' );
314 $this->delete_option( 'migration_count' );
315 }
316
317 /**
318 * Migrations for version 1.2.0.
319 *
320 * @since 1.2.0
321 * @since 1.5.0 Create thumbnails directory
322 *
323 * - Add default embed providers
324 * - Add thumbnails directory
325 */
326 private function migrate_1_2_0() {
327 // add embeds
328 foreach ( $this->providers as $embed ) {
329 $this->add_embed( $embed );
330 }
331
332 $this->create_thumbnails_dir();
333 }
334
335 /**
336 * Migrations for version 1.2.1.
337 *
338 * @since 1.2.1
339 *
340 * - Add missing meta data
341 */
342 private function migrate_1_2_1() {
343 global $wp_filesystem;
344
345 // initialize the WP filesystem if not exists
346 if ( empty( $wp_filesystem ) ) {
347 require_once \ABSPATH . 'wp-admin/includes/file.php';
348 \WP_Filesystem();
349 }
350
351 $available_providers = \get_posts( [
352 'no_found_rows' => true,
353 'numberposts' => -1,
354 'post_type' => 'epi_embed',
355 'update_post_term_cache' => false,
356 ] );
357
358 foreach ( $available_providers as $provider ) {
359 // get according default provider
360 $key = \array_search( $provider->post_title, \array_column( $this->providers, 'post_title' ), true );
361
362 // if no default provider, continue with next available provider
363 if ( $key === false ) {
364 continue;
365 }
366
367 // update default meta data, if missing
368 foreach ( [ 'is_system', 'privacy_policy_url', 'regex_default' ] as $meta_key ) {
369 if ( ! \get_post_meta( $provider->ID, $meta_key, true ) ) {
370 \update_post_meta( $provider->ID, $meta_key, $this->providers[ $key ]['meta_input'][ $meta_key ] );
371 }
372 }
373 }
374 }
375
376 /**
377 * Migrations for version 1.2.2.
378 *
379 * @since 1.2.2
380 *
381 * - Update regex for Amazon Kindle
382 */
383 private function migrate_1_2_2() {
384 $amazon_provider = \get_posts( [
385 'meta_key' => 'is_system',
386 'meta_value' => 'yes',
387 'name' => 'amazon-kindle',
388 'no_found_rows' => true,
389 'post_type' => 'epi_embed',
390 'update_post_term_cache' => false,
391 ] );
392
393 if ( ! empty( $amazon_provider ) ) {
394 $amazon_provider = \reset( $amazon_provider );
395 }
396
397 if ( ! $amazon_provider instanceof WP_Post ) {
398 return;
399 }
400
401 \update_post_meta( $amazon_provider->ID, 'regex_default', '/\\\.?(ama?zo?n\\\.|a\\\.co\\\/|z\\\.cn\\\/)/' );
402 }
403
404 /**
405 * Migrations for version 1.3.0.
406 *
407 * @since 1.3.0
408 *
409 * - Delete post thumbnails
410 * - Update regex for Google Maps
411 */
412 private function migrate_1_3_0() {
413 $providers = Embed_Privacy::get_instance()->get_embeds( 'oembed' );
414 $google_provider = \get_posts( [
415 'meta_key' => 'is_system',
416 'meta_value' => 'yes',
417 'name' => 'google-maps',
418 'no_found_rows' => true,
419 'post_type' => 'epi_embed',
420 'update_post_term_cache' => false,
421 ] );
422 $providers = \array_merge( $providers, $google_provider );
423
424 foreach ( $providers as $provider ) {
425 if ( ! $provider instanceof WP_Post ) {
426 continue;
427 }
428
429 // delete post thumbnails
430 // see https://github.com/epiphyt/embed-privacy/issues/32
431 $thumbnail_id = \get_post_thumbnail_id( $provider->ID );
432
433 if ( $thumbnail_id ) {
434 \delete_post_thumbnail( $provider );
435 \wp_delete_attachment( $thumbnail_id, true );
436 }
437
438 // make regex ungreedy
439 // see https://github.com/epiphyt/embed-privacy/issues/31
440 if ( $provider->post_name === 'google-maps' ) {
441 \update_post_meta( $provider->ID, 'regex_default', '/google\\\.com\\\/maps\\\/embed/' );
442 }
443 }
444 }
445
446 /**
447 * Migrations for version 1.4.0.
448 *
449 * @since 1.4.0
450 *
451 * - Replace duplicate embed providers
452 * - Add missing default embed providers (this also adds new Wolfram Cloud)
453 */
454 private function migrate_1_4_0() {
455 $providers = Embed_Privacy::get_instance()->get_embeds();
456 $missing_providers = $this->providers;
457 $processed_providers = [];
458
459 foreach ( $providers as $provider ) {
460 if ( ! $provider instanceof WP_Post ) {
461 continue;
462 }
463
464 // check only system providers
465 if ( \get_post_meta( $provider->ID, 'is_system', true ) !== 'yes' ) {
466 continue;
467 }
468
469 // since post name differs, use post title to get duplicates
470 if ( \in_array( $provider->post_title, $processed_providers, true ) ) {
471 // delete duplicate providers
472 \wp_delete_post( $provider->ID, true );
473 }
474 else {
475 $processed_providers[] = $provider->post_title;
476 }
477
478 $key = false;
479
480 // delete provider from list of missing providers if it already exists
481 foreach ( $missing_providers as $provider_key => $missing_provider ) {
482 if ( $provider->post_title === $missing_provider['post_title'] ) {
483 $key = $provider_key;
484 break;
485 }
486 }
487
488 if ( $key !== false ) {
489 unset( $missing_providers[ $key ] );
490 }
491 }
492
493 // add missing default providers
494 foreach ( $missing_providers as $missing_provider ) {
495 $this->add_embed( $missing_provider );
496 }
497 }
498
499 /**
500 * Migrations for version 1.4.7.
501 *
502 * @see https://github.com/epiphyt/embed-privacy/issues/120
503 * @since 1.4.7
504 *
505 * - Update regex for Google Maps
506 */
507 private function migrate_1_4_7() {
508 $google_provider = \get_posts( [
509 'meta_key' => 'is_system',
510 'meta_value' => 'yes',
511 'name' => 'google-maps',
512 'no_found_rows' => true,
513 'post_type' => 'epi_embed',
514 'update_post_term_cache' => false,
515 ] );
516 $google_provider = \reset( $google_provider );
517
518 \update_post_meta( $google_provider->ID, 'regex_default', '/google\\\.com\\\/maps\\\/(d\\\/)?embed/' );
519 }
520
521 /**
522 * Migrations for version 1.5.0.
523 *
524 * @see https://github.com/epiphyt/embed-privacy/issues/124
525 * @since 1.5.0
526 *
527 * - Add new embed provider Pocket Casts
528 * - Add new embed provider Maps Marker
529 * - Add thumbnails directory
530 * - Update Google Maps regex
531 */
532 private function migrate_1_5_0() {
533 $this->add_embed( [
534 'meta_input' => [
535 'is_system' => 'yes',
536 'privacy_policy_url' => \__( 'https://support.pocketcasts.com/article/privacy-policy/', 'embed-privacy' ),
537 'regex_default' => '/pca\\\.st/',
538 ],
539 /* translators: embed provider */
540 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Pocket Casts', 'embed provider', 'embed-privacy' ) ),
541 'post_status' => 'publish',
542 'post_title' => \_x( 'Pocket Casts', 'embed provider', 'embed-privacy' ),
543 'post_type' => 'epi_embed',
544 ] );
545 $this->add_embed( [
546 'meta_input' => [
547 'is_system' => 'yes',
548 'privacy_policy_url' => '',
549 'regex_default' => '',
550 ],
551 /* translators: embed provider */
552 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
553 'post_status' => 'publish',
554 'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
555 'post_type' => 'epi_embed',
556 ] );
557 $this->create_thumbnails_dir();
558
559 $google_provider = \get_posts( [
560 'meta_key' => 'is_system',
561 'meta_value' => 'yes',
562 'name' => 'google-maps',
563 'no_found_rows' => true,
564 'post_type' => 'epi_embed',
565 'update_post_term_cache' => false,
566 ] );
567 $google_provider = \reset( $google_provider );
568
569 if ( $google_provider instanceof WP_Post ) {
570 \update_post_meta( $google_provider->ID, 'regex_default', '/(google\\\.com\\\/maps\\\/embed|maps\\\.google\\\.com\\\/(maps)?)/' );
571 }
572 }
573
574 /**
575 * Migrations for version 1.6.0.
576 *
577 * @see https://github.com/epiphyt/embed-privacy/issues/124
578 * @since 1.6.0
579 *
580 * - Update Google Maps regex
581 */
582 private function migrate_1_6_0() {
583 $google_provider = \get_posts( [
584 'meta_key' => 'is_system',
585 'meta_value' => 'yes',
586 'name' => 'google-maps',
587 'no_found_rows' => true,
588 'post_type' => 'epi_embed',
589 'update_post_term_cache' => false,
590 ] );
591 $google_provider = \reset( $google_provider );
592
593 if ( $google_provider instanceof WP_Post ) {
594 \update_post_meta( $google_provider->ID, 'regex_default', '/(google\\\.com\\\/maps\\\/embed|maps\\\.google\\\.com\\\/(maps)?)/' );
595 }
596 }
597
598 /**
599 * Migrations for version 1.7.0.
600 *
601 * @see https://github.com/epiphyt/embed-privacy/issues/163
602 * @since 1.7.0
603 *
604 * - Update CrowdSignal regex
605 */
606 private function migrate_1_7_0() {
607 $crowdsignal_provider = \get_posts( [
608 'meta_key' => 'is_system',
609 'meta_value' => 'yes',
610 'name' => 'crowdsignal',
611 'no_found_rows' => true,
612 'post_type' => 'epi_embed',
613 'update_post_term_cache' => false,
614 ] );
615 $crowdsignal_provider = \reset( $crowdsignal_provider );
616
617 if ( $crowdsignal_provider instanceof WP_Post ) {
618 \update_post_meta( $crowdsignal_provider->ID, 'regex_default', '/((poll(\\\.fm|daddy\\\.com))|crowdsignal\\\.(com|net)|survey\\\.fm)/' );
619 }
620 }
621
622 /**
623 * Migrations for version 1.7.3.
624 *
625 * @since 1.7.3
626 *
627 * - Copy thumbnails to different directory
628 */
629 private function migrate_1_7_3() {
630 $this->create_thumbnails_dir();
631
632 $new_dir = Thumbnail::get_directory()['base_dir'];
633 $old_dir = \WP_CONTENT_DIR . '/uploads/embed-privacy/thumbnails';
634
635 // directories are identical, don't do anything
636 if ( $new_dir === $old_dir ) {
637 return;
638 }
639
640 if ( \file_exists( $old_dir ) ) {
641 $post_args = [
642 'fields' => 'ids',
643 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
644 [
645 'compare' => '!=',
646 'compare_key' => 'LIKE',
647 'key' => 'embed_privacy_thumbnail_',
648 'value' => '',
649 ],
650 ],
651 'no_found_rows' => true,
652 'offset' => 0,
653 'post_type' => 'any',
654 'update_post_term_cache' => false,
655 ];
656 $posts = \get_posts( $post_args );
657
658 // iterate through posts to get metadata
659 while ( \count( $posts ) ) {
660 foreach ( $posts as $post_id ) {
661 $metadata = \get_post_meta( $post_id );
662
663 foreach ( $metadata as $meta_key => $meta_value ) {
664 if ( ! \str_contains( $meta_key, 'embed_privacy_thumbnail_' ) ) {
665 continue;
666 }
667
668 if ( \str_contains( $meta_key, '_url' ) ) {
669 continue;
670 }
671
672 $filename = \reset( $meta_value );
673
674 // move thumbnail
675 if ( \file_exists( $old_dir . '/' . $filename ) ) {
676 Embed_Privacy::get_wp_filesystem()->move( $old_dir . '/' . $filename, $new_dir . '/' . $filename );
677 }
678 }
679 }
680
681 $post_args['offset'] += 5;
682 $posts = \get_posts( $post_args );
683 }
684
685 // remove old directory
686 if ( ! ( new FilesystemIterator( $old_dir ) )->valid() ) {
687 Embed_Privacy::get_wp_filesystem()->rmdir( $old_dir, true );
688 }
689 }
690 }
691
692 /**
693 * Migrations for version 1.8.0.
694 *
695 * @since 1.8.0
696 *
697 * - Add new embed provider Anghami
698 */
699 private function migrate_1_8_0() {
700 $this->add_embed( [
701 'meta_input' => [
702 'is_system' => 'yes',
703 'privacy_policy_url' => \__( 'https://www.anghami.com/legal', 'embed-privacy' ),
704 'regex_default' => '/anghami\\\.com/',
705 ],
706 /* translators: embed provider */
707 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Anghami', 'embed provider', 'embed-privacy' ) ),
708 'post_status' => 'publish',
709 'post_title' => \_x( 'Anghami', 'embed provider', 'embed-privacy' ),
710 'post_type' => 'epi_embed',
711 ] );
712 }
713
714 /**
715 * Migrations for version 1.10.5.
716 *
717 * @see https://github.com/epiphyt/embed-privacy/issues/235
718 * @since 1.10.5
719 *
720 * - Rename Twitter to X
721 */
722 private function migrate_1_10_5() {
723 $twitter_provider = \get_posts( [
724 'meta_key' => 'is_system',
725 'meta_value' => 'yes',
726 'name' => 'twitter',
727 'no_found_rows' => true,
728 'post_type' => 'epi_embed',
729 'update_post_term_cache' => false,
730 ] );
731 $twitter_provider = \reset( $twitter_provider );
732
733 if ( $twitter_provider instanceof WP_Post ) {
734 $x_provider = [
735 'ID' => $twitter_provider->ID,
736 'post_name' => \sanitize_title( \_x( 'X', 'embed provider', 'embed-privacy' ) ),
737 'post_title' => \_x( 'X', 'embed provider', 'embed-privacy' ),
738 ];
739
740 /* translators: embed provider */
741 if ( $twitter_provider->post_content === \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Twitter', 'embed provider', 'embed-privacy' ) ) ) {
742 /* translators: embed provider */
743 $x_provider['post_content'] = \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'X', 'embed provider', 'embed-privacy' ) );
744 }
745
746 \wp_update_post( $x_provider );
747 \update_post_meta( $twitter_provider->ID, 'privacy_policy_url', \__( 'https://x.com/privacy', 'embed-privacy' ) );
748 \update_post_meta( $twitter_provider->ID, 'regex_default', '/^(www\\\.)?(twitter|x)\\\.com/' );
749 \update_post_meta( $twitter_provider->ID, 'is_system', 'yes' );
750 }
751 }
752
753 /**
754 * Migrations for version 1.10.6.
755 *
756 * @since 1.10.6
757 *
758 * - Rename Maps Marker to Maps Marker Pro
759 */
760 private function migrate_1_10_6() {
761 $maps_marker_provider = \get_posts( [
762 'meta_key' => 'is_system',
763 'meta_value' => 'yes',
764 'name' => 'maps-marker',
765 'no_found_rows' => true,
766 'post_type' => 'epi_embed',
767 'update_post_term_cache' => false,
768 ] );
769 $maps_marker_provider = \reset( $maps_marker_provider );
770
771 if ( $maps_marker_provider instanceof WP_Post ) {
772 $maps_marker_pro_provider = [
773 'ID' => $maps_marker_provider->ID,
774 'post_name' => \sanitize_title( \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
775 'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
776 ];
777
778 /* translators: embed provider */
779 if ( $maps_marker_provider->post_content === \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ) ) ) {
780 /* translators: embed provider */
781 $maps_marker_pro_provider['post_content'] = \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) );
782 }
783
784 \wp_update_post( $maps_marker_pro_provider );
785 }
786 }
787
788 /**
789 * Migrations for version 1.10.7.
790 *
791 * @since 1.10.7
792 *
793 * - Improve X regular expression
794 */
795 private function migrate_1_10_7() {
796 $x_provider = \get_posts( [
797 'meta_key' => 'is_system',
798 'meta_value' => 'yes',
799 'name' => 'x',
800 'no_found_rows' => true,
801 'post_type' => 'epi_embed',
802 'update_post_term_cache' => false,
803 ] );
804 $x_provider = \reset( $x_provider );
805
806 if ( $x_provider instanceof WP_Post ) {
807 \update_post_meta( $x_provider->ID, 'regex_default', '/^(www\\\.)?(twitter|x)\\\.com/' );
808 }
809
810 \delete_option( 'embed_privacy_javascript_detection' );
811 }
812
813 /**
814 * Register default embed providers.
815 */
816 public function register_default_embed_providers() {
817 $this->providers = [
818 [
819 'meta_input' => [
820 'is_system' => 'yes',
821 'privacy_policy_url' => \__( 'https://www.amazon.com/gp/help/customer/display.html?nodeId=GX7NJQ4ZB8MHFRNJ', 'embed-privacy' ),
822 'regex_default' => '/\\\.?(ama?zo?n\\\.|a\\\.co\\\/|z\\\.cn\\\/)/',
823 ],
824 /* translators: embed provider */
825 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Amazon Kindle', 'embed provider', 'embed-privacy' ) ),
826 'post_status' => 'publish',
827 'post_title' => \_x( 'Amazon Kindle', 'embed provider', 'embed-privacy' ),
828 'post_type' => 'epi_embed',
829 ],
830 [
831 'meta_input' => [
832 'is_system' => 'yes',
833 'privacy_policy_url' => \__( 'https://www.anghami.com/legal', 'embed-privacy' ),
834 'regex_default' => '/anghami\\\.com/',
835 ],
836 /* translators: embed provider */
837 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Anghami', 'embed provider', 'embed-privacy' ) ),
838 'post_status' => 'publish',
839 'post_title' => \_x( 'Anghami', 'embed provider', 'embed-privacy' ),
840 'post_type' => 'epi_embed',
841 ],
842 [
843 'meta_input' => [
844 'is_system' => 'yes',
845 'privacy_policy_url' => \__( 'https://animoto.com/legal/privacy_policy', 'embed-privacy' ),
846 'regex_default' => '/animoto\\\.com/',
847 ],
848 /* translators: embed provider */
849 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Animoto', 'embed provider', 'embed-privacy' ) ),
850 'post_status' => 'publish',
851 'post_title' => \_x( 'Animoto', 'embed provider', 'embed-privacy' ),
852 'post_type' => 'epi_embed',
853 ],
854 [
855 'meta_input' => [
856 'is_system' => 'yes',
857 'privacy_policy_url' => \__( 'https://automattic.com/privacy/', 'embed-privacy' ),
858 'regex_default' => '/cloudup\\\.com/',
859 ],
860 /* translators: embed provider */
861 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Cloudup', 'embed provider', 'embed-privacy' ) ),
862 'post_status' => 'publish',
863 'post_title' => \_x( 'Cloudup', 'embed provider', 'embed-privacy' ),
864 'post_type' => 'epi_embed',
865 ],
866 [
867 'meta_input' => [
868 'is_system' => 'yes',
869 'privacy_policy_url' => \__( 'https://automattic.com/privacy/', 'embed-privacy' ),
870 'regex_default' => '/((poll(\\\.fm|daddy\\\.com))|crowdsignal\\\.(com|net)|survey\\\.fm)/',
871 ],
872 /* translators: embed provider */
873 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Crowdsignal', 'embed provider', 'embed-privacy' ) ),
874 'post_status' => 'publish',
875 'post_title' => \_x( 'Crowdsignal', 'embed provider', 'embed-privacy' ),
876 'post_type' => 'epi_embed',
877 ],
878 [
879 'meta_input' => [
880 'is_system' => 'yes',
881 'privacy_policy_url' => \__( 'https://www.dailymotion.com/legal/privacy?localization=en', 'embed-privacy' ),
882 'regex_default' => '/dailymotion\\\.com/',
883 ],
884 /* translators: embed provider */
885 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'DailyMotion', 'embed provider', 'embed-privacy' ) ),
886 'post_status' => 'publish',
887 'post_title' => \_x( 'DailyMotion', 'embed provider', 'embed-privacy' ),
888 'post_type' => 'epi_embed',
889 ],
890 [
891 'meta_input' => [
892 'is_system' => 'yes',
893 'privacy_policy_url' => \__( 'https://www.facebook.com/privacy/explanation', 'embed-privacy' ),
894 'regex_default' => '/facebook\\\.com/',
895 ],
896 /* translators: embed provider */
897 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Facebook', 'embed provider', 'embed-privacy' ) ),
898 'post_status' => 'publish',
899 'post_title' => \_x( 'Facebook', 'embed provider', 'embed-privacy' ),
900 'post_type' => 'epi_embed',
901 ],
902 [
903 'meta_input' => [
904 'is_system' => 'yes',
905 'privacy_policy_url' => \__( 'https://www.flickr.com/help/privacy', 'embed-privacy' ),
906 'regex_default' => '/flickr\\\.com/',
907 ],
908 /* translators: embed provider */
909 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Flickr', 'embed provider', 'embed-privacy' ) ),
910 'post_status' => 'publish',
911 'post_title' => \_x( 'Flickr', 'embed provider', 'embed-privacy' ),
912 'post_type' => 'epi_embed',
913 ],
914 [
915 'meta_input' => [
916 'is_system' => 'yes',
917 'privacy_policy_url' => \__( 'https://www.funnyordie.com/legal/privacy-notice', 'embed-privacy' ),
918 'regex_default' => '/funnyordie\\\.com/',
919 ],
920 /* translators: embed provider */
921 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Funny Or Die', 'embed provider', 'embed-privacy' ) ),
922 'post_status' => 'publish',
923 'post_title' => \_x( 'Funny Or Die', 'embed provider', 'embed-privacy' ),
924 'post_type' => 'epi_embed',
925 ],
926 [
927 'meta_input' => [
928 'is_system' => 'yes',
929 'privacy_policy_url' => \__( 'https://policies.google.com/privacy?hl=en', 'embed-privacy' ),
930 'regex_default' => '/(google\\\.com\\\/maps\\\/embed|maps\\\.google\\\.com\\\/(maps)?)/',
931 ],
932 /* translators: embed provider */
933 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Google Maps', 'embed provider', 'embed-privacy' ) ),
934 'post_status' => 'publish',
935 'post_title' => \_x( 'Google Maps', 'embed provider', 'embed-privacy' ),
936 'post_type' => 'epi_embed',
937 ],
938 [
939 'meta_input' => [
940 'is_system' => 'yes',
941 'privacy_policy_url' => \__( 'https://imgur.com/privacy', 'embed-privacy' ),
942 'regex_default' => '/imgur\\\.com/',
943 ],
944 /* translators: embed provider */
945 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Imgur', 'embed provider', 'embed-privacy' ) ),
946 'post_status' => 'publish',
947 'post_title' => \_x( 'Imgur', 'embed provider', 'embed-privacy' ),
948 'post_type' => 'epi_embed',
949 ],
950 [
951 'meta_input' => [
952 'is_system' => 'yes',
953 'privacy_policy_url' => \__( 'https://www.instagram.com/legal/privacy/', 'embed-privacy' ),
954 'regex_default' => '/instagram\\\.com/',
955 ],
956 /* translators: embed provider */
957 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Instagram', 'embed provider', 'embed-privacy' ) ),
958 'post_status' => 'publish',
959 'post_title' => \_x( 'Instagram', 'embed provider', 'embed-privacy' ),
960 'post_type' => 'epi_embed',
961 ],
962 [
963 'meta_input' => [
964 'is_system' => 'yes',
965 'privacy_policy_url' => \__( 'https://issuu.com/legal/privacy', 'embed-privacy' ),
966 'regex_default' => '/issuu\\\.com/',
967 ],
968 /* translators: embed provider */
969 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Issuu', 'embed provider', 'embed-privacy' ) ),
970 'post_status' => 'publish',
971 'post_title' => \_x( 'Issuu', 'embed provider', 'embed-privacy' ),
972 'post_type' => 'epi_embed',
973 ],
974 [
975 'meta_input' => [
976 'is_system' => 'yes',
977 'privacy_policy_url' => \__( 'https://www.kickstarter.com/privacy', 'embed-privacy' ),
978 'regex_default' => '/kickstarter\\\.com/',
979 ],
980 /* translators: embed provider */
981 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Kickstarter', 'embed provider', 'embed-privacy' ) ),
982 'post_status' => 'publish',
983 'post_title' => \_x( 'Kickstarter', 'embed provider', 'embed-privacy' ),
984 'post_type' => 'epi_embed',
985 ],
986 [
987 'meta_input' => [
988 'is_system' => 'yes',
989 'privacy_policy_url' => '',
990 'regex_default' => '',
991 ],
992 /* translators: embed provider */
993 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
994 'post_status' => 'publish',
995 'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
996 'post_type' => 'epi_embed',
997 ],
998 [
999 'meta_input' => [
1000 'is_system' => 'yes',
1001 'privacy_policy_url' => \__( 'https://www.meetup.com/privacy/', 'embed-privacy' ),
1002 'regex_default' => '/meetup\\\.com/',
1003 ],
1004 /* translators: embed provider */
1005 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Meetup', 'embed provider', 'embed-privacy' ) ),
1006 'post_status' => 'publish',
1007 'post_title' => \_x( 'Meetup', 'embed provider', 'embed-privacy' ),
1008 'post_type' => 'epi_embed',
1009 ],
1010 [
1011 'meta_input' => [
1012 'is_system' => 'yes',
1013 'privacy_policy_url' => \__( 'https://www.mixcloud.com/privacy/', 'embed-privacy' ),
1014 'regex_default' => '/mixcloud\\\.com/',
1015 ],
1016 /* translators: embed provider */
1017 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Mixcloud', 'embed provider', 'embed-privacy' ) ),
1018 'post_status' => 'publish',
1019 'post_title' => \_x( 'Mixcloud', 'embed provider', 'embed-privacy' ),
1020 'post_type' => 'epi_embed',
1021 ],
1022 [
1023 'meta_input' => [
1024 'is_system' => 'yes',
1025 'privacy_policy_url' => \__( 'https://app.photobucket.com/privacy', 'embed-privacy' ),
1026 'regex_default' => '/photobucket\\\.com/',
1027 ],
1028 /* translators: embed provider */
1029 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Photobucket', 'embed provider', 'embed-privacy' ) ),
1030 'post_status' => 'publish',
1031 'post_title' => \_x( 'Photobucket', 'embed provider', 'embed-privacy' ),
1032 'post_type' => 'epi_embed',
1033 ],
1034 [
1035 'meta_input' => [
1036 'is_system' => 'yes',
1037 'privacy_policy_url' => \__( 'https://policy.pinterest.com/en/privacy-policy', 'embed-privacy' ),
1038 'regex_default' => '/pinterest\\\./',
1039 ],
1040 /* translators: embed provider */
1041 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Pinterest', 'embed provider', 'embed-privacy' ) ),
1042 'post_status' => 'publish',
1043 'post_title' => \_x( 'Pinterest', 'embed provider', 'embed-privacy' ),
1044 'post_type' => 'epi_embed',
1045 ],
1046 [
1047 'meta_input' => [
1048 'is_system' => 'yes',
1049 'privacy_policy_url' => \__( 'https://support.pocketcasts.com/article/privacy-policy/', 'embed-privacy' ),
1050 'regex_default' => '/pca\\\.st/',
1051 ],
1052 /* translators: embed provider */
1053 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Pocket Casts', 'embed provider', 'embed-privacy' ) ),
1054 'post_status' => 'publish',
1055 'post_title' => \_x( 'Pocket Casts', 'embed provider', 'embed-privacy' ),
1056 'post_type' => 'epi_embed',
1057 ],
1058 [
1059 'meta_input' => [
1060 'is_system' => 'yes',
1061 'privacy_policy_url' => \__( 'https://www.reddit.com/help/privacypolicy', 'embed-privacy' ),
1062 'regex_default' => '/reddit\\\.com/',
1063 ],
1064 /* translators: embed provider */
1065 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Reddit', 'embed provider', 'embed-privacy' ) ),
1066 'post_status' => 'publish',
1067 'post_title' => \_x( 'Reddit', 'embed provider', 'embed-privacy' ),
1068 'post_type' => 'epi_embed',
1069 ],
1070 [
1071 'meta_input' => [
1072 'is_system' => 'yes',
1073 'privacy_policy_url' => \__( 'https://www.reverbnation.com/privacy', 'embed-privacy' ),
1074 'regex_default' => '/reverbnation\\\.com/',
1075 ],
1076 /* translators: embed provider */
1077 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'ReverbNation', 'embed provider', 'embed-privacy' ) ),
1078 'post_status' => 'publish',
1079 'post_title' => \_x( 'ReverbNation', 'embed provider', 'embed-privacy' ),
1080 'post_type' => 'epi_embed',
1081 ],
1082 [
1083 'meta_input' => [
1084 'is_system' => 'yes',
1085 'privacy_policy_url' => \__( 'https://scribd.com/privacy', 'embed-privacy' ),
1086 'regex_default' => '/scribd\\\.com/',
1087 ],
1088 /* translators: embed provider */
1089 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Scribd', 'embed provider', 'embed-privacy' ) ),
1090 'post_status' => 'publish',
1091 'post_title' => \_x( 'Scribd', 'embed provider', 'embed-privacy' ),
1092 'post_type' => 'epi_embed',
1093 ],
1094 [
1095 'meta_input' => [
1096 'is_system' => 'yes',
1097 'privacy_policy_url' => \__( 'https://sketchfab.com/privacy', 'embed-privacy' ),
1098 'regex_default' => '/sketchfab\\\.com/',
1099 ],
1100 /* translators: embed provider */
1101 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Sketchfab', 'embed provider', 'embed-privacy' ) ),
1102 'post_status' => 'publish',
1103 'post_title' => \_x( 'Sketchfab', 'embed provider', 'embed-privacy' ),
1104 'post_type' => 'epi_embed',
1105 ],
1106 [
1107 'meta_input' => [
1108 'is_system' => 'yes',
1109 'privacy_policy_url' => \__( 'https://www.slideshare.net/privacy', 'embed-privacy' ),
1110 'regex_default' => '/slideshare\\\.net/',
1111 ],
1112 /* translators: embed provider */
1113 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'SlideShare', 'embed provider', 'embed-privacy' ) ),
1114 'post_status' => 'publish',
1115 'post_title' => \_x( 'SlideShare', 'embed provider', 'embed-privacy' ),
1116 'post_type' => 'epi_embed',
1117 ],
1118 [
1119 'meta_input' => [
1120 'is_system' => 'yes',
1121 'privacy_policy_url' => \__( 'https://www.smugmug.com/about/privacy', 'embed-privacy' ),
1122 'regex_default' => '/smugmug\\\.com/',
1123 ],
1124 /* translators: embed provider */
1125 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'SmugMug', 'embed provider', 'embed-privacy' ) ),
1126 'post_status' => 'publish',
1127 'post_title' => \_x( 'SmugMug', 'embed provider', 'embed-privacy' ),
1128 'post_type' => 'epi_embed',
1129 ],
1130 [
1131 'meta_input' => [
1132 'is_system' => 'yes',
1133 'privacy_policy_url' => \__( 'https://soundcloud.com/pages/privacy', 'embed-privacy' ),
1134 'regex_default' => '/soundcloud\\\.com/',
1135 ],
1136 /* translators: embed provider */
1137 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'SoundCloud', 'embed provider', 'embed-privacy' ) ),
1138 'post_status' => 'publish',
1139 'post_title' => \_x( 'SoundCloud', 'embed provider', 'embed-privacy' ),
1140 'post_type' => 'epi_embed',
1141 ],
1142 [
1143 'meta_input' => [
1144 'is_system' => 'yes',
1145 'privacy_policy_url' => \__( 'https://speakerdeck.com/privacy', 'embed-privacy' ),
1146 'regex_default' => '/speakerdeck\\\.com/',
1147 ],
1148 /* translators: embed provider */
1149 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Speaker Deck', 'embed provider', 'embed-privacy' ) ),
1150 'post_status' => 'publish',
1151 'post_title' => \_x( 'Speaker Deck', 'embed provider', 'embed-privacy' ),
1152 'post_type' => 'epi_embed',
1153 ],
1154 [
1155 'meta_input' => [
1156 'is_system' => 'yes',
1157 'privacy_policy_url' => \__( 'https://www.spotify.com/privacy/', 'embed-privacy' ),
1158 'regex_default' => '/spotify\\\.com/',
1159 ],
1160 /* translators: embed provider */
1161 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Spotify', 'embed provider', 'embed-privacy' ) ),
1162 'post_status' => 'publish',
1163 'post_title' => \_x( 'Spotify', 'embed provider', 'embed-privacy' ),
1164 'post_type' => 'epi_embed',
1165 ],
1166 [
1167 'meta_input' => [
1168 'is_system' => 'yes',
1169 'privacy_policy_url' => \__( 'https://www.tiktok.com/legal/privacy-policy?lang=en-US', 'embed-privacy' ),
1170 'regex_default' => '/tiktok\\\.com/',
1171 ],
1172 /* translators: embed provider */
1173 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'TikTok', 'embed provider', 'embed-privacy' ) ),
1174 'post_status' => 'publish',
1175 'post_title' => \_x( 'TikTok', 'embed provider', 'embed-privacy' ),
1176 'post_type' => 'epi_embed',
1177 ],
1178 [
1179 'meta_input' => [
1180 'is_system' => 'yes',
1181 'privacy_policy_url' => \__( 'https://www.ted.com/about/our-organization/our-policies-terms/privacy-policy', 'embed-privacy' ),
1182 'regex_default' => '/ted\\\.com/',
1183 ],
1184 /* translators: embed provider */
1185 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'TED', 'embed provider', 'embed-privacy' ) ),
1186 'post_status' => 'publish',
1187 'post_title' => \_x( 'TED', 'embed provider', 'embed-privacy' ),
1188 'post_type' => 'epi_embed',
1189 ],
1190 [
1191 'meta_input' => [
1192 'is_system' => 'yes',
1193 'privacy_policy_url' => \__( 'https://www.tumblr.com/privacy_policy', 'embed-privacy' ),
1194 'regex_default' => '/tumblr\\\.com/',
1195 ],
1196 /* translators: embed provider */
1197 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Tumblr', 'embed provider', 'embed-privacy' ) ),
1198 'post_status' => 'publish',
1199 'post_title' => \_x( 'Tumblr', 'embed provider', 'embed-privacy' ),
1200 'post_type' => 'epi_embed',
1201 ],
1202 [
1203 'meta_input' => [
1204 'is_system' => 'yes',
1205 'privacy_policy_url' => \__( 'https://x.com/privacy', 'embed-privacy' ),
1206 'regex_default' => '^(www\\\.)?(twitter|x)\\\.com/',
1207 ],
1208 /* translators: embed provider */
1209 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'X', 'embed provider', 'embed-privacy' ) ),
1210 'post_status' => 'publish',
1211 'post_title' => \_x( 'X', 'embed provider', 'embed-privacy' ),
1212 'post_type' => 'epi_embed',
1213 ],
1214 [
1215 'meta_input' => [
1216 'is_system' => 'yes',
1217 'privacy_policy_url' => \__( 'https://automattic.com/privacy/', 'embed-privacy' ),
1218 'regex_default' => '/videopress\\\.com/',
1219 ],
1220 /* translators: embed provider */
1221 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'VideoPress', 'embed provider', 'embed-privacy' ) ),
1222 'post_status' => 'publish',
1223 'post_title' => \_x( 'VideoPress', 'embed provider', 'embed-privacy' ),
1224 'post_type' => 'epi_embed',
1225 ],
1226 [
1227 'meta_input' => [
1228 'is_system' => 'yes',
1229 'privacy_policy_url' => \__( 'https://vimeo.com/privacy', 'embed-privacy' ),
1230 'regex_default' => '/vimeo\\\.com/',
1231 ],
1232 /* translators: embed provider */
1233 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Vimeo', 'embed provider', 'embed-privacy' ) ),
1234 'post_status' => 'publish',
1235 'post_title' => \_x( 'Vimeo', 'embed provider', 'embed-privacy' ),
1236 'post_type' => 'epi_embed',
1237 ],
1238 [
1239 'meta_input' => [
1240 'is_system' => 'yes',
1241 'privacy_policy_url' => \__( 'https://www.wolfram.com/legal/privacy/wolfram/', 'embed-privacy' ),
1242 'regex_default' => '/wolframcloud\\\.com/',
1243 ],
1244 /* translators: embed provider */
1245 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Wolfram Cloud', 'embed provider', 'embed-privacy' ) ),
1246 'post_status' => 'publish',
1247 'post_title' => \_x( 'Wolfram Cloud', 'embed provider', 'embed-privacy' ),
1248 'post_type' => 'epi_embed',
1249 ],
1250 [
1251 'meta_input' => [
1252 'is_system' => 'yes',
1253 'privacy_policy_url' => \__( 'https://wordpress.org/about/privacy/', 'embed-privacy' ),
1254 'regex_default' => '/wordpress\\\.org\\\/plugins/',
1255 ],
1256 /* translators: embed provider */
1257 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'WordPress.org', 'embed provider', 'embed-privacy' ) ),
1258 'post_status' => 'publish',
1259 'post_title' => \_x( 'WordPress.org', 'embed provider', 'embed-privacy' ),
1260 'post_type' => 'epi_embed',
1261 ],
1262 [
1263 'meta_input' => [
1264 'is_system' => 'yes',
1265 'privacy_policy_url' => \__( 'https://wordpress.org/about/privacy/', 'embed-privacy' ),
1266 'regex_default' => '/wordpress\\\.tv\/',
1267 ],
1268 /* translators: embed provider */
1269 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'WordPress.tv', 'embed provider', 'embed-privacy' ) ),
1270 'post_status' => 'publish',
1271 'post_title' => \_x( 'WordPress.tv', 'embed provider', 'embed-privacy' ),
1272 'post_type' => 'epi_embed',
1273 ],
1274 [
1275 'meta_input' => [
1276 'is_system' => 'yes',
1277 'privacy_policy_url' => \__( 'https://policies.google.com/privacy?hl=en', 'embed-privacy' ),
1278 'regex_default' => '/https?:\\\/\\\/(?:.+?.)?youtu(?:.be|be.com)/',
1279 ],
1280 /* translators: embed provider */
1281 'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'YouTube', 'embed provider', 'embed-privacy' ) ),
1282 'post_status' => 'publish',
1283 'post_title' => \_x( 'YouTube', 'embed provider', 'embed-privacy' ),
1284 'post_type' => 'epi_embed',
1285 ],
1286 ];
1287 }
1288
1289 /**
1290 * Add a notice if migration failed.
1291 *
1292 * @since 1.5.0
1293 */
1294 public function register_migration_failed_notice() {
1295 if ( (int) $this->get_option( 'migration_count' ) < 3 ) {
1296 return;
1297 }
1298 ?>
1299 <div class="notice notice-error" data-notice="embed_privacy_migration_failed_notice">
1300 <p>
1301 <?php
1302 \printf(
1303 /* translators: 1: current migration version, 2: target migration version, 3: starting HTML anchor, 4: ending HTML anchor */
1304 \esc_html__( 'Embed Privacy migration from version %1$s to %2$s failed. Please contact the %3$ssupport%4$s for further assistance.', 'embed-privacy' ),
1305 \esc_html( $this->get_option( 'migrate_version' ) ),
1306 \esc_html( $this->version ),
1307 '<a href="' . \esc_url( \__( 'https://wordpress.org/support/plugin/embed-privacy/#new-topic-0', 'embed-privacy' ) ) . '">',
1308 '</a>'
1309 ); ?>
1310 </p>
1311 </div>
1312 <?php
1313 }
1314
1315 /**
1316 * Update an option either from the global multisite settings or the regular site.
1317 *
1318 * @param string $option The option name
1319 * @param mixed $value The value to update
1320 * @return bool Whether the update was successful
1321 */
1322 private function update_option( $option, $value ) {
1323 return \update_option( 'embed_privacy_' . $option, $value );
1324 }
1325 }
1326