Changeset 2366697 for display-environment-type
- Timestamp:
- 08/21/2020 05:13:06 PM (5 years ago)
- Location:
- display-environment-type
- Files:
-
- 6 added
- 2 edited
-
tags/1.2 (added)
-
tags/1.2/LICENSE (added)
-
tags/1.2/css (added)
-
tags/1.2/css/admin.css (added)
-
tags/1.2/display-environment-type.php (added)
-
tags/1.2/readme.txt (added)
-
trunk/display-environment-type.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
display-environment-type/trunk/display-environment-type.php
r2366476 r2366697 4 4 * Plugin URI: https://roytanck.com/2020/08/21/new-wordpress-plugin-display-environment-type/ 5 5 * Description: Display the site's environment type in wp-admin. 6 * Version: 1. 16 * Version: 1.2 7 7 * Requires at least: 5.5 8 8 * Requires PHP: 5.6 … … 94 94 */ 95 95 private function check_display() { 96 // Don't display if no user logged in. 97 if( ! is_user_logged_in() ) { 98 return false; 99 } 96 // Set the return value to the default (false). 97 $display = false; 100 98 // Always display if in wp-admin. 101 99 if( is_admin() ) { 102 return true; 100 $display = true; 101 } else { 102 // Display on the front-end only if user has certain capability. 103 if( is_user_logged_in() && current_user_can( 'manage_options' ) ) { 104 $display = true; 105 } 103 106 } 104 // Display on the front-end only if user has certain capability. 105 if( current_user_can( 'manage_options' ) ) { 106 return true; 107 } 108 // Default: false. 109 return false; 107 /** 108 * Filter whether or not the environent type should be displayed. 109 * 110 * Allows you to perform checks like user capabilities or is_admin() 111 * and return true to display the environment type, or false to not. 112 * 113 * @since 1.2 114 * 115 * @param boolean $display Should the environment type be displayed? 116 */ 117 $display = ( apply_filters( 'det_display_environment_type', $display ) === true ); 118 // Return the filtered boolean. 119 return $display; 110 120 } 111 121 -
display-environment-type/trunk/readme.txt
r2366476 r2366697 5 5 Tested up to: 5.5 6 6 Requires PHP: 5.6 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 License: GPLv3 9 9 10 Displays WordPress 5.5's new environment type setting in the admin bar and the 'at a glance' dashboard widget. 10 Displays WordPress 5.5's new environment type setting in the admin bar and the 'at a glance' dashboard widget. 11 11 12 12 == Description == … … 24 24 = Can I set custom color for my environment types? = 25 25 26 The colors a currently fixed. This was done to avoid possible confusion. If the colors were user-configurable, they would need to be set up exactly the same on all related servers.26 The colors are currently fixed. This was done to avoid possible confusion. If the colors were user-configurable, they would need to be set up exactly the same on all related servers. 27 27 28 28 = What will happen when I define custom environment types? = 29 29 30 Custom types will be displayed in blue, with a lightbulb icon. There's currently no way to set different colors for your custom types i syou have more than one.30 Custom types will be displayed in blue, with a lightbulb icon. There's currently no way to set different colors for your custom types if you have more than one. 31 31 32 32 = Why is there no display on the front-end of the site, for logged-in users with the admin bar enabled? = 33 33 34 There's no display for non-admin users. The reasoning behind this is that in most cases, you'd probably not want to bother logged-in subscribers with a bright-colored box in their admin bar. 34 There's no display for non-admin users. The reasoning behind this is that in most cases, you'd probably not want to bother logged-in subscribers with a bright-colored box on their admin bar. 35 36 For additional control, you can use the 'det_display_environment_type' filter hook: 37 38 function rt_det_display_filter( $display ){ 39 // Disable the environment type display for user ID 2. 40 return ( get_current_user_id() !== 2 ); 41 } 42 add_filter( 'det_display_environment_type', 'rt_det_display_filter' ); 35 43 36 44 == Screenshots == … … 40 48 41 49 == Changelog == 50 51 = 1.2 (2020-08-21) = 52 * Adds a filter hook to allow you to determine whether the environmment is displayed. 42 53 43 54 = 1.1 (2020-08-21) =
Note: See TracChangeset
for help on using the changeset viewer.