Skip to content

Commit 0c1cec2

Browse files
committed
Move amp-beta-tester.php to root folder
1 parent dd5869a commit 0c1cec2

File tree

6 files changed

+68
-180
lines changed

6 files changed

+68
-180
lines changed

amp-beta-tester.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

amp.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,22 @@
161161
);
162162
}
163163

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+
164180
/**
165181
* Displays an admin notice about why the plugin is unable to load.
166182
*

beta-tester/amp-beta-tester.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

beta-tester/includes/class-amp-beta-tester-plugin.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

beta-tester/includes/class-autoloader.php

Lines changed: 0 additions & 108 deletions
This file was deleted.

beta-tester/languages/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)