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 / admin / class-settings.php

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

134 lines 4.0 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\admin;
3
4 use epiphyt\Embed_Privacy\Embed_Privacy;
5
6 /**
7 * Admin settings.
8 *
9 * @author Epiphyt
10 * @license GPL2
11 * @package epiphyt\Embed_Privacy
12 * @since 1.10.0
13 */
14 final class Settings {
15 const CAPABILITY = 'manage_options';
16
17 /**
18 * Initialize functionality.
19 */
20 public static function init() {
21 \add_action( 'admin_init', [ self::class, 'register' ] );
22 \add_action( 'admin_menu', [ self::class, 'register_menu' ] );
23 }
24
25 /**
26 * Get settings page.
27 */
28 public static function get_page() {
29 if ( ! \current_user_can( self::CAPABILITY ) ) {
30 return;
31 }
32
33 \settings_errors( 'embed_privacy_messages' );
34 ?>
35 <div class="wrap">
36 <h1><?php \esc_html_e( 'Embed Privacy', 'embed-privacy' ); ?> <a href="<?php echo \esc_url( \admin_url( 'edit.php?post_type=epi_embed' ) ); ?>" class="page-title-action"><?php \esc_html_e( 'Manage embeds', 'embed-privacy' ); ?></a></h1>
37
38 <form action="options.php" method="post">
39 <?php
40 \settings_fields( 'embed_privacy' );
41 \do_settings_sections( 'embed_privacy' );
42 \submit_button( \esc_html__( 'Save Settings', 'embed-privacy' ) );
43 ?>
44 </form>
45 </div>
46 <?php
47 }
48
49 /**
50 * Register settings.
51 */
52 public static function register() {
53 \add_settings_section( 'embed_privacy_general', null, '__return_null', 'embed_privacy' );
54 \add_settings_field(
55 'embed_privacy_local_tweets',
56 \__( 'Embeds', 'embed-privacy' ),
57 [ Field::class, 'get' ],
58 'embed_privacy',
59 'embed_privacy_general',
60 [
61 'description' => \__( 'By enabling this option, tweets are embedded locally as text without any connection to X, and no privacy overlay is required.', 'embed-privacy' ),
62 'name' => 'embed_privacy_local_tweets',
63 'option_type' => 'option',
64 'title' => \__( 'Local tweets', 'embed-privacy' ),
65 'type' => 'checkbox',
66 ]
67 );
68 \register_setting( 'embed_privacy', 'embed_privacy_local_tweets' );
69 \add_settings_field(
70 'embed_privacy_disable_link',
71 null,
72 [ Field::class, 'get' ],
73 'embed_privacy',
74 'embed_privacy_general',
75 [
76 'description' => \__( 'Disable the direct link on the lower right corner that opens the embed directly.', 'embed-privacy' ),
77 'name' => 'embed_privacy_disable_link',
78 'option_type' => 'option',
79 'title' => \__( 'Disable direct link', 'embed-privacy' ),
80 'type' => 'checkbox',
81 ]
82 );
83 \register_setting( 'embed_privacy', 'embed_privacy_disable_link' );
84 \add_settings_field(
85 'embed_privacy_download_thumbnails',
86 null,
87 [ Field::class, 'get' ],
88 'embed_privacy',
89 'embed_privacy_general',
90 [
91 /* translators: list of supported embed providers */
92 'description' => \wp_sprintf(
93 \__( 'Try to automatically download thumbnails of the embedded content and use them as background image of the overlay. Currently supported: %l.', 'embed-privacy' ),
94 Embed_Privacy::get_instance()->thumbnail->get_provider_titles()
95 ),
96 'name' => 'embed_privacy_download_thumbnails',
97 'option_type' => 'option',
98 'title' => \__( 'Download thumbnails', 'embed-privacy' ),
99 'type' => 'checkbox',
100 ]
101 );
102 \register_setting( 'embed_privacy', 'embed_privacy_download_thumbnails' );
103 \add_settings_field(
104 'embed_privacy_preserve_data_on_uninstall',
105 \__( 'Data handling', 'embed-privacy' ),
106 [ Field::class, 'get' ],
107 'embed_privacy',
108 'embed_privacy_general',
109 [
110 'description' => \__( 'By enabling this option, all plugin data is preserved on uninstall.', 'embed-privacy' ),
111 'name' => 'embed_privacy_preserve_data_on_uninstall',
112 'option_type' => 'option',
113 'title' => \__( 'Preserve data on uninstall', 'embed-privacy' ),
114 'type' => 'checkbox',
115 ]
116 );
117 \register_setting( 'embed_privacy', 'embed_privacy_preserve_data_on_uninstall' );
118 }
119
120 /**
121 * Register menu items.
122 */
123 public static function register_menu() {
124 \add_submenu_page(
125 'options-general.php',
126 \__( 'Embed Privacy', 'embed-privacy' ),
127 \__( 'Embed Privacy', 'embed-privacy' ),
128 self::CAPABILITY,
129 'embed_privacy',
130 [ self::class, 'get_page' ]
131 );
132 }
133 }
134