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