wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_admin_bar_wp_menu › WordPress Function

Seit3.3.0
Veraltetn/v
wp_admin_bar_wp_menu ( $wp_admin_bar )
Parameter:
  • (WP_Admin_Bar) $wp_admin_bar The WP_Admin_Bar instance.
    Erforderlich: Ja
Definiert in:
Codex:

Adds the WordPress logo menu.



Quellcode

function wp_admin_bar_wp_menu( $wp_admin_bar ) {
	if ( current_user_can( 'read' ) ) {
		$about_url      = self_admin_url( 'about.php' );
		$contribute_url = self_admin_url( 'contribute.php' );
	} elseif ( is_multisite() ) {
		$about_url      = get_dashboard_url( get_current_user_id(), 'about.php' );
		$contribute_url = get_dashboard_url( get_current_user_id(), 'contribute.php' );
	} else {
		$about_url      = false;
		$contribute_url = false;
	}

	$wp_logo_menu_args = array(
		'id'    => 'wp-logo',
		'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' .
				/* translators: Hidden accessibility text. */
				__( 'About WordPress' ) .
			'</span>',
		'href'  => $about_url,
		'meta'  => array(
			'menu_title' => __( 'About WordPress' ),
		),
	);

	// Set tabindex="0" to make sub menus accessible when no URL is available.
	if ( ! $about_url ) {
		$wp_logo_menu_args['meta'] = array(
			'tabindex' => 0,
		);
	}

	$wp_admin_bar->add_node( $wp_logo_menu_args );

	if ( $about_url ) {
		// Add "About WordPress" link.
		$wp_admin_bar->add_node(
			array(
				'parent' => 'wp-logo',
				'id'     => 'about',
				'title'  => __( 'About WordPress' ),
				'href'   => $about_url,
			)
		);
	}

	if ( $contribute_url ) {
		// Add contribute link.
		$wp_admin_bar->add_node(
			array(
				'parent' => 'wp-logo',
				'id'     => 'contribute',
				'title'  => __( 'Get Involved' ),
				'href'   => $contribute_url,
			)
		);
	}

	// Add WordPress.org link.
	$wp_admin_bar->add_node(
		array(
			'parent' => 'wp-logo-external',
			'id'     => 'wporg',
			'title'  => __( 'WordPress.org' ),
			'href'   => __( 'https://wordpress.org/' ),
		)
	);

	// Add documentation link.
	$wp_admin_bar->add_node(
		array(
			'parent' => 'wp-logo-external',
			'id'     => 'documentation',
			'title'  => __( 'Documentation' ),
			'href'   => __( 'https://wordpress.org/documentation/' ),
		)
	);

	// Add learn link.
	$wp_admin_bar->add_node(
		array(
			'parent' => 'wp-logo-external',
			'id'     => 'learn',
			'title'  => __( 'Learn WordPress' ),
			'href'   => __( 'https://learn.wordpress.org/' ),
		)
	);

	// Add forums link.
	$wp_admin_bar->add_node(
		array(
			'parent' => 'wp-logo-external',
			'id'     => 'support-forums',
			'title'  => __( 'Support' ),
			'href'   => __( 'https://wordpress.org/support/forums/' ),
		)
	);

	// Add feedback link.
	$wp_admin_bar->add_node(
		array(
			'parent' => 'wp-logo-external',
			'id'     => 'feedback',
			'title'  => __( 'Feedback' ),
			'href'   => __( 'https://wordpress.org/support/forum/requests-and-feedback' ),
		)
	);
}