-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
29 changed files
with
3,075 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
# WordPress Coding Standards | ||
# http://make.wordpress.org/core/handbook/coding-standards/ | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{*.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.txt] | ||
end_of_line = crlf | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vendor/bin | ||
vendor/dealerdirect | ||
vendor/squizlabs | ||
vendor/wp-coding-standards | ||
node_modules | ||
*.code-workspace | ||
*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "michaelbourne/gravity-forms-zoom-webinar-registration", | ||
"description": "Register attendees in your Zoom Webinar through a Gravity Form", | ||
"version": "0.0.1", | ||
"license": "GPL-3.0-or-later", | ||
"authors": [{ | ||
"name": "Michael Bourne", | ||
"email": "[email protected]", | ||
"homepage": "https://5forests.com" | ||
}], | ||
"support": { | ||
"issues": "https://github.com/michaelbourne/gravity-forms-zoom-webinar-registration/issues" | ||
}, | ||
"require-dev": { | ||
"squizlabs/php_codesniffer": "^3.2.3", | ||
"wp-coding-standards/wpcs": "^0.14.1", | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" | ||
}, | ||
"require": { | ||
"firebase/php-jwt": "^5.2.0" | ||
}, | ||
"archive": { | ||
"exclude": ["/vendor/wp-coding-standards", "/vendor/bin", "/vendor/squizlabs", "/vendor/dealerdirect"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Register attendees in your Zoom Webinar through a Gravity Form | ||
* | ||
* @package Gravity Forms Zoom Webinar Registration | ||
* @author Michael Bourne | ||
* @license GPL3 | ||
* @link https://5forests.com | ||
* @since 1.0.0 | ||
* | ||
* @wordpress-plugin | ||
* Plugin Name: Gravity Forms Zoom Webinar Registration | ||
* Description: Register attendees in your Zoom Webinar through a Gravity Form | ||
* Version: 1.0.0 | ||
* Author: Michael Bourne | ||
* Author URI: https://5forests.com | ||
* Requires at least: 5.3 | ||
* Tested up to: 5.3 | ||
* Stable tag: 1.0.0 | ||
* Requires PHP: 7.2 | ||
* License: GPL3 | ||
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* Text Domain: gravity-zwr | ||
* Domain Path: /languages | ||
* | ||
* Created Date: Friday March 25th 2020 | ||
* Author: Michael Bourne | ||
* ----- | ||
* Last Modified: Wednesday, March 25th 2020, 7:00:11 pm | ||
* Modified By: Michael Bourne | ||
* ----- | ||
* Copyright (C) 2020 Michael Bourne | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
return; | ||
} | ||
|
||
defined( 'GRAVITYZWR_ROOT' ) || define( 'GRAVITYZWR_ROOT', plugin_dir_path( __FILE__ ) ); | ||
defined( 'GRAVITYZWR_URI' ) || define( 'GRAVITYZWR_URI', plugin_dir_url( __FILE__ ) ); | ||
defined( 'GRAVITYZWR_VERSION' ) || define( 'GRAVITYZWR_VERSION', '1.0.0' ); | ||
defined( 'GRAVITYZWR_ZOOMAPIURL' ) || define( 'GRAVITYZWR_ZOOMAPIURL', 'https://api.zoom.us/v2' ); | ||
|
||
add_action( 'gform_loaded', array( 'GravityZWR_Bootstrap', 'load' ), 5 ); | ||
|
||
/** | ||
* GravityZWR_Bootstrap Class | ||
*/ | ||
class GravityZWR_Bootstrap { | ||
|
||
public static function load() { | ||
|
||
if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) { | ||
return; | ||
} | ||
|
||
// load vendor files. | ||
require_once GRAVITYZWR_ROOT . 'vendor/autoload.php'; | ||
|
||
// Load API Helper classes. | ||
require_once GRAVITYZWR_ROOT . 'includes/class-gravityzwr-wordpressremote.php'; | ||
require_once GRAVITYZWR_ROOT . 'includes/class-gravityzwr-zoomapi.php'; | ||
|
||
// Load main plugin class. | ||
require_once GRAVITYZWR_ROOT . 'includes/class-gravityzwr.php'; | ||
|
||
GFAddOn::register( 'GravityZWR' ); | ||
} | ||
|
||
} | ||
|
||
function gf_simple_addon() { | ||
return GravityZWR::get_instance(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<?php | ||
/** | ||
* GravityZWR_WordPressRemote Class | ||
* | ||
* General wp_remote_request wrapper for API interfacing | ||
* | ||
* @package Gravity Forms Zoom Webinar Registration | ||
* @author Michael Bourne | ||
* @license GPL3 | ||
* @link https://5forests.com | ||
* @since 1.0.0 | ||
* | ||
* Created Date: Friday March 25th 2020 | ||
* Author: Michael Bourne | ||
* ----- | ||
* Last Modified: Wednesday, March 25th 2020, 3:41:27 pm | ||
* Modified By: Michael Bourne | ||
* ----- | ||
* Copyright (C) 2020 Michael Bourne | ||
*/ | ||
|
||
/** | ||
* GravityZWR_WordPressRemote Class | ||
*/ | ||
class GravityZWR_WordPressRemote { | ||
|
||
|
||
/** | ||
* Request method | ||
* | ||
* @var string | ||
*/ | ||
protected $method = ''; | ||
|
||
/** | ||
* URL where to send the request | ||
* | ||
* @var string | ||
*/ | ||
protected $url = ''; | ||
|
||
/** | ||
* Arguments applied to the request | ||
* | ||
* @var array | ||
*/ | ||
protected $arguments = array(); | ||
|
||
/** | ||
* Request response | ||
* | ||
* @var [type] | ||
*/ | ||
protected $response; | ||
|
||
/** | ||
* Body of the response | ||
* | ||
* @var [type] | ||
*/ | ||
protected $body; | ||
|
||
/** | ||
* Headers of the response | ||
* | ||
* @var [type] | ||
*/ | ||
protected $headers; | ||
|
||
/** | ||
* Response Code from the Request | ||
* | ||
* @var [type] | ||
*/ | ||
protected $response_code; | ||
|
||
/** | ||
* Response Message from the Request | ||
* | ||
* @var [type] | ||
*/ | ||
protected $response_message; | ||
|
||
/** | ||
* Creating the object | ||
* | ||
* @param string $url Request URL. | ||
* @param array $arguments Request Arguements. | ||
* @param string $method Request Method. | ||
*/ | ||
public function __construct( $url, $arguments = array(), $method = 'get' ) { | ||
$this->method = strtoupper( $method ); | ||
$this->url = $url; | ||
$this->arguments = $arguments; | ||
$this->arguments['method'] = $this->method; | ||
} | ||
|
||
/** | ||
* Running the request and setting all the attributes | ||
* | ||
* @return void | ||
*/ | ||
public function run() { | ||
$this->response = wp_remote_request( $this->url, $this->arguments ); | ||
$this->body = wp_remote_retrieve_body( $this->response ); | ||
$this->headers = wp_remote_retrieve_headers( $this->response ); | ||
$this->response_code = wp_remote_retrieve_response_code( $this->response ); | ||
$this->response_message = wp_remote_retrieve_response_message( $this->response ); | ||
} | ||
|
||
/** | ||
* Get the body | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_body() { | ||
return $this->body; | ||
} | ||
|
||
/** | ||
* Get the headers | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_headers() { | ||
return $this->headers; | ||
} | ||
|
||
/** | ||
* Response Code | ||
* | ||
* @return string | ||
*/ | ||
public function get_response_code() { | ||
return $this->response_code; | ||
} | ||
|
||
/** | ||
* Get the response message | ||
* | ||
* @return string | ||
*/ | ||
public function get_response_message() { | ||
return $this->response_message; | ||
} | ||
|
||
/** | ||
* Get the whole response | ||
* | ||
* @return mixed | ||
*/ | ||
public function get_response() { | ||
return $this->response; | ||
} | ||
|
||
/** | ||
* If the request was a success | ||
* | ||
* @return mixed | ||
*/ | ||
public function is_success() { | ||
// phpcs:ignore | ||
if ( '200' == (string) $this->response_code ) { | ||
return true; | ||
} | ||
// phpcs:ignore | ||
if ( '201' == (string) $this->response_code ) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* GravityZWR_ZOOMAPI Class. | ||
* | ||
* Extension class to interface Zoom with our API wrapper with proper headers | ||
* | ||
* @package Gravity Forms Zoom Webinar Registration | ||
* @author Michael Bourne | ||
* @license GPL3 | ||
* @link https://5forests.com | ||
* @since 1.0.0 | ||
* | ||
* Created Date: Friday March 25th 2020 | ||
* Author: Michael Bourne | ||
* ----- | ||
* Last Modified: Wednesday, March 25th 2020, 7:13:03 pm | ||
* Modified By: Michael Bourne | ||
* ----- | ||
* Copyright (C) 2020 Michael Bourne | ||
*/ | ||
|
||
use \Firebase\JWT\JWT; | ||
|
||
/** | ||
* GravityZWR_ZOOMAPI Class | ||
*/ | ||
class GravityZWR_ZOOMAPI extends GravityZWR_WordPressRemote { | ||
/** | ||
* Prepare the headers for JSON request and generate a JWT. | ||
*/ | ||
public function run() { | ||
$options = GravityZWR::get_zoom_settings_keys(); | ||
$key = $options['zoomapikey']; | ||
$secret = $options['zoomapisecret']; | ||
$token = array( | ||
'iss' => $key, | ||
'exp' => time() + 60, | ||
); | ||
|
||
$this->arguments['headers']['Authorization'] = 'Bearer ' . JWT::encode( $token, $secret ); | ||
$this->arguments['headers']['Content-type'] = 'application/json'; | ||
parent::run(); | ||
} | ||
|
||
} |
Oops, something went wrong.