PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 2.5.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v2.5.2
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 2.5.2, at includes/Traits/SocialShare.php

47 lines 1.6 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 'link' => 'https://www.facebook.com/sharer/sharer.php?u=' . $_permalink
15 ],
16 'twitter' => [
17 'alt' => 'Twitter',
18 'icon' => betterdocs()->assets->icon( 'social/twitter.svg' ),
19 'link' => 'https://twitter.com/intent/tweet?url=' . $_permalink
20 ],
21 'linkedin' => [
22 'alt' => 'LinkedIn',
23 'icon' => betterdocs()->assets->icon( 'social/linkedin.svg' ),
24 'link' => 'https://www.linkedin.com/shareArticle?mini=true&url=' . $_permalink
25 ],
26 'pinterest' => [
27 'alt' => 'Pinterest',
28 'icon' => betterdocs()->assets->icon( 'social/pinterest.svg' ),
29 'link' => 'https://pinterest.com/pin/create/button/?url=' . $_permalink
30 ]
31 ];
32
33 return array_filter( $_defaults, function ( $key ) {
34 return array_key_exists( $key, $this->attributes ) && (bool) filter_var( $this->attributes[$key], FILTER_VALIDATE_BOOLEAN );
35 }, ARRAY_FILTER_USE_KEY );
36 }
37
38 public function view_params() {
39 $links = $this->generate_links();
40 $this->attributes['links'] = $links;
41
42 return [
43 'links' => $links
44 ];
45 }
46 }
47