Skip to content

Instantly share code, notes, and snippets.

@boonebgorges
Created January 27, 2021 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boonebgorges/95d1ec1c291e7c63cdeb0391780b6d51 to your computer and use it in GitHub Desktop.
Save boonebgorges/95d1ec1c291e7c63cdeb0391780b6d51 to your computer and use it in GitHub Desktop.
Modify 'Open' and 'Cloneable' badge markup for Commons In A Box OpenLab
<?php
add_filter(
'openlab_badges_badge_links',
function( $badge_links, $group_id, $context ) {
foreach ( $badge_links as &$link ) {
if ( false !== strpos( $link, '>Open<' ) ) {
$link = str_replace( 'href="somelink"', 'href="#"', $link );
}
if ( false !== strpos( $link, '>Clone<' ) ) {
$link = str_replace( '>Clone<', '>Cloneable<', $link );
}
}
return $badge_links;
},
20,
3
);
@profstein
Copy link

Note, if you also want to change the default link for clone, currently someotherlink, you can add in this if statement. Note this would come after line 13 and the search is for Cloneable as Clone is changed to Cloneable in the 11–13 if statement.

    if ( false !== strpos( $link, '>Cloneable<' ) ) {
        $link = str_replace( 'href="someotherlink"', 'href="#"', $link );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment