Making WordPress.org

Changeset 11654


Ignore:
Timestamp:
03/09/2022 05:50:36 AM (4 years ago)
Author:
dd32
Message:

Table of Contents plugin: Switch out the heading hashes for a link icon and linking the entire heading.

Closes https://github.com/WordPress/wordpress.org/pull/64.
See #6171.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

    r11532 r11654  
    88        protected $post_types = array();
    99
    10         protected $styles = '<style> .toc-jump { text-align: right; font-size: 12px; } .page .toc-heading { margin-top: -50px; padding-top: 50px !important; }</style>';
     10        protected $styles = '<style>
     11                .toc-jump { text-align: right; font-size: 12px; }
     12                .toc-heading a { color: inherit; font-weight: inherit; margin-left: -25px; text-decoration: none !important; }
     13                .toc-heading a:before { visibility: hidden; vertical-align: middle; margin-top: -5px; margin-right: 5px; }
     14                .toc-heading:target a:before { margin-left: -8px; margin-right: 13px; }
     15                .toc-heading a:hover:before, .toc-heading a:focus:before { visibility: visible; }
     16        </style>';
    1117
    1218        /**
     
    193199                        }
    194200
    195                         $a11y_text      = sprintf( '<span class="screen-reader-text">%s</span>', $title );
    196                         $anchor         = sprintf( '<a href="#%1$s" class="anchor"><span aria-hidden="true">#</span>%2$s</a>', $id, $a11y_text );
    197                         $replacement   .= sprintf( '<%1$s id="%2$s" class="%3$s" tabindex="-1" %4$s>%5$s %6$s</%1$s>', $tag, $id, $class, $extra_attrs, $title, $anchor );
     201                        $replacement   .= sprintf(
     202                                '<%1$s id="%2$s" class="%3$s" tabindex="-1" %4$s><a href="#%2$s" class="dashicons-before dashicons-admin-links">%5$s</a></%1$s>',
     203                                $tag,
     204                                $id,
     205                                $class,
     206                                $extra_attrs,
     207                                $title
     208                        );
    198209                        $replacements[] = $replacement;
    199210                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-helphub/inc/handbook-toc/table-of-contents.php

    r11390 r11654  
    88        protected $post_types = array();
    99
    10         protected $styles = '<style> .toc-jump { text-align: right; font-size: 12px; } .page .toc-heading { margin-top: -50px; padding-top: 50px !important; }</style>';
     10        protected $styles = '<style>
     11                .toc-jump { text-align: right; font-size: 12px; }
     12                .toc-heading a { color: inherit; font-weight: inherit; margin-left: -25px; text-decoration: none !important; }
     13                .toc-heading a:before { visibility: hidden; vertical-align: middle; margin-top: -5px; margin-right: 5px; }
     14                .toc-heading:target a:before { margin-left: -8px; margin-right: 13px; }
     15                .toc-heading a:hover:before, .toc-heading a:focus:before { visibility: visible; }
     16        </style>';
    1117
    1218        /**
     
    126132
    127133                // Replace each level of the headings.
     134                $content .= $this->styles . "\n";
    128135                $content = $this->add_ids_and_jumpto_links( $items, $content );
    129136
     
    133140
    134141                $contents_header = 'h' . reset( $items )['level']; // Duplicate the first <h#> tag in the document for the TOC header
    135                 $toc            .= $this->styles;
    136142                $toc            .= '<div class="table-of-contents">';
    137143                $toc            .= "<$contents_header>" . esc_html( $this->args->header_text ) . "</$contents_header><ul class=\"items\">";
     
    193199                        }
    194200
    195                         $a11y_text      = sprintf( '<span class="screen-reader-text">%s</span>', $title );
    196                         $anchor         = sprintf( '<a href="#%1$s" class="anchor"><span aria-hidden="true">#</span>%2$s</a>', $id, $a11y_text );
    197                         $replacement   .= sprintf( '<%1$s id="%2$s" class="%3$s" tabindex="-1" %4$s>%5$s %6$s</%1$s>', $tag, $id, $class, $extra_attrs, $title, $anchor );
     201                        $replacement   .= sprintf(
     202                                '<%1$s id="%2$s" class="%3$s" tabindex="-1" %4$s><a href="#%2$s" class="dashicons-before dashicons-admin-links">%5$s</a></%1$s>',
     203                                $tag,
     204                                $id,
     205                                $class,
     206                                $extra_attrs,
     207                                $title
     208                        );
    198209                        $replacements[] = $replacement;
    199210                }
Note: See TracChangeset for help on using the changeset viewer.