PluginProbe
Embed Privacy / 1.10.2
Embed Privacy v1.10.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 / admin / class-settings.php

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

149 lines 4.7 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_javascript_detection',
56 \__( 'JavaScript detection', 'embed-privacy' ),
57 [ Field::class, 'get' ],
58 'embed_privacy',
59 'embed_privacy_general',
60 [
61 'description' => \__( 'By enabling this option, checks for embed providers are made via JavaScript on the client-side rather than on your server. Enabling this option is recommended when using a caching plugin.', 'embed-privacy' ),
62 'name' => 'embed_privacy_javascript_detection',
63 'option_type' => 'option',
64 'title' => \__( 'JavaScript detection for active providers', 'embed-privacy' ),
65 'type' => 'checkbox',
66 ]
67 );
68 \register_setting( 'embed_privacy', 'embed_privacy_javascript_detection' );
69 \add_settings_field(
70 'embed_privacy_local_tweets',
71 \__( 'Embeds', 'embed-privacy' ),
72 [ Field::class, 'get' ],
73 'embed_privacy',
74 'embed_privacy_general',
75 [
76 'description' => \__( 'By enabling this option, tweets are embedded locally as text without any connection to Twitter, and no privacy overlay is required.', 'embed-privacy' ),
77 'name' => 'embed_privacy_local_tweets',
78 'option_type' => 'option',
79 'title' => \__( 'Local tweets', 'embed-privacy' ),
80 'type' => 'checkbox',
81 ]
82 );
83 \register_setting( 'embed_privacy', 'embed_privacy_local_tweets' );
84 \add_settings_field(
85 'embed_privacy_disable_link',
86 null,
87 [ Field::class, 'get' ],
88 'embed_privacy',
89 'embed_privacy_general',
90 [
91 'description' => \__( 'Disable the direct link on the lower right corner that opens the embed directly.', 'embed-privacy' ),
92 'name' => 'embed_privacy_disable_link',
93 'option_type' => 'option',
94 'title' => \__( 'Disable direct link', 'embed-privacy' ),
95 'type' => 'checkbox',
96 ]
97 );
98 \register_setting( 'embed_privacy', 'embed_privacy_disable_link' );
99 \add_settings_field(
100 'embed_privacy_download_thumbnails',
101 null,
102 [ Field::class, 'get' ],
103 'embed_privacy',
104 'embed_privacy_general',
105 [
106 /* translators: list of supported embed providers */
107 'description' => \wp_sprintf(
108 \__( 'Try to automatically download thumbnails of the embedded content and use them as background image of the overlay. Currently supported: %l.', 'embed-privacy' ),
109 Embed_Privacy::get_instance()->thumbnail->get_provider_titles()
110 ),
111 'name' => 'embed_privacy_download_thumbnails',
112 'option_type' => 'option',
113 'title' => \__( 'Download thumbnails', 'embed-privacy' ),
114 'type' => 'checkbox',
115 ]
116 );
117 \register_setting( 'embed_privacy', 'embed_privacy_download_thumbnails' );
118 \add_settings_field(
119 'embed_privacy_preserve_data_on_uninstall',
120 \__( 'Data handling', 'embed-privacy' ),
121 [ Field::class, 'get' ],
122 'embed_privacy',
123 'embed_privacy_general',
124 [
125 'description' => \__( 'By enabling this option, all plugin data is preserved on uninstall.', 'embed-privacy' ),
126 'name' => 'embed_privacy_preserve_data_on_uninstall',
127 'option_type' => 'option',
128 'title' => \__( 'Preserve data on uninstall', 'embed-privacy' ),
129 'type' => 'checkbox',
130 ]
131 );
132 \register_setting( 'embed_privacy', 'embed_privacy_preserve_data_on_uninstall' );
133 }
134
135 /**
136 * Register menu items.
137 */
138 public static function register_menu() {
139 \add_submenu_page(
140 'options-general.php',
141 \__( 'Embed Privacy', 'embed-privacy' ),
142 \__( 'Embed Privacy', 'embed-privacy' ),
143 self::CAPABILITY,
144 'embed_privacy',
145 [ self::class, 'get_page' ]
146 );
147 }
148 }
149