@@ -32,8 +32,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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, $args['post'] ); |
|
| 92 | + foreach (self::$_services as $service => $params) { |
|
| 93 | + $args = array_merge($params, $args); |
|
| 94 | + self::_render_sharing_link($args, $service, $args['post']); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 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 | |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * @param string $service |
| 113 | 113 | * @param \WP_Post $post |
| 114 | 114 | */ |
| 115 | - private static function _render_sharing_link( $params, $service, $post ) { |
|
| 115 | + private static function _render_sharing_link($params, $service, $post) { |
|
| 116 | 116 | |
| 117 | - $classes = apply_filters( "wpst_link_classes_{$service}", array() ); |
|
| 117 | + $classes = apply_filters("wpst_link_classes_{$service}", array()); |
|
| 118 | 118 | |
| 119 | 119 | // set some defaults |
| 120 | - $args = wp_parse_args( $params, array( |
|
| 120 | + $args = wp_parse_args($params, array( |
|
| 121 | 121 | 'url' => get_the_permalink(), |
| 122 | 122 | 'short_url' => null, |
| 123 | 123 | 'title' => get_the_title(), |
@@ -126,39 +126,39 @@ discard block |
||
| 126 | 126 | 'username' => null, |
| 127 | 127 | 'message' => get_the_excerpt(), |
| 128 | 128 | 'share_count' => true, |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | |
| 131 | 131 | // if we have a post, we will use post values for the defaults |
| 132 | - if ( $post instanceof \WP_Post ) { |
|
| 133 | - $args = wp_parse_args( $params, array( |
|
| 134 | - 'url' => get_permalink( $post ), |
|
| 132 | + if ($post instanceof \WP_Post) { |
|
| 133 | + $args = wp_parse_args($params, array( |
|
| 134 | + 'url' => get_permalink($post), |
|
| 135 | 135 | 'short_url' => null, |
| 136 | - 'title' => get_the_title( $post ), |
|
| 136 | + 'title' => get_the_title($post), |
|
| 137 | 137 | 'image' => null, |
| 138 | - 'description' => get_the_excerpt( $post ), |
|
| 138 | + 'description' => get_the_excerpt($post), |
|
| 139 | 139 | 'username' => null, |
| 140 | - 'message' => get_the_excerpt( $post ), |
|
| 140 | + 'message' => get_the_excerpt($post), |
|
| 141 | 141 | 'share_count' => true, |
| 142 | - ) ); |
|
| 142 | + )); |
|
| 143 | 143 | |
| 144 | - if ( has_post_thumbnail( $post ) ) { |
|
| 145 | - $args['image'] = get_the_post_thumbnail_url( $post ); |
|
| 144 | + if (has_post_thumbnail($post)) { |
|
| 145 | + $args['image'] = get_the_post_thumbnail_url($post); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | printf( |
| 150 | 150 | '<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>', |
| 151 | 151 | $service, |
| 152 | - implode( ' ', apply_filters( 'wpst_link_classes', $classes, $service ) ), |
|
| 153 | - self::_item_sharing_property( 'url', $args['url'] ), |
|
| 154 | - self::_item_sharing_property( 'short_url', $args['short_url'] ), |
|
| 155 | - self::_item_sharing_property( 'title', $args['title'] ), |
|
| 156 | - self::_item_sharing_property( 'image', $args['image'] ), |
|
| 157 | - self::_item_sharing_property( 'description', $args['description'] ), |
|
| 158 | - self::_item_sharing_property( 'username', $args['username'] ), |
|
| 159 | - self::_item_sharing_property( 'message', $args['message'] . "\r\n\r\n" . $args['url'] ), |
|
| 160 | - apply_filters( 'wpst_link_text', ucfirst( $service ) ), |
|
| 161 | - self::_item_sharing_count( $args['share_count'] ) |
|
| 152 | + implode(' ', apply_filters('wpst_link_classes', $classes, $service)), |
|
| 153 | + self::_item_sharing_property('url', $args['url']), |
|
| 154 | + self::_item_sharing_property('short_url', $args['short_url']), |
|
| 155 | + self::_item_sharing_property('title', $args['title']), |
|
| 156 | + self::_item_sharing_property('image', $args['image']), |
|
| 157 | + self::_item_sharing_property('description', $args['description']), |
|
| 158 | + self::_item_sharing_property('username', $args['username']), |
|
| 159 | + self::_item_sharing_property('message', $args['message'] . "\r\n\r\n" . $args['url']), |
|
| 160 | + apply_filters('wpst_link_text', ucfirst($service)), |
|
| 161 | + self::_item_sharing_count($args['share_count']) |
|
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | 164 | } |
@@ -168,16 +168,16 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | private static function _facebook_og() { |
| 170 | 170 | |
| 171 | - printf( '<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url() ); |
|
| 172 | - printf( '<meta property="og:type" content="%1$s" />' . PHP_EOL, self::_og_type() ); |
|
| 173 | - printf( '<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title() ); |
|
| 171 | + printf('<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url()); |
|
| 172 | + printf('<meta property="og:type" content="%1$s" />' . PHP_EOL, self::_og_type()); |
|
| 173 | + printf('<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title()); |
|
| 174 | 174 | |
| 175 | - if ( ! ( empty( $description = self::_og_description() ) ) ) { |
|
| 176 | - printf( '<meta property="og:description" content="%1$s" />' . PHP_EOL, $description ); |
|
| 175 | + if ( ! (empty($description = self::_og_description()))) { |
|
| 176 | + printf('<meta property="og:description" content="%1$s" />' . PHP_EOL, $description); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $image_url = self::_og_image() ) { |
|
| 180 | - printf( '<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url ); |
|
| 179 | + if ($image_url = self::_og_image()) { |
|
| 180 | + printf('<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $url = get_permalink(); |
| 191 | 191 | |
| 192 | - if ( is_home() || is_front_page() ) { |
|
| 192 | + if (is_home() || is_front_page()) { |
|
| 193 | 193 | $url = home_url(); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - return apply_filters( 'wpst_og_url', esc_url( $url ) ); |
|
| 196 | + return apply_filters('wpst_og_url', esc_url($url)); |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $type = 'website'; |
| 206 | 206 | |
| 207 | - if ( is_single() ) { |
|
| 207 | + if (is_single()) { |
|
| 208 | 208 | $type = 'article'; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - return apply_filters( 'wpst_og_type', $type ); |
|
| 211 | + return apply_filters('wpst_og_type', $type); |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $title = get_the_title(); |
| 222 | 222 | |
| 223 | - if ( is_home() || is_front_page() ) { |
|
| 224 | - $title = get_bloginfo( 'name' ); |
|
| 223 | + if (is_home() || is_front_page()) { |
|
| 224 | + $title = get_bloginfo('name'); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - return apply_filters( 'wpst_og_title', wp_kses_post( $title ) ); |
|
| 227 | + return apply_filters('wpst_og_title', wp_kses_post($title)); |
|
| 228 | 228 | |
| 229 | 229 | } |
| 230 | 230 | |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | private static function _og_description() { |
| 235 | 235 | |
| 236 | - $description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 236 | + $description = apply_filters('the_excerpt', get_the_excerpt()); |
|
| 237 | 237 | |
| 238 | - if ( is_home() || is_front_page() ) { |
|
| 239 | - $description = get_bloginfo( 'description' ); |
|
| 238 | + if (is_home() || is_front_page()) { |
|
| 239 | + $description = get_bloginfo('description'); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return apply_filters( 'wpst_og_description', esc_html( $description ) ); |
|
| 242 | + return apply_filters('wpst_og_description', esc_html($description)); |
|
| 243 | 243 | |
| 244 | 244 | } |
| 245 | 245 | |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $image_url = get_the_post_thumbnail_url(); |
| 252 | 252 | |
| 253 | - if ( is_home() || is_front_page() ) { |
|
| 253 | + if (is_home() || is_front_page()) { |
|
| 254 | 254 | $image_url = ''; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - return apply_filters( 'wpst_og_image', esc_url( $image_url ) ); |
|
| 257 | + return apply_filters('wpst_og_image', esc_url($image_url)); |
|
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | |
@@ -264,13 +264,13 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | - private static function _item_sharing_property( $property, $value ) { |
|
| 267 | + private static function _item_sharing_property($property, $value) { |
|
| 268 | 268 | |
| 269 | 269 | $text = ''; |
| 270 | - $maybe = apply_filters( "wpst_item_{$property}", $value ); |
|
| 270 | + $maybe = apply_filters("wpst_item_{$property}", $value); |
|
| 271 | 271 | |
| 272 | - if ( ! empty( $maybe ) ) { |
|
| 273 | - $text = sprintf( ' data-%1$s="%2$s" ', str_replace('_', '-', $property ), esc_attr( $maybe ) ); |
|
| 272 | + if ( ! empty($maybe)) { |
|
| 273 | + $text = sprintf(' data-%1$s="%2$s" ', str_replace('_', '-', $property), esc_attr($maybe)); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | return $text; |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return string |
| 284 | 284 | */ |
| 285 | - private static function _item_sharing_count( $show ) { |
|
| 285 | + private static function _item_sharing_count($show) { |
|
| 286 | 286 | |
| 287 | 287 | $text = ''; |
| 288 | 288 | |
| 289 | - if ( $show ) { |
|
| 289 | + if ($show) { |
|
| 290 | 290 | $text = '<span class="count"></span>'; |
| 291 | 291 | } |
| 292 | 292 | |