@@ -1,33 +1,33 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if ( ! defined( 'ABSPATH' )) { |
|
5 | 5 | exit; |
6 | 6 | } |
7 | 7 | |
8 | -include_once( PPP_PATH . '/includes/wpme-functions.php' ); |
|
8 | +include_once(PPP_PATH.'/includes/wpme-functions.php'); |
|
9 | 9 | |
10 | 10 | global $ppp_twitter_oauth; |
11 | -include_once( PPP_PATH . '/includes/twitter-functions.php' ); |
|
12 | -require_once( PPP_PATH . '/includes/libs/twitter.php'); |
|
11 | +include_once(PPP_PATH.'/includes/twitter-functions.php'); |
|
12 | +require_once(PPP_PATH.'/includes/libs/twitter.php'); |
|
13 | 13 | $ppp_twitter_oauth = new PPP_Twitter(); |
14 | 14 | |
15 | 15 | // Also include the user specific Twitter Class ( separate for now ) |
16 | -require_once( PPP_PATH . '/includes/libs/twitter-user.php' ); |
|
16 | +require_once(PPP_PATH.'/includes/libs/twitter-user.php'); |
|
17 | 17 | |
18 | 18 | global $ppp_facebook_oauth; |
19 | -include_once( PPP_PATH . '/includes/facebook-functions.php' ); |
|
20 | -require_once( PPP_PATH . '/includes/libs/facebook.php'); |
|
19 | +include_once(PPP_PATH.'/includes/facebook-functions.php'); |
|
20 | +require_once(PPP_PATH.'/includes/libs/facebook.php'); |
|
21 | 21 | $ppp_facebook_oauth = new PPP_Facebook(); |
22 | 22 | |
23 | 23 | global $ppp_bitly_oauth; |
24 | -include_once( PPP_PATH . '/includes/bitly-functions.php' ); |
|
25 | -require_once( PPP_PATH . '/includes/libs/bitly.php' ); |
|
24 | +include_once(PPP_PATH.'/includes/bitly-functions.php'); |
|
25 | +require_once(PPP_PATH.'/includes/libs/bitly.php'); |
|
26 | 26 | $ppp_bitly_oauth = new PPP_Bitly(); |
27 | 27 | |
28 | 28 | global $ppp_linkedin_oauth; |
29 | -include_once( PPP_PATH . '/includes/linkedin-functions.php' ); |
|
30 | -require_once( PPP_PATH . '/includes/libs/linkedin.php' ); |
|
29 | +include_once(PPP_PATH.'/includes/linkedin-functions.php'); |
|
30 | +require_once(PPP_PATH.'/includes/libs/linkedin.php'); |
|
31 | 31 | $ppp_linkedin_oauth = new PPP_Linkedin(); |
32 | 32 | |
33 | -include_once( PPP_PATH . '/includes/pinterest-functions.php' ); |
|
33 | +include_once(PPP_PATH.'/includes/pinterest-functions.php'); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if ( ! defined( 'ABSPATH' )) { |
|
5 | 5 | exit; |
6 | 6 | } |
7 | 7 | |
@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function ppp_share_on_publish( $new_status, $old_status, $post ) { |
18 | 18 | // don't publish password protected posts |
19 | - if ( '' !== $post->post_password ) { |
|
19 | + if ('' !== $post->post_password) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | - if ( $new_status == 'publish' && $old_status != 'publish' ) { |
|
23 | + if ($new_status == 'publish' && $old_status != 'publish') { |
|
24 | 24 | global $ppp_options; |
25 | 25 | |
26 | - $allowed_post_types = isset( $ppp_options['post_types'] ) ? $ppp_options['post_types'] : array(); |
|
26 | + $allowed_post_types = isset($ppp_options['post_types']) ? $ppp_options['post_types'] : array(); |
|
27 | 27 | $allowed_post_types = apply_filters( 'ppp_schedule_share_post_types', $allowed_post_types ); |
28 | 28 | |
29 | - if ( !isset( $post->post_status ) || !array_key_exists( $post->post_type, $allowed_post_types ) ) { |
|
29 | + if ( ! isset($post->post_status) || ! array_key_exists( $post->post_type, $allowed_post_types )) { |
|
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
@@ -55,26 +55,26 @@ discard block |
||
55 | 55 | function ppp_share_post( $post_id, $name ) { |
56 | 56 | global $ppp_options, $ppp_social_settings, $ppp_share_settings, $ppp_twitter_oauth; |
57 | 57 | |
58 | - if ( ppp_is_dev_or_staging() ) { |
|
58 | + if (ppp_is_dev_or_staging()) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // If we've already started to share this, don't share it again. |
63 | 63 | // Compensates for wp-cron's race conditions |
64 | - if ( get_transient( 'ppp_sharing' . $name ) === 'true' ) { |
|
64 | + if (get_transient( 'ppp_sharing'.$name ) === 'true') { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // For 10 seconds, don't allow another share to go for this post |
69 | - set_transient( 'ppp_sharing' . $name, 'true', 10 ); |
|
69 | + set_transient( 'ppp_sharing'.$name, 'true', 10 ); |
|
70 | 70 | |
71 | 71 | $name_parts = explode( '_', $name ); |
72 | 72 | $index = $name_parts[1]; |
73 | - $service = isset( $name_parts[3] ) ? $name_parts[3] : 'tw'; |
|
73 | + $service = isset($name_parts[3]) ? $name_parts[3] : 'tw'; |
|
74 | 74 | |
75 | 75 | // If we're fired on a cron, check for stale cron runs |
76 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
77 | - switch( $service ) { |
|
76 | + if (defined( 'DOING_CRON' ) && DOING_CRON) { |
|
77 | + switch ($service) { |
|
78 | 78 | case 'tw': |
79 | 79 | $post_meta = get_post_meta( $post_id, '_ppp_tweets', true ); |
80 | 80 | break; |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | $share_data = array(); |
92 | - if ( isset( $post_meta[ $index ] ) ) { |
|
93 | - $share_data = $post_meta[ $index ]; |
|
92 | + if (isset($post_meta[$index])) { |
|
93 | + $share_data = $post_meta[$index]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $timestamp = ppp_generate_timestamp( $share_data['date'], $share_data['time'] ); |
97 | 97 | |
98 | 98 | // If the current time is more than 60 minutes (filterable) overdue, don't fire the share |
99 | 99 | $share_buffer = apply_filters( 'ppp_share_buffer', HOUR_IN_SECONDS ); |
100 | - if ( ( current_time( 'timestamp', 1 ) - $timestamp ) > $share_buffer ) { |
|
100 | + if ((current_time( 'timestamp', 1 ) - $timestamp) > $share_buffer) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - do_action( 'ppp_share_scheduled_' . $service, $post_id, $index, $name ); |
|
105 | + do_action( 'ppp_share_scheduled_'.$service, $post_id, $index, $name ); |
|
106 | 106 | |
107 | 107 | // Just in case we get caught in a weird state, kill this share immediately after we execute it. |
108 | 108 | wp_clear_scheduled_hook( 'ppp_share_post_event', array( $post_id, $name ) ); |
@@ -114,28 +114,28 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | function ppp_set_social_tokens() { |
117 | - if ( ( defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' ) ) || |
|
118 | - ( defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' ) ) || |
|
119 | - ( defined( 'bitly_clientid' ) && defined( 'bitly_secret' ) ) || |
|
120 | - ( defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' ) ) |
|
117 | + if ((defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' )) || |
|
118 | + (defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' )) || |
|
119 | + (defined( 'bitly_clientid' ) && defined( 'bitly_secret' )) || |
|
120 | + (defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' )) |
|
121 | 121 | ) { |
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $social_tokens = ppp_has_local_tokens(); |
126 | 126 | |
127 | - if ( empty( $social_tokens ) ) { |
|
128 | - if ( ! defined( 'PPP_LOCAL_TOKENS' ) ) { |
|
127 | + if (empty($social_tokens)) { |
|
128 | + if ( ! defined( 'PPP_LOCAL_TOKENS' )) { |
|
129 | 129 | define( 'PPP_LOCAL_TOKENS', false ); |
130 | 130 | } |
131 | 131 | $social_tokens = get_transient( 'ppp_social_tokens' ); |
132 | 132 | |
133 | - if ( ! $social_tokens ) { |
|
133 | + if ( ! $social_tokens) { |
|
134 | 134 | $license = trim( get_option( '_ppp_license_key' ) ); |
135 | - $url = PPP_STORE_URL . '/?ppp-get-tokens&ppp-license-key=' . $license . '&ver=' . md5( time() . $license ); |
|
135 | + $url = PPP_STORE_URL.'/?ppp-get-tokens&ppp-license-key='.$license.'&ver='.md5( time().$license ); |
|
136 | 136 | $response = wp_remote_get( $url, array( 'timeout' => 15, 'sslverify' => false ) ); |
137 | 137 | |
138 | - if ( is_wp_error( $response ) ) { |
|
138 | + if (is_wp_error( $response )) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | } else { |
147 | - if ( ! defined ( 'PPP_LOCAL_TOKENS' ) ) { |
|
147 | + if ( ! defined( 'PPP_LOCAL_TOKENS' )) { |
|
148 | 148 | define( 'PPP_LOCAL_TOKENS', true ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | delete_transient( 'ppp_social_tokens' ); |
152 | 152 | |
153 | - if ( isset( $social_tokens->options ) ) { |
|
154 | - foreach ( $social_tokens->options as $constant => $value ) { |
|
153 | + if (isset($social_tokens->options)) { |
|
154 | + foreach ($social_tokens->options as $constant => $value) { |
|
155 | 155 | |
156 | 156 | $constant = strtoupper( $constant ); |
157 | 157 | |
158 | - if ( defined( $constant ) ) { |
|
158 | + if (defined( $constant )) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | - switch( $constant ) { |
|
162 | + switch ($constant) { |
|
163 | 163 | |
164 | 164 | case 'NO_AUTO_UPDATE': |
165 | 165 | // Avoid the call to the API to check for software updates |
166 | 166 | $value = is_bool( $value ) ? $value : false; |
167 | - if ( ! defined( 'NO_AUTO_UPDATE' ) ) { |
|
167 | + if ( ! defined( 'NO_AUTO_UPDATE' )) { |
|
168 | 168 | define( 'NO_AUTO_UPDATE', $value ); |
169 | 169 | } |
170 | 170 | break; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if ( false === PPP_LOCAL_TOKENS && ! isset( $social_tokens->error ) && ( isset( $social_tokens->twitter ) || isset( $social_tokens->facebook ) || isset( $social_tokens->linkedin ) ) ) { |
|
177 | + if (false === PPP_LOCAL_TOKENS && ! isset($social_tokens->error) && (isset($social_tokens->twitter) || isset($social_tokens->facebook) || isset($social_tokens->linkedin))) { |
|
178 | 178 | set_transient( 'ppp_social_tokens', $social_tokens, WEEK_IN_SECONDS ); |
179 | 179 | } |
180 | 180 | |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function ppp_has_local_tokens() { |
189 | 189 | |
190 | - $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path() . '/ppp-social-tokens.json' ); |
|
190 | + $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path().'/ppp-social-tokens.json' ); |
|
191 | 191 | $local_tokens = false; |
192 | 192 | |
193 | - if ( ! file_exists( $token_file ) ) { |
|
193 | + if ( ! file_exists( $token_file )) { |
|
194 | 194 | return $local_tokens; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $local_tokens = json_decode( file_get_contents( $token_file ) ); |
198 | 198 | |
199 | 199 | // Failed to parse as JSON |
200 | - if ( false === $local_tokens ) { |
|
200 | + if (false === $local_tokens) { |
|
201 | 201 | return $local_tokens; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // No social tokens found in the format we accept or it was empty |
205 | - if ( empty( $local_tokens ) || ( ! isset( $local_tokens->twitter ) || ! isset( $local_tokens->facebook ) || ! isset( $local_tokens->linkedin ) ) ) { |
|
205 | + if (empty($local_tokens) || ( ! isset($local_tokens->twitter) || ! isset($local_tokens->facebook) || ! isset($local_tokens->linkedin))) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | global $ppp_share_settings; |
221 | 221 | $share_link = get_permalink( $post_id ); |
222 | 222 | |
223 | - if ( ppp_link_tracking_enabled() ) { |
|
223 | + if (ppp_link_tracking_enabled()) { |
|
224 | 224 | $share_link = ppp_generate_link_tracking( $share_link, $post_id, $name ); |
225 | 225 | } |
226 | 226 | |
227 | - if ( ppp_is_shortener_enabled() && $scheduled ) { |
|
227 | + if (ppp_is_shortener_enabled() && $scheduled) { |
|
228 | 228 | $shortener_name = $ppp_share_settings['shortener']; |
229 | - $share_link = apply_filters( 'ppp_apply_shortener-' . $shortener_name, $share_link ); |
|
229 | + $share_link = apply_filters( 'ppp_apply_shortener-'.$shortener_name, $share_link ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * @return string The URL to post, with proper analytics applied if necessary |
242 | 242 | */ |
243 | 243 | function ppp_generate_link_tracking( $share_link, $post_id, $name ) { |
244 | - if ( ppp_link_tracking_enabled() ) { |
|
244 | + if (ppp_link_tracking_enabled()) { |
|
245 | 245 | global $ppp_share_settings; |
246 | 246 | $link_tracking_type = $ppp_share_settings['analytics']; |
247 | 247 | |
248 | 248 | // Given the setting name, devs can extend this and apply a filter of ppp_analytics-[setting value] |
249 | 249 | // to apply their own rules for link tracking |
250 | - $share_link = apply_filters( 'ppp_analytics-' . $link_tracking_type, $share_link, $post_id, $name ); |
|
250 | + $share_link = apply_filters( 'ppp_analytics-'.$link_tracking_type, $share_link, $post_id, $name ); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $share_link = apply_filters( 'ppp_generate_link_tracking', $share_link, $post_id, $name ); |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | * @return mixed If a thumbnail is found returns the URL, otherwise returns false |
264 | 264 | */ |
265 | 265 | function ppp_post_has_media( $post_id, $network, $use_media, $attachment_id = false ) { |
266 | - if ( !$use_media || empty( $post_id ) || empty( $network ) ) { |
|
266 | + if ( ! $use_media || empty($post_id) || empty($network)) { |
|
267 | 267 | return false; |
268 | 268 | } |
269 | 269 | |
270 | - $thumb_id = empty( $attachment_id ) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
271 | - $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-' . $network . '-share-image', true ); |
|
270 | + $thumb_id = empty($attachment_id) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
271 | + $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-'.$network.'-share-image', true ); |
|
272 | 272 | |
273 | - if ( isset( $thumb_url[0] ) && ! empty( $thumb_url[0] ) && !strpos( $thumb_url[0], 'wp-includes/images/media/default.png' ) ) { |
|
273 | + if (isset($thumb_url[0]) && ! empty($thumb_url[0]) && ! strpos( $thumb_url[0], 'wp-includes/images/media/default.png' )) { |
|
274 | 274 | return $thumb_url[0]; |
275 | 275 | } |
276 | 276 | |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | $filename = end( $path ); |
293 | 293 | |
294 | 294 | // First check a social media share (thumbnail sizes) |
295 | - $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE '%s';", '%' . $wpdb->esc_like( $filename ) . '%' ) ); |
|
296 | - if ( ! empty( $thumb_id[0] ) ) { |
|
295 | + $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE '%s';", '%'.$wpdb->esc_like( $filename ).'%' ) ); |
|
296 | + if ( ! empty($thumb_id[0])) { |
|
297 | 297 | $attachment_id = $thumb_id[0]; |
298 | 298 | } else { |
299 | 299 | |
300 | 300 | // We didn't find one via the thumbnail sizes, try the full image URL. |
301 | 301 | $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) ); |
302 | - if ( ! empty( $thumb_id[0] ) ) { |
|
302 | + if ( ! empty($thumb_id[0])) { |
|
303 | 303 | $attachment_id = $thumb_id[0]; |
304 | 304 | } |
305 | 305 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if ( ! defined( 'ABSPATH' )) { |
|
5 | 5 | exit; |
6 | 6 | } |
7 | 7 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function ppp_pt_save_post_meta_boxes( $post_id, $post ) { |
86 | 86 | |
87 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
87 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function ppp_pt_open_graph_meta() { |
105 | 105 | |
106 | - if ( ! is_single() ) { |
|
106 | + if ( ! is_single()) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | global $post, $ppp_options; |
111 | 111 | |
112 | - if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] ) ) { |
|
112 | + if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] )) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | |
128 | 128 | $return = ''; |
129 | 129 | |
130 | - if ( ! is_single() ) { |
|
130 | + if ( ! is_single()) { |
|
131 | 131 | return $return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | global $post; |
135 | 135 | |
136 | 136 | |
137 | - if ( empty( $post ) ) { |
|
137 | + if (empty($post)) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $elements = ppp_pt_default_meta_elements(); |
142 | - foreach ( $elements as $name => $content ) { |
|
143 | - $return .= '<meta name="' . $name . '" content="' . $content . '" />' . "\n"; |
|
142 | + foreach ($elements as $name => $content) { |
|
143 | + $return .= '<meta name="'.$name.'" content="'.$content.'" />'."\n"; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return apply_filters( 'ppp_pt_og_data', $return ); |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | $elements = array(); |
161 | 161 | $pinterest_data = get_post_meta( $post->ID, '_ppp_pt_media', true ); |
162 | 162 | |
163 | - if ( ! empty( $pinterest_data['image'] ) ) { |
|
163 | + if ( ! empty($pinterest_data['image'])) { |
|
164 | 164 | $elements['og:image'] = $pinterest_data['image']; |
165 | 165 | |
166 | - $thumb_id = ! empty( $pinterest_data['attachment_id'] ) ? (int) $pinterest_data['attachment_id'] : ppp_get_attachment_id_from_image_url( $pinterest_data['image'] ) ; |
|
166 | + $thumb_id = ! empty($pinterest_data['attachment_id']) ? (int) $pinterest_data['attachment_id'] : ppp_get_attachment_id_from_image_url( $pinterest_data['image'] ); |
|
167 | 167 | |
168 | - if ( ! empty( $thumb_id ) ) { |
|
168 | + if ( ! empty($thumb_id)) { |
|
169 | 169 | $alt_text = ppp_get_attachment_alt_text( $thumb_id ); |
170 | 170 | // When adding media via the WP Uploader, any 'alt text' supplied will be used as the accessible alt text. |
171 | - if ( ! empty( $alt_text ) ) { |
|
171 | + if ( ! empty($alt_text)) { |
|
172 | 172 | $elements['og:image:alt'] = esc_attr( $alt_text ); |
173 | 173 | } |
174 | 174 | } |