Skip to content

Commit

Permalink
Move amp-beta-tester.php to root folder
Browse files Browse the repository at this point in the history
  • Loading branch information
pierlon committed Oct 20, 2019
1 parent dd5869a commit 0c1cec2
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 180 deletions.
52 changes: 52 additions & 0 deletions amp-beta-tester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Plugin Name: AMP Beta Tester
* Description: Opt-in to receive non-stable release builds for the AMP plugin.
* Plugin URI: https://amp-wp.org
* Author: AMP Project Contributors
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
* Version: 0.1
* Text Domain: amp-beta-tester
* Domain Path: /languages/
* License: GPLv2 or later
*
* @package AMP Beta Tester
*/

namespace AMP_Beta_Tester;

define( 'AMP__BETA_TESTER__DIR__', dirname( __FILE__ ) );

add_action( 'plugins_loaded', __NAMESPACE__ . '\init' );

/**
* Hook into WP.
*
* @return void
*/
function init() {
// Abort init if AMP plugin is not available.
if ( ! defined( 'AMP__FILE__' ) ) {
add_action( 'admin_notices', __NAMESPACE__ . '\show_missing_amp_notice' );
return;
}
}

/**
* Display an admin notice if the AMP plugin is not detected.
*
* @return void
*/
function show_missing_amp_notice() {
$error = sprintf(
// translators: %s: AMP plugin URL.
esc_html__(
'AMP Beta Tester requires AMP to be installed and active. You can download AMP %s.',
'amp-beta-tester'
),
'<a href="https://amp-wp.org" target="_blank">here</a>'
);

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo "<div class='notice notice-error'><p><strong>{$error}</strong></p></div>";
}
16 changes: 16 additions & 0 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@
);
}

// DEV_CODE. This block of code is removed during the build process.
if ( file_exists( AMP__DIR__ . '/amp-beta-tester.php' ) ) {
add_filter(
'site_transient_update_plugins',
function ( $updates ) {
if ( isset( $updates->response ) && is_array( $updates->response ) ) {
if ( array_key_exists( 'amp/amp-beta-tester.php', $updates->response ) ) {
unset( $updates->response['amp/amp-beta-tester.php'] );
}
}

return $updates;
}
);
}

/**
* Displays an admin notice about why the plugin is unable to load.
*
Expand Down
24 changes: 0 additions & 24 deletions beta-tester/amp-beta-tester.php

This file was deleted.

48 changes: 0 additions & 48 deletions beta-tester/includes/class-amp-beta-tester-plugin.php

This file was deleted.

108 changes: 0 additions & 108 deletions beta-tester/includes/class-autoloader.php

This file was deleted.

Empty file removed beta-tester/languages/.gitkeep
Empty file.

0 comments on commit 0c1cec2

Please sign in to comment.