wp/wp-includes/admin-bar.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   129 		$about_url = false;
   129 		$about_url = false;
   130 	}
   130 	}
   131 
   131 
   132 	$wp_logo_menu_args = array(
   132 	$wp_logo_menu_args = array(
   133 		'id'    => 'wp-logo',
   133 		'id'    => 'wp-logo',
   134 		'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
   134 		'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
   135 		'href'  => $about_url,
   135 		'href'  => $about_url,
   136 	);
   136 	);
   137 
   137 
   138 	// Set tabindex="0" to make sub menus accessible when no URL is available.
   138 	// Set tabindex="0" to make sub menus accessible when no URL is available.
   139 	if ( ! $about_url ) {
   139 	if ( ! $about_url ) {
   164 			'title'  => __( 'WordPress.org' ),
   164 			'title'  => __( 'WordPress.org' ),
   165 			'href'   => __( 'https://wordpress.org/' ),
   165 			'href'   => __( 'https://wordpress.org/' ),
   166 		)
   166 		)
   167 	);
   167 	);
   168 
   168 
   169 	// Add Codex link.
   169 	// Add documentation link.
   170 	$wp_admin_bar->add_node(
   170 	$wp_admin_bar->add_node(
   171 		array(
   171 		array(
   172 			'parent' => 'wp-logo-external',
   172 			'parent' => 'wp-logo-external',
   173 			'id'     => 'documentation',
   173 			'id'     => 'documentation',
   174 			'title'  => __( 'Documentation' ),
   174 			'title'  => __( 'Documentation' ),
   175 			'href'   => __( 'https://codex.wordpress.org/' ),
   175 			'href'   => __( 'https://wordpress.org/support/' ),
   176 		)
   176 		)
   177 	);
   177 	);
   178 
   178 
   179 	// Add forums link.
   179 	// Add forums link.
   180 	$wp_admin_bar->add_node(
   180 	$wp_admin_bar->add_node(
   181 		array(
   181 		array(
   182 			'parent' => 'wp-logo-external',
   182 			'parent' => 'wp-logo-external',
   183 			'id'     => 'support-forums',
   183 			'id'     => 'support-forums',
   184 			'title'  => __( 'Support' ),
   184 			'title'  => __( 'Support' ),
   185 			'href'   => __( 'https://wordpress.org/support/' ),
   185 			'href'   => __( 'https://wordpress.org/support/forums/' ),
   186 		)
   186 		)
   187 	);
   187 	);
   188 
   188 
   189 	// Add feedback link.
   189 	// Add feedback link.
   190 	$wp_admin_bar->add_node(
   190 	$wp_admin_bar->add_node(
   207 function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
   207 function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
   208 	if ( is_admin() ) {
   208 	if ( is_admin() ) {
   209 		$wp_admin_bar->add_node(
   209 		$wp_admin_bar->add_node(
   210 			array(
   210 			array(
   211 				'id'    => 'menu-toggle',
   211 				'id'    => 'menu-toggle',
   212 				'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
   212 				'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
   213 				'href'  => '#',
   213 				'href'  => '#',
   214 			)
   214 			)
   215 		);
   215 		);
   216 	}
   216 	}
   217 }
   217 }
   580 	);
   580 	);
   581 
   581 
   582 	foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
   582 	foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
   583 		switch_to_blog( $blog->userblog_id );
   583 		switch_to_blog( $blog->userblog_id );
   584 
   584 
   585 		$blavatar = '<div class="blavatar"></div>';
   585 		if ( has_site_icon() ) {
       
   586 			$blavatar = sprintf(
       
   587 				'<img class="blavatar" src="%s" srcset="%s 2x" alt="" width="16" height="16" />',
       
   588 				esc_url( get_site_icon_url( 16 ) ),
       
   589 				esc_url( get_site_icon_url( 32 ) )
       
   590 			);
       
   591 		} else {
       
   592 			$blavatar = '<div class="blavatar"></div>';
       
   593 		}
   586 
   594 
   587 		$blogname = $blog->blogname;
   595 		$blogname = $blog->blogname;
   588 
   596 
   589 		if ( ! $blogname ) {
   597 		if ( ! $blogname ) {
   590 			$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
   598 			$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
   685 
   693 
   686 /**
   694 /**
   687  * Provide an edit link for posts and terms.
   695  * Provide an edit link for posts and terms.
   688  *
   696  *
   689  * @since 3.1.0
   697  * @since 3.1.0
       
   698  * @since 5.5.0 Added a "View Post" link on Comments screen for a single post.
   690  *
   699  *
   691  * @global WP_Term  $tag
   700  * @global WP_Term  $tag
   692  * @global WP_Query $wp_the_query WordPress Query object.
   701  * @global WP_Query $wp_the_query WordPress Query object.
   693  * @global int      $user_id      The ID of the user being edited. Not to be confused with the
   702  * @global int      $user_id      The ID of the user being edited. Not to be confused with the
   694  *                                global $user_ID, which contains the ID of the current user.
   703  *                                global $user_ID, which contains the ID of the current user.
   876 
   885 
   877 	if ( ! $actions ) {
   886 	if ( ! $actions ) {
   878 		return;
   887 		return;
   879 	}
   888 	}
   880 
   889 
   881 	$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
   890 	$title = '<span class="ab-icon" aria-hidden="true"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
   882 
   891 
   883 	$wp_admin_bar->add_node(
   892 	$wp_admin_bar->add_node(
   884 		array(
   893 		array(
   885 			'id'    => 'new-content',
   894 			'id'    => 'new-content',
   886 			'title' => $title,
   895 			'title' => $title,
   920 		/* translators: %s: Number of comments. */
   929 		/* translators: %s: Number of comments. */
   921 		_n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
   930 		_n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
   922 		number_format_i18n( $awaiting_mod )
   931 		number_format_i18n( $awaiting_mod )
   923 	);
   932 	);
   924 
   933 
   925 	$icon   = '<span class="ab-icon"></span>';
   934 	$icon   = '<span class="ab-icon" aria-hidden="true"></span>';
   926 	$title  = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
   935 	$title  = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
   927 	$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
   936 	$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
   928 
   937 
   929 	$wp_admin_bar->add_node(
   938 	$wp_admin_bar->add_node(
   930 		array(
   939 		array(
  1030 
  1039 
  1031 	if ( ! $update_data['counts']['total'] ) {
  1040 	if ( ! $update_data['counts']['total'] ) {
  1032 		return;
  1041 		return;
  1033 	}
  1042 	}
  1034 
  1043 
  1035 	$title  = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
  1044 	$updates_text = sprintf(
  1036 	$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
  1045 		/* translators: %s: Total number of updates available. */
       
  1046 		_n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
       
  1047 		number_format_i18n( $update_data['counts']['total'] )
       
  1048 	);
       
  1049 
       
  1050 	$icon   = '<span class="ab-icon" aria-hidden="true"></span>';
       
  1051 	$title  = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
       
  1052 	$title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';
  1037 
  1053 
  1038 	$wp_admin_bar->add_node(
  1054 	$wp_admin_bar->add_node(
  1039 		array(
  1055 		array(
  1040 			'id'    => 'updates',
  1056 			'id'    => 'updates',
  1041 			'title' => $title,
  1057 			'title' => $icon . $title,
  1042 			'href'  => network_admin_url( 'update-core.php' ),
  1058 			'href'  => network_admin_url( 'update-core.php' ),
  1043 			'meta'  => array(
       
  1044 				'title' => $update_data['title'],
       
  1045 			),
       
  1046 		)
  1059 		)
  1047 	);
  1060 	);
  1048 }
  1061 }
  1049 
  1062 
  1050 /**
  1063 /**
  1060 	}
  1073 	}
  1061 
  1074 
  1062 	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
  1075 	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
  1063 	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
  1076 	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
  1064 	$form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>';
  1077 	$form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>';
  1065 	$form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '"/>';
  1078 	$form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '" />';
  1066 	$form .= '</form>';
  1079 	$form .= '</form>';
  1067 
  1080 
  1068 	$wp_admin_bar->add_node(
  1081 	$wp_admin_bar->add_node(
  1069 		array(
  1082 		array(
  1070 			'parent' => 'top-secondary',
  1083 			'parent' => 'top-secondary',