Plugin Directory

Changeset 2459994


Ignore:
Timestamp:
01/20/2021 09:34:07 PM (5 years ago)
Author:
clint.s
Message:

Adjusted functions to include escape mechanisms; updated deactivator to not lose data.

Location:
wp-bitly/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-bitly/trunk/README.txt

    r2459172 r2459994  
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Use Bitly generated shortlinks for all your WordPress posts and pages, including custom post types.
     11Create short links to your content with Bitly’s WordPress Plugin.
    1212
    1313== Description ==
    1414
    15 Love WordPress? Love Bitly? What if you could access an interface between both? Now, you can. WP-bitly allows WordPress users to quickly and easily generate shortlinks for any page, post or custom post type.
     15Love WordPress? Love Bitly? After installing this plugin, you’ll be able to shorten a link and view clicks right from WordPress. Your new links will be saved to Bitly for reference and deeper analysis.
    1616
    17 What's more, these shortlinks may also be embedded using a php function or a WordPress shortcode. No matter the type of site you own (from a personal blog to an ecommerce store and everything in between) WP-bitly makes it easy to share your links as and when you please.
     17*To do that, you must have a Bitly account to use the plugin. Your account is where you store, edit, and view metrics for your links. Register at bitly.com.*
    1818
    19 Getting started is easy as pie. Simply install the plugin, visit the settings page, and authorize with your Bitly account. Pick the post types you want shortlinks generated for, and voila! You're ready to start sharing posts with speed and ease.
    20 
    21 After all, texting a shortlink is far simpler and quicker than texting the full URL.
    22 
    23 **PS:** *WP Bitly also offers insights into the way in which your links do the rounds. Who's clicking? Who's sharing? With WP-bitly, you'll always know.*
    24 
     19No matter the type of site you own (from a personal blog to an ecommerce store and everything in between) Bitly makes it easy to create shorter links and keep an eye on your clicks. Whether you share your links on social, SMS, or email, a short link is easier to manage and remember. 
    2520
    2621== Installation ==
    27 Note: you must have a Bitly account in order to use this plugin. Any level of account will work.
    28 * Either install automatically through the WordPress admin, or download the .zip file, unzip to a folder, and upload the folder to your /wp-content/plugins/ directory. Read Installing Plugins in the WordPress Codex for details.
    29 * Activate the plugin through the Plugins menu in WordPress.
     22# Installing the plugin
    3023
    31 Settings for this plugin are found on the Settings->Writing page. You can also access this page directly via the Settings link under this plugin on the Plugins page.
     24You must have a Bitly account to connect to. You can create one at bitly.com. Your account is where you store, edit, and view metrics for your links.
     25If you're familiar with adding a plugin to WordPress directly, you can download the ZIP file and upload it to /wp-content/plugins/ after step 2. Otherwise, follow these steps:
     261. Go to your WordPress plugins settings.
     272. Click Add New.
     283. Search for Bitly's WordPress Plugin.
     294. Click Install Now.
     305. Click Activate.
     316. Scroll down the list of your installed plugins, find
     32Bitly, and click Settings.
     337. Now you'll connect the plugin to your Bitly account. Scroll down to Bitly's WordPress Plugin and click Authorize.
     348. Sign in to Bitly, if necessary, and click Allow. The plugin will retrieve an authorization from Bitly and update the Bitly OAuth Token field.
     359. Scroll down and click Save Changes.
     3610. Select which types of entries you'll be creating short links for.
     3711. If your Bitly account has more than one group, select a group. This is the group where your short links will be saved in Bitly.
     3812. If your Bitly account has more than one custom domain, select a domain. This is the domain that will be used for your short links.
     3913. Click Save Changes.
    3240
    33 To begin using this plugin, you must first obtain an Authorization Token.
    34 To do so, in a separate browser tab login to the Bitly account to which you would like to connect.
    35 Back on the WordPress Writing Settings page, simply click the large Authorize button next
    36 to "Connect with Bitly". If that works successfully the "Bitly OAuth Token" field will be populated with an Authorization Token string. Save these settings.
     41Now you can shorten links when you create a new post!
    3742
    38 Once you have an Authorization Token in place, you can proceed with the related configuration settings.
    39 * **Post Types:** Check which available post types will automatically have shortlinks created automatically upon creation.
    40 * **Default Group:** This select box will allow users with [Enterprise] (https://bitly.com/pages/pricing) level accounts to choose which Group the shortlinks will be associated with. Other account levels will just see their default Group listed.
    41 * **Default Domain:** This select box will allow users with [Basic or Enterprise] (https://bitly.com/pages/pricing) level accounts to choose the shortlink domain that will be used for link creation. By default (and the only option for Free users) this is bit.ly.
    42 * **Debug WP Bitly:** Checking this will create a debug log in /wp-content/plugins/wp-bitly/log/debug.txt.
     43# Creating a short link
    4344
     45After publishing a page or post, you’ll see the Bitly's Wordpress Plugin option in the settings. Click Get Shortlink to create a link to the current content. The link will be saved in your Bitly account, and you’ll be able to view the number of clicks it receives right from this setting.
     46
     47# Viewing a link’s click data
     48
     49Click metrics for a short link will appear in the post’s or page’s settings. They include the number of clicks today, the total number clicks over time, and a graph of the number of clicks over the last 7 days.0
    4450
    4551== Frequently Asked Questions ==
     
    4753= After installation, do I need to update all my posts for short links to be created? =
    4854
    49 No. The first time a shortlink is requested for a particular post, WP Bitly will automatically generate one.
    50 
    51 = What happens if I change a posts permalink? =
    52 
    53 WP Bitly verifies all shortlink requests against Bitly. If the URL has changed it will see this and request a new shortlink.
    54 
    55 = Can I include the shortlink directly in a post? =
    56 
    57 The shortcode `[wpbitly]` accepts all the same arguments as the_shortlink(). You can also set a "post_id" directly if you wish.
    58 
    59 = How do I include a shortlink using PHP? =
    60 
    61 Return a shortlink for the current post:
    62 `wpbitly_shortlink();`
    63 
    64 Returns a shortlink for the specified post ID:
    65 `wpbitly_shortlink(42);`
     55No. The first time a shortlink is requested for a particular post, the plugin will automatically generate one.
    6656
    6757== Changelog ==
  • wp-bitly/trunk/admin/class-wp-bitly-admin.php

    r2459218 r2459994  
    166166
    167167
    168             $token = $_GET['access_token'];
    169             $login = $_GET['login'];
     168            $token = sanitize_text_field($_GET['access_token']);
     169            $login = sanitize_text_field($_GET['login']);
    170170
    171171            $this->wp_bitly_logger->wpbitly_debug_log(array('Referer' => $_SERVER['HTTP_REFERER'], 'Query String' => $_SERVER['QUERY_STRING']), 'Authorizing Env');
     
    201201    public function authorization_successful_notice()
    202202    {
    203         $token = $_GET['access_token'];
     203        $token = sanitize_text_field($_GET['access_token']);
    204204
    205205        if ($this->wp_bitly_auth->isAuthorized()) {
     
    234234            }
    235235
    236             $post_id = (int)$_GET['post'];
     236            $post_id = (int)sanitize_text_field($_GET['post']);
    237237           
    238238            $this->wp_bitly_shortlink->wpbitly_generate_shortlink($post_id, 1);
  • wp-bitly/trunk/includes/class-wp-bitly-auth.php

    r2459218 r2459994  
    108108            exit;
    109109        }
     110       
     111        $code = sanitize_text_field($_POST['code']);
    110112
    111113        $param_arr = array(
    112114            'client_id' => WPBITLY_OAUTH_CLIENT_ID,
    113115            'client_secret' => WPBITLY_OAUTH_CLIENT_SECRET,
    114             'code' => $_POST['code'],
     116            'code' => $code,
    115117            'redirect_uri' => WPBITLY_OAUTH_REDIRECT_URI,
    116118        );
     
    158160        $this->wp_bitly_logger->wpbitly_debug_log( $curl_response, 'class-wp-bitly-auth.php: Processed curl response' );
    159161
    160         $access_token = isset( $curl_response['access_token'] ) ? $curl_response['access_token'] : NULL;
    161         $login = isset( $curl_response['login'] ) ? $curl_response['login'] : NULL;
     162        $access_token = isset( $curl_response['access_token'] ) ? sanitize_text_field($curl_response['access_token']) : NULL;
     163        $login = isset( $curl_response['login'] ) ? sanitize_text_field($curl_response['login']) : NULL;
    162164
    163165        if( !$access_token ) {
  • wp-bitly/trunk/includes/class-wp-bitly-deactivator.php

    r2459218 r2459994  
    2323class Wp_Bitly_Deactivator {
    2424
    25     /**
    26     * Short Description. (use period)
    27     *
    28     * Long Description.
    29     *
    30     * @since    2.6.0
    31     */
    32     public static function deactivate() {
     25    /**
     26    * Short Description. (use period)
     27    *
     28    * Long Description.
     29    *
     30    * @since    2.6.0
     31    */
     32    public static function deactivate() {
    3333
    34     delete_option(WPBITLY_OPTIONS);
    35     delete_option(WPBITLY_AUTHORIZED);
     34        //No actions to be taken at this time.
    3635
    37     // Grab all posts with an attached shortlink
    38     $posts = get_posts('numberposts=-1&post_type=any&meta_key=_wpbitly');
    39 
    40     // And remove our meta information from them
    41     // @TODO benchmark this against deleting it with a quick SQL query. Probably quicker, any conflict?
    42         foreach ($posts as $post) {
    43             delete_post_meta($post->ID, '_wpbitly');
    44         }
    45 
    46     }
     36    }
    4737       
    48 
    4938}
  • wp-bitly/trunk/uninstall.php

    r1808926 r2459994  
    1212
    1313/**
    14  * Some people just don't know how cool this plugin is. When they realize
    15  * it and come back later, let's make sure they have to start all over.
    1614 *
    1715 * @return void
     
    2624
    2725    // And remove our meta information from them
    28     // @TODO benchmark this against deleting it with a quick SQL query. Probably quicker, any conflict?
    29     foreach ($posts as $post)
     26    foreach ($posts as $post){
    3027        delete_post_meta($post->ID, '_wpbitly');
     28    }
    3129
    3230}
    33 
    34 // G'bye!
    3531wpbitly_uninstall();
Note: See TracChangeset for help on using the changeset viewer.