Changeset 1811195
- Timestamp:
- 01/29/2018 01:06:11 PM (8 years ago)
- Location:
- wp-to-buffer/trunk
- Files:
-
- 6 edited
-
_modules/dashboard/dashboard.php (modified) (2 diffs)
-
includes/admin/admin.php (modified) (4 diffs)
-
includes/admin/buffer-api.php (modified) (16 diffs)
-
includes/admin/publish.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-to-buffer.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-to-buffer/trunk/_modules/dashboard/dashboard.php
r1735682 r1811195 54 54 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_css' ) ); 55 55 add_action( str_replace( '-', '_', $this->plugin->name ) . '_admin_menu', array( $this, 'admin_menu' ), 99 ); 56 57 // Plugin Actions 58 add_filter( 'plugin_action_links_' . $this->plugin->name . '/' . $this->plugin->name . '.php', array( $this, 'add_action_link' ), 10, 2 ); 56 59 57 60 // Reviews … … 183 186 add_submenu_page( $slug, __( 'Support', $this->plugin->name ), __( 'Support', $this->plugin->name ), 'manage_options', $this->plugin->name . '-support', array( $this, 'support_screen' ) ); 184 187 188 } 189 190 /** 191 * Adds Plugin Action Links to the Plugin when activated in the Plugins Screen 192 * 193 * @since 1.0.0 194 * 195 * @param array $links Action Links 196 * @param string $file Plugin File 197 * @return array Action Links 198 */ 199 public function add_action_link( $links, $file ) { 200 201 // Bail if the licensing class exists 202 if ( class_exists( 'LicensingUpdateManager' ) ) { 203 return $links; 204 } 205 206 // Add Links 207 $links[] = '<a href="' . $this->get_upgrade_url( 'plugins' ) . '" target="_blank">' . __( 'Upgrade', $this->plugin->name ) . '</a>'; 208 209 // Return 210 return $links; 211 185 212 } 186 213 -
wp-to-buffer/trunk/includes/admin/admin.php
r1766858 r1811195 179 179 180 180 // CSS - always load 181 // Menu Icon is inline, because when Gravity Forms no conflict mode is ON, it kills all enqueued styles, 182 // which results in a large menu SVG icon displaying. 183 ?> 184 <style type="text/css"> 185 li.toplevel_page_wp-to-buffer-settings a div.wp-menu-image, li.toplevel_page_wp-to-buffer-pro a div.wp-menu-image { 186 background: url(<?php echo $this->base->plugin->url; ?>/assets/images/icons/buffer-dark.svg) center no-repeat; 187 background-size: 16px 16px; 188 } 189 li.toplevel_page_wp-to-buffer-settings a div.wp-menu-image img, li.toplevel_page_wp-to-buffer-pro a div.wp-menu-image img { 190 display: none; 191 } 192 193 body.admin-color-fresh li.toplevel_page_wp-to-buffer-settings a div.wp-menu-image, 194 body.admin-color-fresh li.toplevel_page_wp-to-buffer-pro a div.wp-menu-image, 195 body.admin-color-midnight li.toplevel_page_wp-to-buffer-settings a div.wp-menu-image, 196 body.admin-color-midnight li.toplevel_page_wp-to-buffer-pro a div.wp-menu-image { 197 background: url(<?php echo $this->base->plugin->url; ?>/assets/images/icons/buffer-light.svg) center no-repeat; 198 background-size: 16px 16px; 199 } 200 </style> 201 <?php 181 202 wp_enqueue_style( $this->base->plugin->name, $this->base->plugin->url . 'assets/css/admin.css', array(), $this->base->plugin->version ); 182 203 … … 244 265 245 266 // Maybe disconnect from Buffer 246 $result = $this->disconnect(); 247 if ( is_string( $result ) ) { 248 // Error - add to array of errors for output 249 $this->notices['error'][] = $result; 250 } elseif ( $result === true ) { 251 // Success 252 $this->notices['success'][] = __( 'Buffer account disconnected successfully.', $this->base->plugin->name ); 267 if ( isset( $_GET['wp-to-buffer-pro-disconnect'] ) ) { 268 $result = $this->disconnect(); 269 if ( is_string( $result ) ) { 270 // Error - add to array of errors for output 271 $this->notices['error'][] = $result; 272 } elseif ( $result === true ) { 273 // Success 274 $this->notices['success'][] = __( 'Buffer account disconnected successfully.', $this->base->plugin->name ); 275 } 253 276 } 254 277 … … 276 299 277 300 // Get Buffer Profiles 301 // Display an error if we couldn't fetch the profiles from Buffer 278 302 $profiles = $api->profiles( true ); 303 if ( is_wp_error( $profiles ) ) { 304 // If the error is a 401, the user revoked access to the plugin through buffer.com 305 // Disconnect the Plugin from Buffer, and explain why this happened 306 if ( $profiles->get_error_code() == 401 ) { 307 // Disconnect the Plugin 308 $this->disconnect(); 309 310 // Fetch a new oAuth URL 311 $oauth_url = $api->get_oauth_url(); 312 313 // Display an error message 314 $this->notices['error'][] = __( 'Hmm, it looks like you revoked access to WordPress to Buffer Pro through your Buffer account at buffer.com. This means we can no longer post updates to your social networks. To re-authorize, click the Authorize Plugin button.', 'wp-to-buffer-pro' ); 315 } else { 316 // Some other error 317 $this->notices['error'][] = $profiles->get_error_message(); 318 } 319 } 279 320 280 321 // Get Post Types, Image Options and Roles … … 343 384 */ 344 385 public function disconnect() { 345 346 if ( ! isset( $_GET['wp-to-buffer-pro-disconnect'] ) ) {347 return false;348 }349 386 350 387 return WP_To_Buffer_Pro_Settings::get_instance()->update_access_token( '' ); -
wp-to-buffer/trunk/includes/admin/buffer-api.php
r1735682 r1811195 36 36 private $oauth_gateway_endpoint = 'https://www.wpzinc.com/?oauth=buffer'; 37 37 38 /**38 /** 39 39 * Access Token 40 40 * … … 71 71 public function set_access_token( $access_token ) { 72 72 73 $this->access_token = $access_token;73 $this->access_token = $access_token; 74 74 75 75 } … … 100 100 * @return mixed WP_Error | User object 101 101 */ 102 public function user() {102 public function user() { 103 103 104 104 // Check access token … … 109 109 return $this->get( 'user.json' ); 110 110 111 }112 113 /**111 } 112 113 /** 114 114 * Returns a list of Social Media Profiles attached to the Buffer Account. 115 115 * … … 119 119 * @return mixed WP_Error | Profiles object 120 120 */ 121 public function profiles( $force = false ) {121 public function profiles( $force = false ) { 122 122 123 123 // Check access token … … 175 175 } 176 176 177 // Return results177 // Return results 178 178 return $profiles; 179 179 180 }180 } 181 181 182 182 /** … … 193 193 } 194 194 195 /** 196 * Private function to perform a GET request 197 * 198 * @since 3.0.0 199 * 200 * @param string $cmd Command (required) 201 * @param array $params Params (optional) 202 * @return mixed WP_Error | object 203 */ 204 private function get( $cmd, $params = array() ) { 205 206 return $this->request( $cmd, 'get', $params ); 207 208 } 209 210 /** 211 * Private function to perform a POST request 212 * 195 /** 196 * Private function to perform a GET request 197 * 213 198 * @since 3.0.0 214 199 * … … 217 202 * @return mixed WP_Error | object 218 203 */ 219 private function post( $cmd, $params = array() ) { 220 221 return $this->request( $cmd, 'post', $params ); 222 223 } 224 225 /** 204 private function get( $cmd, $params = array() ) { 205 206 return $this->request( $cmd, 'get', $params ); 207 208 } 209 210 /** 211 * Private function to perform a POST request 212 * 213 * @since 3.0.0 214 * 215 * @param string $cmd Command (required) 216 * @param array $params Params (optional) 217 * @return mixed WP_Error | object 218 */ 219 private function post( $cmd, $params = array() ) { 220 221 return $this->request( $cmd, 'post', $params ); 222 223 } 224 225 /** 226 226 * Main function which handles sending requests to the Buffer API 227 227 * … … 229 229 * 230 230 * @param string $cmd Command 231 * @param string $method Method (get|post)232 * @param array $params Parameters (optional)231 * @param string $method Method (get|post) 232 * @param array $params Parameters (optional) 233 233 * @return mixed WP_Error | object 234 234 */ 235 235 private function request( $cmd, $method = 'get', $params = array() ) { 236 236 237 // Check required parameters exist238 if ( empty( $this->access_token ) ) {237 // Check required parameters exist 238 if ( empty( $this->access_token ) ) { 239 239 return new WP_Error( 'missing_access_token', __( 'No access token was specified' ) ); 240 } 241 242 // Add access token to command, depending on the command's format 243 if ( strpos ( $cmd, '?' ) !== false ) { 244 $cmd .= '&access_token=' . $this->access_token; 245 } else { 246 $cmd .= '?access_token=' . $this->access_token; 247 } 248 249 // Build endpoint URL 250 $url = 'https://api.bufferapp.com/1/' . $cmd; 240 } 241 242 // Add access token to command, depending on the command's format 243 if ( strpos ( $cmd, '?' ) !== false ) { 244 $cmd .= '&access_token=' . $this->access_token; 245 } else { 246 $cmd .= '?access_token=' . $this->access_token; 247 } 248 249 // Build endpoint URL 250 $url = 'https://api.bufferapp.com/1/' . $cmd; 251 252 // Define timeout, in seconds 253 $timeout = apply_filters( 'wp_to_buffer_pro_buffer_api_request', 10 ); 251 254 252 255 // Request via WordPress functions 253 $result = $this->request_wordpress( $url, $method, $params );256 $result = $this->request_wordpress( $url, $method, $params, $timeout ); 254 257 255 258 // Request via cURL if WordPress functions failed 256 259 if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) { 257 260 if ( is_wp_error( $result ) ) { 258 $result = $this->request_curl( $url, $method, $params );261 $result = $this->request_curl( $url, $method, $params, $timeout ); 259 262 } 260 263 } … … 274 277 * @param string $method Method (post|get) 275 278 * @param array $params Parameters 279 * @param int $timeout Timeout, in seconds (default: 10) 276 280 * @return mixed WP_Error | object 277 281 */ 278 private function request_wordpress( $url, $method, $params ) {282 private function request_wordpress( $url, $method, $params, $timeout = 10 ) { 279 283 280 284 // Send request … … 286 290 $result = wp_remote_get( $url, array( 287 291 'body' => $params, 288 'timeout' => 3,292 'timeout' => $timeout, 289 293 ) ); 290 294 break; … … 296 300 $result = wp_remote_post( $url, array( 297 301 'body' => $params, 298 'timeout' => 3,302 'timeout' => $timeout, 299 303 ) ); 300 304 break; … … 311 315 $body = json_decode( $result['body'] ); 312 316 317 // Define the error message 318 $message = array(); 319 if ( isset( $body->error ) ) { 320 $message[] = $body->error; 321 } 322 if ( isset( $body->message ) ) { 323 $message[] = $body->message; 324 } 325 313 326 // Return WP_Error 314 327 return new WP_Error( 315 328 $result['response']['code'], 316 'Buffer API Error: HTTP Code ' . $result['response']['code'] . '. #' . $body->code . ' - ' . $body->message329 'Buffer API Error: HTTP Code ' . $result['response']['code'] . '. #' . $body->code . ' - ' . implode( "\n", $message ) 317 330 ); 318 331 } … … 336 349 * @param string $method Method (post|get) 337 350 * @param array $params Parameters 351 * @param int $timeout Timeout, in seconds (default: 10) 338 352 * @return mixed WP_Error | object 339 353 */ 340 private function request_curl( $url, $method, $params ) {354 private function request_curl( $url, $method, $params, $timeout = 10 ) { 341 355 342 356 // Init … … 380 394 CURLOPT_FOLLOWLOCATION => true, 381 395 CURLOPT_MAXREDIRS => 10, 382 CURLOPT_CONNECTTIMEOUT => 5,383 CURLOPT_TIMEOUT => 5,396 CURLOPT_CONNECTTIMEOUT => $timeout, 397 CURLOPT_TIMEOUT => $timeout, 384 398 ) ); 385 399 … … 408 422 } 409 423 424 // Define the error message 425 $message = array(); 426 if ( isset( $result->error ) ) { 427 $message[] = $result->error; 428 } 429 if ( isset( $result->message ) ) { 430 $message[] = $result->message; 431 } 432 410 433 // Return WP_Error 411 return new WP_Error( $http_code, 'Buffer API Error: HTTP Code ' . $http_code . '. #' . $result->code. ' - ' . $result->message);434 return new WP_Error( $http_code, 'Buffer API Error: HTTP Code ' . $http_code . '. #' . $result->code. ' - ' . implode( "\n", $message ) ); 412 435 } 413 436 -
wp-to-buffer/trunk/includes/admin/publish.php
r1766858 r1811195 65 65 // New Post Screen loading 66 66 // Draft saved 67 if ( $new_status == 'auto-draft' || $new_status == 'draft' || $new_status == 'inherit' ) {67 if ( $new_status == 'auto-draft' || $new_status == 'draft' || $new_status == 'inherit' || $new_status == 'trash' ) { 68 68 return; 69 69 } … … 77 77 if ( $new_status == 'publish' && $old_status == 'publish' ) { 78 78 $result = $this->publish( $post->ID, 'update' ); 79 } 80 81 // If no result, bail 82 if ( ! isset( $result ) ) { 83 return; 79 84 } 80 85 … … 291 296 292 297 // Media 293 $args['media']['link'] = rtrim( get_permalink( $post->ID ), '/' ); 298 // By default, fetch from OpenGraph by specifying the Post Link 299 $args['media'] = array( 300 'link' => rtrim( get_permalink( $post->ID ), '/' ), 301 ); 302 303 // If a Featured Image is present, use that instead 294 304 $featured_image_id = get_post_thumbnail_id( $post->ID ); 295 305 if ( $featured_image_id > 0 ) { 296 306 $featured_image = wp_get_attachment_image_src( $featured_image_id, 'large' ); 307 $featured_image_thumbnail = wp_get_attachment_image_src( $featured_image_id, 'thumbnail' ); 308 297 309 if ( is_array( $featured_image ) ) { 298 $args['media'] = array( );299 $args['media']['title'] = $post->post_title;// Required for LinkedIn to work300 $args['media']['picture'] = $featured_image[0];301 $args['media']['thumbnail'] = $featured_image[0];302 $args['media']['description'] = $post->post_title;303 unset( $args['media']['link'] ); // Important: if set, this attaches a link and drops the image!310 $args['media'] = array( 311 'title' => $post->post_title, 312 'description' => $post->post_excerpt, 313 'picture' => $featured_image[0], 314 'thumbnail' => $featured_image_thumbnail[0], 315 ); 304 316 } 305 317 } -
wp-to-buffer/trunk/readme.txt
r1766858 r1811195 4 4 Tags: buffer, bufferapp, buffer app, buffer my post, buffer old post, buffer post, post to buffer, promote old posts, promote posts, promote custom posts, promote selected posts, share posts, bulk share posts, share old posts, social, media, sharing, social media, social sharing, schedule, auto post, auto publish, publish, facebook, facebook post, facebook selected posts, facebook plugin, auto facebook post, post facebook, post to facebook, twitter, twitter post, tweet post twitter selected posts, tweet selected posts twitter plugin, auto twitter post, auto tweet post post twitter, post to twitter, linkedin, linkedin post, linkedin selected posts, linkedin plugin, auto linkedin post, post linkedin, post to linkedin, google, google post, google selected posts, google plugin, auto google post, post google, post to google, pinterest, pinterest post, pinterest selected posts, pinterest plugin, auto pinterest post, post pinterest, post to pinterest, best wordpress social plugin, best wordpress social sharing plugin, best social plugin, best social sharing plugin, best facebook social plugin, best twitter social plugin, best linkedin social plugin, best pinterest social plugin, best google+ social plugin, instagram, pinterest 5 5 Requires at least: 3.6 6 Tested up to: 4.9 6 Tested up to: 4.9.2 7 Requires PHP: 5.2 7 8 Stable tag: trunk 8 9 License: GPLv2 or later … … 62 63 == Screenshots == 63 64 64 1. Settings Panel when plugin is first installed.65 2. Settings Panel when Buffer Access Token is entered.66 3. Settings Panel showing available options for Posts, Pages and any Custom Post Types when the plugin is authenticated with Buffer.67 4. Post level settings meta box.65 1. Settings Screen when Plugin is first installed. 66 2. Settings Screen when Buffer is authorized. 67 3. Settings Screen showing available options for Posts. 68 4. Post-level Logging. 68 69 69 70 == Changelog == 71 72 = 3.3.3 = 73 * Added: Filter for defining max timeout on Buffer API requests (default: 10 seconds) 74 * Added: Re-authorize option when Plugin's access is revoked by a user via their buffer.com account 75 * Fix: Some cURL timeouts, despite statuses going through to Buffer 76 * Fix: Menu Icon size preserved when Gravity Forms no conflict mode is set to on 77 * Fix: Use 'thumbnail' WordPress image size for Buffer thumbnail, instead of 'small' 70 78 71 79 = 3.3.2 = -
wp-to-buffer/trunk/wp-to-buffer.php
r1766858 r1811195 3 3 * Plugin Name: WP to Buffer 4 4 * Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro 5 * Version: 3.3. 25 * Version: 3.3.3 6 6 * Author: WP Zinc 7 7 * Author URI: http://www.wpzinc.com … … 58 58 $this->plugin->settingsName = 'wp-to-buffer'; // Settings key - ensures upgrade users don't lose settings 59 59 $this->plugin->displayName = 'WP to Buffer'; 60 $this->plugin->version = '3.3. 2';61 $this->plugin->buildDate = '201 7-11-15 18:00:00';60 $this->plugin->version = '3.3.3'; 61 $this->plugin->buildDate = '2018-01-29 12:00:00'; 62 62 $this->plugin->requires = 3.6; 63 $this->plugin->tested = '4.9 ';63 $this->plugin->tested = '4.9.2'; 64 64 $this->plugin->folder = plugin_dir_path( __FILE__ ); 65 65 $this->plugin->url = plugin_dir_url( __FILE__ );
Note: See TracChangeset
for help on using the changeset viewer.