|
@@ -3,9 +3,10 @@
|
|
|
Plugin Name: Keyring
|
|
|
Plugin URI: http://dentedreality.com.au/projects/wp-keyring/
|
|
|
Description: Keyring helps you manage your keys. It provides a generic, very hookable framework for connecting to remote systems and managing your access tokens, username/password combos etc for those services. On its own it doesn't do much, but it enables other plugins to do things that require authorization to act on your behalf.
|
|
|
-Version: 1.5.1
|
|
|
+Version: 1.6
|
|
|
Author: Beau Lebens
|
|
|
Author URI: http://dentedreality.com.au
|
|
|
+License: GPL v2 or newer <https://www.gnu.org/licenses/gpl.txt>
|
|
|
*/
|
|
|
|
|
|
// Define this in your wp-config (and set to true) to enable debugging
|
|
@@ -25,7 +26,7 @@ define( 'KEYRING__DEBUG_WARN', 2 );
|
|
|
define( 'KEYRING__DEBUG_ERROR', 3 );
|
|
|
|
|
|
// Indicates Keyring is installed/active so that other plugins can detect it
|
|
|
-define( 'KEYRING__VERSION', '1.5.1' );
|
|
|
+define( 'KEYRING__VERSION', '1.6' );
|
|
|
|
|
|
/**
|
|
|
* Core Keyring class that handles UI and the general flow of requesting access tokens etc
|
|
@@ -38,6 +39,7 @@ class Keyring {
|
|
|
protected $store = false;
|
|
|
protected $errors = array();
|
|
|
protected $messages = array();
|
|
|
+ protected $token_store = '';
|
|
|
var $admin_page = 'keyring';
|
|
|
|
|
|
function __construct() {
|
|
@@ -45,9 +47,10 @@ class Keyring {
|
|
|
require_once dirname( __FILE__ ) . '/admin-ui.php';
|
|
|
Keyring_Admin_UI::init();
|
|
|
|
|
|
- add_filter( 'keyring_admin_url', function( $url ) {
|
|
|
- return admin_url( 'tools.php?page=' . Keyring::init()->admin_page );
|
|
|
- } );
|
|
|
+ add_filter( 'keyring_admin_url', function( $url, $params ) {
|
|
|
+ $url = admin_url( 'tools.php?page=' . Keyring::init()->admin_page );
|
|
|
+ return add_query_arg( $params, $url );
|
|
|
+ }, 10, 2 );
|
|
|
}
|
|
|
|
|
|
// This is used internally to create URLs, and also to know when to
|
|
@@ -82,7 +85,9 @@ class Keyring {
|
|
|
// Load stores early so we can confirm they're loaded correctly
|
|
|
require_once dirname( __FILE__ ) . '/store.php';
|
|
|
do_action( 'keyring_load_token_stores' );
|
|
|
- if ( !defined( 'KEYRING__TOKEN_STORE' ) || !class_exists( KEYRING__TOKEN_STORE ) || !in_array( 'Keyring_Store', class_parents( KEYRING__TOKEN_STORE ) ) )
|
|
|
+ $keyring = Keyring::init();
|
|
|
+ $keyring->token_store = apply_filters( 'keyring_token_store', defined( 'KEYRING__TOKEN_STORE' ) ? KEYRING__TOKEN_STORE : false );
|
|
|
+ if ( !class_exists( $keyring->token_store ) || !in_array( 'Keyring_Store', class_parents( $keyring->token_store ) ) )
|
|
|
wp_die( sprintf( __( 'Invalid <code>KEYRING__TOKEN_STORE</code> specified. Please make sure <code>KEYRING__TOKEN_STORE</code> is set to a valid classname for handling token storage in <code>%s</code> (or <code>wp-config.php</code>)', 'keyring' ), __FILE__ ) );
|
|
|
|
|
|
// Load base token and service definitions + core services
|
|
@@ -173,7 +178,7 @@ class Keyring {
|
|
|
$keyring = Keyring::init();
|
|
|
|
|
|
if ( !$keyring->store )
|
|
|
- $keyring->store = call_user_func( array( KEYRING__TOKEN_STORE, 'init' ) );
|
|
|
+ $keyring->store = call_user_func( array( $keyring->token_store, 'init' ) );
|
|
|
|
|
|
return $keyring->store;
|
|
|
}
|
|
@@ -251,15 +256,15 @@ class Keyring_Util {
|
|
|
* @return URL to Keyring admin UI (main listing, or specific service verify process)
|
|
|
*/
|
|
|
static function admin_url( $service = false, $params = array() ) {
|
|
|
- $url = apply_filters( 'keyring_admin_url', admin_url( '' ) );
|
|
|
+ $url = admin_url();
|
|
|
|
|
|
if ( $service )
|
|
|
- $url = add_query_arg( array( 'service' => $service ), $url );
|
|
|
+ $params['service'] = $service;
|
|
|
|
|
|
if ( count( $params ) )
|
|
|
$url = add_query_arg( $params, $url );
|
|
|
|
|
|
- return $url;
|
|
|
+ return apply_filters( 'keyring_admin_url', $url, $params );
|
|
|
}
|
|
|
|
|
|
static function connect_to( $service, $for ) {
|