Website Summary Files Commits Branches @commit @diff @stats
path: root / wp-content / themes / carmag / functions.php
diff options
context:
space:
mode:
Commitb731b4a319e5e9e3f7f1263d43bf9c157c90d23f (patch)
Author
 Ivan Dimitrov <ivan.dimitrov293@gmail.com>
2020-07-13 17:49:49 +0300
Committer
 Ivan Dimitrov <ivan.dimitrov293@gmail.com>
2020-07-13 17:49:49 +0300
Files2fe7a7332e26b5dd08af2f8fb7f829e50b4f6473 /wp-content/themes/carmag/functions.php
tues-interns-2020-feature/header.tar
tues-interns-2020-feature/header.tar.gz
tues-interns-2020-feature/header.zip
Parent13e4865311b884fe6050bf6187ff2124c5c74ff0 (diff)
[Update] Added 'profile' menu when the user is logged in feature/header
1 files changed, 13 insertions, 2 deletions
-rw-r--r--wp-content/themes/carmag/functions.php15
diff --git a/wp-content/themes/carmag/functions.php b/wp-content/themes/carmag/functions.php
index c40a666..5e52ddf 100644
--- a/wp-content/themes/carmag/functions.php
+++ b/wp-content/themes/carmag/functions.php
@@ -92,8 +92,19 @@ function carmag_setup() {
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
- 'primary' => esc_html__( 'Primary', 'carmag' ),
- ) );
+ 'primary' => esc_html__( 'Primary', 'carmag' ),
+ 'profile' => esc_html__( 'Profile', 'carmag' ),
+ ) );
+ add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
+ function my_dynamic_menu_items( $menu_items ) {
+ foreach ( $menu_items as $menu_item ) {
+ if ( strpos($menu_item->title, '#profile_name#') !== false) {
+ $menu_item->title = str_replace("#profile_name#", wp_get_current_user()->display_name, $menu_item->title);
+ }
+ }
+
+ return $menu_items;
+ }
/*
* Switch default core markup for search form, comment form, and comments