mirror of
https://github.com/discourse/wp-discourse.git
synced 2025-10-04 09:01:05 +08:00
Renamed SSO Client class
- added composer autoload
This commit is contained in:
parent
5225fade4f
commit
388af97d2c
18 changed files with 665 additions and 1436 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -4,6 +4,9 @@
|
||||||
.idea/*
|
.idea/*
|
||||||
|
|
||||||
vendor/*
|
vendor/*
|
||||||
|
!vendor/autoload.php
|
||||||
*.sublime-workspace
|
!vendor/composer/
|
||||||
*.sublime-project
|
!vendor/composer/**
|
||||||
|
|
||||||
|
*.sublime-workspace
|
||||||
|
*.sublime-project
|
||||||
|
|
|
@ -8,10 +8,13 @@
|
||||||
|
|
||||||
<!-- Include the WordPress ruleset, with exclusions. -->
|
<!-- Include the WordPress ruleset, with exclusions. -->
|
||||||
<rule ref="WordPress">
|
<rule ref="WordPress">
|
||||||
|
<exclude name="Generic.Files.LowercasedFilename" />
|
||||||
|
<exclude name="WordPress.NamingConventions.ValidHookName" />
|
||||||
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
||||||
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
||||||
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
|
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
|
||||||
<exclude name="WordPress.VIP.RestrictedFunctions" />
|
<exclude name="WordPress.VIP.RestrictedFunctions" />
|
||||||
|
<exclude name="WordPress.VIP.SlowDBQuery" />
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Include sniffs for PHP cross-version compatibility. -->
|
<!-- Include sniffs for PHP cross-version compatibility. -->
|
||||||
|
|
|
@ -18,11 +18,27 @@
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/discourse/wp-discourse/issues"
|
"issues": "https://github.com/discourse/wp-discourse/issues"
|
||||||
},
|
},
|
||||||
"require": {
|
"autoload": {
|
||||||
"php": ">=5.3",
|
"psr-4": {
|
||||||
"composer/installers": "1.0.*"
|
"WPDiscourse\\": "lib"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
|
||||||
"php-mock/php-mock-phpunit": "^0.3"
|
"files" : [
|
||||||
|
"lib/utilities.php",
|
||||||
|
"lib/nonce.php",
|
||||||
|
"templates/html-templates.php",
|
||||||
|
"templates/template-functions.php",
|
||||||
|
"lib/discourse.php",
|
||||||
|
"lib/settings-validator.php",
|
||||||
|
"lib/admin.php",
|
||||||
|
"lib/sso.php",
|
||||||
|
"lib/wordpress-email-verification.php",
|
||||||
|
"lib/discourse-sso.php",
|
||||||
|
"lib/discourse-publish.php",
|
||||||
|
"lib/discourse-comment.php",
|
||||||
|
"lib/meta-box.php",
|
||||||
|
"lib/shortcodes/external-sso.php",
|
||||||
|
"lib/sso-login-form.php"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1394
composer.lock
generated
1394
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -257,14 +257,14 @@ class DiscourseAdmin {
|
||||||
'sso_settings_tab_details',
|
'sso_settings_tab_details',
|
||||||
), 'discourse_sso' );
|
), 'discourse_sso' );
|
||||||
|
|
||||||
add_settings_field( 'discourse_enable_sso', __( 'Enable SSO', 'wp-discourse' ), array(
|
add_settings_field( 'discourse_enable_sso', __( 'Enable SSO Server', 'wp-discourse' ), array(
|
||||||
$this,
|
$this,
|
||||||
'enable_sso_checkbox',
|
'enable_sso_provider_checkbox',
|
||||||
), 'discourse_sso', 'discourse_sso_settings_section' );
|
), 'discourse_sso', 'discourse_sso_settings_section' );
|
||||||
|
|
||||||
add_settings_field( 'discourse_enable_discourse_sso', __( 'Enable Discourse SSO', 'wp-discourse' ), array(
|
add_settings_field( 'discourse_enable_discourse_sso', __( 'Enable SSO Client', 'wp-discourse' ), array(
|
||||||
$this,
|
$this,
|
||||||
'enable_discourse_sso_checkbox',
|
'enable_sso_client_checkbox',
|
||||||
), 'discourse_sso', 'discourse_sso_settings_section' );
|
), 'discourse_sso', 'discourse_sso_settings_section' );
|
||||||
|
|
||||||
add_settings_field( 'enable_discourse_sso_login_form_change', __( 'Add "Login with Discourse" on the login form', 'wp-discourse' ), array(
|
add_settings_field( 'enable_discourse_sso_login_form_change', __( 'Add "Login with Discourse" on the login form', 'wp-discourse' ), array(
|
||||||
|
@ -578,23 +578,24 @@ class DiscourseAdmin {
|
||||||
/**
|
/**
|
||||||
* Outputs markup for the enable-sso checkbox.
|
* Outputs markup for the enable-sso checkbox.
|
||||||
*/
|
*/
|
||||||
public function enable_sso_checkbox() {
|
public function enable_sso_provider_checkbox() {
|
||||||
$this->checkbox_input( 'enable-sso', 'discourse_sso', __( 'Enable SSO to Discourse.', 'wp-discourse' ) );
|
$description = __( 'Use this WP Instance as a SSO provider.', 'wp-discourse' );
|
||||||
|
$this->checkbox_input( 'enable-sso', 'discourse_sso', __( 'Enable SSO Provider.', 'wp-discourse' ), $description );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs markup for enable-discourse-sso checkbox.
|
* Outputs markup for sso-client-enabled checkbox.
|
||||||
*/
|
*/
|
||||||
public function enable_discourse_sso_checkbox() {
|
public function enable_sso_client_checkbox() {
|
||||||
$description = __( 'Use external Discourse instance as a SSO provider. In order to enable this functionality, you <strong>must</strong> fill <code>SSO Secret key</code> and <code>Discourse URL</code> fields', 'wp-discourse' );
|
$description = __( 'Use external Discourse instance as a SSO provider. In order to enable this functionality, you <strong>must</strong> fill <code>SSO Secret key</code> and <code>Discourse URL</code> fields', 'wp-discourse' );
|
||||||
$this->checkbox_input( 'enable-discourse-sso', 'discourse_sso', __( 'Enable SSO From Discourse.', 'wp-discourse' ), $description );
|
$this->checkbox_input( 'sso-client-enabled', 'discourse_sso', __( 'Enable SSO Client.', 'wp-discourse' ), $description );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs markup for enable-discourse-sso-login-form-change
|
* Outputs markup for sso-client-login-form-change
|
||||||
*/
|
*/
|
||||||
public function enable_discourse_sso_login_form_change_checkbox() {
|
public function enable_discourse_sso_login_form_change_checkbox() {
|
||||||
$this->checkbox_input( 'enable-discourse-sso-login-form-change', 'discourse_sso', __( 'Add "Login with Discourse" on the login form', 'wp-discourse' ) );
|
$this->checkbox_input( 'sso-client-login-form-change', 'discourse_sso', __( 'Add "Login with Discourse" on the login form', 'wp-discourse' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use \WPDiscourse\Utilities\Utilities as DiscourseUtilities;
|
||||||
*/
|
*/
|
||||||
function discourse_sso_auto_inject_button() {
|
function discourse_sso_auto_inject_button() {
|
||||||
$options = DiscourseUtilities::get_options();
|
$options = DiscourseUtilities::get_options();
|
||||||
return ! empty( $options['enable-discourse-sso'] ) && ! empty( $options['enable-discourse-sso-login-form-change'] );
|
return ! empty( $options['sso-client-enabled'] ) && ! empty( $options['sso-client-login-form-change'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
/**
|
/**
|
||||||
* Allows for Single Sign On between WordPress and Discourse with Discourse as SSO Provider
|
* Allows for Single Sign On between WordPress and Discourse with Discourse as SSO Provider
|
||||||
*
|
*
|
||||||
* @package WPDiscourse\DiscourseSSO
|
* @package WPDiscourse\sso
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace WPDiscourse\DiscourseSSO;
|
namespace WPDiscourse\sso;
|
||||||
|
|
||||||
use \WPDiscourse\Utilities\Utilities as DiscourseUtilities;
|
use \WPDiscourse\Utilities\Utilities as DiscourseUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DiscourseExternalSSO
|
* Class Client
|
||||||
*/
|
*/
|
||||||
class DiscourseExternalSSO {
|
class Client {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user meta key name that would store the Discourse user id
|
* The user meta key name that would store the Discourse user id
|
7
vendor/autoload.php
vendored
Normal file
7
vendor/autoload.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
|
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||||
|
|
||||||
|
return ComposerAutoloaderInitf7efd7869497cb2fedf38f172df9f351::getLoader();
|
413
vendor/composer/ClassLoader.php
vendored
Normal file
413
vendor/composer/ClassLoader.php
vendored
Normal file
|
@ -0,0 +1,413 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||||
|
*
|
||||||
|
* $loader = new \Composer\Autoload\ClassLoader();
|
||||||
|
*
|
||||||
|
* // register classes with namespaces
|
||||||
|
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||||
|
* $loader->add('Symfony', __DIR__.'/framework');
|
||||||
|
*
|
||||||
|
* // activate the autoloader
|
||||||
|
* $loader->register();
|
||||||
|
*
|
||||||
|
* // to enable searching the include path (eg. for PEAR packages)
|
||||||
|
* $loader->setUseIncludePath(true);
|
||||||
|
*
|
||||||
|
* In this example, if you try to use a class in the Symfony\Component
|
||||||
|
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||||
|
* the autoloader will first look for the class under the component/
|
||||||
|
* directory, and it will then fallback to the framework/ directory if not
|
||||||
|
* found before giving up.
|
||||||
|
*
|
||||||
|
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
* @see http://www.php-fig.org/psr/psr-0/
|
||||||
|
* @see http://www.php-fig.org/psr/psr-4/
|
||||||
|
*/
|
||||||
|
class ClassLoader
|
||||||
|
{
|
||||||
|
// PSR-4
|
||||||
|
private $prefixLengthsPsr4 = array();
|
||||||
|
private $prefixDirsPsr4 = array();
|
||||||
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
// PSR-0
|
||||||
|
private $prefixesPsr0 = array();
|
||||||
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
|
private $useIncludePath = false;
|
||||||
|
private $classMap = array();
|
||||||
|
|
||||||
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrefixesPsr4()
|
||||||
|
{
|
||||||
|
return $this->prefixDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFallbackDirs()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFallbackDirsPsr4()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassMap()
|
||||||
|
{
|
||||||
|
return $this->classMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $classMap Class to filename map
|
||||||
|
*/
|
||||||
|
public function addClassMap(array $classMap)
|
||||||
|
{
|
||||||
|
if ($this->classMap) {
|
||||||
|
$this->classMap = array_merge($this->classMap, $classMap);
|
||||||
|
} else {
|
||||||
|
$this->classMap = $classMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param array|string $paths The PSR-0 root directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*/
|
||||||
|
public function add($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->fallbackDirsPsr0
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$this->fallbackDirsPsr0,
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = $prefix[0];
|
||||||
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($prepend) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param array|string $paths The PSR-4 base directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
// Register directories for the root namespace.
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->fallbackDirsPsr4
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$this->fallbackDirsPsr4,
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
|
// Register directories for a new namespace.
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
} elseif ($prepend) {
|
||||||
|
// Prepend directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->prefixDirsPsr4[$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Append directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$this->prefixDirsPsr4[$prefix],
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
|
* replacing any others previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param array|string $paths The PSR-0 base directories
|
||||||
|
*/
|
||||||
|
public function set($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr0 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
|
* replacing any others previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param array|string $paths The PSR-4 base directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function setPsr4($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on searching the include path for class files.
|
||||||
|
*
|
||||||
|
* @param bool $useIncludePath
|
||||||
|
*/
|
||||||
|
public function setUseIncludePath($useIncludePath)
|
||||||
|
{
|
||||||
|
$this->useIncludePath = $useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to check if the autoloader uses the include path to check
|
||||||
|
* for classes.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseIncludePath()
|
||||||
|
{
|
||||||
|
return $this->useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns off searching the prefix and fallback directories for classes
|
||||||
|
* that have not been registered with the class map.
|
||||||
|
*
|
||||||
|
* @param bool $classMapAuthoritative
|
||||||
|
*/
|
||||||
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
|
{
|
||||||
|
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should class lookup fail if not found in the current class map?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isClassMapAuthoritative()
|
||||||
|
{
|
||||||
|
return $this->classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
|
*/
|
||||||
|
public function register($prepend = false)
|
||||||
|
{
|
||||||
|
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters this instance as an autoloader.
|
||||||
|
*/
|
||||||
|
public function unregister()
|
||||||
|
{
|
||||||
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given class or interface.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
* @return bool|null True if loaded, null otherwise
|
||||||
|
*/
|
||||||
|
public function loadClass($class)
|
||||||
|
{
|
||||||
|
if ($file = $this->findFile($class)) {
|
||||||
|
includeFile($file);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the path to the file where the class is defined.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
*
|
||||||
|
* @return string|false The path if found, false otherwise
|
||||||
|
*/
|
||||||
|
public function findFile($class)
|
||||||
|
{
|
||||||
|
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
||||||
|
if ('\\' == $class[0]) {
|
||||||
|
$class = substr($class, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// class map lookup
|
||||||
|
if (isset($this->classMap[$class])) {
|
||||||
|
return $this->classMap[$class];
|
||||||
|
}
|
||||||
|
if ($this->classMapAuthoritative) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $this->findFileWithExtension($class, '.php');
|
||||||
|
|
||||||
|
// Search for Hack files if we are running on HHVM
|
||||||
|
if ($file === null && defined('HHVM_VERSION')) {
|
||||||
|
$file = $this->findFileWithExtension($class, '.hh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file === null) {
|
||||||
|
// Remember that this class does not exist.
|
||||||
|
return $this->classMap[$class] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function findFileWithExtension($class, $ext)
|
||||||
|
{
|
||||||
|
// PSR-4 lookup
|
||||||
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
|
$first = $class[0];
|
||||||
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||||
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-4 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 lookup
|
||||||
|
if (false !== $pos = strrpos($class, '\\')) {
|
||||||
|
// namespaced class name
|
||||||
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||||
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||||
|
} else {
|
||||||
|
// PEAR-like class name
|
||||||
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||||
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 include paths.
|
||||||
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*/
|
||||||
|
function includeFile($file)
|
||||||
|
{
|
||||||
|
include $file;
|
||||||
|
}
|
21
vendor/composer/LICENSE
vendored
Normal file
21
vendor/composer/LICENSE
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
9
vendor/composer/autoload_classmap.php
vendored
Normal file
9
vendor/composer/autoload_classmap.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
);
|
24
vendor/composer/autoload_files.php
vendored
Normal file
24
vendor/composer/autoload_files.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_files.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'191c68385fa25fcf7c0ba64b69c63c81' => $baseDir . '/lib/utilities.php',
|
||||||
|
'a16245baefd6785ef0345cff114aa134' => $baseDir . '/lib/nonce.php',
|
||||||
|
'0c7c4aacd75fdaf585b72348270cb3de' => $baseDir . '/templates/html-templates.php',
|
||||||
|
'8c3c05c3c2519b6641a1e486567145b8' => $baseDir . '/templates/template-functions.php',
|
||||||
|
'e5efb0fa381f8438272be104b093e499' => $baseDir . '/lib/discourse.php',
|
||||||
|
'3ee622b6e8c6ba4a0ceb853911efa068' => $baseDir . '/lib/settings-validator.php',
|
||||||
|
'c2a1c14d662e9675c74081ad8fd263df' => $baseDir . '/lib/admin.php',
|
||||||
|
'8414ac5b3317db5c7f814a400a70bede' => $baseDir . '/lib/sso.php',
|
||||||
|
'3e670055f2a1d37231fc0de01060df5c' => $baseDir . '/lib/wordpress-email-verification.php',
|
||||||
|
'2576b78bf953f170e6fb49c7522f4b87' => $baseDir . '/lib/discourse-sso.php',
|
||||||
|
'ad23c5c120928b04a64d78776bec03a9' => $baseDir . '/lib/discourse-publish.php',
|
||||||
|
'3ef930cf0d8770f15146243e7a52ec35' => $baseDir . '/lib/discourse-comment.php',
|
||||||
|
'b417e751a51291c9433c4df9c572ce7e' => $baseDir . '/lib/meta-box.php',
|
||||||
|
'ebb56e0ef496de48d5b73d0229747ab3' => $baseDir . '/lib/shortcodes/external-sso.php',
|
||||||
|
'dce7995de1a1d2d76b86220bac8dbbff' => $baseDir . '/lib/sso-login-form.php',
|
||||||
|
);
|
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
);
|
10
vendor/composer/autoload_psr4.php
vendored
Normal file
10
vendor/composer/autoload_psr4.php
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'WPDiscourse\\' => array($baseDir . '/lib'),
|
||||||
|
);
|
70
vendor/composer/autoload_real.php
vendored
Normal file
70
vendor/composer/autoload_real.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
|
class ComposerAutoloaderInitf7efd7869497cb2fedf38f172df9f351
|
||||||
|
{
|
||||||
|
private static $loader;
|
||||||
|
|
||||||
|
public static function loadClassLoader($class)
|
||||||
|
{
|
||||||
|
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||||
|
require __DIR__ . '/ClassLoader.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getLoader()
|
||||||
|
{
|
||||||
|
if (null !== self::$loader) {
|
||||||
|
return self::$loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
spl_autoload_register(array('ComposerAutoloaderInitf7efd7869497cb2fedf38f172df9f351', 'loadClassLoader'), true, true);
|
||||||
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||||
|
spl_autoload_unregister(array('ComposerAutoloaderInitf7efd7869497cb2fedf38f172df9f351', 'loadClassLoader'));
|
||||||
|
|
||||||
|
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
|
||||||
|
if ($useStaticLoader) {
|
||||||
|
require_once __DIR__ . '/autoload_static.php';
|
||||||
|
|
||||||
|
call_user_func(\Composer\Autoload\ComposerStaticInitf7efd7869497cb2fedf38f172df9f351::getInitializer($loader));
|
||||||
|
} else {
|
||||||
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||||
|
foreach ($map as $namespace => $path) {
|
||||||
|
$loader->set($namespace, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = require __DIR__ . '/autoload_psr4.php';
|
||||||
|
foreach ($map as $namespace => $path) {
|
||||||
|
$loader->setPsr4($namespace, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||||
|
if ($classMap) {
|
||||||
|
$loader->addClassMap($classMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$loader->register(true);
|
||||||
|
|
||||||
|
if ($useStaticLoader) {
|
||||||
|
$includeFiles = Composer\Autoload\ComposerStaticInitf7efd7869497cb2fedf38f172df9f351::$files;
|
||||||
|
} else {
|
||||||
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
|
}
|
||||||
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
|
composerRequiref7efd7869497cb2fedf38f172df9f351($fileIdentifier, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $loader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function composerRequiref7efd7869497cb2fedf38f172df9f351($fileIdentifier, $file)
|
||||||
|
{
|
||||||
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
|
require $file;
|
||||||
|
|
||||||
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
}
|
||||||
|
}
|
49
vendor/composer/autoload_static.php
vendored
Normal file
49
vendor/composer/autoload_static.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_static.php @generated by Composer
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
class ComposerStaticInitf7efd7869497cb2fedf38f172df9f351
|
||||||
|
{
|
||||||
|
public static $files = array (
|
||||||
|
'191c68385fa25fcf7c0ba64b69c63c81' => __DIR__ . '/../..' . '/lib/utilities.php',
|
||||||
|
'a16245baefd6785ef0345cff114aa134' => __DIR__ . '/../..' . '/lib/nonce.php',
|
||||||
|
'0c7c4aacd75fdaf585b72348270cb3de' => __DIR__ . '/../..' . '/templates/html-templates.php',
|
||||||
|
'8c3c05c3c2519b6641a1e486567145b8' => __DIR__ . '/../..' . '/templates/template-functions.php',
|
||||||
|
'e5efb0fa381f8438272be104b093e499' => __DIR__ . '/../..' . '/lib/discourse.php',
|
||||||
|
'3ee622b6e8c6ba4a0ceb853911efa068' => __DIR__ . '/../..' . '/lib/settings-validator.php',
|
||||||
|
'c2a1c14d662e9675c74081ad8fd263df' => __DIR__ . '/../..' . '/lib/admin.php',
|
||||||
|
'8414ac5b3317db5c7f814a400a70bede' => __DIR__ . '/../..' . '/lib/sso.php',
|
||||||
|
'3e670055f2a1d37231fc0de01060df5c' => __DIR__ . '/../..' . '/lib/wordpress-email-verification.php',
|
||||||
|
'2576b78bf953f170e6fb49c7522f4b87' => __DIR__ . '/../..' . '/lib/discourse-sso.php',
|
||||||
|
'ad23c5c120928b04a64d78776bec03a9' => __DIR__ . '/../..' . '/lib/discourse-publish.php',
|
||||||
|
'3ef930cf0d8770f15146243e7a52ec35' => __DIR__ . '/../..' . '/lib/discourse-comment.php',
|
||||||
|
'b417e751a51291c9433c4df9c572ce7e' => __DIR__ . '/../..' . '/lib/meta-box.php',
|
||||||
|
'ebb56e0ef496de48d5b73d0229747ab3' => __DIR__ . '/../..' . '/lib/shortcodes/external-sso.php',
|
||||||
|
'dce7995de1a1d2d76b86220bac8dbbff' => __DIR__ . '/../..' . '/lib/sso-login-form.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixLengthsPsr4 = array (
|
||||||
|
'W' =>
|
||||||
|
array (
|
||||||
|
'WPDiscourse\\' => 12,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixDirsPsr4 = array (
|
||||||
|
'WPDiscourse\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/lib',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function getInitializer(ClassLoader $loader)
|
||||||
|
{
|
||||||
|
return \Closure::bind(function () use ($loader) {
|
||||||
|
$loader->prefixLengthsPsr4 = ComposerStaticInitf7efd7869497cb2fedf38f172df9f351::$prefixLengthsPsr4;
|
||||||
|
$loader->prefixDirsPsr4 = ComposerStaticInitf7efd7869497cb2fedf38f172df9f351::$prefixDirsPsr4;
|
||||||
|
|
||||||
|
}, null, ClassLoader::class);
|
||||||
|
}
|
||||||
|
}
|
1
vendor/composer/installed.json
vendored
Normal file
1
vendor/composer/installed.json
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
|
@ -36,22 +36,7 @@ define( 'MIN_WP_VERSION', '4.4' );
|
||||||
define( 'MIN_PHP_VERSION', '5.4.0' );
|
define( 'MIN_PHP_VERSION', '5.4.0' );
|
||||||
define( 'WPDISCOURSE_VERSION', '1.1.1' );
|
define( 'WPDISCOURSE_VERSION', '1.1.1' );
|
||||||
|
|
||||||
require_once( __DIR__ . '/lib/utilities.php' );
|
require 'vendor/autoload.php';
|
||||||
require_once( __DIR__ . '/lib/nonce.php' );
|
|
||||||
require_once( __DIR__ . '/templates/html-templates.php' );
|
|
||||||
require_once( __DIR__ . '/templates/template-functions.php' );
|
|
||||||
require_once( __DIR__ . '/lib/discourse.php' );
|
|
||||||
require_once( __DIR__ . '/lib/settings-validator.php' );
|
|
||||||
require_once( __DIR__ . '/lib/admin.php' );
|
|
||||||
require_once( __DIR__ . '/lib/sso.php' );
|
|
||||||
require_once( __DIR__ . '/lib/wordpress-email-verification.php' );
|
|
||||||
require_once( __DIR__ . '/lib/discourse-sso.php' );
|
|
||||||
require_once( __DIR__ . '/lib/discourse-external-sso.php' );
|
|
||||||
require_once( __DIR__ . '/lib/discourse-publish.php' );
|
|
||||||
require_once( __DIR__ . '/lib/discourse-comment.php' );
|
|
||||||
require_once( __DIR__ . '/lib/meta-box.php' );
|
|
||||||
require_once( __DIR__ . '/lib/shortcodes/external-sso.php' );
|
|
||||||
require_once( __DIR__ . '/lib/sso-login-form.php' );
|
|
||||||
|
|
||||||
$discourse_settings_validator = new WPDiscourse\Validator\SettingsValidator();
|
$discourse_settings_validator = new WPDiscourse\Validator\SettingsValidator();
|
||||||
$discourse = new WPDiscourse\Discourse\Discourse();
|
$discourse = new WPDiscourse\Discourse\Discourse();
|
||||||
|
@ -60,7 +45,9 @@ $discourse_publisher = new WPDiscourse\DiscoursePublish\DiscoursePublis
|
||||||
$discourse_comment = new WPDiscourse\DiscourseComment\DiscourseComment();
|
$discourse_comment = new WPDiscourse\DiscourseComment\DiscourseComment();
|
||||||
$wordpress_email_verifier = new WPDiscourse\WordPressEmailVerification\WordPressEmailVerification( 'discourse_email_verification_key', 'discourse' );
|
$wordpress_email_verifier = new WPDiscourse\WordPressEmailVerification\WordPressEmailVerification( 'discourse_email_verification_key', 'discourse' );
|
||||||
$discourse_sso = new WPDiscourse\DiscourseSSO\DiscourseSSO( $wordpress_email_verifier );
|
$discourse_sso = new WPDiscourse\DiscourseSSO\DiscourseSSO( $wordpress_email_verifier );
|
||||||
$discourse_external_sso = new WPDiscourse\DiscourseSSO\DiscourseExternalSSO();
|
|
||||||
$discourse_publish_metabox = new WPDiscourse\MetaBox\MetaBox();
|
$discourse_publish_metabox = new WPDiscourse\MetaBox\MetaBox();
|
||||||
|
|
||||||
|
// refactored classes that use autoload
|
||||||
|
$discourse_external_sso = new WPDiscourse\sso\Client();
|
||||||
|
|
||||||
register_activation_hook( __FILE__, array( $discourse, 'install' ) );
|
register_activation_hook( __FILE__, array( $discourse, 'install' ) );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue