PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.70
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.70
9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 8.5.4 All 221 releases
wpvr / public / classes / class-wpvr-common.php

class-wpvr-common.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.70, at public/classes/class-wpvr-common.php

153 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 /**
4 * Responsible for managing Helper for WPVR Public
5 *
6 * @link http://rextheme.com/
7 * @since 8.0.0
8 *
9 * @package Wpvr
10 * @subpackage Wpvr/admin/classes
11 */
12 Class WPVR_Helper {
13
14 /**
15 * Generates an array of social media share links for the given page URL.
16 *
17 * @param string $page_url The URL of the page to be shared on social media.
18 *
19 * @return array Associative array containing social media platforms with their respective details.
20 * Each platform has an 'icon' (image URL), 'url' (share link URL), and 'class' (CSS class).
21 *
22 * @filter wpvr_social_media_link Allows filtering of the social media array before returning.
23 */
24 public static function social_media_share_links($page_url)
25 {
26 $social_media = array(
27 'facebook' => array(
28 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/facebook-icon.png',
29 'url' => 'https://www.facebook.com/sharer/sharer.php?u='.$page_url,
30 'class' => 'wpvr-facebook-icon',
31 ),
32 'linkedin' => array(
33 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/linkedin-icon.png',
34 'url' => 'https://www.linkedin.com/shareArticle?url='.$page_url,
35 'class' => 'wpvr-linkedin-icon',
36 ),
37 'twitter' => array(
38 // 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/twitter-icon.png',
39 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/x.png',
40 'url' => 'https://twitter.com/intent/tweet?url='.$page_url,
41 'class' => 'wpvr-twitter-icon',
42 ),
43 'email' => array(
44 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/email.png',
45 'url' => 'mailto:?body='.$page_url,
46 'class' => 'wpvr-email-icon',
47 ),
48 'reddit' => array(
49 'icon' => WPVR_PLUGIN_PUBLIC_DIR_URL.'image/reddit-icon.png',
50 'url' => 'https://www.reddit.com/submit?url='.$page_url,
51 'class' => 'wpvr-reddit-icon',
52 ),
53 );
54
55 /**
56 * Allows filtering of the social media array before returning.
57 *
58 * @param array $social_media Associative array containing social media platforms with their respective details.
59 * Each platform has an 'icon' (image URL), 'url' (share link URL), and 'class' (CSS class).
60 * @return array Modified social media array.
61 */
62
63 return apply_filters('wpvr_social_media_link',$social_media);
64 }
65
66 /**
67 * Displays social media share links for the given page URL.
68 *
69 * @param string $page_url The URL of the page to be shared on social media.
70 *
71 * @return void Outputs HTML for social media share links.
72 */
73 public static function social_media_share_links_display($page_url)
74 {
75 $social_media = self::social_media_share_links($page_url);
76 foreach ($social_media as $platform => $data) {
77 /**
78 * Outputs HTML for a social media share link.
79 *
80 * @param string $platform The social media platform (e.g., 'facebook', 'linkedin').
81 * @param string $icon The URL of the social media icon image.
82 * @param string $url The share link URL for the platform.
83 * @param string $class The CSS class for styling the social media icon.
84 */
85 echo self::generateSocialMediaLink($platform, $data['icon'], $data['url'],$data['class']);
86 }
87 }
88
89 /**
90 * Generates HTML for a social media share link.
91 *
92 * @param string $platform The social media platform (e.g., 'facebook', 'linkedin').
93 * @param string $iconPath The URL of the social media icon image.
94 * @param string $profileUrl The share link URL for the platform.
95 * @param string $class The CSS class for styling the social media icon.
96 *
97 * @return string HTML code for the social media share link.
98 */
99 public static function generateSocialMediaLink($platform, $iconPath, $profileUrl,$class) {
100 return sprintf(
101 '<a href="%s" class="%s" target="_blank"><img src="%s" alt="%s"></a>',
102 $profileUrl,
103 $class,
104 $iconPath,
105 ucfirst($platform)
106 );
107 }
108
109 /**
110 * Checks if social sharing is enabled for a given tour data.
111 *
112 * @param array $tour_data The data associated with the tour.
113 *
114 * @return string Returns 'on' if social sharing is enabled, 'off' otherwise.
115 */
116 public static function is_enable_social_share($tour_data)
117 {
118 /**
119 * Check if social sharing is enabled for a given tour.
120 *
121 * @param array $tour_data The data associated with the tour.
122 *
123 * @return string Returns 'on' if social sharing is enabled, 'off' otherwise.
124 */
125 return isset($tour_data['wpvr_social_share'])? $tour_data['wpvr_social_share'] : 'off';
126 }
127 /**
128 * Generates HTML for social media share links suitable for embedding in a page.
129 *
130 * @param string $page_url The URL of the page to be shared on social media.
131 *
132 * @return string HTML code for social media share links.
133 */
134 public static function social_media_share_links_display_in_embed($page_url)
135 {
136 $html = '';
137 $social_media = self::social_media_share_links($page_url);
138 foreach ($social_media as $platform => $data) {
139 /**
140 * Generates HTML for a social media share link suitable for embedding in a page.
141 *
142 * @param string $platform The social media platform (e.g., 'facebook', 'linkedin').
143 * @param string $icon The URL of the social media icon image.
144 * @param string $url The share link URL for the platform.
145 * @param string $class The CSS class for styling the social media icon.
146 *
147 * @return string HTML code for the social media share link.
148 */
149 $html .= self::generateSocialMediaLink($platform, $data['icon'], $data['url'],$data['class']);
150 }
151 return $html;
152 }
153 }