'atomic-blocks-style-css', 'attributes' => array( 'facebook' => array( 'type' => 'boolean', 'default' => true, ), 'twitter' => array( 'type' => 'boolean', 'default' => true, ), 'google' => array( 'type' => 'boolean', 'default' => true, ), 'linkedin' => array( 'type' => 'boolean', 'default' => false, ), 'pinterest' => array( 'type' => 'boolean', 'default' => false, ), 'email' => array( 'type' => 'boolean', 'default' => false, ), 'reddit' => array( 'type' => 'boolean', 'default' => false, ), 'shareAlignment' => array( 'type' => 'string', ), 'shareButtonStyle' => array( 'type' => 'string', 'default' => 'ab-share-icon-text', ), 'shareButtonShape' => array( 'type' => 'string', 'default' => 'ab-share-shape-circular', ), 'shareButtonSize' => array( 'type' => 'string', 'default' => 'ab-share-size-medium', ), 'shareButtonColor' => array( 'type' => 'string', 'default' => 'ab-share-color-standard', ), ), 'render_callback' => 'atomic_blocks_render_sharing', ) ); } add_action( 'init', 'atomic_blocks_register_sharing' ); /** * Add the pop-up share window to the footer */ function atomic_blocks_social_icon_footer_script() { if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { return; } ?> ID ); $thumbnail = $thumbnail_id ? current( wp_get_attachment_image_src( $thumbnail_id, 'large', true ) ) : ''; } else { $thumbnail = null; } $is_amp_endpoint = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint(); $twitter_url = 'http://twitter.com/share?text=' . get_the_title() . '&url=' . get_the_permalink() . ''; $facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' . get_the_permalink() . '&title=' . get_the_title() . ''; $google_url = 'https://plus.google.com/share?url=' . get_the_permalink() . ''; $linkedin_url = 'https://www.linkedin.com/shareArticle?mini=true&url=' . get_the_permalink() . '&title=' . get_the_title() . ''; $pinterest_url = 'https://pinterest.com/pin/create/button/?&url=' . get_the_permalink() . '&description=' . get_the_title() . '&media=' . esc_url( $thumbnail ) . ''; $email_url = 'mailto:?subject=' . get_the_title() . '&body=' . get_the_title() . '—' . get_the_permalink() . ''; $reddit_url = 'https://www.reddit.com/submit?url=' . get_the_permalink() . ''; $share_url = ''; if ( isset( $attributes['twitter'] ) && $attributes['twitter'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $twitter_url ), esc_html__( 'Share on Twitter', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $twitter_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on Twitter', 'atomic-blocks' ) ); } if ( isset( $attributes['facebook'] ) && $attributes['facebook'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $facebook_url ), esc_html__( 'Share on Facebook', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $facebook_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on Facebook', 'atomic-blocks' ) ); } if ( isset( $attributes['google'] ) && $attributes['google'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $google_url ), esc_html__( 'Share on Google', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $google_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on Google', 'atomic-blocks' ) ); } if ( isset( $attributes['pinterest'] ) && $attributes['pinterest'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $pinterest_url ), esc_html__( 'Share on Pinterest', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $pinterest_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on Pinterest', 'atomic-blocks' ) ); } if ( isset( $attributes['linkedin'] ) && $attributes['linkedin'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $linkedin_url ), esc_html__( 'Share on LinkedIn', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $linkedin_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on LinkedIn', 'atomic-blocks' ) ); } if ( isset( $attributes['reddit'] ) && $attributes['reddit'] ) { $href_format = sprintf( 'href="javascript:void(0)" onClick="javascript:atomicBlocksShare(\'%1$s\', \'%2$s\', \'600\', \'600\')"', esc_url( $reddit_url ), esc_html__( 'Share on Reddit', 'atomic-blocks' ) ); if ( $is_amp_endpoint ) { $href_format = sprintf( 'href="%1$s"', esc_url( $reddit_url ) ); } $share_url .= sprintf( '
  • %2$s
  • ', $href_format, esc_html__( 'Share on Reddit', 'atomic-blocks' ) ); } if ( isset( $attributes['email'] ) && $attributes['email'] ) { if ( ! $is_amp_endpoint ) { $share_url .= sprintf( '
  • %2$s
  • ', esc_url( $email_url ), esc_html__( 'Share via Email', 'atomic-blocks' ) ); } } $block_content = sprintf( '
    ', $share_url, isset( $attributes['shareButtonStyle'] ) ? $attributes['shareButtonStyle'] : null, isset( $attributes['shareButtonShape'] ) ? $attributes['shareButtonShape'] : null, isset( $attributes['shareButtonSize'] ) ? $attributes['shareButtonSize'] : null, isset( $attributes['shareButtonColor'] ) ? $attributes['shareButtonColor'] : null, isset( $attributes['shareAlignment'] ) ? $attributes['shareAlignment'] : null ); return $block_content; }