Skip to content

Commit c041aeb

Browse files
committed
Add a notice about installing themes or plugins
1 parent dc1876f commit c041aeb

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

wp/wp-content/mu-plugins/serverlesswp.php

+40-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,45 @@
55
Plugin URI: https://github.com/mitchmac/serverlesswp
66
Description: Plugin that makes sure your site runs smoothly on Vercel or Netlify.
77
Author: Mitch MacKenzie
8-
Version: 1.0.0
8+
Version: 1.0.1
99
*/
1010

11-
add_filter( 'got_url_rewrite', '__return_true' );
11+
// WordPress doesn't know that serverlesswp-node emulates typical mod_rewrite behaviour.
12+
add_filter( 'got_url_rewrite', '__return_true' );
13+
14+
15+
// A notice to let people know they can't directly install themes.
16+
function serverlesswp_theme_install_notice() {
17+
global $pagenow;
18+
$pages = ['themes.php'];
19+
if (is_admin() && in_array($pagenow, $pages)) {
20+
?>
21+
<div class="notice notice-info">
22+
<h2><?php _e( 'Want to add a theme?', 'serverlesswp' ); ?></h2>
23+
<p><?php _e( 'Direct theme installation is not currently possible with serverless functions. You can still add themes to your site though!', 'serverlesswp' ); ?></p>
24+
<p><?php _e( '<a href="https://github.com/mitchmac/ServerlessWP/discussions/35">Learn how to add themes to your site\'s git repository.</a>', 'serverlesswp' ); ?></p>
25+
</div>
26+
<?php
27+
}
28+
}
29+
30+
// Register the notice action.
31+
add_action('admin_notices', 'serverlesswp_theme_install_notice');
32+
33+
// A notice to let people know they can't directly install themes.
34+
function serverlesswp_plugin_install_notice() {
35+
global $pagenow;
36+
$pages = ['plugin-install.php', 'plugins.php'];
37+
if (is_admin() && in_array($pagenow, $pages)) {
38+
?>
39+
<div class="notice notice-info">
40+
<h2><?php _e( 'Want to add a plugin?', 'serverlesswp' ); ?></h2>
41+
<p><?php _e( 'Direct plugin installation is not currently possible with serverless functions. You can still add plugins to your site though!', 'serverlesswp' ); ?></p>
42+
<p><?php _e( '<a href="https://github.com/mitchmac/ServerlessWP/discussions/35">Learn how to add plugins to your site\'s git repository.</a>', 'serverlesswp' ); ?></p>
43+
</div>
44+
<?php
45+
}
46+
}
47+
48+
// Register the notice action.
49+
add_action('admin_notices', 'serverlesswp_plugin_install_notice');

0 commit comments

Comments
 (0)