Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

profstein commented Feb 16, 2021

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