Skip to content

Commit ed74be0

Browse files
committed
fix(style): fix highlighting text problem on Chrome
Adds styling to admin bar that fixes highlighting text problem in block editor on Chrome latest version
1 parent 45adf01 commit ed74be0

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?php
2+
/**
3+
* WP_MS_Networks_Admin_Bar class
4+
*
5+
* @package WPMN
6+
* @since 2.2.0
7+
*/
8+
9+
// Exit if accessed directly.
10+
defined( 'ABSPATH' ) || exit;
11+
12+
/**
13+
* Class for integrating with the admin bar.
14+
*
15+
* @since 2.2.0
16+
*/
17+
class WP_MS_Networks_Admin_Bar {
18+
19+
/**
20+
* Constructor.
21+
*
22+
* Hooks in the necessary methods.
23+
*
24+
* @since 2.2.0
25+
*/
26+
public function __construct() {
27+
add_action( 'admin_bar_menu', array( $this, 'admin_bar' ), 20 );
28+
29+
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
30+
add_action( 'wp_print_styles', array( $this, 'admin_print_styles' ) );
31+
}
32+
33+
/**
34+
* Adds networking icon to admin bar network menu item.
35+
*
36+
* This is done inline to avoid registering a separate CSS file for just an
37+
* icon in the menu bar.
38+
*
39+
* @since 2.2.0
40+
*/
41+
public function admin_print_styles() {
42+
?>
43+
<style type="text/css">
44+
#wpadminbar #wp-admin-bar-my-networks > .ab-item:first-child:before {
45+
content: "\f325";
46+
top: 3px;
47+
}
48+
.block-editor-block-list__layout::selection {
49+
background: green !important;
50+
}
51+
</style>
52+
<?php
53+
}
54+
55+
/**
56+
* Outputs the admin bar menu items.
57+
*
58+
* @since 2.2.0
59+
*
60+
* @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
61+
*/
62+
public function admin_bar( $wp_admin_bar ) {
63+
64+
// Bail if logged out user or single site mode.
65+
if ( ! is_user_logged_in() || ! is_multisite() ) {
66+
return;
67+
}
68+
69+
$networks = user_has_networks();
70+
71+
// Bail if user does not have networks or they can't manage networks.
72+
if ( empty( $networks ) || ! current_user_can( 'manage_networks' ) ) {
73+
return;
74+
}
75+
76+
$wp_admin_bar->add_menu( array(
77+
'id' => 'my-networks',
78+
'title' => __( 'My Networks', 'wp-multi-network' ),
79+
'href' => network_admin_url( 'admin.php?page=networks' ),
80+
'meta' => array(
81+
'class' => 'networks-parent',
82+
),
83+
) );
84+
85+
foreach ( $networks as $network_id ) {
86+
$network = get_network( $network_id );
87+
if ( ! $network ) {
88+
continue;
89+
}
90+
91+
switch_to_network( $network_id );
92+
93+
if ( ! current_user_can( 'manage_network' ) ) {
94+
restore_current_network();
95+
continue;
96+
}
97+
98+
$wp_admin_bar->add_group( array(
99+
'parent' => 'my-networks',
100+
'id' => 'group-network-admin-' . $network_id,
101+
) );
102+
103+
$wp_admin_bar->add_menu( array(
104+
'parent' => 'group-network-admin-' . $network_id,
105+
'id' => 'network-admin-' . $network_id,
106+
'title' => $network->site_name,
107+
'href' => network_admin_url(),
108+
) );
109+
110+
$wp_admin_bar->add_menu( array(
111+
'parent' => 'network-admin-' . $network_id,
112+
'id' => 'network-admin-d',
113+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
114+
'title' => __( 'Dashboard' ),
115+
'href' => network_admin_url(),
116+
) );
117+
118+
if ( current_user_can( 'manage_sites' ) ) {
119+
$wp_admin_bar->add_menu( array(
120+
'parent' => 'network-admin-' . $network_id,
121+
'id' => 'network-admin-s' . $network_id,
122+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
123+
'title' => __( 'Sites' ),
124+
'href' => network_admin_url( 'sites.php' ),
125+
) );
126+
}
127+
128+
if ( current_user_can( 'manage_network_users' ) ) {
129+
$wp_admin_bar->add_menu( array(
130+
'parent' => 'network-admin-' . $network_id,
131+
'id' => 'network-admin-u' . $network_id,
132+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
133+
'title' => __( 'Users' ),
134+
'href' => network_admin_url( 'users.php' ),
135+
) );
136+
}
137+
138+
if ( current_user_can( 'manage_network_themes' ) ) {
139+
$wp_admin_bar->add_menu( array(
140+
'parent' => 'network-admin-' . $network_id,
141+
'id' => 'network-admin-t' . $network_id,
142+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
143+
'title' => __( 'Themes' ),
144+
'href' => network_admin_url( 'themes.php' ),
145+
) );
146+
}
147+
148+
if ( current_user_can( 'manage_network_plugins' ) ) {
149+
$wp_admin_bar->add_menu( array(
150+
'parent' => 'network-admin-' . $network_id,
151+
'id' => 'network-admin-p' . $network_id,
152+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
153+
'title' => __( 'Plugins' ),
154+
'href' => network_admin_url( 'plugins.php' ),
155+
) );
156+
}
157+
158+
if ( current_user_can( 'manage_network_options' ) ) {
159+
$wp_admin_bar->add_menu( array(
160+
'parent' => 'network-admin-' . $network_id,
161+
'id' => 'network-admin-o' . $network_id,
162+
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
163+
'title' => __( 'Settings' ),
164+
'href' => network_admin_url( 'settings.php' ),
165+
) );
166+
}
167+
168+
restore_current_network();
169+
}
170+
}
171+
}

0 commit comments

Comments
 (0)