PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.6.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.6.1
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Traits / SocialShare.php

SocialShare.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.6.1, at includes/Traits/SocialShare.php

69 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPDeveloper\BetterDocs\Traits;
3
4 trait SocialShare {
5 public $view_wrapper = 'betterdocs-social-share';
6
7 public function generate_links() {
8 $_permalink = get_the_permalink();
9
10 $_defaults = [
11 'facebook' => [
12 'alt' => 'Facebook',
13 'icon' => betterdocs()->assets->icon( 'social/facebook.svg' ),
14 'icon-2' => betterdocs()->assets->icon( 'social/facebook-box-line.svg' ),
15 'link' => 'https://www.facebook.com/sharer/sharer.php?u=' . $_permalink
16 ],
17 'twitter' => [
18 'alt' => 'X',
19 'icon' => betterdocs()->assets->icon( 'social/twitter.svg' ),
20 'icon-2' => betterdocs()->assets->icon( 'social/twitter-x-line.svg' ),
21 'link' => 'https://twitter.com/intent/tweet?url=' . $_permalink
22 ],
23 'linkedin' => [
24 'alt' => 'LinkedIn',
25 'icon' => betterdocs()->assets->icon( 'social/linkedin.svg' ),
26 'icon-2' => betterdocs()->assets->icon( 'social/linkedin-box-line.svg' ),
27 'link' => 'https://www.linkedin.com/shareArticle?mini=true&url=' . $_permalink
28 ],
29 'pinterest' => [
30 'alt' => 'Pinterest',
31 'icon' => betterdocs()->assets->icon( 'social/pinterest.svg' ),
32 'icon-2' => betterdocs()->assets->icon( 'social/pinterest-line.svg' ),
33 'link' => 'https://pinterest.com/pin/create/button/?url=' . $_permalink
34 ],
35 // 'instagram' => [
36 // 'alt' => 'Instagram',
37 // 'icon' => betterdocs()->assets->icon( 'social/instagram.svg' ),
38 // 'icon-2' => betterdocs()->assets->icon( 'social/instagram-line.svg' ),
39 // 'link' => 'https://pinterest.com/pin/create/button/?url=' . $_permalink
40 // ]
41 ];
42
43 return array_filter(
44 $_defaults,
45 function ( $key ) {
46 return array_key_exists( $key, $this->attributes ) && (bool) filter_var( $this->attributes[ $key ], FILTER_VALIDATE_BOOLEAN );
47 },
48 ARRAY_FILTER_USE_KEY
49 );
50 }
51
52 public function view_params() {
53 $links = $this->generate_links();
54 $this->attributes['links'] = $links;
55
56 if ( isset( $this->attributes['share_title_select_layout_layout'] ) && $this->attributes['share_title_select_layout_layout'] == 'layout-2' ) { // for elementor only
57 $this->view_wrapper .= ' layout-2';
58 }
59
60 if ( isset( $this->attributes['layout'] ) && $this->attributes['layout'] == 'layout-2' ) { //for blocks
61 $this->view_wrapper .= ' layout-2';
62 }
63
64 return [
65 'links' => $links
66 ];
67 }
68 }
69