@@ -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 | |
@@ -43,21 +43,21 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | public function column_default( $item, $column_name ) { |
| 45 | 45 | switch ( $column_name ) { |
| 46 | - case 'date': |
|
| 47 | - case 'post_title': |
|
| 48 | - return $item[ $column_name ]; |
|
| 49 | - case 'content': |
|
| 50 | - $content = $item[ $column_name ]; |
|
| 51 | - return $content; |
|
| 52 | - case 'image': |
|
| 53 | - if ( ! empty( $item['image_url'] ) ) { |
|
| 54 | - $content = '<img src="' . $item['image_url'] . '" />'; |
|
| 55 | - } else { |
|
| 56 | - $content = __( 'None', 'ppp-txt' ); |
|
| 57 | - } |
|
| 58 | - return $content; |
|
| 59 | - default: |
|
| 60 | - return; |
|
| 46 | + case 'date': |
|
| 47 | + case 'post_title': |
|
| 48 | + return $item[ $column_name ]; |
|
| 49 | + case 'content': |
|
| 50 | + $content = $item[ $column_name ]; |
|
| 51 | + return $content; |
|
| 52 | + case 'image': |
|
| 53 | + if ( ! empty( $item['image_url'] ) ) { |
|
| 54 | + $content = '<img src="' . $item['image_url'] . '" />'; |
|
| 55 | + } else { |
|
| 56 | + $content = __( 'None', 'ppp-txt' ); |
|
| 57 | + } |
|
| 58 | + return $content; |
|
| 59 | + default: |
|
| 60 | + return; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -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,16 +42,16 @@ discard block |
||
| 42 | 42 | * @return string The Content to display |
| 43 | 43 | */ |
| 44 | 44 | public function column_default( $item, $column_name ) { |
| 45 | - switch ( $column_name ) { |
|
| 45 | + switch ($column_name) { |
|
| 46 | 46 | case 'date': |
| 47 | 47 | case 'post_title': |
| 48 | - return $item[ $column_name ]; |
|
| 48 | + return $item[$column_name]; |
|
| 49 | 49 | case 'content': |
| 50 | - $content = $item[ $column_name ]; |
|
| 50 | + $content = $item[$column_name]; |
|
| 51 | 51 | return $content; |
| 52 | 52 | case 'image': |
| 53 | - if ( ! empty( $item['image_url'] ) ) { |
|
| 54 | - $content = '<img src="' . $item['image_url'] . '" />'; |
|
| 53 | + if ( ! empty($item['image_url'])) { |
|
| 54 | + $content = '<img src="'.$item['image_url'].'" />'; |
|
| 55 | 55 | } else { |
| 56 | 56 | $content = __( 'None', 'ppp-txt' ); |
| 57 | 57 | } |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | * @return string The HTML to display for this column. |
| 83 | 83 | */ |
| 84 | 84 | public function column_post_title( $item ) { |
| 85 | - $item_name = $item['name'] . '_' . $item['service']; |
|
| 85 | + $item_name = $item['name'].'_'.$item['service']; |
|
| 86 | 86 | $actions = array( |
| 87 | - 'edit' => sprintf( __( '<a href="%s">Edit</a>', 'ppp-txt' ), admin_url( 'post.php?post=' . $item['post_id'] . '&action=edit#ppp_schedule_metabox' ) ), |
|
| 88 | - 'delete' => sprintf( __( '<a href="%s">Delete</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=delete_item&post_id=' . $item['post_id'] . '&name=' . $item_name . '&index=' . $item['index'] ) ), |
|
| 89 | - 'share' => sprintf( __( '<a href="%s">Share Now</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=share_now&post_id=' . $item['post_id'] . '&name=' . $item_name ) ), |
|
| 90 | - 'share_delete' => sprintf( __( '<a href="%s">Share Now & Delete</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=share_now&post_id=' . $item['post_id'] . '&name=' . $item_name . '&index=' . $item['index'] . '&delete_too=true' ) ), |
|
| 87 | + 'edit' => sprintf( __( '<a href="%s">Edit</a>', 'ppp-txt' ), admin_url( 'post.php?post='.$item['post_id'].'&action=edit#ppp_schedule_metabox' ) ), |
|
| 88 | + 'delete' => sprintf( __( '<a href="%s">Delete</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=delete_item&post_id='.$item['post_id'].'&name='.$item_name.'&index='.$item['index'] ) ), |
|
| 89 | + 'share' => sprintf( __( '<a href="%s">Share Now</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=share_now&post_id='.$item['post_id'].'&name='.$item_name ) ), |
|
| 90 | + 'share_delete' => sprintf( __( '<a href="%s">Share Now & Delete</a>', 'ppp-txt' ), admin_url( 'admin.php?page=ppp-schedule-info&action=share_now&post_id='.$item['post_id'].'&name='.$item_name.'&index='.$item['index'].'&delete_too=true' ) ), |
|
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - return sprintf( '<span class="dashicons icon-ppp-' . $item['service'] . '"></span> %1$s %2$s', $item['post_title'], $this->row_actions( $actions ) ); |
|
| 93 | + return sprintf( '<span class="dashicons icon-ppp-'.$item['service'].'"></span> %1$s %2$s', $item['post_title'], $this->row_actions( $actions ) ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * @return string The HTML to display the date |
| 100 | 100 | */ |
| 101 | 101 | public function column_date( $item ) { |
| 102 | - $date = date_i18n( get_option('date_format') . ' @ ' . get_option('time_format'), $item['date'] ); |
|
| 103 | - if ( $item['conflict'] ) { |
|
| 104 | - $date .= '<br /><small style="color: red">' . __( 'Warning: Multiple items scheduled at this time.', 'ppp-txt' ) . '</small>'; |
|
| 102 | + $date = date_i18n( get_option( 'date_format' ).' @ '.get_option( 'time_format' ), $item['date'] ); |
|
| 103 | + if ($item['conflict']) { |
|
| 104 | + $date .= '<br /><small style="color: red">'.__( 'Warning: Multiple items scheduled at this time.', 'ppp-txt' ).'</small>'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $date; |
@@ -123,48 +123,48 @@ discard block |
||
| 123 | 123 | $crons = ppp_get_shceduled_crons(); |
| 124 | 124 | |
| 125 | 125 | $cron_tally = array(); |
| 126 | - foreach ( $crons as $key => $cron ) { |
|
| 126 | + foreach ($crons as $key => $cron) { |
|
| 127 | 127 | $ppp_data = $cron; |
| 128 | 128 | $timestamp = $ppp_data['timestamp']; |
| 129 | 129 | |
| 130 | - $cron_tally[$timestamp] = isset( $cron_tally[$timestamp] ) ? $cron_tally[$timestamp] + 1 : 1; |
|
| 130 | + $cron_tally[$timestamp] = isset($cron_tally[$timestamp]) ? $cron_tally[$timestamp] + 1 : 1; |
|
| 131 | 131 | |
| 132 | 132 | $name_parts = explode( '_', $ppp_data['args'][1] ); |
| 133 | 133 | $post_id = $ppp_data['args'][0]; |
| 134 | 134 | $index = $name_parts[1]; |
| 135 | - $service = isset( $name_parts[3] ) ? $name_parts[3] : 'tw'; |
|
| 136 | - $builder = 'ppp_' . $service . '_build_share_message'; |
|
| 137 | - $post_meta = apply_filters( 'ppp_get_scheduled_items_' . $service, array(), $post_id ); |
|
| 135 | + $service = isset($name_parts[3]) ? $name_parts[3] : 'tw'; |
|
| 136 | + $builder = 'ppp_'.$service.'_build_share_message'; |
|
| 137 | + $post_meta = apply_filters( 'ppp_get_scheduled_items_'.$service, array(), $post_id ); |
|
| 138 | 138 | $image_url = ''; |
| 139 | 139 | |
| 140 | - if ( ! empty( $post_meta[$index]['attachment_id'] ) ) { |
|
| 141 | - $image_url = ppp_post_has_media( $post_id, $service, true, $post_meta[ $index ]['attachment_id'] ); |
|
| 142 | - } elseif ( ! empty( $post_meta[ $index ]['image'] ) ) { |
|
| 143 | - $image_url = $post_meta[ $index ]['image']; |
|
| 140 | + if ( ! empty($post_meta[$index]['attachment_id'])) { |
|
| 141 | + $image_url = ppp_post_has_media( $post_id, $service, true, $post_meta[$index]['attachment_id'] ); |
|
| 142 | + } elseif ( ! empty($post_meta[$index]['image'])) { |
|
| 143 | + $image_url = $post_meta[$index]['image']; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $conflict = $cron_tally[ $timestamp ] > 1 ? true : false; |
|
| 146 | + $conflict = $cron_tally[$timestamp] > 1 ? true : false; |
|
| 147 | 147 | |
| 148 | - $data[ $key ] = array( |
|
| 148 | + $data[$key] = array( |
|
| 149 | 149 | 'post_id' => $post_id, |
| 150 | 150 | 'post_title' => get_the_title( $post_id ), |
| 151 | 151 | 'service' => $service, |
| 152 | 152 | 'index' => $index, |
| 153 | - 'date' => $timestamp + ( get_option( 'gmt_offset' ) * 3600 ), |
|
| 153 | + 'date' => $timestamp + (get_option( 'gmt_offset' ) * 3600), |
|
| 154 | 154 | 'content' => function_exists( $builder ) ? $builder( $post_id, $ppp_data['args'][1], false ) : '', |
| 155 | - 'name' => 'sharedate_' . $index . '_' . $post_id, |
|
| 155 | + 'name' => 'sharedate_'.$index.'_'.$post_id, |
|
| 156 | 156 | 'conflict' => $conflict, |
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | - if ( ! empty( $image_url ) ) { |
|
| 160 | - $data[ $key ]['image_url'] = $image_url; |
|
| 159 | + if ( ! empty($image_url)) { |
|
| 160 | + $data[$key]['image_url'] = $image_url; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $description_function = 'ppp_' . $service . '_get_share_description'; |
|
| 164 | - if ( function_exists( $description_function ) ) { |
|
| 163 | + $description_function = 'ppp_'.$service.'_get_share_description'; |
|
| 164 | + if (function_exists( $description_function )) { |
|
| 165 | 165 | $description = $description_function( $post_id, $index ); |
| 166 | - if ( ! empty( $description ) ) { |
|
| 167 | - $data[ $key ]['content'] .= '<br />' . $description; |
|
| 166 | + if ( ! empty($description)) { |
|
| 167 | + $data[$key]['content'] .= '<br />'.$description; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $total_items = count( $data ); |
| 174 | 174 | |
| 175 | - $offset = isset( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
| 175 | + $offset = isset($_GET['paged']) ? $_GET['paged'] : 1; |
|
| 176 | 176 | |
| 177 | - $data = array_slice( $data, ( $offset - 1 ) * $per_page, $per_page, true ); |
|
| 177 | + $data = array_slice( $data, ($offset - 1) * $per_page, $per_page, true ); |
|
| 178 | 178 | $this->items = $data; |
| 179 | 179 | |
| 180 | 180 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 13 | +if ( ! defined( 'ABSPATH' )) exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Render Upgrades Screen |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | 21 | function ppp_upgrades_screen() { |
| 22 | - $action = isset( $_GET['ppp-upgrade'] ) ? sanitize_text_field( $_GET['ppp-upgrade'] ) : ''; |
|
| 23 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
| 24 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
| 25 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
| 26 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
| 27 | - $steps = round( ( $total / $number ), 0 ); |
|
| 22 | + $action = isset($_GET['ppp-upgrade']) ? sanitize_text_field( $_GET['ppp-upgrade'] ) : ''; |
|
| 23 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
| 24 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
| 25 | + $custom = isset($_GET['custom']) ? absint( $_GET['custom'] ) : 0; |
|
| 26 | + $number = isset($_GET['number']) ? absint( $_GET['number'] ) : 100; |
|
| 27 | + $steps = round( ($total / $number), 0 ); |
|
| 28 | 28 | |
| 29 | 29 | $doing_upgrade_args = array( |
| 30 | 30 | 'page' => 'ppp-upgrades', |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | update_option( 'ppp_doing_upgrade', $doing_upgrade_args ); |
| 39 | - if ( $step > $steps ) { |
|
| 39 | + if ($step > $steps) { |
|
| 40 | 40 | // Prevent a weird case where the estimate was off. Usually only a couple. |
| 41 | 41 | $steps = $step; |
| 42 | 42 | } |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | <div class="wrap"> |
| 45 | 45 | <h1><?php _e( 'Post Promoter Pro - Upgrades', 'ppp-txt' ); ?></h1> |
| 46 | 46 | |
| 47 | - <?php if( ! empty( $action ) ) : ?> |
|
| 47 | + <?php if ( ! empty($action)) : ?> |
|
| 48 | 48 | |
| 49 | 49 | <div id="ppp-upgrade-status"> |
| 50 | 50 | <p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'ppp-txt' ); ?></p> |
| 51 | 51 | |
| 52 | - <?php if( ! empty( $total ) ) : ?> |
|
| 52 | + <?php if ( ! empty($total)) : ?> |
|
| 53 | 53 | <p><strong><?php printf( __( 'Step %d of approximately %d running', 'ppp-txt' ), $step, $steps ); ?></strong></p> |
| 54 | 54 | <?php endif; ?> |
| 55 | 55 | </div> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | function ppp_register_meta_boxes() { |
| 13 | 13 | global $post, $ppp_options; |
| 14 | 14 | |
| 15 | - if ( !isset( $ppp_options['post_types'] ) || !is_array( $ppp_options['post_types'] ) ) { |
|
| 15 | + if ( ! isset($ppp_options['post_types']) || ! is_array( $ppp_options['post_types'] )) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - foreach ( $ppp_options['post_types'] as $post_type => $value ) { |
|
| 19 | + foreach ($ppp_options['post_types'] as $post_type => $value) { |
|
| 20 | 20 | add_meta_box( 'ppp_schedule_metabox', 'Post Promoter Pro', 'ppp_schedule_callback', $post_type, 'normal', 'high' ); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( !defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | * Handles all bitly functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Bitly' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Bitly' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Bitly { |
| 17 | 17 | |
| 18 | 18 | var $bitly; |
| 19 | 19 | |
| 20 | - public function __construct(){ |
|
| 20 | + public function __construct() { |
|
| 21 | 21 | ppp_maybe_start_session(); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | * Handles to load twitter class |
| 28 | 28 | */ |
| 29 | 29 | public function ppp_load_bitly() { |
| 30 | - if( !class_exists( 'Bitly' ) ) { |
|
| 31 | - require_once ( PPP_PATH . '/includes/libs/bitly/bitly.php' ); |
|
| 30 | + if ( ! class_exists( 'Bitly' )) { |
|
| 31 | + require_once (PPP_PATH.'/includes/libs/bitly/bitly.php'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | ppp_set_social_tokens(); |
| 35 | 35 | |
| 36 | - if ( ! defined( 'bitly_clientid' ) || ! defined( 'bitly_secret' ) ) { |
|
| 36 | + if ( ! defined( 'bitly_clientid' ) || ! defined( 'bitly_secret' )) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | global $ppp_social_settings; |
| 41 | 41 | |
| 42 | - if ( isset( $ppp_social_settings['bitly'] ) ) { |
|
| 43 | - if ( !defined( 'bitly_accesstoken' ) ) { |
|
| 42 | + if (isset($ppp_social_settings['bitly'])) { |
|
| 43 | + if ( ! defined( 'bitly_accesstoken' )) { |
|
| 44 | 44 | define( 'bitly_accesstoken', $ppp_social_settings['bitly']['access_token'] ); |
| 45 | 45 | } |
| 46 | 46 | $this->bitly = new Bitly( bitly_clientid, bitly_secret, bitly_accesstoken ); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function revoke_access() { |
| 55 | 55 | global $ppp_social_settings; |
| 56 | 56 | |
| 57 | - unset( $ppp_social_settings['bitly'] ); |
|
| 57 | + unset($ppp_social_settings['bitly']); |
|
| 58 | 58 | |
| 59 | 59 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 60 | 60 | } |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | * Get auth codes for Bitly |
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | - public function ppp_get_bitly_auth_url () { |
|
| 66 | + public function ppp_get_bitly_auth_url() { |
|
| 67 | 67 | //load bitly class |
| 68 | 68 | $bitly = $this->ppp_load_bitly(); |
| 69 | 69 | |
| 70 | 70 | //check bitly class is loaded or not |
| 71 | - if( !$bitly ) { |
|
| 71 | + if ( ! $bitly) { |
|
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function ppp_make_bitly_link( $link = null ) { |
| 80 | - if ( empty( $link ) ) { |
|
| 80 | + if (empty($link)) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $bitly = $this->ppp_load_bitly(); |
| 85 | 85 | |
| 86 | - if ( !$bitly ) { |
|
| 86 | + if ( ! $bitly) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function ppp_bitly_user_info() { |
| 94 | 94 | $bitly = $this->ppp_load_bitly(); |
| 95 | 95 | |
| 96 | - if ( !$bitly ) { |
|
| 96 | + if ( ! $bitly) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -146,16 +146,16 @@ |
||
| 146 | 146 | // If last connection failed don't display authorization link. |
| 147 | 147 | switch( $this->twitter->http_code ) { |
| 148 | 148 | |
| 149 | - case 200: |
|
| 150 | - $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
|
| 151 | - $_SESSION['ppp_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
|
| 152 | - |
|
| 153 | - $token = $request_token['oauth_token']; |
|
| 154 | - $url = $this->twitter->getAuthorizeURL( $token, NULL ); |
|
| 155 | - break; |
|
| 156 | - default: |
|
| 157 | - $url = ''; |
|
| 158 | - break; |
|
| 149 | + case 200: |
|
| 150 | + $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
|
| 151 | + $_SESSION['ppp_twt_oauth_token_secret'] = $request_token['oauth_token_secret']; |
|
| 152 | + |
|
| 153 | + $token = $request_token['oauth_token']; |
|
| 154 | + $url = $this->twitter->getAuthorizeURL( $token, NULL ); |
|
| 155 | + break; |
|
| 156 | + default: |
|
| 157 | + $url = ''; |
|
| 158 | + break; |
|
| 159 | 159 | } |
| 160 | 160 | return $url; |
| 161 | 161 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( !defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * Handles all twitter functions |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -if( !class_exists( 'PPP_Twitter' ) ) { |
|
| 14 | +if ( ! class_exists( 'PPP_Twitter' )) { |
|
| 15 | 15 | |
| 16 | 16 | class PPP_Twitter { |
| 17 | 17 | |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | * Handles to load twitter class |
| 30 | 30 | */ |
| 31 | 31 | public function ppp_load_twitter() { |
| 32 | - if( !class_exists( 'TwitterOAuth' ) ) { |
|
| 33 | - require_once ( PPP_PATH . '/includes/libs/twitter/twitteroauth.php' ); |
|
| 32 | + if ( ! class_exists( 'TwitterOAuth' )) { |
|
| 33 | + require_once (PPP_PATH.'/includes/libs/twitter/twitteroauth.php'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | ppp_set_social_tokens(); |
| 37 | 37 | |
| 38 | - if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' ) ) { |
|
| 38 | + if ( ! defined( 'PPP_TW_CONSUMER_KEY' ) || ! defined( 'PPP_TW_CONSUMER_SECRET' )) { |
|
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function revoke_access() { |
| 48 | 48 | global $ppp_social_settings; |
| 49 | 49 | |
| 50 | - unset( $ppp_social_settings['twitter'] ); |
|
| 50 | + unset($ppp_social_settings['twitter']); |
|
| 51 | 51 | |
| 52 | 52 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 53 | 53 | } |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | public function ppp_initialize_twitter() { |
| 60 | 60 | |
| 61 | 61 | //when user is going to logged in in twitter and verified successfully session will create |
| 62 | - if ( ! empty( $_REQUEST['oauth_verifier'] ) ) { |
|
| 62 | + if ( ! empty($_REQUEST['oauth_verifier'])) { |
|
| 63 | 63 | $ppp_social_settings = get_option( 'ppp_social_settings' ); |
| 64 | 64 | |
| 65 | 65 | //load twitter class |
| 66 | 66 | $twitter = $this->ppp_load_twitter(); |
| 67 | 67 | |
| 68 | 68 | //check twitter class is loaded or not |
| 69 | - if( ! $twitter ) { |
|
| 69 | + if ( ! $twitter) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | //session for verifier |
| 79 | 79 | $verifier['oauth_verifier'] = $_REQUEST['oauth_verifier']; |
| 80 | 80 | |
| 81 | - $_SESSION[ 'ppp_twt_user_cache' ] = $verifier; |
|
| 81 | + $_SESSION['ppp_twt_user_cache'] = $verifier; |
|
| 82 | 82 | |
| 83 | 83 | //getting user data from twitter |
| 84 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 84 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 85 | 85 | |
| 86 | 86 | //if user data get successfully |
| 87 | - if ( $response->id_str ) { |
|
| 87 | + if ($response->id_str) { |
|
| 88 | 88 | |
| 89 | 89 | $data['user'] = $response; |
| 90 | 90 | $data['user']->accessToken = $ppp_tw_access_token; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $this->ppp_load_twitter(); |
| 101 | 101 | |
| 102 | 102 | global $ppp_social_settings; |
| 103 | - if ( isset( $ppp_social_settings['twitter'] ) ) { |
|
| 103 | + if (isset($ppp_social_settings['twitter'])) { |
|
| 104 | 104 | |
| 105 | 105 | $this->twitter = new TwitterOAuth( |
| 106 | 106 | PPP_TW_CONSUMER_KEY, |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $ppp_social_settings['twitter']['user']->accessToken['oauth_token_secret'] |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - $response = $this->twitter->get('account/verify_credentials'); |
|
| 113 | - if ( is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0 ) { |
|
| 114 | - foreach ( $response->errors as $error ) { |
|
| 115 | - if ( $error->code == 89 ) { // Expired or revoked tokens |
|
| 116 | - unset( $ppp_social_settings['twitter'] ); |
|
| 112 | + $response = $this->twitter->get( 'account/verify_credentials' ); |
|
| 113 | + if (is_object( $response ) && property_exists( $response, 'errors' ) && count( $response->errors ) > 0) { |
|
| 114 | + foreach ($response->errors as $error) { |
|
| 115 | + if ($error->code == 89) { // Expired or revoked tokens |
|
| 116 | + unset($ppp_social_settings['twitter']); |
|
| 117 | 117 | update_option( 'ppp_social_settings', $ppp_social_settings ); |
| 118 | 118 | |
| 119 | 119 | return array( 'error' => __( 'Post Promoter Pro has been removed from your Twitter account. Please reauthorize to continue promoting your content.', 'ppp-txt' ) ); |
@@ -129,23 +129,23 @@ discard block |
||
| 129 | 129 | * Get auth url for twitter |
| 130 | 130 | * |
| 131 | 131 | */ |
| 132 | - public function ppp_get_twitter_auth_url ( $return_url = '' ) { |
|
| 132 | + public function ppp_get_twitter_auth_url( $return_url = '' ) { |
|
| 133 | 133 | |
| 134 | - if ( empty( $return_url ) ) { |
|
| 134 | + if (empty($return_url)) { |
|
| 135 | 135 | $return_url = admin_url( 'admin.php?page=ppp-social-settings' ); |
| 136 | 136 | } |
| 137 | 137 | //load twitter class |
| 138 | 138 | $twitter = $this->ppp_load_twitter(); |
| 139 | 139 | |
| 140 | 140 | //check twitter class is loaded or not |
| 141 | - if( !$twitter ) { |
|
| 141 | + if ( ! $twitter) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $request_token = $this->twitter->getRequestToken( 'oob' ); |
| 146 | 146 | |
| 147 | 147 | // If last connection failed don't display authorization link. |
| 148 | - switch( $this->twitter->http_code ) { |
|
| 148 | + switch ($this->twitter->http_code) { |
|
| 149 | 149 | |
| 150 | 150 | case 200: |
| 151 | 151 | $_SESSION['ppp_twt_oauth_token'] = $request_token['oauth_token']; |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public function ppp_tweet( $message = '', $media = null ) { |
| 165 | - if ( empty( $message ) ) { |
|
| 165 | + if (empty($message)) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $verify = $this->ppp_verify_twitter_credentials(); |
| 170 | - if ( $verify === true ) { |
|
| 170 | + if ($verify === true) { |
|
| 171 | 171 | $args = array(); |
| 172 | - if ( ! empty( $media ) ) { |
|
| 172 | + if ( ! empty($media)) { |
|
| 173 | 173 | $endpoint = 'statuses/update_with_media'; |
| 174 | 174 | $args['media[]'] = wp_remote_retrieve_body( wp_remote_get( $media ) ); |
| 175 | 175 | } else { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined( 'ABSPATH' )) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -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]; |