Plugin Directory

Changeset 1811195


Ignore:
Timestamp:
01/29/2018 01:06:11 PM (8 years ago)
Author:
n7studios
Message:

Adding version 3.3.3

Location:
wp-to-buffer/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • wp-to-buffer/trunk/_modules/dashboard/dashboard.php

    r1735682 r1811195  
    5454        add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_css' ) );
    5555        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 );
    5659
    5760        // Reviews
     
    183186        add_submenu_page( $slug, __( 'Support', $this->plugin->name ), __( 'Support', $this->plugin->name ), 'manage_options', $this->plugin->name . '-support', array( $this, 'support_screen' ) );
    184187   
     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
    185212    }
    186213
  • wp-to-buffer/trunk/includes/admin/admin.php

    r1766858 r1811195  
    179179
    180180        // 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
    181202        wp_enqueue_style( $this->base->plugin->name, $this->base->plugin->url . 'assets/css/admin.css', array(), $this->base->plugin->version );
    182203       
     
    244265
    245266        // 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            }
    253276        }
    254277
     
    276299
    277300        // Get Buffer Profiles
     301        // Display an error if we couldn't fetch the profiles from Buffer
    278302        $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        }
    279320       
    280321        // Get Post Types, Image Options and Roles
     
    343384     */
    344385    public function disconnect() {
    345 
    346         if ( ! isset( $_GET['wp-to-buffer-pro-disconnect'] ) ) {
    347             return false;
    348         }
    349386
    350387        return WP_To_Buffer_Pro_Settings::get_instance()->update_access_token( '' );
  • wp-to-buffer/trunk/includes/admin/buffer-api.php

    r1735682 r1811195  
    3636    private $oauth_gateway_endpoint = 'https://www.wpzinc.com/?oauth=buffer';
    3737   
    38     /**
     38    /**
    3939     * Access Token
    4040     *
     
    7171    public function set_access_token( $access_token ) {
    7272
    73         $this->access_token = $access_token;
     73        $this->access_token = $access_token;
    7474
    7575    }
     
    100100     * @return  mixed   WP_Error | User object
    101101     */
    102     public function user() {
     102    public function user() {
    103103
    104104        // Check access token
     
    109109        return $this->get( 'user.json' );
    110110
    111     }
    112 
    113     /**
     111    }
     112
     113    /**
    114114     * Returns a list of Social Media Profiles attached to the Buffer Account.
    115115     *
     
    119119     * @return  mixed           WP_Error | Profiles object
    120120     */
    121     public function profiles( $force = false ) {
     121    public function profiles( $force = false ) {
    122122
    123123        // Check access token
     
    175175        }
    176176
    177         // Return results
     177        // Return results
    178178        return $profiles;
    179179
    180     }
     180    }
    181181
    182182    /**
     
    193193    }
    194194
    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     *
    213198     * @since  3.0.0
    214199     *
     
    217202     * @return mixed               WP_Error | object
    218203     */
    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    /**
    226226     * Main function which handles sending requests to the Buffer API
    227227     *
     
    229229     *
    230230     * @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)
    233233     * @return mixed                WP_Error | object
    234234     */
    235235    private function request( $cmd, $method = 'get', $params = array() ) {
    236236
    237         // Check required parameters exist
    238         if ( empty( $this->access_token ) ) {
     237        // Check required parameters exist
     238        if ( empty( $this->access_token ) ) {
    239239            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 );
    251254
    252255        // Request via WordPress functions
    253         $result = $this->request_wordpress( $url, $method, $params );
     256        $result = $this->request_wordpress( $url, $method, $params, $timeout );
    254257
    255258        // Request via cURL if WordPress functions failed
    256259        if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
    257260            if ( is_wp_error( $result ) ) {
    258                 $result = $this->request_curl( $url, $method, $params );
     261                $result = $this->request_curl( $url, $method, $params, $timeout );
    259262            }
    260263        }
     
    274277     * @param   string  $method     Method (post|get)
    275278     * @param   array   $params     Parameters
     279     * @param   int     $timeout    Timeout, in seconds (default: 10)
    276280     * @return  mixed               WP_Error | object
    277281     */
    278     private function request_wordpress( $url, $method, $params ) {
     282    private function request_wordpress( $url, $method, $params, $timeout = 10 ) {
    279283
    280284        // Send request
     
    286290                $result = wp_remote_get( $url, array(
    287291                    'body'      => $params,
    288                     'timeout'   => 3,
     292                    'timeout'   => $timeout,
    289293                ) );
    290294                break;
     
    296300                $result = wp_remote_post( $url, array(
    297301                    'body'      => $params,
    298                     'timeout'   => 3,
     302                    'timeout'   => $timeout,
    299303                ) );
    300304                break;
     
    311315            $body = json_decode( $result['body'] );
    312316
     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
    313326            // Return WP_Error
    314327            return new WP_Error(
    315328                $result['response']['code'],
    316                 'Buffer API Error: HTTP Code ' . $result['response']['code'] . '. #' . $body->code . ' - ' . $body->message
     329                'Buffer API Error: HTTP Code ' . $result['response']['code'] . '. #' . $body->code . ' - ' . implode( "\n", $message )
    317330            );
    318331        }
     
    336349     * @param   string  $method     Method (post|get)
    337350     * @param   array   $params     Parameters
     351     * @param   int     $timeout    Timeout, in seconds (default: 10)
    338352     * @return  mixed               WP_Error | object
    339353     */
    340     private function request_curl( $url, $method, $params ) {
     354    private function request_curl( $url, $method, $params, $timeout = 10 ) {
    341355
    342356        // Init
     
    380394            CURLOPT_FOLLOWLOCATION  => true,
    381395            CURLOPT_MAXREDIRS       => 10,
    382             CURLOPT_CONNECTTIMEOUT  => 5,
    383             CURLOPT_TIMEOUT         => 5,
     396            CURLOPT_CONNECTTIMEOUT  => $timeout,
     397            CURLOPT_TIMEOUT         => $timeout,
    384398        ) );
    385399
     
    408422            }
    409423
     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
    410433            // 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 ) );
    412435        }
    413436       
  • wp-to-buffer/trunk/includes/admin/publish.php

    r1766858 r1811195  
    6565        // New Post Screen loading
    6666        // 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' ) {
    6868            return;
    6969        }
     
    7777        if ( $new_status == 'publish' && $old_status == 'publish' ) {
    7878            $result = $this->publish( $post->ID, 'update' );
     79        }
     80
     81        // If no result, bail
     82        if ( ! isset( $result ) ) {
     83            return;
    7984        }
    8085
     
    291296
    292297        // 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
    294304        $featured_image_id = get_post_thumbnail_id( $post->ID );
    295305        if ( $featured_image_id > 0 ) {
    296306            $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
    297309            if ( is_array( $featured_image ) ) {
    298                 $args['media'] = array();
    299                 $args['media']['title']         = $post->post_title;// Required for LinkedIn to work
    300                 $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                );
    304316            }
    305317        }
  • wp-to-buffer/trunk/readme.txt

    r1766858 r1811195  
    44Tags: 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
    55Requires at least: 3.6
    6 Tested up to: 4.9
     6Tested up to: 4.9.2
     7Requires PHP: 5.2
    78Stable tag: trunk
    89License: GPLv2 or later
     
    6263== Screenshots ==
    6364
    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.
     651. Settings Screen when Plugin is first installed.
     662. Settings Screen when Buffer is authorized.
     673. Settings Screen showing available options for Posts.
     684. Post-level Logging.
    6869
    6970== 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'
    7078
    7179= 3.3.2 =
  • wp-to-buffer/trunk/wp-to-buffer.php

    r1766858 r1811195  
    33* Plugin Name: WP to Buffer
    44* Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro
    5 * Version: 3.3.2
     5* Version: 3.3.3
    66* Author: WP Zinc
    77* Author URI: http://www.wpzinc.com
     
    5858        $this->plugin->settingsName     = 'wp-to-buffer'; // Settings key - ensures upgrade users don't lose settings
    5959        $this->plugin->displayName      = 'WP to Buffer';
    60         $this->plugin->version          = '3.3.2';
    61         $this->plugin->buildDate        = '2017-11-15 18:00:00';
     60        $this->plugin->version          = '3.3.3';
     61        $this->plugin->buildDate        = '2018-01-29 12:00:00';
    6262        $this->plugin->requires         = 3.6;
    63         $this->plugin->tested           = '4.9';
     63        $this->plugin->tested           = '4.9.2';
    6464        $this->plugin->folder           = plugin_dir_path( __FILE__ );
    6565        $this->plugin->url              = plugin_dir_url( __FILE__ );
Note: See TracChangeset for help on using the changeset viewer.