__construct(); } function __construct(){ $mo = plugin_dir_path(__FILE__) . 'languages/' . $this->domain . '-' . get_locale() . '.mo'; load_textdomain($this->domain, $mo); add_action( 'admin_menu', array( &$this, 'plugin_menu_link' ) ); add_action( 'init', array(&$this, "plugin_init")); } function plugin_init(){ $this->settings = get_option( "admin_bar_settings" ); add_action( 'wp_head', array(&$this, 'advanced_admin_bar'), 11 ); if(isset($this->settings[ 'show_admin' ])){ if (!current_user_can('administrator') && !is_admin()) { add_action('get_header', array(&$this, 'remove_admin_login_header')); } }else{ if(isset($this->settings[ 'hide_admin_bar' ])){ add_action('get_header', array(&$this, 'remove_admin_login_header')); } } } function remove_admin_login_header() { remove_action('wp_head', '_admin_bar_bump_cb'); } function advanced_admin_bar() { $inactive = $this->settings[ 'inactive_opacity' ] == "" ? 30 : $this->settings[ 'inactive_opacity' ]; $active = $this->settings[ 'active_opacity' ] == "" ? 100 : $this->settings[ 'active_opacity' ]; $style = ''; if(isset($this->settings[ 'show_admin' ])){ if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); }else{ echo $style; } }else{ if(isset($this->settings[ 'hide_admin_bar' ])){ show_admin_bar(false); }else{ echo $style; } } } function filter_plugin_actions($links, $file) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); return $links; } function plugin_menu_link() { $this->plugin_admin_page = add_submenu_page( 'options-general.php', __( 'Better Admin Bar', $this->domain ), __( 'Better Admin Bar', $this->domain ), 'manage_options', basename(__FILE__), array( $this, 'admin_options_page' ) ); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this, 'filter_plugin_actions'), 10, 2 ); } function admin_options_page() { if ( get_current_screen()->id != $this->plugin_admin_page ) return; $this->settings = get_option( "admin_bar_settings" ); if(isset($_POST['plugin_sent'])){ $this->settings = $_POST; update_option( "admin_bar_settings", $this->settings ); } ?>
'.__( 'Settings saved.' ).'