'custom', 'type' => 'simple', 'size' => 'custom', 'fill' => false ] ); $attr = [ 'data-type' => $args['type'], 'data-size' => $args['size'], 'data-color' => $args['icons-color'] ]; if ($args['fill']) { if ($args['type'] !== 'simple') { $attr['data-fill'] = $args['fill']; } } return blocksy_get_social_box([ 'attr' => $attr, 'socials' => $socials_descriptor, 'hide_labels' => true ]); } /** * Get social share box. */ function blocksy_get_social_share_box($check_for_preview = false, $args = []) { $args = wp_parse_args( $args, [ 'html_atts' => [], 'type' => 'type-1' ] ); $old_args = $args['html_atts']; $args['html_atts'] = wp_parse_args($old_args, $args['html_atts']); $args['html_atts']['data-type'] = $args['type']; $after_content = ''; if ($args['type'] === 'type-2' || $check_for_preview) { $after_content = ' '; } return blocksy_get_social_box([ 'type' => 'share', 'root_class' => 'ct-share-box', 'class' => blocksy_visibility_classes( get_theme_mod('share_box_visibility', [ 'desktop' => true, 'tablet' => true, 'mobile' => false, ]) ), 'has_count' => $args['type'] === 'type-2' || $check_for_preview, 'attr' => $args['html_atts'], 'after_links_content' => $after_content, 'force_output' => $check_for_preview ]); } function blocksy_get_social_metadata($args = []) { $args = wp_parse_args( $args, [ // url | share 'type' => 'url', 'social' => null, ] ); $metadata = [ 'facebook' => [ 'name' => __( 'Facebook', 'blocksy' ), 'icon' => ' ', ], 'twitter' => [ 'name' => __( 'Twitter', 'blocksy' ), 'icon' => ' ', ], 'pinterest' => [ 'name' => __( 'Pinterest', 'blocksy' ), 'icon' => ' ', ], 'linkedin' => [ 'name' => __( 'LinkedIn', 'blocksy' ), 'icon' => ' ', ], 'reddit' => [ 'name' => __( 'Reddit', 'blocksy' ), 'icon' => ' ', ], 'hacker_news' => [ 'name' => __( 'Hacker News', 'blocksy' ), 'icon' => ' ', ], 'vk' => [ 'name' => __( 'VK', 'blocksy' ), 'icon' => ' ', ], 'ok' => [ 'name' => __( 'Odnoklassniki', 'blocksy' ), 'icon' => ' ', ], 'telegram' => [ 'name' => __( 'Telegram', 'blocksy' ), 'icon' => ' ', ], 'viber' => [ 'name' => __( 'Viber', 'blocksy' ), 'icon' => ' ', ], 'whatsapp' => [ 'name' => __( 'WhatsApp', 'blocksy' ), 'icon' => ' ', ], 'wechat' => [ 'name' => 'WeChat', 'icon' => ' ' ], 'qq' => [ 'name' => 'QQ', 'icon' => ' ' ], 'weibo' => [ 'name' => 'Weibo', 'icon' => ' ' ], 'xing' => [ 'name' => 'Xing', 'icon' => ' ' ], 'rss' => [ 'name' => 'RSS', 'icon' => ' ' ], 'vimeo' => [ 'name' => 'Vimeo', 'icon' => ' ' ], 'youtube' => [ 'name' => 'YouTube', 'icon' => ' ' ], 'patreon' => [ 'name' => 'Patreon', 'icon' => ' ' ], 'medium' => [ 'name' => 'Medium', 'icon' => ' ' ], 'dribbble' => [ 'name' => 'Dribbble', 'icon' => ' ' ], 'instagram' => [ 'name' => 'Instagram', 'icon' => ' ' ] ]; if (! $args['social']) { return null; } if (! isset($metadata[$args['social']])) { return null; } $single_metadata = $metadata[$args['social']]; $single_metadata['url'] = ''; if ($args['type'] === 'url') { $single_metadata['url'] = get_theme_mod($args['social'], '#'); if (empty(trim($single_metadata['url']))) { $single_metadata['url'] = '#'; } } if ($args['type'] === 'share') { $home_url = blocksy_encode_uri_component( home_url(add_query_arg(null, null)) ); $social_urls = [ 'facebook' => str_replace( '{url}', $home_url, 'https://www.facebook.com/sharer/sharer.php?u={url}' ), 'twitter' => str_replace( '{url}', $home_url, 'https://twitter.com/share?url={url}' ), 'pinterest' => str_replace( '{url}', $home_url, '#' ), 'linkedin' => str_replace( '{url}', $home_url, 'https://www.linkedin.com/shareArticle?url={url}' ), 'reddit' => str_replace( '{url}', $home_url, 'https://reddit.com/submit?url={url}' ), 'hacker_news' => str_replace( '{url}', $home_url, 'https://news.ycombinator.com/submitlink?u={url}' ), 'reddit' => str_replace( '{url}', $home_url, 'http://www.reddit.com/submit?url={url}' ), 'vk' => str_replace( '{url}', $home_url, 'http://vk.com/share.php?url={url}' ), 'ok' => str_replace( '{url}', $home_url, 'https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl={url}' ), 'telegram' => str_replace( '{url}', $home_url, 'https://t.me/share/url?url={url}' ), 'viber' => str_replace( '{url}', $home_url, 'viber://forward?{url}=This+is+the+content' ), 'whatsapp' => str_replace( '{url}', $home_url, 'whatsapp://send?text={url}' ), ]; if (isset($social_urls[$args['social']])) { $single_metadata['url'] = $social_urls[$args['social']]; } else { $single_metadata['url'] = '#'; } } return $single_metadata; } function blocksy_get_social_share_items() { return [ [ 'id' => 'facebook', 'enabled' => get_theme_mod('share_facebook', 'yes') === 'yes', ], [ 'id' => 'twitter', 'enabled' => get_theme_mod('share_twitter', 'yes') === 'yes', ], [ 'enabled' => get_theme_mod('share_pinterest', 'yes') === 'yes', 'id' => 'pinterest', ], [ 'enabled' => get_theme_mod('share_linkedin', 'yes') === 'yes', 'id' => 'linkedin', ], [ 'enabled' => get_theme_mod('share_reddit', 'no') === 'yes', 'id' => 'reddit', ], [ 'enabled' => get_theme_mod('share_hacker_news', 'no') === 'yes', 'id' => 'hacker_news', ], [ 'enabled' => get_theme_mod('share_vk', 'no') === 'yes', 'id' => 'vk', ], [ 'enabled' => get_theme_mod('share_ok', 'no') === 'yes', 'id' => 'ok', ], [ 'enabled' => get_theme_mod('share_telegram', 'no') === 'yes', 'id' => 'telegram', ], [ 'enabled' => get_theme_mod('share_viber', 'no') === 'yes', 'id' => 'viber', ], [ 'enabled' => get_theme_mod('share_whatsapp', 'no') === 'yes', 'id' => 'whatsapp', ], ]; } function blockst_get_social_url_items() { return [ [ 'id' => 'facebook', 'enabled' => true, ], [ 'id' => 'twitter', 'enabled' => true, ], [ 'id' => 'instagram', 'enabled' => true, ], [ 'id' => 'pinterest', 'enabled' => true, ], [ 'id' => 'dribbble', 'enabled' => true, ], [ 'id' => 'linkedin', 'enabled' => true, ], [ 'id' => 'medium', 'enabled' => true, ], [ 'id' => 'patreon', 'enabled' => true, ], [ 'id' => 'vk', 'enabled' => true, ], [ 'id' => 'youtube', 'enabled' => true, ], [ 'id' => 'vimeo', 'enabled' => true, ], [ 'id' => 'rss', 'enabled' => true, ], [ 'id' => 'xing', 'enabled' => true, ], [ 'id' => 'whatsapp', 'enabled' => true, ], [ 'id' => 'viber', 'enabled' => true, ], [ 'id' => 'telegram', 'enabled' => true, ], [ 'id' => 'weibo', 'enabled' => true, ], [ 'id' => 'qq', 'enabled' => true, ], [ 'id' => 'wechat', 'enabled' => true, ], ]; } function blocksy_get_social_box($args = []) { $args = wp_parse_args( $args, [ // url | share 'type' => 'url', 'socials' => null, 'attr' => [], 'class' => '', 'before_links_content' => '', 'after_links_content' => '', 'has_count' => false, 'hide_labels' => false, 'root_class' => 'ct-social-box', 'force_output' => false ] ); if ($args['type'] === 'share') { $args['socials'] = blocksy_get_social_share_items(); } if (! $args['socials']) { $args['socials'] = blockst_get_social_url_items(); } $has_any_social = 0; foreach ($args['socials'] as $single_social) { if ( ! isset($single_social['enabled']) || ( isset($single_social['enabled']) && $single_social['enabled'] ) || $args['force_output'] ) { $has_any_social++; } } if (! $has_any_social) { return ''; } $old_attr = []; $old_attr['class'] = $args['root_class']; if (! empty($args['class'])) { $old_attr['class'] .= ' ' . $args['class']; } if ($args['type'] === 'share') { // $old_attr['data-behavior'] = 'share'; } if ($args['has_count']) { $old_attr['data-count'] = $has_any_social; } $old_attr = array_merge($old_attr, $args['attr']); ob_start(); ?>