@@ -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> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 13 | +if ( !defined( 'ABSPATH' ) ) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Render Upgrades Screen |
@@ -57,11 +59,14 @@ discard block |
||
| 57 | 59 | setTimeout(function() { document.location.href = "index.php?ppp_action=<?php echo $action; ?>&step=<?php echo $step; ?>&total=<?php echo $total; ?>&custom=<?php echo $custom; ?>"; }, 250); |
| 58 | 60 | </script> |
| 59 | 61 | |
| 60 | - <?php else : ?> |
|
| 62 | + <?php else { |
|
| 63 | + : ?> |
|
| 61 | 64 | |
| 62 | 65 | <div id="ppp-upgrade-status"> |
| 63 | 66 | <p> |
| 64 | - <?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' ); ?> |
|
| 67 | + <?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' ); |
|
| 68 | +} |
|
| 69 | +?> |
|
| 65 | 70 | </p> |
| 66 | 71 | </div> |
| 67 | 72 | <script type="text/javascript"> |
@@ -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 | |
@@ -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]; |
@@ -429,9 +429,12 @@ |
||
| 429 | 429 | |
| 430 | 430 | <?php endforeach; ?> |
| 431 | 431 | |
| 432 | - <?php else: ?> |
|
| 432 | + <?php else { |
|
| 433 | + : ?> |
|
| 433 | 434 | |
| 434 | - <?php ppp_render_li_share_row( 1, array( 'date' => '', 'time' => '', 'text' => '', 'desc' => '', 'image' => '', 'attachment_id' => '' ) ); ?> |
|
| 435 | + <?php ppp_render_li_share_row( 1, array( 'date' => '', 'time' => '', 'text' => '', 'desc' => '', 'image' => '', 'attachment_id' => '' ) ); |
|
| 436 | +} |
|
| 437 | +?> |
|
| 435 | 438 | |
| 436 | 439 | <?php endif; ?> |
| 437 | 440 | </tbody> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | function ppp_linkedin_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['linkedin'] ) && !empty( $ppp_social_settings['linkedin'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['linkedin']) && ! empty($ppp_social_settings['linkedin'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function ppp_li_account_list_name( $string = '' ) { |
| 62 | 62 | |
| 63 | - if ( ppp_linkedin_enabled() ) { |
|
| 63 | + if (ppp_linkedin_enabled()) { |
|
| 64 | 64 | global $ppp_social_settings; |
| 65 | - $string .= $ppp_social_settings['linkedin']->firstName . ' ' . $ppp_social_settings['linkedin']->lastName; |
|
| 65 | + $string .= $ppp_social_settings['linkedin']->firstName.' '.$ppp_social_settings['linkedin']->lastName; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return $string; |
@@ -77,22 +77,22 @@ discard block |
||
| 77 | 77 | function ppp_li_account_list_actions( $string = '' ) { |
| 78 | 78 | global $ppp_linkedin_oauth, $ppp_social_settings; |
| 79 | 79 | |
| 80 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 80 | + if ( ! ppp_linkedin_enabled()) { |
|
| 81 | 81 | $li_authurl = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 82 | 82 | |
| 83 | - $string .= '<a class="button-primary" href="' . $li_authurl . '">' . __( 'Connect to Linkedin', 'ppp-txt' ) . '</a>'; |
|
| 83 | + $string .= '<a class="button-primary" href="'.$li_authurl.'">'.__( 'Connect to Linkedin', 'ppp-txt' ).'</a>'; |
|
| 84 | 84 | } else { |
| 85 | - $string .= '<a class="button-primary" href="' . admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=linkedin' ) . '" >' . __( 'Disconnect from Linkedin', 'ppp-txt' ) . '</a> '; |
|
| 85 | + $string .= '<a class="button-primary" href="'.admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=linkedin' ).'" >'.__( 'Disconnect from Linkedin', 'ppp-txt' ).'</a> '; |
|
| 86 | 86 | |
| 87 | 87 | $refresh_date = (int) get_option( '_ppp_linkedin_refresh', true ); |
| 88 | 88 | |
| 89 | 89 | |
| 90 | - if ( defined( 'LINKEDIN_KEY' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 90 | + if (defined( 'LINKEDIN_KEY' ) && current_time( 'timestamp' ) > $refresh_date) { |
|
| 91 | 91 | $token = $ppp_social_settings['linkedin']->access_token; |
| 92 | 92 | $url = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 93 | - $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 93 | + $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 94 | 94 | |
| 95 | - $string .= '<a class="button-secondary" href="' . $refresh_url . '" >' . __( 'Re-Authorize Linkedin', 'ppp-txt' ) . '</a> '; |
|
| 95 | + $string .= '<a class="button-secondary" href="'.$refresh_url.'" >'.__( 'Re-Authorize Linkedin', 'ppp-txt' ).'</a> '; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | * @return string The HTML for the LinkedIn Extras column |
| 107 | 107 | */ |
| 108 | 108 | function ppp_li_account_list_extras( $string ) { |
| 109 | - if ( ppp_linkedin_enabled() ) { |
|
| 109 | + if (ppp_linkedin_enabled()) { |
|
| 110 | 110 | global $ppp_social_settings, $ppp_options; |
| 111 | - if ( ! empty( $ppp_options['enable_debug'] ) ) { |
|
| 112 | - $days_left = absint( round( ( $ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 113 | - $refresh_in = absint( round( ( get_option( '_ppp_linkedin_refresh' ) - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 111 | + if ( ! empty($ppp_options['enable_debug'])) { |
|
| 112 | + $days_left = absint( round( ($ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 113 | + $refresh_in = absint( round( (get_option( '_ppp_linkedin_refresh' ) - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 114 | 114 | |
| 115 | - $string .= '<br />' . sprintf( __( 'Token expires in %s days' , 'ppp-txt' ), $days_left ); |
|
| 116 | - $string .= '<br />' . sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 115 | + $string .= '<br />'.sprintf( __( 'Token expires in %s days', 'ppp-txt' ), $days_left ); |
|
| 116 | + $string .= '<br />'.sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | function ppp_capture_linkedin_oauth() { |
| 130 | 130 | $should_capture = false; |
| 131 | 131 | |
| 132 | - if ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false ) { |
|
| 132 | + if (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-li' ) !== false) { |
|
| 133 | 133 | // Local config |
| 134 | 134 | $should_capture = true; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( isset( $_REQUEST['li_access_token'] ) ) { |
|
| 137 | + if (isset($_REQUEST['li_access_token'])) { |
|
| 138 | 138 | // Returning from remote config |
| 139 | 139 | $should_capture = true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( $should_capture && ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ppp-social-settings' ) ) { |
|
| 142 | + if ($should_capture && (isset($_REQUEST['page']) && $_REQUEST['page'] == 'ppp-social-settings')) { |
|
| 143 | 143 | global $ppp_linkedin_oauth; |
| 144 | 144 | $ppp_linkedin_oauth->ppp_initialize_linkedin(); |
| 145 | 145 | wp_redirect( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | function ppp_disconnect_linkedin() { |
| 156 | 156 | global $ppp_social_settings; |
| 157 | 157 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 158 | - if ( isset( $ppp_social_settings['linkedin'] ) ) { |
|
| 159 | - unset( $ppp_social_settings['linkedin'] ); |
|
| 158 | + if (isset($ppp_social_settings['linkedin'])) { |
|
| 159 | + unset($ppp_social_settings['linkedin']); |
|
| 160 | 160 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 161 | 161 | delete_option( '_ppp_linkedin_refresh' ); |
| 162 | 162 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function ppp_li_execute_refresh() { |
| 184 | 184 | |
| 185 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 185 | + if ( ! ppp_linkedin_enabled()) { |
|
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $refresh_date = (int) get_option( '_ppp_linkedin_refresh', true ); |
| 190 | 190 | |
| 191 | - if ( ( empty( $_GET['page' ] ) || $_GET['page'] !== 'ppp-social-settings' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 191 | + if ((empty($_GET['page']) || $_GET['page'] !== 'ppp-social-settings') && current_time( 'timestamp' ) > $refresh_date) { |
|
| 192 | 192 | add_action( 'admin_notices', 'ppp_linkedin_refresh_notice' ); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function ppp_linkedin_refresh_notice() { |
| 202 | 202 | |
| 203 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 203 | + if ( ! ppp_linkedin_enabled()) { |
|
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $has_dismissed = get_transient( 'ppp-dismiss-refresh-li' . get_current_user_id() ); |
|
| 208 | - if ( false !== $has_dismissed ) { |
|
| 207 | + $has_dismissed = get_transient( 'ppp-dismiss-refresh-li'.get_current_user_id() ); |
|
| 208 | + if (false !== $has_dismissed) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | $token = $ppp_social_settings['linkedin']->access_token; |
| 218 | 218 | $url = $ppp_linkedin_oauth->ppp_get_linkedin_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 219 | - $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 219 | + $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 220 | 220 | |
| 221 | - $days_left = (int) round( ( $ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ); |
|
| 221 | + $days_left = (int) round( ($ppp_social_settings['linkedin']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ); |
|
| 222 | 222 | ?> |
| 223 | 223 | <div class="notice notice-warning is-dismissible" data-service="li"> |
| 224 | - <?php if ( $days_left > 0 ): ?> |
|
| 224 | + <?php if ($days_left > 0): ?> |
|
| 225 | 225 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your LinkedIn authentication expires in %d days. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $days_left, $url ); ?></p> |
| 226 | - <?php elseif ( $days_left < 1 ): ?> |
|
| 226 | + <?php elseif ($days_left < 1): ?> |
|
| 227 | 227 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your LinkedIn authentication has expired. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $url ); ?></p> |
| 228 | 228 | <?php endif; ?> |
| 229 | 229 | </div> |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function ppp_li_dismiss_notice() { |
| 240 | 240 | |
| 241 | - $nag = sanitize_key( $_POST[ 'nag' ] ); |
|
| 241 | + $nag = sanitize_key( $_POST['nag'] ); |
|
| 242 | 242 | |
| 243 | - if ( $nag === $_POST[ 'nag' ] ) { |
|
| 244 | - set_transient( $nag . get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 243 | + if ($nag === $_POST['nag']) { |
|
| 244 | + set_transient( $nag.get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | 256 | function ppp_set_li_token_constants( $social_tokens ) { |
| 257 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'linkedin' ) ) { |
|
| 257 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'linkedin' )) { |
|
| 258 | 258 | define( 'LINKEDIN_KEY', $social_tokens->linkedin->api_key ); |
| 259 | 259 | define( 'LINKEDIN_SECRET', $social_tokens->linkedin->secret_key ); |
| 260 | 260 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | function ppp_li_share( $title, $description, $link, $media ) { |
| 273 | 273 | global $ppp_linkedin_oauth; |
| 274 | - $args = array ( |
|
| 274 | + $args = array( |
|
| 275 | 275 | 'title' => ppp_entities_and_slashes( $title ), |
| 276 | 276 | 'description' => ppp_entities_and_slashes( $description ), |
| 277 | 277 | 'submitted-url' => $link, |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function ppp_li_add_meta_tab( $tabs ) { |
| 314 | 314 | global $ppp_social_settings; |
| 315 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 315 | + if ( ! ppp_linkedin_enabled()) { |
|
| 316 | 316 | return $tabs; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function ppp_li_register_metabox_content( $content ) { |
| 331 | 331 | global $ppp_social_settings; |
| 332 | - if ( ! ppp_linkedin_enabled() ) { |
|
| 332 | + if ( ! ppp_linkedin_enabled()) { |
|
| 333 | 333 | return $content; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | function ppp_li_add_metabox_content( $post ) { |
| 369 | 369 | global $ppp_options, $ppp_share_settings; |
| 370 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 370 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 371 | 371 | |
| 372 | 372 | $ppp_li_share_on_publish = get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
| 373 | 373 | $ppp_share_on_publish_title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title', true ); |
@@ -377,9 +377,9 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | $show_share_on_publish = false; |
| 379 | 379 | |
| 380 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['linkedin'] ) ? false : true; |
|
| 380 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['linkedin']) ? false : true; |
|
| 381 | 381 | |
| 382 | - if ( $ppp_li_share_on_publish == '1' || ( $ppp_li_share_on_publish == '' && $share_by_default ) ) { |
|
| 382 | + if ($ppp_li_share_on_publish == '1' || ($ppp_li_share_on_publish == '' && $share_by_default)) { |
|
| 383 | 383 | $show_share_on_publish = true; |
| 384 | 384 | } |
| 385 | 385 | ?> |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | <div class="ppp-post-override-wrap"> |
| 388 | 388 | <p><h3><?php _e( 'Share on LinkedIn', 'ppp-txt' ); ?></h3></p> |
| 389 | 389 | <p> |
| 390 | - <?php $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; ?> |
|
| 390 | + <?php $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; ?> |
|
| 391 | 391 | <label for="ppp_li_share_on_publish"><?php _e( 'Share this post on LinkedIn…', 'ppp-txt' ); ?></label> |
| 392 | 392 | <select name="_ppp_li_share_on_publish" id="ppp_li_share_on_publish" class="ppp-toggle-share-on-publish"> |
| 393 | - <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 394 | - <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 393 | + <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 394 | + <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 395 | 395 | <option value="0" <?php selected( false, $show_share_on_publish, true ); ?>><?php _e( 'After this post is published', 'ppp-txt' ); ?></option> |
| 396 | 396 | </select> |
| 397 | 397 | </p> |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | <th style="width: 10px;"></th> |
| 408 | 408 | </tr> |
| 409 | 409 | </thead> |
| 410 | - <tbody id="li-share-on-publish" class="ppp-share-on-publish" <?php if ( false === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 410 | + <tbody id="li-share-on-publish" class="ppp-share-on-publish" <?php if (false === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 411 | 411 | <?php |
| 412 | 412 | $args = array( |
| 413 | 413 | 'text' => $ppp_share_on_publish_title, |
@@ -419,19 +419,19 @@ discard block |
||
| 419 | 419 | ppp_render_li_share_on_publish_row( $args ); |
| 420 | 420 | ?> |
| 421 | 421 | </tbody> |
| 422 | - <tbody id="li-schedule-share" class="ppp-schedule-share" <?php if ( true === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 422 | + <tbody id="li-schedule-share" class="ppp-schedule-share" <?php if (true === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 423 | 423 | <?php $shares = get_post_meta( $post->ID, '_ppp_li_shares', true ); ?> |
| 424 | - <?php if ( ! empty( $shares ) ) : ?> |
|
| 424 | + <?php if ( ! empty($shares)) : ?> |
|
| 425 | 425 | |
| 426 | - <?php foreach ( $shares as $key => $value ) : |
|
| 427 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 428 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 429 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 430 | - $desc = isset( $value['desc'] ) ? $value['desc'] : ''; |
|
| 431 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 432 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 426 | + <?php foreach ($shares as $key => $value) : |
|
| 427 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 428 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 429 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 430 | + $desc = isset($value['desc']) ? $value['desc'] : ''; |
|
| 431 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 432 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 433 | 433 | |
| 434 | - $args = apply_filters( 'ppp_fb_row_args', compact( 'date','time','text', 'desc', 'image','attachment_id' ), $value ); |
|
| 434 | + $args = apply_filters( 'ppp_fb_row_args', compact( 'date', 'time', 'text', 'desc', 'image', 'attachment_id' ), $value ); |
|
| 435 | 435 | ?> |
| 436 | 436 | |
| 437 | 437 | <?php ppp_render_li_share_row( $key, $args ); ?> |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | function ppp_render_li_share_on_publish_row( $args = array() ) { |
| 468 | 468 | global $post; |
| 469 | 469 | $readonly = $post->post_status !== 'publish' ? '' : 'readonly="readonly" '; |
| 470 | - $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; |
|
| 470 | + $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; |
|
| 471 | 471 | ?> |
| 472 | 472 | <tr class="ppp-li-wrapper ppp-repeatable-row on-publish-row"> |
| 473 | 473 | <td colspan="2" class="ppp-on-plublish-date-column"> |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | <tr> |
| 496 | 496 | <td colspan="2"></td> |
| 497 | 497 | <td colspan="3"> |
| 498 | - <textarea <?php if ( $disabled ): ?>readonly<?php endif; ?> name="_ppp_li_share_on_publish_desc" placeholder="<?php _e( 'Link Description', 'ppp-txt' ); ?>"><?php echo esc_attr( $args['desc'] ); ?></textarea> |
|
| 498 | + <textarea <?php if ($disabled): ?>readonly<?php endif; ?> name="_ppp_li_share_on_publish_desc" placeholder="<?php _e( 'Link Description', 'ppp-txt' ); ?>"><?php echo esc_attr( $args['desc'] ); ?></textarea> |
|
| 499 | 499 | </td> |
| 500 | 500 | </tr> |
| 501 | 501 | <?php |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 517 | 517 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 518 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 519 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 518 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 519 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 520 | 520 | ?> |
| 521 | 521 | <tr class="ppp-li-wrapper ppp-repeatable-row ppp-repeatable-linkedin scheduled-row" data-key="<?php echo esc_attr( $key ); ?>"> |
| 522 | 522 | <td> |
@@ -567,26 +567,26 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | function ppp_li_save_post_meta_boxes( $post_id, $post ) { |
| 569 | 569 | |
| 570 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 570 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 571 | 571 | return; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $ppp_li_share_on_publish = ( isset( $_REQUEST['_ppp_li_share_on_publish'] ) ) ? $_REQUEST['_ppp_li_share_on_publish'] : '-1'; |
|
| 575 | - $ppp_share_on_publish_title = ( isset( $_REQUEST['_ppp_li_share_on_publish_title'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_title'] : ''; |
|
| 576 | - $ppp_share_on_publish_desc = ( isset( $_REQUEST['_ppp_li_share_on_publish_desc'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_desc'] : ''; |
|
| 577 | - $ppp_share_on_publish_image_url = ( isset( $_REQUEST['_ppp_li_share_on_publish_image_url'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 578 | - $ppp_share_on_publish_attachment_id = ( isset( $_REQUEST['_ppp_li_share_on_publish_attachment_id'] ) ) ? $_REQUEST['_ppp_li_share_on_publish_attachment_id'] : ''; |
|
| 574 | + $ppp_li_share_on_publish = (isset($_REQUEST['_ppp_li_share_on_publish'])) ? $_REQUEST['_ppp_li_share_on_publish'] : '-1'; |
|
| 575 | + $ppp_share_on_publish_title = (isset($_REQUEST['_ppp_li_share_on_publish_title'])) ? $_REQUEST['_ppp_li_share_on_publish_title'] : ''; |
|
| 576 | + $ppp_share_on_publish_desc = (isset($_REQUEST['_ppp_li_share_on_publish_desc'])) ? $_REQUEST['_ppp_li_share_on_publish_desc'] : ''; |
|
| 577 | + $ppp_share_on_publish_image_url = (isset($_REQUEST['_ppp_li_share_on_publish_image_url'])) ? $_REQUEST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 578 | + $ppp_share_on_publish_attachment_id = (isset($_REQUEST['_ppp_li_share_on_publish_attachment_id'])) ? $_REQUEST['_ppp_li_share_on_publish_attachment_id'] : ''; |
|
| 579 | 579 | |
| 580 | - update_post_meta( $post_id, '_ppp_li_share_on_publish', $ppp_li_share_on_publish ); |
|
| 581 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 582 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_desc', $ppp_share_on_publish_desc ); |
|
| 583 | - update_post_meta( $post_id, '_ppp_li_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 580 | + update_post_meta( $post_id, '_ppp_li_share_on_publish', $ppp_li_share_on_publish ); |
|
| 581 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 582 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_desc', $ppp_share_on_publish_desc ); |
|
| 583 | + update_post_meta( $post_id, '_ppp_li_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 584 | 584 | update_post_meta( $post_id, '_ppp_li_share_on_publish_attachment_id', $ppp_share_on_publish_attachment_id ); |
| 585 | 585 | |
| 586 | - $li_data = ( isset( $_REQUEST['_ppp_li_shares'] ) && empty( $ppp_li_share_on_publish ) ) ? $_REQUEST['_ppp_li_shares'] : array(); |
|
| 587 | - foreach ( $li_data as $index => $share ) { |
|
| 588 | - $li_data[ $index ]['text'] = sanitize_text_field( $share['text'] ); |
|
| 589 | - $li_data[ $index ]['desc'] = sanitize_text_field( $share['desc'] ); |
|
| 586 | + $li_data = (isset($_REQUEST['_ppp_li_shares']) && empty($ppp_li_share_on_publish)) ? $_REQUEST['_ppp_li_shares'] : array(); |
|
| 587 | + foreach ($li_data as $index => $share) { |
|
| 588 | + $li_data[$index]['text'] = sanitize_text_field( $share['text'] ); |
|
| 589 | + $li_data[$index]['desc'] = sanitize_text_field( $share['desc'] ); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | update_post_meta( $post_id, '_ppp_li_shares', $li_data ); |
@@ -602,10 +602,10 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | function ppp_li_share_on_publish( $new_status, $old_status, $post ) { |
| 604 | 604 | global $ppp_options; |
| 605 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
|
| 606 | - $from_post = isset( $_POST['_ppp_li_share_on_publish'] ) ? $_POST['_ppp_li_share_on_publish']: '0'; |
|
| 605 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_li_share_on_publish', true ); |
|
| 606 | + $from_post = isset($_POST['_ppp_li_share_on_publish']) ? $_POST['_ppp_li_share_on_publish'] : '0'; |
|
| 607 | 607 | |
| 608 | - if ( '1' != $from_meta && '1' != $from_post ) { |
|
| 608 | + if ('1' != $from_meta && '1' != $from_post) { |
|
| 609 | 609 | return; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -618,30 +618,30 @@ discard block |
||
| 618 | 618 | $image_url = ''; |
| 619 | 619 | |
| 620 | 620 | // Determine if we're seeing the share on publish in meta or $_POST |
| 621 | - if ( $from_meta && ! $from_post ) { |
|
| 622 | - $title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title' , true ); |
|
| 623 | - $desc = get_post_meta( $post->ID, '_ppp_li_share_on_publish_desc' , true ); |
|
| 621 | + if ($from_meta && ! $from_post) { |
|
| 622 | + $title = get_post_meta( $post->ID, '_ppp_li_share_on_publish_title', true ); |
|
| 623 | + $desc = get_post_meta( $post->ID, '_ppp_li_share_on_publish_desc', true ); |
|
| 624 | 624 | $attachment_id = get_post_meta( $post->ID, '_ppp_li_share_on_publish_attachment_id', true ); |
| 625 | - $image_url = get_post_meta( $post->ID, '_ppp_li_share_on_publish_image_url' , true ); |
|
| 625 | + $image_url = get_post_meta( $post->ID, '_ppp_li_share_on_publish_image_url', true ); |
|
| 626 | 626 | } else { |
| 627 | - $title = isset( $_POST['_ppp_li_share_on_publish_title'] ) ? $_POST['_ppp_li_share_on_publish_title'] : ''; |
|
| 628 | - $desc = isset( $_POST['_ppp_li_share_on_publish_desc'] ) ? $_POST['_ppp_li_share_on_publish_desc'] : false; |
|
| 629 | - $attachment_id = isset( $_POST['_ppp_li_share_on_publish_attachment_id'] ) ? $_POST['_ppp_li_share_on_publish_attachment_id'] : 0; |
|
| 630 | - $image_url = isset( $_POST['_ppp_li_share_on_publish_image_url'] ) ? $_POST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 627 | + $title = isset($_POST['_ppp_li_share_on_publish_title']) ? $_POST['_ppp_li_share_on_publish_title'] : ''; |
|
| 628 | + $desc = isset($_POST['_ppp_li_share_on_publish_desc']) ? $_POST['_ppp_li_share_on_publish_desc'] : false; |
|
| 629 | + $attachment_id = isset($_POST['_ppp_li_share_on_publish_attachment_id']) ? $_POST['_ppp_li_share_on_publish_attachment_id'] : 0; |
|
| 630 | + $image_url = isset($_POST['_ppp_li_share_on_publish_image_url']) ? $_POST['_ppp_li_share_on_publish_image_url'] : ''; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $thumbnail = ''; |
| 634 | - if ( empty( $attachment_id ) && ! empty( $image_url ) ) { |
|
| 634 | + if (empty($attachment_id) && ! empty($image_url)) { |
|
| 635 | 635 | $thumbnail = $image_url; |
| 636 | 636 | } else { |
| 637 | 637 | $thumbnail = ppp_post_has_media( $post->ID, 'li', true, $attachment_id ); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - $name = 'sharedate_0_' . $post->ID . '_li'; |
|
| 640 | + $name = 'sharedate_0_'.$post->ID.'_li'; |
|
| 641 | 641 | |
| 642 | - $default_title = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 642 | + $default_title = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 643 | 643 | // If an override was found, use it, otherwise try the default text content |
| 644 | - if ( empty( $title ) && empty( $default_title ) ) { |
|
| 644 | + if (empty($title) && empty($default_title)) { |
|
| 645 | 645 | $title = get_the_title( $post->ID ); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | * @param string $name The name of the Cron |
| 677 | 677 | * @return void |
| 678 | 678 | */ |
| 679 | -function ppp_li_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 679 | +function ppp_li_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 680 | 680 | global $ppp_options; |
| 681 | 681 | |
| 682 | 682 | $link = ppp_generate_link( $post_id, $name ); |
| 683 | 683 | |
| 684 | 684 | $post_meta = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 685 | - $this_share = $post_meta[ $index ]; |
|
| 686 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 685 | + $this_share = $post_meta[$index]; |
|
| 686 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 687 | 687 | |
| 688 | 688 | $share_message = ppp_li_build_share_message( $post_id, $name ); |
| 689 | 689 | |
| 690 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 690 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 691 | 691 | $media = $this_share['image']; |
| 692 | 692 | } else { |
| 693 | 693 | $use_media = ppp_li_use_media( $post_id, $index ); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | * @return bool Whether or not this tweet should contain a media post |
| 725 | 725 | */ |
| 726 | 726 | function ppp_li_use_media( $post_id, $index ) { |
| 727 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 727 | + if (empty($post_id) || empty($index)) { |
|
| 728 | 728 | return false; |
| 729 | 729 | } |
| 730 | 730 | |
@@ -757,22 +757,22 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | function ppp_li_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 759 | 759 | global $ppp_options; |
| 760 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 760 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 761 | 761 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 762 | 762 | |
| 763 | - if ( ! empty( $li_shares ) ) { |
|
| 763 | + if ( ! empty($li_shares)) { |
|
| 764 | 764 | $name_array = explode( '_', $name ); |
| 765 | 765 | $index = $name_array[1]; |
| 766 | - if ( isset( $li_shares[ $index ] ) ) { |
|
| 767 | - $share_content = $li_shares[ $index ]['text']; |
|
| 766 | + if (isset($li_shares[$index])) { |
|
| 767 | + $share_content = $li_shares[$index]['text']; |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | // If an override was found, use it, otherwise try the default text content |
| 772 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 772 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 773 | 773 | |
| 774 | 774 | // If the content is still empty, just use the post title |
| 775 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 775 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 776 | 776 | |
| 777 | 777 | return apply_filters( 'ppp_share_content_li', $share_content, array( 'post_id' => $post_id ) ); |
| 778 | 778 | } |
@@ -789,8 +789,8 @@ discard block |
||
| 789 | 789 | $description = ''; |
| 790 | 790 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 791 | 791 | |
| 792 | - if ( ! empty( $li_shares[ $index ] ) ) { |
|
| 793 | - $description = ! empty( $li_shares[ $index ]['desc'] ) ? $li_shares[ $index ]['desc'] : ''; |
|
| 792 | + if ( ! empty($li_shares[$index])) { |
|
| 793 | + $description = ! empty($li_shares[$index]['desc']) ? $li_shares[$index]['desc'] : ''; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | return $description; |
@@ -807,20 +807,20 @@ discard block |
||
| 807 | 807 | function ppp_li_generate_timestamps( $times, $post_id ) { |
| 808 | 808 | $li_shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 809 | 809 | |
| 810 | - if ( empty( $li_shares ) ) { |
|
| 810 | + if (empty($li_shares)) { |
|
| 811 | 811 | $li_shares = array(); |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - foreach ( $li_shares as $key => $data ) { |
|
| 815 | - if ( ! array_filter( $data ) ) { |
|
| 814 | + foreach ($li_shares as $key => $data) { |
|
| 815 | + if ( ! array_filter( $data )) { |
|
| 816 | 816 | continue; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 820 | 820 | |
| 821 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 822 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_li'; |
|
| 823 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_li'; |
|
| 821 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 822 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_li'; |
|
| 823 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_li'; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | } |
@@ -840,14 +840,14 @@ discard block |
||
| 840 | 840 | function ppp_li_calendar_on_publish_event( $events, $post_id ) { |
| 841 | 841 | $share_on_publish = get_post_meta( $post_id, '_ppp_li_share_on_publish', true ); |
| 842 | 842 | |
| 843 | - if ( ! empty( $share_on_publish ) ) { |
|
| 843 | + if ( ! empty($share_on_publish)) { |
|
| 844 | 844 | $share_text = get_post_meta( $post_id, '_ppp_li_share_on_publish_title', true ); |
| 845 | 845 | $events[] = array( |
| 846 | - 'id' => $post_id . '-share-on-publish', |
|
| 847 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_li_generate_share_content( $post_id, null, false ), |
|
| 848 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 849 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 850 | - 'className' => 'ppp-calendar-item-li cal-post-' . $post_id, |
|
| 846 | + 'id' => $post_id.'-share-on-publish', |
|
| 847 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_li_generate_share_content( $post_id, null, false ), |
|
| 848 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 849 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 850 | + 'className' => 'ppp-calendar-item-li cal-post-'.$post_id, |
|
| 851 | 851 | 'belongsTo' => $post_id, |
| 852 | 852 | ); |
| 853 | 853 | } |
@@ -858,9 +858,9 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | function ppp_li_get_post_shares( $items, $post_id ) { |
| 860 | 860 | $shares = get_post_meta( $post_id, '_ppp_li_shares', true ); |
| 861 | - if ( empty( $shares ) ) { return $items; } |
|
| 861 | + if (empty($shares)) { return $items; } |
|
| 862 | 862 | |
| 863 | - foreach ( $shares as $key => $share ) { |
|
| 863 | + foreach ($shares as $key => $share) { |
|
| 864 | 864 | $items[] = array( 'id' => $key, 'service' => 'li' ); |
| 865 | 865 | } |
| 866 | 866 | return $items; |
@@ -464,9 +464,12 @@ |
||
| 464 | 464 | |
| 465 | 465 | <?php endforeach; ?> |
| 466 | 466 | |
| 467 | - <?php else: ?> |
|
| 467 | + <?php else { |
|
| 468 | + : ?> |
|
| 468 | 469 | |
| 469 | - <?php ppp_render_fb_share_row( 1, array( 'date' => '', 'time' => '', 'text' => '', 'image' => '', 'attachment_id' => '' ), $post->ID, 1 ); ?> |
|
| 470 | + <?php ppp_render_fb_share_row( 1, array( 'date' => '', 'time' => '', 'text' => '', 'image' => '', 'attachment_id' => '' ), $post->ID, 1 ); |
|
| 471 | +} |
|
| 472 | +?> |
|
| 470 | 473 | |
| 471 | 474 | <?php endif; ?> |
| 472 | 475 | </tbody> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | function ppp_facebook_enabled() { |
| 13 | 13 | global $ppp_social_settings; |
| 14 | 14 | |
| 15 | - if ( isset( $ppp_social_settings['facebook'] ) && !empty( $ppp_social_settings['facebook'] ) ) { |
|
| 15 | + if (isset($ppp_social_settings['facebook']) && ! empty($ppp_social_settings['facebook'])) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function ppp_fb_account_list_avatar( $string = '' ) { |
| 52 | 52 | |
| 53 | - if ( ppp_facebook_enabled() ) { |
|
| 53 | + if (ppp_facebook_enabled()) { |
|
| 54 | 54 | global $ppp_social_settings; |
| 55 | 55 | $avatar_url = $ppp_social_settings['facebook']->avatar; |
| 56 | - $string = '<img class="ppp-social-icon" src="' . $avatar_url . '" />'; |
|
| 56 | + $string = '<img class="ppp-social-icon" src="'.$avatar_url.'" />'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $string; |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function ppp_fb_account_list_name( $string = '' ) { |
| 69 | 69 | |
| 70 | - if ( ppp_facebook_enabled() ) { |
|
| 70 | + if (ppp_facebook_enabled()) { |
|
| 71 | 71 | global $ppp_social_settings; |
| 72 | - $string = $ppp_social_settings['facebook']->name; |
|
| 72 | + $string = $ppp_social_settings['facebook']->name; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $string; |
@@ -84,22 +84,22 @@ discard block |
||
| 84 | 84 | function ppp_fb_account_list_actions( $string = '' ) { |
| 85 | 85 | global $ppp_facebook_oauth, $ppp_social_settings; |
| 86 | 86 | |
| 87 | - if ( ! ppp_facebook_enabled() ) { |
|
| 87 | + if ( ! ppp_facebook_enabled()) { |
|
| 88 | 88 | |
| 89 | 89 | $fb_authurl = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 90 | 90 | |
| 91 | - $string .= '<a class="button-primary" href="' . $fb_authurl . '">' . __( 'Connect to Facebook', 'ppp-txt' ) . '</a>'; |
|
| 91 | + $string .= '<a class="button-primary" href="'.$fb_authurl.'">'.__( 'Connect to Facebook', 'ppp-txt' ).'</a>'; |
|
| 92 | 92 | } else { |
| 93 | - $string .= '<a class="button-primary" href="' . admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=facebook' ) . '" >' . __( 'Disconnect from Facebook', 'ppp-txt' ) . '</a> '; |
|
| 93 | + $string .= '<a class="button-primary" href="'.admin_url( 'admin.php?page=ppp-social-settings&ppp_social_disconnect=true&ppp_network=facebook' ).'" >'.__( 'Disconnect from Facebook', 'ppp-txt' ).'</a> '; |
|
| 94 | 94 | |
| 95 | 95 | $refresh_date = (int) get_option( '_ppp_facebook_refresh', true ); |
| 96 | 96 | |
| 97 | - if ( defined( 'PPP_FB_APP_ID' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 97 | + if (defined( 'PPP_FB_APP_ID' ) && current_time( 'timestamp' ) > $refresh_date) { |
|
| 98 | 98 | $token = $ppp_social_settings['facebook']->access_token; |
| 99 | 99 | $url = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 100 | - $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 100 | + $refresh_url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 101 | 101 | |
| 102 | - $string .= '<a class="button-secondary" href="' . $refresh_url . '" >' . __( 'Re-Authorize Facebook', 'ppp-txt' ) . '</a> '; |
|
| 102 | + $string .= '<a class="button-secondary" href="'.$refresh_url.'" >'.__( 'Re-Authorize Facebook', 'ppp-txt' ).'</a> '; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -114,27 +114,27 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function ppp_fb_account_list_extras( $string ) { |
| 116 | 116 | |
| 117 | - if ( ppp_facebook_enabled() ) { |
|
| 117 | + if (ppp_facebook_enabled()) { |
|
| 118 | 118 | global $ppp_social_settings, $ppp_facebook_oauth, $ppp_options; |
| 119 | 119 | $pages = $ppp_facebook_oauth->ppp_get_fb_user_pages( $ppp_social_settings['facebook']->access_token ); |
| 120 | - $selected = isset( $ppp_social_settings['facebook']->page ) ? stripslashes( $ppp_social_settings['facebook']->page ) : 'me'; |
|
| 120 | + $selected = isset($ppp_social_settings['facebook']->page) ? stripslashes( $ppp_social_settings['facebook']->page ) : 'me'; |
|
| 121 | 121 | |
| 122 | - if ( !empty( $pages ) ) { |
|
| 123 | - $string = '<label>' . __( 'Publish as:', 'ppp-txt' ) . '</label><br />'; |
|
| 122 | + if ( ! empty($pages)) { |
|
| 123 | + $string = '<label>'.__( 'Publish as:', 'ppp-txt' ).'</label><br />'; |
|
| 124 | 124 | $string .= '<select id="fb-page">'; |
| 125 | - foreach ( $pages as $page ) { |
|
| 126 | - $value = $page->name . '|' . $page->access_token . '|' . $page->id; |
|
| 127 | - $string .= '<option ' . selected( $value, $selected, false ) . ' value="' . $value . '">' . $page->name . '</option>'; |
|
| 125 | + foreach ($pages as $page) { |
|
| 126 | + $value = $page->name.'|'.$page->access_token.'|'.$page->id; |
|
| 127 | + $string .= '<option '.selected( $value, $selected, false ).' value="'.$value.'">'.$page->name.'</option>'; |
|
| 128 | 128 | } |
| 129 | 129 | $string .= '</select><span class="spinner"></span>'; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( ! empty( $ppp_options['enable_debug'] ) ) { |
|
| 133 | - $days_left = absint( round( ( $ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 134 | - $refresh_in = absint( round( ( get_option( '_ppp_facebook_refresh' ) - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ) ); |
|
| 132 | + if ( ! empty($ppp_options['enable_debug'])) { |
|
| 133 | + $days_left = absint( round( ($ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 134 | + $refresh_in = absint( round( (get_option( '_ppp_facebook_refresh' ) - current_time( 'timestamp' )) / DAY_IN_SECONDS ) ); |
|
| 135 | 135 | |
| 136 | - $string .= '<br />' . sprintf( __( 'Token expires in %s days' , 'ppp-txt' ), $days_left ); |
|
| 137 | - $string .= '<br />' . sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 136 | + $string .= '<br />'.sprintf( __( 'Token expires in %s days', 'ppp-txt' ), $days_left ); |
|
| 137 | + $string .= '<br />'.sprintf( __( 'Refresh notice in %s days', 'ppp-txt' ), $refresh_in ); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | 150 | function ppp_set_fb_token_constants( $social_tokens ) { |
| 151 | - if ( !empty( $social_tokens ) && property_exists( $social_tokens, 'facebook' ) ) { |
|
| 151 | + if ( ! empty($social_tokens) && property_exists( $social_tokens, 'facebook' )) { |
|
| 152 | 152 | define( 'PPP_FB_APP_ID', $social_tokens->facebook->app_id ); |
| 153 | 153 | define( 'PPP_FB_APP_SECRET', $social_tokens->facebook->app_secret ); |
| 154 | 154 | } |
@@ -162,17 +162,17 @@ discard block |
||
| 162 | 162 | function ppp_capture_facebook_oauth() { |
| 163 | 163 | $should_capture = false; |
| 164 | 164 | |
| 165 | - if ( isset( $_GET['state'] ) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false ) { |
|
| 165 | + if (isset($_GET['state']) && strpos( $_GET['state'], 'ppp-local-keys-fb' ) !== false) { |
|
| 166 | 166 | // Local config |
| 167 | 167 | $should_capture = true; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( isset( $_REQUEST['fb_access_token'] ) ) { |
|
| 170 | + if (isset($_REQUEST['fb_access_token'])) { |
|
| 171 | 171 | // Returning from remote config |
| 172 | 172 | $should_capture = true; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( $should_capture && ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ppp-social-settings' ) ) { |
|
| 175 | + if ($should_capture && (isset($_REQUEST['page']) && $_REQUEST['page'] == 'ppp-social-settings')) { |
|
| 176 | 176 | global $ppp_facebook_oauth; |
| 177 | 177 | $ppp_facebook_oauth->ppp_initialize_facebook(); |
| 178 | 178 | wp_redirect( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | function ppp_disconnect_facebook() { |
| 190 | 190 | global $ppp_social_settings; |
| 191 | 191 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 192 | - if ( isset( $ppp_social_settings['facebook'] ) ) { |
|
| 193 | - unset( $ppp_social_settings['facebook'] ); |
|
| 192 | + if (isset($ppp_social_settings['facebook'])) { |
|
| 193 | + unset($ppp_social_settings['facebook']); |
|
| 194 | 194 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 195 | 195 | delete_option( '_ppp_facebook_refresh' ); |
| 196 | 196 | } |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function ppp_fb_execute_refresh() { |
| 218 | 218 | |
| 219 | - if ( ! ppp_facebook_enabled() ) { |
|
| 219 | + if ( ! ppp_facebook_enabled()) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $refresh_date = (int) get_option( '_ppp_facebook_refresh', true ); |
| 224 | 224 | |
| 225 | - if ( ( empty( $_GET['page' ] ) || $_GET['page'] !== 'ppp-social-settings' ) && current_time( 'timestamp' ) > $refresh_date ) { |
|
| 225 | + if ((empty($_GET['page']) || $_GET['page'] !== 'ppp-social-settings') && current_time( 'timestamp' ) > $refresh_date) { |
|
| 226 | 226 | add_action( 'admin_notices', 'ppp_facebook_refresh_notice' ); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | function ppp_facebook_refresh_notice() { |
| 236 | 236 | |
| 237 | - if ( ! ppp_facebook_enabled() ) { |
|
| 237 | + if ( ! ppp_facebook_enabled()) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $has_dismissed = get_transient( 'ppp-dismiss-refresh-fb' . get_current_user_id() ); |
|
| 242 | - if ( false !== $has_dismissed ) { |
|
| 241 | + $has_dismissed = get_transient( 'ppp-dismiss-refresh-fb'.get_current_user_id() ); |
|
| 242 | + if (false !== $has_dismissed) { |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $token = $ppp_social_settings['facebook']->access_token; |
| 252 | 252 | $url = $ppp_facebook_oauth->ppp_get_facebook_auth_url( admin_url( 'admin.php?page=ppp-social-settings' ) ); |
| 253 | - $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token=' . $token, $url ); |
|
| 253 | + $url = str_replace( '?ppp-social-auth', '?ppp-social-auth&ppp-refresh=true&access_token='.$token, $url ); |
|
| 254 | 254 | |
| 255 | - $days_left = (int) round( ( $ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' ) ) / DAY_IN_SECONDS ); |
|
| 255 | + $days_left = (int) round( ($ppp_social_settings['facebook']->expires_on - current_time( 'timestamp' )) / DAY_IN_SECONDS ); |
|
| 256 | 256 | ?> |
| 257 | 257 | <div class="notice notice-warning is-dismissible" data-service="fb"> |
| 258 | - <?php if ( $days_left > 0 ): ?> |
|
| 258 | + <?php if ($days_left > 0): ?> |
|
| 259 | 259 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your Facebook authentication expires in %d days. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $days_left, $url ); ?></p> |
| 260 | - <?php elseif ( $days_left < 1 ): ?> |
|
| 260 | + <?php elseif ($days_left < 1): ?> |
|
| 261 | 261 | <p><strong>Post Promoter Pro: </strong><?php printf( __( 'Your Facebook authentication has expired. Please <a href="%s">refresh access</a>.', 'ppp-txt' ), $url ); ?></p> |
| 262 | 262 | <?php endif; ?> |
| 263 | 263 | </div> |
@@ -272,10 +272,10 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | function ppp_fb_dismiss_notice() { |
| 274 | 274 | |
| 275 | - $nag = sanitize_key( $_POST[ 'nag' ] ); |
|
| 275 | + $nag = sanitize_key( $_POST['nag'] ); |
|
| 276 | 276 | |
| 277 | - if ( $nag === $_POST[ 'nag' ] ) { |
|
| 278 | - set_transient( $nag . get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 277 | + if ($nag === $_POST['nag']) { |
|
| 278 | + set_transient( $nag.get_current_user_id(), true, DAY_IN_SECONDS ); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | * @param string $name The name of the Cron |
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | -function ppp_fb_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 306 | +function ppp_fb_scheduled_share( $post_id = 0, $index = 1, $name = '' ) { |
|
| 307 | 307 | global $ppp_options; |
| 308 | 308 | |
| 309 | 309 | $link = ppp_generate_link( $post_id, $name ); |
| 310 | 310 | |
| 311 | 311 | $post_meta = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 312 | - $this_share = $post_meta[ $index ]; |
|
| 313 | - $attachment_id = isset( $this_share['attachment_id'] ) ? $this_share['attachment_id'] : false; |
|
| 312 | + $this_share = $post_meta[$index]; |
|
| 313 | + $attachment_id = isset($this_share['attachment_id']) ? $this_share['attachment_id'] : false; |
|
| 314 | 314 | |
| 315 | 315 | $share_message = ppp_fb_build_share_message( $post_id, $name ); |
| 316 | 316 | |
| 317 | - if ( empty( $attachment_id ) && ! empty( $this_share['image'] ) ) { |
|
| 317 | + if (empty($attachment_id) && ! empty($this_share['image'])) { |
|
| 318 | 318 | $media = $this_share['image']; |
| 319 | 319 | } else { |
| 320 | 320 | $use_media = ppp_fb_use_media( $post_id, $index ); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function ppp_fb_add_meta_tab( $tabs ) { |
| 374 | 374 | global $ppp_social_settings; |
| 375 | - if ( ! ppp_facebook_enabled() ) { |
|
| 375 | + if ( ! ppp_facebook_enabled()) { |
|
| 376 | 376 | return $tabs; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | function ppp_fb_register_metabox_content( $content ) { |
| 391 | 391 | global $ppp_social_settings; |
| 392 | - if ( ! ppp_facebook_enabled() ) { |
|
| 392 | + if ( ! ppp_facebook_enabled()) { |
|
| 393 | 393 | return $content; |
| 394 | 394 | } |
| 395 | 395 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function ppp_fb_add_metabox_content( $post ) { |
| 407 | 407 | global $ppp_options, $ppp_share_settings; |
| 408 | - $default_text = !empty( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 408 | + $default_text = ! empty($ppp_options['default_text']) ? $ppp_options['default_text'] : __( 'Social Text', 'ppp-txt' ); |
|
| 409 | 409 | |
| 410 | 410 | $ppp_fb_share_on_publish = get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
| 411 | 411 | $ppp_share_on_publish_title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | $show_share_on_publish = false; |
| 416 | 416 | |
| 417 | - $share_by_default = empty( $ppp_share_settings['share_on_publish'][ $post->post_type ]['facebook'] ) ? false : true; |
|
| 417 | + $share_by_default = empty($ppp_share_settings['share_on_publish'][$post->post_type]['facebook']) ? false : true; |
|
| 418 | 418 | |
| 419 | - if ( $ppp_fb_share_on_publish == '1' || ( $ppp_fb_share_on_publish == '' && $share_by_default ) ) { |
|
| 419 | + if ($ppp_fb_share_on_publish == '1' || ($ppp_fb_share_on_publish == '' && $share_by_default)) { |
|
| 420 | 420 | $show_share_on_publish = true; |
| 421 | 421 | } |
| 422 | 422 | |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | <div class="ppp-post-override-wrap"> |
| 426 | 426 | <p><h3><?php _e( 'Share on Facebook', 'ppp-txt' ); ?></h3></p> |
| 427 | 427 | <p> |
| 428 | - <?php $disabled = ( $post->post_status === 'publish' && time() > strtotime( $post->post_date ) ) ? true : false; ?> |
|
| 428 | + <?php $disabled = ($post->post_status === 'publish' && time() > strtotime( $post->post_date )) ? true : false; ?> |
|
| 429 | 429 | <label for="ppp_fb_share_on_publish"><?php _e( 'Share this post on Facebook…', 'ppp-txt' ); ?></label> |
| 430 | 430 | <select name="_ppp_fb_share_on_publish" id="ppp_fb_share_on_publish" class="ppp-toggle-share-on-publish"> |
| 431 | - <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 432 | - <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ( $disabled ): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 431 | + <option value="-1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'Do not share this post', 'ppp-txt' ); ?></option> |
|
| 432 | + <option value="1" <?php selected( true, $show_share_on_publish, true ); ?><?php if ($disabled): ?>disabled<?php endif; ?>><?php _e( 'When this post is published', 'ppp-txt' ); ?></option> |
|
| 433 | 433 | <option value="0" <?php selected( false, $show_share_on_publish, true ); ?>><?php _e( 'After this post is published', 'ppp-txt' ); ?></option> |
| 434 | 434 | </select> |
| 435 | 435 | </p> |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | <th style="width: 10px;"></th> |
| 446 | 446 | </tr> |
| 447 | 447 | </thead> |
| 448 | - <tbody id="fb-share-on-publish" class="ppp-share-on-publish" <?php if ( false === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 448 | + <tbody id="fb-share-on-publish" class="ppp-share-on-publish" <?php if (false === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 449 | 449 | <?php |
| 450 | 450 | $args = array( |
| 451 | 451 | 'text' => $ppp_share_on_publish_title, |
@@ -456,18 +456,18 @@ discard block |
||
| 456 | 456 | ppp_render_fb_share_on_publish_row( $args ); |
| 457 | 457 | ?> |
| 458 | 458 | </tbody> |
| 459 | - <tbody id="fb-schedule-share" class="ppp-schedule-share" <?php if ( true === $show_share_on_publish ) : echo 'style="display: none;"'; endif; ?>> |
|
| 459 | + <tbody id="fb-schedule-share" class="ppp-schedule-share" <?php if (true === $show_share_on_publish) : echo 'style="display: none;"'; endif; ?>> |
|
| 460 | 460 | <?php $shares = get_post_meta( $post->ID, '_ppp_fb_shares', true ); ?> |
| 461 | - <?php if ( ! empty( $shares ) ) : ?> |
|
| 461 | + <?php if ( ! empty($shares)) : ?> |
|
| 462 | 462 | |
| 463 | - <?php foreach ( $shares as $key => $value ) : |
|
| 464 | - $date = isset( $value['date'] ) ? $value['date'] : ''; |
|
| 465 | - $time = isset( $value['time'] ) ? $value['time'] : ''; |
|
| 466 | - $text = isset( $value['text'] ) ? $value['text'] : ''; |
|
| 467 | - $image = isset( $value['image'] ) ? $value['image'] : ''; |
|
| 468 | - $attachment_id = isset( $value['attachment_id'] ) ? $value['attachment_id'] : ''; |
|
| 463 | + <?php foreach ($shares as $key => $value) : |
|
| 464 | + $date = isset($value['date']) ? $value['date'] : ''; |
|
| 465 | + $time = isset($value['time']) ? $value['time'] : ''; |
|
| 466 | + $text = isset($value['text']) ? $value['text'] : ''; |
|
| 467 | + $image = isset($value['image']) ? $value['image'] : ''; |
|
| 468 | + $attachment_id = isset($value['attachment_id']) ? $value['attachment_id'] : ''; |
|
| 469 | 469 | |
| 470 | - $args = apply_filters( 'ppp_fb_row_args', compact( 'date','time','text','image','attachment_id' ), $value ); |
|
| 470 | + $args = apply_filters( 'ppp_fb_row_args', compact( 'date', 'time', 'text', 'image', 'attachment_id' ), $value ); |
|
| 471 | 471 | ?> |
| 472 | 472 | |
| 473 | 473 | <?php ppp_render_fb_share_row( $key, $args, $post->ID ); ?> |
@@ -547,8 +547,8 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | $share_time = ppp_generate_timestamp( $args['date'], $args['time'] ); |
| 549 | 549 | $readonly = ppp_generate_timestamp() > $share_time ? 'readonly="readonly" ' : false; |
| 550 | - $no_date = ! empty( $readonly ) ? ' hasDatepicker' : ''; |
|
| 551 | - $hide = ! empty( $readonly ) ? 'display: none;' : ''; |
|
| 550 | + $no_date = ! empty($readonly) ? ' hasDatepicker' : ''; |
|
| 551 | + $hide = ! empty($readonly) ? 'display: none;' : ''; |
|
| 552 | 552 | ?> |
| 553 | 553 | <tr class="ppp-fb-wrapper ppp-repeatable-row ppp-repeatable-facebook scheduled-row" data-key="<?php echo esc_attr( $key ); ?>"> |
| 554 | 554 | <td> |
@@ -593,23 +593,23 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | function ppp_fb_save_post_meta_boxes( $post_id, $post ) { |
| 595 | 595 | |
| 596 | - if ( ! ppp_should_save( $post_id, $post ) ) { |
|
| 596 | + if ( ! ppp_should_save( $post_id, $post )) { |
|
| 597 | 597 | return; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - $ppp_fb_share_on_publish = ( isset( $_REQUEST['_ppp_fb_share_on_publish'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish'] : '-1'; |
|
| 601 | - $ppp_share_on_publish_title = ( isset( $_REQUEST['_ppp_fb_share_on_publish_title'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 602 | - $ppp_share_on_publish_image_url = ( isset( $_REQUEST['_ppp_fb_share_on_publish_image_url'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 603 | - $ppp_share_on_publish_attachment_id = ( isset( $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] ) ) ? $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] : ''; |
|
| 600 | + $ppp_fb_share_on_publish = (isset($_REQUEST['_ppp_fb_share_on_publish'])) ? $_REQUEST['_ppp_fb_share_on_publish'] : '-1'; |
|
| 601 | + $ppp_share_on_publish_title = (isset($_REQUEST['_ppp_fb_share_on_publish_title'])) ? $_REQUEST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 602 | + $ppp_share_on_publish_image_url = (isset($_REQUEST['_ppp_fb_share_on_publish_image_url'])) ? $_REQUEST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 603 | + $ppp_share_on_publish_attachment_id = (isset($_REQUEST['_ppp_fb_share_on_publish_attachment_id'])) ? $_REQUEST['_ppp_fb_share_on_publish_attachment_id'] : ''; |
|
| 604 | 604 | |
| 605 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish', $ppp_fb_share_on_publish ); |
|
| 606 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 607 | - update_post_meta( $post_id, '_ppp_fb_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 605 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish', $ppp_fb_share_on_publish ); |
|
| 606 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish_title', $ppp_share_on_publish_title ); |
|
| 607 | + update_post_meta( $post_id, '_ppp_fb_share_on_publish_image_url', $ppp_share_on_publish_image_url ); |
|
| 608 | 608 | update_post_meta( $post_id, '_ppp_fb_share_on_publish_attachment_id', $ppp_share_on_publish_attachment_id ); |
| 609 | 609 | |
| 610 | - $fb_data = ( isset( $_REQUEST['_ppp_fb_shares'] ) && empty( $ppp_fb_share_on_publish ) ) ? $_REQUEST['_ppp_fb_shares'] : array(); |
|
| 611 | - foreach ( $fb_data as $index => $share ) { |
|
| 612 | - $fb_data[ $index ]['text'] = sanitize_text_field( $share['text'] ); |
|
| 610 | + $fb_data = (isset($_REQUEST['_ppp_fb_shares']) && empty($ppp_fb_share_on_publish)) ? $_REQUEST['_ppp_fb_shares'] : array(); |
|
| 611 | + foreach ($fb_data as $index => $share) { |
|
| 612 | + $fb_data[$index]['text'] = sanitize_text_field( $share['text'] ); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | update_post_meta( $post_id, '_ppp_fb_shares', $fb_data ); |
@@ -626,10 +626,10 @@ discard block |
||
| 626 | 626 | function ppp_fb_share_on_publish( $new_status, $old_status, $post ) { |
| 627 | 627 | global $ppp_options; |
| 628 | 628 | |
| 629 | - $from_meta = ! empty( $_POST['ppp_post_edit'] ) ? false : get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
|
| 630 | - $from_post = isset( $_POST['_ppp_fb_share_on_publish'] ) ? $_POST['_ppp_fb_share_on_publish'] : '0'; |
|
| 629 | + $from_meta = ! empty($_POST['ppp_post_edit']) ? false : get_post_meta( $post->ID, '_ppp_fb_share_on_publish', true ); |
|
| 630 | + $from_post = isset($_POST['_ppp_fb_share_on_publish']) ? $_POST['_ppp_fb_share_on_publish'] : '0'; |
|
| 631 | 631 | |
| 632 | - if ( '1' != $from_meta && '1' != $from_post ) { |
|
| 632 | + if ('1' != $from_meta && '1' != $from_post) { |
|
| 633 | 633 | return; |
| 634 | 634 | } |
| 635 | 635 | |
@@ -641,28 +641,28 @@ discard block |
||
| 641 | 641 | $image_url = ''; |
| 642 | 642 | |
| 643 | 643 | // Determine if we're seeing the share on publish in meta or $_POST |
| 644 | - if ( $from_meta && ! $from_post ) { |
|
| 645 | - $title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
|
| 644 | + if ($from_meta && ! $from_post) { |
|
| 645 | + $title = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_title', true ); |
|
| 646 | 646 | $attachment_id = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_attachment_id', true ); |
| 647 | - $image_url = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_image_url', true ); |
|
| 647 | + $image_url = get_post_meta( $post->ID, '_ppp_fb_share_on_publish_image_url', true ); |
|
| 648 | 648 | } else { |
| 649 | - $title = isset( $_POST['_ppp_fb_share_on_publish_title'] ) ? $_POST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 650 | - $attachment_id = isset( $_POST['_ppp_fb_share_on_publish_attachment_id'] ) ? $_POST['_ppp_fb_share_on_publish_attachment_id'] : 0; |
|
| 651 | - $image_url = isset( $_POST['_ppp_fb_share_on_publish_image_url'] ) ? $_POST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 649 | + $title = isset($_POST['_ppp_fb_share_on_publish_title']) ? $_POST['_ppp_fb_share_on_publish_title'] : ''; |
|
| 650 | + $attachment_id = isset($_POST['_ppp_fb_share_on_publish_attachment_id']) ? $_POST['_ppp_fb_share_on_publish_attachment_id'] : 0; |
|
| 651 | + $image_url = isset($_POST['_ppp_fb_share_on_publish_image_url']) ? $_POST['_ppp_fb_share_on_publish_image_url'] : ''; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | $thumbnail = ''; |
| 655 | - if ( empty( $attachment_id ) && ! empty( $image_url ) ) { |
|
| 655 | + if (empty($attachment_id) && ! empty($image_url)) { |
|
| 656 | 656 | $thumbnail = $image_url; |
| 657 | 657 | } else { |
| 658 | 658 | $thumbnail = ppp_post_has_media( $post->ID, 'fb', true, $attachment_id ); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - $name = 'sharedate_0_' . $post->ID . '_fb'; |
|
| 661 | + $name = 'sharedate_0_'.$post->ID.'_fb'; |
|
| 662 | 662 | |
| 663 | - $default_title = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 663 | + $default_title = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 664 | 664 | // If an override was found, use it, otherwise try the default text content |
| 665 | - if ( empty( $title ) && empty( $default_title ) ) { |
|
| 665 | + if (empty($title) && empty($default_title)) { |
|
| 666 | 666 | $title = get_the_title( $post->ID ); |
| 667 | 667 | } |
| 668 | 668 | |
@@ -702,20 +702,20 @@ discard block |
||
| 702 | 702 | function ppp_fb_generate_timestamps( $times, $post_id ) { |
| 703 | 703 | $fb_shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 704 | 704 | |
| 705 | - if ( empty( $fb_shares ) ) { |
|
| 705 | + if (empty($fb_shares)) { |
|
| 706 | 706 | $fb_shares = array(); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - foreach ( $fb_shares as $key => $data ) { |
|
| 710 | - if ( ! array_filter( $data ) ) { |
|
| 709 | + foreach ($fb_shares as $key => $data) { |
|
| 710 | + if ( ! array_filter( $data )) { |
|
| 711 | 711 | continue; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | $timestamp = ppp_generate_timestamp( $data['date'], $data['time'] ); |
| 715 | 715 | |
| 716 | - if ( $timestamp > current_time( 'timestamp', 1 ) ) { // Make sure the timestamp we're getting is in the future |
|
| 717 | - $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp , true ) ) . '_fb'; |
|
| 718 | - $times[ $time_key ] = 'sharedate_' . $key . '_' . $post_id . '_fb'; |
|
| 716 | + if ($timestamp > current_time( 'timestamp', 1 )) { // Make sure the timestamp we're getting is in the future |
|
| 717 | + $time_key = strtotime( date_i18n( 'd-m-Y H:i:s', $timestamp, true ) ).'_fb'; |
|
| 718 | + $times[$time_key] = 'sharedate_'.$key.'_'.$post_id.'_fb'; |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | } |
@@ -765,22 +765,22 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | function ppp_fb_generate_share_content( $post_id, $name, $is_scheduled = true ) { |
| 767 | 767 | global $ppp_options; |
| 768 | - $default_text = isset( $ppp_options['default_text'] ) ? $ppp_options['default_text'] : ''; |
|
| 768 | + $default_text = isset($ppp_options['default_text']) ? $ppp_options['default_text'] : ''; |
|
| 769 | 769 | $fb_shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 770 | 770 | |
| 771 | - if ( ! empty( $fb_shares ) ) { |
|
| 771 | + if ( ! empty($fb_shares)) { |
|
| 772 | 772 | $name_array = explode( '_', $name ); |
| 773 | 773 | $index = $name_array[1]; |
| 774 | - if ( isset( $fb_shares[ $index ] ) ) { |
|
| 775 | - $share_content = $fb_shares[ $index ]['text']; |
|
| 774 | + if (isset($fb_shares[$index])) { |
|
| 775 | + $share_content = $fb_shares[$index]['text']; |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | // If an override was found, use it, otherwise try the default text content |
| 780 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : $default_text; |
|
| 780 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : $default_text; |
|
| 781 | 781 | |
| 782 | 782 | // If the content is still empty, just use the post title |
| 783 | - $share_content = ( isset( $share_content ) && !empty( $share_content ) ) ? $share_content : get_the_title( $post_id ); |
|
| 783 | + $share_content = (isset($share_content) && ! empty($share_content)) ? $share_content : get_the_title( $post_id ); |
|
| 784 | 784 | |
| 785 | 785 | return apply_filters( 'ppp_share_content_fb', $share_content, array( 'post_id' => $post_id ) ); |
| 786 | 786 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @return bool Whether or not this tweet should contain a media post |
| 793 | 793 | */ |
| 794 | 794 | function ppp_fb_use_media( $post_id, $index ) { |
| 795 | - if ( empty( $post_id ) || empty( $index ) ) { |
|
| 795 | + if (empty($post_id) || empty($index)) { |
|
| 796 | 796 | return false; |
| 797 | 797 | } |
| 798 | 798 | |
@@ -808,9 +808,9 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | ppp_set_social_tokens(); |
| 810 | 810 | |
| 811 | - $account = isset( $_POST['account'] ) ? $_POST['account'] : false; |
|
| 811 | + $account = isset($_POST['account']) ? $_POST['account'] : false; |
|
| 812 | 812 | |
| 813 | - if ( !empty( $account ) ) { |
|
| 813 | + if ( ! empty($account)) { |
|
| 814 | 814 | $ppp_social_settings['facebook']->page = $account; |
| 815 | 815 | |
| 816 | 816 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
@@ -826,14 +826,14 @@ discard block |
||
| 826 | 826 | function ppp_fb_calendar_on_publish_event( $events, $post_id ) { |
| 827 | 827 | $share_on_publish = get_post_meta( $post_id, '_ppp_fb_share_on_publish', true ); |
| 828 | 828 | |
| 829 | - if ( ! empty( $share_on_publish ) ) { |
|
| 829 | + if ( ! empty($share_on_publish)) { |
|
| 830 | 830 | $share_text = get_post_meta( $post_id, '_ppp_fb_share_on_publish_title', true ); |
| 831 | 831 | $events[] = array( |
| 832 | - 'id' => $post_id . '-share-on-publish', |
|
| 833 | - 'title' => ( ! empty( $share_text ) ) ? $share_text : ppp_fb_generate_share_content( $post_id, null, false ), |
|
| 834 | - 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 835 | - 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ) . ' ' . get_the_time( null, $post_id ) ) + 1 ), |
|
| 836 | - 'className' => 'ppp-calendar-item-fb cal-post-' . $post_id, |
|
| 832 | + 'id' => $post_id.'-share-on-publish', |
|
| 833 | + 'title' => ( ! empty($share_text)) ? $share_text : ppp_fb_generate_share_content( $post_id, null, false ), |
|
| 834 | + 'start' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 835 | + 'end' => date_i18n( 'Y-m-d/TH:i:s', strtotime( get_the_date( null, $post_id ).' '.get_the_time( null, $post_id ) ) + 1 ), |
|
| 836 | + 'className' => 'ppp-calendar-item-fb cal-post-'.$post_id, |
|
| 837 | 837 | 'belongsTo' => $post_id, |
| 838 | 838 | ); |
| 839 | 839 | } |
@@ -844,9 +844,9 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | function ppp_fb_get_post_shares( $items, $post_id ) { |
| 846 | 846 | $shares = get_post_meta( $post_id, '_ppp_fb_shares', true ); |
| 847 | - if ( empty( $shares ) ) { return $items; } |
|
| 847 | + if (empty($shares)) { return $items; } |
|
| 848 | 848 | |
| 849 | - foreach ( $shares as $key => $share ) { |
|
| 849 | + foreach ($shares as $key => $share) { |
|
| 850 | 850 | $items[] = array( 'id' => $key, 'service' => 'fb' ); |
| 851 | 851 | } |
| 852 | 852 | return $items; |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | function ppp_fb_clear_open_graph_cache( $post_id, $post_after, $post_before ) { |
| 866 | 866 | $post_types = ppp_allowed_post_types(); |
| 867 | - if ( ! in_array( $post_after->post_type, $post_types ) ) { |
|
| 867 | + if ( ! in_array( $post_after->post_type, $post_types )) { |
|
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( 'publish' == $post_after->post_status ) { |
|
| 871 | + if ('publish' == $post_after->post_status) { |
|
| 872 | 872 | global $ppp_facebook_oauth; |
| 873 | 873 | |
| 874 | 874 | return $ppp_facebook_oauth->clear_og_cache( $post_id ); |
@@ -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 | |
@@ -318,8 +318,9 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | if( $log_id && ! empty( $log_meta ) ) { |
| 320 | 320 | foreach( (array) $log_meta as $key => $meta ) { |
| 321 | - if( ! empty( $meta ) ) |
|
| 322 | - update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta ); |
|
| 321 | + if( ! empty( $meta ) ) { |
|
| 322 | + update_post_meta( $log_id, '_wp_log_' . sanitize_key( $key ), $meta ); |
|
| 323 | + } |
|
| 323 | 324 | } |
| 324 | 325 | } |
| 325 | 326 | |
@@ -388,8 +389,9 @@ discard block |
||
| 388 | 389 | |
| 389 | 390 | $logs = get_posts( $query_args ); |
| 390 | 391 | |
| 391 | - if( $logs ) |
|
| 392 | - return $logs; |
|
| 392 | + if( $logs ) { |
|
| 393 | + return $logs; |
|
| 394 | + } |
|
| 393 | 395 | |
| 394 | 396 | // no logs found |
| 395 | 397 | return false; |