|
22 | 22 | } |
23 | 23 |
|
24 | 24 | add_action('admin_notices', function () { |
25 | | - if (defined('WP_ENV') && WP_ENV) { |
26 | | - $wp_env = WP_ENV; |
27 | | - } else if (function_exists('wp_get_environment_type')) { |
28 | | - $wp_env = wp_get_environment_type(); |
29 | | - } else { |
30 | | - $wp_env = null; |
| 25 | + $env = defined('WP_ENV') && WP_ENV ? WP_ENV : null; |
| 26 | + |
| 27 | + if (!$env && function_exists('wp_get_environment_type')) { |
| 28 | + $env = wp_get_environment_type(); |
31 | 29 | } |
32 | 30 |
|
33 | | - $wp_env = apply_filters('roots/bedrock/disallow_indexing_environment_type', $wp_env); |
34 | | - if ($wp_env) { |
35 | | - $message = sprintf( |
36 | | - __('%1$s Search engine indexing has been discouraged because the current environment is %2$s.', 'roots'), |
37 | | - '<strong>Bedrock:</strong>', |
38 | | - '<code>'.$wp_env.'</code>' |
39 | | - ); |
40 | | - } else { |
41 | | - $message = sprintf( |
42 | | - __('%1$s Search engine indexing has been discouraged.', 'roots'), |
43 | | - '<strong>Bedrock:</strong>' |
| 31 | + $env = apply_filters('roots/bedrock/disallow_indexing_environment_type', $env); |
| 32 | + |
| 33 | + if (!$env) { |
| 34 | + printf( |
| 35 | + '<div class="notice notice-warning"><p>%s</p></div>', |
| 36 | + sprintf( |
| 37 | + /* translators: %s: Bedrock prefix. */ |
| 38 | + __('%s Search engine indexing has been discouraged.', 'roots'), |
| 39 | + '<strong>Bedrock:</strong>' |
| 40 | + ) |
44 | 41 | ); |
| 42 | + return; |
45 | 43 | } |
46 | 44 |
|
47 | | - echo "<div class='notice notice-warning'><p>{$message}</p></div>"; |
| 45 | + printf( |
| 46 | + '<div class="notice notice-warning"><p>%s</p></div>', |
| 47 | + sprintf( |
| 48 | + /* translators: 1: Bedrock prefix, 2: Environment type. */ |
| 49 | + __('%1$s Search engine indexing has been discouraged because the current environment is %2$s.', 'roots'), |
| 50 | + '<strong>Bedrock:</strong>', |
| 51 | + '<code>' . $env . '</code>' |
| 52 | + ) |
| 53 | + ); |
48 | 54 | }); |
49 | 55 | }); |
0 commit comments