Forked from ipokkel/font-awesome-icons-for-member-directory-and-profile-pages.php
Last active
February 19, 2024 12:54
-
-
Save kimwhite/e4bcc89c486295e08c385f3546c7f911 to your computer and use it in GitHub Desktop.
Add a Fontawesome 5 icon before a URL link on the PMPro Member Directory and Profile pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This recipe adds a Fontawesome 5 icon before a custom field containing | |
* a URL on the Member Directory and Profile pages. | |
* | |
* This recipe assumes that Fontawesome 5 support is made available either | |
* via the active theme or a plugin. | |
* | |
* WordPress auto-embeds feeds from certain oEmbed providers, e.g. Twitter. | |
* https://wordpress.org/support/article/embeds/ | |
* | |
* You may need to disable this for the Member Directory and Profile pages | |
* to only display a clickable link instead of the feed. | |
* https://gist.github.com/ipokkel/dde134d098be8b5b6d3a7e63c79d84cc | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function fa_icons_for_pmpro_member_directory_and_profile_pages() { | |
global $pmpro_pages; | |
if ( is_page( $pmpro_pages['directory'] ) || is_page( $pmpro_pages['profile'] ) ) { | |
?> | |
<!-- Add fontawesome icons to links --> | |
<script> | |
jQuery(document).ready(function($){ | |
$('<i class="fab fa-twitter"> </i>').insertBefore( $('a[href*="twitter.com/"]') ); | |
$('<i class="fab fa-linkedin"> </i>').insertBefore( $('a[href*="linkedin.com/"]') ); | |
$('<i class="fab fa-facebook"> </i>').insertBefore( $('a[href*="facebook.com/"]') ); | |
}); | |
</script> | |
<!-- Optional: CSS to hide field headings, reference each field according to the RH input field name used as meta key --> | |
<style> | |
p.pmpro_member_directory_linkedin_url strong, | |
p.pmpro_member_directory_twitter_url strong, | |
p.pmpro_member_directory_facebook_url strong { | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'fa_icons_for_pmpro_member_directory_and_profile_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment