Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent plugin/theme installation from Admin UI #15

Open
gilzow opened this issue Jul 8, 2022 · 1 comment
Open

Prevent plugin/theme installation from Admin UI #15

gilzow opened this issue Jul 8, 2022 · 1 comment

Comments

@gilzow
Copy link
Contributor

gilzow commented Jul 8, 2022

What in this template can be improved or added as a feature?

Since application containers are read-only, any attempts to add plugins/themes via the admin UI will fail, and prompt the user for SFTP credentials. For users who are new to platform.sh, this can cause considerable confusion.

What exactly should be updated?

In wp-config.php, we should add

define('DISALLOW_FILE_MODS',true);

Which will disable the ability to add new plugins/themes, and removes the file editor. However, because this too can be a bit jarring to users new to Platform.sh, it's suggested we add a warning to the Plugin and Theme panels letting users know the "Add New" is unavailable due to the system being read-only. We can do this by adding in a must-use plugin that hooks to admin_notices.

The following is SAMPLE code on how we could accomplish this.

<?php
/**
 * Platform.sh Admin UI Plugin/Theme Notifier
 *
 * Plugin Name: Platform.sh Plugin/Theme Notifier
 * Plugin URI:  https://platform.sh/
 * Description: Displays a warning in the plugins, themes admin panels that adding new/updating themes is disabled.
 * Version:     0.1.0
 * Author:      Paul Gilzow, Platform.sh
 * Author URI:  https://github.com/platformsh
 * Tested up to: 6.0
 * Requires PHP: 5.2.4
 *
 */

if ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ) {
    add_action('admin_notices', function () {
        $panels = ['plugins','themes'];
        $screen = get_current_screen();
        if(in_array($screen->id, $panels)) {
            $notice = sprintf('<div class="notice notice-warning is-dismissible">
             <p>
                Due to how Platform.sh operates, adding new %1$s and updating %1$s from this admin panel have been disabled. 
                Please see <a href="https://docs.platform.sh/guides/wordpress/composer.html">this document</a> for additional information.  
             </p>
         </div>', $screen->id);
            echo $notice;
        }
    });
}

It was suggested that we improve the language in the notice a bit more before implementing.

Example screen shots:
Plugins:
Screen Shot 2022-07-08 at 12 56 20 PM

Themes:
Screen Shot 2022-07-08 at 12 57 03 PM

How important is this feature to you?

Adding this new feature will help alleviate new customer frustration, and get relevant information to them earlier in the process of their exploration of Platform.sh

Additional context

No response

@gilzow
Copy link
Contributor Author

gilzow commented Jul 8, 2022

@chadwcarlson, ori said we need to redo the wording. Who should I talk to for improvements on the wording?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant