@@ -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,24 +72,24 @@ 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 | |
| 81 | 81 | /** |
| 82 | 82 | * @param array $args |
| 83 | 83 | */ |
| 84 | - public static function the_sharing_links( $args = array() ) { |
|
| 84 | + public static function the_sharing_links($args = array()) { |
|
| 85 | 85 | |
| 86 | - $args = wp_parse_args( $args, array( |
|
| 86 | + $args = wp_parse_args($args, array( |
|
| 87 | 87 | 'post' => get_post(), |
| 88 | - ) ); |
|
| 88 | + )); |
|
| 89 | 89 | |
| 90 | - foreach ( self::$_services as $service => $params ) { |
|
| 91 | - $args = array_merge( $params, $args ); |
|
| 92 | - self::_render_sharing_link( $args, $service, $args['post'] ); |
|
| 90 | + foreach (self::$_services as $service => $params) { |
|
| 91 | + $args = array_merge($params, $args); |
|
| 92 | + self::_render_sharing_link($args, $service, $args['post']); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @since 0.0.2 |
| 101 | 101 | */ |
| 102 | - public static function use_og( $use = true ) { |
|
| 102 | + public static function use_og($use = true) { |
|
| 103 | 103 | |
| 104 | 104 | self::$_facebook_og = $use; |
| 105 | 105 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | * @param string $service |
| 111 | 111 | * @param \WP_Post $post |
| 112 | 112 | */ |
| 113 | - private static function _render_sharing_link( $params, $service, $post ) { |
|
| 113 | + private static function _render_sharing_link($params, $service, $post) { |
|
| 114 | 114 | |
| 115 | - $classes = apply_filters( "wpst_link_classes_{$service}", array() ); |
|
| 115 | + $classes = apply_filters("wpst_link_classes_{$service}", array()); |
|
| 116 | 116 | |
| 117 | 117 | // set some defaults |
| 118 | - $args = wp_parse_args( $params, array( |
|
| 118 | + $args = wp_parse_args($params, array( |
|
| 119 | 119 | 'url' => null, |
| 120 | 120 | 'short_url' => null, |
| 121 | 121 | 'title' => null, |
@@ -124,39 +124,39 @@ discard block |
||
| 124 | 124 | 'username' => null, |
| 125 | 125 | 'message' => null, |
| 126 | 126 | 'share_count' => true, |
| 127 | - ) ); |
|
| 127 | + )); |
|
| 128 | 128 | |
| 129 | 129 | // if we have a post, we will use post values for the defaults |
| 130 | - if ( $post instanceof \WP_Post ) { |
|
| 131 | - $args = wp_parse_args( $params, array( |
|
| 132 | - 'url' => get_permalink( $post ), |
|
| 130 | + if ($post instanceof \WP_Post) { |
|
| 131 | + $args = wp_parse_args($params, array( |
|
| 132 | + 'url' => get_permalink($post), |
|
| 133 | 133 | 'short_url' => null, |
| 134 | 134 | 'title' => $post->post_title, |
| 135 | 135 | 'image' => null, |
| 136 | - 'description' => get_the_excerpt( $post ), |
|
| 136 | + 'description' => get_the_excerpt($post), |
|
| 137 | 137 | 'username' => null, |
| 138 | 138 | 'message' => null, |
| 139 | 139 | 'share_count' => true, |
| 140 | - ) ); |
|
| 140 | + )); |
|
| 141 | 141 | |
| 142 | - if ( has_post_thumbnail( $post ) ) { |
|
| 143 | - $args['image'] = get_the_post_thumbnail_url( $post ); |
|
| 142 | + if (has_post_thumbnail($post)) { |
|
| 143 | + $args['image'] = get_the_post_thumbnail_url($post); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | printf( |
| 148 | 148 | '<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>', |
| 149 | 149 | $service, |
| 150 | - implode( ' ', apply_filters( 'wpst_link_classes', $classes, $service ) ), |
|
| 151 | - self::_item_sharing_property( 'url', $args['url'] ), |
|
| 152 | - self::_item_sharing_property( 'short_url', $args['short_url'] ), |
|
| 153 | - self::_item_sharing_property( 'title', $args['title'] ), |
|
| 154 | - self::_item_sharing_property( 'image', $args['image'] ), |
|
| 155 | - self::_item_sharing_property( 'description', $args['description'] ), |
|
| 156 | - self::_item_sharing_property( 'username', $args['username'] ), |
|
| 157 | - self::_item_sharing_property( 'message', $args['message'] ), |
|
| 158 | - apply_filters( 'wpst_link_text', ucfirst( $service ) ), |
|
| 159 | - self::_item_sharing_count( $args['share_count'] ) |
|
| 150 | + implode(' ', apply_filters('wpst_link_classes', $classes, $service)), |
|
| 151 | + self::_item_sharing_property('url', $args['url']), |
|
| 152 | + self::_item_sharing_property('short_url', $args['short_url']), |
|
| 153 | + self::_item_sharing_property('title', $args['title']), |
|
| 154 | + self::_item_sharing_property('image', $args['image']), |
|
| 155 | + self::_item_sharing_property('description', $args['description']), |
|
| 156 | + self::_item_sharing_property('username', $args['username']), |
|
| 157 | + self::_item_sharing_property('message', $args['message']), |
|
| 158 | + apply_filters('wpst_link_text', ucfirst($service)), |
|
| 159 | + self::_item_sharing_count($args['share_count']) |
|
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | } |
@@ -166,16 +166,16 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | private static function _facebook_og() { |
| 168 | 168 | |
| 169 | - printf( '<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url() ); |
|
| 169 | + printf('<meta property="og:url" content="%1$s" />' . PHP_EOL, self::_og_url()); |
|
| 170 | 170 | print '<meta property="og:type" content="article" />' . PHP_EOL; |
| 171 | - printf( '<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title() ); |
|
| 171 | + printf('<meta property="og:title" content="%1$s" />' . PHP_EOL, self::_og_title()); |
|
| 172 | 172 | |
| 173 | - if ( ! ( empty( $description = self::_og_description() ) ) ) { |
|
| 174 | - printf( '<meta property="og:description" content="%1$s" />' . PHP_EOL, $description ); |
|
| 173 | + if ( ! (empty($description = self::_og_description()))) { |
|
| 174 | + printf('<meta property="og:description" content="%1$s" />' . PHP_EOL, $description); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( $image_url = self::_og_image() ) { |
|
| 178 | - printf( '<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url ); |
|
| 177 | + if ($image_url = self::_og_image()) { |
|
| 178 | + printf('<meta property="og:image" content="%1$s" />' . PHP_EOL, $image_url); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | } |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | $url = get_permalink(); |
| 189 | 189 | |
| 190 | - if ( is_home() || is_front_page() ) { |
|
| 190 | + if (is_home() || is_front_page()) { |
|
| 191 | 191 | $url = home_url(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return apply_filters( 'wpst_og_url', esc_url( $url ) ); |
|
| 194 | + return apply_filters('wpst_og_url', esc_url($url)); |
|
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | $title = get_the_title(); |
| 204 | 204 | |
| 205 | - if ( is_home() || is_front_page() ) { |
|
| 206 | - $title = get_bloginfo( 'name' ); |
|
| 205 | + if (is_home() || is_front_page()) { |
|
| 206 | + $title = get_bloginfo('name'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - return apply_filters( 'wpst_og_title', wp_kses_post( $title ) ); |
|
| 209 | + return apply_filters('wpst_og_title', wp_kses_post($title)); |
|
| 210 | 210 | |
| 211 | 211 | } |
| 212 | 212 | |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | private static function _og_description() { |
| 217 | 217 | |
| 218 | - $description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 218 | + $description = apply_filters('the_excerpt', get_the_excerpt()); |
|
| 219 | 219 | |
| 220 | - if ( is_home() || is_front_page() ) { |
|
| 221 | - $description = get_bloginfo( 'description' ); |
|
| 220 | + if (is_home() || is_front_page()) { |
|
| 221 | + $description = get_bloginfo('description'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - return apply_filters( 'wpst_og_description', esc_html( $description ) ); |
|
| 224 | + return apply_filters('wpst_og_description', esc_html($description)); |
|
| 225 | 225 | |
| 226 | 226 | } |
| 227 | 227 | |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $image_url = get_the_post_thumbnail_url(); |
| 234 | 234 | |
| 235 | - if ( is_home() || is_front_page() ) { |
|
| 235 | + if (is_home() || is_front_page()) { |
|
| 236 | 236 | $image_url = ''; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return apply_filters( 'wpst_og_image', esc_url( $image_url ) ); |
|
| 239 | + return apply_filters('wpst_og_image', esc_url($image_url)); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return string |
| 248 | 248 | */ |
| 249 | - private static function _item_sharing_property( $property, $value ) { |
|
| 249 | + private static function _item_sharing_property($property, $value) { |
|
| 250 | 250 | |
| 251 | 251 | $text = ''; |
| 252 | - $maybe = apply_filters( "wpst_item_{$property}", $value ); |
|
| 252 | + $maybe = apply_filters("wpst_item_{$property}", $value); |
|
| 253 | 253 | |
| 254 | - if ( ! empty( $maybe ) ) { |
|
| 255 | - $text = sprintf( ' data-%1$s="%2$s" ', str_replace('_', '-', $property ), esc_attr( $maybe ) ); |
|
| 254 | + if ( ! empty($maybe)) { |
|
| 255 | + $text = sprintf(' data-%1$s="%2$s" ', str_replace('_', '-', $property), esc_attr($maybe)); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return $text; |
@@ -264,11 +264,11 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | - private static function _item_sharing_count( $show ) { |
|
| 267 | + private static function _item_sharing_count($show) { |
|
| 268 | 268 | |
| 269 | 269 | $text = ''; |
| 270 | 270 | |
| 271 | - if ( $show ) { |
|
| 271 | + if ($show) { |
|
| 272 | 272 | $text = '<span class="count"></span>'; |
| 273 | 273 | } |
| 274 | 274 | |