How to change the text of favorite button to an image ?
-
Hi, Does anybody know how to change the text of the favorite button to an image and still return the AJAX function. I have changed it to shape but it does not return AJAX function that is triggered when you click the favorite button. I’ve changed bp-templates/bp-legacy/buddypress-functions.php to this:
/** * Mark an activity as a favourite via a POST request. ... */ function bp_legacy_theme_mark_activity_favorite() { // Bail if not a POST action. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return; if ( bp_activity_add_user_favorite( $_POST['id'] ) ) echo '<img src="../images/star_on.png">'; else echo '<img src="../images/star_off.png">'; exit; } /** * Un-favourite an activity via a POST request. ... function bp_legacy_theme_unmark_activity_favorite() { // Bail if not a POST action. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return; if ( bp_activity_remove_user_favorite( $_POST['id'] ) ) echo '<img src="../images/star_off.png">'; else echo '<img src="../images/star_on.png">'; exit; }
I also did the the necessary adjustment to /buddypress/activity/entry.php and changed
_e( 'Favorite', 'buddypress' );
toecho '<img src="../images/star_off.png">';
and_e( 'Remove Favorite', 'buddypress' );
toecho '<img src="../images/star_on.png">';
Favourit button now has changed its shape to a nice star that change when you click on it but not as AJAX. It keeps refreshing the page each time I click the button.any help would be appreciated.
BuddyPress: 2.5.2 —- WP: 4.5 2.5.2 —- WP: 4.5
- You must be logged in to reply to this topic.