Plugin Directory

Changeset 947412


Ignore:
Timestamp:
07/12/2014 11:26:52 AM (12 years ago)
Author:
perfect-web
Message:

Version 1.2.0

Location:
pwebonedrive/trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • pwebonedrive/trunk/admin-buttons.php

    r939310 r947412  
    11<?php
    22/**
    3  * @version 1.1.0
     3 * @version 1.2.0
    44 * @package OneDrive
    55 * @copyright © 2014 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
     
    5656        'client_id:"'.get_option('pweb_onedrive_client_id').'"',
    5757        'task_url:"'.admin_url( 'admin-ajax.php?action=pweb_onedrive_' ).'"',
    58         'redirect_url:"'.plugins_url( 'callback.php', __FILE__ ).'"',
     58        'redirect_url:"'.LiveConnectClient::getRedirectUri().'"',
    5959        'spinner_url:"'.includes_url().'images/wpspin-2x.gif"'
    6060    );
  • pwebonedrive/trunk/admin.php

    r939310 r947412  
    11<?php
    22/**
    3  * @version 1.1.0
     3 * @version 1.2.0
    44 * @package OneDrive
    55 * @copyright © 2014 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
     
    1818}
    1919
    20 add_filter('plugin_action_links', 'pweb_onedrive_plugin_action_links', 10, 2);
     20add_filter( 'plugin_action_links', 'pweb_onedrive_plugin_action_links', 10, 2 );
    2121function pweb_onedrive_plugin_action_links( $links, $file )
    2222{
     
    2828}
    2929
     30add_action( 'admin_notices', 'pweb_onedrive_admin_notices' );
     31function pweb_onedrive_admin_notices()
     32{
     33    if ((!isset($_GET['page']) OR $_GET['page'] !== 'pwebonedrive-config') AND LiveConnectClient::getRedirectUri() !== get_option('pweb_onedrive_redirect_uri'))
     34    {
     35    ?>
     36    <div class="error" id="pwebonedrive_redirect_uri_notice">
     37        <p><?php printf(__( 'Redirect URL for Perfect OneDrive Gallery & File has changed. You have to update your Windows Live Application. Go to plugin %ssettings%s and save it to dismiss this notice.', 'pwebonedrive' ), '<a href="' . admin_url( 'admin.php?page=pwebonedrive-config' ) . '">', '</a>'); ?></p>
     38    </div>
     39    <?php
     40    }
     41}
    3042
    3143// displays the page content for the settings submenu
     
    3547   
    3648    //must check that the user has the required capability
    37     if (!current_user_can('manage_options'))
    38     {
     49    if (!current_user_can('manage_options')) {
    3950        wp_die( __('You do not have sufficient permissions to access this page.') );
    4051    }
     52   
     53    // cleanup plugin after update
     54    if (is_file( dirname(__FILE__).'/do.php' )) {
     55        @unlink( dirname(__FILE__).'/do.php' );
     56    }
     57   
     58    wp_enqueue_script('jquery');
    4159
    4260    // See if the user has posted us some information
    4361    // If they did, this hidden field will be set to 'Y'
    4462    if (isset($_POST['submitConfig'])) {
    45        
     63   
    4664        $errors = array();
    4765       
    48         if ( isset( $_POST['client_id'] ) AND $_POST['client_id'] )
    49         {
     66        if ( isset( $_POST['client_id'] ) AND $_POST['client_id'] ) {
     67       
    5068            if (preg_match('/^[0-9a-zA-Z]{16}$/', $_POST['client_id'])) {
    5169                update_option( 'pweb_onedrive_client_id', preg_replace('/[^0-9a-zA-Z]$/', '', $_POST['client_id']) );
     
    6583            $errors[] = __('Missing Client secret.', 'pwebonedrive' );
    6684        }
     85       
     86        update_option('pweb_onedrive_redirect_uri', LiveConnectClient::getRedirectUri());
    6787
    6888        if (count($errors)) {
     
    7797        }
    7898    }
     99   
     100    if (LiveConnectClient::getRedirectUri() !== get_option('pweb_onedrive_redirect_uri')) {
     101?>
     102<div class="error">
     103    <p><?php _e( 'Redirect URL for Perfect OneDrive Gallery & File has changed. You have to update your Windows Live Application. Save settings to dismiss this notice.', 'pwebonedrive' ); ?></p>
     104</div>
     105<?php
     106    }
    79107?>
    80108<div class="wrap">
     
    94122    </h2>
    95123   
    96     <?php if (version_compare( $wp_version, '2.8', '<' ) ) { ?>
    97         <div class="error"><p><strong><?php _e('This plugin is compatible with WordPress 2.8 or higher.', 'pwebonedrive' ); ?></strong></p></div>
     124    <?php if (version_compare( $wp_version, '3.1', '<' ) ) { ?>
     125        <div class="error"><p><strong><?php _e('This plugin is compatible with WordPress 3.1 or higher.', 'pwebonedrive' ); ?></strong></p></div>
    98126    <?php } ?>
    99127   
     
    113141                            <?php _e('Register your site in', 'pwebonedrive'); ?>
    114142                            <a target="_blank" href="https://account.live.com/developers/applications/index"><?php _e('Windows Live application management', 'pwebonedrive'); ?></a>.<br>
    115                             <?php _e('Remember to set', 'pwebonedrive'); ?> <strong><?php _e('Redirect URL', 'pwebonedrive'); ?></strong>:
    116                             <a href="<?php echo plugins_url( 'callback.php', __FILE__ ); ?>" target="_blank"><?php echo plugins_url( 'callback.php', __FILE__ ); ?></a><br>
     143                            <?php _e('Remember to set', 'pwebonedrive'); ?> <strong><?php _e('Redirect URL', 'pwebonedrive'); ?></strong>
    117144                            <?php _e('and', 'pwebonedrive'); ?> <strong><?php _e('Mobile client app: No', 'pwebonedrive'); ?></strong><br>
    118145                            <?php _e('and if available', 'pwebonedrive'); ?> <strong><?php _e('Enhanced redirection security: Enabled', 'pwebonedrive'); ?></strong> <?php _e('(for applications created before June 2014)', 'pwebonedrive'); ?><br>
    119146                            <?php _e('Read how to', 'pwebonedrive'); ?> <a target="_blank" href="http://msdn.microsoft.com/library/cc287659.aspx"><?php _e('get your Client ID', 'pwebonedrive'); ?></a>.
    120147                        </p>
     148                    </td>
     149                </tr>
     150                <tr>
     151                    <th><label for="pweb-redirect_uri"><?php _e('Redirect URL', 'pwebonedrive'); ?></label></th>
     152                    <td>
     153                        <input id="pweb-redirect_uri" name="redirect_uri" type="text" size="30" readonly="readonly" value="<?php echo esc_attr( LiveConnectClient::getRedirectUri() ); ?>" class="regular-text code">
     154                        <script type="text/javascript">
     155                        jQuery(document).ready(function($){
     156                            $("input#pweb-redirect_uri")
     157                                .on("click", function(e){
     158                                    e.preventDefault();
     159                                    e.stopPropagation();
     160                                    $(this).select();
     161                                })
     162                                .on("keydown", function(e){
     163                                    e.preventDefault();
     164                                    e.stopPropagation();
     165                                    $(this).select();
     166                                });
     167                        });
     168                        </script>
     169                        <p><em><?php _e('This URL might change if you change WordPress permalinks settings', 'pwebonedrive'); ?></em></p>
    121170                    </td>
    122171                </tr>
     
    154203    (function(){
    155204        var pw=document.createElement("script");pw.type="text/javascript";pw.async=true;
    156         pw.src="https://www.perfect-web.co/index.php?option=com_pwebshop&view=updates&format=raw&extension=wp_onedrive&version=<?php echo pweb_onedrive_get_version(); ?>&wpversion=<?php echo $wp_version; ?>";
     205        pw.src="https://www.perfect-web.co/index.php?option=com_pwebshop&view=updates&format=raw&extension=wp_onedrive&version=<?php echo pweb_onedrive_get_version(); ?>&wpversion=<?php echo $wp_version; ?>&uid=<?php echo md5(home_url()); ?>";
    157206        var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(pw,s);
    158207    })();
  • pwebonedrive/trunk/callback.php

    r939310 r947412  
    11<?php
    22/**
    3  * @version 1.1.0
     3 * @version 1.2.0
    44 * @package OneDrive
    55 * @copyright © 2014 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
    66 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
    77 * @author Piotr Moćko
     8 *
     9 * @deprecated Enable permalinks in WordPress settings to stop using this file
    810 */
    911
     
    1315require_once( dirname(dirname(dirname( dirname( __FILE__ ) ))) . '/wp-load.php' );
    1416
    15 
    16 $client = LiveConnectClient::getInstance();
    17 $client->log(__FUNCTION__);
    18 
    19 echo $client->handlePageRequest();
    20 
    21 $client->log(__FUNCTION__.'. Die');
     17pweb_onedrive_callback();
    2218
    2319die();
  • pwebonedrive/trunk/languages/pwebonedrive-en_GB.pot

    r939310 r947412  
    22msgstr ""
    33"Project-Id-Version: Perfect OneDrive\n"
    4 "POT-Creation-Date: 2014-06-26 22:37+0100\n"
    5 "PO-Revision-Date: 2014-06-26 22:38+0100\n"
     4"POT-Creation-Date: 2014-07-12 13:25+0100\n"
     5"PO-Revision-Date: 2014-07-12 13:26+0100\n"
    66"Last-Translator: Piotr Moćko <[email protected]>\n"
    77"Language-Team: Perfect-Web.co <[email protected]>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.6.5\n"
     12"X-Generator: Poedit 1.6.6\n"
    1313"X-Poedit-Basepath: ../\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    5959msgstr ""
    6060
    61 #: admin.php:39
     61#: admin.php:37
     62#, php-format
     63msgid ""
     64"Redirect URL for Perfect OneDrive Gallery & File has changed. You have to "
     65"update your Windows Live Application. Go to plugin %ssettings%s and save it "
     66"to dismiss this notice."
     67msgstr ""
     68
     69#: admin.php:50
    6270msgid "You do not have sufficient permissions to access this page."
    6371msgstr ""
    6472
    65 #: admin.php:54
     73#: admin.php:72
    6674msgid "Incorrect Client ID."
    6775msgstr ""
    6876
    69 #: admin.php:58
     77#: admin.php:76
    7078msgid "Missing Client ID."
    7179msgstr ""
    7280
    73 #: admin.php:65
     81#: admin.php:83
    7482msgid "Missing Client secret."
    7583msgstr ""
    7684
    77 #: admin.php:75
     85#: admin.php:95
    7886msgid "Settings saved."
    7987msgstr ""
    8088
    81 #: admin.php:83
     89#: admin.php:103
     90msgid ""
     91"Redirect URL for Perfect OneDrive Gallery & File has changed. You have to "
     92"update your Windows Live Application. Save settings to dismiss this notice."
     93msgstr ""
     94
     95#: admin.php:111
    8296msgid "Version"
    8397msgstr ""
    8498
    85 #: admin.php:87
     99#: admin.php:115
    86100msgid "Perfect OneDrive Gallery & File Settings"
    87101msgstr ""
    88102
    89 #: admin.php:90
     103#: admin.php:118
    90104msgid "Documentation"
    91105msgstr ""
    92106
    93 #: admin.php:93
     107#: admin.php:121
    94108msgid "Buy Support"
    95109msgstr ""
    96110
    97 #: admin.php:97
    98 msgid "This plugin is compatible with WordPress 2.8 or higher."
     111#: admin.php:125
     112msgid "This plugin is compatible with WordPress 3.1 or higher."
    99113msgstr ""
    100114
    101 #: admin.php:102
     115#: admin.php:130
    102116msgid ""
    103117"Share easily your photos and files stored on Microsoft OneDrive. You can "
     
    105119msgstr ""
    106120
    107 #: admin.php:113
     121#: admin.php:141
    108122msgid "Register your site in"
    109123msgstr ""
    110124
    111 #: admin.php:114
     125#: admin.php:142
    112126msgid "Windows Live application management"
    113127msgstr ""
    114128
    115 #: admin.php:115
     129#: admin.php:143
    116130msgid "Remember to set"
    117131msgstr ""
    118132
    119 #: admin.php:115
     133#: admin.php:143 admin.php:151
    120134msgid "Redirect URL"
    121135msgstr ""
    122136
    123 #: admin.php:117
     137#: admin.php:144
    124138msgid "and"
    125139msgstr ""
    126140
    127 #: admin.php:117
     141#: admin.php:144
    128142msgid "Mobile client app: No"
    129143msgstr ""
    130144
    131 #: admin.php:118
     145#: admin.php:145
    132146msgid "and if available"
    133147msgstr ""
    134148
    135 #: admin.php:118
     149#: admin.php:145
    136150msgid "Enhanced redirection security: Enabled"
    137151msgstr ""
    138152
    139 #: admin.php:118
     153#: admin.php:145
    140154msgid "(for applications created before June 2014)"
    141155msgstr ""
    142156
    143 #: admin.php:119
     157#: admin.php:146
    144158msgid "Read how to"
    145159msgstr ""
    146160
    147 #: admin.php:119
     161#: admin.php:146
    148162msgid "get your Client ID"
    149163msgstr ""
    150164
    151 #: admin.php:124
     165#: admin.php:169
     166msgid "This URL might change if you change WordPress permalinks settings"
     167msgstr ""
     168
     169#: admin.php:173
    152170msgid "Client ID"
    153171msgstr ""
    154172
    155 #: admin.php:130
     173#: admin.php:179
    156174msgid "Client secret"
    157175msgstr ""
    158176
    159 #: pwebonedrive.php:141
     177#: pwebonedrive.php:143
    160178msgid "There are no images in this gallery!"
    161179msgstr ""
    162180
    163 #: pwebonedrive.php:147
     181#: pwebonedrive.php:149
    164182msgid "Can not load images!"
    165183msgstr ""
    166184
    167 #: pwebonedrive.php:244
     185#: pwebonedrive.php:246
    168186msgid "Can not load file!"
    169187msgstr ""
    170188
    171 #: pwebonedrive.php:268 pwebonedrive.php:309 pwebonedrive.php:382
    172 #: pwebonedrive.php:422 pwebonedrive.php:445
     189#: pwebonedrive.php:270 pwebonedrive.php:311 pwebonedrive.php:385
     190#: pwebonedrive.php:426 pwebonedrive.php:449
    173191msgid "Can not load data!"
    174192msgstr ""
  • pwebonedrive/trunk/liveconnect.php

    r939310 r947412  
    11<?php
    22/**
    3  * @version 1.1.0
     3 * @version 1.2.0
    44 * @package OneDrive
    55 * @copyright © 2014 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
     
    1919    protected $options;
    2020    protected $http;
    21     protected $access_id        = 0;
    22     protected static $access    = array();
    23     protected static $token     = array();
    24     protected static $instance  = null;
     21    protected $access_id            = 0;
     22    protected static $access        = array();
     23    protected static $token         = array();
     24    protected static $redirect_uri  = null;
     25    protected static $instance      = null;
    2526   
    2627    public function __construct($options = null)
     
    3334            'authurl'       => 'https://login.live.com/oauth20_token.srf',
    3435            'tokenurl'      => 'https://login.live.com/oauth20_token.srf',
    35             'redirecturi'   => plugins_url( 'callback.php', __FILE__ ),
     36            'redirecturi'   => self::getRedirectUri(),
    3637            'userefresh'    => true,
    3738            'storetoken'    => true,
     
    6465            self::$instance = & $instance;
    6566        }
     67    }
     68   
     69   
     70    public static function getRedirectUri()
     71    {
     72        if (!self::$redirect_uri)
     73        {
     74            $permalink_structure = get_option('permalink_structure');
     75           
     76            if ($permalink_structure)
     77            {
     78                $pos = strpos($permalink_structure, 'index.php/');
     79                if ($pos === 0 OR $pos === 1)
     80                {
     81                    self::$redirect_uri = home_url( 'index.php/pwebonedrive/callback' );
     82                }
     83                else
     84                {
     85                    self::$redirect_uri = home_url( 'pwebonedrive/callback' );
     86                }
     87            }
     88            else
     89            {
     90                self::$redirect_uri = plugins_url( 'callback.php', __FILE__ );
     91            }
     92        }
     93       
     94        return self::$redirect_uri;
    6695    }
    6796   
  • pwebonedrive/trunk/pwebonedrive.php

    r942142 r947412  
    44 * Plugin URI: http://www.perfect-web.co/wordpress/microsoft-onedrive-gallery-file
    55 * Description: Share easily your photos and files stored on Microsoft OneDrive. You can display a gallery with your photos or a link to a file for download.
    6  * Version: 1.1.0
     6 * Version: 1.2.0
    77 * Text Domain: pwebonedrive
    88 * Author: Piotr Moćko
     
    2727}
    2828add_action('init', 'pweb_onedrive_init');
     29
    2930
    3031
     
    123124               
    124125                // Image url
    125                 $url = plugins_url('do.php', __FILE__).'?action=display_photo&aid='.$images->access_id.'&code='.base64_encode($image->id.'/picture?type='.$full).'#'.$image->ext;
    126                 $src = plugins_url('do.php', __FILE__).'?action=display_photo&aid='.$images->access_id.'&code='.base64_encode($image->id.'/picture?type='.$thumbnail);
     126                $url = admin_url('admin-ajax.php?action=pweb_onedrive_display_photo&aid='.$images->access_id.'&code='.base64_encode($image->id.'/picture?type='.$full).'#'.$image->ext);
     127                $src = admin_url('admin-ajax.php?action=pweb_onedrive_display_photo&aid='.$images->access_id.'&code='.base64_encode($image->id.'/picture?type='.$thumbnail));
    127128               
    128129                // Output image
     
    190191           
    191192            // Image url
    192             $src = plugins_url('do.php', __FILE__).'?action=display_photo&aid='.$file->access_id.'&code='.base64_encode($file->id.'/picture?type='.$image);
     193            $src = admin_url('admin-ajax.php?action=pweb_onedrive_display_photo&aid='.$file->access_id.'&code='.base64_encode($file->id.'/picture?type='.$image));
    193194           
    194195            // Output image
     
    227228           
    228229            // File url
    229             $url = plugins_url('do.php', __FILE__).'?action=download_file&aid='.$file->access_id.'&code='.base64_encode($file->id.'/content?download=true');
     230            $url = admin_url('admin-ajax.php?action=pweb_onedrive_download_file&aid='.$file->access_id.'&code='.base64_encode($file->id.'/content?download=true'));
    230231           
    231232            // Output file
     
    364365
    365366
     367add_action('wp_ajax_pweb_onedrive_download_file', 'pweb_onedrive_download_file');
    366368add_action('wp_ajax_nopriv_pweb_onedrive_download_file', 'pweb_onedrive_download_file');
    367369function pweb_onedrive_download_file()
     
    404406
    405407
     408add_action('wp_ajax_pweb_onedrive_display_photo', 'pweb_onedrive_display_photo');
    406409add_action('wp_ajax_nopriv_pweb_onedrive_display_photo', 'pweb_onedrive_display_photo');
    407410function pweb_onedrive_display_photo()
     
    454457        echo $response['body'];
    455458    }
     459
     460    die();
     461}
     462
     463
     464function pweb_onedrive_parse_request()
     465{
     466    if (!empty($_SERVER['REQUEST_URI']) AND preg_match('/\/pwebonedrive\/callback\/?$/', $_SERVER['REQUEST_URI']) === 1)
     467    {
     468        pweb_onedrive_callback();
     469    }
     470}
     471add_action('parse_request', 'pweb_onedrive_parse_request');
     472
     473function pweb_onedrive_callback()
     474{
     475    $client = LiveConnectClient::getInstance();
     476    $client->log(__FUNCTION__);
     477
     478    echo $client->handlePageRequest();
     479
     480    $client->log(__FUNCTION__.'. Die');
    456481
    457482    die();
     
    493518    dbDelta( $sql );
    494519}
     520
     521register_uninstall_hook( __FILE__, 'pweb_onedrive_uninstall' );
     522function pweb_onedrive_uninstall()
     523{
     524    global $wpdb;
     525   
     526    $wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}onedrive_access`" );
     527    $wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}onedrive_storage`" );
     528   
     529    delete_option( 'pweb_onedrive_client_id' );
     530    delete_option( 'pweb_onedrive_client_secret' );
     531    delete_option( 'pweb_onedrive_redirect_uri' );
     532}
  • pwebonedrive/trunk/readme.txt

    r939310 r947412  
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CDDZ6G6LDV4LG
    44Tags: onedrive, one drive, skydrive, microsoft, gallery, download, cloud storage
    5 Requires at least: 2.8.0
     5Requires at least: 3.1.0
    66Tested up to: 3.9.1
    7 Stable tag: 1.1.0
     7Stable tag: 1.2.0
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    124124== Changelog ==
    125125
     126= 1.2.0 / 12-07-2014 =
     127* Requires at least WordPress 3.1
     128* New redirect URL which supports permalinks
     129* Handle OneDrive calls through WordPress AJAX interface
     130
    126131= 1.1.0 / 26-06-2014 =
    127132* Fixed redirect URL for new Windows Live applications
     
    150155= 1.1.0 =
    151156New redirect URL for Windows Live applications! See configuration of plugin after upgrade.
     157
     158= 1.2.0 =
     159New redirect URL for Windows Live applications! See configuration of plugin after upgrade.
Note: See TracChangeset for help on using the changeset viewer.