-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stiofan
committed
Feb 18, 2020
1 parent
e240886
commit 735263a
Showing
13 changed files
with
2,158 additions
and
964 deletions.
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,14 @@ | ||
# Items to ignore when downloading release | ||
|
||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.scrutinizer.yml export-ignore | ||
composer.json export-ignore | ||
composer.lock export-ignore | ||
CONTRIBUTING.md export-ignore | ||
phpunit.xml export-ignore | ||
README.md export-ignore | ||
/tests/ export-ignore | ||
/.idea/ export-ignore | ||
/.github/ export-ignore | ||
/.wordpress-org/ export-ignore |
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,5 @@ | ||
.idea/ | ||
|
||
# Composer | ||
composer.phar | ||
composer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# wp-service-client | ||
WP Service Client class | ||
# ayecode-connect | ||
AyeCode Connect Client class |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,126 @@ | ||
/** | ||
* Request to enable update notifications. | ||
* | ||
* @param $input | ||
* @param $state | ||
*/ | ||
function ayecode_connect_updates($input,$state){ | ||
jQuery.ajax({ | ||
url: ajaxurl, | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
action: 'ayecode_connect_updates', | ||
security: ayecode_connect.nonce, | ||
state: $state | ||
}, | ||
beforeSend: function() { | ||
jQuery($input).prop('disabled', true); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
success: function(data, textStatus, xhr) { | ||
console.log(data); | ||
if(data.success){ | ||
// yay | ||
// maybe switch off licence sync also | ||
if (!$state && jQuery('#ac-setting-licences').is(':checked')) { | ||
jQuery('#ac-setting-licences').trigger('click'); | ||
} | ||
|
||
}else{ | ||
// oh dear, toggle it back | ||
jQuery($input).prop('checked', !$state); | ||
alert(ayecode_connect.error_msg); | ||
} | ||
jQuery($input).prop('disabled', false); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
error: function(xhr, textStatus, errorThrown) { | ||
alert(textStatus); | ||
jQuery($input).prop('disabled', false); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
} | ||
}); // end of ajax | ||
} | ||
|
||
/** | ||
* Request to disconnect site from AyeCode Connect. | ||
* | ||
* @param $input | ||
*/ | ||
function ayecode_connect_disconnect($input){ | ||
if(window.confirm(ayecode_connect.disconnect_msg)){ | ||
jQuery.ajax({ | ||
url: ajaxurl, | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
action: 'ayecode_connect_disconnect', | ||
security: ayecode_connect.nonce | ||
}, | ||
beforeSend: function() { | ||
jQuery($input).prop('disabled', true); | ||
jQuery($input).closest('p').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
success: function(data, textStatus, xhr) { | ||
console.log(data); | ||
if(data.success){ | ||
location.reload(); | ||
}else{ | ||
// oh dear | ||
alert(ayecode_connect.error_msg); | ||
} | ||
jQuery($input).prop('disabled', false); | ||
jQuery($input).closest('p').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
error: function(xhr, textStatus, errorThrown) { | ||
alert(textStatus); | ||
} | ||
}); // end of ajax | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Request to enable licence sync. | ||
* | ||
* @param $input | ||
* @param $state | ||
*/ | ||
function ayecode_connect_licences($input,$state){ | ||
jQuery.ajax({ | ||
url: ajaxurl, | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
action: 'ayecode_connect_licences', | ||
security: ayecode_connect.nonce, | ||
state: $state | ||
}, | ||
beforeSend: function() { | ||
jQuery($input).prop('disabled', true); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
success: function(data, textStatus, xhr) { | ||
console.log(data); | ||
if(data.success){ | ||
// yay | ||
}else if(data.data){ | ||
// oh dear, toggle it back | ||
jQuery($input).prop('checked', !$state); | ||
alert(data.data); | ||
}else{ | ||
// oh dear, toggle it back | ||
jQuery($input).prop('checked', !$state); | ||
alert(ayecode_connect.error_msg); | ||
} | ||
jQuery($input).prop('disabled', false); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
}, | ||
error: function(xhr, textStatus, errorThrown) { | ||
alert(textStatus); | ||
jQuery($input).prop('disabled', false); | ||
jQuery($input).closest('li').find('.spinner-border').toggleClass('d-none'); | ||
} | ||
}); // end of ajax | ||
} |
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,74 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin Name: AyeCode Connect | ||
* Plugin URI: https://ayecode.io/ | ||
* Description: A service plugin letting users connect AyeCode Services to their site. | ||
* Version: 1.0.0 | ||
* Author: AyeCode | ||
* Author URI: https://ayecode.io/ | ||
* Requires at least: 4.7 | ||
* Tested up to: 5.3 | ||
* | ||
* Text Domain: ayecode-connect | ||
* Domain Path: /languages/ | ||
* | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
if ( !defined( 'AYECODE_CONNECT_VERSION' ) ) { | ||
define( 'AYECODE_CONNECT_VERSION', '1.0.0' ); | ||
} | ||
|
||
add_action( 'plugins_loaded', 'ayecode_connect' ); | ||
|
||
/** | ||
* Sets up the client | ||
*/ | ||
function ayecode_connect() { | ||
|
||
//Include the client connection class | ||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ayecode-connect.php'; | ||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ayecode-connect-settings.php'; | ||
|
||
//Prepare client args | ||
$args = ayecode_connect_args(); | ||
|
||
$client = new AyeCode_Connect( $args ); | ||
|
||
//Call the init method to register routes. This should be called exactly once per client (Preferably before the init hook). | ||
$client->init(); | ||
|
||
} | ||
|
||
/** | ||
* The AyeCode Connect arguments. | ||
* | ||
* @return array | ||
*/ | ||
function ayecode_connect_args(){ | ||
$base_url = 'https://ayecode.io'; | ||
return array( | ||
'remote_url' => $base_url, //URL to the WP site containing the WP_Service_Provider class | ||
'connection_url' => $base_url.'/connect', //This should be a custom page the authinticates a user the calls the WP_Service_Provider::connect_site() method | ||
'api_url' => $base_url.'/wp-json/', //Might be different for you | ||
'api_namespace' => 'ayecode/v1', | ||
'local_api_namespace' => 'ayecode-connect/v1', //Should be unique for each client implementation | ||
'prefix' => 'ayecode_connect', //A unique prefix for things (accepts alphanumerics and underscores). Each client on a given site should have it's own unique prefix | ||
'textdomain' => 'ayecode-connect', | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Remove wp cron on deactivation if set. | ||
*/ | ||
register_deactivation_hook( __FILE__, 'ayecode_connect_deactivation' ); | ||
function ayecode_connect_deactivation() { | ||
$args = ayecode_connect_args(); | ||
$prefix = $args['prefix']; | ||
wp_clear_scheduled_hook( $prefix.'_callback' ); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.