options = $options; $this->public_class_object = $public_class_object; } /** * Shortcode for Social Sharing. */ public function follow_icons_shortcode( $params ) { extract( shortcode_atts( array( 'style' => '', 'width' => '32', 'height' => '32', 'shape' => 'square', 'social_networks' => '', 'type' => 'standard', 'theme' => '', 'left' => '0', 'right' => '0', 'top' => '100', 'align' => 'left', 'title' => '' ), $params ) ); $html = ''; if ( $social_networks ) { $networks = explode( ',', $social_networks ); $icon_style = 'width:' . $width . 'px;height:' . $height . 'px;' . ( $shape == 'round' ? 'border-radius:999px;' : '' ); if ( $theme == '' ) { $icon_theme = $theme; } elseif ( $theme == 'standard' ) { $icon_theme = $theme . '_'; } elseif ( $theme == 'floating' ) { $icon_theme = $theme . '_'; } $html .= '
'; if ( ! empty( $title ) ) { if ( $type == 'floating' ) { $html .= '
'; } $html .= $title; if ( $type == 'floating' ) { $html .= '
'; } } $html .= ''; $html .= '
'; $html .= '
'; } return $html; } /** * Shortcode for Social Sharing * * @since 1.0.0 */ public function sharing_shortcode( $params ) { extract( shortcode_atts( array( 'style' => '', 'type' => 'standard', 'left' => '0', 'right' => '0', 'top' => '100', 'url' => '', 'count' => 0, 'align' => 'left', 'title' => '', 'total_shares' => 'OFF' ), $params ) ); $type = strtolower( $type ); if ( ( $type == 'standard' && ! isset( $this->options['hor_enable'] ) ) || ( $type == 'floating' && ! isset( $this->options['vertical_enable'] ) ) || ( ! isset( $this->options['amp_enable'] ) && $this->public_class_object->is_amp_page() ) ) { return; } global $post; if ( ! is_object( $post ) ) { return; } if ( $url ) { $target_url = $url; $post_id = 0; } elseif ( is_front_page() ) { $target_url = esc_url( home_url() ); $post_id = 0; } elseif ( ! is_singular() && $type == 'vertical' ) { $target_url = html_entity_decode( esc_url( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ) ); $post_id = 0; } elseif ( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] ) { $target_url = html_entity_decode( esc_url( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ) ); $post_id = $post -> ID; } elseif ( get_permalink( $post -> ID ) ) { $target_url = get_permalink( $post -> ID ); $post_id = $post -> ID; } else { $target_url = html_entity_decode( esc_url( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ) ); $post_id = 0; } $share_count_url = $target_url; if ( $url == '' && is_singular() ) { $share_count_url = get_permalink( $post -> ID ); } $custom_post_url = $this->public_class_object->apply_target_share_url_filter( $target_url, $type, false ); if ( $custom_post_url != $target_url ) { $target_url = $custom_post_url; $share_count_url = $target_url; } // generate short url $short_url = $this->public_class_object->get_short_url( $target_url, $post_id ); $alignment_offset = 0; if ( $left) { $alignment_offset = $left; } elseif ( $right) { $alignment_offset = $right; } // share count transient ID $this->public_class_object->share_count_transient_id = $this->public_class_object->get_share_count_transient_id( $target_url ); $cached_share_count = $this->public_class_object->get_cached_share_count( $this->public_class_object->share_count_transient_id ); $html = '
public_class_object->is_amp_page() ? "" : "heateor-sss-data-href='" . ( isset( $share_count_url ) && $share_count_url ? $share_count_url : $target_url ) . "'" ) . ( ( $cached_share_count === false || $this->public_class_object->is_amp_page() ) ? "" : 'heateor-sss-no-counts="1" ' ); $vertical_offsets = ''; if ( $type == 'floating' ) { $vertical_offsets = $align . ': ' . $$align . 'px; top: ' . $top . 'px;width:' . ( ( $this->options['vertical_sharing_size'] ? $this->options['vertical_sharing_size'] : '35' ) + 4 ) . "px;"; } // style if ( $style != "" || $vertical_offsets != '' ) { $html .= 'style="'; if ( strpos( $style, 'background' ) === false ) { $html .= '-webkit-box-shadow:none;box-shadow:none;'; } $html .= $vertical_offsets; $html .= $style; $html .= '"'; } $html .= '>'; if ( $type == 'standard' && $title != '' ) { $html .= '
' . ucfirst( $title ) . '
'; } $html .= $this->public_class_object->prepare_sharing_html( $short_url ? $short_url : $target_url, $type == 'standard' ? 'horizontal' : 'vertical', $count, $total_shares == 'ON' ? 1 : 0 ); $html .= '
'; if ( ( $count || $total_shares == 'ON' ) && $cached_share_count === false ) { $html .= ''; } return $html; } }