Notifications
Clear all

wpForo 1.x.x [Solved] How to add an attribute to an anchor tag

11 Posts
2 Users
0 Reactions
987 Views
Posts: 38
Topic starter
(@pyue6299)
Trusted Member
Joined: 5 years ago

Hi there, 

I would like to amend the following files:

/home/jdclab/public_html/wp-content/plugins/wpforo/wpf-includes/class-activity.php

by adding an attribute (a class) to an anchor tag.

I tried to use child theme and implement the /class-activity.php/ file to public_html/wp-content/themes/ion-ap3-child/wpforo/wpf-includes/, but no use.

I tried to us js in function by adding the following code to my function.php, but no use:

<script>

jQuery(document).on('ready', function() {
jQuery(".wpf-notification-content a").attr('class', 'push-page'); });

</script>

Can you suggest me a way?

Thanks

Patrick

10 Replies
Robert
Posts: 10591
Admin
(@robert)
Support Team
Joined: 9 years ago

Hi @pyue6299,

The correct and update-safe way to customize wpForo template file is this:

https://wpforo.com/docs/root/forum-themes/theme-customization/

Posts: 38
Topic starter
(@pyue6299)
Trusted Member
Joined: 5 years ago

so do i put class-activity.php to:

/home/jdclab/public_html/wp-content/plugins/wpforo/

Your website seems to only apply to wpforo themes only?

8 Replies
Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@pyue6299,

Please never do that. You should only customize the template file. For example, you should customize activity template file not the activity class file. The user activity template files is this:

/wpforo/wpf-themes/classic/profile-activity.php

This file can be copied in your current WordPress active theme /wpforo/ folder as it's explained here: https://wpforo.com/docs/root/forum-themes/theme-customization/

 

And here are all template files you can edit in update safe way:

https://wpforo.com/docs/root/forum-themes/theme-files/

 

(@pyue6299)
Joined: 5 years ago

Trusted Member
Posts: 38

@robert

I would like to add a class="push-page" to this anchor tag:

.wpf-notification-content a

But this only appears in the class-activity.php, not in classic/profile-activity.php as you suggested.

How should i correctly add class="push-page" to .wpf-notification-content a ?

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@pyue6299,

Ok, then you don't need any customization. Just use hooks. Put this code in your current active WordPress theme functions.php file and delete all caches:

function add_class_to_notifications_links( $notifications ){
if( !empty( $notifications ) ){
foreach( $notifications as $key => $notification ){
$notifications[$key] = str_replace('<div class="wpf-nright"><a', '<div class="wpf-nright"><a class="push-page" ', $notification);
}
}
return $notifications;
}
add_filter('wpforo_notifications_list', 'add_class_to_notifications_links', 10, 1);
(@pyue6299)
Joined: 5 years ago

Trusted Member
Posts: 38

@robert

That worked. 

May I know how can i display:none the "You have new notifications" box as well as the arrow on the bottom of the box?

I can't find the correct CSS class to do so.

Thanks.

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@pyue6299,

I'm sorry but I don't see what you mean. Please leave some screenshot.

(@pyue6299)
Joined: 5 years ago

Trusted Member
Posts: 38

@robert

You see the screenshot attached. There is a box on top of the notification bell saying "you have no new notification"

I would like to disable it entirely.

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@pyue6299,

Use this CSS Code:

#wpforo #wpforo-wrap #wpforo-menu .wpf-alerts [wpf-tooltip]::after,
#wpforo #wpforo-wrap #wpforo-menu .wpf-alerts [wpf-tooltip]::before {
    display: none;
}
(@pyue6299)
Joined: 5 years ago

Trusted Member
Posts: 38

@robert

It worked. Thanks!