AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Solved] How to add an attribute to an anchor tag

11 Posts
2 Users
0 Reactions
1,697 Views
Posts: 38
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@pyue6299)
Trusted Member
Joined: 6 years ago
[#13988]

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: 10741
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 3 months 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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@pyue6299)
Trusted Member
Joined: 6 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: 3 months ago

Support Team
Posts: 10741
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 6 years ago

Trusted Member
Posts: 38
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 3 months ago

Support Team
Posts: 10741
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 6 years ago

Trusted Member
Posts: 38
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 3 months ago

Support Team
Posts: 10741
Robert
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@pyue6299,

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


(@pyue6299)
Joined: 6 years ago

Trusted Member
Posts: 38
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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.

 Screen Shot 2020 07 14 at 2.34.04 PM

Robert
Admin
(@robert)
Joined: 3 months ago

Support Team
Posts: 10741
Robert
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 6 years ago

Trusted Member
Posts: 38
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@robert

It worked. Thanks!


Share: