Support » Plugin: WP ULike » Blank notifications title (meta-bug-report)

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Alimir

    (@alimir)

    Hi @richardfoley
    I apologize for the delay.
    I want to solve this problem once and for all, But I need to test this in a troubled system! Can you provide me with an online link with the permission to modify and test plugin codes?

    hi @alimir,
    great to hear you have some time to look into this. Having looked into it some more, I’m beginning to think it might be not entirely your plugin, I’ll explain.

    After some plugin updates on my site, it transpired that switching the AnsPress plugin on/off, affected the *same* blank notifications. Also, switching your WP-Ulike plugin on/off no longer produced the blank notifications. Therefore, for me, the problem has temporarily gone away, much to the relief of my social media network site members.

    What this additionally demonstrated to me was that the database interactions, and data, appear to all be correct, and the issue is in the *display* of the notifications. So my thought was that perhaps something is switching either the visibility of the notifications off, *or* the DOM is perhaps being manipulated somehow to remove elements on the page.

    If I discover more, I’ll post here.

    R.

    • This reply was modified 9 months, 1 week ago by  Richard Foley.

    This is really a Buddypress issue it seems. We experienced the same problem. If you can resolve it would be great.

    Plugin Author Alimir

    (@alimir)

    @richardfoley Yes, this problem is returns to a BuddyPress hook, which has caused this problem for many other plugins.
    Anyway, I wrote today a new code for this section, which I put under this post. Hope you can test it.

    path: inc/genral-hooks.php

    	if( ! function_exists( 'wp_ulike_format_buddypress_notifications' ) ){
    		function wp_ulike_format_buddypress_notifications( $content, $item_id, $secondary_item_id, $total_items, $format = 'string', $action, $component ) {
    			global $wp_filter,$wp_version;
    
    			if ( strpos( $action, 'wp_ulike_' ) !== false ) {
    				$custom_link	= '';
    				//Extracting ulike type from the action value.
    				preg_match('/wp_ulike_(.*?)_action/', $action, $type);
    			    //Extracting user id from old action name values.
    			    preg_match('/action_([0-9]+)/', $action, $user_ID);
    				//Get user info
    				$user_ID     = isset( $user_ID[1] ) ? $user_ID[1] : $secondary_item_id;
    				$user_info   = get_userdata( $user_ID );
    				$custom_text = sprintf( __('You have a new like %s', WP_ULIKE_SLUG ), is_object( $user_info ) ? __( 'from' , WP_ULIKE_SLUG ) . ' ' . $user_info->display_name : '' );
    
    				//checking the ulike types
    				switch ( $type[1] ) {
    					case 'commentliked':
    						$custom_link = get_comment_link( $item_id );
    						break;
    
    					case 'activityliked':
    						$custom_link = bp_activity_get_permalink( $item_id );
    						break;
    
    					default:
    						$custom_link = get_permalink($item_id);
    						break;
    				}
    
    				// WordPress Toolbar
    				if ( 'string' === $format ) {
    					$content = apply_filters( 'wp_ulike_bp_notifications_template', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_text ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
    				// Deprecated BuddyBar
    				} else {
    					$content = apply_filters( 'wp_ulike_bp_notifications_template', array(
    						'text' => $custom_text,
    						'link' => $custom_link
    					), $custom_link, (int) $total_items, $custom_text, $custom_text );
    				}
    				// global wp_filter to call bbPress wrapper function
    				if( isset( $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications'] ) ) {
    					if( version_compare( $wp_version, '4.7', '>=' ) ) {
    						// https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
    						$wp_filter['bp_notifications_get_notifications_for_user']->callbacks[10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
    					} else {
    						$wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications']['function'] = 'wp_ulike_bbp_format_buddypress_notifications';
    					}
    				}
    
    				return $content;
    			}
    
    			return $content;
    		}
    		add_filter( 'bp_notifications_get_notifications_for_user', 'wp_ulike_format_buddypress_notifications', 25, 7 );
    	}
    Plugin Author Alimir

    (@alimir)

    @kevlew Can you test the code above?

    I will test later today, no problem.

    Will this do anything for the issue with notifications (not blank) failing to clear? The user can delete them, but as soon as the page is refreshed, they’re all back again. Some users have hundreds of notifications due to this issue.

    Thanks!

    @jguenther, please don’t hijack unrelated threads, as this just serves to confuse everybody. This thread is for BLANK notifications, as the title and the tags make clear. Many thanks.

    @richardfoley I would say a notification issue IS related. Perhaps in the future, you might want to omit the comma from your tags. “Blank notifications” would have been more appropriate. Many sorries.

    hallo Alimir and Rahul,

    after further investigation I can confirm that the issue on *my* site was exacerbated by a combination of using buddyPress with both the uLike plugin and the ansPress plugin. When I commented out the line in the ansPress plugin as follows, the blank notifications simply reappeared. This confirms it has nothing to do with any posting, and is a display issue. Here’s the culprit:

    // wp-content/plugins/anspress-question-answer/addons/buddypress/buddypress.php
    // line 60
    //
    // anspress()->add_action( ‘bp_notifications_get_notifications_for_user’, $this, ‘notifications_for_user’, 10, 8 );

    ps. I’m cross-posting this to both plugins because both plugins use this function, and that might make it easier for you 2 to fix this blank notifications issue with buddypress, it seems to be a recurring and long-running issue.

    https://wordpress.org/support/topic/blank-notifications-title-meta-bug-report-2/

    Cheers R.

    • This reply was modified 8 months, 4 weeks ago by  Richard Foley.
    Plugin Author Alimir

    (@alimir)

    @richardfoley I fully examined the problems in this section and will make a lot of changes in the next update. :))

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Blank notifications title (meta-bug-report)’ is closed to new replies.