@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined( 'ABSPATH' )) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * @since 1.2 |
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | - add_action( 'admin_menu', array( $this, 'admin_menus') ); |
|
| 38 | + add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
|
| 39 | 39 | add_action( 'admin_head', array( $this, 'admin_head' ) ); |
| 40 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
| 40 | + add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | remove_submenu_page( 'index.php', 'ppp-getting-started' ); |
| 82 | 82 | |
| 83 | 83 | // Badge for welcome page |
| 84 | - $badge_url = PPP_URL . 'includes/images/ppp-badge.png'; |
|
| 84 | + $badge_url = PPP_URL.'includes/images/ppp-badge.png'; |
|
| 85 | 85 | ?> |
| 86 | 86 | <style type="text/css" media="screen"> |
| 87 | 87 | /*<![CDATA[*/ |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | 123 | public function tabs() { |
| 124 | - $selected = isset( $_GET['page'] ) ? $_GET['page'] : 'ppp-about'; |
|
| 124 | + $selected = isset($_GET['page']) ? $_GET['page'] : 'ppp-about'; |
|
| 125 | 125 | ?> |
| 126 | 126 | <h1 class="nav-tab-wrapper"> |
| 127 | 127 | <a class="nav-tab <?php echo $selected == 'ppp-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'ppp-about' ), 'index.php' ) ) ); ?>"> |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | 141 | public function about_screen() { |
| 142 | - list( $display_version ) = explode( '-', PPP_VERSION ); |
|
| 142 | + list($display_version) = explode( '-', PPP_VERSION ); |
|
| 143 | 143 | ?> |
| 144 | 144 | <div class="wrap about-wrap"> |
| 145 | 145 | <h1><?php printf( __( 'Post Promoter Pro %s', 'ppp-txt' ), $display_version ); ?></h1> |
@@ -149,59 +149,59 @@ discard block |
||
| 149 | 149 | <?php $this->tabs(); ?> |
| 150 | 150 | |
| 151 | 151 | <div class="changelog"> |
| 152 | - <h3><?php _e( 'Free Form Tweet Scheduling', 'ppp-txt' );?></h3> |
|
| 152 | + <h3><?php _e( 'Free Form Tweet Scheduling', 'ppp-txt' ); ?></h3> |
|
| 153 | 153 | |
| 154 | 154 | <div class="feature-section"> |
| 155 | 155 | |
| 156 | - <img src="<?php echo PPP_URL . '/includes/images/screenshots/free-form-tweets.jpg'; ?>" class="ppp-welcome-screenshots"/> |
|
| 156 | + <img src="<?php echo PPP_URL.'/includes/images/screenshots/free-form-tweets.jpg'; ?>" class="ppp-welcome-screenshots"/> |
|
| 157 | 157 | |
| 158 | - <h4><?php _e( 'More effective, and user friendly.', 'ppp-txt' );?></h4> |
|
| 159 | - <p><?php _e( 'No longer do you have to figure out what "Day 1" means. With free form scheduling, you can now create Tweets, days, weeks, or months in the future. Even multiples a day.', 'ppp-txt' );?></p> |
|
| 160 | - <p><?php _e( 'Have an old post that you want to promote again? No problem, just go back and add another Scheduled Tweet to the list!', 'ppp-txt' );?></p> |
|
| 158 | + <h4><?php _e( 'More effective, and user friendly.', 'ppp-txt' ); ?></h4> |
|
| 159 | + <p><?php _e( 'No longer do you have to figure out what "Day 1" means. With free form scheduling, you can now create Tweets, days, weeks, or months in the future. Even multiples a day.', 'ppp-txt' ); ?></p> |
|
| 160 | + <p><?php _e( 'Have an old post that you want to promote again? No problem, just go back and add another Scheduled Tweet to the list!', 'ppp-txt' ); ?></p> |
|
| 161 | 161 | |
| 162 | 162 | </div> |
| 163 | 163 | </div> |
| 164 | 164 | |
| 165 | 165 | <div class="changelog"> |
| 166 | - <h3><?php _e( 'Twitter Cards Support', 'ppp-txt' );?></h3> |
|
| 166 | + <h3><?php _e( 'Twitter Cards Support', 'ppp-txt' ); ?></h3> |
|
| 167 | 167 | |
| 168 | 168 | <div class="feature-section"> |
| 169 | 169 | |
| 170 | - <img src="<?php echo PPP_URL . '/includes/images/screenshots/twitter-cards.jpg'; ?>" class="ppp-welcome-screenshots"/> |
|
| 170 | + <img src="<?php echo PPP_URL.'/includes/images/screenshots/twitter-cards.jpg'; ?>" class="ppp-welcome-screenshots"/> |
|
| 171 | 171 | |
| 172 | - <h4><?php _e( 'Increased visibility on Twitter','ppp-txt' );?></h4> |
|
| 173 | - <p><?php _e( 'Enable this feature if you want your Tweets to look the best they can.', 'ppp-txt' );?></p> |
|
| 174 | - <p><?php _e( 'This is an opt-in setting, so if you have a plugin that already does this, no conflicts will arise upon upgrade.', 'ppp-txt' );?></p> |
|
| 172 | + <h4><?php _e( 'Increased visibility on Twitter', 'ppp-txt' ); ?></h4> |
|
| 173 | + <p><?php _e( 'Enable this feature if you want your Tweets to look the best they can.', 'ppp-txt' ); ?></p> |
|
| 174 | + <p><?php _e( 'This is an opt-in setting, so if you have a plugin that already does this, no conflicts will arise upon upgrade.', 'ppp-txt' ); ?></p> |
|
| 175 | 175 | |
| 176 | 176 | </div> |
| 177 | 177 | </div> |
| 178 | 178 | |
| 179 | 179 | <div class="changelog"> |
| 180 | - <h3><?php _e( 'Variable Twitter Images', 'ppp-txt' );?></h3> |
|
| 180 | + <h3><?php _e( 'Variable Twitter Images', 'ppp-txt' ); ?></h3> |
|
| 181 | 181 | |
| 182 | 182 | <div class="feature-section"> |
| 183 | 183 | |
| 184 | - <h4><?php _e( 'Change the image attached to each Tweet','ppp-txt' );?></h4> |
|
| 185 | - <p><?php _e( 'Have a few rotating images you want to use for your scheduled Tweets? No problem, Version 2.2 supports changing this for every scheduled Tweet.', 'ppp-txt' );?></p> |
|
| 184 | + <h4><?php _e( 'Change the image attached to each Tweet', 'ppp-txt' ); ?></h4> |
|
| 185 | + <p><?php _e( 'Have a few rotating images you want to use for your scheduled Tweets? No problem, Version 2.2 supports changing this for every scheduled Tweet.', 'ppp-txt' ); ?></p> |
|
| 186 | 186 | |
| 187 | 187 | </div> |
| 188 | 188 | </div> |
| 189 | 189 | |
| 190 | 190 | <div class="changelog"> |
| 191 | - <h3><?php _e( 'Additional Updates', 'ppp-txt' );?></h3> |
|
| 191 | + <h3><?php _e( 'Additional Updates', 'ppp-txt' ); ?></h3> |
|
| 192 | 192 | |
| 193 | 193 | <div class="feature-section col three-col"> |
| 194 | 194 | <div> |
| 195 | - <h4><?php _e( 'Updated image sizes', 'ppp-txt' );?></h4> |
|
| 196 | - <p><?php _e( 'Changed the optimal thumbnail image sizes to meet the 2015 network standards.', 'ppp-txt' );?></p> |
|
| 195 | + <h4><?php _e( 'Updated image sizes', 'ppp-txt' ); ?></h4> |
|
| 196 | + <p><?php _e( 'Changed the optimal thumbnail image sizes to meet the 2015 network standards.', 'ppp-txt' ); ?></p> |
|
| 197 | 197 | |
| 198 | - <h4><?php _e( 'CSS Updates', 'ppp-txt' );?></h4> |
|
| 199 | - <p><?php _e( 'Fixed a conflict in the media library CSS.', 'ppp-txt' );?></p> |
|
| 198 | + <h4><?php _e( 'CSS Updates', 'ppp-txt' ); ?></h4> |
|
| 199 | + <p><?php _e( 'Fixed a conflict in the media library CSS.', 'ppp-txt' ); ?></p> |
|
| 200 | 200 | </div> |
| 201 | 201 | |
| 202 | 202 | <div class="last-feature"> |
| 203 | - <h4><?php _e( 'Improved Facebook Token Refresh', 'ppp-txt' );?></h4> |
|
| 204 | - <p><?php _e( 'Fixed a bug with the Facebook token refresh resetting the "Post As", dropdown.', 'ppp-txt' );?></p> |
|
| 203 | + <h4><?php _e( 'Improved Facebook Token Refresh', 'ppp-txt' ); ?></h4> |
|
| 204 | + <p><?php _e( 'Fixed a bug with the Facebook token refresh resetting the "Post As", dropdown.', 'ppp-txt' ); ?></p> |
|
| 205 | 205 | </div> |
| 206 | 206 | </div> |
| 207 | 207 | </div> |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return void |
| 222 | 222 | */ |
| 223 | 223 | public function getting_started_screen() { |
| 224 | - list( $display_version ) = explode( '-', PPP_VERSION ); |
|
| 224 | + list($display_version) = explode( '-', PPP_VERSION ); |
|
| 225 | 225 | ?> |
| 226 | 226 | <div class="wrap about-wrap"> |
| 227 | 227 | <h1><?php printf( __( 'Welcome to Post Promoter Pro %s', 'ppp-txt' ), $display_version ); ?></h1> |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | public function welcome() { |
| 248 | 248 | |
| 249 | 249 | $version_level = explode( '.', PPP_VERSION ); |
| 250 | - if ( count( $version_level > 2 ) ) { |
|
| 250 | + if (count( $version_level > 2 )) { |
|
| 251 | 251 | return; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // Bail if no activation redirect |
| 255 | - if ( ! get_transient( '_ppp_activation_redirect' ) ) { |
|
| 255 | + if ( ! get_transient( '_ppp_activation_redirect' )) { |
|
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | delete_transient( '_ppp_activation_redirect' ); |
| 261 | 261 | |
| 262 | 262 | // Bail if activating from network, or bulk |
| 263 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 263 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -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_bitly_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['bitly'] ) && !empty( $ppp_social_settings['bitly'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['bitly']) && ! empty($ppp_social_settings['bitly'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | global $ppp_bitly_oauth, $ppp_social_settings; |
| 38 | 38 | ?> |
| 39 | 39 | <p> |
| 40 | - <?php if ( !ppp_bitly_enabled() ) : ?> |
|
| 40 | + <?php if ( ! ppp_bitly_enabled()) : ?> |
|
| 41 | 41 | <form autocomplete="off"> |
| 42 | 42 | <input id="bitly-username" name="ppp-bitly-username" autocomplete="off" type="text" value="" placeholder="Bit.ly Username" size="25" /><br /> |
| 43 | 43 | <input id="bitly-password" name="ppp-bitly-password" autocomplete="off" type="password" value="" placeholder="Bit.ly Password" size="25" /><br /> |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | <input type="hidden" id="bitly-redirect-url" value="<?php echo admin_url( 'admin.php?page=ppp-social-settings' ); ?>" /> |
| 49 | 49 | </form> |
| 50 | 50 | <?php endif; ?> |
| 51 | - <?php if ( ppp_bitly_enabled() ) : ?> |
|
| 51 | + <?php if (ppp_bitly_enabled()) : ?> |
|
| 52 | 52 | <div class="ppp-social-profile ppp-bitly-profile"> |
| 53 | 53 | <img class="ppp-social-icon" src="<?php echo $ppp_social_settings['bitly']['avatar']; ?>" /> |
| 54 | 54 | <div class="ppp-bitly-info"> |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | function ppp_disconnect_bitly() { |
| 73 | 73 | global $ppp_social_settings; |
| 74 | 74 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 75 | - if ( isset( $ppp_social_settings['bitly'] ) ) { |
|
| 76 | - unset( $ppp_social_settings['bitly'] ); |
|
| 75 | + if (isset($ppp_social_settings['bitly'])) { |
|
| 76 | + unset($ppp_social_settings['bitly']); |
|
| 77 | 77 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | add_action( 'ppp_disconnect-bitly', 'ppp_disconnect_bitly', 10 ); |
| 81 | 81 | |
| 82 | 82 | function ppp_set_bitly_token_constants( $social_tokens ) { |
| 83 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'bitly' ) ) { |
|
| 83 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'bitly' )) { |
|
| 84 | 84 | define( 'bitly_clientid', $social_tokens->bitly->client_id ); |
| 85 | 85 | define( 'bitly_secret', $social_tokens->bitly->client_secret ); |
| 86 | 86 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $result = $ppp_bitly_oauth->ppp_make_bitly_link( $link ); |
| 99 | 99 | $result = json_decode( $result, true ); |
| 100 | 100 | |
| 101 | - if ( isset ( $result['status_code'] ) && $result['status_code'] == 200 ) { |
|
| 101 | + if (isset ($result['status_code']) && $result['status_code'] == 200) { |
|
| 102 | 102 | return $result['data']['url']; |
| 103 | 103 | } else { |
| 104 | 104 | return $link; |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | $url = 'https://api-ssl.bitly.com/oauth/access_token'; |
| 117 | 117 | $username = $_POST['username']; |
| 118 | 118 | $password = $_POST['password']; |
| 119 | - $headers = array( 'Authorization' => 'Basic ' . base64_encode( bitly_clientid . ':' . bitly_secret ) ); |
|
| 120 | - $body = 'grant_type=password&username=' . $username . '&password=' . $password; |
|
| 119 | + $headers = array( 'Authorization' => 'Basic '.base64_encode( bitly_clientid.':'.bitly_secret ) ); |
|
| 120 | + $body = 'grant_type=password&username='.$username.'&password='.$password; |
|
| 121 | 121 | $result = wp_remote_post( $url, array( 'headers' => $headers, 'body' => $body ) ); |
| 122 | 122 | $body = wp_remote_retrieve_body( $result ); |
| 123 | 123 | $data = json_decode( $body ); |
| 124 | 124 | |
| 125 | - if ( isset( $data->access_token ) ) { |
|
| 125 | + if (isset($data->access_token)) { |
|
| 126 | 126 | global $ppp_social_settings; |
| 127 | 127 | $ppp_social_settings['bitly']['access_token'] = $data->access_token; |
| 128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 135 | 135 | echo 1; |
| 136 | - } elseif ( $body == 'INVALID_LOGIN' ) { |
|
| 136 | + } elseif ($body == 'INVALID_LOGIN') { |
|
| 137 | 137 | echo 'INVALID_LOGIN'; |
| 138 | 138 | } else { |
| 139 | 139 | echo 0; |
@@ -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 bitly functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Bitly' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Bitly' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Bitly { |
| 17 | 17 | |
| 18 | 18 | var $bitly; |
| 19 | 19 | |
| 20 | - public function __construct(){ |
|
| 20 | + public function __construct() { |
|
| 21 | 21 | ppp_maybe_start_session(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | * Handles to load twitter class |
| 28 | 28 | */ |
| 29 | 29 | public function ppp_load_bitly() { |
| 30 | - if( !class_exists( 'Bitly' ) ) { |
|
| 31 | - require_once ( PPP_PATH . '/includes/libs/bitly/bitly.php' ); |
|
| 30 | + if ( ! class_exists( 'Bitly' )) { |
|
| 31 | + require_once (PPP_PATH.'/includes/libs/bitly/bitly.php'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | ppp_set_social_tokens(); |
| 35 | 35 | |
| 36 | - if ( ! defined( 'bitly_clientid' ) || ! defined( 'bitly_secret' ) ) { |
|
| 36 | + if ( ! defined( 'bitly_clientid' ) || ! defined( 'bitly_secret' )) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | global $ppp_social_settings; |
| 41 | 41 | |
| 42 | - if ( isset( $ppp_social_settings['bitly'] ) ) { |
|
| 43 | - if ( !defined( 'bitly_accesstoken' ) ) { |
|
| 42 | + if (isset($ppp_social_settings['bitly'])) { |
|
| 43 | + if ( ! defined( 'bitly_accesstoken' )) { |
|
| 44 | 44 | define( 'bitly_accesstoken', $ppp_social_settings['bitly']['access_token'] ); |
| 45 | 45 | } |
| 46 | 46 | $this->bitly = new Bitly( bitly_clientid, bitly_secret, bitly_accesstoken ); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function revoke_access() { |
| 55 | 55 | global $ppp_social_settings; |
| 56 | 56 | |
| 57 | - unset( $ppp_social_settings['bitly'] ); |
|
| 57 | + unset($ppp_social_settings['bitly']); |
|
| 58 | 58 | |
| 59 | 59 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 60 | 60 | } |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | * Get auth codes for Bitly |
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | - public function ppp_get_bitly_auth_url () { |
|
| 66 | + public function ppp_get_bitly_auth_url() { |
|
| 67 | 67 | //load bitly class |
| 68 | 68 | $bitly = $this->ppp_load_bitly(); |
| 69 | 69 | |
| 70 | 70 | //check bitly class is loaded or not |
| 71 | - if( !$bitly ) { |
|
| 71 | + if ( ! $bitly) { |
|
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function ppp_make_bitly_link( $link = null ) { |
| 80 | - if ( empty( $link ) ) { |
|
| 80 | + if (empty($link)) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $bitly = $this->ppp_load_bitly(); |
| 85 | 85 | |
| 86 | - if ( !$bitly ) { |
|
| 86 | + if ( ! $bitly) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function ppp_bitly_user_info() { |
| 94 | 94 | $bitly = $this->ppp_load_bitly(); |
| 95 | 95 | |
| 96 | - if ( !$bitly ) { |
|
| 96 | + if ( ! $bitly) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( !defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | * Handles all facebook functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Facebook' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Facebook' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Facebook { |
| 17 | 17 | |
| 18 | 18 | var $facebook; |
| 19 | 19 | |
| 20 | - public function __construct(){ |
|
| 20 | + public function __construct() { |
|
| 21 | 21 | ppp_maybe_start_session(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | public function ppp_load_facebook() { |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - if( !class_exists( 'Facebook' ) ) { |
|
| 34 | - require_once ( PPP_PATH . '/includes/libs/facebook/facebook.php' ); |
|
| 33 | + if ( ! class_exists( 'Facebook' )) { |
|
| 34 | + require_once (PPP_PATH.'/includes/libs/facebook/facebook.php'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ppp_set_social_tokens(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'appId' => PPP_FB_APP_ID, |
| 41 | 41 | 'secret' => PPP_FB_APP_SECRET, |
| 42 | 42 | 'cookie' => true |
| 43 | - )); |
|
| 43 | + ) ); |
|
| 44 | 44 | |
| 45 | 45 | return true; |
| 46 | 46 | |
@@ -55,72 +55,72 @@ discard block |
||
| 55 | 55 | $facebook = $this->ppp_load_facebook(); |
| 56 | 56 | |
| 57 | 57 | //when user is going to logged in and verified successfully session will create |
| 58 | - if ( isset( $_REQUEST['fb_access_token'] ) && isset( $_REQUEST['expires_in'] ) ) { |
|
| 58 | + if (isset($_REQUEST['fb_access_token']) && isset($_REQUEST['expires_in'])) { |
|
| 59 | 59 | |
| 60 | 60 | $access_token = $_REQUEST['fb_access_token']; |
| 61 | 61 | $expires_in = $_REQUEST['expires_in']; |
| 62 | 62 | |
| 63 | - } elseif ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false ) { |
|
| 64 | - $access_code = isset( $_GET['code'] ) ? $_GET['code'] : false; |
|
| 63 | + } elseif (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false) { |
|
| 64 | + $access_code = isset($_GET['code']) ? $_GET['code'] : false; |
|
| 65 | 65 | |
| 66 | - if ( empty( $access_code ) ) { |
|
| 66 | + if (empty($access_code)) { |
|
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $params = '?client_id=' . PPP_FB_APP_ID; |
|
| 71 | - $params .= '&client_secret=' . PPP_FB_APP_SECRET; |
|
| 72 | - $params .= '&code=' . $access_code; |
|
| 73 | - $params .= '&redirect_uri=' . admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 74 | - $url = 'https://graph.facebook.com/oauth/access_token' . $params; |
|
| 70 | + $params = '?client_id='.PPP_FB_APP_ID; |
|
| 71 | + $params .= '&client_secret='.PPP_FB_APP_SECRET; |
|
| 72 | + $params .= '&code='.$access_code; |
|
| 73 | + $params .= '&redirect_uri='.admin_url( 'admin.php?page=ppp-social-settings' ); |
|
| 74 | + $url = 'https://graph.facebook.com/oauth/access_token'.$params; |
|
| 75 | 75 | |
| 76 | 76 | $access_token = ''; |
| 77 | 77 | $expires = ''; |
| 78 | 78 | parse_str( wp_remote_retrieve_body( wp_remote_post( $url ) ) ); |
| 79 | 79 | |
| 80 | - $access_token = ! empty( $access_token ) ? $access_token : false; |
|
| 81 | - $expires_in = ! empty( $expires ) ? $expires : false; |
|
| 80 | + $access_token = ! empty($access_token) ? $access_token : false; |
|
| 81 | + $expires_in = ! empty($expires) ? $expires : false; |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( ! empty( $access_token ) ) { |
|
| 85 | + if ( ! empty($access_token)) { |
|
| 86 | 86 | global $ppp_social_settings; |
| 87 | 87 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 88 | 88 | |
| 89 | 89 | //check facebook class is loaded or not |
| 90 | - if( !$facebook ) { |
|
| 90 | + if ( ! $facebook) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $data = new stdClass(); |
| 95 | 95 | $data->access_token = $access_token; |
| 96 | 96 | |
| 97 | - $expires_in = empty( $expires_in ) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 97 | + $expires_in = empty($expires_in) ? 60 * 24 * 60 * 60 : $expires_in; // days * hours * minutes * seconds |
|
| 98 | 98 | $data->expires_on = current_time( 'timestamp' ) + $expires_in; |
| 99 | 99 | |
| 100 | - update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in/1.25 ) ); |
|
| 100 | + update_option( '_ppp_facebook_refresh', current_time( 'timestamp' ) + round( $expires_in / 1.25 ) ); |
|
| 101 | 101 | |
| 102 | 102 | // Now that we have a valid auth, get some user info |
| 103 | 103 | $user_info = $this->ppp_get_fb_user( $data->access_token ); |
| 104 | 104 | |
| 105 | - if ( $user_info ) { |
|
| 106 | - if ( !empty( $user_info->name ) ) { |
|
| 105 | + if ($user_info) { |
|
| 106 | + if ( ! empty($user_info->name)) { |
|
| 107 | 107 | $data->name = $user_info->name; |
| 108 | 108 | } else { |
| 109 | - $parsed_name = $user_info->first_name . ' ' . $user_info->last_name; |
|
| 109 | + $parsed_name = $user_info->first_name.' '.$user_info->last_name; |
|
| 110 | 110 | $data->name = $parsed_name; |
| 111 | 111 | } |
| 112 | 112 | $data->userid = $user_info->id; |
| 113 | 113 | $data->avatar = $this->ppp_fb_get_profile_picture( array( 'type' => 'square' ), $data->userid ); |
| 114 | 114 | |
| 115 | - if ( ! empty( $ppp_social_settings['facebook']->page ) ) { |
|
| 115 | + if ( ! empty($ppp_social_settings['facebook']->page)) { |
|
| 116 | 116 | $current_page = $ppp_social_settings['facebook']->page; |
| 117 | 117 | $page_parts = explode( '|', $current_page ); |
| 118 | 118 | |
| 119 | 119 | $pages = $this->ppp_get_fb_user_pages( $data->access_token ); |
| 120 | 120 | |
| 121 | - foreach ( $pages as $page ) { |
|
| 122 | - if ( $page->id == $page_parts[2] ) { |
|
| 123 | - $data->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 121 | + foreach ($pages as $page) { |
|
| 122 | + if ($page->id == $page_parts[2]) { |
|
| 123 | + $data->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | - $url = remove_query_arg( array( 'fb_access_token' , 'expires_in' ) ); |
|
| 136 | + $url = remove_query_arg( array( 'fb_access_token', 'expires_in' ) ); |
|
| 137 | 137 | wp_redirect( $url ); |
| 138 | 138 | die(); |
| 139 | 139 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | $facebook = $this->ppp_load_facebook(); |
| 152 | 152 | |
| 153 | 153 | //check facebook class is exis or not |
| 154 | - if( !$facebook ) { |
|
| 154 | + if ( ! $facebook) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | global $ppp_social_settings; |
| 159 | - $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token=' . $access_token ) ) ); |
|
| 159 | + $user = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me?access_token='.$access_token ) ) ); |
|
| 160 | 160 | |
| 161 | 161 | return $user; |
| 162 | 162 | |
@@ -168,27 +168,27 @@ discard block |
||
| 168 | 168 | $facebook = $this->ppp_load_facebook(); |
| 169 | 169 | |
| 170 | 170 | // check facebook cleast is exists or not |
| 171 | - if( !$facebook ) { |
|
| 171 | + if ( ! $facebook) { |
|
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | global $ppp_social_settings; |
| 176 | 176 | $facebook_settings = $ppp_social_settings['facebook']; |
| 177 | 177 | |
| 178 | - if ( ! isset( $facebook_settings->available_pages ) || |
|
| 179 | - ! isset( $facebook_settings->pages_last_updated ) || |
|
| 180 | - $facebook_settings->pages_last_updated < current_time( 'timestamp' ) ) { |
|
| 178 | + if ( ! isset($facebook_settings->available_pages) || |
|
| 179 | + ! isset($facebook_settings->pages_last_updated) || |
|
| 180 | + $facebook_settings->pages_last_updated < current_time( 'timestamp' )) { |
|
| 181 | 181 | |
| 182 | - $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token=' . $access_token ) ) ); |
|
| 182 | + $all_pages = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://graph.facebook.com/me/accounts?access_token='.$access_token ) ) ); |
|
| 183 | 183 | $pages = array(); |
| 184 | 184 | |
| 185 | - if ( !empty( $all_pages ) ) { |
|
| 186 | - foreach ( $all_pages->data as $page ) { |
|
| 187 | - if ( in_array( 'CREATE_CONTENT', $page->perms ) ) { |
|
| 185 | + if ( ! empty($all_pages)) { |
|
| 186 | + foreach ($all_pages->data as $page) { |
|
| 187 | + if (in_array( 'CREATE_CONTENT', $page->perms )) { |
|
| 188 | 188 | $pages[] = $page; |
| 189 | 189 | |
| 190 | - if ( ! empty( $ppp_social_settings['facebook']->page ) && strpos( $ppp_social_settings['facebook']->page, $page->id ) ) { |
|
| 191 | - $ppp_social_settings['facebook']->page = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 190 | + if ( ! empty($ppp_social_settings['facebook']->page) && strpos( $ppp_social_settings['facebook']->page, $page->id )) { |
|
| 191 | + $ppp_social_settings['facebook']->page = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $pages = (object) $pages; |
| 201 | 201 | $ppp_social_settings['facebook']->available_pages = $pages; |
| 202 | - $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + ( HOUR_IN_SECONDS / 4 ); |
|
| 202 | + $ppp_social_settings['facebook']->pages_last_updated = current_time( 'timestamp' ) + (HOUR_IN_SECONDS / 4); |
|
| 203 | 203 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 204 | 204 | } else { |
| 205 | 205 | $pages = $facebook_settings->available_pages; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $facebook = $this->ppp_load_facebook(); |
| 222 | 222 | |
| 223 | 223 | //check facebook class is exis or not |
| 224 | - if( !$facebook ) { |
|
| 224 | + if ( ! $facebook) { |
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -232,27 +232,27 @@ discard block |
||
| 232 | 232 | * Get auth url for facebook |
| 233 | 233 | * |
| 234 | 234 | */ |
| 235 | - public function ppp_get_facebook_auth_url ( $return_url ) { |
|
| 235 | + public function ppp_get_facebook_auth_url( $return_url ) { |
|
| 236 | 236 | |
| 237 | 237 | //load facebook class |
| 238 | 238 | $facebook = $this->ppp_load_facebook(); |
| 239 | 239 | |
| 240 | 240 | //check facebook class is exis or not |
| 241 | - if( !$facebook ) { |
|
| 241 | + if ( ! $facebook) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( ! PPP_LOCAL_TOKENS ) { |
|
| 245 | + if ( ! PPP_LOCAL_TOKENS) { |
|
| 246 | 246 | $base_url = 'https://postpromoterpro.com/?ppp-social-auth'; |
| 247 | - $url = $base_url . '&ppp-service=fb&ppp-license-key=' . trim( get_option( '_ppp_license_key' ) ); |
|
| 247 | + $url = $base_url.'&ppp-service=fb&ppp-license-key='.trim( get_option( '_ppp_license_key' ) ); |
|
| 248 | 248 | $url .= '&nocache'; |
| 249 | - $url .= '&return_url=' . esc_url( $return_url ); |
|
| 249 | + $url .= '&return_url='.esc_url( $return_url ); |
|
| 250 | 250 | } else { |
| 251 | 251 | $url = 'https://graph.facebook.com/oauth/authorize?'; |
| 252 | - $url .= 'client_id=' . PPP_FB_APP_ID; |
|
| 252 | + $url .= 'client_id='.PPP_FB_APP_ID; |
|
| 253 | 253 | $url .= '&scope=public_profile,publish_actions,manage_pages,publish_pages'; |
| 254 | 254 | $url .= '&state=ppp-local-keys-fb'; |
| 255 | - $url .= '&redirect_uri=' . esc_url( $return_url ) . '&nocache'; |
|
| 255 | + $url .= '&redirect_uri='.esc_url( $return_url ).'&nocache'; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return $url; |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * Getting the the profile image of the connected Facebook user. |
| 265 | 265 | * |
| 266 | 266 | */ |
| 267 | - public function ppp_fb_get_profile_picture( $args=array(), $user ) { |
|
| 267 | + public function ppp_fb_get_profile_picture( $args = array(), $user ) { |
|
| 268 | 268 | |
| 269 | - if( isset( $args['type'] ) && !empty( $args['type'] ) ) { |
|
| 269 | + if (isset($args['type']) && ! empty($args['type'])) { |
|
| 270 | 270 | $type = $args['type']; |
| 271 | 271 | } else { |
| 272 | 272 | $type = 'large'; |
| 273 | 273 | } |
| 274 | - $url = 'https://graph.facebook.com/' . $user . '/picture?type=' . $type; |
|
| 274 | + $url = 'https://graph.facebook.com/'.$user.'/picture?type='.$type; |
|
| 275 | 275 | return $url; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | global $ppp_social_settings; |
| 280 | 280 | $facebook_settings = $ppp_social_settings['facebook']; |
| 281 | 281 | |
| 282 | - if ( !isset( $facebook_settings->page ) || strtolower( $facebook_settings->page ) === 'me' ) { |
|
| 282 | + if ( ! isset($facebook_settings->page) || strtolower( $facebook_settings->page ) === 'me') { |
|
| 283 | 283 | $account = 'me'; |
| 284 | 284 | $access_token = $facebook_settings->access_token; |
| 285 | 285 | } else { |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | $access_token = $page_info[1]; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $url = 'https://graph.facebook.com/' . $account . '/feed?access_token=' . $access_token; |
|
| 291 | + $url = 'https://graph.facebook.com/'.$account.'/feed?access_token='.$access_token; |
|
| 292 | 292 | $args = array( 'link' => $link, 'message' => $message ); |
| 293 | - if ( !empty( $image ) ) { |
|
| 293 | + if ( ! empty($image)) { |
|
| 294 | 294 | $args['picture'] = $image; |
| 295 | 295 | } |
| 296 | 296 | $results = wp_remote_post( $url, array( 'body' => $args ) ); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | public function ppp_get_data_from_url( $url ) { |
| 310 | 310 | |
| 311 | 311 | //Use wp_remote_post and wp_remote_get |
| 312 | - $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 312 | + $data = wp_remote_retrieve_body( wp_remote_get( $url ) ); |
|
| 313 | 313 | |
| 314 | 314 | return $data; |
| 315 | 315 | } |
@@ -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=rw_nus%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,13 +144,13 @@ 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 | |
| 151 | 151 | $this->ppp_load_linkedin(); |
| 152 | 152 | global $ppp_social_settings; |
| 153 | - $url = 'https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=' . $ppp_social_settings['linkedin']->access_token; |
|
| 153 | + $url = 'https://api.linkedin.com/v1/people/~/shares?oauth2_access_token='.$ppp_social_settings['linkedin']->access_token; |
|
| 154 | 154 | $share = array( |
| 155 | 155 | 'content' => array( |
| 156 | 156 | 'title' => $args['title'], |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | ) |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | - if ( $args['submitted-image-url'] !== false ) { |
|
| 165 | + if ($args['submitted-image-url'] !== false) { |
|
| 166 | 166 | $share['content']['submitted-image-url'] = $args['submitted-image-url']; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $this->ppp_load_linkedin(); |
| 179 | 179 | global $ppp_social_settings; |
| 180 | - $url = 'https://api.linkedin.com/v1/people/~?oauth2_access_token=' . $ppp_social_settings['linkedin']->access_token; |
|
| 180 | + $url = 'https://api.linkedin.com/v1/people/~?oauth2_access_token='.$ppp_social_settings['linkedin']->access_token; |
|
| 181 | 181 | |
| 182 | 182 | $headers = array( 'x-li-format' => 'json', 'Content-Type' => 'application/json' ); |
| 183 | 183 | |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -include_once( PPP_PATH . '/includes/wpme-functions.php' ); |
|
| 8 | +include_once(PPP_PATH.'/includes/wpme-functions.php'); |
|
| 9 | 9 | |
| 10 | 10 | global $ppp_twitter_oauth; |
| 11 | -include_once( PPP_PATH . '/includes/twitter-functions.php' ); |
|
| 12 | -require_once( PPP_PATH . '/includes/libs/twitter.php'); |
|
| 11 | +include_once(PPP_PATH.'/includes/twitter-functions.php'); |
|
| 12 | +require_once(PPP_PATH.'/includes/libs/twitter.php'); |
|
| 13 | 13 | $ppp_twitter_oauth = new PPP_Twitter(); |
| 14 | 14 | |
| 15 | 15 | // Also include the user specific Twitter Class ( separate for now ) |
| 16 | -require_once( PPP_PATH . '/includes/libs/twitter-user.php' ); |
|
| 16 | +require_once(PPP_PATH.'/includes/libs/twitter-user.php'); |
|
| 17 | 17 | |
| 18 | 18 | global $ppp_facebook_oauth; |
| 19 | -include_once( PPP_PATH . '/includes/facebook-functions.php' ); |
|
| 20 | -require_once( PPP_PATH . '/includes/libs/facebook.php'); |
|
| 19 | +include_once(PPP_PATH.'/includes/facebook-functions.php'); |
|
| 20 | +require_once(PPP_PATH.'/includes/libs/facebook.php'); |
|
| 21 | 21 | $ppp_facebook_oauth = new PPP_Facebook(); |
| 22 | 22 | |
| 23 | 23 | global $ppp_bitly_oauth; |
| 24 | -include_once( PPP_PATH . '/includes/bitly-functions.php' ); |
|
| 25 | -require_once( PPP_PATH . '/includes/libs/bitly.php' ); |
|
| 24 | +include_once(PPP_PATH.'/includes/bitly-functions.php'); |
|
| 25 | +require_once(PPP_PATH.'/includes/libs/bitly.php'); |
|
| 26 | 26 | $ppp_bitly_oauth = new PPP_Bitly(); |
| 27 | 27 | |
| 28 | 28 | global $ppp_linkedin_oauth; |
| 29 | -include_once( PPP_PATH . '/includes/linkedin-functions.php' ); |
|
| 30 | -require_once( PPP_PATH . '/includes/libs/linkedin.php' ); |
|
| 29 | +include_once(PPP_PATH.'/includes/linkedin-functions.php'); |
|
| 30 | +require_once(PPP_PATH.'/includes/libs/linkedin.php'); |
|
| 31 | 31 | $ppp_linkedin_oauth = new PPP_Linkedin(); |
@@ -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'] ) && isset( $_REQUEST['oauth_token'] ) ) { |
|
| 59 | + if (isset($_REQUEST['oauth_verifier']) && isset($_REQUEST['oauth_token'])) { |
|
| 60 | 60 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 61 | 61 | |
| 62 | 62 | //load twitter class |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | //session for verifier |
| 70 | 70 | $verifier['oauth_verifier'] = $_REQUEST['oauth_verifier']; |
| 71 | - $_SESSION[ 'ppp_twt_user_cache' ] = $verifier; |
|
| 71 | + $_SESSION['ppp_twt_user_cache'] = $verifier; |
|
| 72 | 72 | |
| 73 | 73 | //getting user data from twitter |
| 74 | 74 | $response = $this->twitter->get( 'account/verify_credentials' ); |
| 75 | 75 | |
| 76 | 76 | //if user data get successfully |
| 77 | - if ( $response->id_str ) { |
|
| 77 | + if ($response->id_str) { |
|
| 78 | 78 | |
| 79 | 79 | $data['user'] = $response; |
| 80 | 80 | $data['user']->accessToken = $ppp_tw_access_token; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->load(); |
| 89 | 89 | |
| 90 | 90 | $user_settings = get_user_meta( $this->user_id, '_ppp_twitter_data', true ); |
| 91 | - if ( ! empty( $user_settings ) ) { |
|
| 91 | + if ( ! empty($user_settings)) { |
|
| 92 | 92 | |
| 93 | 93 | $this->twitter = new TwitterOAuth( |
| 94 | 94 | PPP_TW_CONSUMER_KEY, |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | $user_settings['user']->accessToken['oauth_token_secret'] |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 101 | - if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) { |
|
| 102 | - foreach ( $response->errors as $error ) { |
|
| 103 | - if ( $error->code == 89 ) { // Expired or revoked tokens |
|
| 100 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 101 | + if (is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0) { |
|
| 102 | + foreach ($response->errors as $error) { |
|
| 103 | + if ($error->code == 89) { // Expired or revoked tokens |
|
| 104 | 104 | |
| 105 | 105 | $this->revoke_access(); |
| 106 | 106 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | * Get auth url for twitter |
| 118 | 118 | * |
| 119 | 119 | */ |
| 120 | - public function get_auth_url ( $return_url = '' ) { |
|
| 120 | + public function get_auth_url( $return_url = '' ) { |
|
| 121 | 121 | |
| 122 | - if ( empty( $return_url ) ) { |
|
| 122 | + if (empty($return_url)) { |
|
| 123 | 123 | $return_url = admin_url( 'admin.php?page=ppp-social-settings' ); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $request_token = $this->twitter->getRequestToken( $return_url ); |
| 129 | 129 | |
| 130 | 130 | // If last connection failed don't display authorization link. |
| 131 | - switch( $this->twitter->http_code ) { |
|
| 131 | + switch ($this->twitter->http_code) { |
|
| 132 | 132 | case 200: |
| 133 | 133 | $_SESSION['ppp_user_twt_oauth_token'] = $request_token['oauth_token']; |
| 134 | 134 | $_SESSION['ppp_user_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function send_tweet( $message = '', $media = null ) { |
| 148 | - if ( empty( $message ) ) { |
|
| 148 | + if (empty($message)) { |
|
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $verify = $this->verify_credentials(); |
| 153 | - if ( $verify === true ) { |
|
| 153 | + if ($verify === true) { |
|
| 154 | 154 | $args = array(); |
| 155 | - if ( ! empty( $media ) ) { |
|
| 155 | + if ( ! empty($media)) { |
|
| 156 | 156 | $endpoint = 'statuses/update_with_media'; |
| 157 | 157 | $args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) ); |
| 158 | 158 | } else { |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function retweet( $tweet_id ) { |
| 170 | - if ( empty( $tweet_id ) ) { |
|
| 170 | + if (empty($tweet_id)) { |
|
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $verify = $this->verify_credentials(); |
| 175 | - if ( $verify === true ) { |
|
| 176 | - $endpoint = 'statuses/retweet/' . $tweet_id; |
|
| 175 | + if ($verify === true) { |
|
| 176 | + $endpoint = 'statuses/retweet/'.$tweet_id; |
|
| 177 | 177 | |
| 178 | 178 | return $this->twitter->post( $endpoint, array(), true ); |
| 179 | 179 | } else { |
@@ -146,16 +146,16 @@ |
||
| 146 | 146 | // If last connection failed don't display authorization link. |
| 147 | 147 | switch( $this->twitter->http_code ) { |
| 148 | 148 | |
| 149 | - case 200: |
|
| 150 | - $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
|
| 151 | - $_SESSION['ppp_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
|
| 152 | - |
|
| 153 | - $token = $request_token['oauth_token']; |
|
| 154 | - $url = $this->twitter->getAuthorizeURL( $token, NULL ); |
|
| 155 | - break; |
|
| 156 | - default: |
|
| 157 | - $url = ''; |
|
| 158 | - break; |
|
| 149 | + case 200: |
|
| 150 | + $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
|
| 151 | + $_SESSION['ppp_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
|
| 152 | + |
|
| 153 | + $token = $request_token['oauth_token']; |
|
| 154 | + $url = $this->twitter->getAuthorizeURL( $token, NULL ); |
|
| 155 | + break; |
|
| 156 | + default: |
|
| 157 | + $url = ''; |
|
| 158 | + break; |
|
| 159 | 159 | } |
| 160 | 160 | return $url; |
| 161 | 161 | } |
@@ -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' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Twitter' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Twitter { |
| 17 | 17 | |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | * Handles to load twitter class |
| 30 | 30 | */ |
| 31 | 31 | public function ppp_load_twitter() { |
| 32 | - if( !class_exists( 'TwitterOAuth' ) ) { |
|
| 33 | - require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' ); |
|
| 32 | + if ( ! class_exists( 'TwitterOAuth' )) { |
|
| 33 | + require_once (PPP_PATH.'/includes/libs/twitter/twitteroauth.php'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | ppp_set_social_tokens(); |
| 37 | 37 | |
| 38 | - if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' ) ) { |
|
| 38 | + if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' )) { |
|
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function revoke_access() { |
| 48 | 48 | global $ppp_social_settings; |
| 49 | 49 | |
| 50 | - unset( $ppp_social_settings['twitter'] ); |
|
| 50 | + unset($ppp_social_settings['twitter']); |
|
| 51 | 51 | |
| 52 | 52 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 53 | 53 | } |
@@ -59,32 +59,32 @@ discard block |
||
| 59 | 59 | public function ppp_initialize_twitter() { |
| 60 | 60 | |
| 61 | 61 | //when user is going to logged in in twitter and verified successfully session will create |
| 62 | - if ( isset( $_REQUEST['oauth_verifier'] ) && isset( $_REQUEST['oauth_token'] ) ) { |
|
| 62 | + if (isset($_REQUEST['oauth_verifier']) && isset($_REQUEST['oauth_token'])) { |
|
| 63 | 63 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 64 | 64 | |
| 65 | 65 | //load twitter class |
| 66 | 66 | $twitter = $this->ppp_load_twitter(); |
| 67 | 67 | |
| 68 | 68 | //check twitter class is loaded or not |
| 69 | - if( !$twitter ) { |
|
| 69 | + if ( ! $twitter) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $this->twitter = new TwitterOAuth( PPP_TW_CONSUMER_KEY, PPP_TW_CONSUMER_SECRET, $_SESSION['ppp_twt_oauth_token'], $_SESSION['ppp_twt_oauth_token_secret'] ); |
| 74 | 74 | |
| 75 | 75 | // Request access tokens from twitter |
| 76 | - $ppp_tw_access_token = $this->twitter->getAccessToken($_REQUEST['oauth_verifier']); |
|
| 76 | + $ppp_tw_access_token = $this->twitter->getAccessToken( $_REQUEST['oauth_verifier'] ); |
|
| 77 | 77 | |
| 78 | 78 | //session for verifier |
| 79 | 79 | $verifier['oauth_verifier'] = $_REQUEST['oauth_verifier']; |
| 80 | 80 | |
| 81 | - $_SESSION[ 'ppp_twt_user_cache' ] = $verifier; |
|
| 81 | + $_SESSION['ppp_twt_user_cache'] = $verifier; |
|
| 82 | 82 | |
| 83 | 83 | //getting user data from twitter |
| 84 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 84 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 85 | 85 | |
| 86 | 86 | //if user data get successfully |
| 87 | - if ( $response->id_str ) { |
|
| 87 | + if ($response->id_str) { |
|
| 88 | 88 | |
| 89 | 89 | $data['user'] = $response; |
| 90 | 90 | $data['user']->accessToken = $ppp_tw_access_token; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $this->ppp_load_twitter(); |
| 100 | 100 | |
| 101 | 101 | global $ppp_social_settings; |
| 102 | - if ( isset( $ppp_social_settings['twitter'] ) ) { |
|
| 102 | + if (isset($ppp_social_settings['twitter'])) { |
|
| 103 | 103 | |
| 104 | 104 | $this->twitter = new TwitterOAuth( |
| 105 | 105 | PPP_TW_CONSUMER_KEY, |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | $ppp_social_settings['twitter']['user']->accessToken['oauth_token_secret'] |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 112 | - if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) { |
|
| 113 | - foreach ( $response->errors as $error ) { |
|
| 114 | - if ( $error->code == 89 ) { // Expired or revoked tokens |
|
| 115 | - unset( $ppp_social_settings['twitter'] ); |
|
| 111 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 112 | + if (is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0) { |
|
| 113 | + foreach ($response->errors as $error) { |
|
| 114 | + if ($error->code == 89) { // Expired or revoked tokens |
|
| 115 | + unset($ppp_social_settings['twitter']); |
|
| 116 | 116 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 117 | 117 | |
| 118 | 118 | return array( 'error' => __( 'Post Promoter Pro has been removed from your Twitter account. Please reauthorize to continue promoting your content.', 'ppp-txt' ) ); |
@@ -128,23 +128,23 @@ discard block |
||
| 128 | 128 | * Get auth url for twitter |
| 129 | 129 | * |
| 130 | 130 | */ |
| 131 | - public function ppp_get_twitter_auth_url ( $return_url = '' ) { |
|
| 131 | + public function ppp_get_twitter_auth_url( $return_url = '' ) { |
|
| 132 | 132 | |
| 133 | - if ( empty( $return_url ) ) { |
|
| 133 | + if (empty($return_url)) { |
|
| 134 | 134 | $return_url = admin_url( 'admin.php?page=ppp-social-settings' ); |
| 135 | 135 | } |
| 136 | 136 | //load twitter class |
| 137 | 137 | $twitter = $this->ppp_load_twitter(); |
| 138 | 138 | |
| 139 | 139 | //check twitter class is loaded or not |
| 140 | - if( !$twitter ) { |
|
| 140 | + if ( ! $twitter) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $request_token = $this->twitter->getRequestToken( $return_url ); |
| 145 | 145 | |
| 146 | 146 | // If last connection failed don't display authorization link. |
| 147 | - switch( $this->twitter->http_code ) { |
|
| 147 | + switch ($this->twitter->http_code) { |
|
| 148 | 148 | |
| 149 | 149 | case 200: |
| 150 | 150 | $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
@@ -161,14 +161,14 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function ppp_tweet( $message = '', $media = null ) { |
| 164 | - if ( empty( $message ) ) { |
|
| 164 | + if (empty($message)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $verify = $this->ppp_verify_twitter_credentials(); |
| 169 | - if ( $verify === true ) { |
|
| 169 | + if ($verify === true) { |
|
| 170 | 170 | $args = array(); |
| 171 | - if ( ! empty( $media ) ) { |
|
| 171 | + if ( ! empty($media)) { |
|
| 172 | 172 | $endpoint = 'statuses/update_with_media'; |
| 173 | 173 | $args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) ); |
| 174 | 174 | } else { |
@@ -141,9 +141,9 @@ |
||
| 141 | 141 | */ |
| 142 | 142 | function ppp_set_social_tokens() { |
| 143 | 143 | if ( ( defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' ) ) || |
| 144 | - ( defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' ) ) || |
|
| 145 | - ( defined( 'bitly_clientid' ) && defined( 'bitly_secret' ) ) || |
|
| 146 | - ( defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' ) ) |
|
| 144 | + ( defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' ) ) || |
|
| 145 | + ( defined( 'bitly_clientid' ) && defined( 'bitly_secret' ) ) || |
|
| 146 | + ( defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' ) ) |
|
| 147 | 147 | ) { |
| 148 | 148 | return; |
| 149 | 149 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function ppp_share_on_publish( $new_status, $old_status, $post ) { |
| 18 | 18 | // don't publish password protected posts |
| 19 | - if ( '' !== $post->post_password ) { |
|
| 19 | + if ('' !== $post->post_password) { |
|
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( $new_status == 'publish' && $old_status != 'publish' ) { |
|
| 23 | + if ($new_status == 'publish' && $old_status != 'publish') { |
|
| 24 | 24 | global $ppp_options; |
| 25 | 25 | |
| 26 | - $allowed_post_types = isset( $ppp_options['post_types'] ) ? $ppp_options['post_types'] : array(); |
|
| 26 | + $allowed_post_types = isset($ppp_options['post_types']) ? $ppp_options['post_types'] : array(); |
|
| 27 | 27 | $allowed_post_types = apply_filters( 'ppp_schedule_share_post_types', $allowed_post_types ); |
| 28 | 28 | |
| 29 | - if ( !isset( $post->post_status ) || !array_key_exists( $post->post_type, $allowed_post_types ) ) { |
|
| 29 | + if ( ! isset($post->post_status) || ! array_key_exists( $post->post_type, $allowed_post_types )) { |
|
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -57,20 +57,20 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // If we've already started to share this, don't share it again. |
| 59 | 59 | // Compensates for wp-cron's race conditions |
| 60 | - if ( get_transient( 'ppp_sharing' . $name ) === 'true' ) { |
|
| 60 | + if (get_transient( 'ppp_sharing'.$name ) === 'true') { |
|
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // For 10 seconds, don't allow another share to go for this post |
| 65 | - set_transient( 'ppp_sharing' . $name, 'true', 10 ); |
|
| 65 | + set_transient( 'ppp_sharing'.$name, 'true', 10 ); |
|
| 66 | 66 | |
| 67 | 67 | $name_parts = explode( '_', $name ); |
| 68 | 68 | $index = $name_parts[1]; |
| 69 | - $service = isset( $name_parts[3] ) ? $name_parts[3] : 'tw'; |
|
| 69 | + $service = isset($name_parts[3]) ? $name_parts[3] : 'tw'; |
|
| 70 | 70 | |
| 71 | 71 | // If we're fired on a cron, check for stale cron runs |
| 72 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 73 | - switch( $service ) { |
|
| 72 | + if (defined( 'DOING_CRON' ) && DOING_CRON) { |
|
| 73 | + switch ($service) { |
|
| 74 | 74 | case 'tw': |
| 75 | 75 | $post_meta = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 76 | 76 | break; |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $share_data = array(); |
| 88 | - if ( isset( $post_meta[ $index ] ) ) { |
|
| 89 | - $share_data = $post_meta[ $index ]; |
|
| 88 | + if (isset($post_meta[$index])) { |
|
| 89 | + $share_data = $post_meta[$index]; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $timestamp = ppp_generate_timestamp( $share_data['date'], $share_data['time'] ); |
| 93 | 93 | |
| 94 | 94 | // If the current time is more than 60 minutes (filterable) overdue, don't fire the share |
| 95 | 95 | $share_buffer = apply_filters( 'ppp_share_buffer', HOUR_IN_SECONDS ); |
| 96 | - if ( ( current_time( 'timestamp', 1 ) - $timestamp ) > $share_buffer ) { |
|
| 96 | + if ((current_time( 'timestamp', 1 ) - $timestamp) > $share_buffer) { |
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - do_action( 'ppp_share_scheduled_' . $service, $post_id, $index, $name ); |
|
| 101 | + do_action( 'ppp_share_scheduled_'.$service, $post_id, $index, $name ); |
|
| 102 | 102 | |
| 103 | 103 | } |
| 104 | 104 | |
@@ -107,26 +107,26 @@ discard block |
||
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | 109 | function ppp_set_social_tokens() { |
| 110 | - if ( ( defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' ) ) || |
|
| 111 | - ( defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' ) ) || |
|
| 112 | - ( defined( 'bitly_clientid' ) && defined( 'bitly_secret' ) ) || |
|
| 113 | - ( defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' ) ) |
|
| 110 | + if ((defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' )) || |
|
| 111 | + (defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' )) || |
|
| 112 | + (defined( 'bitly_clientid' ) && defined( 'bitly_secret' )) || |
|
| 113 | + (defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' )) |
|
| 114 | 114 | ) { |
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $social_tokens = ppp_has_local_tokens(); |
| 119 | 119 | |
| 120 | - if ( false === $social_tokens ) { |
|
| 120 | + if (false === $social_tokens) { |
|
| 121 | 121 | define( 'PPP_LOCAL_TOKENS', false ); |
| 122 | 122 | $social_tokens = get_transient( 'ppp_social_tokens' ); |
| 123 | 123 | |
| 124 | - if ( ! $social_tokens ) { |
|
| 124 | + if ( ! $social_tokens) { |
|
| 125 | 125 | $license = trim( get_option( '_ppp_license_key' ) ); |
| 126 | - $url = PPP_STORE_URL . '/?ppp-get-tokens&ppp-license-key=' . $license . '&ver=' . md5( time() . $license ); |
|
| 126 | + $url = PPP_STORE_URL.'/?ppp-get-tokens&ppp-license-key='.$license.'&ver='.md5( time().$license ); |
|
| 127 | 127 | $response = wp_remote_get( $url, array( 'timeout' => 15, 'sslverify' => false ) ); |
| 128 | 128 | |
| 129 | - if ( is_wp_error( $response ) ) { |
|
| 129 | + if (is_wp_error( $response )) { |
|
| 130 | 130 | return false; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | define( 'PPP_LOCAL_TOKENS', true ); |
| 139 | 139 | delete_transient( 'ppp_social_tokens' ); |
| 140 | 140 | |
| 141 | - if ( isset( $social_tokens->options ) ) { |
|
| 142 | - foreach ( $social_tokens->options as $constant => $value ) { |
|
| 141 | + if (isset($social_tokens->options)) { |
|
| 142 | + foreach ($social_tokens->options as $constant => $value) { |
|
| 143 | 143 | |
| 144 | 144 | $constant = strtoupper( $constant ); |
| 145 | 145 | |
| 146 | - if ( defined( $constant ) ) { |
|
| 146 | + if (defined( $constant )) { |
|
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - switch( $constant ) { |
|
| 150 | + switch ($constant) { |
|
| 151 | 151 | |
| 152 | 152 | case 'NO_AUTO_UPDATE': |
| 153 | 153 | // Avoid the call to the API to check for software updates |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( false === PPP_LOCAL_TOKENS && ! isset( $social_tokens->error ) && ( isset( $social_tokens->twitter ) || isset( $social_tokens->facebook ) || isset( $social_tokens->linkedin ) ) ) { |
|
| 163 | + if (false === PPP_LOCAL_TOKENS && ! isset($social_tokens->error) && (isset($social_tokens->twitter) || isset($social_tokens->facebook) || isset($social_tokens->linkedin))) { |
|
| 164 | 164 | set_transient( 'ppp_social_tokens', $social_tokens, WEEK_IN_SECONDS ); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -173,22 +173,22 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function ppp_has_local_tokens() { |
| 175 | 175 | |
| 176 | - $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path() . '/ppp-social-tokens.json' ); |
|
| 176 | + $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path().'/ppp-social-tokens.json' ); |
|
| 177 | 177 | $local_tokens = false; |
| 178 | 178 | |
| 179 | - if ( ! file_exists( $token_file ) ) { |
|
| 179 | + if ( ! file_exists( $token_file )) { |
|
| 180 | 180 | return $local_tokens; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $local_tokens = json_decode( file_get_contents( $token_file ) ); |
| 184 | 184 | |
| 185 | 185 | // Failed to parse as JSON |
| 186 | - if ( false === $local_tokens ) { |
|
| 186 | + if (false === $local_tokens) { |
|
| 187 | 187 | return $local_tokens; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // No social tokens found in the format we accept or it was empty |
| 191 | - if ( empty( $local_tokens ) || ( ! isset( $local_tokens->twitter ) || ! isset( $local_tokens->facebook ) || ! isset( $local_tokens->linkedin ) ) ) { |
|
| 191 | + if (empty($local_tokens) || ( ! isset($local_tokens->twitter) || ! isset($local_tokens->facebook) || ! isset($local_tokens->linkedin))) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | global $ppp_share_settings; |
| 207 | 207 | $share_link = get_permalink( $post_id ); |
| 208 | 208 | |
| 209 | - if ( ppp_link_tracking_enabled() ) { |
|
| 209 | + if (ppp_link_tracking_enabled()) { |
|
| 210 | 210 | $share_link = ppp_generate_link_tracking( $share_link, $post_id, $name ); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( ppp_is_shortener_enabled() && $scheduled ) { |
|
| 213 | + if (ppp_is_shortener_enabled() && $scheduled) { |
|
| 214 | 214 | $shortener_name = $ppp_share_settings['shortener']; |
| 215 | - $share_link = apply_filters( 'ppp_apply_shortener-' . $shortener_name, $share_link ); |
|
| 215 | + $share_link = apply_filters( 'ppp_apply_shortener-'.$shortener_name, $share_link ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | * @return string The URL to post, with proper analytics applied if necessary |
| 228 | 228 | */ |
| 229 | 229 | function ppp_generate_link_tracking( $share_link, $post_id, $name ) { |
| 230 | - if ( ppp_link_tracking_enabled() ) { |
|
| 230 | + if (ppp_link_tracking_enabled()) { |
|
| 231 | 231 | global $ppp_share_settings; |
| 232 | 232 | $link_tracking_type = $ppp_share_settings['analytics']; |
| 233 | 233 | |
| 234 | 234 | // Given the setting name, devs can extend this and apply a filter of ppp_analytics-[setting value] |
| 235 | 235 | // to apply their own rules for link tracking |
| 236 | - $share_link = apply_filters( 'ppp_analytics-' . $link_tracking_type, $share_link, $post_id, $name ); |
|
| 236 | + $share_link = apply_filters( 'ppp_analytics-'.$link_tracking_type, $share_link, $post_id, $name ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $share_link = apply_filters( 'ppp_generate_link_tracking', $share_link, $post_id, $name ); |
@@ -249,14 +249,14 @@ discard block |
||
| 249 | 249 | * @return mixed If a thumbnail is found returns the URL, otherwise returns false |
| 250 | 250 | */ |
| 251 | 251 | function ppp_post_has_media( $post_id, $network, $use_media, $attachment_id = false ) { |
| 252 | - if ( !$use_media || empty( $post_id ) || empty( $network ) ) { |
|
| 252 | + if ( ! $use_media || empty($post_id) || empty($network)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $thumb_id = empty( $attachment_id ) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
| 257 | - $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-' . $network . '-share-image', true ); |
|
| 256 | + $thumb_id = empty($attachment_id) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
| 257 | + $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-'.$network.'-share-image', true ); |
|
| 258 | 258 | |
| 259 | - if ( isset( $thumb_url[0] ) && ! empty( $thumb_url[0] ) && !strpos( $thumb_url[0], 'wp-includes/images/media/default.png' ) ) { |
|
| 259 | + if (isset($thumb_url[0]) && ! empty($thumb_url[0]) && ! strpos( $thumb_url[0], 'wp-includes/images/media/default.png' )) { |
|
| 260 | 260 | return $thumb_url[0]; |
| 261 | 261 | } |
| 262 | 262 | |