[wp-meta] [Making WordPress.org] #3649: add new filter for attributes on link anchor elements in wporg-developer theme

Making WordPress.org noreply at wordpress.org
Wed May 30 20:30:57 UTC 2018

#3649: add new filter for attributes on link anchor elements in wporg-developer
 Reporter:  pbiron         |       Owner:  (none)
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:
Component:  Developer Hub  |  Resolution:
 Keywords:                 |

Comment (by pbiron):

 Here's how I would use the proposed filter to produce the screenshot I
 just attached to this ticket.

 Suppose I have the following DocBlock:

  * Tries to convert an attachment URL for intermediate sized images into a
 post ID.
  * This function is intended to be hooked into {@link
  * to overcome the fact that {@link
  * will only find an attachment ID when the `$url` is for the full-sized
  * @param int $post_id The found post ID.
  * @param string $url The URL to resolve.
  * @return int The found post ID, or 0 on failure.
 function shc_attachment_url_to_postid_filter( $post_id, $url ) {

 I'd hook the following function into the proposed filter

 add_filter( 'devhub-format-link-attributes', 'shc_link_attributes', 10, 2
 function shc_link_attributes( $attrs, $url ) {
         $host = parse_url( $url, PHP_URL_HOST );
         switch ( $host ) {
                 case 'developer.wordpress.org':
                 case 'codex.wordpress.org':
                 case 'make.wordpress.org':
                         $attrs['class'] = 'external wporg';
                         $attrs['title'] = 'External link to


                 case 'php.net':
                         $attrs['class'] = 'external php';
                         $attrs['title'] = 'External link to php.net';


                 case 'w3.org':
                 case 'www.w3.org':
                         $attrs['class'] = 'external w3c';
                         $attrs['title'] = 'External link to w3.org';


         return $attrs;

 and use the following snippet of CSS:

 a.external::after {
         background-origin: content-box;
         background-position: center;
         background-repeat: no-repeat;
         background-size: 1em 1em;
         content: '';
         display: inline-block;
         height: 1em;
         margin: 0 0 0 5px;
         width: 1em;

 a.external.wporg::after {
         background-image: url( images/wordpress-logo.svg );
 a.external.php::after {
         background-image: url( images/php-logo.svg );
 a.external.w3c::after {
         background-image: url( images/w3c-logo.svg );

 to produce the WP logo "decoration" of the link.

Ticket URL: <https://meta.trac.wordpress.org/ticket/3649#comment:1>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org

More information about the wp-meta mailing list