diff --git a/changelog.md b/changelog.md index 9d4a9f6..9751fa9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,16 @@ # Receptar Changelog +## 2.0.3, 20240915 + +### Updated +- Improving and fixing social icons (introducing option to force the icon with `has-icon-#` class) + +### File updates + changelog.md + style.css + inc/setup.php + + ## 2.0.2, 20240902 ### Updated diff --git a/inc/setup.php b/inc/setup.php index 0b101c8..b8f78f2 100644 --- a/inc/setup.php +++ b/inc/setup.php @@ -6,7 +6,7 @@ * @copyright 2015 WebMan - Oliver Juhas * * @since 1.0.0 - * @version 2.0.1 + * @version 2.0.3 * * CONTENT: * - 10) Actions and filters @@ -1000,7 +1000,7 @@ function receptar_menu_social() { * Social links supported icons * * @since 1.6.0 - * @version 2.0.1 + * @version 2.0.3 */ function receptar_social_links_icons() { @@ -1053,6 +1053,7 @@ function receptar_social_links_icons() { 'wa.me' => 'whatsapp', 'wordpress.org' => 'wordpress', 'wordpress.com' => 'wordpress', + 'x.com' => 'x', 'xing.com' => 'xing', 'yelp.com' => 'yelp', 'youtube.com' => 'youtube', @@ -1068,7 +1069,7 @@ function receptar_social_links_icons() { * Display SVG icons in social links menu * * @since 1.6.0 - * @version 1.6.1 + * @version 2.0.3 * * @param string $item_output The menu item output. * @param WP_Post $item Menu item object. @@ -1092,10 +1093,32 @@ function receptar_nav_menu_social_icons( $item_output, $item, $depth, $args ) { // Processing - foreach ( $social_icons as $url => $icon ) { - if ( false !== strpos( $item_output, $url ) ) { - $social_icon = $icon; - break; + if ( + ! empty( $item->classes ) + && false !== stripos( implode( ' ', (array) $item->classes ), 'has-icon-' ) + ) { + + $forced_icon = array_intersect( + $social_icons, + array_map( + function( $item ) { + return str_replace( 'has-icon-', '', trim( $item ) ); + }, + (array) $item->classes + ) + ); + + if ( ! empty( $forced_icon ) ) { + $social_icon = reset( $forced_icon ); + } + + } else { + + foreach ( $social_icons as $url => $icon ) { + if ( false !== strpos( $item_output, $url ) ) { + $social_icon = $icon; + break; + } } } diff --git a/style.css b/style.css index 241828b..9e42669 100644 --- a/style.css +++ b/style.css @@ -3,7 +3,7 @@ Theme Name: Receptar Theme URI: https://www.webmandesign.eu/portfolio/receptar-wordpress-theme/ Author: WebMan Design Author URI: https://www.webmandesign.eu/ -Version: 2.0.2 +Version: 2.0.3 Text Domain: receptar Domain Path: /languages License: GNU General Public License v3