Remove 'woocommerce_lock_down_admin' option and use filter only instead

This commit is contained in:
JeroenSormani 2017-11-19 14:17:37 +01:00
parent c4fe2927d7
commit b397b37b3e
2 changed files with 2 additions and 4 deletions

View File

@ -159,7 +159,7 @@ class WC_Admin {
public function prevent_admin_access() { public function prevent_admin_access() {
$prevent_access = false; $prevent_access = false;
if ( 'yes' === get_option( 'woocommerce_lock_down_admin', 'yes' ) && ! is_ajax() && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) { if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! is_ajax() && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) {
$has_cap = false; $has_cap = false;
$access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' ); $access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' );

View File

@ -17,14 +17,12 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from seeing the admin bar. * Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from seeing the admin bar.
* *
* Note: get_option( 'woocommerce_lock_down_admin', true ) is a deprecated option here for backwards compatibility. Defaults to true.
*
* @access public * @access public
* @param bool $show_admin_bar * @param bool $show_admin_bar
* @return bool * @return bool
*/ */
function wc_disable_admin_bar( $show_admin_bar ) { function wc_disable_admin_bar( $show_admin_bar ) {
if ( apply_filters( 'woocommerce_disable_admin_bar', get_option( 'woocommerce_lock_down_admin', 'yes' ) === 'yes' ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) { if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) {
$show_admin_bar = false; $show_admin_bar = false;
} }