-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a more meaningful notice when trying to install WP plugin in Git…
… mode. For more information, see https://pantheon.io/docs/start-states/wordpress#20220606-1
- Loading branch information
John Spellman
authored and
Pantheon Automation
committed
Jul 12, 2022
1 parent
ee3b1d9
commit d1ff5a1
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
wp-content/mu-plugins/pantheon/pantheon-plugin-install-notice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* If a Pantheon site is in Git mode, hide the Plugin installation functionality and show a notice. | ||
*/ | ||
|
||
if ( ! wp_is_writable( WP_PLUGIN_DIR ) ) { | ||
if ( ! defined( 'DISALLOW_FILE_MODS' ) ) { | ||
define( 'DISALLOW_FILE_MODS', true ); | ||
} | ||
|
||
add_action( 'admin_notices', '_pantheon_plugin_install_notice' ); | ||
add_action( 'network_admin_notices', '_pantheon_plugin_install_notice' ); | ||
} | ||
|
||
function _pantheon_plugin_install_notice() { | ||
$screen = get_current_screen(); | ||
// Only show this notice on the plugins page. | ||
if ( 'plugins' === $screen->id || 'plugins-network' === $screen->id ) { ?> | ||
<div class="update-nag notice notice-warning is-dismissible" style="margin: 5px 6em 15px 0;"> | ||
<p style="font-size: 14px; margin: 0;"> | ||
<?php | ||
// Translators: %s is a URL to the user's Pantheon Dashboard. | ||
echo wp_kses_post( sprintf( __( 'If you wish to update or add plugins using the WordPress UI, switch your site to SFTP mode from <a href="%s">your Pantheon dashboard</a>.', 'pantheon-systems' ), 'https://dashboard.pantheon.io/sites/' . $_ENV['PANTHEON_SITE'] ) ); | ||
?> | ||
</p> | ||
</div> | ||
<?php | ||
} | ||
} |