Skip to content

Commit

Permalink
Re-add the original go_avaliable_social_icons filter (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHerman authored Jul 18, 2023
1 parent 63d0404 commit f0d3e68
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
29 changes: 27 additions & 2 deletions .dev/tests/php/test-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ function testGetAvailableSocialIcons() {
}

/**
* Test filtering the social icons
* Test filtering the social icons with the go_avaliable_social_icons filter (old filter name with typo).
*/
function testGetAvailableSocialIconsFilter() {
function testGetAvaliableSocialIconsFilter() {

$test_data = [
'label' => 'Test',
Expand All @@ -1047,6 +1047,31 @@ function testGetAvailableSocialIconsFilter() {

}

/**
* Test filtering the social icons with the go_available_social_icons filter.
*/
function testGetAvailableSocialIconsFilter() {

$test_data = [
'label' => 'Test New',
'icon' => 'icon',
'placeholder' => 'placeholder',
];

add_filter( 'go_available_social_icons', function( $social_icons ) use( $test_data ) {

$social_icons['test_new'] = $test_data;

return $social_icons;

} );

$social_icons = Go\Core\get_available_social_icons();

$this->assertEquals( $test_data, $social_icons['test_new'] );

}

/**
* Test retreiving the social icons
*/
Expand Down
5 changes: 4 additions & 1 deletion includes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,11 @@ function get_available_social_icons() {
* @since 0.1.0
*
* @param array $social_icons Array containing the supported social icons.
*
* Note: There is a double filter here to maintain backwards compatibility after fixing a typo in the name of the filter.
* @see https://github.com/godaddy-wordpress/go/pull/870/files#diff-21e944aca0f42ff6529bde979b0fd787d00e010406e6642f947e71bf5e6f5ad1L1272-R1272
*/
return (array) apply_filters( 'go_available_social_icons', $social_icons );
return (array) apply_filters( 'go_available_social_icons', apply_filters( 'go_avaliable_social_icons', $social_icons ) );

}

Expand Down

0 comments on commit f0d3e68

Please sign in to comment.