@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Checks to see if a session is set and it's appropriate to start one, and starts it if necessary |
| 10 | - * @return void |
|
| 10 | + * @return boolean |
|
| 11 | 11 | */ |
| 12 | 12 | function ppp_maybe_start_session() { |
| 13 | 13 | if( !class_exists( 'TwitterOAuth' ) ) { |
@@ -77,6 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Strips slashes and html_entities_decode for sending to the networks. |
| 80 | + * @param string $string |
|
| 80 | 81 | */ |
| 81 | 82 | function ppp_entities_and_slashes( $string ) { |
| 82 | 83 | return stripslashes( html_entity_decode( $string, ENT_COMPAT, 'UTF-8' ) ); |
@@ -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 ) ) && ! isset( $_SESSION ) ) { |
|
| 18 | + if ((is_admin() || (defined( 'DOING_CRON' ) && DOING_CRON)) && ! isset($_SESSION)) { |
|
| 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 | |
@@ -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,14 +59,14 @@ 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 ( ! empty( $_REQUEST['oauth_verifier'] ) ) { |
|
| 62 | + if ( ! empty($_REQUEST['oauth_verifier'])) { |
|
| 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 | |
@@ -78,13 +78,13 @@ discard block |
||
| 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; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $this->ppp_load_twitter(); |
| 101 | 101 | |
| 102 | 102 | global $ppp_social_settings; |
| 103 | - if ( isset( $ppp_social_settings['twitter'] ) ) { |
|
| 103 | + if (isset($ppp_social_settings['twitter'])) { |
|
| 104 | 104 | |
| 105 | 105 | $this->twitter = new TwitterOAuth( |
| 106 | 106 | PPP_TW_CONSUMER_KEY, |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $ppp_social_settings['twitter']['user']->accessToken['oauth_token_secret'] |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 113 | - if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) { |
|
| 114 | - foreach ( $response->errors as $error ) { |
|
| 115 | - if ( $error->code == 89 ) { // Expired or revoked tokens |
|
| 116 | - unset( $ppp_social_settings['twitter'] ); |
|
| 112 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 113 | + if (is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0) { |
|
| 114 | + foreach ($response->errors as $error) { |
|
| 115 | + if ($error->code == 89) { // Expired or revoked tokens |
|
| 116 | + unset($ppp_social_settings['twitter']); |
|
| 117 | 117 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 118 | 118 | |
| 119 | 119 | return array( 'error' => __( 'Post Promoter Pro has been removed from your Twitter account. Please reauthorize to continue promoting your content.', 'ppp-txt' ) ); |
@@ -129,23 +129,23 @@ discard block |
||
| 129 | 129 | * Get auth url for twitter |
| 130 | 130 | * |
| 131 | 131 | */ |
| 132 | - public function ppp_get_twitter_auth_url ( $return_url = '' ) { |
|
| 132 | + public function ppp_get_twitter_auth_url( $return_url = '' ) { |
|
| 133 | 133 | |
| 134 | - if ( empty( $return_url ) ) { |
|
| 134 | + if (empty($return_url)) { |
|
| 135 | 135 | $return_url = admin_url( 'admin.php?page=ppp-social-settings' ); |
| 136 | 136 | } |
| 137 | 137 | //load twitter class |
| 138 | 138 | $twitter = $this->ppp_load_twitter(); |
| 139 | 139 | |
| 140 | 140 | //check twitter class is loaded or not |
| 141 | - if( !$twitter ) { |
|
| 141 | + if ( ! $twitter) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $request_token = $this->twitter->getRequestToken( 'oob' ); |
| 146 | 146 | |
| 147 | 147 | // If last connection failed don't display authorization link. |
| 148 | - switch( $this->twitter->http_code ) { |
|
| 148 | + switch ($this->twitter->http_code) { |
|
| 149 | 149 | |
| 150 | 150 | case 200: |
| 151 | 151 | $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function ppp_tweet( $message = '', $media = null ) { |
| 165 | - if ( empty( $message ) ) { |
|
| 165 | + if (empty($message)) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $verify = $this->ppp_verify_twitter_credentials(); |
| 170 | - if ( $verify === true ) { |
|
| 170 | + if ($verify === true) { |
|
| 171 | 171 | $args = array(); |
| 172 | - if ( ! empty( $media ) ) { |
|
| 172 | + if ( ! empty($media)) { |
|
| 173 | 173 | $endpoint = 'statuses/update_with_media'; |
| 174 | 174 | $args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) ); |
| 175 | 175 | } 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' ) . '" /> <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' ).'" /> <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,26 +106,26 @@ 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 | - if ( ! empty( $_POST['ppp_user_auth'] ) ) { |
|
| 123 | + if ( ! empty($_POST['ppp_user_auth'])) { |
|
| 124 | 124 | $twitter = new PPP_Twitter; |
| 125 | 125 | $twitter->ppp_initialize_twitter(); |
| 126 | 126 | $settings = get_option( 'ppp_social_settings', true ); |
| 127 | 127 | |
| 128 | - if ( ! empty( $settings['twitter']['user']->id ) ) { |
|
| 128 | + if ( ! empty($settings['twitter']['user']->id)) { |
|
| 129 | 129 | echo 1; |
| 130 | 130 | } else { |
| 131 | 131 | echo 0; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $twitter->init(); |
| 136 | 136 | |
| 137 | 137 | $user = get_user_meta( get_current_user_id(), '_ppp_twitter_data', true ); |
| 138 | - if ( ! empty( $user['user']->id ) ) { |
|
| 138 | + if ( ! empty($user['user']->id)) { |
|
| 139 | 139 | echo 1; |
| 140 | 140 | } else { |
| 141 | 141 | echo 0; |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | * @return void |
| 152 | 152 | */ |
| 153 | 153 | function ppp_capture_twitter_oauth() { |
| 154 | - if ( isset( $_REQUEST['oauth_verifier'] ) && isset( $_REQUEST['oauth_token'] ) ) { |
|
| 154 | + if (isset($_REQUEST['oauth_verifier']) && isset($_REQUEST['oauth_token'])) { |
|
| 155 | 155 | $current_screen = get_current_screen(); |
| 156 | - if ( 'user-edit' === $current_screen->base ) { |
|
| 157 | - $user_id = ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ? $_GET['user_id'] : false; |
|
| 156 | + if ('user-edit' === $current_screen->base) { |
|
| 157 | + $user_id = ! empty($_GET['user_id']) && is_numeric( $_GET['user_id'] ) ? $_GET['user_id'] : false; |
|
| 158 | 158 | $twitter = new PPP_Twitter_User( $user_id ); |
| 159 | 159 | $twitter->init(); |
| 160 | - $redirect = admin_url( 'user-edit.php?updated=1&user_id=' . $user_id ); |
|
| 160 | + $redirect = admin_url( 'user-edit.php?updated=1&user_id='.$user_id ); |
|
| 161 | 161 | } else { |
| 162 | 162 | global $ppp_twitter_oauth; |
| 163 | 163 | $ppp_twitter_oauth->ppp_initialize_twitter(); |
@@ -175,17 +175,17 @@ discard block |
||
| 175 | 175 | * @return void |
| 176 | 176 | */ |
| 177 | 177 | function ppp_disconnect_twitter() { |
| 178 | - if ( ! empty( $_GET['user_id'] ) ) { |
|
| 178 | + if ( ! empty($_GET['user_id'])) { |
|
| 179 | 179 | $user_id = (int) sanitize_text_field( $_GET['user_id'] ); |
| 180 | - if ( $user_id !== get_current_user_id() || ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 180 | + if ($user_id !== get_current_user_id() || ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 181 | 181 | wp_die( __( 'Unable to disconnect Twitter account', 'ppp-txt' ) ); |
| 182 | 182 | } |
| 183 | 183 | delete_user_meta( $user_id, '_ppp_twitter_data' ); |
| 184 | 184 | } else { |
| 185 | 185 | global $ppp_social_settings; |
| 186 | 186 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 187 | - if ( isset( $ppp_social_settings['twitter'] ) ) { |
|
| 188 | - unset( $ppp_social_settings['twitter'] ); |
|
| 187 | + if (isset($ppp_social_settings['twitter'])) { |
|
| 188 | + unset($ppp_social_settings['twitter']); |
|
| 189 | 189 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -216,12 +216,12 @@ discard block |
||
| 216 | 216 | global $ppp_options, $wp_logs, $wp_filter; |
| 217 | 217 | |
| 218 | 218 | $post_meta = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 219 | - $this_share = $post_meta[ $index ]; |
|
| 220 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 219 | + $this_share = $post_meta[$index]; |
|
| 220 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 221 | 221 | |
| 222 | 222 | $share_message = ppp_tw_build_share_message( $post_id, $name ); |
| 223 | 223 | |
| 224 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 224 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 225 | 225 | $media = $this_share['image']; |
| 226 | 226 | } else { |
| 227 | 227 | $use_media = ppp_tw_use_media( $post_id, $index ); |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | update_post_meta( $log_entry, '_ppp_share_status', $status ); |
| 250 | 250 | |
| 251 | - if ( ! empty( $status->id_str ) ) { |
|
| 251 | + if ( ! empty($status->id_str)) { |
|
| 252 | 252 | $post = get_post( $post_id ); |
| 253 | 253 | $author_id = $post->post_author; |
| 254 | 254 | $author_rt = get_user_meta( $author_id, '_ppp_share_scheduled', true ); |
| 255 | 255 | |
| 256 | - if ( $author_rt ) { |
|
| 256 | + if ($author_rt) { |
|
| 257 | 257 | $twitter_user = new PPP_Twitter_User( $author_id ); |
| 258 | 258 | $twitter_user->retweet( $status->id_str ); |
| 259 | 259 | } |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | $other_rt = get_users( $args ); |
| 276 | 276 | |
| 277 | - if ( $other_rt ){ |
|
| 278 | - foreach ( $other_rt as $user ) { |
|
| 277 | + if ($other_rt) { |
|
| 278 | + foreach ($other_rt as $user) { |
|
| 279 | 279 | $twitter_user = new PPP_Twitter_User( $user->ID ); |
| 280 | 280 | $twitter_user->retweet( $status->id_str ); |
| 281 | 281 | } |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | function ppp_tw_build_share_message( $post_id, $name, $scheduled = true, $include_link = true ) { |
| 296 | 296 | $share_content = ppp_tw_generate_share_content( $post_id, $name, $scheduled ); |
| 297 | 297 | |
| 298 | - if ( $include_link ) { |
|
| 298 | + if ($include_link) { |
|
| 299 | 299 | $share_link = ppp_generate_link( $post_id, $name, $scheduled ); |
| 300 | - $share_content = $share_content . ' ' . $share_link; |
|
| 300 | + $share_content = $share_content.' '.$share_link; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | return apply_filters( 'ppp_tw_build_share_message', $share_content ); |
@@ -311,22 +311,22 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | function ppp_tw_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 313 | 313 | global $ppp_options; |
| 314 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 314 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 315 | 315 | $ppp_tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 316 | 316 | |
| 317 | - if ( ! empty( $ppp_tweets ) ) { |
|
| 317 | + if ( ! empty($ppp_tweets)) { |
|
| 318 | 318 | $name_array = explode( '_', $name ); |
| 319 | 319 | $index = $name_array[1]; |
| 320 | - if ( isset( $ppp_tweets[ $index ] ) ) { |
|
| 321 | - $share_content = $ppp_tweets[ $index ]['text']; |
|
| 320 | + if (isset($ppp_tweets[$index])) { |
|
| 321 | + $share_content = $ppp_tweets[$index]['text']; |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // If an override was found, use it, otherwise try the default text content |
| 326 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 326 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 327 | 327 | |
| 328 | 328 | // If the content is still empty, just use the post title |
| 329 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 329 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 330 | 330 | |
| 331 | 331 | return apply_filters( 'ppp_share_content', $share_content, array( 'post_id' => $post_id ) ); |
| 332 | 332 | } |
@@ -338,12 +338,12 @@ discard block |
||
| 338 | 338 | * @return bool Whether or not this tweet should contain a media post |
| 339 | 339 | */ |
| 340 | 340 | function ppp_tw_use_media( $post_id, $index ) { |
| 341 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 341 | + if (empty($post_id) || empty($index)) { |
|
| 342 | 342 | return false; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $share_data = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 346 | - $use_media = ! empty( $share_data[$index]['attachment_id'] ) || ! empty( $share_data[$index]['image'] ) ? true : false; |
|
| 346 | + $use_media = ! empty($share_data[$index]['attachment_id']) || ! empty($share_data[$index]['image']) ? true : false; |
|
| 347 | 347 | |
| 348 | 348 | return $use_media; |
| 349 | 349 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return void |
| 355 | 355 | */ |
| 356 | 356 | function ppp_set_tw_token_constants( $social_tokens ) { |
| 357 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'twitter' ) ) { |
|
| 357 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'twitter' )) { |
|
| 358 | 358 | define( 'PPP_TW_CONSUMER_KEY', $social_tokens->twitter->consumer_token ); |
| 359 | 359 | define( 'PPP_TW_CONSUMER_SECRET', $social_tokens->twitter->consumer_secret ); |
| 360 | 360 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | function ppp_tw_add_meta_tab( $tabs ) { |
| 394 | 394 | global $ppp_social_settings; |
| 395 | - if ( !isset( $ppp_social_settings['twitter'] ) ) { |
|
| 395 | + if ( ! isset($ppp_social_settings['twitter'])) { |
|
| 396 | 396 | return $tabs; |
| 397 | 397 | } |
| 398 | 398 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | */ |
| 410 | 410 | function ppp_tw_register_metabox_content( $content ) { |
| 411 | 411 | global $ppp_social_settings; |
| 412 | - if ( !isset( $ppp_social_settings['twitter'] ) ) { |
|
| 412 | + if ( ! isset($ppp_social_settings['twitter'])) { |
|
| 413 | 413 | return $content; |
| 414 | 414 | } |
| 415 | 415 | |
@@ -468,16 +468,16 @@ discard block |
||
| 468 | 468 | <tbody> |
| 469 | 469 | <?php ppp_render_tweet_share_on_publish_row(); ?> |
| 470 | 470 | <?php $tweets = get_post_meta( $post->ID, '_ppp_tweets', true ); ?> |
| 471 | - <?php if ( ! empty( $tweets ) ) : ?> |
|
| 471 | + <?php if ( ! empty($tweets)) : ?> |
|
| 472 | 472 | |
| 473 | - <?php foreach ( $tweets as $key => $value ) : |
|
| 474 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 475 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 476 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 477 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 478 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 473 | + <?php foreach ($tweets as $key => $value) : |
|
| 474 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 475 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 476 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 477 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 478 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 479 | 479 | |
| 480 | - $args = apply_filters( 'ppp_tweet_row_args', compact( 'date','time','text','image','attachment_id' ), $value ); |
|
| 480 | + $args = apply_filters( 'ppp_tweet_row_args', compact( 'date', 'time', 'text', 'image', 'attachment_id' ), $value ); |
|
| 481 | 481 | ?> |
| 482 | 482 | |
| 483 | 483 | <?php ppp_render_tweet_row( $key, $args, $post->ID ); ?> |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | <?php endforeach; ?> |
| 487 | 487 | |
| 488 | 488 | <?php |
| 489 | - if ( ! empty( $has_past_shares ) && count ( $tweets ) == $has_past_shares ) { |
|
| 489 | + if ( ! empty($has_past_shares) && count( $tweets ) == $has_past_shares) { |
|
| 490 | 490 | $args = array( |
| 491 | 491 | 'date' => '', |
| 492 | 492 | 'time' => '', |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | <tr class="ppp-add-repeatable-wrapper"> |
| 510 | 510 | <td class="submit" colspan="4" style="float: none; clear:both; background:#fff;"> |
| 511 | 511 | <a class="button-secondary ppp-add-repeatable" style="margin: 6px 0;"><?php _e( 'Add New Tweet', 'ppp-txt' ); ?></a> |
| 512 | - <?php if ( ! empty( $has_past_shares ) ) : ?> |
|
| 512 | + <?php if ( ! empty($has_past_shares)) : ?> |
|
| 513 | 513 | <a class="button-secondary ppp-view-all" style="margin: 6px 0;"><?php _e( 'Toggle Past Tweets', 'ppp-txt' ); ?></a> |
| 514 | 514 | <?php endif; ?> |
| 515 | 515 | </td> |
@@ -535,38 +535,38 @@ discard block |
||
| 535 | 535 | */ |
| 536 | 536 | function ppp_render_tweet_share_on_publish_row() { |
| 537 | 537 | global $post, $ppp_share_settings; |
| 538 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 538 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 539 | 539 | |
| 540 | 540 | $ppp_post_exclude = get_post_meta( $post->ID, '_ppp_post_exclude', true ); |
| 541 | 541 | |
| 542 | 542 | $ppp_share_on_publish = get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
| 543 | 543 | $show_share_on_publish = false; |
| 544 | 544 | |
| 545 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['twitter'] ) ? false : true; |
|
| 545 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['twitter']) ? false : true; |
|
| 546 | 546 | |
| 547 | - if ( $ppp_share_on_publish == '1' || ( $ppp_share_on_publish == '' && $share_by_default ) ) { |
|
| 547 | + if ($ppp_share_on_publish == '1' || ($ppp_share_on_publish == '' && $share_by_default)) { |
|
| 548 | 548 | $show_share_on_publish = true; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $ppp_share_on_publish_text = get_post_meta( $post->ID, '_ppp_share_on_publish_text', true ); |
| 552 | 552 | $ppp_share_on_publish_include_image = get_post_meta( $post->ID, '_ppp_share_on_publish_include_image', true ); |
| 553 | 553 | |
| 554 | - $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; |
|
| 554 | + $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; |
|
| 555 | 555 | ?> |
| 556 | 556 | <tr class="ppp-tweet-wrapper ppp-repeatable-row on-publish-row"> |
| 557 | 557 | <td colspan="2" class="ppp-on-plublish-date-column"> |
| 558 | - <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 ); ?> /> |
|
| 558 | + <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 | 559 | <label for="ppp_share_on_publish"><?php _e( 'Tweet On Publish', 'ppp-txt' ); ?></label> |
| 560 | 560 | </td> |
| 561 | 561 | |
| 562 | 562 | <td> |
| 563 | - <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> |
|
| 564 | - <?php $length = ! empty( $ppp_share_on_publish_text ) ? strlen( $ppp_share_on_publish_text ) : 0; ?> |
|
| 563 | + <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> |
|
| 564 | + <?php $length = ! empty($ppp_share_on_publish_text) ? strlen( $ppp_share_on_publish_text ) : 0; ?> |
|
| 565 | 565 | <span class="ppp-text-length"><?php echo $length; ?></span> |
| 566 | 566 | </td> |
| 567 | 567 | |
| 568 | 568 | <td style="width: 200px" colspan="2"> |
| 569 | - <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 ); ?>/> |
|
| 569 | + <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 | 570 | <label for="ppp-share-on-publish-image"><?php _e( 'Featured Image', 'ppp-txt' ); ?></label> |
| 571 | 571 | </td> |
| 572 | 572 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | function ppp_render_tweet_row( $key, $args = array(), $post_id ) { |
| 586 | 586 | global $post, $has_past_shares; |
| 587 | 587 | |
| 588 | - if ( ! empty( $args['date'] ) && ! empty( $args['time'] ) ) { |
|
| 588 | + if ( ! empty($args['date']) && ! empty($args['time'])) { |
|
| 589 | 589 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 590 | 590 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 591 | 591 | } else { |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | $readonly = false; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 597 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 598 | - $shared = ! empty( $readonly ) ? 'past-share' : ''; |
|
| 596 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 597 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 598 | + $shared = ! empty($readonly) ? 'past-share' : ''; |
|
| 599 | 599 | |
| 600 | - if ( ! empty( $readonly ) ) { |
|
| 600 | + if ( ! empty($readonly)) { |
|
| 601 | 601 | $has_past_shares++; |
| 602 | 602 | } |
| 603 | 603 | ?> |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | <td> |
| 614 | 614 | <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> |
| 615 | - <?php $length = ! empty( $args['text'] ) ? strlen( $args['text'] ) : 0; ?> |
|
| 615 | + <?php $length = ! empty($args['text']) ? strlen( $args['text'] ) : 0; ?> |
|
| 616 | 616 | <span class="ppp-text-length"><?php echo $length; ?></span> |
| 617 | 617 | </td> |
| 618 | 618 | |
@@ -647,24 +647,24 @@ discard block |
||
| 647 | 647 | */ |
| 648 | 648 | function ppp_tw_save_post_meta_boxes( $post_id, $post ) { |
| 649 | 649 | |
| 650 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 650 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 651 | 651 | return; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - $ppp_post_exclude = ( isset( $_REQUEST['_ppp_post_exclude'] ) ) ? $_REQUEST['_ppp_post_exclude'] : '0'; |
|
| 654 | + $ppp_post_exclude = (isset($_REQUEST['_ppp_post_exclude'])) ? $_REQUEST['_ppp_post_exclude'] : '0'; |
|
| 655 | 655 | |
| 656 | - $ppp_share_on_publish = ( isset( $_REQUEST['_ppp_share_on_publish'] ) ) ? $_REQUEST['_ppp_share_on_publish'] : '0'; |
|
| 657 | - $ppp_share_on_publish_text = ( isset( $_REQUEST['_ppp_share_on_publish_text'] ) ) ? $_REQUEST['_ppp_share_on_publish_text'] : ''; |
|
| 658 | - $ppp_share_on_publish_include_image = ( isset( $_REQUEST['_ppp_share_on_publish_include_image'] ) ) ? $_REQUEST['_ppp_share_on_publish_include_image'] : ''; |
|
| 656 | + $ppp_share_on_publish = (isset($_REQUEST['_ppp_share_on_publish'])) ? $_REQUEST['_ppp_share_on_publish'] : '0'; |
|
| 657 | + $ppp_share_on_publish_text = (isset($_REQUEST['_ppp_share_on_publish_text'])) ? $_REQUEST['_ppp_share_on_publish_text'] : ''; |
|
| 658 | + $ppp_share_on_publish_include_image = (isset($_REQUEST['_ppp_share_on_publish_include_image'])) ? $_REQUEST['_ppp_share_on_publish_include_image'] : ''; |
|
| 659 | 659 | |
| 660 | 660 | |
| 661 | 661 | update_post_meta( $post_id, '_ppp_share_on_publish', $ppp_share_on_publish ); |
| 662 | 662 | update_post_meta( $post_id, '_ppp_share_on_publish_text', $ppp_share_on_publish_text ); |
| 663 | 663 | update_post_meta( $post_id, '_ppp_share_on_publish_include_image', $ppp_share_on_publish_include_image ); |
| 664 | 664 | |
| 665 | - $tweet_data = isset( $_REQUEST['_ppp_tweets'] ) ? $_REQUEST['_ppp_tweets'] : array(); |
|
| 666 | - foreach ( $tweet_data as $index => $tweet ) { |
|
| 667 | - $tweet_data[ $index ]['text'] = sanitize_text_field( $tweet['text'] ); |
|
| 665 | + $tweet_data = isset($_REQUEST['_ppp_tweets']) ? $_REQUEST['_ppp_tweets'] : array(); |
|
| 666 | + foreach ($tweet_data as $index => $tweet) { |
|
| 667 | + $tweet_data[$index]['text'] = sanitize_text_field( $tweet['text'] ); |
|
| 668 | 668 | } |
| 669 | 669 | update_post_meta( $post_id, '_ppp_tweets', $tweet_data ); |
| 670 | 670 | |
@@ -681,29 +681,29 @@ discard block |
||
| 681 | 681 | function ppp_tw_share_on_publish( $new_status, $old_status, $post ) { |
| 682 | 682 | global $ppp_options; |
| 683 | 683 | |
| 684 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
|
| 685 | - $from_post = isset( $_POST['_ppp_share_on_publish'] ); |
|
| 684 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_share_on_publish', true ); |
|
| 685 | + $from_post = isset($_POST['_ppp_share_on_publish']); |
|
| 686 | 686 | |
| 687 | - if ( empty( $from_meta ) && empty( $from_post ) ) { |
|
| 687 | + if (empty($from_meta) && empty($from_post)) { |
|
| 688 | 688 | return; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | // Determine if we're seeing the share on publish in meta or $_POST |
| 692 | - if ( $from_meta && !$from_post ) { |
|
| 692 | + if ($from_meta && ! $from_post) { |
|
| 693 | 693 | $ppp_share_on_publish_text = get_post_meta( $post->ID, '_ppp_share_on_publish_text', true ); |
| 694 | 694 | $use_media = get_post_meta( $post->ID, '_ppp_share_on_publish_include_image', true ); |
| 695 | 695 | } else { |
| 696 | - $ppp_share_on_publish_text = isset( $_POST['_ppp_share_on_publish_text'] ) ? $_POST['_ppp_share_on_publish_text'] : ''; |
|
| 697 | - $use_media = isset( $_POST['_ppp_share_on_publish_include_image'] ) ? $_POST['_ppp_share_on_publish_include_image'] : false; |
|
| 696 | + $ppp_share_on_publish_text = isset($_POST['_ppp_share_on_publish_text']) ? $_POST['_ppp_share_on_publish_text'] : ''; |
|
| 697 | + $use_media = isset($_POST['_ppp_share_on_publish_include_image']) ? $_POST['_ppp_share_on_publish_include_image'] : false; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - $share_content = ( !empty( $ppp_share_on_publish_text ) ) ? $ppp_share_on_publish_text : ppp_tw_generate_share_content( $post->ID, null, false ); |
|
| 700 | + $share_content = ( ! empty($ppp_share_on_publish_text)) ? $ppp_share_on_publish_text : ppp_tw_generate_share_content( $post->ID, null, false ); |
|
| 701 | 701 | $share_content = apply_filters( 'ppp_share_content', $share_content, array( 'post_id' => $post->ID ) ); |
| 702 | - $name = 'sharedate_0_' . $post->ID; |
|
| 702 | + $name = 'sharedate_0_'.$post->ID; |
|
| 703 | 703 | $media = ppp_post_has_media( $post->ID, 'tw', $use_media ); |
| 704 | 704 | $share_link = ppp_generate_link( $post->ID, $name, true ); |
| 705 | 705 | |
| 706 | - $status = ppp_send_tweet( $share_content . ' ' . $share_link, $post->ID, $media ); |
|
| 706 | + $status = ppp_send_tweet( $share_content.' '.$share_link, $post->ID, $media ); |
|
| 707 | 707 | |
| 708 | 708 | $log_title = ppp_tw_build_share_message( $post->ID, $name, false, false ); |
| 709 | 709 | |
@@ -721,11 +721,11 @@ discard block |
||
| 721 | 721 | |
| 722 | 722 | $log_entry = WP_Logging::insert_log( $log_data, $log_meta ); |
| 723 | 723 | |
| 724 | - if ( ! empty( $status->id_str ) ) { |
|
| 724 | + if ( ! empty($status->id_str)) { |
|
| 725 | 725 | $author_id = $post->post_author; |
| 726 | 726 | $author_rt = get_user_meta( $author_id, '_ppp_share_on_publish', true ); |
| 727 | 727 | |
| 728 | - if ( $author_rt ) { |
|
| 728 | + if ($author_rt) { |
|
| 729 | 729 | $twitter_user = new PPP_Twitter_User( $author_id ); |
| 730 | 730 | $twitter_user->retweet( $status->id_str ); |
| 731 | 731 | } |
@@ -746,8 +746,8 @@ discard block |
||
| 746 | 746 | ); |
| 747 | 747 | $other_rt = get_users( $args ); |
| 748 | 748 | |
| 749 | - if ( $other_rt ){ |
|
| 750 | - foreach ( $other_rt as $user ) { |
|
| 749 | + if ($other_rt) { |
|
| 750 | + foreach ($other_rt as $user) { |
|
| 751 | 751 | $twitter_user = new PPP_Twitter_User( $user->ID ); |
| 752 | 752 | $twitter_user->retweet( $status->id_str ); |
| 753 | 753 | } |
@@ -768,20 +768,20 @@ discard block |
||
| 768 | 768 | function ppp_tw_generate_timestamps( $times, $post_id ) { |
| 769 | 769 | $ppp_tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 770 | 770 | |
| 771 | - if ( empty( $ppp_tweets ) ) { |
|
| 771 | + if (empty($ppp_tweets)) { |
|
| 772 | 772 | $ppp_tweets = array(); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - foreach ( $ppp_tweets as $key => $data ) { |
|
| 776 | - if ( ! array_filter( $data ) ) { |
|
| 775 | + foreach ($ppp_tweets as $key => $data) { |
|
| 776 | + if ( ! array_filter( $data )) { |
|
| 777 | 777 | continue; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 781 | 781 | |
| 782 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 783 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_tw'; |
|
| 784 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_tw'; |
|
| 782 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 783 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_tw'; |
|
| 784 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_tw'; |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | } |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $ret = false; |
| 803 | 803 | |
| 804 | - if ( ! empty( $ppp_share_settings['twitter']['cards_enabled'] ) ) { |
|
| 804 | + if ( ! empty($ppp_share_settings['twitter']['cards_enabled'])) { |
|
| 805 | 805 | $ret = true; |
| 806 | 806 | } |
| 807 | 807 | |
@@ -816,13 +816,13 @@ discard block |
||
| 816 | 816 | */ |
| 817 | 817 | function ppp_tw_card_meta() { |
| 818 | 818 | |
| 819 | - if ( ! is_single() || ! ppp_twitter_enabled() || ! ppp_tw_cards_enabled() ) { |
|
| 819 | + if ( ! is_single() || ! ppp_twitter_enabled() || ! ppp_tw_cards_enabled()) { |
|
| 820 | 820 | return; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | global $post, $ppp_options; |
| 824 | 824 | |
| 825 | - if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] ) ) { |
|
| 825 | + if ( ! array_key_exists( $post->post_type, $ppp_options['post_types'] )) { |
|
| 826 | 826 | return; |
| 827 | 827 | } |
| 828 | 828 | |
@@ -840,20 +840,20 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | $return = ''; |
| 842 | 842 | |
| 843 | - if ( ! is_single() || ! ppp_tw_cards_enabled() ) { |
|
| 843 | + if ( ! is_single() || ! ppp_tw_cards_enabled()) { |
|
| 844 | 844 | return $return; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | global $post, $ppp_social_settings; |
| 848 | 848 | |
| 849 | 849 | |
| 850 | - if ( empty( $post ) ) { |
|
| 850 | + if (empty($post)) { |
|
| 851 | 851 | return; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | $elements = ppp_tw_default_meta_elements(); |
| 855 | - foreach ( $elements as $name => $content ) { |
|
| 856 | - $return .= '<meta name="' . $name . '" content="' . $content . '" />' . "\n"; |
|
| 855 | + foreach ($elements as $name => $content) { |
|
| 856 | + $return .= '<meta name="'.$name.'" content="'.$content.'" />'."\n"; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | return apply_filters( 'ppp_tw_card_meta', $return ); |
@@ -873,15 +873,15 @@ discard block |
||
| 873 | 873 | $elements = array(); |
| 874 | 874 | |
| 875 | 875 | $image_url = ppp_post_has_media( $post->ID, 'tw', true ); |
| 876 | - if ( $image_url ) { |
|
| 876 | + if ($image_url) { |
|
| 877 | 877 | $elements['twitter:card'] = 'summary_large_image'; |
| 878 | 878 | $elements['twitter:image:src'] = $image_url; |
| 879 | 879 | |
| 880 | 880 | $thumb_id = ppp_get_attachment_id_from_image_url( $image_url ); |
| 881 | - if ( ! empty( $thumb_id ) ) { |
|
| 881 | + if ( ! empty($thumb_id)) { |
|
| 882 | 882 | $alt_text = ppp_get_attachment_alt_text( $thumb_id ); |
| 883 | 883 | // When adding media via the WP Uploader, any 'alt text' supplied will be used as the accessible alt text. |
| 884 | - if ( ! empty( $alt_text ) ) { |
|
| 884 | + if ( ! empty($alt_text)) { |
|
| 885 | 885 | $elements['twitter:image:alt'] = esc_attr( $alt_text ); |
| 886 | 886 | } |
| 887 | 887 | } |
@@ -889,15 +889,15 @@ discard block |
||
| 889 | 889 | $elements['twitter:card'] = 'summary'; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - $elements['twitter:site'] = '@' . $ppp_social_settings['twitter']['user']->screen_name; |
|
| 892 | + $elements['twitter:site'] = '@'.$ppp_social_settings['twitter']['user']->screen_name; |
|
| 893 | 893 | $elements['twitter:title'] = esc_attr( strip_tags( $post->post_title ) ); |
| 894 | 894 | $elements['twitter:description'] = esc_attr( ppp_tw_get_card_description() ); |
| 895 | 895 | |
| 896 | 896 | $author_twitter_handle = get_user_meta( $post->post_author, 'twitter', true ); |
| 897 | - if ( ! empty( $author_twitter_handle ) ) { |
|
| 897 | + if ( ! empty($author_twitter_handle)) { |
|
| 898 | 898 | |
| 899 | - if ( strpos( $author_twitter_handle, '@' ) === false ) { |
|
| 900 | - $author_twitter_handle = '@' . $author_twitter_handle; |
|
| 899 | + if (strpos( $author_twitter_handle, '@' ) === false) { |
|
| 900 | + $author_twitter_handle = '@'.$author_twitter_handle; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | $elements['twitter:creator'] = esc_attr( strip_tags( $author_twitter_handle ) ); |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | function ppp_tw_get_card_description() { |
| 917 | 917 | global $post; |
| 918 | 918 | |
| 919 | - if ( ! is_single() || empty( $post ) ) { |
|
| 919 | + if ( ! is_single() || empty($post)) { |
|
| 920 | 920 | return false; |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | $excerpt = $post->post_excerpt; |
| 924 | 924 | |
| 925 | - if ( empty( $excerpt ) ) { |
|
| 925 | + if (empty($excerpt)) { |
|
| 926 | 926 | $excerpt = ppp_tw_format_card_description( $post->post_content ); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -940,10 +940,10 @@ discard block |
||
| 940 | 940 | $max_len = apply_filters( 'ppp_tw_cart_desc_length', 200 ); |
| 941 | 941 | $excerpt = strip_tags( $excerpt ); |
| 942 | 942 | |
| 943 | - if ( strlen( $excerpt ) > $max_len ) { |
|
| 943 | + if (strlen( $excerpt ) > $max_len) { |
|
| 944 | 944 | $excerpt_pre = substr( $excerpt, 0, $max_len ); |
| 945 | 945 | $last_space = strrpos( $excerpt_pre, ' ' ); |
| 946 | - $excerpt = substr( $excerpt_pre, 0, $last_space ) . '...'; |
|
| 946 | + $excerpt = substr( $excerpt_pre, 0, $last_space ).'...'; |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | return $excerpt; |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | */ |
| 959 | 959 | function ppp_tw_add_contact_method( $user_contactmethods ) { |
| 960 | 960 | |
| 961 | - if ( ! isset( $user_contactmethods['twitter'] ) ) { |
|
| 961 | + if ( ! isset($user_contactmethods['twitter'])) { |
|
| 962 | 962 | $user_contactmethods['twitter'] = __( 'Twitter', 'ppp-txt' ); |
| 963 | 963 | } |
| 964 | 964 | // Returns the contact methods |
@@ -977,15 +977,15 @@ discard block |
||
| 977 | 977 | function ppp_tw_profile_settings( $user ) { |
| 978 | 978 | global $ppp_social_settings; |
| 979 | 979 | |
| 980 | - if ( $user->ID == get_current_user_id() && ! current_user_can( 'edit_posts' ) ) { |
|
| 980 | + if ($user->ID == get_current_user_id() && ! current_user_can( 'edit_posts' )) { |
|
| 981 | 981 | return; |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - if ( $user->ID !== get_current_user_id() && ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
| 984 | + if ($user->ID !== get_current_user_id() && ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
| 985 | 985 | return; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if ( ! isset( $ppp_social_settings['twitter'] ) || is_null( $ppp_social_settings['twitter'] ) ) { |
|
| 988 | + if ( ! isset($ppp_social_settings['twitter']) || is_null( $ppp_social_settings['twitter'] )) { |
|
| 989 | 989 | return; |
| 990 | 990 | } |
| 991 | 991 | |
@@ -999,12 +999,12 @@ discard block |
||
| 999 | 999 | <?php |
| 1000 | 1000 | $twitter = new PPP_Twitter_User( get_current_user_id() ); |
| 1001 | 1001 | $tw_user = get_user_meta( $user->ID, '_ppp_twitter_data', true ); |
| 1002 | - if ( empty( $tw_user ) ) { |
|
| 1003 | - $tw_authurl = $twitter->get_auth_url( admin_url( 'user-edit.php?user_id=' . $user->ID ) ); |
|
| 1002 | + if (empty($tw_user)) { |
|
| 1003 | + $tw_authurl = $twitter->get_auth_url( admin_url( 'user-edit.php?user_id='.$user->ID ) ); |
|
| 1004 | 1004 | |
| 1005 | - $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>'; |
|
| 1006 | - $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>'; |
|
| 1007 | - $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' ) . '" /> <a href="#" class="button-secondary tw-oob-pin-submit">' . __( 'Submit', 'ppp-txt' ) . '</a><span class="spinner"></span></span>'; |
|
| 1005 | + $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>'; |
|
| 1006 | + $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>'; |
|
| 1007 | + $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' ).'" /> <a href="#" class="button-secondary tw-oob-pin-submit">'.__( 'Submit', 'ppp-txt' ).'</a><span class="spinner"></span></span>'; |
|
| 1008 | 1008 | $string .= '<input type="hidden" name="ppp_user_auth" value="1" />'; |
| 1009 | 1009 | |
| 1010 | 1010 | echo $string; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | ?> |
| 1014 | 1014 | <p><strong><?php _e( 'Signed in as', 'ppp-txt' ); ?>: </strong><?php echo $tw_user['user']->screen_name; ?></p> |
| 1015 | 1015 | <p> |
| 1016 | - <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> |
|
| 1016 | + <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> |
|
| 1017 | 1017 | <a class="button-secondary" href="https://twitter.com/settings/applications" target="blank"><?php _e( 'Revoke Access via Twitter', 'ppp-txt' ); ?></a> |
| 1018 | 1018 | </p> |
| 1019 | 1019 | <?php |
@@ -1022,12 +1022,12 @@ discard block |
||
| 1022 | 1022 | </td> |
| 1023 | 1023 | </tr> |
| 1024 | 1024 | |
| 1025 | - <?php if ( $connected ) : ?> |
|
| 1025 | + <?php if ($connected) : ?> |
|
| 1026 | 1026 | <?php |
| 1027 | 1027 | $share_on_publish = get_user_meta( $user->ID, '_ppp_share_on_publish', true ); |
| 1028 | - $share_scheduled = get_user_meta( $user->ID, '_ppp_share_scheduled' , true ); |
|
| 1028 | + $share_scheduled = get_user_meta( $user->ID, '_ppp_share_scheduled', true ); |
|
| 1029 | 1029 | $share_others_on_publish = get_user_meta( $user->ID, '_ppp_share_others_on_publish', true ); |
| 1030 | - $share_others_scheduled = get_user_meta( $user->ID, '_ppp_share_others_scheduled' , true ); |
|
| 1030 | + $share_others_scheduled = get_user_meta( $user->ID, '_ppp_share_others_scheduled', true ); |
|
| 1031 | 1031 | ?> |
| 1032 | 1032 | <tr> |
| 1033 | 1033 | <th><?php _e( 'Sharing Options', 'ppp-txt' ); ?></th> |
@@ -1075,19 +1075,19 @@ discard block |
||
| 1075 | 1075 | function ppp_tw_save_profile( $user_id ) { |
| 1076 | 1076 | global $ppp_social_settings; |
| 1077 | 1077 | |
| 1078 | - if ( ! isset( $ppp_social_settings['twitter'] ) || is_null( $ppp_social_settings['twitter'] ) ) { |
|
| 1078 | + if ( ! isset($ppp_social_settings['twitter']) || is_null( $ppp_social_settings['twitter'] )) { |
|
| 1079 | 1079 | return; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - $share_on_publish = ! empty( $_POST['share_on_publish'] ) ? true : false; |
|
| 1083 | - $share_scheduled = ! empty( $_POST['share_scheduled'] ) ? true : false; |
|
| 1084 | - $share_others_on_publish = ! empty( $_POST['share_others_on_publish'] ) ? true : false; |
|
| 1085 | - $share_others_scheduled = ! empty( $_POST['share_others_scheduled'] ) ? true : false; |
|
| 1082 | + $share_on_publish = ! empty($_POST['share_on_publish']) ? true : false; |
|
| 1083 | + $share_scheduled = ! empty($_POST['share_scheduled']) ? true : false; |
|
| 1084 | + $share_others_on_publish = ! empty($_POST['share_others_on_publish']) ? true : false; |
|
| 1085 | + $share_others_scheduled = ! empty($_POST['share_others_scheduled']) ? true : false; |
|
| 1086 | 1086 | |
| 1087 | 1087 | update_user_meta( $user_id, '_ppp_share_on_publish', $share_on_publish ); |
| 1088 | - update_user_meta( $user_id, '_ppp_share_scheduled', $share_scheduled ); |
|
| 1088 | + update_user_meta( $user_id, '_ppp_share_scheduled', $share_scheduled ); |
|
| 1089 | 1089 | update_user_meta( $user_id, '_ppp_share_others_on_publish', $share_others_on_publish ); |
| 1090 | - update_user_meta( $user_id, '_ppp_share_others_scheduled', $share_others_scheduled ); |
|
| 1090 | + update_user_meta( $user_id, '_ppp_share_others_scheduled', $share_others_scheduled ); |
|
| 1091 | 1091 | |
| 1092 | 1092 | } |
| 1093 | 1093 | add_action( 'personal_options_update', 'ppp_tw_save_profile' ); |
@@ -1096,14 +1096,14 @@ discard block |
||
| 1096 | 1096 | function ppp_tw_calendar_on_publish_event( $events, $post_id ) { |
| 1097 | 1097 | $share_on_publish = get_post_meta( $post_id, '_ppp_share_on_publish', true ); |
| 1098 | 1098 | |
| 1099 | - if ( ! empty( $share_on_publish ) ) { |
|
| 1099 | + if ( ! empty($share_on_publish)) { |
|
| 1100 | 1100 | $share_text = get_post_meta( $post_id, '_ppp_share_on_publish_text', true ); |
| 1101 | 1101 | $events[] = array( |
| 1102 | - 'id' => $post_id . '-share-on-publish', |
|
| 1103 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_tw_generate_share_content( $post_id, null, false ), |
|
| 1104 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 1105 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 1106 | - 'className' => 'ppp-calendar-item-tw cal-post-' . $post_id, |
|
| 1102 | + 'id' => $post_id.'-share-on-publish', |
|
| 1103 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_tw_generate_share_content( $post_id, null, false ), |
|
| 1104 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 1105 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 1106 | + 'className' => 'ppp-calendar-item-tw cal-post-'.$post_id, |
|
| 1107 | 1107 | 'belongsTo' => $post_id, |
| 1108 | 1108 | ); |
| 1109 | 1109 | } |
@@ -1114,9 +1114,9 @@ discard block |
||
| 1114 | 1114 | |
| 1115 | 1115 | function ppp_tw_get_post_shares( $items, $post_id ) { |
| 1116 | 1116 | $tweets = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 1117 | - if ( empty( $tweets ) ) { return $items; } |
|
| 1117 | + if (empty($tweets)) { return $items; } |
|
| 1118 | 1118 | |
| 1119 | - foreach ( $tweets as $key => $tweet ) { |
|
| 1119 | + foreach ($tweets as $key => $tweet) { |
|
| 1120 | 1120 | $items[] = array( 'id' => $key, 'service' => 'tw' ); |
| 1121 | 1121 | } |
| 1122 | 1122 | 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,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 | $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( 'oob' ); |
| 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 { |