Completed
Push — master ( d1aa46...0c3199 )
by Daryl
05:18 queued 02:56
created
wp-share-this.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,11 +82,11 @@  discard block
 block discarded – undo
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
-		foreach ( self::$_services as $service => $params ) {
88
-			$args = array_merge( $params, $args );
89
-			self::_render_sharing_link( $args, $service, $post );
87
+		foreach (self::$_services as $service => $params) {
88
+			$args = array_merge($params, $args);
89
+			self::_render_sharing_link($args, $service, $post);
90 90
 		}
91 91
 
92 92
 	}
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 * @param string   $service
97 97
 	 * @param \WP_Post $post
98 98
 	 */
99
-	public static function _render_sharing_link( $params, $service, $post ) {
99
+	public static function _render_sharing_link($params, $service, $post) {
100 100
 
101
-		$classes = apply_filters( "wpst_link_classes_{$service}", array() );
101
+		$classes = apply_filters("wpst_link_classes_{$service}", array());
102 102
 
103 103
 		// set some defaults
104
-		$args = wp_parse_args( $params, array(
104
+		$args = wp_parse_args($params, array(
105 105
 			'url'         => null,
106 106
 			'short_url'   => null,
107 107
 			'title'       => null,
@@ -110,39 +110,39 @@  discard block
 block discarded – undo
110 110
 			'username'    => null,
111 111
 			'message'     => null,
112 112
 			'share_count' => true,
113
-		) );
113
+		));
114 114
 
115 115
 		// if we have a post, we will use post values for the defaults
116
-		if ( $post instanceof \WP_Post ) {
117
-			$args = wp_parse_args( $params, array(
118
-				'url'         => get_permalink( $post ),
116
+		if ($post instanceof \WP_Post) {
117
+			$args = wp_parse_args($params, array(
118
+				'url'         => get_permalink($post),
119 119
 				'short_url'   => null,
120 120
 				'title'       => $post->post_title,
121 121
 				'image'       => null,
122
-				'description' => get_the_excerpt( $post ),
122
+				'description' => get_the_excerpt($post),
123 123
 				'username'    => null,
124 124
 				'message'     => null,
125 125
 				'share_count' => true,
126
-			) );
126
+			));
127 127
 
128
-			if ( has_post_thumbnail( $post ) ) {
129
-				$args['image'] = get_the_post_thumbnail_url( $post );
128
+			if (has_post_thumbnail($post)) {
129
+				$args['image'] = get_the_post_thumbnail_url($post);
130 130
 			}
131 131
 		}
132 132
 
133 133
 		printf(
134 134
 			'<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>',
135 135
 			$service,
136
-			implode( ' ', apply_filters( 'wpst_link_classes', $classes, $service ) ),
137
-			self::_item_sharing_property( 'url',         $args['url'] ),
138
-			self::_item_sharing_property( 'short_url',   $args['short_url'] ),
139
-			self::_item_sharing_property( 'title',       $args['title'] ),
140
-			self::_item_sharing_property( 'image',       $args['image'] ),
141
-			self::_item_sharing_property( 'description', $args['description'] ),
142
-			self::_item_sharing_property( 'username',    $args['username'] ),
143
-			self::_item_sharing_property( 'message',     $args['message'] ),
144
-			apply_filters( 'wpst_link_text', ucfirst( $service ) ),
145
-			self::_item_sharing_count( $args['share_count'] )
136
+			implode(' ', apply_filters('wpst_link_classes', $classes, $service)),
137
+			self::_item_sharing_property('url', $args['url']),
138
+			self::_item_sharing_property('short_url', $args['short_url']),
139
+			self::_item_sharing_property('title', $args['title']),
140
+			self::_item_sharing_property('image', $args['image']),
141
+			self::_item_sharing_property('description', $args['description']),
142
+			self::_item_sharing_property('username', $args['username']),
143
+			self::_item_sharing_property('message', $args['message']),
144
+			apply_filters('wpst_link_text', ucfirst($service)),
145
+			self::_item_sharing_count($args['share_count'])
146 146
 		);
147 147
 
148 148
 	}
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	private static function _facebook_og() {
154 154
 
155
-		printf( '<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url() );
155
+		printf('<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url());
156 156
 		print '<meta property="og:type" content="article" />' . PHP_EOL;
157
-		printf( '<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title() );
157
+		printf('<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title());
158 158
 
159
-		if ( ! ( empty( $description = self::_og_description() ) ) ) {
160
-			printf(	'<meta property="og:description" content="%1$s" />' . PHP_EOL, $description );
159
+		if ( ! (empty($description = self::_og_description()))) {
160
+			printf('<meta property="og:description" content="%1$s" />' . PHP_EOL, $description);
161 161
 		}
162 162
 
163
-		if ( $image_url = self::_og_image() ) {
164
-			printf( '<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url );
163
+		if ($image_url = self::_og_image()) {
164
+			printf('<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url);
165 165
 		}
166 166
 
167 167
 	}
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$url = get_permalink();
175 175
 
176
-		if ( is_home() || is_front_page() ) {
176
+		if (is_home() || is_front_page()) {
177 177
 			$url = home_url();
178 178
 		}
179 179
 
180
-		return apply_filters( 'wpst_og_url', esc_url( $url ) );
180
+		return apply_filters('wpst_og_url', esc_url($url));
181 181
 
182 182
 	}
183 183
 
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 
189 189
 		$title = get_the_title();
190 190
 
191
-		if ( is_home() || is_front_page() ) {
192
-			$title = get_bloginfo( 'name' );
191
+		if (is_home() || is_front_page()) {
192
+			$title = get_bloginfo('name');
193 193
 		}
194 194
 
195
-		return apply_filters( 'wpst_og_title', wp_kses_post( $title ) );
195
+		return apply_filters('wpst_og_title', wp_kses_post($title));
196 196
 
197 197
 	}
198 198
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	private static function _og_description() {
203 203
 
204
-		$description = apply_filters( 'the_excerpt', get_the_excerpt() );
204
+		$description = apply_filters('the_excerpt', get_the_excerpt());
205 205
 
206
-		if ( is_home() || is_front_page() ) {
207
-			$description = get_bloginfo( 'description' );
206
+		if (is_home() || is_front_page()) {
207
+			$description = get_bloginfo('description');
208 208
 		}
209 209
 
210
-		return apply_filters( 'wpst_og_description', esc_html( $description ) );
210
+		return apply_filters('wpst_og_description', esc_html($description));
211 211
 
212 212
 	}
213 213
 
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
 
219 219
 		$image_url = get_the_post_thumbnail_url();
220 220
 
221
-		if ( is_home() || is_front_page() ) {
221
+		if (is_home() || is_front_page()) {
222 222
 			$image_url = '';
223 223
 		}
224 224
 
225
-		return apply_filters( 'wpst_og_image', esc_url( $image_url ) );
225
+		return apply_filters('wpst_og_image', esc_url($image_url));
226 226
 
227 227
 	}
228 228
 
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return string
234 234
 	 */
235
-	private static function _item_sharing_property( $property, $value ) {
235
+	private static function _item_sharing_property($property, $value) {
236 236
 
237 237
 		$text  = '';
238
-		$maybe = apply_filters( "wpst_item_{$property}", $value );
238
+		$maybe = apply_filters("wpst_item_{$property}", $value);
239 239
 
240
-		if ( ! empty( $maybe ) ) {
241
-			$text = sprintf( ' data-%1$s="%2$s" ', str_replace('_', '-', $property ), esc_attr( $maybe ) );
240
+		if ( ! empty($maybe)) {
241
+			$text = sprintf(' data-%1$s="%2$s" ', str_replace('_', '-', $property), esc_attr($maybe));
242 242
 		}
243 243
 
244 244
 		return $text;
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return string
252 252
 	 */
253
-	private static function _item_sharing_count( $show ) {
253
+	private static function _item_sharing_count($show) {
254 254
 
255 255
 		$text = '';
256 256
 
257
-		if ( $show ) {
257
+		if ($show) {
258 258
 			$text = '<span class="count"></span>';
259 259
 		}
260 260
 
Please login to merge, or discard this patch.