@@ -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,7 +11,7 @@ discard block |
||
| 11 | 11 | * Handles all twitter functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Twitter_User' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Twitter_User' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Twitter_User { |
| 17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | ppp_maybe_start_session(); |
| 20 | 20 | $this->user_id = $_user_id; |
| 21 | 21 | |
| 22 | - if ( ! empty( $this->user_id ) ) { |
|
| 22 | + if ( ! empty($this->user_id)) { |
|
| 23 | 23 | $this->verify_credentials(); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * Handles to load twitter class |
| 31 | 31 | */ |
| 32 | 32 | public function load() { |
| 33 | - if( !class_exists( 'TwitterOAuth' ) ) { |
|
| 34 | - require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' ); |
|
| 33 | + if ( ! class_exists( 'TwitterOAuth' )) { |
|
| 34 | + require_once (PPP_PATH.'/includes/libs/twitter/twitteroauth.php'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ppp_set_social_tokens(); |
| 38 | 38 | |
| 39 | - if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' ) ) { |
|
| 39 | + if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' )) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function init() { |
| 57 | 57 | |
| 58 | 58 | //when user is going to logged in in twitter and verified successfully session will create |
| 59 | - if ( isset( $_REQUEST['oauth_verifier'] ) ) { |
|
| 59 | + if (isset($_REQUEST['oauth_verifier'])) { |
|
| 60 | 60 | |
| 61 | 61 | //load twitter class |
| 62 | 62 | $twitter = $this->load(); |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | //session for verifier |
| 69 | 69 | $verifier['oauth_verifier'] = $_REQUEST['oauth_verifier']; |
| 70 | - $_SESSION[ 'ppp_twt_user_cache' ] = $verifier; |
|
| 70 | + $_SESSION['ppp_twt_user_cache'] = $verifier; |
|
| 71 | 71 | |
| 72 | 72 | //getting user data from twitter |
| 73 | 73 | $response = $this->twitter->get( 'account/verify_credentials' ); |
| 74 | 74 | |
| 75 | 75 | //if user data get successfully |
| 76 | - if ( $response->id_str ) { |
|
| 76 | + if ($response->id_str) { |
|
| 77 | 77 | $data['user'] = $response; |
| 78 | 78 | $data['user']->accessToken = $ppp_tw_access_token; |
| 79 | 79 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->load(); |
| 87 | 87 | |
| 88 | 88 | $user_settings = get_user_meta( $this->user_id, '_ppp_twitter_data', true ); |
| 89 | - if ( ! empty( $user_settings ) ) { |
|
| 89 | + if ( ! empty($user_settings)) { |
|
| 90 | 90 | |
| 91 | 91 | $this->twitter = new TwitterOAuth( |
| 92 | 92 | PPP_TW_CONSUMER_KEY, |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | $user_settings['user']->accessToken['oauth_token_secret'] |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 99 | - if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) { |
|
| 100 | - foreach ( $response->errors as $error ) { |
|
| 101 | - if ( $error->code == 89 ) { // Expired or revoked tokens |
|
| 98 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 99 | + if (is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0) { |
|
| 100 | + foreach ($response->errors as $error) { |
|
| 101 | + if ($error->code == 89) { // Expired or revoked tokens |
|
| 102 | 102 | |
| 103 | 103 | $this->revoke_access(); |
| 104 | 104 | |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * Get auth url for twitter |
| 116 | 116 | * |
| 117 | 117 | */ |
| 118 | - public function get_auth_url ( $return_url = '' ) { |
|
| 118 | + public function get_auth_url( $return_url = '' ) { |
|
| 119 | 119 | |
| 120 | - if ( empty( $return_url ) ) { |
|
| 120 | + if (empty($return_url)) { |
|
| 121 | 121 | $return_url = admin_url( 'admin.php?page=ppp-social-settings' ); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $request_token = $this->twitter->getRequestToken( 'oob' ); |
| 127 | 127 | |
| 128 | 128 | // If last connection failed don't display authorization link. |
| 129 | - switch( $this->twitter->http_code ) { |
|
| 129 | + switch ($this->twitter->http_code) { |
|
| 130 | 130 | case 200: |
| 131 | 131 | $_SESSION['ppp_user_twt_oauth_token'] = $request_token['oauth_token']; |
| 132 | 132 | $_SESSION['ppp_user_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
@@ -143,14 +143,14 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public function send_tweet( $message = '', $media = null ) { |
| 146 | - if ( empty( $message ) ) { |
|
| 146 | + if (empty($message)) { |
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $verify = $this->verify_credentials(); |
| 151 | - if ( $verify === true ) { |
|
| 151 | + if ($verify === true) { |
|
| 152 | 152 | $args = array(); |
| 153 | - if ( ! empty( $media ) ) { |
|
| 153 | + if ( ! empty($media)) { |
|
| 154 | 154 | $endpoint = 'statuses/update_with_media'; |
| 155 | 155 | $args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) ); |
| 156 | 156 | } else { |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | public function retweet( $tweet_id ) { |
| 168 | - if ( empty( $tweet_id ) ) { |
|
| 168 | + if (empty($tweet_id)) { |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $verify = $this->verify_credentials(); |
| 173 | - if ( $verify === true ) { |
|
| 174 | - $endpoint = 'statuses/retweet/' . $tweet_id; |
|
| 173 | + if ($verify === true) { |
|
| 174 | + $endpoint = 'statuses/retweet/'.$tweet_id; |
|
| 175 | 175 | |
| 176 | 176 | return $this->twitter->post( $endpoint, array(), true ); |
| 177 | 177 | } else { |
@@ -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_twitter_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['twitter'] ) && !empty( $ppp_social_settings['twitter'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['twitter']) && ! empty($ppp_social_settings['twitter'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function ppp_tw_account_list_avatar( $string = '' ) { |
| 52 | 52 | |
| 53 | - if ( ppp_twitter_enabled() ) { |
|
| 53 | + if (ppp_twitter_enabled()) { |
|
| 54 | 54 | global $ppp_social_settings; |
| 55 | 55 | $avatar_url = $ppp_social_settings['twitter']['user']->profile_image_url_https; |
| 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,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function ppp_tw_account_list_name( $string = '' ) { |
| 69 | 69 | |
| 70 | - if ( ppp_twitter_enabled() ) { |
|
| 70 | + if (ppp_twitter_enabled()) { |
|
| 71 | 71 | global $ppp_social_settings; |
| 72 | 72 | $string .= $ppp_social_settings['twitter']['user']->name; |
| 73 | 73 | } |
@@ -83,17 +83,17 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function ppp_tw_account_list_actions( $string = '' ) { |
| 85 | 85 | |
| 86 | - if ( ! ppp_twitter_enabled() ) { |
|
| 86 | + if ( ! ppp_twitter_enabled()) { |
|
| 87 | 87 | global $ppp_twitter_oauth, $ppp_social_settings; |
| 88 | 88 | $tw_auth = $ppp_twitter_oauth->ppp_verify_twitter_credentials(); |
| 89 | 89 | $tw_authurl = $ppp_twitter_oauth->ppp_get_twitter_auth_url(); |
| 90 | 90 | |
| 91 | - $string .= '<span id="tw-oob-auth-link-wrapper"><a id="tw-oob-auth-link" href="' . $tw_authurl . '" target="_blank"><img src="' . PPP_URL . '/includes/images/sign-in-with-twitter-gray.png" /></a></span>'; |
|
| 92 | - $string .= '<span style="display:none;" id="tw-oob-pin-notice">' . __( 'You are being directed to Twitter to authenticate. When complete, return here and enter the PIN you were provided.', 'ppp-txt' ) . '</span>'; |
|
| 93 | - $string .= '<span style="display:none;" id="tw-oob-pin-wrapper"><input type="text" size="10" placeholder="Enter your PIN" value="" id="tw-oob-pin" data-nonce="' . wp_create_nonce( 'ppp-tw-pin' ) . '" data-user="0" /> <a href="#" class="button-secondary tw-oob-pin-submit">' . __( 'Submit', 'ppp-txt' ) . '</a><span class="spinner"></span></span>'; |
|
| 91 | + $string .= '<span id="tw-oob-auth-link-wrapper"><a id="tw-oob-auth-link" href="'.$tw_authurl.'" target="_blank"><img src="'.PPP_URL.'/includes/images/sign-in-with-twitter-gray.png" /></a></span>'; |
|
| 92 | + $string .= '<span style="display:none;" id="tw-oob-pin-notice">'.__( 'You are being directed to Twitter to authenticate. When complete, return here and enter the PIN you were provided.', 'ppp-txt' ).'</span>'; |
|
| 93 | + $string .= '<span style="display:none;" id="tw-oob-pin-wrapper"><input type="text" size="10" placeholder="Enter your PIN" value="" id="tw-oob-pin" data-nonce="'.wp_create_nonce( 'ppp-tw-pin' ).'" data-user="0" /> <a href="#" class="button-secondary tw-oob-pin-submit">'.__( 'Submit', 'ppp-txt' ).'</a><span class="spinner"></span></span>'; |
|
| 94 | 94 | } else { |
| 95 | - $string .= '<a class="button-primary" href="' . admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=twitter' ) . '" >' . __( 'Disconnect from Twitter', 'ppp-txt' ) . '</a> '; |
|
| 96 | - $string .= '<a class="button-secondary" href="https://twitter.com/settings/applications" target="blank">' . __( 'Revoke Access via Twitter', 'ppp-txt' ) . '</a>'; |
|
| 95 | + $string .= '<a class="button-primary" href="'.admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=twitter' ).'" >'.__( 'Disconnect from Twitter', 'ppp-txt' ).'</a> '; |
|
| 96 | + $string .= '<a class="button-secondary" href="https://twitter.com/settings/applications" target="blank">'.__( 'Revoke Access via Twitter', 'ppp-txt' ).'</a>'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $string; |
@@ -106,27 +106,27 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | ppp_set_social_tokens(); |
| 108 | 108 | |
| 109 | - $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; |
|
| 109 | + $nonce = isset($_POST['nonce']) ? sanitize_text_field( $_POST['nonce'] ) : ''; |
|
| 110 | 110 | $nonce_verified = wp_verify_nonce( $nonce, 'ppp-tw-pin' ); |
| 111 | 111 | |
| 112 | - if ( ! $nonce_verified ) { |
|
| 112 | + if ( ! $nonce_verified) { |
|
| 113 | 113 | wp_die(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $pin = isset( $_POST['pin'] ) ? absint( $_POST['pin'] ) : false; |
|
| 116 | + $pin = isset($_POST['pin']) ? absint( $_POST['pin'] ) : false; |
|
| 117 | 117 | |
| 118 | - if ( empty( $pin ) ) { |
|
| 118 | + if (empty($pin)) { |
|
| 119 | 119 | wp_die(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $_REQUEST['oauth_verifier'] = $pin; |
| 123 | 123 | |
| 124 | - if ( empty( $_POST['user_auth'] ) ) { |
|
| 124 | + if (empty($_POST['user_auth'])) { |
|
| 125 | 125 | $twitter = new PPP_Twitter; |
| 126 | 126 | $twitter->ppp_initialize_twitter(); |
| 127 | 127 | $settings = get_option( 'ppp_social_settings', true ); |
| 128 | 128 | |
| 129 | - if ( ! empty( $settings['twitter']['user']->id ) ) { |
|
| 129 | + if ( ! empty($settings['twitter']['user']->id)) { |
|
| 130 | 130 | echo 1; |
| 131 | 131 | } else { |
| 132 | 132 | echo 0; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $twitter->init(); |
| 137 | 137 | |
| 138 | 138 | $user = get_user_meta( get_current_user_id(), '_ppp_twitter_data', true ); |
| 139 | - if ( ! empty( $user['user']->id ) ) { |
|
| 139 | + if ( ! empty($user['user']->id)) { |
|
| 140 | 140 | echo 1; |
| 141 | 141 | } else { |
| 142 | 142 | echo 0; |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | function ppp_capture_twitter_oauth() { |
| 155 | - if ( isset( $_REQUEST['oauth_verifier'] ) && isset( $_REQUEST['oauth_token'] ) ) { |
|
| 155 | + if (isset($_REQUEST['oauth_verifier']) && isset($_REQUEST['oauth_token'])) { |
|
| 156 | 156 | $current_screen = get_current_screen(); |
| 157 | - if ( 'user-edit' === $current_screen->base ) { |
|
| 158 | - $user_id = ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ? $_GET['user_id'] : false; |
|
| 157 | + if ('user-edit' === $current_screen->base) { |
|
| 158 | + $user_id = ! empty($_GET['user_id']) && is_numeric( $_GET['user_id'] ) ? $_GET['user_id'] : false; |
|
| 159 | 159 | $twitter = new PPP_Twitter_User( $user_id ); |
| 160 | 160 | $twitter->init(); |
| 161 | - $redirect = admin_url( 'user-edit.php?updated=1&user_id=' . $user_id ); |
|
| 161 | + $redirect = admin_url( 'user-edit.php?updated=1&user_id='.$user_id ); |
|
| 162 | 162 | } else { |
| 163 | 163 | global $ppp_twitter_oauth; |
| 164 | 164 | $ppp_twitter_oauth->ppp_initialize_twitter(); |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | * @return void |
| 177 | 177 | */ |
| 178 | 178 | function ppp_disconnect_twitter() { |
| 179 | - if ( ! empty( $_GET['user_id'] ) ) { |
|
| 179 | + if ( ! empty($_GET['user_id'])) { |
|
| 180 | 180 | $user_id = (int) sanitize_text_field( $_GET['user_id'] ); |
| 181 | - if ( $user_id !== get_current_user_id() || ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 181 | + if ($user_id !== get_current_user_id() || ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 182 | 182 | wp_die( __( 'Unable to disconnect Twitter account', 'ppp-txt' ) ); |
| 183 | 183 | } |
| 184 | 184 | delete_user_meta( $user_id, '_ppp_twitter_data' ); |
| 185 | 185 | } else { |
| 186 | 186 | global $ppp_social_settings; |
| 187 | 187 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 188 | - if ( isset( $ppp_social_settings['twitter'] ) ) { |
|
| 189 | - unset( $ppp_social_settings['twitter'] ); |
|
| 188 | + if (isset($ppp_social_settings['twitter'])) { |
|
| 189 | + unset($ppp_social_settings['twitter']); |
|
| 190 | 190 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | global $ppp_options, $wp_logs, $wp_filter; |
| 218 | 218 | |
| 219 | 219 | $post_meta = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 220 | - $this_share = $post_meta[ $index ]; |
|
| 221 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 220 | + $this_share = $post_meta[$index]; |
|
| 221 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 222 | 222 | |
| 223 | 223 | $share_message = ppp_tw_build_share_message( $post_id, $name ); |
| 224 | 224 | |
| 225 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 225 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 226 | 226 | $media = $this_share['image']; |
| 227 | 227 | } else { |
| 228 | 228 | $use_media = ppp_tw_use_media( $post_id, $index ); |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | update_post_meta( $log_entry, '_ppp_share_status', $status ); |
| 251 | 251 | |
| 252 | - if ( ! empty( $status->id_str ) ) { |
|
| 252 | + if ( ! empty($status->id_str)) { |
|
| 253 | 253 | $post = get_post( $post_id ); |
| 254 | 254 | $author_id = $post->post_author; |
| 255 | 255 | $author_rt = get_user_meta( $author_id, '_ppp_share_scheduled', true ); |
| 256 | 256 | |
| 257 | - if ( $author_rt ) { |
|
| 257 | + if ($author_rt) { |
|
| 258 | 258 | $twitter_user = new PPP_Twitter_User( $author_id ); |
| 259 | 259 | $twitter_user->retweet( $status->id_str ); |
| 260 | 260 | } |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | ); |
| 276 | 276 | $other_rt = get_users( $args ); |
| 277 | 277 | |
| 278 | - if ( $other_rt ){ |
|
| 279 | - foreach ( $other_rt as $user ) { |
|
| 278 | + if ($other_rt) { |
|
| 279 | + foreach ($other_rt as $user) { |
|
| 280 | 280 | $twitter_user = new PPP_Twitter_User( $user->ID ); |
| 281 | 281 | $twitter_user->retweet( $status->id_str ); |
| 282 | 282 | } |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | function ppp_tw_build_share_message( $post_id, $name, $scheduled = true, $include_link = true ) { |
| 297 | 297 | $share_content = ppp_tw_generate_share_content( $post_id, $name, $scheduled ); |
| 298 | 298 | |
| 299 | - if ( $include_link ) { |
|
| 299 | + if ($include_link) { |
|
| 300 | 300 | $share_link = ppp_generate_link( $post_id, $name, $scheduled ); |
| 301 | - $share_content = $share_content . ' ' . $share_link; |
|
| 301 | + $share_content = $share_content.' '.$share_link; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | return apply_filters( 'ppp_tw_build_share_message', $share_content ); |
@@ -312,22 +312,22 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function ppp_tw_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 314 | 314 | global $ppp_options; |
| 315 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 315 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 316 | 316 | $ppp_tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 317 | 317 | |
| 318 | - if ( ! empty( $ppp_tweets ) ) { |
|
| 318 | + if ( ! empty($ppp_tweets)) { |
|
| 319 | 319 | $name_array = explode( '_', $name ); |
| 320 | 320 | $index = $name_array[1]; |
| 321 | - if ( isset( $ppp_tweets[ $index ] ) ) { |
|
| 322 | - $share_content = $ppp_tweets[ $index ]['text']; |
|
| 321 | + if (isset($ppp_tweets[$index])) { |
|
| 322 | + $share_content = $ppp_tweets[$index]['text']; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // If an override was found, use it, otherwise try the default text content |
| 327 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 327 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 328 | 328 | |
| 329 | 329 | // If the content is still empty, just use the post title |
| 330 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 330 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 331 | 331 | |
| 332 | 332 | return apply_filters( 'ppp_share_content', $share_content, array( 'post_id' => $post_id ) ); |
| 333 | 333 | } |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | * @return bool Whether or not this tweet should contain a media post |
| 340 | 340 | */ |
| 341 | 341 | function ppp_tw_use_media( $post_id, $index ) { |
| 342 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 342 | + if (empty($post_id) || empty($index)) { |
|
| 343 | 343 | return false; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $share_data = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 347 | - $use_media = ! empty( $share_data[$index]['attachment_id'] ) || ! empty( $share_data[$index]['image'] ) ? true : false; |
|
| 347 | + $use_media = ! empty($share_data[$index]['attachment_id']) || ! empty($share_data[$index]['image']) ? true : false; |
|
| 348 | 348 | |
| 349 | 349 | return $use_media; |
| 350 | 350 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @return void |
| 356 | 356 | */ |
| 357 | 357 | function ppp_set_tw_token_constants( $social_tokens ) { |
| 358 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'twitter' ) ) { |
|
| 358 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'twitter' )) { |
|
| 359 | 359 | define( 'PPP_TW_CONSUMER_KEY', $social_tokens->twitter->consumer_token ); |
| 360 | 360 | define( 'PPP_TW_CONSUMER_SECRET', $social_tokens->twitter->consumer_secret ); |
| 361 | 361 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function ppp_tw_add_meta_tab( $tabs ) { |
| 395 | 395 | global $ppp_social_settings; |
| 396 | - if ( !isset( $ppp_social_settings['twitter'] ) ) { |
|
| 396 | + if ( ! isset($ppp_social_settings['twitter'])) { |
|
| 397 | 397 | return $tabs; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | function ppp_tw_register_metabox_content( $content ) { |
| 412 | 412 | global $ppp_social_settings; |
| 413 | - if ( !isset( $ppp_social_settings['twitter'] ) ) { |
|
| 413 | + if ( ! isset($ppp_social_settings['twitter'])) { |
|
| 414 | 414 | return $content; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -469,16 +469,16 @@ discard block |
||
| 469 | 469 | <tbody> |
| 470 | 470 | <?php ppp_render_tweet_share_on_publish_row(); ?> |
| 471 | 471 | <?php $tweets = get_post_meta( $post->ID, '_ppp_tweets', true ); ?> |
| 472 | - <?php if ( ! empty( $tweets ) ) : ?> |
|
| 472 | + <?php if ( ! empty($tweets)) : ?> |
|
| 473 | 473 | |
| 474 | - <?php foreach ( $tweets as $key => $value ) : |
|
| 475 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 476 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 477 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 478 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 479 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 474 | + <?php foreach ($tweets as $key => $value) : |
|
| 475 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 476 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 477 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 478 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 479 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 480 | 480 | |
| 481 | - $args = apply_filters( 'ppp_tweet_row_args', compact( 'date','time','text','image','attachment_id' ), $value ); |
|
| 481 | + $args = apply_filters( 'ppp_tweet_row_args', compact( 'date', 'time', 'text', 'image', 'attachment_id' ), $value ); |
|
| 482 | 482 | ?> |
| 483 | 483 | |
| 484 | 484 | <?php ppp_render_tweet_row( $key, $args, $post->ID ); ?> |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | <?php endforeach; ?> |
| 488 | 488 | |
| 489 | 489 | <?php |
| 490 | - if ( ! empty( $has_past_shares ) && count ( $tweets ) == $has_past_shares ) { |
|
| 490 | + if ( ! empty($has_past_shares) && count( $tweets ) == $has_past_shares) { |
|
| 491 | 491 | $args = array( |
| 492 | 492 | 'date' => '', |
| 493 | 493 | 'time' => '', |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | <tr class="ppp-add-repeatable-wrapper"> |
| 511 | 511 | <td class="submit" colspan="4" style="float: none; clear:both; background:#fff;"> |
| 512 | 512 | <a class="button-secondary ppp-add-repeatable" style="margin: 6px 0;"><?php _e( 'Add New Tweet', 'ppp-txt' ); ?></a> |
| 513 | - <?php if ( ! empty( $has_past_shares ) ) : ?> |
|
| 513 | + <?php if ( ! empty($has_past_shares)) : ?> |
|
| 514 | 514 | <a class="button-secondary ppp-view-all" style="margin: 6px 0;"><?php _e( 'Toggle Past Tweets', 'ppp-txt' ); ?></a> |
| 515 | 515 | <?php endif; ?> |
| 516 | 516 | </td> |
@@ -536,38 +536,38 @@ discard block |
||
| 536 | 536 | */ |
| 537 | 537 | function ppp_render_tweet_share_on_publish_row() { |
| 538 | 538 | global $post, $ppp_share_settings; |
| 539 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 539 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 540 | 540 | |
| 541 | 541 | $ppp_post_exclude = get_post_meta( $post->ID, '_ppp_post_exclude', true ); |
| 542 | 542 | |
| 543 | 543 | $ppp_share_on_publish = get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
| 544 | 544 | $show_share_on_publish = false; |
| 545 | 545 | |
| 546 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['twitter'] ) ? false : true; |
|
| 546 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['twitter']) ? false : true; |
|
| 547 | 547 | |
| 548 | - if ( $ppp_share_on_publish == '1' || ( $ppp_share_on_publish == '' && $share_by_default ) ) { |
|
| 548 | + if ($ppp_share_on_publish == '1' || ($ppp_share_on_publish == '' && $share_by_default)) { |
|
| 549 | 549 | $show_share_on_publish = true; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | $ppp_share_on_publish_text = get_post_meta( $post->ID, '_ppp_share_on_publish_text', true ); |
| 553 | 553 | $ppp_share_on_publish_include_image = get_post_meta( $post->ID, '_ppp_share_on_publish_include_image', true ); |
| 554 | 554 | |
| 555 | - $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; |
|
| 555 | + $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; |
|
| 556 | 556 | ?> |
| 557 | 557 | <tr class="ppp-tweet-wrapper ppp-repeatable-row on-publish-row"> |
| 558 | 558 | <td colspan="2" class="ppp-on-plublish-date-column"> |
| 559 | - <input <?php if ( $disabled ): ?>readonly<?php endif; ?> type="checkbox" name="_ppp_share_on_publish" id="ppp_share_on_publish" value="1" <?php checked( true, $show_share_on_publish, true ); ?> /> |
|
| 559 | + <input <?php if ($disabled): ?>readonly<?php endif; ?> type="checkbox" name="_ppp_share_on_publish" id="ppp_share_on_publish" value="1" <?php checked( true, $show_share_on_publish, true ); ?> /> |
|
| 560 | 560 | <label for="ppp_share_on_publish"><?php _e( 'Tweet On Publish', 'ppp-txt' ); ?></label> |
| 561 | 561 | </td> |
| 562 | 562 | |
| 563 | 563 | <td> |
| 564 | - <textarea <?php if ( $disabled ): ?>readonly<?php endif; ?> class="ppp-tweet-text-repeatable" type="text" name="_ppp_share_on_publish_text"><?php echo esc_attr( $ppp_share_on_publish_text ); ?></textarea> |
|
| 565 | - <?php $length = ! empty( $ppp_share_on_publish_text ) ? strlen( $ppp_share_on_publish_text ) : 0; ?> |
|
| 564 | + <textarea <?php if ($disabled): ?>readonly<?php endif; ?> class="ppp-tweet-text-repeatable" type="text" name="_ppp_share_on_publish_text"><?php echo esc_attr( $ppp_share_on_publish_text ); ?></textarea> |
|
| 565 | + <?php $length = ! empty($ppp_share_on_publish_text) ? strlen( $ppp_share_on_publish_text ) : 0; ?> |
|
| 566 | 566 | <span class="ppp-text-length"><?php echo $length; ?></span> |
| 567 | 567 | </td> |
| 568 | 568 | |
| 569 | 569 | <td style="width: 200px" colspan="2"> |
| 570 | - <input class="ppp-tw-featured-image-input" <?php if ( $disabled ): ?>readonly<?php endif; ?> id="ppp-share-on-publish-image" type="checkbox" name="_ppp_share_on_publish_include_image" value="1" <?php checked( '1', $ppp_share_on_publish_include_image, true ); ?>/> |
|
| 570 | + <input class="ppp-tw-featured-image-input" <?php if ($disabled): ?>readonly<?php endif; ?> id="ppp-share-on-publish-image" type="checkbox" name="_ppp_share_on_publish_include_image" value="1" <?php checked( '1', $ppp_share_on_publish_include_image, true ); ?>/> |
|
| 571 | 571 | <label for="ppp-share-on-publish-image"><?php _e( 'Featured Image', 'ppp-txt' ); ?></label> |
| 572 | 572 | </td> |
| 573 | 573 | |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | function ppp_render_tweet_row( $key, $args = array(), $post_id ) { |
| 587 | 587 | global $post, $has_past_shares; |
| 588 | 588 | |
| 589 | - if ( ! empty( $args['date'] ) && ! empty( $args['time'] ) ) { |
|
| 589 | + if ( ! empty($args['date']) && ! empty($args['time'])) { |
|
| 590 | 590 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 591 | 591 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 592 | 592 | } else { |
@@ -594,11 +594,11 @@ discard block |
||
| 594 | 594 | $readonly = false; |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 598 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 599 | - $shared = ! empty( $readonly ) ? 'past-share' : ''; |
|
| 597 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 598 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 599 | + $shared = ! empty($readonly) ? 'past-share' : ''; |
|
| 600 | 600 | |
| 601 | - if ( ! empty( $readonly ) ) { |
|
| 601 | + if ( ! empty($readonly)) { |
|
| 602 | 602 | $has_past_shares++; |
| 603 | 603 | } |
| 604 | 604 | ?> |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | <td> |
| 615 | 615 | <textarea class="ppp-tweet-text-repeatable" type="text" name="_ppp_tweets[<?php echo $key; ?>][text]" <?php echo $readonly; ?>><?php echo esc_attr( $args['text'] ); ?></textarea> |
| 616 | - <?php $length = ! empty( $args['text'] ) ? strlen( $args['text'] ) : 0; ?> |
|
| 616 | + <?php $length = ! empty($args['text']) ? strlen( $args['text'] ) : 0; ?> |
|
| 617 | 617 | <span class="ppp-text-length"><?php echo $length; ?></span> |
| 618 | 618 | </td> |
| 619 | 619 | |
@@ -648,24 +648,24 @@ discard block |
||
| 648 | 648 | */ |
| 649 | 649 | function ppp_tw_save_post_meta_boxes( $post_id, $post ) { |
| 650 | 650 | |
| 651 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 651 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 652 | 652 | return; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $ppp_post_exclude = ( isset( $_REQUEST['_ppp_post_exclude'] ) ) ? $_REQUEST['_ppp_post_exclude'] : '0'; |
|
| 655 | + $ppp_post_exclude = (isset($_REQUEST['_ppp_post_exclude'])) ? $_REQUEST['_ppp_post_exclude'] : '0'; |
|
| 656 | 656 | |
| 657 | - $ppp_share_on_publish = ( isset( $_REQUEST['_ppp_share_on_publish'] ) ) ? $_REQUEST['_ppp_share_on_publish'] : '0'; |
|
| 658 | - $ppp_share_on_publish_text = ( isset( $_REQUEST['_ppp_share_on_publish_text'] ) ) ? $_REQUEST['_ppp_share_on_publish_text'] : ''; |
|
| 659 | - $ppp_share_on_publish_include_image = ( isset( $_REQUEST['_ppp_share_on_publish_include_image'] ) ) ? $_REQUEST['_ppp_share_on_publish_include_image'] : ''; |
|
| 657 | + $ppp_share_on_publish = (isset($_REQUEST['_ppp_share_on_publish'])) ? $_REQUEST['_ppp_share_on_publish'] : '0'; |
|
| 658 | + $ppp_share_on_publish_text = (isset($_REQUEST['_ppp_share_on_publish_text'])) ? $_REQUEST['_ppp_share_on_publish_text'] : ''; |
|
| 659 | + $ppp_share_on_publish_include_image = (isset($_REQUEST['_ppp_share_on_publish_include_image'])) ? $_REQUEST['_ppp_share_on_publish_include_image'] : ''; |
|
| 660 | 660 | |
| 661 | 661 | |
| 662 | 662 | update_post_meta( $post_id, '_ppp_share_on_publish', $ppp_share_on_publish ); |
| 663 | 663 | update_post_meta( $post_id, '_ppp_share_on_publish_text', $ppp_share_on_publish_text ); |
| 664 | 664 | update_post_meta( $post_id, '_ppp_share_on_publish_include_image', $ppp_share_on_publish_include_image ); |
| 665 | 665 | |
| 666 | - $tweet_data = isset( $_REQUEST['_ppp_tweets'] ) ? $_REQUEST['_ppp_tweets'] : array(); |
|
| 667 | - foreach ( $tweet_data as $index => $tweet ) { |
|
| 668 | - $tweet_data[ $index ]['text'] = sanitize_text_field( $tweet['text'] ); |
|
| 666 | + $tweet_data = isset($_REQUEST['_ppp_tweets']) ? $_REQUEST['_ppp_tweets'] : array(); |
|
| 667 | + foreach ($tweet_data as $index => $tweet) { |
|
| 668 | + $tweet_data[$index]['text'] = sanitize_text_field( $tweet['text'] ); |
|
| 669 | 669 | } |
| 670 | 670 | update_post_meta( $post_id, '_ppp_tweets', $tweet_data ); |
| 671 | 671 | |
@@ -682,29 +682,29 @@ discard block |
||
| 682 | 682 | function ppp_tw_share_on_publish( $new_status, $old_status, $post ) { |
| 683 | 683 | global $ppp_options; |
| 684 | 684 | |
| 685 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
|
| 686 | - $from_post = isset( $_POST['_ppp_share_on_publish'] ); |
|
| 685 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
|
| 686 | + $from_post = isset($_POST['_ppp_share_on_publish']); |
|
| 687 | 687 | |
| 688 | - if ( empty( $from_meta ) && empty( $from_post ) ) { |
|
| 688 | + if (empty($from_meta) && empty($from_post)) { |
|
| 689 | 689 | return; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | // Determine if we're seeing the share on publish in meta or $_POST |
| 693 | - if ( $from_meta && !$from_post ) { |
|
| 693 | + if ($from_meta && ! $from_post) { |
|
| 694 | 694 | $ppp_share_on_publish_text = get_post_meta( $post->ID, '_ppp_share_on_publish_text', true ); |
| 695 | 695 | $use_media = get_post_meta( $post->ID, '_ppp_share_on_publish_include_image', true ); |
| 696 | 696 | } else { |
| 697 | - $ppp_share_on_publish_text = isset( $_POST['_ppp_share_on_publish_text'] ) ? $_POST['_ppp_share_on_publish_text'] : ''; |
|
| 698 | - $use_media = isset( $_POST['_ppp_share_on_publish_include_image'] ) ? $_POST['_ppp_share_on_publish_include_image'] : false; |
|
| 697 | + $ppp_share_on_publish_text = isset($_POST['_ppp_share_on_publish_text']) ? $_POST['_ppp_share_on_publish_text'] : ''; |
|
| 698 | + $use_media = isset($_POST['_ppp_share_on_publish_include_image']) ? $_POST['_ppp_share_on_publish_include_image'] : false; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - $share_content = ( !empty( $ppp_share_on_publish_text ) ) ? $ppp_share_on_publish_text : ppp_tw_generate_share_content( $post->ID, null, false ); |
|
| 701 | + $share_content = ( ! empty($ppp_share_on_publish_text)) ? $ppp_share_on_publish_text : ppp_tw_generate_share_content( $post->ID, null, false ); |
|
| 702 | 702 | $share_content = apply_filters( 'ppp_share_content', $share_content, array( 'post_id' => $post->ID ) ); |
| 703 | - $name = 'sharedate_0_' . $post->ID; |
|
| 703 | + $name = 'sharedate_0_'.$post->ID; |
|
| 704 | 704 | $media = ppp_post_has_media( $post->ID, 'tw', $use_media ); |
| 705 | 705 | $share_link = ppp_generate_link( $post->ID, $name, true ); |
| 706 | 706 | |
| 707 | - $status = ppp_send_tweet( $share_content . ' ' . $share_link, $post->ID, $media ); |
|
| 707 | + $status = ppp_send_tweet( $share_content.' '.$share_link, $post->ID, $media ); |
|
| 708 | 708 | |
| 709 | 709 | $log_title = ppp_tw_build_share_message( $post->ID, $name, false, false ); |
| 710 | 710 | |
@@ -722,11 +722,11 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | $log_entry = WP_Logging::insert_log( $log_data, $log_meta ); |
| 724 | 724 | |
| 725 | - if ( ! empty( $status->id_str ) ) { |
|
| 725 | + if ( ! empty($status->id_str)) { |
|
| 726 | 726 | $author_id = $post->post_author; |
| 727 | 727 | $author_rt = get_user_meta( $author_id, '_ppp_share_on_publish', true ); |
| 728 | 728 | |
| 729 | - if ( $author_rt ) { |
|
| 729 | + if ($author_rt) { |
|
| 730 | 730 | $twitter_user = new PPP_Twitter_User( $author_id ); |
| 731 | 731 | $twitter_user->retweet( $status->id_str ); |
| 732 | 732 | } |
@@ -747,8 +747,8 @@ discard block |
||
| 747 | 747 | ); |
| 748 | 748 | $other_rt = get_users( $args ); |
| 749 | 749 | |
| 750 | - if ( $other_rt ){ |
|
| 751 | - foreach ( $other_rt as $user ) { |
|
| 750 | + if ($other_rt) { |
|
| 751 | + foreach ($other_rt as $user) { |
|
| 752 | 752 | $twitter_user = new PPP_Twitter_User( $user->ID ); |
| 753 | 753 | $twitter_user->retweet( $status->id_str ); |
| 754 | 754 | } |
@@ -769,20 +769,20 @@ discard block |
||
| 769 | 769 | function ppp_tw_generate_timestamps( $times, $post_id ) { |
| 770 | 770 | $ppp_tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 771 | 771 | |
| 772 | - if ( empty( $ppp_tweets ) ) { |
|
| 772 | + if (empty($ppp_tweets)) { |
|
| 773 | 773 | $ppp_tweets = array(); |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - foreach ( $ppp_tweets as $key => $data ) { |
|
| 777 | - if ( ! array_filter( $data ) ) { |
|
| 776 | + foreach ($ppp_tweets as $key => $data) { |
|
| 777 | + if ( ! array_filter( $data )) { |
|
| 778 | 778 | continue; |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 782 | 782 | |
| 783 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 784 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_tw'; |
|
| 785 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_tw'; |
|
| 783 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 784 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_tw'; |
|
| 785 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_tw'; |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | } |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | $ret = false; |
| 804 | 804 | |
| 805 | - if ( ! empty( $ppp_share_settings['twitter']['cards_enabled'] ) ) { |
|
| 805 | + if ( ! empty($ppp_share_settings['twitter']['cards_enabled'])) { |
|
| 806 | 806 | $ret = true; |
| 807 | 807 | } |
| 808 | 808 | |
@@ -817,13 +817,13 @@ discard block |
||
| 817 | 817 | */ |
| 818 | 818 | function ppp_tw_card_meta() { |
| 819 | 819 | |
| 820 | - if ( ! is_single() || ! ppp_twitter_enabled() || ! ppp_tw_cards_enabled() ) { |
|
| 820 | + if ( ! is_single() || ! ppp_twitter_enabled() || ! ppp_tw_cards_enabled()) { |
|
| 821 | 821 | return; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | global $post, $ppp_options; |
| 825 | 825 | |
| 826 | - if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] ) ) { |
|
| 826 | + if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] )) { |
|
| 827 | 827 | return; |
| 828 | 828 | } |
| 829 | 829 | |
@@ -841,20 +841,20 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | $return = ''; |
| 843 | 843 | |
| 844 | - if ( ! is_single() || ! ppp_tw_cards_enabled() ) { |
|
| 844 | + if ( ! is_single() || ! ppp_tw_cards_enabled()) { |
|
| 845 | 845 | return $return; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | global $post, $ppp_social_settings; |
| 849 | 849 | |
| 850 | 850 | |
| 851 | - if ( empty( $post ) ) { |
|
| 851 | + if (empty($post)) { |
|
| 852 | 852 | return; |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | $elements = ppp_tw_default_meta_elements(); |
| 856 | - foreach ( $elements as $name => $content ) { |
|
| 857 | - $return .= '<meta name="' . $name . '" content="' . $content . '" />' . "\n"; |
|
| 856 | + foreach ($elements as $name => $content) { |
|
| 857 | + $return .= '<meta name="'.$name.'" content="'.$content.'" />'."\n"; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | return apply_filters( 'ppp_tw_card_meta', $return ); |
@@ -874,15 +874,15 @@ discard block |
||
| 874 | 874 | $elements = array(); |
| 875 | 875 | |
| 876 | 876 | $image_url = ppp_post_has_media( $post->ID, 'tw', true ); |
| 877 | - if ( $image_url ) { |
|
| 877 | + if ($image_url) { |
|
| 878 | 878 | $elements['twitter:card'] = 'summary_large_image'; |
| 879 | 879 | $elements['twitter:image:src'] = $image_url; |
| 880 | 880 | |
| 881 | 881 | $thumb_id = ppp_get_attachment_id_from_image_url( $image_url ); |
| 882 | - if ( ! empty( $thumb_id ) ) { |
|
| 882 | + if ( ! empty($thumb_id)) { |
|
| 883 | 883 | $alt_text = ppp_get_attachment_alt_text( $thumb_id ); |
| 884 | 884 | // When adding media via the WP Uploader, any 'alt text' supplied will be used as the accessible alt text. |
| 885 | - if ( ! empty( $alt_text ) ) { |
|
| 885 | + if ( ! empty($alt_text)) { |
|
| 886 | 886 | $elements['twitter:image:alt'] = esc_attr( $alt_text ); |
| 887 | 887 | } |
| 888 | 888 | } |
@@ -890,15 +890,15 @@ discard block |
||
| 890 | 890 | $elements['twitter:card'] = 'summary'; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - $elements['twitter:site'] = '@' . $ppp_social_settings['twitter']['user']->screen_name; |
|
| 893 | + $elements['twitter:site'] = '@'.$ppp_social_settings['twitter']['user']->screen_name; |
|
| 894 | 894 | $elements['twitter:title'] = esc_attr( strip_tags( $post->post_title ) ); |
| 895 | 895 | $elements['twitter:description'] = esc_attr( ppp_tw_get_card_description() ); |
| 896 | 896 | |
| 897 | 897 | $author_twitter_handle = get_user_meta( $post->post_author, 'twitter', true ); |
| 898 | - if ( ! empty( $author_twitter_handle ) ) { |
|
| 898 | + if ( ! empty($author_twitter_handle)) { |
|
| 899 | 899 | |
| 900 | - if ( strpos( $author_twitter_handle, '@' ) === false ) { |
|
| 901 | - $author_twitter_handle = '@' . $author_twitter_handle; |
|
| 900 | + if (strpos( $author_twitter_handle, '@' ) === false) { |
|
| 901 | + $author_twitter_handle = '@'.$author_twitter_handle; |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | $elements['twitter:creator'] = esc_attr( strip_tags( $author_twitter_handle ) ); |
@@ -917,13 +917,13 @@ discard block |
||
| 917 | 917 | function ppp_tw_get_card_description() { |
| 918 | 918 | global $post; |
| 919 | 919 | |
| 920 | - if ( ! is_single() || empty( $post ) ) { |
|
| 920 | + if ( ! is_single() || empty($post)) { |
|
| 921 | 921 | return false; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | $excerpt = $post->post_excerpt; |
| 925 | 925 | |
| 926 | - if ( empty( $excerpt ) ) { |
|
| 926 | + if (empty($excerpt)) { |
|
| 927 | 927 | $excerpt = ppp_tw_format_card_description( $post->post_content ); |
| 928 | 928 | } |
| 929 | 929 | |
@@ -941,10 +941,10 @@ discard block |
||
| 941 | 941 | $max_len = apply_filters( 'ppp_tw_cart_desc_length', 200 ); |
| 942 | 942 | $excerpt = strip_tags( $excerpt ); |
| 943 | 943 | |
| 944 | - if ( strlen( $excerpt ) > $max_len ) { |
|
| 944 | + if (strlen( $excerpt ) > $max_len) { |
|
| 945 | 945 | $excerpt_pre = substr( $excerpt, 0, $max_len ); |
| 946 | 946 | $last_space = strrpos( $excerpt_pre, ' ' ); |
| 947 | - $excerpt = substr( $excerpt_pre, 0, $last_space ) . '...'; |
|
| 947 | + $excerpt = substr( $excerpt_pre, 0, $last_space ).'...'; |
|
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | return $excerpt; |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | */ |
| 960 | 960 | function ppp_tw_add_contact_method( $user_contactmethods ) { |
| 961 | 961 | |
| 962 | - if ( ! isset( $user_contactmethods['twitter'] ) ) { |
|
| 962 | + if ( ! isset($user_contactmethods['twitter'])) { |
|
| 963 | 963 | $user_contactmethods['twitter'] = __( 'Twitter', 'ppp-txt' ); |
| 964 | 964 | } |
| 965 | 965 | // Returns the contact methods |
@@ -978,15 +978,15 @@ discard block |
||
| 978 | 978 | function ppp_tw_profile_settings( $user ) { |
| 979 | 979 | global $ppp_social_settings; |
| 980 | 980 | |
| 981 | - if ( $user->ID == get_current_user_id() && ! current_user_can( 'edit_posts' ) ) { |
|
| 981 | + if ($user->ID == get_current_user_id() && ! current_user_can( 'edit_posts' )) { |
|
| 982 | 982 | return; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - if ( $user->ID !== get_current_user_id() && ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 985 | + if ($user->ID !== get_current_user_id() && ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 986 | 986 | return; |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | - if ( ! isset( $ppp_social_settings['twitter'] ) || is_null( $ppp_social_settings['twitter'] ) ) { |
|
| 989 | + if ( ! isset($ppp_social_settings['twitter']) || is_null( $ppp_social_settings['twitter'] )) { |
|
| 990 | 990 | return; |
| 991 | 991 | } |
| 992 | 992 | |
@@ -1001,12 +1001,12 @@ discard block |
||
| 1001 | 1001 | $twitter = new PPP_Twitter_User( get_current_user_id() ); |
| 1002 | 1002 | $tw_user = get_user_meta( $user->ID, '_ppp_twitter_data', true ); |
| 1003 | 1003 | |
| 1004 | - if ( empty( $tw_user ) ) { |
|
| 1005 | - $tw_authurl = $twitter->get_auth_url( admin_url( 'user-edit.php?user_id=' . $user->ID ) ); |
|
| 1004 | + if (empty($tw_user)) { |
|
| 1005 | + $tw_authurl = $twitter->get_auth_url( admin_url( 'user-edit.php?user_id='.$user->ID ) ); |
|
| 1006 | 1006 | |
| 1007 | - $string = '<span id="tw-oob-auth-link-wrapper"><a id="tw-oob-auth-link" href="' . $tw_authurl . '" target="_blank"><img src="' . PPP_URL . '/includes/images/sign-in-with-twitter-gray.png" /></a></span>'; |
|
| 1008 | - $string .= '<span style="display:none;" id="tw-oob-pin-notice">' . __( 'You are being directed to Twitter to authenticate. When complete, return here and enter the PIN you were provided.', 'ppp-txt' ) . '</span>'; |
|
| 1009 | - $string .= '<span style="display:none;" id="tw-oob-pin-wrapper"><input type="text" size="10" placeholder="Enter your PIN" value="" id="tw-oob-pin" data-nonce="' . wp_create_nonce( 'ppp-tw-pin' ) . '" data-user="1" /> <a href="#" class="button-secondary tw-oob-pin-submit">' . __( 'Submit', 'ppp-txt' ) . '</a><span class="spinner"></span></span>'; |
|
| 1007 | + $string = '<span id="tw-oob-auth-link-wrapper"><a id="tw-oob-auth-link" href="'.$tw_authurl.'" target="_blank"><img src="'.PPP_URL.'/includes/images/sign-in-with-twitter-gray.png" /></a></span>'; |
|
| 1008 | + $string .= '<span style="display:none;" id="tw-oob-pin-notice">'.__( 'You are being directed to Twitter to authenticate. When complete, return here and enter the PIN you were provided.', 'ppp-txt' ).'</span>'; |
|
| 1009 | + $string .= '<span style="display:none;" id="tw-oob-pin-wrapper"><input type="text" size="10" placeholder="Enter your PIN" value="" id="tw-oob-pin" data-nonce="'.wp_create_nonce( 'ppp-tw-pin' ).'" data-user="1" /> <a href="#" class="button-secondary tw-oob-pin-submit">'.__( 'Submit', 'ppp-txt' ).'</a><span class="spinner"></span></span>'; |
|
| 1010 | 1010 | $string .= '<input type="hidden" name="ppp_user_auth" value="1" />'; |
| 1011 | 1011 | |
| 1012 | 1012 | echo $string; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | ?> |
| 1016 | 1016 | <p><strong><?php _e( 'Signed in as', 'ppp-txt' ); ?>: </strong><?php echo $tw_user['user']->screen_name; ?></p> |
| 1017 | 1017 | <p> |
| 1018 | - <a class="button-primary" href="<?php echo admin_url( 'user-edit.php?user_id=' . $user->ID . '&ppp_social_disconnect=true&ppp_network=twitter&user_id=' . $user->ID ); ?>" ><?php _e( 'Disconnect from Twitter', 'ppp-txt' ); ?></a> |
|
| 1018 | + <a class="button-primary" href="<?php echo admin_url( 'user-edit.php?user_id='.$user->ID.'&ppp_social_disconnect=true&ppp_network=twitter&user_id='.$user->ID ); ?>" ><?php _e( 'Disconnect from Twitter', 'ppp-txt' ); ?></a> |
|
| 1019 | 1019 | <a class="button-secondary" href="https://twitter.com/settings/applications" target="blank"><?php _e( 'Revoke Access via Twitter', 'ppp-txt' ); ?></a> |
| 1020 | 1020 | </p> |
| 1021 | 1021 | <?php |
@@ -1024,12 +1024,12 @@ discard block |
||
| 1024 | 1024 | </td> |
| 1025 | 1025 | </tr> |
| 1026 | 1026 | |
| 1027 | - <?php if ( $connected ) : ?> |
|
| 1027 | + <?php if ($connected) : ?> |
|
| 1028 | 1028 | <?php |
| 1029 | 1029 | $share_on_publish = get_user_meta( $user->ID, '_ppp_share_on_publish', true ); |
| 1030 | - $share_scheduled = get_user_meta( $user->ID, '_ppp_share_scheduled' , true ); |
|
| 1030 | + $share_scheduled = get_user_meta( $user->ID, '_ppp_share_scheduled', true ); |
|
| 1031 | 1031 | $share_others_on_publish = get_user_meta( $user->ID, '_ppp_share_others_on_publish', true ); |
| 1032 | - $share_others_scheduled = get_user_meta( $user->ID, '_ppp_share_others_scheduled' , true ); |
|
| 1032 | + $share_others_scheduled = get_user_meta( $user->ID, '_ppp_share_others_scheduled', true ); |
|
| 1033 | 1033 | ?> |
| 1034 | 1034 | <tr> |
| 1035 | 1035 | <th><?php _e( 'Sharing Options', 'ppp-txt' ); ?></th> |
@@ -1077,19 +1077,19 @@ discard block |
||
| 1077 | 1077 | function ppp_tw_save_profile( $user_id ) { |
| 1078 | 1078 | global $ppp_social_settings; |
| 1079 | 1079 | |
| 1080 | - if ( ! isset( $ppp_social_settings['twitter'] ) || is_null( $ppp_social_settings['twitter'] ) ) { |
|
| 1080 | + if ( ! isset($ppp_social_settings['twitter']) || is_null( $ppp_social_settings['twitter'] )) { |
|
| 1081 | 1081 | return; |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | - $share_on_publish = ! empty( $_POST['share_on_publish'] ) ? true : false; |
|
| 1085 | - $share_scheduled = ! empty( $_POST['share_scheduled'] ) ? true : false; |
|
| 1086 | - $share_others_on_publish = ! empty( $_POST['share_others_on_publish'] ) ? true : false; |
|
| 1087 | - $share_others_scheduled = ! empty( $_POST['share_others_scheduled'] ) ? true : false; |
|
| 1084 | + $share_on_publish = ! empty($_POST['share_on_publish']) ? true : false; |
|
| 1085 | + $share_scheduled = ! empty($_POST['share_scheduled']) ? true : false; |
|
| 1086 | + $share_others_on_publish = ! empty($_POST['share_others_on_publish']) ? true : false; |
|
| 1087 | + $share_others_scheduled = ! empty($_POST['share_others_scheduled']) ? true : false; |
|
| 1088 | 1088 | |
| 1089 | 1089 | update_user_meta( $user_id, '_ppp_share_on_publish', $share_on_publish ); |
| 1090 | - update_user_meta( $user_id, '_ppp_share_scheduled', $share_scheduled ); |
|
| 1090 | + update_user_meta( $user_id, '_ppp_share_scheduled', $share_scheduled ); |
|
| 1091 | 1091 | update_user_meta( $user_id, '_ppp_share_others_on_publish', $share_others_on_publish ); |
| 1092 | - update_user_meta( $user_id, '_ppp_share_others_scheduled', $share_others_scheduled ); |
|
| 1092 | + update_user_meta( $user_id, '_ppp_share_others_scheduled', $share_others_scheduled ); |
|
| 1093 | 1093 | |
| 1094 | 1094 | } |
| 1095 | 1095 | add_action( 'personal_options_update', 'ppp_tw_save_profile' ); |
@@ -1098,14 +1098,14 @@ discard block |
||
| 1098 | 1098 | function ppp_tw_calendar_on_publish_event( $events, $post_id ) { |
| 1099 | 1099 | $share_on_publish = get_post_meta( $post_id, '_ppp_share_on_publish', true ); |
| 1100 | 1100 | |
| 1101 | - if ( ! empty( $share_on_publish ) ) { |
|
| 1101 | + if ( ! empty($share_on_publish)) { |
|
| 1102 | 1102 | $share_text = get_post_meta( $post_id, '_ppp_share_on_publish_text', true ); |
| 1103 | 1103 | $events[] = array( |
| 1104 | - 'id' => $post_id . '-share-on-publish', |
|
| 1105 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_tw_generate_share_content( $post_id, null, false ), |
|
| 1106 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 1107 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 1108 | - 'className' => 'ppp-calendar-item-tw cal-post-' . $post_id, |
|
| 1104 | + 'id' => $post_id.'-share-on-publish', |
|
| 1105 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_tw_generate_share_content( $post_id, null, false ), |
|
| 1106 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 1107 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 1108 | + 'className' => 'ppp-calendar-item-tw cal-post-'.$post_id, |
|
| 1109 | 1109 | 'belongsTo' => $post_id, |
| 1110 | 1110 | ); |
| 1111 | 1111 | } |
@@ -1116,9 +1116,9 @@ discard block |
||
| 1116 | 1116 | |
| 1117 | 1117 | function ppp_tw_get_post_shares( $items, $post_id ) { |
| 1118 | 1118 | $tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 1119 | - if ( empty( $tweets ) ) { return $items; } |
|
| 1119 | + if (empty($tweets)) { return $items; } |
|
| 1120 | 1120 | |
| 1121 | - foreach ( $tweets as $key => $tweet ) { |
|
| 1121 | + foreach ($tweets as $key => $tweet) { |
|
| 1122 | 1122 | $items[] = array( 'id' => $key, 'service' => 'tw' ); |
| 1123 | 1123 | } |
| 1124 | 1124 | return $items; |
@@ -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,13 +1,13 @@ 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 | |
| 8 | 8 | function ppp_upgrade_notices() { |
| 9 | 9 | |
| 10 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'ppp-about' || $_GET['page'] == 'ppp-upgrades' ) ) { |
|
| 10 | + if (isset($_GET['page']) && ($_GET['page'] == 'ppp-about' || $_GET['page'] == 'ppp-upgrades')) { |
|
| 11 | 11 | return; // Don't show notices on the upgrades page |
| 12 | 12 | } |
| 13 | 13 | |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | // Sequential Orders was the first stepped upgrade, so check if we have a stalled upgrade |
| 17 | 17 | $resume_upgrade = ppp_maybe_resume_upgrade(); |
| 18 | - if ( ! empty( $resume_upgrade ) ) { |
|
| 18 | + if ( ! empty($resume_upgrade)) { |
|
| 19 | 19 | |
| 20 | 20 | $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
| 21 | 21 | printf( |
| 22 | - '<div class="error"><p>' . __( 'Post Promoter Pro needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
| 22 | + '<div class="error"><p>'.__( 'Post Promoter Pro needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'ppp-txt' ).'</p></div>', |
|
| 23 | 23 | esc_url( $resume_url ) |
| 24 | 24 | ); |
| 25 | 25 | |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | // Include all 'Stepped' upgrade process notices in this else statement, |
| 29 | 29 | // to avoid having a pending, and new upgrade suggested at the same time |
| 30 | 30 | |
| 31 | - if ( version_compare( $ppp_version, '2.2', '<' ) || ! ppp_has_upgrade_completed( 'upgrade_post_meta' ) ) { |
|
| 31 | + if (version_compare( $ppp_version, '2.2', '<' ) || ! ppp_has_upgrade_completed( 'upgrade_post_meta' )) { |
|
| 32 | 32 | printf( |
| 33 | - '<div class="notice notice-info"><p>' . __( 'Post Promoter Pro needs to upgrade share override data, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
| 33 | + '<div class="notice notice-info"><p>'.__( 'Post Promoter Pro needs to upgrade share override data, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ).'</p></div>', |
|
| 34 | 34 | esc_url( admin_url( 'index.php?page=ppp-upgrades&ppp-upgrade=upgrade_post_meta' ) ) |
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if ( version_compare( $ppp_version, '2.3.19', '<' ) || ! ppp_has_upgrade_completed( 'fix_scheduled_shares_2319' ) ) { |
|
| 38 | + if (version_compare( $ppp_version, '2.3.19', '<' ) || ! ppp_has_upgrade_completed( 'fix_scheduled_shares_2319' )) { |
|
| 39 | 39 | printf( |
| 40 | - '<div class="notice notice-info"><p>' . __( 'Post Promoter Pro needs to fix an issue with scheduled shares, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
| 40 | + '<div class="notice notice-info"><p>'.__( 'Post Promoter Pro needs to fix an issue with scheduled shares, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ).'</p></div>', |
|
| 41 | 41 | esc_url( admin_url( 'index.php?page=ppp-upgrades&ppp-upgrade=fix_scheduled_shares_2319' ) ) |
| 42 | 42 | ); |
| 43 | 43 | } |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | $upgrades_executed = false; |
| 60 | 60 | |
| 61 | 61 | // We don't have a version yet, so we need to run the upgrader |
| 62 | - if ( !$ppp_version && PPP_VERSION == '1.3' ) { |
|
| 62 | + if ( ! $ppp_version && PPP_VERSION == '1.3') { |
|
| 63 | 63 | ppp_v13_upgrades(); |
| 64 | 64 | $upgrades_executed = true; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( version_compare( $ppp_version, 2.1, '<' ) ) { |
|
| 67 | + if (version_compare( $ppp_version, 2.1, '<' )) { |
|
| 68 | 68 | ppp_v21_upgrades(); |
| 69 | 69 | $upgrades_executed = true; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if ( $upgrades_executed || version_compare( $ppp_version, PPP_VERSION, '<' ) ) { |
|
| 72 | + if ($upgrades_executed || version_compare( $ppp_version, PPP_VERSION, '<' )) { |
|
| 73 | 73 | set_transient( '_ppp_activation_redirect', '1', 60 ); |
| 74 | 74 | update_option( 'ppp_version', PPP_VERSION ); |
| 75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $doing_upgrade = get_option( 'ppp_doing_upgrade', false ); |
| 89 | 89 | |
| 90 | - if ( empty( $doing_upgrade ) ) { |
|
| 90 | + if (empty($doing_upgrade)) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -103,22 +103,22 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function ppp_v13_upgrades() { |
| 105 | 105 | global $ppp_share_settings; |
| 106 | - $uq_status = ( isset( $ppp_share_settings['ppp_unique_links'] ) && $ppp_share_settings['ppp_unique_links'] == '1' ) ? $ppp_share_settings['ppp_unique_links'] : 0; |
|
| 107 | - $ga_status = ( isset( $ppp_share_settings['ppp_ga_tags'] ) && $ppp_share_settings['ppp_ga_tags'] == '1' ) ? $ppp_share_settings['ppp_ga_tags'] : 0; |
|
| 106 | + $uq_status = (isset($ppp_share_settings['ppp_unique_links']) && $ppp_share_settings['ppp_unique_links'] == '1') ? $ppp_share_settings['ppp_unique_links'] : 0; |
|
| 107 | + $ga_status = (isset($ppp_share_settings['ppp_ga_tags']) && $ppp_share_settings['ppp_ga_tags'] == '1') ? $ppp_share_settings['ppp_ga_tags'] : 0; |
|
| 108 | 108 | |
| 109 | - if ( $uq_status ) { |
|
| 109 | + if ($uq_status) { |
|
| 110 | 110 | $ppp_share_settings['analytics'] = 'unique_links'; |
| 111 | - unset( $ppp_share_settings['ppp_unique_links'] ); |
|
| 112 | - } elseif ( $ga_status ) { |
|
| 111 | + unset($ppp_share_settings['ppp_unique_links']); |
|
| 112 | + } elseif ($ga_status) { |
|
| 113 | 113 | $ppp_share_settings['analytics'] = 'google_analytics'; |
| 114 | - unset( $ppp_share_settings['ppp_ga_tags'] ); |
|
| 114 | + unset($ppp_share_settings['ppp_ga_tags']); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | update_option( 'ppp_share_settings', $ppp_share_settings ); |
| 118 | 118 | |
| 119 | 119 | global $ppp_options; |
| 120 | 120 | $ppp_options['default_text'] = '{post_title}'; |
| 121 | - $ppp_options['days'] = array( 'day1' => 'on', 'day2' => 'on', 'day3' => 'on', 'day4' => 'on', 'day5' => 'on', 'day6' => 'on'); |
|
| 121 | + $ppp_options['days'] = array( 'day1' => 'on', 'day2' => 'on', 'day3' => 'on', 'day4' => 'on', 'day5' => 'on', 'day6' => 'on' ); |
|
| 122 | 122 | |
| 123 | 123 | update_option( 'ppp_options', $ppp_options ); |
| 124 | 124 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | function ppp_v22_postmeta_upgrade() { |
| 142 | 142 | |
| 143 | - if( ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 143 | + if ( ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 144 | 144 | wp_die( __( 'You do not have permission to do upgrades', 'ppp-txt' ), __( 'Error', 'ppp-txt' ), array( 'response' => 403 ) ); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | global $wpdb; |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
| 152 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
| 153 | 153 | $number = 25; |
| 154 | - $offset = $step == 1 ? 0 : ( $step - 1 ) * $number; |
|
| 154 | + $offset = $step == 1 ? 0 : ($step - 1) * $number; |
|
| 155 | 155 | |
| 156 | - if ( $step < 2 ) { |
|
| 156 | + if ($step < 2) { |
|
| 157 | 157 | // Check if we have any payments before moving on |
| 158 | 158 | $sql = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data' LIMIT 1"; |
| 159 | 159 | $has_overrides = $wpdb->get_col( $sql ); |
| 160 | 160 | |
| 161 | - if( empty( $has_overrides ) ) { |
|
| 161 | + if (empty($has_overrides)) { |
|
| 162 | 162 | // We had no payments, just complete |
| 163 | 163 | update_option( 'ppp_version', preg_replace( '/[^0-9.].*/', '', PPP_VERSION ) ); |
| 164 | 164 | ppp_set_upgrade_complete( 'upgrade_post_meta' ); |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
| 170 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
| 171 | 171 | |
| 172 | - if ( empty( $total ) || $total <= 1 ) { |
|
| 172 | + if (empty($total) || $total <= 1) { |
|
| 173 | 173 | $total_sql = "SELECT COUNT(post_id) as total FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data'"; |
| 174 | 174 | $results = $wpdb->get_row( $total_sql, 0 ); |
| 175 | 175 | |
@@ -179,48 +179,48 @@ discard block |
||
| 179 | 179 | $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data' ORDER BY meta_id DESC LIMIT %d,%d;", $offset, $number ) ); |
| 180 | 180 | $new_post_meta = array(); |
| 181 | 181 | |
| 182 | - if ( $results ) { |
|
| 183 | - foreach ( $results as $result ) { |
|
| 182 | + if ($results) { |
|
| 183 | + foreach ($results as $result) { |
|
| 184 | 184 | |
| 185 | 185 | $share_key = 1; |
| 186 | 186 | |
| 187 | 187 | $override_data = unserialize( $result->meta_value ); |
| 188 | 188 | |
| 189 | - foreach ( $override_data as $day => $values ) { |
|
| 189 | + foreach ($override_data as $day => $values) { |
|
| 190 | 190 | |
| 191 | - if ( ! isset( $values['enabled'] ) ) { |
|
| 191 | + if ( ! isset($values['enabled'])) { |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $text = ! empty( $values['text'] ) ? $values['text'] : ''; |
|
| 196 | - $time = ! empty( $values['time'] ) ? $values['time'] : '8:00am'; |
|
| 195 | + $text = ! empty($values['text']) ? $values['text'] : ''; |
|
| 196 | + $time = ! empty($values['time']) ? $values['time'] : '8:00am'; |
|
| 197 | 197 | |
| 198 | 198 | $post = get_post( $result->post_id ); |
| 199 | 199 | $days_ahead = substr( $day, -1 ); |
| 200 | - $date = date( 'm\/d\/Y', strtotime( $post->post_date . '+' . $days_ahead . ' days' ) ); |
|
| 200 | + $date = date( 'm\/d\/Y', strtotime( $post->post_date.'+'.$days_ahead.' days' ) ); |
|
| 201 | 201 | $image = ''; |
| 202 | 202 | $attachment_id = ''; |
| 203 | 203 | |
| 204 | - if ( ! empty( $values['use_image'] ) ) { |
|
| 204 | + if ( ! empty($values['use_image'])) { |
|
| 205 | 205 | $thumb_id = get_post_thumbnail_id( $result->post_id ); |
| 206 | 206 | $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-tw-share-image', true ); |
| 207 | 207 | |
| 208 | - if ( isset( $thumb_url[0] ) && ! empty( $thumb_url[0] ) && !strpos( $thumb_url[0], 'wp-includes/images/media/default.png' ) ) { |
|
| 208 | + if (isset($thumb_url[0]) && ! empty($thumb_url[0]) && ! strpos( $thumb_url[0], 'wp-includes/images/media/default.png' )) { |
|
| 209 | 209 | $thumb_url = $thumb_url[0]; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( ! empty( $thumb_id ) && ! empty( $thumb_url ) ) { |
|
| 212 | + if ( ! empty($thumb_id) && ! empty($thumb_url)) { |
|
| 213 | 213 | $attachment_id = $thumb_id; |
| 214 | 214 | $image = $thumb_url; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $new_post_meta[$share_key] = array ( |
|
| 218 | + $new_post_meta[$share_key] = array( |
|
| 219 | 219 | 'date' => $date, |
| 220 | 220 | 'time' => $time, |
| 221 | 221 | 'text' => $text, |
| 222 | - 'image' => ! empty( $image ) ? $image : '', |
|
| 223 | - 'attachment_id' => ! empty( $attachment_id ) ? $attachment_id : '' |
|
| 222 | + 'image' => ! empty($image) ? $image : '', |
|
| 223 | + 'attachment_id' => ! empty($attachment_id) ? $attachment_id : '' |
|
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | 226 | $share_key++; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | function ppp_fix_scheduled_shares_2319() { |
| 257 | 257 | |
| 258 | - if( ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 258 | + if ( ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 259 | 259 | wp_die( __( 'You do not have permission to do upgrades', 'ppp-txt' ), __( 'Error', 'ppp-txt' ), array( 'response' => 403 ) ); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -264,16 +264,16 @@ discard block |
||
| 264 | 264 | global $wpdb; |
| 265 | 265 | |
| 266 | 266 | |
| 267 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
| 267 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
| 268 | 268 | $number = 25; |
| 269 | - $offset = $step == 1 ? 0 : ( $step - 1 ) * $number; |
|
| 269 | + $offset = $step == 1 ? 0 : ($step - 1) * $number; |
|
| 270 | 270 | |
| 271 | - if ( $step < 2 ) { |
|
| 271 | + if ($step < 2) { |
|
| 272 | 272 | // Check if we have any payments before moving on |
| 273 | 273 | $sql = "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' ) LIMIT 1"; |
| 274 | 274 | $has_shares = $wpdb->get_col( $sql ); |
| 275 | 275 | |
| 276 | - if( empty( $has_shares ) ) { |
|
| 276 | + if (empty($has_shares)) { |
|
| 277 | 277 | // We had no payments, just complete |
| 278 | 278 | update_option( 'ppp_version', preg_replace( '/[^0-9.].*/', '', PPP_VERSION ) ); |
| 279 | 279 | ppp_set_upgrade_complete( 'fix_scheduled_shares_2319' ); |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
| 285 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
| 286 | 286 | |
| 287 | - if ( empty( $total ) || $total <= 1 ) { |
|
| 287 | + if (empty($total) || $total <= 1) { |
|
| 288 | 288 | $total_sql = "SELECT COUNT( DISTINCT post_id ) as total FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' )"; |
| 289 | 289 | $results = $wpdb->get_row( $total_sql, 0 ); |
| 290 | 290 | |
@@ -293,19 +293,19 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' ) ORDER BY post_id DESC LIMIT %d,%d;", $offset, $number ) ); |
| 295 | 295 | |
| 296 | - if ( $results ) { |
|
| 296 | + if ($results) { |
|
| 297 | 297 | $allowed_post_types = ppp_allowed_post_types(); |
| 298 | 298 | |
| 299 | - foreach ( $results as $result ) { |
|
| 299 | + foreach ($results as $result) { |
|
| 300 | 300 | $post = get_post( $result->post_id ); |
| 301 | - if ( ! in_array( $post->post_type, $allowed_post_types ) ) { |
|
| 301 | + if ( ! in_array( $post->post_type, $allowed_post_types )) { |
|
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | ppp_remove_scheduled_shares( $result->post_id ); |
| 306 | 306 | $timestamps = ppp_get_timestamps( $result->post_id ); |
| 307 | 307 | |
| 308 | - foreach ( $timestamps as $timestamp => $name ) { |
|
| 308 | + foreach ($timestamps as $timestamp => $name) { |
|
| 309 | 309 | $timestamp = substr( $timestamp, 0, strlen( $timestamp ) - 3 ); |
| 310 | 310 | wp_schedule_single_event( $timestamp, 'ppp_share_post_event', array( $result->post_id, $name ) ); |
| 311 | 311 | } |
@@ -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,70 +55,70 @@ 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 | parse_str( wp_remote_retrieve_body( wp_remote_post( $url ) ), $result ); |
| 77 | 77 | |
| 78 | - $access_token = ! empty( $result['access_token'] ) ? $result['access_token'] : false; |
|
| 79 | - $expires_in = ! empty( $result['expires'] ) ? $result['expires'] : false; |
|
| 78 | + $access_token = ! empty($result['access_token']) ? $result['access_token'] : false; |
|
| 79 | + $expires_in = ! empty($result['expires']) ? $result['expires'] : false; |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! empty( $access_token ) ) { |
|
| 83 | + if ( ! empty($access_token)) { |
|
| 84 | 84 | global $ppp_social_settings; |
| 85 | 85 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 86 | 86 | |
| 87 | 87 | //check facebook class is loaded or not |
| 88 | - if( !$facebook ) { |
|
| 88 | + if ( ! $facebook) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $data = new stdClass(); |
| 93 | 93 | $data->access_token = $access_token; |
| 94 | 94 | |
| 95 | - $expires_in = empty( $expires_in ) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 95 | + $expires_in = empty($expires_in) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 96 | 96 | $data->expires_on = current_time( 'timestamp' ) + $expires_in; |
| 97 | 97 | |
| 98 | - update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in/1.25 ) ); |
|
| 98 | + update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in / 1.25 ) ); |
|
| 99 | 99 | |
| 100 | 100 | // Now that we have a valid auth, get some user info |
| 101 | 101 | $user_info = $this->ppp_get_fb_user( $data->access_token ); |
| 102 | 102 | |
| 103 | - if ( $user_info ) { |
|
| 104 | - if ( !empty( $user_info->name ) ) { |
|
| 103 | + if ($user_info) { |
|
| 104 | + if ( ! empty($user_info->name)) { |
|
| 105 | 105 | $data->name = $user_info->name; |
| 106 | 106 | } else { |
| 107 | - $parsed_name = $user_info->first_name . ' ' . $user_info->last_name; |
|
| 107 | + $parsed_name = $user_info->first_name.' '.$user_info->last_name; |
|
| 108 | 108 | $data->name = $parsed_name; |
| 109 | 109 | } |
| 110 | 110 | $data->userid = $user_info->id; |
| 111 | 111 | $data->avatar = $this->ppp_fb_get_profile_picture( array( 'type' => 'square' ), $data->userid ); |
| 112 | 112 | |
| 113 | - if ( ! empty( $ppp_social_settings['facebook']->page ) ) { |
|
| 113 | + if ( ! empty($ppp_social_settings['facebook']->page)) { |
|
| 114 | 114 | $current_page = $ppp_social_settings['facebook']->page; |
| 115 | 115 | $page_parts = explode( '|', $current_page ); |
| 116 | 116 | |
| 117 | 117 | $pages = $this->ppp_get_fb_user_pages( $data->access_token ); |
| 118 | 118 | |
| 119 | - foreach ( $pages as $page ) { |
|
| 120 | - if ( $page->id == $page_parts[2] ) { |
|
| 121 | - $data->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 119 | + foreach ($pages as $page) { |
|
| 120 | + if ($page->id == $page_parts[2]) { |
|
| 121 | + $data->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 122 | 122 | continue; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | - $url = remove_query_arg( array( 'fb_access_token' , 'expires_in' ) ); |
|
| 134 | + $url = remove_query_arg( array( 'fb_access_token', 'expires_in' ) ); |
|
| 135 | 135 | wp_redirect( $url ); |
| 136 | 136 | die(); |
| 137 | 137 | } |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | $facebook = $this->ppp_load_facebook(); |
| 150 | 150 | |
| 151 | 151 | //check facebook class is exis or not |
| 152 | - if( !$facebook ) { |
|
| 152 | + if ( ! $facebook) { |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | global $ppp_social_settings; |
| 157 | - $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token=' . $access_token ) ) ); |
|
| 157 | + $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token='.$access_token ) ) ); |
|
| 158 | 158 | |
| 159 | 159 | return $user; |
| 160 | 160 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $facebook = $this->ppp_load_facebook(); |
| 167 | 167 | |
| 168 | 168 | // check facebook cleast is exists or not |
| 169 | - if( !$facebook ) { |
|
| 169 | + if ( ! $facebook) { |
|
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -174,20 +174,20 @@ discard block |
||
| 174 | 174 | $facebook_settings = $ppp_social_settings['facebook']; |
| 175 | 175 | |
| 176 | 176 | |
| 177 | - if ( ! isset( $facebook_settings->available_pages ) || |
|
| 178 | - ! isset( $facebook_settings->pages_last_updated ) || |
|
| 179 | - $facebook_settings->pages_last_updated < current_time( 'timestamp' ) ) { |
|
| 177 | + if ( ! isset($facebook_settings->available_pages) || |
|
| 178 | + ! isset($facebook_settings->pages_last_updated) || |
|
| 179 | + $facebook_settings->pages_last_updated < current_time( 'timestamp' )) { |
|
| 180 | 180 | |
| 181 | - $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token=' . $access_token ) ) ); |
|
| 181 | + $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token='.$access_token ) ) ); |
|
| 182 | 182 | $pages = array(); |
| 183 | 183 | |
| 184 | - if ( !empty( $all_pages ) ) { |
|
| 185 | - foreach ( $all_pages->data as $page ) { |
|
| 186 | - if ( in_array( 'CREATE_CONTENT', $page->tasks ) ) { |
|
| 184 | + if ( ! empty($all_pages)) { |
|
| 185 | + foreach ($all_pages->data as $page) { |
|
| 186 | + if (in_array( 'CREATE_CONTENT', $page->tasks )) { |
|
| 187 | 187 | $pages[] = $page; |
| 188 | 188 | |
| 189 | - if ( ! empty( $ppp_social_settings['facebook']->page ) && strpos( $ppp_social_settings['facebook']->page, $page->id ) ) { |
|
| 190 | - $ppp_social_settings['facebook']->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 189 | + if ( ! empty($ppp_social_settings['facebook']->page) && strpos( $ppp_social_settings['facebook']->page, $page->id )) { |
|
| 190 | + $ppp_social_settings['facebook']->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $pages = (object) $pages; |
| 200 | 200 | $ppp_social_settings['facebook']->available_pages = $pages; |
| 201 | - $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + ( HOUR_IN_SECONDS / 4 ); |
|
| 201 | + $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + (HOUR_IN_SECONDS / 4); |
|
| 202 | 202 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 203 | 203 | } else { |
| 204 | 204 | $pages = $facebook_settings->available_pages; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $facebook = $this->ppp_load_facebook(); |
| 221 | 221 | |
| 222 | 222 | //check facebook class is exis or not |
| 223 | - if( !$facebook ) { |
|
| 223 | + if ( ! $facebook) { |
|
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -231,27 +231,27 @@ discard block |
||
| 231 | 231 | * Get auth url for facebook |
| 232 | 232 | * |
| 233 | 233 | */ |
| 234 | - public function ppp_get_facebook_auth_url ( $return_url ) { |
|
| 234 | + public function ppp_get_facebook_auth_url( $return_url ) { |
|
| 235 | 235 | |
| 236 | 236 | //load facebook class |
| 237 | 237 | $facebook = $this->ppp_load_facebook(); |
| 238 | 238 | |
| 239 | 239 | //check facebook class is exis or not |
| 240 | - if( !$facebook ) { |
|
| 240 | + if ( ! $facebook) { |
|
| 241 | 241 | return false; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if ( ! PPP_LOCAL_TOKENS ) { |
|
| 244 | + if ( ! PPP_LOCAL_TOKENS) { |
|
| 245 | 245 | $base_url = 'https://postpromoterpro.com/?ppp-social-auth'; |
| 246 | - $url = $base_url . '&ppp-service=fb&ppp-license-key=' . trim( get_option( '_ppp_license_key' ) ); |
|
| 246 | + $url = $base_url.'&ppp-service=fb&ppp-license-key='.trim( get_option( '_ppp_license_key' ) ); |
|
| 247 | 247 | $url .= '&nocache'; |
| 248 | - $url .= '&return_url=' . esc_url( $return_url ); |
|
| 248 | + $url .= '&return_url='.esc_url( $return_url ); |
|
| 249 | 249 | } else { |
| 250 | 250 | $url = 'https://graph.facebook.com/oauth/authorize?'; |
| 251 | - $url .= 'client_id=' . PPP_FB_APP_ID; |
|
| 251 | + $url .= 'client_id='.PPP_FB_APP_ID; |
|
| 252 | 252 | $url .= '&scope=public_profile,publish_actions,manage_pages,publish_pages'; |
| 253 | 253 | $url .= '&state=ppp-local-keys-fb'; |
| 254 | - $url .= '&redirect_uri=' . esc_url( $return_url ) . '&nocache'; |
|
| 254 | + $url .= '&redirect_uri='.esc_url( $return_url ).'&nocache'; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return $url; |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | * Getting the the profile image of the connected Facebook user. |
| 264 | 264 | * |
| 265 | 265 | */ |
| 266 | - public function ppp_fb_get_profile_picture( $args=array(), $user ) { |
|
| 266 | + public function ppp_fb_get_profile_picture( $args = array(), $user ) { |
|
| 267 | 267 | |
| 268 | - if( isset( $args['type'] ) && !empty( $args['type'] ) ) { |
|
| 268 | + if (isset($args['type']) && ! empty($args['type'])) { |
|
| 269 | 269 | $type = $args['type']; |
| 270 | 270 | } else { |
| 271 | 271 | $type = 'large'; |
| 272 | 272 | } |
| 273 | - $url = 'https://graph.facebook.com/' . $user . '/picture?type=' . $type; |
|
| 273 | + $url = 'https://graph.facebook.com/'.$user.'/picture?type='.$type; |
|
| 274 | 274 | return $url; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | global $ppp_social_settings; |
| 279 | 279 | $facebook_settings = $ppp_social_settings['facebook']; |
| 280 | 280 | |
| 281 | - if ( !isset( $facebook_settings->page ) || strtolower( $facebook_settings->page ) === 'me' ) { |
|
| 281 | + if ( ! isset($facebook_settings->page) || strtolower( $facebook_settings->page ) === 'me') { |
|
| 282 | 282 | $account = 'me'; |
| 283 | 283 | $access_token = $facebook_settings->access_token; |
| 284 | 284 | } else { |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $access_token = $page_info[1]; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $url = 'https://graph.facebook.com/' . $account . '/feed?access_token=' . $access_token; |
|
| 290 | + $url = 'https://graph.facebook.com/'.$account.'/feed?access_token='.$access_token; |
|
| 291 | 291 | $args = array( 'link' => $link, 'message' => $message ); |
| 292 | - if ( !empty( $image ) ) { |
|
| 292 | + if ( ! empty($image)) { |
|
| 293 | 293 | $args['picture'] = $image; |
| 294 | 294 | } |
| 295 | 295 | $results = json_decode( wp_remote_retrieve_body( wp_remote_post( $url, array( 'body' => $args ) ) ) ); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | public function ppp_get_data_from_url( $url ) { |
| 309 | 309 | |
| 310 | 310 | //Use wp_remote_post and wp_remote_get |
| 311 | - $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 311 | + $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 312 | 312 | |
| 313 | 313 | return $data; |
| 314 | 314 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function clear_og_cache( $post_id ) { |
| 322 | 322 | $post_url = get_permalink( $post_id ); |
| 323 | - if ( ! empty( $post_url ) ) { |
|
| 323 | + if ( ! empty($post_url)) { |
|
| 324 | 324 | $args = array( 'body' => array( 'id' => $post_url, 'scrape' => true ) ); |
| 325 | 325 | $response = json_decode( wp_remote_retrieve_body( wp_remote_post( 'https://graph.facebook.com/', $args ) ) ); |
| 326 | 326 | } |
@@ -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 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $date = sanitize_text_field( $_POST['date'] ); |
| 11 | 11 | $time = sanitize_text_field( $_POST['time'] ); |
| 12 | 12 | |
| 13 | - $offset = (int) -( get_option( 'gmt_offset' ) ); // Make the timestamp in the users' timezone, b/c that makes more sense |
|
| 13 | + $offset = (int) -(get_option( 'gmt_offset' )); // Make the timestamp in the users' timezone, b/c that makes more sense |
|
| 14 | 14 | |
| 15 | 15 | $share_time = explode( ':', $time ); |
| 16 | 16 | |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | $minutes = (int) substr( $share_time[1], 0, 2 ); |
| 19 | 19 | $ampm = strtolower( substr( $share_time[1], -2 ) ); |
| 20 | 20 | |
| 21 | - if ( $ampm == 'pm' && $hours != 12 ) { |
|
| 21 | + if ($ampm == 'pm' && $hours != 12) { |
|
| 22 | 22 | $hours = $hours + 12; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( $ampm == 'am' && $hours == 12 ) { |
|
| 25 | + if ($ampm == 'am' && $hours == 12) { |
|
| 26 | 26 | $hours = 00; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | add_action( 'wp_ajax_ppp_has_schedule_conflict', 'ppp_check_for_schedule_conflict' ); |
| 40 | 40 | |
| 41 | -add_action( 'wp_ajax_ppp_local_url_notice_dismiss', function() { |
|
| 41 | +add_action( 'wp_ajax_ppp_local_url_notice_dismiss', function () { |
|
| 42 | 42 | $error_message = __( 'There was an error dismissing the local URL notice. Please try again.', 'ppp-txt' ); |
| 43 | - if( ! wp_verify_nonce( $_POST['nonce'], 'ppp_local_url_notice_nonce' ) || ! current_user_can( post_promoter_pro()->get_manage_capability() ) ) { |
|
| 43 | + if ( ! wp_verify_nonce( $_POST['nonce'], 'ppp_local_url_notice_nonce' ) || ! current_user_can( post_promoter_pro()->get_manage_capability() )) { |
|
| 44 | 44 | wp_send_json_error( array( |
| 45 | 45 | 'error' => $error_message, |
| 46 | 46 | ) ); |
| 47 | 47 | } |
| 48 | 48 | $updated = update_option( 'ppp_local_url_notice_dismissed', true ); |
| 49 | - if( $updated === false ) { |
|
| 49 | + if ($updated === false) { |
|
| 50 | 50 | wp_send_json_error( array( |
| 51 | 51 | 'error' => $error_message, |
| 52 | 52 | ) ); |
@@ -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 | |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | * @return void |
| 11 | 11 | */ |
| 12 | 12 | function ppp_maybe_start_session() { |
| 13 | - if( !class_exists( 'TwitterOAuth' ) ) { |
|
| 14 | - require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' ); |
|
| 13 | + if ( ! class_exists( 'TwitterOAuth' )) { |
|
| 14 | + require_once (PPP_PATH.'/includes/libs/twitter/twitteroauth.php'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $ret = false; |
| 18 | - if ( ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) && session_status() == PHP_SESSION_NONE && ! headers_sent() ) { |
|
| 18 | + if ((is_admin() || (defined( 'DOING_CRON' ) && DOING_CRON)) && session_status() == PHP_SESSION_NONE && ! headers_sent()) { |
|
| 19 | 19 | $ret = session_start(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | global $ppp_share_settings; |
| 31 | 31 | $result = false; |
| 32 | 32 | |
| 33 | - if ( isset( $ppp_share_settings['analytics'] ) && $ppp_share_settings['analytics'] !== 'none' ) { |
|
| 34 | - $result = true; |
|
| 33 | + if (isset($ppp_share_settings['analytics']) && $ppp_share_settings['analytics'] !== 'none') { |
|
| 34 | + $result = true; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return apply_filters( 'ppp_is_link_tracking_enabled', $result ); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | function ppp_is_shortener_enabled() { |
| 73 | 73 | global $ppp_share_settings; |
| 74 | 74 | |
| 75 | - return ( isset( $ppp_share_settings['shortener'] ) && !empty( $ppp_share_settings['shortener'] ) && $ppp_share_settings != '-1' ); |
|
| 75 | + return (isset($ppp_share_settings['shortener']) && ! empty($ppp_share_settings['shortener']) && $ppp_share_settings != '-1'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | $post_types = get_post_types( $post_type_args, NULL, 'and' ); |
| 105 | 105 | |
| 106 | 106 | $unsupported_post_types = array( 'wp_log', 'attachment' ); |
| 107 | - foreach ( $unsupported_post_types as $unsupported_post_type ) { |
|
| 108 | - if ( array_key_exists( $unsupported_post_type, $post_types ) ) { |
|
| 109 | - unset( $post_types[ $unsupported_post_type ] ); |
|
| 107 | + foreach ($unsupported_post_types as $unsupported_post_type) { |
|
| 108 | + if (array_key_exists( $unsupported_post_type, $post_types )) { |
|
| 109 | + unset($post_types[$unsupported_post_type]); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | function ppp_should_save( $post_id, $post ) { |
| 135 | 135 | $ret = true; |
| 136 | 136 | |
| 137 | - if ( empty( $_POST ) ) { |
|
| 137 | + if (empty($_POST)) { |
|
| 138 | 138 | $ret = false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( wp_is_post_revision( $post_id ) ) { |
|
| 141 | + if (wp_is_post_revision( $post_id )) { |
|
| 142 | 142 | $ret = false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | global $ppp_options; |
| 146 | - if ( !isset( $ppp_options['post_types'] ) || !is_array( $ppp_options['post_types'] ) || !array_key_exists( $post->post_type, $ppp_options['post_types'] ) ) { |
|
| 146 | + if ( ! isset($ppp_options['post_types']) || ! is_array( $ppp_options['post_types'] ) || ! array_key_exists( $post->post_type, $ppp_options['post_types'] )) { |
|
| 147 | 147 | $ret = false; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | function ppp_set_uploads_dir() { |
| 160 | 160 | $upload_path = ppp_get_upload_path(); |
| 161 | 161 | |
| 162 | - if ( false === get_transient( 'ppp_check_protection_files' ) ) { |
|
| 162 | + if (false === get_transient( 'ppp_check_protection_files' )) { |
|
| 163 | 163 | |
| 164 | 164 | // Make sure the /ppp folder is created |
| 165 | 165 | wp_mkdir_p( $upload_path ); |
@@ -168,22 +168,22 @@ discard block |
||
| 168 | 168 | $rules = "Options -Indexes\n"; |
| 169 | 169 | $rules .= "deny from all\n"; |
| 170 | 170 | |
| 171 | - $htaccess_exists = file_exists( $upload_path . '/.htaccess' ); |
|
| 171 | + $htaccess_exists = file_exists( $upload_path.'/.htaccess' ); |
|
| 172 | 172 | |
| 173 | - if ( $htaccess_exists ) { |
|
| 174 | - $contents = @file_get_contents( $upload_path . '/.htaccess' ); |
|
| 175 | - if ( $contents !== $rules || ! $contents ) { |
|
| 173 | + if ($htaccess_exists) { |
|
| 174 | + $contents = @file_get_contents( $upload_path.'/.htaccess' ); |
|
| 175 | + if ($contents !== $rules || ! $contents) { |
|
| 176 | 176 | // Update the .htaccess rules if they don't match |
| 177 | - @file_put_contents( $upload_path . '/.htaccess', $rules ); |
|
| 177 | + @file_put_contents( $upload_path.'/.htaccess', $rules ); |
|
| 178 | 178 | } |
| 179 | - } elseif( wp_is_writable( $upload_path ) ) { |
|
| 179 | + } elseif (wp_is_writable( $upload_path )) { |
|
| 180 | 180 | // Create the file if it doesn't exist |
| 181 | - @file_put_contents( $upload_path . '/.htaccess', $rules ); |
|
| 181 | + @file_put_contents( $upload_path.'/.htaccess', $rules ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Top level blank index.php |
| 185 | - if ( ! file_exists( $upload_path . '/index.php' ) && wp_is_writable( $upload_path ) ) { |
|
| 186 | - @file_put_contents( $upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.' ); |
|
| 185 | + if ( ! file_exists( $upload_path.'/index.php' ) && wp_is_writable( $upload_path )) { |
|
| 186 | + @file_put_contents( $upload_path.'/index.php', '<?php'.PHP_EOL.'// Silence is golden.' ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Check for the files once per day |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function ppp_get_upload_path() { |
| 202 | 202 | $wp_upload_dir = wp_upload_dir(); |
| 203 | - return $wp_upload_dir['basedir'] . '/ppp'; |
|
| 203 | + return $wp_upload_dir['basedir'].'/ppp'; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | $completed_upgrades = get_option( 'ppp_completed_upgrades' ); |
| 215 | 215 | |
| 216 | - if ( false === $completed_upgrades ) { |
|
| 216 | + if (false === $completed_upgrades) { |
|
| 217 | 217 | $completed_upgrades = array(); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function ppp_has_upgrade_completed( $upgrade_action = '' ) { |
| 232 | 232 | |
| 233 | - if ( empty( $upgrade_action ) ) { |
|
| 233 | + if (empty($upgrade_action)) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function ppp_set_upgrade_complete( $upgrade_action = '' ) { |
| 251 | 251 | |
| 252 | - if ( empty( $upgrade_action ) ) { |
|
| 252 | + if (empty($upgrade_action)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -274,48 +274,48 @@ discard block |
||
| 274 | 274 | $url = strtolower( trim( get_home_url( '/' ) ) ); |
| 275 | 275 | |
| 276 | 276 | // Need to get the host...so let's add the scheme so we can use parse_url |
| 277 | - if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) { |
|
| 278 | - $url = 'http://' . $url; |
|
| 277 | + if (false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' )) { |
|
| 278 | + $url = 'http://'.$url; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | $url_parts = parse_url( $url ); |
| 282 | - $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false; |
|
| 282 | + $host = ! empty($url_parts['host']) ? $url_parts['host'] : false; |
|
| 283 | 283 | |
| 284 | - if ( ! empty( $url ) && ! empty( $host ) ) { |
|
| 284 | + if ( ! empty($url) && ! empty($host)) { |
|
| 285 | 285 | |
| 286 | - if ( false !== ip2long( $host ) ) { |
|
| 287 | - if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { |
|
| 286 | + if (false !== ip2long( $host )) { |
|
| 287 | + if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE )) { |
|
| 288 | 288 | $is_local_url = true; |
| 289 | 289 | } |
| 290 | - } else if ( 'localhost' === $host ) { |
|
| 290 | + } else if ('localhost' === $host) { |
|
| 291 | 291 | $is_local_url = true; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $check_tlds = apply_filters( 'ppp_validate_tlds', true ); |
| 295 | - if ( $check_tlds ) { |
|
| 295 | + if ($check_tlds) { |
|
| 296 | 296 | $tlds_to_check = apply_filters( 'ppp_url_tlds', array( |
| 297 | 297 | '.dev', '.local', '.test' |
| 298 | 298 | ) ); |
| 299 | 299 | |
| 300 | - foreach ( $tlds_to_check as $tld ) { |
|
| 301 | - if ( false !== strpos( $host, $tld ) ) { |
|
| 300 | + foreach ($tlds_to_check as $tld) { |
|
| 301 | + if (false !== strpos( $host, $tld )) { |
|
| 302 | 302 | $is_local_url = true; |
| 303 | 303 | continue; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( substr_count( $host, '.' ) > 1 ) { |
|
| 308 | + if (substr_count( $host, '.' ) > 1) { |
|
| 309 | 309 | $subdomains_to_check = apply_filters( 'ppp_url_subdomains', array( |
| 310 | 310 | 'dev.', '*.staging.', |
| 311 | 311 | ) ); |
| 312 | 312 | |
| 313 | - foreach ( $subdomains_to_check as $subdomain ) { |
|
| 313 | + foreach ($subdomains_to_check as $subdomain) { |
|
| 314 | 314 | |
| 315 | 315 | $subdomain = str_replace( '.', '(.)', $subdomain ); |
| 316 | 316 | $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain ); |
| 317 | 317 | |
| 318 | - if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) { |
|
| 318 | + if (preg_match( '/^('.$subdomain.')/', $host )) { |
|
| 319 | 319 | $is_local_url = true; |
| 320 | 320 | continue; |
| 321 | 321 | } |
@@ -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_linkedin_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['linkedin'] ) && !empty( $ppp_social_settings['linkedin'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['linkedin']) && ! empty($ppp_social_settings['linkedin'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function ppp_li_account_list_name( $string = '' ) { |
| 62 | 62 | |
| 63 | - if ( ppp_linkedin_enabled() ) { |
|
| 63 | + if (ppp_linkedin_enabled()) { |
|
| 64 | 64 | global $ppp_social_settings; |
| 65 | - $string .= $ppp_social_settings['linkedin']->firstName . ' ' . $ppp_social_settings['linkedin']->lastName; |
|
| 65 | + $string .= $ppp_social_settings['linkedin']->firstName.' '.$ppp_social_settings['linkedin']->lastName; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return $string; |
@@ -77,22 +77,22 @@ discard block |
||
| 77 | 77 | function ppp_li_account_list_actions( $string = '' ) { |
| 78 | 78 | global $ppp_linkedin_oauth, $ppp_social_settings; |
| 79 | 79 | |
| 80 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 80 | + if ( ! ppp_linkedin_enabled()) { |
|
| 81 | 81 | $li_authurl = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 82 | 82 | |
| 83 | - $string .= '<a class="button-primary" href="' . $li_authurl . '">' . __( 'Connect to Linkedin', 'ppp-txt' ) . '</a>'; |
|
| 83 | + $string .= '<a class="button-primary" href="'.$li_authurl.'">'.__( 'Connect to Linkedin', 'ppp-txt' ).'</a>'; |
|
| 84 | 84 | } else { |
| 85 | - $string .= '<a class="button-primary" href="' . admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=linkedin' ) . '" >' . __( 'Disconnect from Linkedin', 'ppp-txt' ) . '</a> '; |
|
| 85 | + $string .= '<a class="button-primary" href="'.admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=linkedin' ).'" >'.__( 'Disconnect from Linkedin', 'ppp-txt' ).'</a> '; |
|
| 86 | 86 | |
| 87 | 87 | $refresh_date = (int) get_option( '_ppp_linkedin_refresh', true ); |
| 88 | 88 | |
| 89 | 89 | |
| 90 | - if ( defined( 'LINKEDIN_KEY' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 90 | + if (defined( 'LINKEDIN_KEY' ) && current_time( 'timestamp' ) > $refresh_date) { |
|
| 91 | 91 | $token = $ppp_social_settings['linkedin']->access_token; |
| 92 | 92 | $url = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 93 | - $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 93 | + $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 94 | 94 | |
| 95 | - $string .= '<a class="button-secondary" href="' . $refresh_url . '" >' . __( 'Re-Authorize Linkedin', 'ppp-txt' ) . '</a> '; |
|
| 95 | + $string .= '<a class="button-secondary" href="'.$refresh_url.'" >'.__( 'Re-Authorize Linkedin', 'ppp-txt' ).'</a> '; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | * @return string The HTML for the LinkedIn Extras column |
| 107 | 107 | */ |
| 108 | 108 | function ppp_li_account_list_extras( $string ) { |
| 109 | - if ( ppp_linkedin_enabled() ) { |
|
| 109 | + if (ppp_linkedin_enabled()) { |
|
| 110 | 110 | global $ppp_social_settings, $ppp_options; |
| 111 | - if ( ! empty( $ppp_options['enable_debug'] ) ) { |
|
| 112 | - $days_left = absint( round( ( $ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 113 | - $refresh_in = absint( round( ( get_option( '_ppp_linkedin_refresh' ) - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 111 | + if ( ! empty($ppp_options['enable_debug'])) { |
|
| 112 | + $days_left = absint( round( ($ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 113 | + $refresh_in = absint( round( (get_option( '_ppp_linkedin_refresh' ) - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 114 | 114 | |
| 115 | - $string .= '<br />' . sprintf( __( 'Token expires in %s days' , 'ppp-txt' ), $days_left ); |
|
| 116 | - $string .= '<br />' . sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 115 | + $string .= '<br />'.sprintf( __( 'Token expires in %s days', 'ppp-txt' ), $days_left ); |
|
| 116 | + $string .= '<br />'.sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | function ppp_capture_linkedin_oauth() { |
| 130 | 130 | $should_capture = false; |
| 131 | 131 | |
| 132 | - if ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false ) { |
|
| 132 | + if (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false) { |
|
| 133 | 133 | // Local config |
| 134 | 134 | $should_capture = true; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( isset( $_REQUEST['li_access_token'] ) ) { |
|
| 137 | + if (isset($_REQUEST['li_access_token'])) { |
|
| 138 | 138 | // Returning from remote config |
| 139 | 139 | $should_capture = true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( $should_capture && ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ppp-social-settings' ) ) { |
|
| 142 | + if ($should_capture && (isset($_REQUEST['page']) && $_REQUEST['page'] == 'ppp-social-settings')) { |
|
| 143 | 143 | global $ppp_linkedin_oauth; |
| 144 | 144 | $ppp_linkedin_oauth->ppp_initialize_linkedin(); |
| 145 | 145 | wp_redirect( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | function ppp_disconnect_linkedin() { |
| 156 | 156 | global $ppp_social_settings; |
| 157 | 157 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 158 | - if ( isset( $ppp_social_settings['linkedin'] ) ) { |
|
| 159 | - unset( $ppp_social_settings['linkedin'] ); |
|
| 158 | + if (isset($ppp_social_settings['linkedin'])) { |
|
| 159 | + unset($ppp_social_settings['linkedin']); |
|
| 160 | 160 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 161 | 161 | delete_option( '_ppp_linkedin_refresh' ); |
| 162 | 162 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function ppp_li_execute_refresh() { |
| 184 | 184 | |
| 185 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 185 | + if ( ! ppp_linkedin_enabled()) { |
|
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $refresh_date = (int) get_option( '_ppp_linkedin_refresh', true ); |
| 190 | 190 | |
| 191 | - if ( ( empty( $_GET['page' ] ) || $_GET['page'] !== 'ppp-social-settings' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 191 | + if ((empty($_GET['page']) || $_GET['page'] !== 'ppp-social-settings') && current_time( 'timestamp' ) > $refresh_date) { |
|
| 192 | 192 | add_action( 'admin_notices', 'ppp_linkedin_refresh_notice' ); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function ppp_linkedin_refresh_notice() { |
| 202 | 202 | |
| 203 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 203 | + if ( ! ppp_linkedin_enabled()) { |
|
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $has_dismissed = get_transient( 'ppp-dismiss-refresh-li' . get_current_user_id() ); |
|
| 208 | - if ( false !== $has_dismissed ) { |
|
| 207 | + $has_dismissed = get_transient( 'ppp-dismiss-refresh-li'.get_current_user_id() ); |
|
| 208 | + if (false !== $has_dismissed) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | $token = $ppp_social_settings['linkedin']->access_token; |
| 218 | 218 | $url = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 219 | - $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 219 | + $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 220 | 220 | |
| 221 | - $days_left = (int) round( ( $ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ); |
|
| 221 | + $days_left = (int) round( ($ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ); |
|
| 222 | 222 | ?> |
| 223 | 223 | <div class="notice notice-warning is-dismissible" data-service="li"> |
| 224 | - <?php if ( $days_left > 0 ): ?> |
|
| 224 | + <?php if ($days_left > 0): ?> |
|
| 225 | 225 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your LinkedIn authentication expires in %d days. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $days_left, $url ); ?></p> |
| 226 | - <?php elseif ( $days_left < 1 ): ?> |
|
| 226 | + <?php elseif ($days_left < 1): ?> |
|
| 227 | 227 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your LinkedIn authentication has expired. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $url ); ?></p> |
| 228 | 228 | <?php endif; ?> |
| 229 | 229 | </div> |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function ppp_li_dismiss_notice() { |
| 240 | 240 | |
| 241 | - $nag = sanitize_key( $_POST[ 'nag' ] ); |
|
| 241 | + $nag = sanitize_key( $_POST['nag'] ); |
|
| 242 | 242 | |
| 243 | - if ( $nag === $_POST[ 'nag' ] ) { |
|
| 244 | - set_transient( $nag . get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 243 | + if ($nag === $_POST['nag']) { |
|
| 244 | + set_transient( $nag.get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | 256 | function ppp_set_li_token_constants( $social_tokens ) { |
| 257 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'linkedin' ) ) { |
|
| 257 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'linkedin' )) { |
|
| 258 | 258 | define( 'LINKEDIN_KEY', $social_tokens->linkedin->api_key ); |
| 259 | 259 | define( 'LINKEDIN_SECRET', $social_tokens->linkedin->secret_key ); |
| 260 | 260 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | function ppp_li_share( $title, $description, $link, $media ) { |
| 273 | 273 | global $ppp_linkedin_oauth; |
| 274 | - $args = array ( |
|
| 274 | + $args = array( |
|
| 275 | 275 | 'title' => ppp_entities_and_slashes( $title ), |
| 276 | 276 | 'description' => ppp_entities_and_slashes( $description ), |
| 277 | 277 | 'submitted-url' => $link, |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function ppp_li_add_meta_tab( $tabs ) { |
| 314 | 314 | global $ppp_social_settings; |
| 315 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 315 | + if ( ! ppp_linkedin_enabled()) { |
|
| 316 | 316 | return $tabs; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function ppp_li_register_metabox_content( $content ) { |
| 331 | 331 | global $ppp_social_settings; |
| 332 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 332 | + if ( ! ppp_linkedin_enabled()) { |
|
| 333 | 333 | return $content; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | function ppp_li_add_metabox_content( $post ) { |
| 369 | 369 | global $ppp_options, $ppp_share_settings; |
| 370 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 370 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 371 | 371 | |
| 372 | 372 | $ppp_li_share_on_publish = get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
| 373 | 373 | $ppp_share_on_publish_title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title', true ); |
@@ -377,9 +377,9 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | $show_share_on_publish = false; |
| 379 | 379 | |
| 380 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['linkedin'] ) ? false : true; |
|
| 380 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['linkedin']) ? false : true; |
|
| 381 | 381 | |
| 382 | - if ( $ppp_li_share_on_publish == '1' || ( $ppp_li_share_on_publish == '' && $share_by_default ) ) { |
|
| 382 | + if ($ppp_li_share_on_publish == '1' || ($ppp_li_share_on_publish == '' && $share_by_default)) { |
|
| 383 | 383 | $show_share_on_publish = true; |
| 384 | 384 | } |
| 385 | 385 | ?> |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | <div class="ppp-post-override-wrap"> |
| 388 | 388 | <p><h3><?php _e( 'Share on LinkedIn', 'ppp-txt' ); ?></h3></p> |
| 389 | 389 | <p> |
| 390 | - <?php $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; ?> |
|
| 390 | + <?php $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; ?> |
|
| 391 | 391 | <label for="ppp_li_share_on_publish"><?php _e( 'Share this post on LinkedIn…', 'ppp-txt' ); ?></label> |
| 392 | 392 | <select name="_ppp_li_share_on_publish" id="ppp_li_share_on_publish" class="ppp-toggle-share-on-publish"> |
| 393 | - <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> |
|
| 394 | - <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> |
|
| 393 | + <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> |
|
| 394 | + <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> |
|
| 395 | 395 | <option value="0" <?php selected( false, $show_share_on_publish, true ); ?>><?php _e( 'After this post is published', 'ppp-txt' ); ?></option> |
| 396 | 396 | </select> |
| 397 | 397 | </p> |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | <th style="width: 10px;"></th> |
| 408 | 408 | </tr> |
| 409 | 409 | </thead> |
| 410 | - <tbody id="li-share-on-publish" class="ppp-share-on-publish" <?php if ( false === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 410 | + <tbody id="li-share-on-publish" class="ppp-share-on-publish" <?php if (false === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 411 | 411 | <?php |
| 412 | 412 | $args = array( |
| 413 | 413 | 'text' => $ppp_share_on_publish_title, |
@@ -419,19 +419,19 @@ discard block |
||
| 419 | 419 | ppp_render_li_share_on_publish_row( $args ); |
| 420 | 420 | ?> |
| 421 | 421 | </tbody> |
| 422 | - <tbody id="li-schedule-share" class="ppp-schedule-share" <?php if ( true === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 422 | + <tbody id="li-schedule-share" class="ppp-schedule-share" <?php if (true === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 423 | 423 | <?php $shares = get_post_meta( $post->ID, '_ppp_li_shares', true ); ?> |
| 424 | - <?php if ( ! empty( $shares ) ) : ?> |
|
| 424 | + <?php if ( ! empty($shares)) : ?> |
|
| 425 | 425 | |
| 426 | - <?php foreach ( $shares as $key => $value ) : |
|
| 427 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 428 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 429 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 430 | - $desc = isset( $value['desc'] ) ? $value['desc'] : ''; |
|
| 431 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 432 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 426 | + <?php foreach ($shares as $key => $value) : |
|
| 427 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 428 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 429 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 430 | + $desc = isset($value['desc']) ? $value['desc'] : ''; |
|
| 431 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 432 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 433 | 433 | |
| 434 | - $args = apply_filters( 'ppp_fb_row_args', compact( 'date','time','text', 'desc', 'image','attachment_id' ), $value ); |
|
| 434 | + $args = apply_filters( 'ppp_fb_row_args', compact( 'date', 'time', 'text', 'desc', 'image', 'attachment_id' ), $value ); |
|
| 435 | 435 | ?> |
| 436 | 436 | |
| 437 | 437 | <?php ppp_render_li_share_row( $key, $args ); ?> |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | function ppp_render_li_share_on_publish_row( $args = array() ) { |
| 468 | 468 | global $post; |
| 469 | 469 | $readonly = $post->post_status !== 'publish' ? '' : 'readonly="readonly" '; |
| 470 | - $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; |
|
| 470 | + $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; |
|
| 471 | 471 | ?> |
| 472 | 472 | <tr class="ppp-li-wrapper ppp-repeatable-row on-publish-row"> |
| 473 | 473 | <td colspan="2" class="ppp-on-plublish-date-column"> |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | <tr> |
| 496 | 496 | <td colspan="2"></td> |
| 497 | 497 | <td colspan="3"> |
| 498 | - <textarea <?php if ( $disabled ): ?>readonly<?php endif; ?> name="_ppp_li_share_on_publish_desc" placeholder="<?php _e( 'Link Description', 'ppp-txt' ); ?>"><?php echo esc_attr( $args['desc'] ); ?></textarea> |
|
| 498 | + <textarea <?php if ($disabled): ?>readonly<?php endif; ?> name="_ppp_li_share_on_publish_desc" placeholder="<?php _e( 'Link Description', 'ppp-txt' ); ?>"><?php echo esc_attr( $args['desc'] ); ?></textarea> |
|
| 499 | 499 | </td> |
| 500 | 500 | </tr> |
| 501 | 501 | <?php |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 517 | 517 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 518 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 519 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 518 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 519 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 520 | 520 | ?> |
| 521 | 521 | <tr class="ppp-li-wrapper ppp-repeatable-row ppp-repeatable-linkedin scheduled-row" data-key="<?php echo esc_attr( $key ); ?>"> |
| 522 | 522 | <td> |
@@ -567,26 +567,26 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | function ppp_li_save_post_meta_boxes( $post_id, $post ) { |
| 569 | 569 | |
| 570 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 570 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 571 | 571 | return; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $ppp_li_share_on_publish = ( isset( $_REQUEST['_ppp_li_share_on_publish'] ) ) ? $_REQUEST['_ppp_li_share_on_publish'] : '-1'; |
|
| 575 | - $ppp_share_on_publish_title = ( isset( $_REQUEST['_ppp_li_share_on_publish_title'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_title'] : ''; |
|
| 576 | - $ppp_share_on_publish_desc = ( isset( $_REQUEST['_ppp_li_share_on_publish_desc'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_desc'] : ''; |
|
| 577 | - $ppp_share_on_publish_image_url = ( isset( $_REQUEST['_ppp_li_share_on_publish_image_url'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 578 | - $ppp_share_on_publish_attachment_id = ( isset( $_REQUEST['_ppp_li_share_on_publish_attachment_id'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_attachment_id'] : ''; |
|
| 574 | + $ppp_li_share_on_publish = (isset($_REQUEST['_ppp_li_share_on_publish'])) ? $_REQUEST['_ppp_li_share_on_publish'] : '-1'; |
|
| 575 | + $ppp_share_on_publish_title = (isset($_REQUEST['_ppp_li_share_on_publish_title'])) ? $_REQUEST['_ppp_li_share_on_publish_title'] : ''; |
|
| 576 | + $ppp_share_on_publish_desc = (isset($_REQUEST['_ppp_li_share_on_publish_desc'])) ? $_REQUEST['_ppp_li_share_on_publish_desc'] : ''; |
|
| 577 | + $ppp_share_on_publish_image_url = (isset($_REQUEST['_ppp_li_share_on_publish_image_url'])) ? $_REQUEST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 578 | + $ppp_share_on_publish_attachment_id = (isset($_REQUEST['_ppp_li_share_on_publish_attachment_id'])) ? $_REQUEST['_ppp_li_share_on_publish_attachment_id'] : ''; |
|
| 579 | 579 | |
| 580 | - update_post_meta( $post_id, '_ppp_li_share_on_publish', $ppp_li_share_on_publish ); |
|
| 581 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 582 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_desc', $ppp_share_on_publish_desc ); |
|
| 583 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 580 | + update_post_meta( $post_id, '_ppp_li_share_on_publish', $ppp_li_share_on_publish ); |
|
| 581 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 582 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_desc', $ppp_share_on_publish_desc ); |
|
| 583 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 584 | 584 | update_post_meta( $post_id, '_ppp_li_share_on_publish_attachment_id', $ppp_share_on_publish_attachment_id ); |
| 585 | 585 | |
| 586 | - $li_data = ( isset( $_REQUEST['_ppp_li_shares'] ) && empty( $ppp_li_share_on_publish ) ) ? $_REQUEST['_ppp_li_shares'] : array(); |
|
| 587 | - foreach ( $li_data as $index => $share ) { |
|
| 588 | - $li_data[ $index ]['text'] = sanitize_text_field( $share['text'] ); |
|
| 589 | - $li_data[ $index ]['desc'] = sanitize_text_field( $share['desc'] ); |
|
| 586 | + $li_data = (isset($_REQUEST['_ppp_li_shares']) && empty($ppp_li_share_on_publish)) ? $_REQUEST['_ppp_li_shares'] : array(); |
|
| 587 | + foreach ($li_data as $index => $share) { |
|
| 588 | + $li_data[$index]['text'] = sanitize_text_field( $share['text'] ); |
|
| 589 | + $li_data[$index]['desc'] = sanitize_text_field( $share['desc'] ); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | update_post_meta( $post_id, '_ppp_li_shares', $li_data ); |
@@ -602,10 +602,10 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | function ppp_li_share_on_publish( $new_status, $old_status, $post ) { |
| 604 | 604 | global $ppp_options; |
| 605 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
|
| 606 | - $from_post = isset( $_POST['_ppp_li_share_on_publish'] ) ? $_POST['_ppp_li_share_on_publish']: '0'; |
|
| 605 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
|
| 606 | + $from_post = isset($_POST['_ppp_li_share_on_publish']) ? $_POST['_ppp_li_share_on_publish'] : '0'; |
|
| 607 | 607 | |
| 608 | - if ( '1' != $from_meta && '1' != $from_post ) { |
|
| 608 | + if ('1' != $from_meta && '1' != $from_post) { |
|
| 609 | 609 | return; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -618,30 +618,30 @@ discard block |
||
| 618 | 618 | $image_url = ''; |
| 619 | 619 | |
| 620 | 620 | // Determine if we're seeing the share on publish in meta or $_POST |
| 621 | - if ( $from_meta && ! $from_post ) { |
|
| 622 | - $title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title' , true ); |
|
| 623 | - $desc = get_post_meta( $post->ID, '_ppp_li_share_on_publish_desc' , true ); |
|
| 621 | + if ($from_meta && ! $from_post) { |
|
| 622 | + $title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title', true ); |
|
| 623 | + $desc = get_post_meta( $post->ID, '_ppp_li_share_on_publish_desc', true ); |
|
| 624 | 624 | $attachment_id = get_post_meta( $post->ID, '_ppp_li_share_on_publish_attachment_id', true ); |
| 625 | - $image_url = get_post_meta( $post->ID, '_ppp_li_share_on_publish_image_url' , true ); |
|
| 625 | + $image_url = get_post_meta( $post->ID, '_ppp_li_share_on_publish_image_url', true ); |
|
| 626 | 626 | } else { |
| 627 | - $title = isset( $_POST['_ppp_li_share_on_publish_title'] ) ? $_POST['_ppp_li_share_on_publish_title'] : ''; |
|
| 628 | - $desc = isset( $_POST['_ppp_li_share_on_publish_desc'] ) ? $_POST['_ppp_li_share_on_publish_desc'] : false; |
|
| 629 | - $attachment_id = isset( $_POST['_ppp_li_share_on_publish_attachment_id'] ) ? $_POST['_ppp_li_share_on_publish_attachment_id'] : 0; |
|
| 630 | - $image_url = isset( $_POST['_ppp_li_share_on_publish_image_url'] ) ? $_POST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 627 | + $title = isset($_POST['_ppp_li_share_on_publish_title']) ? $_POST['_ppp_li_share_on_publish_title'] : ''; |
|
| 628 | + $desc = isset($_POST['_ppp_li_share_on_publish_desc']) ? $_POST['_ppp_li_share_on_publish_desc'] : false; |
|
| 629 | + $attachment_id = isset($_POST['_ppp_li_share_on_publish_attachment_id']) ? $_POST['_ppp_li_share_on_publish_attachment_id'] : 0; |
|
| 630 | + $image_url = isset($_POST['_ppp_li_share_on_publish_image_url']) ? $_POST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $thumbnail = ''; |
| 634 | - if ( empty( $attachment_id ) && ! empty( $image_url ) ) { |
|
| 634 | + if (empty($attachment_id) && ! empty($image_url)) { |
|
| 635 | 635 | $thumbnail = $image_url; |
| 636 | 636 | } else { |
| 637 | 637 | $thumbnail = ppp_post_has_media( $post->ID, 'li', true, $attachment_id ); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - $name = 'sharedate_0_' . $post->ID . '_li'; |
|
| 640 | + $name = 'sharedate_0_'.$post->ID.'_li'; |
|
| 641 | 641 | |
| 642 | - $default_title = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 642 | + $default_title = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 643 | 643 | // If an override was found, use it, otherwise try the default text content |
| 644 | - if ( empty( $title ) && empty( $default_title ) ) { |
|
| 644 | + if (empty($title) && empty($default_title)) { |
|
| 645 | 645 | $title = get_the_title( $post->ID ); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | * @param string $name The name of the Cron |
| 677 | 677 | * @return void |
| 678 | 678 | */ |
| 679 | -function ppp_li_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 679 | +function ppp_li_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 680 | 680 | global $ppp_options; |
| 681 | 681 | |
| 682 | 682 | $link = ppp_generate_link( $post_id, $name ); |
| 683 | 683 | |
| 684 | 684 | $post_meta = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 685 | - $this_share = $post_meta[ $index ]; |
|
| 686 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 685 | + $this_share = $post_meta[$index]; |
|
| 686 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 687 | 687 | |
| 688 | 688 | $share_message = ppp_li_build_share_message( $post_id, $name ); |
| 689 | 689 | |
| 690 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 690 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 691 | 691 | $media = $this_share['image']; |
| 692 | 692 | } else { |
| 693 | 693 | $use_media = ppp_li_use_media( $post_id, $index ); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | * @return bool Whether or not this tweet should contain a media post |
| 725 | 725 | */ |
| 726 | 726 | function ppp_li_use_media( $post_id, $index ) { |
| 727 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 727 | + if (empty($post_id) || empty($index)) { |
|
| 728 | 728 | return false; |
| 729 | 729 | } |
| 730 | 730 | |
@@ -757,22 +757,22 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | function ppp_li_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 759 | 759 | global $ppp_options; |
| 760 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 760 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 761 | 761 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 762 | 762 | |
| 763 | - if ( ! empty( $li_shares ) ) { |
|
| 763 | + if ( ! empty($li_shares)) { |
|
| 764 | 764 | $name_array = explode( '_', $name ); |
| 765 | 765 | $index = $name_array[1]; |
| 766 | - if ( isset( $li_shares[ $index ] ) ) { |
|
| 767 | - $share_content = $li_shares[ $index ]['text']; |
|
| 766 | + if (isset($li_shares[$index])) { |
|
| 767 | + $share_content = $li_shares[$index]['text']; |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | // If an override was found, use it, otherwise try the default text content |
| 772 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 772 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 773 | 773 | |
| 774 | 774 | // If the content is still empty, just use the post title |
| 775 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 775 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 776 | 776 | |
| 777 | 777 | return apply_filters( 'ppp_share_content_li', $share_content, array( 'post_id' => $post_id ) ); |
| 778 | 778 | } |
@@ -789,8 +789,8 @@ discard block |
||
| 789 | 789 | $description = ''; |
| 790 | 790 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 791 | 791 | |
| 792 | - if ( ! empty( $li_shares[ $index ] ) ) { |
|
| 793 | - $description = ! empty( $li_shares[ $index ]['desc'] ) ? $li_shares[ $index ]['desc'] : ''; |
|
| 792 | + if ( ! empty($li_shares[$index])) { |
|
| 793 | + $description = ! empty($li_shares[$index]['desc']) ? $li_shares[$index]['desc'] : ''; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | return $description; |
@@ -807,20 +807,20 @@ discard block |
||
| 807 | 807 | function ppp_li_generate_timestamps( $times, $post_id ) { |
| 808 | 808 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 809 | 809 | |
| 810 | - if ( empty( $li_shares ) ) { |
|
| 810 | + if (empty($li_shares)) { |
|
| 811 | 811 | $li_shares = array(); |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - foreach ( $li_shares as $key => $data ) { |
|
| 815 | - if ( ! array_filter( $data ) ) { |
|
| 814 | + foreach ($li_shares as $key => $data) { |
|
| 815 | + if ( ! array_filter( $data )) { |
|
| 816 | 816 | continue; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 820 | 820 | |
| 821 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 822 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_li'; |
|
| 823 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_li'; |
|
| 821 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 822 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_li'; |
|
| 823 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_li'; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | } |
@@ -840,14 +840,14 @@ discard block |
||
| 840 | 840 | function ppp_li_calendar_on_publish_event( $events, $post_id ) { |
| 841 | 841 | $share_on_publish = get_post_meta( $post_id, '_ppp_li_share_on_publish', true ); |
| 842 | 842 | |
| 843 | - if ( ! empty( $share_on_publish ) ) { |
|
| 843 | + if ( ! empty($share_on_publish)) { |
|
| 844 | 844 | $share_text = get_post_meta( $post_id, '_ppp_li_share_on_publish_title', true ); |
| 845 | 845 | $events[] = array( |
| 846 | - 'id' => $post_id . '-share-on-publish', |
|
| 847 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_li_generate_share_content( $post_id, null, false ), |
|
| 848 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 849 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 850 | - 'className' => 'ppp-calendar-item-li cal-post-' . $post_id, |
|
| 846 | + 'id' => $post_id.'-share-on-publish', |
|
| 847 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_li_generate_share_content( $post_id, null, false ), |
|
| 848 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 849 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 850 | + 'className' => 'ppp-calendar-item-li cal-post-'.$post_id, |
|
| 851 | 851 | 'belongsTo' => $post_id, |
| 852 | 852 | ); |
| 853 | 853 | } |
@@ -858,9 +858,9 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | function ppp_li_get_post_shares( $items, $post_id ) { |
| 860 | 860 | $shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 861 | - if ( empty( $shares ) ) { return $items; } |
|
| 861 | + if (empty($shares)) { return $items; } |
|
| 862 | 862 | |
| 863 | - foreach ( $shares as $key => $share ) { |
|
| 863 | + foreach ($shares as $key => $share) { |
|
| 864 | 864 | $items[] = array( 'id' => $key, 'service' => 'li' ); |
| 865 | 865 | } |
| 866 | 866 | return $items; |
@@ -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 linkedin functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Linkedin' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Linkedin' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Linkedin { |
| 17 | 17 | |
| 18 | 18 | var $linkedin; |
| 19 | 19 | |
| 20 | - public function __construct(){ |
|
| 20 | + public function __construct() { |
|
| 21 | 21 | ppp_maybe_start_session(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -28,24 +28,24 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function ppp_load_linkedin() { |
| 30 | 30 | |
| 31 | - if( !class_exists( 'LinkedIn' ) ) { |
|
| 32 | - require_once ( PPP_PATH . '/includes/libs/linkedin/linkedin_oAuth.php' ); |
|
| 31 | + if ( ! class_exists( 'LinkedIn' )) { |
|
| 32 | + require_once (PPP_PATH.'/includes/libs/linkedin/linkedin_oAuth.php'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | ppp_set_social_tokens(); |
| 37 | 37 | |
| 38 | - if ( ! defined( 'LINKEDIN_KEY' ) || ! defined( 'LINKEDIN_SECRET' ) ) { |
|
| 38 | + if ( ! defined( 'LINKEDIN_KEY' ) || ! defined( 'LINKEDIN_SECRET' )) { |
|
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | global $ppp_social_settings; |
| 43 | 43 | $config = array( 'appKey' => LINKEDIN_KEY, 'appSecret' => LINKEDIN_SECRET ); |
| 44 | - if ( isset( $ppp_social_settings['linkedin']->access_token ) ) { |
|
| 44 | + if (isset($ppp_social_settings['linkedin']->access_token)) { |
|
| 45 | 45 | $config['accessToken'] = $ppp_social_settings['linkedin']->access_token; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( !$this->linkedin ) { |
|
| 48 | + if ( ! $this->linkedin) { |
|
| 49 | 49 | $this->linkedin = new LinkedIn( $config ); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -60,36 +60,36 @@ discard block |
||
| 60 | 60 | $linkedin = $this->ppp_load_linkedin(); |
| 61 | 61 | |
| 62 | 62 | //when user is going to logged in and verified successfully session will create |
| 63 | - if ( isset( $_REQUEST['li_access_token'] ) && isset( $_REQUEST['expires_in'] ) ) { |
|
| 63 | + if (isset($_REQUEST['li_access_token']) && isset($_REQUEST['expires_in'])) { |
|
| 64 | 64 | |
| 65 | 65 | $access_token = $_REQUEST['li_access_token']; |
| 66 | 66 | $expires_in = $_REQUEST['expires_in']; |
| 67 | 67 | |
| 68 | - } elseif ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false ) { |
|
| 69 | - $access_code = isset( $_GET['code'] ) ? $_GET['code'] : false; |
|
| 68 | + } elseif (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false) { |
|
| 69 | + $access_code = isset($_GET['code']) ? $_GET['code'] : false; |
|
| 70 | 70 | |
| 71 | - if ( empty( $access_code ) ) { |
|
| 71 | + if (empty($access_code)) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $params = 'grant_type=authorization_code&client_id=' . LINKEDIN_KEY; |
|
| 76 | - $params .= '&client_secret=' . LINKEDIN_SECRET; |
|
| 77 | - $params .= '&code=' . $access_code; |
|
| 78 | - $params .= '&redirect_uri=' . admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 79 | - $url = 'https://www.linkedin.com/uas/oauth2/accessToken?' . $params; |
|
| 75 | + $params = 'grant_type=authorization_code&client_id='.LINKEDIN_KEY; |
|
| 76 | + $params .= '&client_secret='.LINKEDIN_SECRET; |
|
| 77 | + $params .= '&code='.$access_code; |
|
| 78 | + $params .= '&redirect_uri='.admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 79 | + $url = 'https://www.linkedin.com/uas/oauth2/accessToken?'.$params; |
|
| 80 | 80 | $response = json_decode( wp_remote_retrieve_body( wp_remote_post( $url ) ) ); |
| 81 | 81 | |
| 82 | - $access_token = isset( $response->access_token ) ? $response->access_token : false; |
|
| 83 | - $expires_in = isset( $response->expires_in ) ? $response->expires_in : false; |
|
| 82 | + $access_token = isset($response->access_token) ? $response->access_token : false; |
|
| 83 | + $expires_in = isset($response->expires_in) ? $response->expires_in : false; |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( ! empty( $access_token ) && ! empty( $expires_in ) ) { |
|
| 87 | + if ( ! empty($access_token) && ! empty($expires_in)) { |
|
| 88 | 88 | global $ppp_social_settings; |
| 89 | 89 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 90 | 90 | |
| 91 | 91 | //check linkedin class is loaded or not |
| 92 | - if( !$linkedin ) { |
|
| 92 | + if ( ! $linkedin) { |
|
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $expires_in = (int) $expires_in; |
| 100 | 100 | $data->expires_on = current_time( 'timestamp' ) + $expires_in; |
| 101 | 101 | |
| 102 | - update_option( '_ppp_linkedin_refresh', current_time( 'timestamp' ) + round( $expires_in/1.25 ) ); |
|
| 102 | + update_option( '_ppp_linkedin_refresh', current_time( 'timestamp' ) + round( $expires_in / 1.25 ) ); |
|
| 103 | 103 | |
| 104 | 104 | $ppp_social_settings['linkedin'] = $data; |
| 105 | 105 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 114 | 114 | |
| 115 | - $url = remove_query_arg( array( 'li_access_token' , 'expires_in' ) ); |
|
| 115 | + $url = remove_query_arg( array( 'li_access_token', 'expires_in' ) ); |
|
| 116 | 116 | wp_redirect( $url ); |
| 117 | 117 | die(); |
| 118 | 118 | } |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | * Get auth url for linkedin |
| 123 | 123 | * |
| 124 | 124 | */ |
| 125 | - public function ppp_get_linkedin_auth_url ( $return_url ) { |
|
| 125 | + public function ppp_get_linkedin_auth_url( $return_url ) { |
|
| 126 | 126 | |
| 127 | - if ( ! PPP_LOCAL_TOKENS ) { |
|
| 127 | + if ( ! PPP_LOCAL_TOKENS) { |
|
| 128 | 128 | $base_url = 'https://postpromoterpro.com/?ppp-social-auth'; |
| 129 | - $url = $base_url . '&ppp-service=li&ppp-license-key=' . trim( get_option( '_ppp_license_key' ) ); |
|
| 129 | + $url = $base_url.'&ppp-service=li&ppp-license-key='.trim( get_option( '_ppp_license_key' ) ); |
|
| 130 | 130 | $url .= '&nocache'; |
| 131 | - $url .= '&return_url=' . esc_url( $return_url ); |
|
| 131 | + $url .= '&return_url='.esc_url( $return_url ); |
|
| 132 | 132 | } else { |
| 133 | 133 | $url = 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code'; |
| 134 | - $url .= '&client_id=' . LINKEDIN_KEY; |
|
| 134 | + $url .= '&client_id='.LINKEDIN_KEY; |
|
| 135 | 135 | $url .= '&scope=w_share%20r_basicprofile'; |
| 136 | 136 | $url .= '&state=ppp-local-keys-li'; |
| 137 | - $url .= '&redirect_uri=' . $return_url; |
|
| 137 | + $url .= '&redirect_uri='.$return_url; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return $url; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * Share somethign on linkedin |
| 145 | 145 | */ |
| 146 | 146 | public function ppp_linkedin_share( $args ) { |
| 147 | - if ( empty( $args ) ) { |
|
| 147 | + if (empty($args)) { |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | 'description' => $args['description'], |
| 164 | 164 | 'title' => $args['title'], |
| 165 | 165 | ), |
| 166 | - 'owner' => 'urn:li:person:' . $li_user_info->id, |
|
| 166 | + 'owner' => 'urn:li:person:'.$li_user_info->id, |
|
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | |
| 170 | - if ( $args['submitted-image-url'] !== false ) { |
|
| 170 | + if ($args['submitted-image-url'] !== false) { |
|
| 171 | 171 | $share['content']['contentEntities'][0]['thumbnails'] = array( |
| 172 | 172 | array( |
| 173 | 173 | 'resolvedUrl' => $args['submitted-image-url'], |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $headers = array( 'X-Restli-Protocol-Version' => '2.0.0', 'Authorization' => 'Bearer ' . $ppp_social_settings['linkedin']->access_token, 'Content-Type' => 'application/json' ); |
|
| 178 | + $headers = array( 'X-Restli-Protocol-Version' => '2.0.0', 'Authorization' => 'Bearer '.$ppp_social_settings['linkedin']->access_token, 'Content-Type' => 'application/json' ); |
|
| 179 | 179 | $request = wp_remote_post( $url, array( 'httpversion' => '1.1', 'timeout' => '30', 'headers' => $headers, 'body' => json_encode( $share ) ) ); |
| 180 | 180 | |
| 181 | 181 | return json_decode( wp_remote_retrieve_body( $request ) ); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function ppp_linkedin_profile( $access_token ) { |
| 185 | 185 | $url = 'https://api.linkedin.com/v2/me'; |
| 186 | 186 | |
| 187 | - $headers = array( 'Authorization' => 'Bearer ' . $access_token ); |
|
| 187 | + $headers = array( 'Authorization' => 'Bearer '.$access_token ); |
|
| 188 | 188 | |
| 189 | 189 | $request = wp_remote_get( $url, array( 'headers' => $headers ) ); |
| 190 | 190 | $data = wp_remote_retrieve_body( $request ); |