File tree Expand file tree Collapse file tree 6 files changed +68
-180
lines changed Expand file tree Collapse file tree 6 files changed +68
-180
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Plugin Name: AMP Beta Tester
4
+ * Description: Opt-in to receive non-stable release builds for the AMP plugin.
5
+ * Plugin URI: https://amp-wp.org
6
+ * Author: AMP Project Contributors
7
+ * Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
8
+ * Version: 0.1
9
+ * Text Domain: amp-beta-tester
10
+ * Domain Path: /languages/
11
+ * License: GPLv2 or later
12
+ *
13
+ * @package AMP Beta Tester
14
+ */
15
+
16
+ namespace AMP_Beta_Tester ;
17
+
18
+ define ( 'AMP__BETA_TESTER__DIR__ ' , dirname ( __FILE__ ) );
19
+
20
+ add_action ( 'plugins_loaded ' , __NAMESPACE__ . '\init ' );
21
+
22
+ /**
23
+ * Hook into WP.
24
+ *
25
+ * @return void
26
+ */
27
+ function init () {
28
+ // Abort init if AMP plugin is not available.
29
+ if ( ! defined ( 'AMP__FILE__ ' ) ) {
30
+ add_action ( 'admin_notices ' , __NAMESPACE__ . '\show_missing_amp_notice ' );
31
+ return ;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Display an admin notice if the AMP plugin is not detected.
37
+ *
38
+ * @return void
39
+ */
40
+ function show_missing_amp_notice () {
41
+ $ error = sprintf (
42
+ // translators: %s: AMP plugin URL.
43
+ esc_html__ (
44
+ 'AMP Beta Tester requires AMP to be installed and active. You can download AMP %s. ' ,
45
+ 'amp-beta-tester '
46
+ ),
47
+ '<a href="https://amp-wp.org" target="_blank">here</a> '
48
+ );
49
+
50
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
51
+ echo "<div class='notice notice-error'><p><strong> {$ error }</strong></p></div> " ;
52
+ }
Original file line number Diff line number Diff line change 161
161
);
162
162
}
163
163
164
+ // DEV_CODE. This block of code is removed during the build process.
165
+ if ( file_exists ( AMP__DIR__ . '/amp-beta-tester.php ' ) ) {
166
+ add_filter (
167
+ 'site_transient_update_plugins ' ,
168
+ function ( $ updates ) {
169
+ if ( isset ( $ updates ->response ) && is_array ( $ updates ->response ) ) {
170
+ if ( array_key_exists ( 'amp/amp-beta-tester.php ' , $ updates ->response ) ) {
171
+ unset( $ updates ->response ['amp/amp-beta-tester.php ' ] );
172
+ }
173
+ }
174
+
175
+ return $ updates ;
176
+ }
177
+ );
178
+ }
179
+
164
180
/**
165
181
* Displays an admin notice about why the plugin is unable to load.
166
182
*
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments