Passed
Pull Request — master (#4)
by Daryl
02:51 queued 01:03
created
wp-share-this.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function initialize() {
34 34
 
35
-		add_action( 'wp_enqueue_scripts', array( __CLASS__, '_wp_enqueue_scripts' ) );
36
-		add_action( 'wp_head', array( __CLASS__, '_wp_head' ) );
35
+		add_action('wp_enqueue_scripts', array(__CLASS__, '_wp_enqueue_scripts'));
36
+		add_action('wp_head', array(__CLASS__, '_wp_head'));
37 37
 
38 38
 	}
39 39
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$id = self::$_id;
46 46
 
47
-		wp_enqueue_script('sharethis', "//platform-api.sharethis.com/js/sharethis.js#property={$id}&product=unknown", null, false, true );
47
+		wp_enqueue_script('sharethis', "//platform-api.sharethis.com/js/sharethis.js#property={$id}&product=unknown", null, false, true);
48 48
 
49 49
 	}
50 50
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public static function _wp_head() {
55 55
 
56
-		if ( self::$_facebook_og ) {
56
+		if (self::$_facebook_og) {
57 57
 			self::_facebook_og();
58 58
 		}
59 59
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @param string $id
66 66
 	 */
67
-	public static function register_id( $id ) {
67
+	public static function register_id($id) {
68 68
 
69 69
 		self::$_id = $id;
70 70
 
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
 	 * @param string $service
75 75
 	 * @param array  $params
76 76
 	 */
77
-	public static function register_service( $service, $params = array() ) {
77
+	public static function register_service($service, $params = array()) {
78 78
 
79
-		self::$_services[ $service ] = $params;
79
+		self::$_services[$service] = $params;
80 80
 
81 81
 	}
82 82
 
83 83
 	/**
84 84
 	 * @param array $args
85 85
 	 */
86
-	public static function the_sharing_links( $args = array() ) {
86
+	public static function the_sharing_links($args = array()) {
87 87
 
88
-		$args = wp_parse_args( $args, array(
88
+		$args = wp_parse_args($args, array(
89 89
 			'post' => get_post(),
90
-		) );
90
+		));
91 91
 
92
-		foreach ( self::$_services as $service => $params ) {
93
-			$args = array_merge( $params, $args );
94
-			self::_render_sharing_link( $args, $service );
92
+		foreach (self::$_services as $service => $params) {
93
+			$args = array_merge($params, $args);
94
+			self::_render_sharing_link($args, $service);
95 95
 		}
96 96
 
97 97
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @since 0.0.2
103 103
 	 */
104
-	public static function use_og( $use = true ) {
104
+	public static function use_og($use = true) {
105 105
 
106 106
 		self::$_facebook_og = $use;
107 107
 
@@ -111,45 +111,45 @@  discard block
 block discarded – undo
111 111
 	 * @param array    $params
112 112
 	 * @param string   $service
113 113
 	 */
114
-	private static function _render_sharing_link( $params, $service ) {
114
+	private static function _render_sharing_link($params, $service) {
115 115
 
116
-		$classes = apply_filters( "wpst_link_classes_{$service}", array( $service, ) );
116
+		$classes = apply_filters("wpst_link_classes_{$service}", array($service,));
117 117
 		$post    = get_post();
118 118
 
119
-		if ( $params['post'] instanceof \WP_Post ) {
119
+		if ($params['post'] instanceof \WP_Post) {
120 120
 			$post = $params['post'];
121 121
 		}
122 122
 
123
-		unset( $params['post'] );
123
+		unset($params['post']);
124 124
 
125
-		$args = wp_parse_args( $params, array(
126
-			'url'         => get_permalink( $post ),
125
+		$args = wp_parse_args($params, array(
126
+			'url'         => get_permalink($post),
127 127
 			'short_url'   => null,
128
-			'title'       => get_the_title( $post ),
128
+			'title'       => get_the_title($post),
129 129
 			'image'       => null,
130
-			'description' => get_the_excerpt( $post ),
130
+			'description' => get_the_excerpt($post),
131 131
 			'username'    => null,
132
-			'message'     => get_the_excerpt( $post ),
132
+			'message'     => get_the_excerpt($post),
133 133
 			'share_count' => true,
134
-		) );
134
+		));
135 135
 
136
-		if ( has_post_thumbnail( $post ) ) {
137
-			$args['image'] = get_the_post_thumbnail_url( $post );
136
+		if (has_post_thumbnail($post)) {
137
+			$args['image'] = get_the_post_thumbnail_url($post);
138 138
 		}
139 139
 
140 140
 		printf(
141 141
 			'<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>',
142 142
 			$service,
143
-			implode( ' ', apply_filters( 'wpst_link_classes', $classes, $service ) ),
144
-			self::_item_sharing_property( 'url',         $args['url'] ),
145
-			self::_item_sharing_property( 'short_url',   $args['short_url'] ),
146
-			self::_item_sharing_property( 'title',       $args['title'] ),
147
-			self::_item_sharing_property( 'image',       $args['image'] ),
148
-			self::_item_sharing_property( 'description', $args['description'] ),
149
-			self::_item_sharing_property( 'username',    $args['username'] ),
150
-			self::_item_sharing_property( 'message',     $args['message']  . "\r\n\r\n" . $args['url'] ),
151
-			apply_filters( 'wpst_link_text', ucfirst( $service ) ),
152
-			self::_item_sharing_count( $args['share_count'] )
143
+			implode(' ', apply_filters('wpst_link_classes', $classes, $service)),
144
+			self::_item_sharing_property('url', $args['url']),
145
+			self::_item_sharing_property('short_url', $args['short_url']),
146
+			self::_item_sharing_property('title', $args['title']),
147
+			self::_item_sharing_property('image', $args['image']),
148
+			self::_item_sharing_property('description', $args['description']),
149
+			self::_item_sharing_property('username', $args['username']),
150
+			self::_item_sharing_property('message', $args['message'] . "\r\n\r\n" . $args['url']),
151
+			apply_filters('wpst_link_text', ucfirst($service)),
152
+			self::_item_sharing_count($args['share_count'])
153 153
 		);
154 154
 
155 155
 	}
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	private static function _facebook_og() {
161 161
 
162
-		printf( '<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url() );
163
-		printf( '<meta property="og:type" content="%1$s" />' . PHP_EOL, self::_og_type() );
164
-		printf( '<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title() );
162
+		printf('<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url());
163
+		printf('<meta property="og:type" content="%1$s" />' . PHP_EOL, self::_og_type());
164
+		printf('<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title());
165 165
 
166
-		if ( ! ( empty( $description = self::_og_description() ) ) ) {
167
-			printf(	'<meta property="og:description" content="%1$s" />' . PHP_EOL, $description );
166
+		if ( ! (empty($description = self::_og_description()))) {
167
+			printf('<meta property="og:description" content="%1$s" />' . PHP_EOL, $description);
168 168
 		}
169 169
 
170
-		if ( $image_url = self::_og_image() ) {
171
-			printf( '<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url );
170
+		if ($image_url = self::_og_image()) {
171
+			printf('<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url);
172 172
 		}
173 173
 
174 174
 	}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$url = get_permalink();
182 182
 
183
-		if ( is_home() || is_front_page() ) {
183
+		if (is_home() || is_front_page()) {
184 184
 			$url = home_url();
185 185
 		}
186 186
 
187
-		return apply_filters( 'wpst_og_url', esc_url( $url ) );
187
+		return apply_filters('wpst_og_url', esc_url($url));
188 188
 
189 189
 	}
190 190
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 
196 196
 		$type = 'website';
197 197
 
198
-		if ( is_single() ) {
198
+		if (is_single()) {
199 199
 			$type = 'article';
200 200
 		}
201 201
 
202
-		return apply_filters( 'wpst_og_type', $type );
202
+		return apply_filters('wpst_og_type', $type);
203 203
 
204 204
 	}
205 205
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 
212 212
 		$title = get_the_title();
213 213
 
214
-		if ( is_home() || is_front_page() ) {
215
-			$title = get_bloginfo( 'name' );
214
+		if (is_home() || is_front_page()) {
215
+			$title = get_bloginfo('name');
216 216
 		}
217 217
 
218
-		return apply_filters( 'wpst_og_title', wp_kses_post( $title ) );
218
+		return apply_filters('wpst_og_title', wp_kses_post($title));
219 219
 
220 220
 	}
221 221
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	private static function _og_description() {
226 226
 
227
-		$description = apply_filters( 'the_excerpt', get_the_excerpt() );
227
+		$description = apply_filters('the_excerpt', get_the_excerpt());
228 228
 
229
-		if ( is_home() || is_front_page() ) {
230
-			$description = get_bloginfo( 'description' );
229
+		if (is_home() || is_front_page()) {
230
+			$description = get_bloginfo('description');
231 231
 		}
232 232
 
233
-		return apply_filters( 'wpst_og_description', esc_html( $description ) );
233
+		return apply_filters('wpst_og_description', esc_html($description));
234 234
 
235 235
 	}
236 236
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 
242 242
 		$image_url = get_the_post_thumbnail_url();
243 243
 
244
-		if ( is_home() || is_front_page() ) {
244
+		if (is_home() || is_front_page()) {
245 245
 			$image_url = '';
246 246
 		}
247 247
 
248
-		return apply_filters( 'wpst_og_image', esc_url( $image_url ) );
248
+		return apply_filters('wpst_og_image', esc_url($image_url));
249 249
 
250 250
 	}
251 251
 
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return string
257 257
 	 */
258
-	private static function _item_sharing_property( $property, $value ) {
258
+	private static function _item_sharing_property($property, $value) {
259 259
 
260 260
 		$text  = '';
261
-		$maybe = apply_filters( "wpst_item_{$property}", $value );
261
+		$maybe = apply_filters("wpst_item_{$property}", $value);
262 262
 
263
-		if ( ! empty( $maybe ) ) {
264
-			$text = sprintf( ' data-%1$s="%2$s" ', str_replace('_', '-', $property ), esc_attr( $maybe ) );
263
+		if ( ! empty($maybe)) {
264
+			$text = sprintf(' data-%1$s="%2$s" ', str_replace('_', '-', $property), esc_attr($maybe));
265 265
 		}
266 266
 
267 267
 		return $text;
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return string
275 275
 	 */
276
-	private static function _item_sharing_count( $show ) {
276
+	private static function _item_sharing_count($show) {
277 277
 
278 278
 		$text = '';
279 279
 
280
-		if ( $show ) {
280
+		if ($show) {
281 281
 			$text = '<span class="count"></span>';
282 282
 		}
283 283
 
Please login to merge, or discard this patch.