@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | * @return void |
| 11 | 11 | */ |
| 12 | 12 | function ppp_maybe_start_session() { |
| 13 | - if( !class_exists( 'TwitterOAuth' ) ) { |
|
| 14 | - require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' ); |
|
| 13 | + if ( ! class_exists( 'TwitterOAuth' )) { |
|
| 14 | + require_once (PPP_PATH.'/includes/libs/twitter/twitteroauth.php'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $ret = false; |
| 18 | - if ( ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) && session_status() == PHP_SESSION_NONE && ! headers_sent() ) { |
|
| 18 | + if ((is_admin() || (defined( 'DOING_CRON' ) && DOING_CRON)) && session_status() == PHP_SESSION_NONE && ! headers_sent()) { |
|
| 19 | 19 | $ret = session_start(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | global $ppp_share_settings; |
| 31 | 31 | $result = false; |
| 32 | 32 | |
| 33 | - if ( isset( $ppp_share_settings['analytics'] ) && $ppp_share_settings['analytics'] !== 'none' ) { |
|
| 34 | - $result = true; |
|
| 33 | + if (isset($ppp_share_settings['analytics']) && $ppp_share_settings['analytics'] !== 'none') { |
|
| 34 | + $result = true; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return apply_filters( 'ppp_is_link_tracking_enabled', $result ); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | function ppp_is_shortener_enabled() { |
| 73 | 73 | global $ppp_share_settings; |
| 74 | 74 | |
| 75 | - return ( isset( $ppp_share_settings['shortener'] ) && !empty( $ppp_share_settings['shortener'] ) && $ppp_share_settings != '-1' ); |
|
| 75 | + return (isset($ppp_share_settings['shortener']) && ! empty($ppp_share_settings['shortener']) && $ppp_share_settings != '-1'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | $post_types = get_post_types( $post_type_args, NULL, 'and' ); |
| 105 | 105 | |
| 106 | 106 | $unsupported_post_types = array( 'wp_log', 'attachment' ); |
| 107 | - foreach ( $unsupported_post_types as $unsupported_post_type ) { |
|
| 108 | - if ( array_key_exists( $unsupported_post_type, $post_types ) ) { |
|
| 109 | - unset( $post_types[ $unsupported_post_type ] ); |
|
| 107 | + foreach ($unsupported_post_types as $unsupported_post_type) { |
|
| 108 | + if (array_key_exists( $unsupported_post_type, $post_types )) { |
|
| 109 | + unset($post_types[$unsupported_post_type]); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | function ppp_should_save( $post_id, $post ) { |
| 135 | 135 | $ret = true; |
| 136 | 136 | |
| 137 | - if ( empty( $_POST ) ) { |
|
| 137 | + if (empty($_POST)) { |
|
| 138 | 138 | $ret = false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( wp_is_post_revision( $post_id ) ) { |
|
| 141 | + if (wp_is_post_revision( $post_id )) { |
|
| 142 | 142 | $ret = false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | global $ppp_options; |
| 146 | - if ( !isset( $ppp_options['post_types'] ) || !is_array( $ppp_options['post_types'] ) || !array_key_exists( $post->post_type, $ppp_options['post_types'] ) ) { |
|
| 146 | + if ( ! isset($ppp_options['post_types']) || ! is_array( $ppp_options['post_types'] ) || ! array_key_exists( $post->post_type, $ppp_options['post_types'] )) { |
|
| 147 | 147 | $ret = false; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | function ppp_set_uploads_dir() { |
| 160 | 160 | $upload_path = ppp_get_upload_path(); |
| 161 | 161 | |
| 162 | - if ( false === get_transient( 'ppp_check_protection_files' ) ) { |
|
| 162 | + if (false === get_transient( 'ppp_check_protection_files' )) { |
|
| 163 | 163 | |
| 164 | 164 | // Make sure the /ppp folder is created |
| 165 | 165 | wp_mkdir_p( $upload_path ); |
@@ -168,22 +168,22 @@ discard block |
||
| 168 | 168 | $rules = "Options -Indexes\n"; |
| 169 | 169 | $rules .= "deny from all\n"; |
| 170 | 170 | |
| 171 | - $htaccess_exists = file_exists( $upload_path . '/.htaccess' ); |
|
| 171 | + $htaccess_exists = file_exists( $upload_path.'/.htaccess' ); |
|
| 172 | 172 | |
| 173 | - if ( $htaccess_exists ) { |
|
| 174 | - $contents = @file_get_contents( $upload_path . '/.htaccess' ); |
|
| 175 | - if ( $contents !== $rules || ! $contents ) { |
|
| 173 | + if ($htaccess_exists) { |
|
| 174 | + $contents = @file_get_contents( $upload_path.'/.htaccess' ); |
|
| 175 | + if ($contents !== $rules || ! $contents) { |
|
| 176 | 176 | // Update the .htaccess rules if they don't match |
| 177 | - @file_put_contents( $upload_path . '/.htaccess', $rules ); |
|
| 177 | + @file_put_contents( $upload_path.'/.htaccess', $rules ); |
|
| 178 | 178 | } |
| 179 | - } elseif( wp_is_writable( $upload_path ) ) { |
|
| 179 | + } elseif (wp_is_writable( $upload_path )) { |
|
| 180 | 180 | // Create the file if it doesn't exist |
| 181 | - @file_put_contents( $upload_path . '/.htaccess', $rules ); |
|
| 181 | + @file_put_contents( $upload_path.'/.htaccess', $rules ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Top level blank index.php |
| 185 | - if ( ! file_exists( $upload_path . '/index.php' ) && wp_is_writable( $upload_path ) ) { |
|
| 186 | - @file_put_contents( $upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.' ); |
|
| 185 | + if ( ! file_exists( $upload_path.'/index.php' ) && wp_is_writable( $upload_path )) { |
|
| 186 | + @file_put_contents( $upload_path.'/index.php', '<?php'.PHP_EOL.'// Silence is golden.' ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Check for the files once per day |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function ppp_get_upload_path() { |
| 202 | 202 | $wp_upload_dir = wp_upload_dir(); |
| 203 | - return $wp_upload_dir['basedir'] . '/ppp'; |
|
| 203 | + return $wp_upload_dir['basedir'].'/ppp'; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | $completed_upgrades = get_option( 'ppp_completed_upgrades' ); |
| 215 | 215 | |
| 216 | - if ( false === $completed_upgrades ) { |
|
| 216 | + if (false === $completed_upgrades) { |
|
| 217 | 217 | $completed_upgrades = array(); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function ppp_has_upgrade_completed( $upgrade_action = '' ) { |
| 232 | 232 | |
| 233 | - if ( empty( $upgrade_action ) ) { |
|
| 233 | + if (empty($upgrade_action)) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function ppp_set_upgrade_complete( $upgrade_action = '' ) { |
| 251 | 251 | |
| 252 | - if ( empty( $upgrade_action ) ) { |
|
| 252 | + if (empty($upgrade_action)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -274,48 +274,48 @@ discard block |
||
| 274 | 274 | $url = strtolower( trim( get_home_url( '/' ) ) ); |
| 275 | 275 | |
| 276 | 276 | // Need to get the host...so let's add the scheme so we can use parse_url |
| 277 | - if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) { |
|
| 278 | - $url = 'http://' . $url; |
|
| 277 | + if (false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' )) { |
|
| 278 | + $url = 'http://'.$url; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | $url_parts = parse_url( $url ); |
| 282 | - $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false; |
|
| 282 | + $host = ! empty($url_parts['host']) ? $url_parts['host'] : false; |
|
| 283 | 283 | |
| 284 | - if ( ! empty( $url ) && ! empty( $host ) ) { |
|
| 284 | + if ( ! empty($url) && ! empty($host)) { |
|
| 285 | 285 | |
| 286 | - if ( false !== ip2long( $host ) ) { |
|
| 287 | - if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { |
|
| 286 | + if (false !== ip2long( $host )) { |
|
| 287 | + if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE )) { |
|
| 288 | 288 | $is_local_url = true; |
| 289 | 289 | } |
| 290 | - } else if ( 'localhost' === $host ) { |
|
| 290 | + } else if ('localhost' === $host) { |
|
| 291 | 291 | $is_local_url = true; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $check_tlds = apply_filters( 'ppp_validate_tlds', true ); |
| 295 | - if ( $check_tlds ) { |
|
| 295 | + if ($check_tlds) { |
|
| 296 | 296 | $tlds_to_check = apply_filters( 'ppp_url_tlds', array( |
| 297 | 297 | '.dev', '.local', '.test' |
| 298 | 298 | ) ); |
| 299 | 299 | |
| 300 | - foreach ( $tlds_to_check as $tld ) { |
|
| 301 | - if ( false !== strpos( $host, $tld ) ) { |
|
| 300 | + foreach ($tlds_to_check as $tld) { |
|
| 301 | + if (false !== strpos( $host, $tld )) { |
|
| 302 | 302 | $is_local_url = true; |
| 303 | 303 | continue; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( substr_count( $host, '.' ) > 1 ) { |
|
| 308 | + if (substr_count( $host, '.' ) > 1) { |
|
| 309 | 309 | $subdomains_to_check = apply_filters( 'ppp_url_subdomains', array( |
| 310 | 310 | 'dev.', '*.staging.', |
| 311 | 311 | ) ); |
| 312 | 312 | |
| 313 | - foreach ( $subdomains_to_check as $subdomain ) { |
|
| 313 | + foreach ($subdomains_to_check as $subdomain) { |
|
| 314 | 314 | |
| 315 | 315 | $subdomain = str_replace( '.', '(.)', $subdomain ); |
| 316 | 316 | $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain ); |
| 317 | 317 | |
| 318 | - if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) { |
|
| 318 | + if (preg_match( '/^('.$subdomain.')/', $host )) { |
|
| 319 | 319 | $is_local_url = true; |
| 320 | 320 | continue; |
| 321 | 321 | } |