EduardET

Untitled

May 18th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. function wpc_extra_post_share_links( $echo = true ) {
  2.     $output = '';
  3.     $networks = array();
  4.     // this is backwards due to how epanel saves checkboxes values
  5.     $excluded_networks = et_get_option( "extra_post_share_icons", array() );
  6.     foreach ( ET_Social_Share::get_networks() as $network ) {
  7.         if ( !in_array( $network->slug, $excluded_networks ) ) {
  8.             $networks[$network->slug] = $network;
  9.         }
  10.     }
  11.  
  12.     $permalink = get_the_permalink();
  13.     $title = get_the_title();
  14.     foreach ( $networks as $network ) {
  15.         $share_url = $network->create_share_url( $permalink, $title );
  16.         $share_title = sprintf( __( 'Share "%s" via %s', 'extra' ), $title, $network->name );
  17.         if ($network->slug === 'basic_email') {
  18.             $output .= sprintf(
  19.                 '<a href="%1$s" class="social-share-link wpc-email-link" title="%2$s" data-network-name="%3$s" data-share-title="%4$s" data-share-url="%5$s" onclick="javascript: return true;">
  20.                 <span class="et-extra-icon et-extra-icon-%3$s et-extra-icon-background-hover" ></span>
  21.                 </a>',
  22.                 'mailto:'.get_option('admin_email'),
  23.                 esc_attr( $share_title ),
  24.                 esc_attr( $network->slug ),
  25.                 esc_attr( $title ),
  26.                 esc_attr( $permalink )
  27.             );
  28.         } else {
  29.             $output .= sprintf(
  30.                 '<a href="%1$s" class="social-share-link" title="%2$s" data-network-name="%3$s" data-share-title="%4$s" data-share-url="%5$s">
  31.                 <span class="et-extra-icon et-extra-icon-%3$s et-extra-icon-background-hover" ></span>
  32.                 </a>',
  33.                 $share_url,
  34.                 esc_attr( $share_title ),
  35.                 esc_attr( $network->slug ),
  36.                 esc_attr( $title ),
  37.                 esc_attr( $permalink )
  38.             );
  39.         }
  40.        
  41.         ?>
  42.  
  43.         <?php
  44.     }
  45.  
  46.     if ( $echo ) {
  47.         echo $output;
  48.     } else {
  49.         return $output;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment