Make WordPress Core

Changeset 48180

Timestamp:
06/26/2020 02:40:27 PM (4 years ago)
Author:
ianbelanger
Message:

Bundled Themes: Twenty Twenty Social Icons Filter.

Adds a Social Icons Filter to Twenty Twenty that allows for new icons to be added to the theme by filter.

Props JarretC, nielslange, acosmin, desrosj.
Fixes #48713.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php

    r47796 r48180  
    3030                $arr = array();
    3131            }
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
    3256            if ( array_key_exists( $icon, $arr ) ) {
    3357                $repl = '<svg class="svg-icon" aria-hidden="true" role="img" focusable="false" ';
     
    5276            if ( ! isset( $regex_map ) ) {
    5377                $regex_map = array();
    54                 $map       = &self::$social_icons_map; // Use reference instead of copy, to save memory.
    55                 foreach ( array_keys( self::$social_icons ) as $icon ) {
     78
     79                /**
     80                 * Filters Twenty Twenty's array of domain mappings for social icons.
     81                 *
     82                 * By default, each Icon ID is matched against a .com TLD. To override this behavior,
     83                 * specify all the domains it covers (including the .com TLD too, if applicable).
     84                 *
     85                 * @since 1.5.0
     86                 *
     87                 * @param array $social_icons_map Array of default social icons.
     88                 */
     89                $map = apply_filters( 'twentytwenty_social_icons_map', self::$social_icons_map );
     90
     91                /**
     92                 * Filters Twenty Twenty's array of social icons.
     93                 *
     94                 * @since 1.5.0
     95                 *
     96                 * @param array $social_icons Array of default social icons.
     97                 */
     98                $social_icons = apply_filters( 'twentytwenty_svg_icons_social', self::$social_icons );
     99
     100                foreach ( array_keys( $social_icons ) as $icon ) {
    56101                    $domains            = array_key_exists( $icon, $map ) ? $map[ $icon ] : array( sprintf( '%s.com', $icon ) );
    57102                    $domains            = array_map( 'trim', $domains ); // Remove leading/trailing spaces, to prevent regex from failing to match.
Note: See TracChangeset for help on using the changeset viewer.