@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public static function initialize() { |
32 | 32 | |
33 | - add_action( 'wp_enqueue_scripts', array( __CLASS__, '_wp_enqueue_scripts' ) ); |
|
34 | - add_action( 'wp_head', array( __CLASS__, '_wp_head' ) ); |
|
33 | + add_action('wp_enqueue_scripts', array(__CLASS__, '_wp_enqueue_scripts')); |
|
34 | + add_action('wp_head', array(__CLASS__, '_wp_head')); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $id = self::$_id; |
44 | 44 | |
45 | - wp_enqueue_script('sharethis', "//platform-api.sharethis.com/js/sharethis.js#property={$id}&product=unknown", null, false, true ); |
|
45 | + wp_enqueue_script('sharethis', "//platform-api.sharethis.com/js/sharethis.js#property={$id}&product=unknown", null, false, true); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public static function _wp_head() { |
53 | 53 | |
54 | - if ( self::$_facebook_og ) { |
|
54 | + if (self::$_facebook_og) { |
|
55 | 55 | self::_facebook_og(); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $id |
64 | 64 | */ |
65 | - public static function register_id( $id ) { |
|
65 | + public static function register_id($id) { |
|
66 | 66 | |
67 | 67 | self::$_id = $id; |
68 | 68 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param string $service |
73 | 73 | * @param array $params |
74 | 74 | */ |
75 | - public static function register_service( $service, $params = array() ) { |
|
75 | + public static function register_service($service, $params = array()) { |
|
76 | 76 | |
77 | - self::$_services[ $service ] = $params; |
|
77 | + self::$_services[$service] = $params; |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | * @param \WP_Post|null $post |
83 | 83 | * @param array $args |
84 | 84 | */ |
85 | - public static function the_sharing_links( $post = null, $args = array() ) { |
|
85 | + public static function the_sharing_links($post = null, $args = array()) { |
|
86 | 86 | |
87 | - if ( ! isset( $post ) ) { |
|
87 | + if ( ! isset($post)) { |
|
88 | 88 | $post = get_post(); |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( self::$_services as $service => $params ) { |
|
92 | - $args = array_merge( $params, $args ); |
|
93 | - self::_render_sharing_link( $args, $service, $post ); |
|
91 | + foreach (self::$_services as $service => $params) { |
|
92 | + $args = array_merge($params, $args); |
|
93 | + self::_render_sharing_link($args, $service, $post); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 0.0.2 |
102 | 102 | */ |
103 | - public static function use_og( $use = true ) { |
|
103 | + public static function use_og($use = true) { |
|
104 | 104 | |
105 | 105 | self::$_facebook_og = $use; |
106 | 106 | |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | * @param string $service |
112 | 112 | * @param \WP_Post $post |
113 | 113 | */ |
114 | - private static function _render_sharing_link( $params, $service, $post ) { |
|
114 | + private static function _render_sharing_link($params, $service, $post) { |
|
115 | 115 | |
116 | - $classes = apply_filters( "wpst_link_classes_{$service}", array() ); |
|
116 | + $classes = apply_filters("wpst_link_classes_{$service}", array()); |
|
117 | 117 | |
118 | 118 | // set some defaults |
119 | - $args = wp_parse_args( $params, array( |
|
119 | + $args = wp_parse_args($params, array( |
|
120 | 120 | 'url' => null, |
121 | 121 | 'short_url' => null, |
122 | 122 | 'title' => null, |
@@ -125,39 +125,39 @@ discard block |
||
125 | 125 | 'username' => null, |
126 | 126 | 'message' => null, |
127 | 127 | 'share_count' => true, |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | |
130 | 130 | // if we have a post, we will use post values for the defaults |
131 | - if ( $post instanceof \WP_Post ) { |
|
132 | - $args = wp_parse_args( $params, array( |
|
133 | - 'url' => get_permalink( $post ), |
|
131 | + if ($post instanceof \WP_Post) { |
|
132 | + $args = wp_parse_args($params, array( |
|
133 | + 'url' => get_permalink($post), |
|
134 | 134 | 'short_url' => null, |
135 | 135 | 'title' => $post->post_title, |
136 | 136 | 'image' => null, |
137 | - 'description' => get_the_excerpt( $post ), |
|
137 | + 'description' => get_the_excerpt($post), |
|
138 | 138 | 'username' => null, |
139 | 139 | 'message' => null, |
140 | 140 | 'share_count' => true, |
141 | - ) ); |
|
141 | + )); |
|
142 | 142 | |
143 | - if ( has_post_thumbnail( $post ) ) { |
|
144 | - $args['image'] = get_the_post_thumbnail_url( $post ); |
|
143 | + if (has_post_thumbnail($post)) { |
|
144 | + $args['image'] = get_the_post_thumbnail_url($post); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | printf( |
149 | 149 | '<div data-network="%1$s" class="st-custom-button %2$s"%3$s%4$s%5$s%6$s%7$s%8$s%9$s>%10$s%11$s</div>', |
150 | 150 | $service, |
151 | - implode( ' ', apply_filters( 'wpst_link_classes', $classes, $service ) ), |
|
152 | - self::_item_sharing_property( 'url', $args['url'] ), |
|
153 | - self::_item_sharing_property( 'short_url', $args['short_url'] ), |
|
154 | - self::_item_sharing_property( 'title', $args['title'] ), |
|
155 | - self::_item_sharing_property( 'image', $args['image'] ), |
|
156 | - self::_item_sharing_property( 'description', $args['description'] ), |
|
157 | - self::_item_sharing_property( 'username', $args['username'] ), |
|
158 | - self::_item_sharing_property( 'message', $args['message'] ), |
|
159 | - apply_filters( 'wpst_link_text', ucfirst( $service ) ), |
|
160 | - self::_item_sharing_count( $args['share_count'] ) |
|
151 | + implode(' ', apply_filters('wpst_link_classes', $classes, $service)), |
|
152 | + self::_item_sharing_property('url', $args['url']), |
|
153 | + self::_item_sharing_property('short_url', $args['short_url']), |
|
154 | + self::_item_sharing_property('title', $args['title']), |
|
155 | + self::_item_sharing_property('image', $args['image']), |
|
156 | + self::_item_sharing_property('description', $args['description']), |
|
157 | + self::_item_sharing_property('username', $args['username']), |
|
158 | + self::_item_sharing_property('message', $args['message']), |
|
159 | + apply_filters('wpst_link_text', ucfirst($service)), |
|
160 | + self::_item_sharing_count($args['share_count']) |
|
161 | 161 | ); |
162 | 162 | |
163 | 163 | } |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private static function _facebook_og() { |
169 | 169 | |
170 | - printf( '<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url() ); |
|
170 | + printf('<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url()); |
|
171 | 171 | print '<meta property="og:type" content="article" />' . PHP_EOL; |
172 | - printf( '<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title() ); |
|
172 | + printf('<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title()); |
|
173 | 173 | |
174 | - if ( ! ( empty( $description = self::_og_description() ) ) ) { |
|
175 | - printf( '<meta property="og:description" content="%1$s" />' . PHP_EOL, $description ); |
|
174 | + if ( ! (empty($description = self::_og_description()))) { |
|
175 | + printf('<meta property="og:description" content="%1$s" />' . PHP_EOL, $description); |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( $image_url = self::_og_image() ) { |
|
179 | - printf( '<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url ); |
|
178 | + if ($image_url = self::_og_image()) { |
|
179 | + printf('<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | |
189 | 189 | $url = get_permalink(); |
190 | 190 | |
191 | - if ( is_home() || is_front_page() ) { |
|
191 | + if (is_home() || is_front_page()) { |
|
192 | 192 | $url = home_url(); |
193 | 193 | } |
194 | 194 | |
195 | - return apply_filters( 'wpst_og_url', esc_url( $url ) ); |
|
195 | + return apply_filters('wpst_og_url', esc_url($url)); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | |
204 | 204 | $title = get_the_title(); |
205 | 205 | |
206 | - if ( is_home() || is_front_page() ) { |
|
207 | - $title = get_bloginfo( 'name' ); |
|
206 | + if (is_home() || is_front_page()) { |
|
207 | + $title = get_bloginfo('name'); |
|
208 | 208 | } |
209 | 209 | |
210 | - return apply_filters( 'wpst_og_title', wp_kses_post( $title ) ); |
|
210 | + return apply_filters('wpst_og_title', wp_kses_post($title)); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | */ |
217 | 217 | private static function _og_description() { |
218 | 218 | |
219 | - $description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
219 | + $description = apply_filters('the_excerpt', get_the_excerpt()); |
|
220 | 220 | |
221 | - if ( is_home() || is_front_page() ) { |
|
222 | - $description = get_bloginfo( 'description' ); |
|
221 | + if (is_home() || is_front_page()) { |
|
222 | + $description = get_bloginfo('description'); |
|
223 | 223 | } |
224 | 224 | |
225 | - return apply_filters( 'wpst_og_description', esc_html( $description ) ); |
|
225 | + return apply_filters('wpst_og_description', esc_html($description)); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | |
234 | 234 | $image_url = get_the_post_thumbnail_url(); |
235 | 235 | |
236 | - if ( is_home() || is_front_page() ) { |
|
236 | + if (is_home() || is_front_page()) { |
|
237 | 237 | $image_url = ''; |
238 | 238 | } |
239 | 239 | |
240 | - return apply_filters( 'wpst_og_image', esc_url( $image_url ) ); |
|
240 | + return apply_filters('wpst_og_image', esc_url($image_url)); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return string |
249 | 249 | */ |
250 | - private static function _item_sharing_property( $property, $value ) { |
|
250 | + private static function _item_sharing_property($property, $value) { |
|
251 | 251 | |
252 | 252 | $text = ''; |
253 | - $maybe = apply_filters( "wpst_item_{$property}", $value ); |
|
253 | + $maybe = apply_filters("wpst_item_{$property}", $value); |
|
254 | 254 | |
255 | - if ( ! empty( $maybe ) ) { |
|
256 | - $text = sprintf( ' data-%1$s="%2$s" ', str_replace('_', '-', $property ), esc_attr( $maybe ) ); |
|
255 | + if ( ! empty($maybe)) { |
|
256 | + $text = sprintf(' data-%1$s="%2$s" ', str_replace('_', '-', $property), esc_attr($maybe)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return $text; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return string |
267 | 267 | */ |
268 | - private static function _item_sharing_count( $show ) { |
|
268 | + private static function _item_sharing_count($show) { |
|
269 | 269 | |
270 | 270 | $text = ''; |
271 | 271 | |
272 | - if ( $show ) { |
|
272 | + if ($show) { |
|
273 | 273 | $text = '<span class="count"></span>'; |
274 | 274 | } |
275 | 275 |