0

I have this code below, which comes from Wordpress Core file /wp-admin/includes/class-wp-posts-list-table.php

  printf(
    '<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
    get_edit_post_link( $post->ID ),
    /* translators: %s: post title */
    esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title )),
    $pad,
    $title
  );

In my case the variable $title contains iconfont HTML i.e.

  <i class="fa fa-heart"></i> 

enter image description here

The PHP code is making the web browser display the HTML characters as a string rather than what I'm after which is to display as HTML and render the Font Awesome Icon.

Ive tried wrapping $title in

htmlentities()
html_entity_decode()
htmlspecialchars()

Can some one help thanx

1
  • have you tried with ? htmlentities($title, ENT_HTML5); Commented Feb 9, 2017 at 9:26

1 Answer 1

3

Where did you use html_entity_decode? I've tried this:

printf(
    '<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
    get_edit_post_link( $post->ID ),
    /* translators: %s: post title */
    esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title )),
    $pad,
    html_entity_decode($title)
  );

and seems it works.

But this is BAD idea to change core file. You can try to write (or find) some plugin that allows to add icons to particular post title but not to all post and without changing original file.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes this works thanx, I had overlooked this on my first attempt as nothing had displayed but then I realised that the Font Awesome css file was not included on the Admin side

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.