@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $date = sanitize_text_field( $_POST['date'] ); |
| 11 | 11 | $time = sanitize_text_field( $_POST['time'] ); |
| 12 | 12 | |
| 13 | - $offset = (int) -( get_option( 'gmt_offset' ) ); // Make the timestamp in the users' timezone, b/c that makes more sense |
|
| 13 | + $offset = (int) -(get_option( 'gmt_offset' )); // Make the timestamp in the users' timezone, b/c that makes more sense |
|
| 14 | 14 | |
| 15 | 15 | $share_time = explode( ':', $time ); |
| 16 | 16 | |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | $minutes = (int) substr( $share_time[1], 0, 2 ); |
| 19 | 19 | $ampm = strtolower( substr( $share_time[1], -2 ) ); |
| 20 | 20 | |
| 21 | - if ( $ampm == 'pm' && $hours != 12 ) { |
|
| 21 | + if ($ampm == 'pm' && $hours != 12) { |
|
| 22 | 22 | $hours = $hours + 12; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( $ampm == 'am' && $hours == 12 ) { |
|
| 25 | + if ($ampm == 'am' && $hours == 12) { |
|
| 26 | 26 | $hours = 00; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 9 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 8 | +if ( ! class_exists( 'WP_List_Table' )) { |
|
| 9 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @return string The Content to display |
| 43 | 43 | */ |
| 44 | 44 | public function column_default( $item, $column_name ) { |
| 45 | - return $item[ $column_name ]; |
|
| 45 | + return $item[$column_name]; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $accounts = apply_filters( 'ppp_register_social_service', array() ); |
| 76 | 76 | |
| 77 | - foreach ( $accounts as $account ) { |
|
| 77 | + foreach ($accounts as $account) { |
|
| 78 | 78 | $data[$account] = array( |
| 79 | - 'icon' => apply_filters( 'ppp_account_list_icon-' . $account, '' ), |
|
| 80 | - 'avatar' => apply_filters( 'ppp_account_list_avatar-' . $account, '' ), |
|
| 81 | - 'name' => apply_filters( 'ppp_account_list_name-' . $account, '' ), |
|
| 82 | - 'actions' => apply_filters( 'ppp_account_list_actions-' . $account, '' ), |
|
| 83 | - 'extras' => apply_filters( 'ppp_account_list_extras-' . $account, '' ), |
|
| 79 | + 'icon' => apply_filters( 'ppp_account_list_icon-'.$account, '' ), |
|
| 80 | + 'avatar' => apply_filters( 'ppp_account_list_avatar-'.$account, '' ), |
|
| 81 | + 'name' => apply_filters( 'ppp_account_list_name-'.$account, '' ), |
|
| 82 | + 'actions' => apply_filters( 'ppp_account_list_actions-'.$account, '' ), |
|
| 83 | + 'extras' => apply_filters( 'ppp_account_list_extras-'.$account, '' ), |
|
| 84 | 84 | ); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 13 | +if ( ! defined( 'ABSPATH' )) exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Render Upgrades Screen |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | 21 | function ppp_upgrades_screen() { |
| 22 | - $action = isset( $_GET['ppp-upgrade'] ) ? sanitize_text_field( $_GET['ppp-upgrade'] ) : ''; |
|
| 23 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
| 24 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
| 25 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
| 26 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
| 27 | - $steps = round( ( $total / $number ), 0 ); |
|
| 22 | + $action = isset($_GET['ppp-upgrade']) ? sanitize_text_field( $_GET['ppp-upgrade'] ) : ''; |
|
| 23 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
| 24 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
| 25 | + $custom = isset($_GET['custom']) ? absint( $_GET['custom'] ) : 0; |
|
| 26 | + $number = isset($_GET['number']) ? absint( $_GET['number'] ) : 100; |
|
| 27 | + $steps = round( ($total / $number), 0 ); |
|
| 28 | 28 | |
| 29 | 29 | $doing_upgrade_args = array( |
| 30 | 30 | 'page' => 'ppp-upgrades', |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | update_option( 'ppp_doing_upgrade', $doing_upgrade_args ); |
| 39 | - if ( $step > $steps ) { |
|
| 39 | + if ($step > $steps) { |
|
| 40 | 40 | // Prevent a weird case where the estimate was off. Usually only a couple. |
| 41 | 41 | $steps = $step; |
| 42 | 42 | } |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | <div class="wrap"> |
| 45 | 45 | <h1><?php _e( 'Post Promoter Pro - Upgrades', 'ppp-txt' ); ?></h1> |
| 46 | 46 | |
| 47 | - <?php if( ! empty( $action ) ) : ?> |
|
| 47 | + <?php if ( ! empty($action)) : ?> |
|
| 48 | 48 | |
| 49 | 49 | <div id="ppp-upgrade-status"> |
| 50 | 50 | <p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'ppp-txt' ); ?></p> |
| 51 | 51 | |
| 52 | - <?php if( ! empty( $total ) ) : ?> |
|
| 52 | + <?php if ( ! empty($total)) : ?> |
|
| 53 | 53 | <p><strong><?php printf( __( 'Step %d of approximately %d running', 'ppp-txt' ), $step, $steps ); ?></strong></p> |
| 54 | 54 | <?php endif; ?> |
| 55 | 55 | </div> |
@@ -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,11 +12,11 @@ discard block |
||
| 12 | 12 | function ppp_register_meta_boxes() { |
| 13 | 13 | global $post, $ppp_options; |
| 14 | 14 | |
| 15 | - if ( !isset( $ppp_options['post_types'] ) || !is_array( $ppp_options['post_types'] ) ) { |
|
| 15 | + if ( ! isset($ppp_options['post_types']) || ! is_array( $ppp_options['post_types'] )) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - foreach ( $ppp_options['post_types'] as $post_type => $value ) { |
|
| 19 | + foreach ($ppp_options['post_types'] as $post_type => $value) { |
|
| 20 | 20 | add_meta_box( 'ppp_schedule_metabox', 'Post Promoter Pro', 'ppp_schedule_callback', $post_type, 'normal', 'high' ); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -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 | |
@@ -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 | |
@@ -55,26 +55,26 @@ discard block |
||
| 55 | 55 | function ppp_share_post( $post_id, $name ) { |
| 56 | 56 | global $ppp_options, $ppp_social_settings, $ppp_share_settings, $ppp_twitter_oauth; |
| 57 | 57 | |
| 58 | - if ( ppp_is_dev_or_staging() ) { |
|
| 58 | + if (ppp_is_dev_or_staging()) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // If we've already started to share this, don't share it again. |
| 63 | 63 | // Compensates for wp-cron's race conditions |
| 64 | - if ( get_transient( 'ppp_sharing' . $name ) === 'true' ) { |
|
| 64 | + if (get_transient( 'ppp_sharing'.$name ) === 'true') { |
|
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // For 10 seconds, don't allow another share to go for this post |
| 69 | - set_transient( 'ppp_sharing' . $name, 'true', 10 ); |
|
| 69 | + set_transient( 'ppp_sharing'.$name, 'true', 10 ); |
|
| 70 | 70 | |
| 71 | 71 | $name_parts = explode( '_', $name ); |
| 72 | 72 | $index = $name_parts[1]; |
| 73 | - $service = isset( $name_parts[3] ) ? $name_parts[3] : 'tw'; |
|
| 73 | + $service = isset($name_parts[3]) ? $name_parts[3] : 'tw'; |
|
| 74 | 74 | |
| 75 | 75 | // If we're fired on a cron, check for stale cron runs |
| 76 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 77 | - switch( $service ) { |
|
| 76 | + if (defined( 'DOING_CRON' ) && DOING_CRON) { |
|
| 77 | + switch ($service) { |
|
| 78 | 78 | case 'tw': |
| 79 | 79 | $post_meta = get_post_meta( $post_id, '_ppp_tweets', true ); |
| 80 | 80 | break; |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $share_data = array(); |
| 92 | - if ( isset( $post_meta[ $index ] ) ) { |
|
| 93 | - $share_data = $post_meta[ $index ]; |
|
| 92 | + if (isset($post_meta[$index])) { |
|
| 93 | + $share_data = $post_meta[$index]; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $timestamp = ppp_generate_timestamp( $share_data['date'], $share_data['time'] ); |
| 97 | 97 | |
| 98 | 98 | // If the current time is more than 60 minutes (filterable) overdue, don't fire the share |
| 99 | 99 | $share_buffer = apply_filters( 'ppp_share_buffer', HOUR_IN_SECONDS ); |
| 100 | - if ( ( current_time( 'timestamp', 1 ) - $timestamp ) > $share_buffer ) { |
|
| 100 | + if ((current_time( 'timestamp', 1 ) - $timestamp) > $share_buffer) { |
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - do_action( 'ppp_share_scheduled_' . $service, $post_id, $index, $name ); |
|
| 105 | + do_action( 'ppp_share_scheduled_'.$service, $post_id, $index, $name ); |
|
| 106 | 106 | |
| 107 | 107 | // Just in case we get caught in a weird state, kill this share immediately after we execute it. |
| 108 | 108 | wp_clear_scheduled_hook( 'ppp_share_post_event', array( $post_id, $name ) ); |
@@ -114,28 +114,28 @@ discard block |
||
| 114 | 114 | * @return void |
| 115 | 115 | */ |
| 116 | 116 | function ppp_set_social_tokens() { |
| 117 | - if ( ( defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' ) ) || |
|
| 118 | - ( defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' ) ) || |
|
| 119 | - ( defined( 'bitly_clientid' ) && defined( 'bitly_secret' ) ) || |
|
| 120 | - ( defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' ) ) |
|
| 117 | + if ((defined( 'PPP_TW_CONSUMER_KEY' ) && defined( 'PPP_TW_CONSUMER_SECRET' )) || |
|
| 118 | + (defined( 'LINKEDIN_KEY' ) && defined( 'LINKEDIN_SECRET' )) || |
|
| 119 | + (defined( 'bitly_clientid' ) && defined( 'bitly_secret' )) || |
|
| 120 | + (defined( 'PPP_FB_APP_ID' ) && defined( 'PPP_FB_APP_SECRET' )) |
|
| 121 | 121 | ) { |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $social_tokens = ppp_has_local_tokens(); |
| 126 | 126 | |
| 127 | - if ( empty( $social_tokens ) ) { |
|
| 128 | - if ( ! defined( 'PPP_LOCAL_TOKENS' ) ) { |
|
| 127 | + if (empty($social_tokens)) { |
|
| 128 | + if ( ! defined( 'PPP_LOCAL_TOKENS' )) { |
|
| 129 | 129 | define( 'PPP_LOCAL_TOKENS', false ); |
| 130 | 130 | } |
| 131 | 131 | $social_tokens = get_transient( 'ppp_social_tokens' ); |
| 132 | 132 | |
| 133 | - if ( ! $social_tokens ) { |
|
| 133 | + if ( ! $social_tokens) { |
|
| 134 | 134 | $license = trim( get_option( '_ppp_license_key' ) ); |
| 135 | - $url = PPP_STORE_URL . '/?ppp-get-tokens&ppp-license-key=' . $license . '&ver=' . md5( time() . $license ); |
|
| 135 | + $url = PPP_STORE_URL.'/?ppp-get-tokens&ppp-license-key='.$license.'&ver='.md5( time().$license ); |
|
| 136 | 136 | $response = wp_remote_get( $url, array( 'timeout' => 15, 'sslverify' => false ) ); |
| 137 | 137 | |
| 138 | - if ( is_wp_error( $response ) ) { |
|
| 138 | + if (is_wp_error( $response )) { |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,27 +144,27 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | } else { |
| 147 | - if ( ! defined ( 'PPP_LOCAL_TOKENS' ) ) { |
|
| 147 | + if ( ! defined( 'PPP_LOCAL_TOKENS' )) { |
|
| 148 | 148 | define( 'PPP_LOCAL_TOKENS', true ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | delete_transient( 'ppp_social_tokens' ); |
| 152 | 152 | |
| 153 | - if ( isset( $social_tokens->options ) ) { |
|
| 154 | - foreach ( $social_tokens->options as $constant => $value ) { |
|
| 153 | + if (isset($social_tokens->options)) { |
|
| 154 | + foreach ($social_tokens->options as $constant => $value) { |
|
| 155 | 155 | |
| 156 | 156 | $constant = strtoupper( $constant ); |
| 157 | 157 | |
| 158 | - if ( defined( $constant ) ) { |
|
| 158 | + if (defined( $constant )) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - switch( $constant ) { |
|
| 162 | + switch ($constant) { |
|
| 163 | 163 | |
| 164 | 164 | case 'NO_AUTO_UPDATE': |
| 165 | 165 | // Avoid the call to the API to check for software updates |
| 166 | 166 | $value = is_bool( $value ) ? $value : false; |
| 167 | - if ( ! defined( 'NO_AUTO_UPDATE' ) ) { |
|
| 167 | + if ( ! defined( 'NO_AUTO_UPDATE' )) { |
|
| 168 | 168 | define( 'NO_AUTO_UPDATE', $value ); |
| 169 | 169 | } |
| 170 | 170 | break; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( false === PPP_LOCAL_TOKENS && ! isset( $social_tokens->error ) && ( isset( $social_tokens->twitter ) || isset( $social_tokens->facebook ) || isset( $social_tokens->linkedin ) ) ) { |
|
| 177 | + if (false === PPP_LOCAL_TOKENS && ! isset($social_tokens->error) && (isset($social_tokens->twitter) || isset($social_tokens->facebook) || isset($social_tokens->linkedin))) { |
|
| 178 | 178 | set_transient( 'ppp_social_tokens', $social_tokens, WEEK_IN_SECONDS ); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function ppp_has_local_tokens() { |
| 189 | 189 | |
| 190 | - $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path() . '/ppp-social-tokens.json' ); |
|
| 190 | + $token_file = apply_filters( 'ppp_local_social_token_path', ppp_get_upload_path().'/ppp-social-tokens.json' ); |
|
| 191 | 191 | $local_tokens = false; |
| 192 | 192 | |
| 193 | - if ( ! file_exists( $token_file ) ) { |
|
| 193 | + if ( ! file_exists( $token_file )) { |
|
| 194 | 194 | return $local_tokens; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $local_tokens = json_decode( file_get_contents( $token_file ) ); |
| 198 | 198 | |
| 199 | 199 | // Failed to parse as JSON |
| 200 | - if ( false === $local_tokens ) { |
|
| 200 | + if (false === $local_tokens) { |
|
| 201 | 201 | return $local_tokens; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // No social tokens found in the format we accept or it was empty |
| 205 | - if ( empty( $local_tokens ) || ( ! isset( $local_tokens->twitter ) || ! isset( $local_tokens->facebook ) || ! isset( $local_tokens->linkedin ) ) ) { |
|
| 205 | + if (empty($local_tokens) || ( ! isset($local_tokens->twitter) || ! isset($local_tokens->facebook) || ! isset($local_tokens->linkedin))) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | global $ppp_share_settings; |
| 221 | 221 | $share_link = get_permalink( $post_id ); |
| 222 | 222 | |
| 223 | - if ( ppp_link_tracking_enabled() ) { |
|
| 223 | + if (ppp_link_tracking_enabled()) { |
|
| 224 | 224 | $share_link = ppp_generate_link_tracking( $share_link, $post_id, $name ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ppp_is_shortener_enabled() && $scheduled ) { |
|
| 227 | + if (ppp_is_shortener_enabled() && $scheduled) { |
|
| 228 | 228 | $shortener_name = $ppp_share_settings['shortener']; |
| 229 | - $share_link = apply_filters( 'ppp_apply_shortener-' . $shortener_name, $share_link ); |
|
| 229 | + $share_link = apply_filters( 'ppp_apply_shortener-'.$shortener_name, $share_link ); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | * @return string The URL to post, with proper analytics applied if necessary |
| 242 | 242 | */ |
| 243 | 243 | function ppp_generate_link_tracking( $share_link, $post_id, $name ) { |
| 244 | - if ( ppp_link_tracking_enabled() ) { |
|
| 244 | + if (ppp_link_tracking_enabled()) { |
|
| 245 | 245 | global $ppp_share_settings; |
| 246 | 246 | $link_tracking_type = $ppp_share_settings['analytics']; |
| 247 | 247 | |
| 248 | 248 | // Given the setting name, devs can extend this and apply a filter of ppp_analytics-[setting value] |
| 249 | 249 | // to apply their own rules for link tracking |
| 250 | - $share_link = apply_filters( 'ppp_analytics-' . $link_tracking_type, $share_link, $post_id, $name ); |
|
| 250 | + $share_link = apply_filters( 'ppp_analytics-'.$link_tracking_type, $share_link, $post_id, $name ); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | $share_link = apply_filters( 'ppp_generate_link_tracking', $share_link, $post_id, $name ); |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | * @return mixed If a thumbnail is found returns the URL, otherwise returns false |
| 264 | 264 | */ |
| 265 | 265 | function ppp_post_has_media( $post_id, $network, $use_media, $attachment_id = false ) { |
| 266 | - if ( !$use_media || empty( $post_id ) || empty( $network ) ) { |
|
| 266 | + if ( ! $use_media || empty($post_id) || empty($network)) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $thumb_id = empty( $attachment_id ) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
| 271 | - $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-' . $network . '-share-image', true ); |
|
| 270 | + $thumb_id = empty($attachment_id) ? get_post_thumbnail_id( $post_id ) : $attachment_id; |
|
| 271 | + $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-'.$network.'-share-image', true ); |
|
| 272 | 272 | |
| 273 | - if ( isset( $thumb_url[0] ) && ! empty( $thumb_url[0] ) && !strpos( $thumb_url[0], 'wp-includes/images/media/default.png' ) ) { |
|
| 273 | + if (isset($thumb_url[0]) && ! empty($thumb_url[0]) && ! strpos( $thumb_url[0], 'wp-includes/images/media/default.png' )) { |
|
| 274 | 274 | return $thumb_url[0]; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | $filename = end( $path ); |
| 293 | 293 | |
| 294 | 294 | // First check a social media share (thumbnail sizes) |
| 295 | - $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE '%s';", '%' . $wpdb->esc_like( $filename ) . '%' ) ); |
|
| 296 | - if ( ! empty( $thumb_id[0] ) ) { |
|
| 295 | + $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value LIKE '%s';", '%'.$wpdb->esc_like( $filename ).'%' ) ); |
|
| 296 | + if ( ! empty($thumb_id[0])) { |
|
| 297 | 297 | $attachment_id = $thumb_id[0]; |
| 298 | 298 | } else { |
| 299 | 299 | |
| 300 | 300 | // We didn't find one via the thumbnail sizes, try the full image URL. |
| 301 | 301 | $thumb_id = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) ); |
| 302 | - if ( ! empty( $thumb_id[0] ) ) { |
|
| 302 | + if ( ! empty($thumb_id[0])) { |
|
| 303 | 303 | $attachment_id = $thumb_id[0]; |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -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 | * @return void |
| 12 | 12 | */ |
| 13 | 13 | function ppp_add_wpme_shortener( $selected_shortener ) { |
| 14 | - if( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortlinks' ) ) { ?> |
|
| 14 | + if (class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortlinks' )) { ?> |
|
| 15 | 15 | <option value="wpme" <?php selected( $selected_shortener, 'wpme', true ); ?>>WP.me</option> |
| 16 | 16 | <?php } |
| 17 | 17 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | * @return string The link, after shortening through wp.me |
| 41 | 41 | */ |
| 42 | 42 | function ppp_apply_wpme( $link ) { |
| 43 | - if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortlinks' ) ) { |
|
| 43 | + if (class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortlinks' )) { |
|
| 44 | 44 | $id = url_to_postid( $link ); |
| 45 | 45 | $result = wpme_get_shortlink( $id ); |
| 46 | 46 | |
| 47 | - if ( ! empty( $result ) ) { |
|
| 47 | + if ( ! empty($result)) { |
|
| 48 | 48 | return $result; |
| 49 | 49 | } else { |
| 50 | 50 | return $link; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if ( ! defined( 'ABSPATH' )) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | $options = get_option( 'ppp_options' ); |
| 13 | 13 | |
| 14 | -if ( isset( $options['delete_on_uninstall'] ) ) { |
|
| 14 | +if (isset($options['delete_on_uninstall'])) { |
|
| 15 | 15 | require_once 'includes/cron-functions.php'; |
| 16 | 16 | |
| 17 | 17 | $crons = ppp_get_shceduled_crons(); |
| 18 | - foreach( $crons as $cron ) { |
|
| 18 | + foreach ($crons as $cron) { |
|
| 19 | 19 | $ppp_data = $cron['ppp_share_post_event']; |
| 20 | 20 | $array_keys = array_keys( $ppp_data ); |
| 21 | 21 | $hash_key = $array_keys[0]; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @since 1.0 |
| 124 | 124 | * |
| 125 | 125 | * @return array |
| 126 | - */ |
|
| 126 | + */ |
|
| 127 | 127 | |
| 128 | 128 | private static function log_types() { |
| 129 | 129 | $terms = array( |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @uses register_post_type() |
| 144 | 144 | * |
| 145 | 145 | * @return void |
| 146 | - */ |
|
| 146 | + */ |
|
| 147 | 147 | |
| 148 | 148 | public function register_post_type() { |
| 149 | 149 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @uses wp_insert_term() |
| 177 | 177 | * |
| 178 | 178 | * @return void |
| 179 | - */ |
|
| 179 | + */ |
|
| 180 | 180 | |
| 181 | 181 | public function register_taxonomy() { |
| 182 | 182 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * |
| 204 | 204 | * @return array |
| 205 | - */ |
|
| 205 | + */ |
|
| 206 | 206 | |
| 207 | 207 | private static function valid_type( $type ) { |
| 208 | 208 | return in_array( $type, self::log_types() ); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @uses self::insert_log() |
| 222 | 222 | * |
| 223 | 223 | * @return int The ID of the new log entry |
| 224 | - */ |
|
| 224 | + */ |
|
| 225 | 225 | |
| 226 | 226 | public static function add( $title = '', $message = '', $parent = 0, $type = null ) { |
| 227 | 227 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @uses sanitize_key() |
| 251 | 251 | * |
| 252 | 252 | * @return int The ID of the newly created log item |
| 253 | - */ |
|
| 253 | + */ |
|
| 254 | 254 | |
| 255 | 255 | public static function insert_log( $log_data = array(), $log_meta = array() ) { |
| 256 | 256 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @uses update_post_meta() |
| 301 | 301 | * |
| 302 | 302 | * @return bool True if successful, false otherwise |
| 303 | - */ |
|
| 303 | + */ |
|
| 304 | 304 | public static function update_log( $log_data = array(), $log_meta = array() ) { |
| 305 | 305 | |
| 306 | 306 | do_action( 'wp_pre_update_log', $log_id ); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @uses self::get_connected_logs() |
| 338 | 338 | * |
| 339 | 339 | * @return array |
| 340 | - */ |
|
| 340 | + */ |
|
| 341 | 341 | |
| 342 | 342 | public static function get_logs( $object_id = 0, $type = null, $paged = null ) { |
| 343 | 343 | return self::get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) ); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @uses self::valid_type() |
| 360 | 360 | * |
| 361 | 361 | * @return array / false |
| 362 | - */ |
|
| 362 | + */ |
|
| 363 | 363 | |
| 364 | 364 | public static function get_connected_logs( $args = array() ) { |
| 365 | 365 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @uses self::valid_type() |
| 408 | 408 | * |
| 409 | 409 | * @return int |
| 410 | - */ |
|
| 410 | + */ |
|
| 411 | 411 | |
| 412 | 412 | public static function get_log_count( $object_id = 0, $type = null, $meta_query = null ) { |
| 413 | 413 | |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | * @uses $this->get_logs_to_prune() Returns array of posts via get_posts of logs to prune |
| 42 | 42 | * @uses $this->prune_old_logs() Deletes the logs that we don't want anymore |
| 43 | 43 | */ |
| 44 | - public function prune_logs(){ |
|
| 44 | + public function prune_logs() { |
|
| 45 | 45 | |
| 46 | 46 | $should_we_prune = apply_filters( 'wp_logging_should_we_prune', false ); |
| 47 | 47 | |
| 48 | - if ( $should_we_prune === false ){ |
|
| 48 | + if ($should_we_prune === false) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $logs_to_prune = $this->get_logs_to_prune(); |
| 53 | 53 | |
| 54 | - if ( isset( $logs_to_prune ) && ! empty( $logs_to_prune ) ){ |
|
| 54 | + if (isset($logs_to_prune) && ! empty($logs_to_prune)) { |
|
| 55 | 55 | $this->prune_old_logs( $logs_to_prune ); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @filter wp_logging_force_delete_log Allows user to override the force delete setting which bypasses the trash |
| 71 | 71 | */ |
| 72 | - private function prune_old_logs( $logs ){ |
|
| 72 | + private function prune_old_logs( $logs ) { |
|
| 73 | 73 | |
| 74 | 74 | $force = apply_filters( 'wp_logging_force_delete_log', true ); |
| 75 | 75 | |
| 76 | - foreach( $logs as $l ){ |
|
| 76 | + foreach ($logs as $l) { |
|
| 77 | 77 | wp_delete_post( $l->ID, $force ); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @filter wp_logging_prune_when Users can change how long ago we are looking for logs to prune |
| 94 | 94 | * @filter wp_logging_prune_query_args Gives users access to change any query args for pruning |
| 95 | 95 | */ |
| 96 | - private function get_logs_to_prune(){ |
|
| 96 | + private function get_logs_to_prune() { |
|
| 97 | 97 | |
| 98 | 98 | $how_old = apply_filters( 'wp_logging_prune_when', '2 weeks ago' ); |
| 99 | 99 | |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $types = self::log_types(); |
| 186 | 186 | |
| 187 | - foreach ( $types as $type ) { |
|
| 188 | - if( ! term_exists( $type, 'wp_log_type' ) ) { |
|
| 187 | + foreach ($types as $type) { |
|
| 188 | + if ( ! term_exists( $type, 'wp_log_type' )) { |
|
| 189 | 189 | wp_insert_term( $type, 'wp_log_type' ); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -270,15 +270,15 @@ discard block |
||
| 270 | 270 | $log_id = wp_insert_post( $args ); |
| 271 | 271 | |
| 272 | 272 | // set the log type, if any |
| 273 | - if( $log_data['log_type'] && self::valid_type( $log_data['log_type'] ) ) { |
|
| 273 | + if ($log_data['log_type'] && self::valid_type( $log_data['log_type'] )) { |
|
| 274 | 274 | wp_set_object_terms( $log_id, $log_data['log_type'], 'wp_log_type', false ); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | // set log meta, if any |
| 279 | - if( $log_id && ! empty( $log_meta ) ) { |
|
| 280 | - foreach( (array) $log_meta as $key => $meta ) { |
|
| 281 | - update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta ); |
|
| 279 | + if ($log_id && ! empty($log_meta)) { |
|
| 280 | + foreach ((array) $log_meta as $key => $meta) { |
|
| 281 | + update_post_meta( $log_id, '_wp_log_'.sanitize_key( $key ), $meta ); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | // store the log entry |
| 317 | 317 | $log_id = wp_update_post( $args ); |
| 318 | 318 | |
| 319 | - if( $log_id && ! empty( $log_meta ) ) { |
|
| 320 | - foreach( (array) $log_meta as $key => $meta ) { |
|
| 321 | - if( ! empty( $meta ) ) |
|
| 322 | - update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta ); |
|
| 319 | + if ($log_id && ! empty($log_meta)) { |
|
| 320 | + foreach ((array) $log_meta as $key => $meta) { |
|
| 321 | + if ( ! empty($meta)) |
|
| 322 | + update_post_meta( $log_id, '_wp_log_'.sanitize_key( $key ), $meta ); |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | $query_args = wp_parse_args( $args, $defaults ); |
| 376 | 376 | |
| 377 | - if( $query_args['log_type'] && self::valid_type( $query_args['log_type'] ) ) { |
|
| 377 | + if ($query_args['log_type'] && self::valid_type( $query_args['log_type'] )) { |
|
| 378 | 378 | |
| 379 | 379 | $query_args['tax_query'] = array( |
| 380 | 380 | array( |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | $logs = get_posts( $query_args ); |
| 390 | 390 | |
| 391 | - if( $logs ) |
|
| 391 | + if ($logs) |
|
| 392 | 392 | return $logs; |
| 393 | 393 | |
| 394 | 394 | // no logs found |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | 'post_status' => 'publish' |
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | - if( ! empty( $type ) && self::valid_type( $type ) ) { |
|
| 421 | + if ( ! empty($type) && self::valid_type( $type )) { |
|
| 422 | 422 | |
| 423 | 423 | $query_args['tax_query'] = array( |
| 424 | 424 | array( |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if( ! empty( $meta_query ) ) { |
|
| 433 | + if ( ! empty($meta_query)) { |
|
| 434 | 434 | $query_args['meta_query'] = $meta_query; |
| 435 | 435 | } |
| 436 | 436 | |