'facebook', 'link' => $facebook_url, 'icon' => 'ai ai-facebook', ), array( 'name' => 'twitter', 'link' => $twitter_url, 'icon' => 'ai ai-twitter', ), array( 'name' => 'pinterest', 'link' => $pinterest_url, 'icon' => 'ai ai-pinterest', ), ); } /** * Social Share Content * * @return void */ public function social_share_content() { global $post; ?>
ID, 'ayyash_post_share_count', true ); echo esc_html( 0 === strlen( $post_count ) ? 0 : $post_count ); ?>
social_share_platforms() as $social ) : printf( '', esc_attr( $social['name'] ), esc_url( $social['link'] ), esc_attr( $social['icon'] ) ); endforeach; ?>
engagement ) ) { $data = $json->engagement->share_count; } else { $data = 0; } } else { $data = 0; } return $data; } /** * Facebook Social Count * * @return int */ private function social_share_twitter_count() { //@TODO temporary handled with opensharecount.com $url = 'https://opensharecount.com/count.json?url=' . esc_url ( get_permalink() ); $response = wp_remote_get( $url ); // phpcs:ignore if ( is_array( $response ) && ! is_wp_error( $response ) ) { $body = $response['body']; // use the content $json = json_decode( $body ); $data = $json->count; } else { $data = 0; } return $data; } /** * Pinterest Social Count * * @return int */ private function social_share_pinterest_count() { $url = 'https://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url=' . esc_url( get_permalink() ); $response = wp_remote_get( $url ); // phpcs:ignore if ( is_array( $response ) && ! is_wp_error( $response ) ) { $body = $response['body']; // use the content preg_match( '/\((.*?)\)/', $body, $match ); $data = json_decode( $match[1] ); $data = $data->count; } else { $data = 0; } return $data; } } new Themeoo_Social_Share(); }