Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change Favorite, Comment and Delete text button to SVG icons


  • jcfromkc
    Participant

    @jcfromkc

    Is there a preferred method for changing the Favorite, Comment and Delete text buttons on the Activity Stream to icons or SVG code?

    I’ve tried using the following code in the functions.php but it forces the page to refresh. I’m assuming this is an AJAX issue.

    function multiple_translate_text( $translated_text ) {
    	switch ( $translated_text ) {
                case 'Favorite' :
    			$translated_text = __( '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
    	 width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
    <path d="M6.28,3C9.516,3.001,11.253,6.491,12,8.031c0.75-1.547,2.469-5.021,5.727-5.021C19.784,3.01,22,4.319,22,7.192
    	c0,3.442-4.744,7.851-10,13c-5.258-5.15-10-9.559-10-13C2,4.516,3.965,2.999,6.28,3z M6.281,1C3.098,1,0,3.187,0,7.192
    	C0,11.853,5.57,16.619,12,23c6.43-6.381,12-11.147,12-15.808c0-4.011-3.098-6.182-6.273-6.182c-2.205,0-4.447,1.042-5.727,3.238
    	C10.715,2.042,8.478,1,6.281,1z"/>
    </svg>' );
    			break;
    }
    	return $translated_text;
    }
    add_filter( 'gettext', 'multiple_translate_text',20 );

    Again, the text changes to the SVG icon but refreshes the page when clicking on it.

    Does anyone know how to make this change while keeping AJAX happy?

  • You must be logged in to reply to this topic.
Skip to toolbar