@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | function ppp_facebook_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['facebook'] ) && !empty( $ppp_social_settings['facebook'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['facebook']) && ! empty($ppp_social_settings['facebook'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function ppp_fb_account_list_avatar( $string = '' ) { |
| 52 | 52 | |
| 53 | - if ( ppp_facebook_enabled() ) { |
|
| 53 | + if (ppp_facebook_enabled()) { |
|
| 54 | 54 | global $ppp_social_settings; |
| 55 | 55 | $avatar_url = $ppp_social_settings['facebook']->avatar; |
| 56 | - $string = '<img class="ppp-social-icon" src="' . $avatar_url . '" />'; |
|
| 56 | + $string = '<img class="ppp-social-icon" src="'.$avatar_url.'" />'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $string; |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function ppp_fb_account_list_name( $string = '' ) { |
| 69 | 69 | |
| 70 | - if ( ppp_facebook_enabled() ) { |
|
| 70 | + if (ppp_facebook_enabled()) { |
|
| 71 | 71 | global $ppp_social_settings; |
| 72 | - $string = $ppp_social_settings['facebook']->name; |
|
| 72 | + $string = $ppp_social_settings['facebook']->name; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $string; |
@@ -84,22 +84,22 @@ discard block |
||
| 84 | 84 | function ppp_fb_account_list_actions( $string = '' ) { |
| 85 | 85 | global $ppp_facebook_oauth, $ppp_social_settings; |
| 86 | 86 | |
| 87 | - if ( ! ppp_facebook_enabled() ) { |
|
| 87 | + if ( ! ppp_facebook_enabled()) { |
|
| 88 | 88 | |
| 89 | 89 | $fb_authurl = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 90 | 90 | |
| 91 | - $string .= '<a class="button-primary" href="' . $fb_authurl . '">' . __( 'Connect to Facebook', 'ppp-txt' ) . '</a>'; |
|
| 91 | + $string .= '<a class="button-primary" href="'.$fb_authurl.'">'.__( 'Connect to Facebook', 'ppp-txt' ).'</a>'; |
|
| 92 | 92 | } else { |
| 93 | - $string .= '<a class="button-primary" href="' . admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=facebook' ) . '" >' . __( 'Disconnect from Facebook', 'ppp-txt' ) . '</a> '; |
|
| 93 | + $string .= '<a class="button-primary" href="'.admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=facebook' ).'" >'.__( 'Disconnect from Facebook', 'ppp-txt' ).'</a> '; |
|
| 94 | 94 | |
| 95 | 95 | $refresh_date = (int) get_option( '_ppp_facebook_refresh', true ); |
| 96 | 96 | |
| 97 | - if ( defined( 'PPP_FB_APP_ID' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 97 | + if (defined( 'PPP_FB_APP_ID' ) && current_time( 'timestamp' ) > $refresh_date) { |
|
| 98 | 98 | $token = $ppp_social_settings['facebook']->access_token; |
| 99 | 99 | $url = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 100 | - $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 100 | + $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 101 | 101 | |
| 102 | - $string .= '<a class="button-secondary" href="' . $refresh_url . '" >' . __( 'Re-Authorize Facebook', 'ppp-txt' ) . '</a> '; |
|
| 102 | + $string .= '<a class="button-secondary" href="'.$refresh_url.'" >'.__( 'Re-Authorize Facebook', 'ppp-txt' ).'</a> '; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -114,27 +114,27 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function ppp_fb_account_list_extras( $string ) { |
| 116 | 116 | |
| 117 | - if ( ppp_facebook_enabled() ) { |
|
| 117 | + if (ppp_facebook_enabled()) { |
|
| 118 | 118 | global $ppp_social_settings, $ppp_facebook_oauth, $ppp_options; |
| 119 | 119 | $pages = $ppp_facebook_oauth->ppp_get_fb_user_pages( $ppp_social_settings['facebook']->access_token ); |
| 120 | - $selected = isset( $ppp_social_settings['facebook']->page ) ? stripslashes( $ppp_social_settings['facebook']->page ) : 'me'; |
|
| 120 | + $selected = isset($ppp_social_settings['facebook']->page) ? stripslashes( $ppp_social_settings['facebook']->page ) : 'me'; |
|
| 121 | 121 | |
| 122 | - if ( !empty( $pages ) ) { |
|
| 123 | - $string = '<label>' . __( 'Publish as:', 'ppp-txt' ) . '</label><br />'; |
|
| 122 | + if ( ! empty($pages)) { |
|
| 123 | + $string = '<label>'.__( 'Publish as:', 'ppp-txt' ).'</label><br />'; |
|
| 124 | 124 | $string .= '<select id="fb-page">'; |
| 125 | - foreach ( $pages as $page ) { |
|
| 126 | - $value = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 127 | - $string .= '<option ' . selected( $value, $selected, false ) . ' value="' . $value . '">' . $page->name . '</option>'; |
|
| 125 | + foreach ($pages as $page) { |
|
| 126 | + $value = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 127 | + $string .= '<option '.selected( $value, $selected, false ).' value="'.$value.'">'.$page->name.'</option>'; |
|
| 128 | 128 | } |
| 129 | 129 | $string .= '</select><span class="spinner"></span>'; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( ! empty( $ppp_options['enable_debug'] ) ) { |
|
| 133 | - $days_left = absint( round( ( $ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 134 | - $refresh_in = absint( round( ( get_option( '_ppp_facebook_refresh' ) - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 132 | + if ( ! empty($ppp_options['enable_debug'])) { |
|
| 133 | + $days_left = absint( round( ($ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 134 | + $refresh_in = absint( round( (get_option( '_ppp_facebook_refresh' ) - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 135 | 135 | |
| 136 | - $string .= '<br />' . sprintf( __( 'Token expires in %s days' , 'ppp-txt' ), $days_left ); |
|
| 137 | - $string .= '<br />' . sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 136 | + $string .= '<br />'.sprintf( __( 'Token expires in %s days', 'ppp-txt' ), $days_left ); |
|
| 137 | + $string .= '<br />'.sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | 150 | function ppp_set_fb_token_constants( $social_tokens ) { |
| 151 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'facebook' ) ) { |
|
| 151 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'facebook' )) { |
|
| 152 | 152 | define( 'PPP_FB_APP_ID', $social_tokens->facebook->app_id ); |
| 153 | 153 | define( 'PPP_FB_APP_SECRET', $social_tokens->facebook->app_secret ); |
| 154 | 154 | } |
@@ -162,17 +162,17 @@ discard block |
||
| 162 | 162 | function ppp_capture_facebook_oauth() { |
| 163 | 163 | $should_capture = false; |
| 164 | 164 | |
| 165 | - if ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false ) { |
|
| 165 | + if (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false) { |
|
| 166 | 166 | // Local config |
| 167 | 167 | $should_capture = true; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( isset( $_REQUEST['fb_access_token'] ) ) { |
|
| 170 | + if (isset($_REQUEST['fb_access_token'])) { |
|
| 171 | 171 | // Returning from remote config |
| 172 | 172 | $should_capture = true; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( $should_capture && ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ppp-social-settings' ) ) { |
|
| 175 | + if ($should_capture && (isset($_REQUEST['page']) && $_REQUEST['page'] == 'ppp-social-settings')) { |
|
| 176 | 176 | global $ppp_facebook_oauth; |
| 177 | 177 | $ppp_facebook_oauth->ppp_initialize_facebook(); |
| 178 | 178 | wp_redirect( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | function ppp_disconnect_facebook() { |
| 190 | 190 | global $ppp_social_settings; |
| 191 | 191 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 192 | - if ( isset( $ppp_social_settings['facebook'] ) ) { |
|
| 193 | - unset( $ppp_social_settings['facebook'] ); |
|
| 192 | + if (isset($ppp_social_settings['facebook'])) { |
|
| 193 | + unset($ppp_social_settings['facebook']); |
|
| 194 | 194 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 195 | 195 | delete_option( '_ppp_facebook_refresh' ); |
| 196 | 196 | } |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function ppp_fb_execute_refresh() { |
| 218 | 218 | |
| 219 | - if ( ! ppp_facebook_enabled() ) { |
|
| 219 | + if ( ! ppp_facebook_enabled()) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $refresh_date = (int) get_option( '_ppp_facebook_refresh', true ); |
| 224 | 224 | |
| 225 | - if ( ( empty( $_GET['page' ] ) || $_GET['page'] !== 'ppp-social-settings' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 225 | + if ((empty($_GET['page']) || $_GET['page'] !== 'ppp-social-settings') && current_time( 'timestamp' ) > $refresh_date) { |
|
| 226 | 226 | add_action( 'admin_notices', 'ppp_facebook_refresh_notice' ); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | function ppp_facebook_refresh_notice() { |
| 236 | 236 | |
| 237 | - if ( ! ppp_facebook_enabled() ) { |
|
| 237 | + if ( ! ppp_facebook_enabled()) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $has_dismissed = get_transient( 'ppp-dismiss-refresh-fb' . get_current_user_id() ); |
|
| 242 | - if ( false !== $has_dismissed ) { |
|
| 241 | + $has_dismissed = get_transient( 'ppp-dismiss-refresh-fb'.get_current_user_id() ); |
|
| 242 | + if (false !== $has_dismissed) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $token = $ppp_social_settings['facebook']->access_token; |
| 252 | 252 | $url = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 253 | - $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 253 | + $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 254 | 254 | |
| 255 | - $days_left = (int) round( ( $ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ); |
|
| 255 | + $days_left = (int) round( ($ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ); |
|
| 256 | 256 | ?> |
| 257 | 257 | <div class="notice notice-warning is-dismissible" data-service="fb"> |
| 258 | - <?php if ( $days_left > 0 ): ?> |
|
| 258 | + <?php if ($days_left > 0): ?> |
|
| 259 | 259 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your Facebook authentication expires in %d days. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $days_left, $url ); ?></p> |
| 260 | - <?php elseif ( $days_left < 1 ): ?> |
|
| 260 | + <?php elseif ($days_left < 1): ?> |
|
| 261 | 261 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your Facebook authentication has expired. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $url ); ?></p> |
| 262 | 262 | <?php endif; ?> |
| 263 | 263 | </div> |
@@ -272,10 +272,10 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | function ppp_fb_dismiss_notice() { |
| 274 | 274 | |
| 275 | - $nag = sanitize_key( $_POST[ 'nag' ] ); |
|
| 275 | + $nag = sanitize_key( $_POST['nag'] ); |
|
| 276 | 276 | |
| 277 | - if ( $nag === $_POST[ 'nag' ] ) { |
|
| 278 | - set_transient( $nag . get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 277 | + if ($nag === $_POST['nag']) { |
|
| 278 | + set_transient( $nag.get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | * @param string $name The name of the Cron |
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | -function ppp_fb_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 306 | +function ppp_fb_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 307 | 307 | global $ppp_options; |
| 308 | 308 | |
| 309 | 309 | $link = ppp_generate_link( $post_id, $name ); |
| 310 | 310 | |
| 311 | 311 | $post_meta = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 312 | - $this_share = $post_meta[ $index ]; |
|
| 313 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 312 | + $this_share = $post_meta[$index]; |
|
| 313 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 314 | 314 | |
| 315 | 315 | $share_message = ppp_fb_build_share_message( $post_id, $name ); |
| 316 | 316 | |
| 317 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 317 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 318 | 318 | $media = $this_share['image']; |
| 319 | 319 | } else { |
| 320 | 320 | $use_media = ppp_fb_use_media( $post_id, $index ); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function ppp_fb_add_meta_tab( $tabs ) { |
| 374 | 374 | global $ppp_social_settings; |
| 375 | - if ( ! ppp_facebook_enabled() ) { |
|
| 375 | + if ( ! ppp_facebook_enabled()) { |
|
| 376 | 376 | return $tabs; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | function ppp_fb_register_metabox_content( $content ) { |
| 391 | 391 | global $ppp_social_settings; |
| 392 | - if ( ! ppp_facebook_enabled() ) { |
|
| 392 | + if ( ! ppp_facebook_enabled()) { |
|
| 393 | 393 | return $content; |
| 394 | 394 | } |
| 395 | 395 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function ppp_fb_add_metabox_content( $post ) { |
| 407 | 407 | global $ppp_options, $ppp_share_settings; |
| 408 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 408 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 409 | 409 | |
| 410 | 410 | $ppp_fb_share_on_publish = get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
| 411 | 411 | $ppp_share_on_publish_title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | $show_share_on_publish = false; |
| 416 | 416 | |
| 417 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['facebook'] ) ? false : true; |
|
| 417 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['facebook']) ? false : true; |
|
| 418 | 418 | |
| 419 | - if ( $ppp_fb_share_on_publish == '1' || ( $ppp_fb_share_on_publish == '' && $share_by_default ) ) { |
|
| 419 | + if ($ppp_fb_share_on_publish == '1' || ($ppp_fb_share_on_publish == '' && $share_by_default)) { |
|
| 420 | 420 | $show_share_on_publish = true; |
| 421 | 421 | } |
| 422 | 422 | |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | <div class="ppp-post-override-wrap"> |
| 426 | 426 | <p><h3><?php _e( 'Share on Facebook', 'ppp-txt' ); ?></h3></p> |
| 427 | 427 | <p> |
| 428 | - <?php $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; ?> |
|
| 428 | + <?php $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; ?> |
|
| 429 | 429 | <label for="ppp_fb_share_on_publish"><?php _e( 'Share this post on Facebook…', 'ppp-txt' ); ?></label> |
| 430 | 430 | <select name="_ppp_fb_share_on_publish" id="ppp_fb_share_on_publish" class="ppp-toggle-share-on-publish"> |
| 431 | - <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 432 | - <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 431 | + <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 432 | + <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 433 | 433 | <option value="0" <?php selected( false, $show_share_on_publish, true ); ?>><?php _e( 'After this post is published', 'ppp-txt' ); ?></option> |
| 434 | 434 | </select> |
| 435 | 435 | </p> |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | <th style="width: 10px;"></th> |
| 446 | 446 | </tr> |
| 447 | 447 | </thead> |
| 448 | - <tbody id="fb-share-on-publish" class="ppp-share-on-publish" <?php if ( false === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 448 | + <tbody id="fb-share-on-publish" class="ppp-share-on-publish" <?php if (false === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 449 | 449 | <?php |
| 450 | 450 | $args = array( |
| 451 | 451 | 'text' => $ppp_share_on_publish_title, |
@@ -456,18 +456,18 @@ discard block |
||
| 456 | 456 | ppp_render_fb_share_on_publish_row( $args ); |
| 457 | 457 | ?> |
| 458 | 458 | </tbody> |
| 459 | - <tbody id="fb-schedule-share" class="ppp-schedule-share" <?php if ( true === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 459 | + <tbody id="fb-schedule-share" class="ppp-schedule-share" <?php if (true === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 460 | 460 | <?php $shares = get_post_meta( $post->ID, '_ppp_fb_shares', true ); ?> |
| 461 | - <?php if ( ! empty( $shares ) ) : ?> |
|
| 461 | + <?php if ( ! empty($shares)) : ?> |
|
| 462 | 462 | |
| 463 | - <?php foreach ( $shares as $key => $value ) : |
|
| 464 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 465 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 466 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 467 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 468 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 463 | + <?php foreach ($shares as $key => $value) : |
|
| 464 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 465 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 466 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 467 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 468 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 469 | 469 | |
| 470 | - $args = apply_filters( 'ppp_fb_row_args', compact( 'date','time','text','image','attachment_id' ), $value ); |
|
| 470 | + $args = apply_filters( 'ppp_fb_row_args', compact( 'date', 'time', 'text', 'image', 'attachment_id' ), $value ); |
|
| 471 | 471 | ?> |
| 472 | 472 | |
| 473 | 473 | <?php ppp_render_fb_share_row( $key, $args, $post->ID ); ?> |
@@ -547,8 +547,8 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 549 | 549 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 550 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 551 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 550 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 551 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 552 | 552 | ?> |
| 553 | 553 | <tr class="ppp-fb-wrapper ppp-repeatable-row ppp-repeatable-facebook scheduled-row" data-key="<?php echo esc_attr( $key ); ?>"> |
| 554 | 554 | <td> |
@@ -593,23 +593,23 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | function ppp_fb_save_post_meta_boxes( $post_id, $post ) { |
| 595 | 595 | |
| 596 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 596 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 597 | 597 | return; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - $ppp_fb_share_on_publish = ( isset( $_REQUEST['_ppp_fb_share_on_publish'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish'] : '-1'; |
|
| 601 | - $ppp_share_on_publish_title = ( isset( $_REQUEST['_ppp_fb_share_on_publish_title'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 602 | - $ppp_share_on_publish_image_url = ( isset( $_REQUEST['_ppp_fb_share_on_publish_image_url'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 603 | - $ppp_share_on_publish_attachment_id = ( isset( $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] : ''; |
|
| 600 | + $ppp_fb_share_on_publish = (isset($_REQUEST['_ppp_fb_share_on_publish'])) ? $_REQUEST['_ppp_fb_share_on_publish'] : '-1'; |
|
| 601 | + $ppp_share_on_publish_title = (isset($_REQUEST['_ppp_fb_share_on_publish_title'])) ? $_REQUEST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 602 | + $ppp_share_on_publish_image_url = (isset($_REQUEST['_ppp_fb_share_on_publish_image_url'])) ? $_REQUEST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 603 | + $ppp_share_on_publish_attachment_id = (isset($_REQUEST['_ppp_fb_share_on_publish_attachment_id'])) ? $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] : ''; |
|
| 604 | 604 | |
| 605 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish', $ppp_fb_share_on_publish ); |
|
| 606 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 607 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 605 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish', $ppp_fb_share_on_publish ); |
|
| 606 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 607 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 608 | 608 | update_post_meta( $post_id, '_ppp_fb_share_on_publish_attachment_id', $ppp_share_on_publish_attachment_id ); |
| 609 | 609 | |
| 610 | - $fb_data = ( isset( $_REQUEST['_ppp_fb_shares'] ) && empty( $ppp_fb_share_on_publish ) ) ? $_REQUEST['_ppp_fb_shares'] : array(); |
|
| 611 | - foreach ( $fb_data as $index => $share ) { |
|
| 612 | - $fb_data[ $index ]['text'] = sanitize_text_field( $share['text'] ); |
|
| 610 | + $fb_data = (isset($_REQUEST['_ppp_fb_shares']) && empty($ppp_fb_share_on_publish)) ? $_REQUEST['_ppp_fb_shares'] : array(); |
|
| 611 | + foreach ($fb_data as $index => $share) { |
|
| 612 | + $fb_data[$index]['text'] = sanitize_text_field( $share['text'] ); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | update_post_meta( $post_id, '_ppp_fb_shares', $fb_data ); |
@@ -626,10 +626,10 @@ discard block |
||
| 626 | 626 | function ppp_fb_share_on_publish( $new_status, $old_status, $post ) { |
| 627 | 627 | global $ppp_options; |
| 628 | 628 | |
| 629 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
|
| 630 | - $from_post = isset( $_POST['_ppp_fb_share_on_publish'] ) ? $_POST['_ppp_fb_share_on_publish'] : '0'; |
|
| 629 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
|
| 630 | + $from_post = isset($_POST['_ppp_fb_share_on_publish']) ? $_POST['_ppp_fb_share_on_publish'] : '0'; |
|
| 631 | 631 | |
| 632 | - if ( '1' != $from_meta && '1' != $from_post ) { |
|
| 632 | + if ('1' != $from_meta && '1' != $from_post) { |
|
| 633 | 633 | return; |
| 634 | 634 | } |
| 635 | 635 | |
@@ -641,28 +641,28 @@ discard block |
||
| 641 | 641 | $image_url = ''; |
| 642 | 642 | |
| 643 | 643 | // Determine if we're seeing the share on publish in meta or $_POST |
| 644 | - if ( $from_meta && ! $from_post ) { |
|
| 645 | - $title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
|
| 644 | + if ($from_meta && ! $from_post) { |
|
| 645 | + $title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
|
| 646 | 646 | $attachment_id = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_attachment_id', true ); |
| 647 | - $image_url = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_image_url', true ); |
|
| 647 | + $image_url = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_image_url', true ); |
|
| 648 | 648 | } else { |
| 649 | - $title = isset( $_POST['_ppp_fb_share_on_publish_title'] ) ? $_POST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 650 | - $attachment_id = isset( $_POST['_ppp_fb_share_on_publish_attachment_id'] ) ? $_POST['_ppp_fb_share_on_publish_attachment_id'] : 0; |
|
| 651 | - $image_url = isset( $_POST['_ppp_fb_share_on_publish_image_url'] ) ? $_POST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 649 | + $title = isset($_POST['_ppp_fb_share_on_publish_title']) ? $_POST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 650 | + $attachment_id = isset($_POST['_ppp_fb_share_on_publish_attachment_id']) ? $_POST['_ppp_fb_share_on_publish_attachment_id'] : 0; |
|
| 651 | + $image_url = isset($_POST['_ppp_fb_share_on_publish_image_url']) ? $_POST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | $thumbnail = ''; |
| 655 | - if ( empty( $attachment_id ) && ! empty( $image_url ) ) { |
|
| 655 | + if (empty($attachment_id) && ! empty($image_url)) { |
|
| 656 | 656 | $thumbnail = $image_url; |
| 657 | 657 | } else { |
| 658 | 658 | $thumbnail = ppp_post_has_media( $post->ID, 'fb', true, $attachment_id ); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - $name = 'sharedate_0_' . $post->ID . '_fb'; |
|
| 661 | + $name = 'sharedate_0_'.$post->ID.'_fb'; |
|
| 662 | 662 | |
| 663 | - $default_title = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 663 | + $default_title = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 664 | 664 | // If an override was found, use it, otherwise try the default text content |
| 665 | - if ( empty( $title ) && empty( $default_title ) ) { |
|
| 665 | + if (empty($title) && empty($default_title)) { |
|
| 666 | 666 | $title = get_the_title( $post->ID ); |
| 667 | 667 | } |
| 668 | 668 | |
@@ -702,20 +702,20 @@ discard block |
||
| 702 | 702 | function ppp_fb_generate_timestamps( $times, $post_id ) { |
| 703 | 703 | $fb_shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 704 | 704 | |
| 705 | - if ( empty( $fb_shares ) ) { |
|
| 705 | + if (empty($fb_shares)) { |
|
| 706 | 706 | $fb_shares = array(); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - foreach ( $fb_shares as $key => $data ) { |
|
| 710 | - if ( ! array_filter( $data ) ) { |
|
| 709 | + foreach ($fb_shares as $key => $data) { |
|
| 710 | + if ( ! array_filter( $data )) { |
|
| 711 | 711 | continue; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 715 | 715 | |
| 716 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 717 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_fb'; |
|
| 718 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_fb'; |
|
| 716 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 717 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_fb'; |
|
| 718 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_fb'; |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | } |
@@ -765,22 +765,22 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | function ppp_fb_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 767 | 767 | global $ppp_options; |
| 768 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 768 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 769 | 769 | $fb_shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 770 | 770 | |
| 771 | - if ( ! empty( $fb_shares ) ) { |
|
| 771 | + if ( ! empty($fb_shares)) { |
|
| 772 | 772 | $name_array = explode( '_', $name ); |
| 773 | 773 | $index = $name_array[1]; |
| 774 | - if ( isset( $fb_shares[ $index ] ) ) { |
|
| 775 | - $share_content = $fb_shares[ $index ]['text']; |
|
| 774 | + if (isset($fb_shares[$index])) { |
|
| 775 | + $share_content = $fb_shares[$index]['text']; |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | // If an override was found, use it, otherwise try the default text content |
| 780 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 780 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 781 | 781 | |
| 782 | 782 | // If the content is still empty, just use the post title |
| 783 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 783 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 784 | 784 | |
| 785 | 785 | return apply_filters( 'ppp_share_content_fb', $share_content, array( 'post_id' => $post_id ) ); |
| 786 | 786 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @return bool Whether or not this tweet should contain a media post |
| 793 | 793 | */ |
| 794 | 794 | function ppp_fb_use_media( $post_id, $index ) { |
| 795 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 795 | + if (empty($post_id) || empty($index)) { |
|
| 796 | 796 | return false; |
| 797 | 797 | } |
| 798 | 798 | |
@@ -808,9 +808,9 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | ppp_set_social_tokens(); |
| 810 | 810 | |
| 811 | - $account = isset( $_POST['account'] ) ? $_POST['account'] : false; |
|
| 811 | + $account = isset($_POST['account']) ? $_POST['account'] : false; |
|
| 812 | 812 | |
| 813 | - if ( !empty( $account ) ) { |
|
| 813 | + if ( ! empty($account)) { |
|
| 814 | 814 | $ppp_social_settings['facebook']->page = $account; |
| 815 | 815 | |
| 816 | 816 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
@@ -826,14 +826,14 @@ discard block |
||
| 826 | 826 | function ppp_fb_calendar_on_publish_event( $events, $post_id ) { |
| 827 | 827 | $share_on_publish = get_post_meta( $post_id, '_ppp_fb_share_on_publish', true ); |
| 828 | 828 | |
| 829 | - if ( ! empty( $share_on_publish ) ) { |
|
| 829 | + if ( ! empty($share_on_publish)) { |
|
| 830 | 830 | $share_text = get_post_meta( $post_id, '_ppp_fb_share_on_publish_title', true ); |
| 831 | 831 | $events[] = array( |
| 832 | - 'id' => $post_id . '-share-on-publish', |
|
| 833 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_fb_generate_share_content( $post_id, null, false ), |
|
| 834 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 835 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 836 | - 'className' => 'ppp-calendar-item-fb cal-post-' . $post_id, |
|
| 832 | + 'id' => $post_id.'-share-on-publish', |
|
| 833 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_fb_generate_share_content( $post_id, null, false ), |
|
| 834 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 835 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 836 | + 'className' => 'ppp-calendar-item-fb cal-post-'.$post_id, |
|
| 837 | 837 | 'belongsTo' => $post_id, |
| 838 | 838 | ); |
| 839 | 839 | } |
@@ -844,9 +844,9 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | function ppp_fb_get_post_shares( $items, $post_id ) { |
| 846 | 846 | $shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 847 | - if ( empty( $shares ) ) { return $items; } |
|
| 847 | + if (empty($shares)) { return $items; } |
|
| 848 | 848 | |
| 849 | - foreach ( $shares as $key => $share ) { |
|
| 849 | + foreach ($shares as $key => $share) { |
|
| 850 | 850 | $items[] = array( 'id' => $key, 'service' => 'fb' ); |
| 851 | 851 | } |
| 852 | 852 | return $items; |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | function ppp_fb_clear_open_graph_cache( $post_id, $post_after, $post_before ) { |
| 866 | 866 | $post_types = ppp_allowed_post_types(); |
| 867 | - if ( ! in_array( $post_after->post_type, $post_types ) ) { |
|
| 867 | + if ( ! in_array( $post_after->post_type, $post_types )) { |
|
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( 'publish' == $post_after->post_status ) { |
|
| 871 | + if ('publish' == $post_after->post_status) { |
|
| 872 | 872 | global $ppp_facebook_oauth; |
| 873 | 873 | |
| 874 | 874 | return $ppp_facebook_oauth->clear_og_cache( $post_id ); |
@@ -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 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | * Handles all facebook functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Facebook' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Facebook' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Facebook { |
| 17 | 17 | |
| 18 | 18 | var $facebook; |
| 19 | 19 | |
| 20 | - public function __construct(){ |
|
| 20 | + public function __construct() { |
|
| 21 | 21 | ppp_maybe_start_session(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | public function ppp_load_facebook() { |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - if( !class_exists( 'Facebook' ) ) { |
|
| 34 | - require_once ( PPP_PATH . '/includes/libs/facebook/facebook.php' ); |
|
| 33 | + if ( ! class_exists( 'Facebook' )) { |
|
| 34 | + require_once (PPP_PATH.'/includes/libs/facebook/facebook.php'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ppp_set_social_tokens(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'appId' => PPP_FB_APP_ID, |
| 41 | 41 | 'secret' => PPP_FB_APP_SECRET, |
| 42 | 42 | 'cookie' => true |
| 43 | - )); |
|
| 43 | + ) ); |
|
| 44 | 44 | |
| 45 | 45 | return true; |
| 46 | 46 | |
@@ -55,72 +55,72 @@ discard block |
||
| 55 | 55 | $facebook = $this->ppp_load_facebook(); |
| 56 | 56 | |
| 57 | 57 | //when user is going to logged in and verified successfully session will create |
| 58 | - if ( isset( $_REQUEST['fb_access_token'] ) && isset( $_REQUEST['expires_in'] ) ) { |
|
| 58 | + if (isset($_REQUEST['fb_access_token']) && isset($_REQUEST['expires_in'])) { |
|
| 59 | 59 | |
| 60 | 60 | $access_token = $_REQUEST['fb_access_token']; |
| 61 | 61 | $expires_in = $_REQUEST['expires_in']; |
| 62 | 62 | |
| 63 | - } elseif ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false ) { |
|
| 64 | - $access_code = isset( $_GET['code'] ) ? $_GET['code'] : false; |
|
| 63 | + } elseif (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false) { |
|
| 64 | + $access_code = isset($_GET['code']) ? $_GET['code'] : false; |
|
| 65 | 65 | |
| 66 | - if ( empty( $access_code ) ) { |
|
| 66 | + if (empty($access_code)) { |
|
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $params = '?client_id=' . PPP_FB_APP_ID; |
|
| 71 | - $params .= '&client_secret=' . PPP_FB_APP_SECRET; |
|
| 72 | - $params .= '&code=' . $access_code; |
|
| 73 | - $params .= '&redirect_uri=' . admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 74 | - $url = 'https://graph.facebook.com/oauth/access_token' . $params; |
|
| 70 | + $params = '?client_id='.PPP_FB_APP_ID; |
|
| 71 | + $params .= '&client_secret='.PPP_FB_APP_SECRET; |
|
| 72 | + $params .= '&code='.$access_code; |
|
| 73 | + $params .= '&redirect_uri='.admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 74 | + $url = 'https://graph.facebook.com/oauth/access_token'.$params; |
|
| 75 | 75 | |
| 76 | 76 | $access_token = ''; |
| 77 | 77 | $expires = ''; |
| 78 | 78 | parse_str( wp_remote_retrieve_body( wp_remote_post( $url ) ) ); |
| 79 | 79 | |
| 80 | - $access_token = ! empty( $access_token ) ? $access_token : false; |
|
| 81 | - $expires_in = ! empty( $expires ) ? $expires : false; |
|
| 80 | + $access_token = ! empty($access_token) ? $access_token : false; |
|
| 81 | + $expires_in = ! empty($expires) ? $expires : false; |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( ! empty( $access_token ) ) { |
|
| 85 | + if ( ! empty($access_token)) { |
|
| 86 | 86 | global $ppp_social_settings; |
| 87 | 87 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 88 | 88 | |
| 89 | 89 | //check facebook class is loaded or not |
| 90 | - if( !$facebook ) { |
|
| 90 | + if ( ! $facebook) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $data = new stdClass(); |
| 95 | 95 | $data->access_token = $access_token; |
| 96 | 96 | |
| 97 | - $expires_in = empty( $expires_in ) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 97 | + $expires_in = empty($expires_in) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 98 | 98 | $data->expires_on = current_time( 'timestamp' ) + $expires_in; |
| 99 | 99 | |
| 100 | - update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in/1.25 ) ); |
|
| 100 | + update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in / 1.25 ) ); |
|
| 101 | 101 | |
| 102 | 102 | // Now that we have a valid auth, get some user info |
| 103 | 103 | $user_info = $this->ppp_get_fb_user( $data->access_token ); |
| 104 | 104 | |
| 105 | - if ( $user_info ) { |
|
| 106 | - if ( !empty( $user_info->name ) ) { |
|
| 105 | + if ($user_info) { |
|
| 106 | + if ( ! empty($user_info->name)) { |
|
| 107 | 107 | $data->name = $user_info->name; |
| 108 | 108 | } else { |
| 109 | - $parsed_name = $user_info->first_name . ' ' . $user_info->last_name; |
|
| 109 | + $parsed_name = $user_info->first_name.' '.$user_info->last_name; |
|
| 110 | 110 | $data->name = $parsed_name; |
| 111 | 111 | } |
| 112 | 112 | $data->userid = $user_info->id; |
| 113 | 113 | $data->avatar = $this->ppp_fb_get_profile_picture( array( 'type' => 'square' ), $data->userid ); |
| 114 | 114 | |
| 115 | - if ( ! empty( $ppp_social_settings['facebook']->page ) ) { |
|
| 115 | + if ( ! empty($ppp_social_settings['facebook']->page)) { |
|
| 116 | 116 | $current_page = $ppp_social_settings['facebook']->page; |
| 117 | 117 | $page_parts = explode( '|', $current_page ); |
| 118 | 118 | |
| 119 | 119 | $pages = $this->ppp_get_fb_user_pages( $data->access_token ); |
| 120 | 120 | |
| 121 | - foreach ( $pages as $page ) { |
|
| 122 | - if ( $page->id == $page_parts[2] ) { |
|
| 123 | - $data->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 121 | + foreach ($pages as $page) { |
|
| 122 | + if ($page->id == $page_parts[2]) { |
|
| 123 | + $data->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | - $url = remove_query_arg( array( 'fb_access_token' , 'expires_in' ) ); |
|
| 136 | + $url = remove_query_arg( array( 'fb_access_token', 'expires_in' ) ); |
|
| 137 | 137 | wp_redirect( $url ); |
| 138 | 138 | die(); |
| 139 | 139 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | $facebook = $this->ppp_load_facebook(); |
| 152 | 152 | |
| 153 | 153 | //check facebook class is exis or not |
| 154 | - if( !$facebook ) { |
|
| 154 | + if ( ! $facebook) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | global $ppp_social_settings; |
| 159 | - $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token=' . $access_token ) ) ); |
|
| 159 | + $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token='.$access_token ) ) ); |
|
| 160 | 160 | |
| 161 | 161 | return $user; |
| 162 | 162 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $facebook = $this->ppp_load_facebook(); |
| 169 | 169 | |
| 170 | 170 | // check facebook cleast is exists or not |
| 171 | - if( !$facebook ) { |
|
| 171 | + if ( ! $facebook) { |
|
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -176,20 +176,20 @@ discard block |
||
| 176 | 176 | $facebook_settings = $ppp_social_settings['facebook']; |
| 177 | 177 | |
| 178 | 178 | |
| 179 | - if ( ! isset( $facebook_settings->available_pages ) || |
|
| 180 | - ! isset( $facebook_settings->pages_last_updated ) || |
|
| 181 | - $facebook_settings->pages_last_updated < current_time( 'timestamp' ) ) { |
|
| 179 | + if ( ! isset($facebook_settings->available_pages) || |
|
| 180 | + ! isset($facebook_settings->pages_last_updated) || |
|
| 181 | + $facebook_settings->pages_last_updated < current_time( 'timestamp' )) { |
|
| 182 | 182 | |
| 183 | - $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token=' . $access_token ) ) ); |
|
| 183 | + $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token='.$access_token ) ) ); |
|
| 184 | 184 | $pages = array(); |
| 185 | 185 | |
| 186 | - if ( !empty( $all_pages ) ) { |
|
| 187 | - foreach ( $all_pages->data as $page ) { |
|
| 188 | - if ( in_array( 'CREATE_CONTENT', $page->tasks ) ) { |
|
| 186 | + if ( ! empty($all_pages)) { |
|
| 187 | + foreach ($all_pages->data as $page) { |
|
| 188 | + if (in_array( 'CREATE_CONTENT', $page->tasks )) { |
|
| 189 | 189 | $pages[] = $page; |
| 190 | 190 | |
| 191 | - if ( ! empty( $ppp_social_settings['facebook']->page ) && strpos( $ppp_social_settings['facebook']->page, $page->id ) ) { |
|
| 192 | - $ppp_social_settings['facebook']->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 191 | + if ( ! empty($ppp_social_settings['facebook']->page) && strpos( $ppp_social_settings['facebook']->page, $page->id )) { |
|
| 192 | + $ppp_social_settings['facebook']->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | $pages = (object) $pages; |
| 202 | 202 | $ppp_social_settings['facebook']->available_pages = $pages; |
| 203 | - $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + ( HOUR_IN_SECONDS / 4 ); |
|
| 203 | + $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + (HOUR_IN_SECONDS / 4); |
|
| 204 | 204 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 205 | 205 | } else { |
| 206 | 206 | $pages = $facebook_settings->available_pages; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $facebook = $this->ppp_load_facebook(); |
| 223 | 223 | |
| 224 | 224 | //check facebook class is exis or not |
| 225 | - if( !$facebook ) { |
|
| 225 | + if ( ! $facebook) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -233,27 +233,27 @@ discard block |
||
| 233 | 233 | * Get auth url for facebook |
| 234 | 234 | * |
| 235 | 235 | */ |
| 236 | - public function ppp_get_facebook_auth_url ( $return_url ) { |
|
| 236 | + public function ppp_get_facebook_auth_url( $return_url ) { |
|
| 237 | 237 | |
| 238 | 238 | //load facebook class |
| 239 | 239 | $facebook = $this->ppp_load_facebook(); |
| 240 | 240 | |
| 241 | 241 | //check facebook class is exis or not |
| 242 | - if( !$facebook ) { |
|
| 242 | + if ( ! $facebook) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( ! PPP_LOCAL_TOKENS ) { |
|
| 246 | + if ( ! PPP_LOCAL_TOKENS) { |
|
| 247 | 247 | $base_url = 'https://postpromoterpro.com/?ppp-social-auth'; |
| 248 | - $url = $base_url . '&ppp-service=fb&ppp-license-key=' . trim( get_option( '_ppp_license_key' ) ); |
|
| 248 | + $url = $base_url.'&ppp-service=fb&ppp-license-key='.trim( get_option( '_ppp_license_key' ) ); |
|
| 249 | 249 | $url .= '&nocache'; |
| 250 | - $url .= '&return_url=' . esc_url( $return_url ); |
|
| 250 | + $url .= '&return_url='.esc_url( $return_url ); |
|
| 251 | 251 | } else { |
| 252 | 252 | $url = 'https://graph.facebook.com/oauth/authorize?'; |
| 253 | - $url .= 'client_id=' . PPP_FB_APP_ID; |
|
| 253 | + $url .= 'client_id='.PPP_FB_APP_ID; |
|
| 254 | 254 | $url .= '&scope=public_profile,publish_actions,manage_pages,publish_pages'; |
| 255 | 255 | $url .= '&state=ppp-local-keys-fb'; |
| 256 | - $url .= '&redirect_uri=' . esc_url( $return_url ) . '&nocache'; |
|
| 256 | + $url .= '&redirect_uri='.esc_url( $return_url ).'&nocache'; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | return $url; |
@@ -265,14 +265,14 @@ discard block |
||
| 265 | 265 | * Getting the the profile image of the connected Facebook user. |
| 266 | 266 | * |
| 267 | 267 | */ |
| 268 | - public function ppp_fb_get_profile_picture( $args=array(), $user ) { |
|
| 268 | + public function ppp_fb_get_profile_picture( $args = array(), $user ) { |
|
| 269 | 269 | |
| 270 | - if( isset( $args['type'] ) && !empty( $args['type'] ) ) { |
|
| 270 | + if (isset($args['type']) && ! empty($args['type'])) { |
|
| 271 | 271 | $type = $args['type']; |
| 272 | 272 | } else { |
| 273 | 273 | $type = 'large'; |
| 274 | 274 | } |
| 275 | - $url = 'https://graph.facebook.com/' . $user . '/picture?type=' . $type; |
|
| 275 | + $url = 'https://graph.facebook.com/'.$user.'/picture?type='.$type; |
|
| 276 | 276 | return $url; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | global $ppp_social_settings; |
| 281 | 281 | $facebook_settings = $ppp_social_settings['facebook']; |
| 282 | 282 | |
| 283 | - if ( !isset( $facebook_settings->page ) || strtolower( $facebook_settings->page ) === 'me' ) { |
|
| 283 | + if ( ! isset($facebook_settings->page) || strtolower( $facebook_settings->page ) === 'me') { |
|
| 284 | 284 | $account = 'me'; |
| 285 | 285 | $access_token = $facebook_settings->access_token; |
| 286 | 286 | } else { |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | $access_token = $page_info[1]; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $url = 'https://graph.facebook.com/' . $account . '/feed?access_token=' . $access_token; |
|
| 292 | + $url = 'https://graph.facebook.com/'.$account.'/feed?access_token='.$access_token; |
|
| 293 | 293 | $args = array( 'link' => $link, 'message' => $message ); |
| 294 | - if ( !empty( $image ) ) { |
|
| 294 | + if ( ! empty($image)) { |
|
| 295 | 295 | $args['picture'] = $image; |
| 296 | 296 | } |
| 297 | 297 | $results = json_decode( wp_remote_retrieve_body( wp_remote_post( $url, array( 'body' => $args ) ) ) ); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | public function ppp_get_data_from_url( $url ) { |
| 311 | 311 | |
| 312 | 312 | //Use wp_remote_post and wp_remote_get |
| 313 | - $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 313 | + $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 314 | 314 | |
| 315 | 315 | return $data; |
| 316 | 316 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function clear_og_cache( $post_id ) { |
| 324 | 324 | $post_url = get_permalink( $post_id ); |
| 325 | - if ( ! empty( $post_url ) ) { |
|
| 325 | + if ( ! empty($post_url)) { |
|
| 326 | 326 | $args = array( 'body' => array( 'id' => $post_url, 'scrape' => true ) ); |
| 327 | 327 | $response = json_decode( wp_remote_retrieve_body( wp_remote_post( 'https://graph.facebook.com/', $args ) ) ); |
| 328 | 328 | } |