Skip to content

Commit ea2a4a2

Browse files
authored
Merge pull request #18 from NewPath-Consulting/fix-deactivation
Fix deactivation when WAP is deactivated
2 parents 87ffcac + cc8e656 commit ea2a4a2

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

classes/WaApiClient.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
namespace PO\classes;
33

4-
use WAWP\DataEncryption;
5-
$path = wp_normalize_path(ABSPATH . 'wp-content/plugins/Wild-Apricot-Press/src/DataEncryption.php');
4+
use WAWP\Data_Encryption;
5+
$path = wp_normalize_path(ABSPATH . 'wp-content/plugins/Wild-Apricot-Press/src/class-data-encryption.php');
66

77
require_once ($path);
88
// From:
@@ -24,13 +24,14 @@ class WaApiClient
2424
// $this->initTokenByApiKey($apiKey);
2525
// }
2626

27+
// TODO: try/catch
2728
public function __construct() {
2829
$apiKey = $this->getApiKey();
2930
$this->initTokenByApiKey($apiKey);
3031
}
3132

3233
private function getApiKey() {
33-
$dataEncryption = new DataEncryption();
34+
$dataEncryption = new Data_Encryption();
3435
$credentials = get_option('wawp_wal_name');
3536
if (empty($credentials)) {
3637
throw new \Exception("WildApricot API Keys not configured.");
@@ -123,7 +124,7 @@ private function getAuthTokenByAdminCredentials($login, $password)
123124
urlencode($this->tokenScope)
124125
);
125126

126-
throw new Exception(
127+
throw new \Exception(
127128
'Change clientId and clientSecret to values specific for your authorized application. For details see: https://help.wildapricot.com/display/DOC/Authorizing+external+applications'
128129
);
129130
// $clientId = 'SamplePhpApplication';
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
new ContactsAPI();
3434
new UserProfileShortcode();
3535

36-
const WAWP_MEMDIR_SLUG = 'wawp-addon-member-directory';
36+
const WAWP_MEMDIR_SLUG = 'wap-addon-member-directory';
3737
const WAWP_MEMDIR_SHOW_NOTICE_ACTIVATION = 'show_notice_activation_' . WAWP_MEMDIR_SLUG;
3838
const WAWP_MEMDIR_LICENSE_CHECK = 'license-check-' . WAWP_MEMDIR_SLUG;
3939
const WAWP_MEMDIR_NAME = 'WAP Member Directory Addon';
@@ -46,7 +46,7 @@
4646
add_action( 'init', 'create_block_wawp_addon_member_directory_block_init' );
4747
function create_block_wawp_addon_member_directory_block_init() {
4848
if (!class_exists('WAWP\Addon')) {
49-
wawp_memdir_not_loaded_die();
49+
add_action('admin_init', 'wawp_memdir_not_loaded_die');
5050
return;
5151
}
5252
$license_valid = WAWP\Addon::instance()::has_valid_license(WAWP_MEMDIR_SLUG);
@@ -74,7 +74,7 @@ function add_action_links($links) {
7474
* Error message for if WAWP is not installed or activated.
7575
*/
7676
function wawp_memdir_not_loaded_notice_msg() {
77-
echo "<div class='error'><p><strong>";
77+
echo "<div class='notice notice-error'><p><strong>";
7878
echo WAWP_MEMDIR_NAME . '</strong> requires that Wild Apricot for Wordpress is installed and activated.</p></div>';
7979
unset($_GET['activate']);
8080
return;
@@ -107,16 +107,15 @@ function wawp_memdir_not_loaded_die() {
107107
));
108108
}
109109

110-
111110
/**
112111
* Activation function.
113-
* Checks if WAWP is loaded. Deactivate `if not.
112+
* Checks if WAWP is loaded. Deactivate if not.
114113
* Calls Addon::activate() function which checks for a license key and sets appropriate flags.
115114
*/
116115
register_activation_hook(plugin_basename(__FILE__), 'wawp_memdir_activate');
117116
function wawp_memdir_activate() {
118117
if (!class_exists('WAWP\Addon')) {
119-
wawp_not_loaded_die();
118+
add_action('admin_init', 'wawp_memdir_not_loaded_die');
120119
return;
121120
}
122121

0 commit comments

Comments
 (0)