- fixed replacing placeholders in nav menus. Used an earlier hook for filtering items before generating HTML and avoided issues with raw, not-escaped HTML inside tags' attributes

This commit is contained in:
Nikita Sinelnikov
2021-12-15 03:30:34 +02:00
parent 601c75ad92
commit ea8ce49698
2 changed files with 46 additions and 26 deletions
+36 -24
View File
@@ -1,30 +1,42 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Add dynamic profile headers
*
* @param $items
* @param $args
*
* @return mixed
*/
function um_add_custom_message_to_menu( $items, $args ) {
if ( ! is_user_logged_in() ) {
$items = UM()->shortcodes()->convert_user_tags( $items );
return $items;
}
um_fetch_user( get_current_user_id() );
$items = UM()->shortcodes()->convert_user_tags( $items );
um_reset_user();
return $items;
}
add_filter( 'wp_nav_menu_items', 'um_add_custom_message_to_menu', 10, 2 );
if ( ! is_admin() ) {
/**
* Add dynamic profile headers
*
* @param array $sorted_menu_items
* @param \stdClass $args
*
* @return array
*/
function um_add_custom_message_to_menu( $sorted_menu_items, $args ) {
if ( is_user_logged_in() ) {
um_fetch_user( get_current_user_id() );
}
foreach ( $sorted_menu_items as &$menu_item ) {
if ( $menu_item->title ) {
$menu_item->title = UM()->shortcodes()->convert_user_tags( $menu_item->title );
}
if ( $menu_item->attr_title ) {
$menu_item->attr_title = UM()->shortcodes()->convert_user_tags( $menu_item->attr_title );
}
if ( $menu_item->description ) {
$menu_item->description = UM()->shortcodes()->convert_user_tags( $menu_item->description );
}
}
if ( is_user_logged_in() ) {
um_reset_user();
}
return $sorted_menu_items;
}
add_filter( 'wp_nav_menu_objects', 'um_add_custom_message_to_menu', 9999, 2 );
/**
* Conditional menu items
*
@@ -141,4 +153,4 @@ if ( ! is_admin() ) {
return um_conditional_nav_menu( $items, $args );
}
add_filter( 'wp_get_nav_menu_items', 'um_get_nav_menu_items', 9999, 3 );
}
}
+10 -2
View File
@@ -155,7 +155,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
= 2.3.0: December xx, 2021 =
= 2.3.0: December 16, 2021 =
* Enhancements:
@@ -171,13 +171,21 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
- Fixed: "Clear All" button for the filters with "&" symbol in the label.
- Fixed: Uninstall process when delete UM data. Avoid the issue when 3rd-party pages that had been selected as UM page are removed on UM uninstall.
- Fixed: Header meta for the Twitter Card. If the user has twitter field filled then <meta name="twitter:site"> will be filled by this value.
- Fixed: Member directory a slider filter's label displaying. It uses the filed label for now.
- Fixed: Member directory a slider filter's label displaying. It uses the filled label for now.
- Fixed: SkypeID field validation. Also all SkypeID fields on your forms changed type from `url` to `text`. SkypeID supports nicknames or https://join.skype.com/{hash} links.
- Fixed: Some typos in the fields' labels.
- Fixed: "false" display name in the member directory. It displays empty for now if the user hasn't display name.
- Fixed: `UM()->clean_array()` function.
- Fixed: LinkedIn field URL. Added ability to display the organization URL.
- Fixed: Canonical link of the user profile if WPML plugin is active.
- Fixed: Replacing placeholders in nav menus. Used an earlier hook for filtering items before generating HTML and avoided issues with raw, not-escaped HTML inside tags' attributes.
* Templates required update:
- members-grid.php
- members-list.php
- password-reset.php
* Cached and optimized/minified assets(JS/CSS) must be flushed/re-generated after upgrade
= 2.2.5: September 22, 2021 =