srikat

functions.php

Feb 10th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. //* Enqueue Dashicons
  2. add_action( 'wp_enqueue_scripts', 'enqueue_dashicons' );
  3. function enqueue_dashicons() {
  4. wp_enqueue_style( 'dashicons' );
  5. }
  6.  
  7. //* Add Twitter field in User Profile page in WP admin
  8. function my_new_contactmethods( $contactmethods ) {
  9. $contactmethods['twitter'] = 'Twitter (w/o the @)';
  10.  
  11. return $contactmethods;
  12. }
  13. add_filter( 'user_contactmethods', 'my_new_contactmethods', 10, 1 );
  14.  
  15. //* Create [twitter_link] shortcode
  16. add_shortcode( 'twitter_link', 'gamajo_twitter_link_shortcode' );
  17. function gamajo_twitter_link_shortcode() {
  18. $twitter_handle = ltrim( get_the_author_meta( 'twitter' ), '@' );
  19.  
  20. if ( empty( $twitter_handle ) ) {
  21. return '';
  22. }
  23.  
  24. return sprintf(
  25. '<span class="twitter"><a href="%s" target="_blank"><span class="dashicons dashicons-twitter"></span></a></span>',
  26. esc_url( 'https://twitter.com/' . $twitter_handle ),
  27. $twitter_handle
  28. );
  29. }
  30.  
  31. //* Customize entry meta in the entry header
  32. add_filter( 'genesis_post_info', 'sp_post_info_filter' );
  33. function sp_post_info_filter( $post_info ) {
  34. if ( is_singular( 'post' ) ) {
  35. $post_info = 'by [post_author_posts_link] on [post_date] [twitter_link] [post_edit]';
  36. }
  37. return $post_info;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment