@@ -15,119 +15,119 @@ |
||
15 | 15 | class Button { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Services available. |
|
20 | - * |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - public $services = array( |
|
24 | - 'facebook', |
|
25 | - 'twitter', |
|
26 | - 'pinterest', |
|
27 | - ); |
|
28 | - |
|
29 | - /** |
|
30 | - * Current service. |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - public $service = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * Constructor. |
|
38 | - */ |
|
39 | - public function __construct( $service, $options, $prefix = 'sharing' ) { |
|
40 | - $this->options = $options; |
|
41 | - if ( ! in_array($service, $this->services, true) ) { |
|
42 | - return; |
|
43 | - } |
|
44 | - if ( \lsx\sharing\includes\functions\is_button_disabled('global', $service) || \lsx\sharing\includes\functions\is_button_disabled($prefix, $service) ) { |
|
45 | - return ''; |
|
46 | - } |
|
47 | - $this->service = $service; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Get service link to share. |
|
52 | - */ |
|
53 | - public function get_link( $post ) { |
|
54 | - if ( empty($post) ) { |
|
55 | - return ''; |
|
56 | - } |
|
57 | - |
|
58 | - if ( 'email' === $this->service ) { |
|
59 | - return $this->get_link_email($post); |
|
60 | - } elseif ( 'facebook' === $this->service ) { |
|
61 | - return $this->get_link_facebook($post); |
|
62 | - } elseif ( 'twitter' === $this->service ) { |
|
63 | - return $this->get_link_twitter($post); |
|
64 | - } elseif ( 'pinterest' === $this->service ) { |
|
65 | - return $this->get_link_pinterest($post); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Get Facebook link to share. |
|
71 | - */ |
|
72 | - public function get_link_facebook( $post ) { |
|
73 | - $permalink = get_permalink($post->ID); |
|
74 | - $permalink = apply_filters('lsx_sharing_facebook_url', $permalink, $post); |
|
75 | - $title = apply_filters('the_title', $post->post_title); |
|
76 | - |
|
77 | - return 'https://www.facebook.com/sharer.php?display=page&u=' . rawurlencode($permalink) . '&t=' . rawurlencode($title); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Get Twitter link to share. |
|
82 | - */ |
|
83 | - public function get_link_twitter( $post ) { |
|
84 | - $permalink = get_permalink($post->ID); |
|
85 | - $permalink = apply_filters('lsx_sharing_twitter_url', $permalink, $post); |
|
86 | - $title = apply_filters('the_title', $post->post_title); |
|
87 | - |
|
88 | - if ( function_exists('mb_stripos') ) { |
|
89 | - $strlen = 'mb_strlen'; |
|
90 | - $substr = 'mb_substr'; |
|
91 | - } else { |
|
92 | - $strlen = 'strlen'; |
|
93 | - $substr = 'substr'; |
|
94 | - } |
|
95 | - |
|
96 | - $short_url_length = 24; |
|
97 | - |
|
98 | - if ( ( $strlen($title) + $short_url_length ) > 140 ) { |
|
99 | - $text = $substr($title, 0, ( 140 - $short_url_length - 1 )) . "\xE2\x80\xA6"; |
|
100 | - } else { |
|
101 | - $text = $title; |
|
102 | - } |
|
103 | - |
|
104 | - return 'https://twitter.com/intent/tweet?text=' . rawurlencode($text) . '&url=' . rawurlencode($permalink); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get Pinterest link to share. |
|
109 | - */ |
|
110 | - public function get_link_pinterest( $post ) { |
|
111 | - $image = ''; |
|
112 | - $permalink = get_permalink($post->ID); |
|
113 | - $permalink = apply_filters('lsx_sharing_pinterest_url', $permalink, $post); |
|
114 | - $title = apply_filters('the_title', $post->post_title); |
|
115 | - |
|
116 | - if ( ! has_post_thumbnail($post) ) { |
|
117 | - if ( class_exists('lsx\legacy\Placeholders') ) { |
|
118 | - $image = \lsx\legacy\Placeholders::placeholder_url(null, $post->post_type); |
|
119 | - } elseif ( class_exists('LSX_Placeholders') ) { |
|
120 | - $image = \LSX_Placeholders::placeholder_url(null, $post->post_type); |
|
121 | - } |
|
122 | - } else { |
|
123 | - $image = get_the_post_thumbnail_url($post->ID, 'large'); |
|
124 | - } |
|
125 | - |
|
126 | - return 'https://www.pinterest.com/pin/create/button/?url=' . rawurlencode($permalink) . '&media=' . rawurlencode($image) . '&description=' . rawurlencode($title); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Get Email Link. |
|
131 | - */ |
|
132 | - public function get_link_email() { } |
|
18 | + /** |
|
19 | + * Services available. |
|
20 | + * |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + public $services = array( |
|
24 | + 'facebook', |
|
25 | + 'twitter', |
|
26 | + 'pinterest', |
|
27 | + ); |
|
28 | + |
|
29 | + /** |
|
30 | + * Current service. |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + public $service = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * Constructor. |
|
38 | + */ |
|
39 | + public function __construct( $service, $options, $prefix = 'sharing' ) { |
|
40 | + $this->options = $options; |
|
41 | + if ( ! in_array($service, $this->services, true) ) { |
|
42 | + return; |
|
43 | + } |
|
44 | + if ( \lsx\sharing\includes\functions\is_button_disabled('global', $service) || \lsx\sharing\includes\functions\is_button_disabled($prefix, $service) ) { |
|
45 | + return ''; |
|
46 | + } |
|
47 | + $this->service = $service; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Get service link to share. |
|
52 | + */ |
|
53 | + public function get_link( $post ) { |
|
54 | + if ( empty($post) ) { |
|
55 | + return ''; |
|
56 | + } |
|
57 | + |
|
58 | + if ( 'email' === $this->service ) { |
|
59 | + return $this->get_link_email($post); |
|
60 | + } elseif ( 'facebook' === $this->service ) { |
|
61 | + return $this->get_link_facebook($post); |
|
62 | + } elseif ( 'twitter' === $this->service ) { |
|
63 | + return $this->get_link_twitter($post); |
|
64 | + } elseif ( 'pinterest' === $this->service ) { |
|
65 | + return $this->get_link_pinterest($post); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Get Facebook link to share. |
|
71 | + */ |
|
72 | + public function get_link_facebook( $post ) { |
|
73 | + $permalink = get_permalink($post->ID); |
|
74 | + $permalink = apply_filters('lsx_sharing_facebook_url', $permalink, $post); |
|
75 | + $title = apply_filters('the_title', $post->post_title); |
|
76 | + |
|
77 | + return 'https://www.facebook.com/sharer.php?display=page&u=' . rawurlencode($permalink) . '&t=' . rawurlencode($title); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Get Twitter link to share. |
|
82 | + */ |
|
83 | + public function get_link_twitter( $post ) { |
|
84 | + $permalink = get_permalink($post->ID); |
|
85 | + $permalink = apply_filters('lsx_sharing_twitter_url', $permalink, $post); |
|
86 | + $title = apply_filters('the_title', $post->post_title); |
|
87 | + |
|
88 | + if ( function_exists('mb_stripos') ) { |
|
89 | + $strlen = 'mb_strlen'; |
|
90 | + $substr = 'mb_substr'; |
|
91 | + } else { |
|
92 | + $strlen = 'strlen'; |
|
93 | + $substr = 'substr'; |
|
94 | + } |
|
95 | + |
|
96 | + $short_url_length = 24; |
|
97 | + |
|
98 | + if ( ( $strlen($title) + $short_url_length ) > 140 ) { |
|
99 | + $text = $substr($title, 0, ( 140 - $short_url_length - 1 )) . "\xE2\x80\xA6"; |
|
100 | + } else { |
|
101 | + $text = $title; |
|
102 | + } |
|
103 | + |
|
104 | + return 'https://twitter.com/intent/tweet?text=' . rawurlencode($text) . '&url=' . rawurlencode($permalink); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get Pinterest link to share. |
|
109 | + */ |
|
110 | + public function get_link_pinterest( $post ) { |
|
111 | + $image = ''; |
|
112 | + $permalink = get_permalink($post->ID); |
|
113 | + $permalink = apply_filters('lsx_sharing_pinterest_url', $permalink, $post); |
|
114 | + $title = apply_filters('the_title', $post->post_title); |
|
115 | + |
|
116 | + if ( ! has_post_thumbnail($post) ) { |
|
117 | + if ( class_exists('lsx\legacy\Placeholders') ) { |
|
118 | + $image = \lsx\legacy\Placeholders::placeholder_url(null, $post->post_type); |
|
119 | + } elseif ( class_exists('LSX_Placeholders') ) { |
|
120 | + $image = \LSX_Placeholders::placeholder_url(null, $post->post_type); |
|
121 | + } |
|
122 | + } else { |
|
123 | + $image = get_the_post_thumbnail_url($post->ID, 'large'); |
|
124 | + } |
|
125 | + |
|
126 | + return 'https://www.pinterest.com/pin/create/button/?url=' . rawurlencode($permalink) . '&media=' . rawurlencode($image) . '&description=' . rawurlencode($title); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Get Email Link. |
|
131 | + */ |
|
132 | + public function get_link_email() { } |
|
133 | 133 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * @package lsx-sharing |
14 | 14 | */ |
15 | -class Button { |
|
15 | +class Button{ |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @var array |
22 | 22 | */ |
23 | - public $services = array( |
|
23 | + public $services=array( |
|
24 | 24 | 'facebook', |
25 | 25 | 'twitter', |
26 | 26 | 'pinterest', |
@@ -31,37 +31,37 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @var string |
33 | 33 | */ |
34 | - public $service = ''; |
|
34 | + public $service=''; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Constructor. |
38 | 38 | */ |
39 | - public function __construct( $service, $options, $prefix = 'sharing' ) { |
|
40 | - $this->options = $options; |
|
41 | - if ( ! in_array($service, $this->services, true) ) { |
|
39 | + public function __construct($service,$options,$prefix='sharing'){ |
|
40 | + $this->options=$options; |
|
41 | + if(!in_array($service,$this->services,true)){ |
|
42 | 42 | return; |
43 | 43 | } |
44 | - if ( \lsx\sharing\includes\functions\is_button_disabled('global', $service) || \lsx\sharing\includes\functions\is_button_disabled($prefix, $service) ) { |
|
44 | + if(\lsx\sharing\includes\functions\is_button_disabled('global',$service)||\lsx\sharing\includes\functions\is_button_disabled($prefix,$service)){ |
|
45 | 45 | return ''; |
46 | 46 | } |
47 | - $this->service = $service; |
|
47 | + $this->service=$service; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Get service link to share. |
52 | 52 | */ |
53 | - public function get_link( $post ) { |
|
54 | - if ( empty($post) ) { |
|
53 | + public function get_link($post){ |
|
54 | + if(empty($post)){ |
|
55 | 55 | return ''; |
56 | 56 | } |
57 | 57 | |
58 | - if ( 'email' === $this->service ) { |
|
58 | + if('email'===$this->service){ |
|
59 | 59 | return $this->get_link_email($post); |
60 | - } elseif ( 'facebook' === $this->service ) { |
|
60 | + } elseif('facebook'===$this->service){ |
|
61 | 61 | return $this->get_link_facebook($post); |
62 | - } elseif ( 'twitter' === $this->service ) { |
|
62 | + } elseif('twitter'===$this->service){ |
|
63 | 63 | return $this->get_link_twitter($post); |
64 | - } elseif ( 'pinterest' === $this->service ) { |
|
64 | + } elseif('pinterest'===$this->service){ |
|
65 | 65 | return $this->get_link_pinterest($post); |
66 | 66 | } |
67 | 67 | } |
@@ -69,65 +69,65 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * Get Facebook link to share. |
71 | 71 | */ |
72 | - public function get_link_facebook( $post ) { |
|
73 | - $permalink = get_permalink($post->ID); |
|
74 | - $permalink = apply_filters('lsx_sharing_facebook_url', $permalink, $post); |
|
75 | - $title = apply_filters('the_title', $post->post_title); |
|
72 | + public function get_link_facebook($post){ |
|
73 | + $permalink=get_permalink($post->ID); |
|
74 | + $permalink=apply_filters('lsx_sharing_facebook_url',$permalink,$post); |
|
75 | + $title=apply_filters('the_title',$post->post_title); |
|
76 | 76 | |
77 | - return 'https://www.facebook.com/sharer.php?display=page&u=' . rawurlencode($permalink) . '&t=' . rawurlencode($title); |
|
77 | + return 'https://www.facebook.com/sharer.php?display=page&u='.rawurlencode($permalink).'&t='.rawurlencode($title); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Get Twitter link to share. |
82 | 82 | */ |
83 | - public function get_link_twitter( $post ) { |
|
84 | - $permalink = get_permalink($post->ID); |
|
85 | - $permalink = apply_filters('lsx_sharing_twitter_url', $permalink, $post); |
|
86 | - $title = apply_filters('the_title', $post->post_title); |
|
87 | - |
|
88 | - if ( function_exists('mb_stripos') ) { |
|
89 | - $strlen = 'mb_strlen'; |
|
90 | - $substr = 'mb_substr'; |
|
91 | - } else { |
|
92 | - $strlen = 'strlen'; |
|
93 | - $substr = 'substr'; |
|
83 | + public function get_link_twitter($post){ |
|
84 | + $permalink=get_permalink($post->ID); |
|
85 | + $permalink=apply_filters('lsx_sharing_twitter_url',$permalink,$post); |
|
86 | + $title=apply_filters('the_title',$post->post_title); |
|
87 | + |
|
88 | + if(function_exists('mb_stripos')){ |
|
89 | + $strlen='mb_strlen'; |
|
90 | + $substr='mb_substr'; |
|
91 | + }else{ |
|
92 | + $strlen='strlen'; |
|
93 | + $substr='substr'; |
|
94 | 94 | } |
95 | 95 | |
96 | - $short_url_length = 24; |
|
96 | + $short_url_length=24; |
|
97 | 97 | |
98 | - if ( ( $strlen($title) + $short_url_length ) > 140 ) { |
|
99 | - $text = $substr($title, 0, ( 140 - $short_url_length - 1 )) . "\xE2\x80\xA6"; |
|
100 | - } else { |
|
101 | - $text = $title; |
|
98 | + if(($strlen($title)+$short_url_length)>140){ |
|
99 | + $text=$substr($title,0,(140-$short_url_length-1))."\xE2\x80\xA6"; |
|
100 | + }else{ |
|
101 | + $text=$title; |
|
102 | 102 | } |
103 | 103 | |
104 | - return 'https://twitter.com/intent/tweet?text=' . rawurlencode($text) . '&url=' . rawurlencode($permalink); |
|
104 | + return 'https://twitter.com/intent/tweet?text='.rawurlencode($text).'&url='.rawurlencode($permalink); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Get Pinterest link to share. |
109 | 109 | */ |
110 | - public function get_link_pinterest( $post ) { |
|
111 | - $image = ''; |
|
112 | - $permalink = get_permalink($post->ID); |
|
113 | - $permalink = apply_filters('lsx_sharing_pinterest_url', $permalink, $post); |
|
114 | - $title = apply_filters('the_title', $post->post_title); |
|
115 | - |
|
116 | - if ( ! has_post_thumbnail($post) ) { |
|
117 | - if ( class_exists('lsx\legacy\Placeholders') ) { |
|
118 | - $image = \lsx\legacy\Placeholders::placeholder_url(null, $post->post_type); |
|
119 | - } elseif ( class_exists('LSX_Placeholders') ) { |
|
120 | - $image = \LSX_Placeholders::placeholder_url(null, $post->post_type); |
|
110 | + public function get_link_pinterest($post){ |
|
111 | + $image=''; |
|
112 | + $permalink=get_permalink($post->ID); |
|
113 | + $permalink=apply_filters('lsx_sharing_pinterest_url',$permalink,$post); |
|
114 | + $title=apply_filters('the_title',$post->post_title); |
|
115 | + |
|
116 | + if(!has_post_thumbnail($post)){ |
|
117 | + if(class_exists('lsx\legacy\Placeholders')){ |
|
118 | + $image=\lsx\legacy\Placeholders::placeholder_url(null,$post->post_type); |
|
119 | + } elseif(class_exists('LSX_Placeholders')){ |
|
120 | + $image=\LSX_Placeholders::placeholder_url(null,$post->post_type); |
|
121 | 121 | } |
122 | - } else { |
|
123 | - $image = get_the_post_thumbnail_url($post->ID, 'large'); |
|
122 | + }else{ |
|
123 | + $image=get_the_post_thumbnail_url($post->ID,'large'); |
|
124 | 124 | } |
125 | 125 | |
126 | - return 'https://www.pinterest.com/pin/create/button/?url=' . rawurlencode($permalink) . '&media=' . rawurlencode($image) . '&description=' . rawurlencode($title); |
|
126 | + return 'https://www.pinterest.com/pin/create/button/?url='.rawurlencode($permalink).'&media='.rawurlencode($image).'&description='.rawurlencode($title); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Get Email Link. |
131 | 131 | */ |
132 | - public function get_link_email() { } |
|
132 | + public function get_link_email(){ } |
|
133 | 133 | } |