-
Notifications
You must be signed in to change notification settings - Fork 8
New. Settings. Getting apikey wizard. #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
92af28d
apbct-wisard
svfcode 2b607db
upd flow
svfcode d1353bc
fix phpcs
svfcode 6fd3873
fix brace
svfcode 3235815
improve building
svfcode 0722b9c
fix eslint
svfcode dac7cf3
remove duplicate link
svfcode 3cce5d4
upd text an links
svfcode 0c2b16c
upd wizard key check
svfcode 5a24e40
Merge branch 'dev' into wizard-init
svfcode 1eaae5c
upd unittest
svfcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,144 @@ | ||
| <?php | ||
|
|
||
| use Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnvironmentHandler; | ||
| use Cleantalk\ApbctWP\AJAXService; | ||
|
|
||
| // Prevent direct call | ||
| /** @psalm-suppress ParadoxicalCondition */ | ||
| if ( ! defined('ABSPATH') ) { | ||
| die('Not allowed!'); | ||
| } | ||
|
|
||
| add_action('wp_ajax_apbct_react_access_key_check', 'apbct_react_access_key_check'); | ||
| add_action('wp_ajax_apbct_react_sfw_update', 'apbct_react_sfw_update'); | ||
| add_action('wp_ajax_apbct_react_send_feedback', 'apbct_react_send_feedback'); | ||
| add_action('wp_ajax_apbct_react_brief_data', 'apbct_react_brief_data'); | ||
| add_action('wp_ajax_apbct_react_run_adjusting_env', 'apbct_react_run_adjusting_env'); | ||
| add_action('wp_ajax_apbct_react_sync_end', 'apbct_react_sync_end'); | ||
|
|
||
| /** | ||
| * @param bool $success | ||
| */ | ||
| function apbct_react_sync_json_response($success = true) | ||
| { | ||
| wp_send_json(array( | ||
| 'error' => false, | ||
| 'message' => '', | ||
| 'success' => $success, | ||
| )); | ||
| } | ||
|
|
||
| function apbct_react_access_key_check() | ||
| { | ||
| global $apbct; | ||
|
|
||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| $apbct->errorDeleteAll(true); | ||
|
|
||
| $account_is_ok = (bool) ct_account_status_check($apbct->settings['apikey']); | ||
|
|
||
| if ( $account_is_ok ) { | ||
| $apbct->data['key_is_ok'] = true; | ||
| $apbct->errorDelete('key_invalid key_get', 'save'); | ||
| } else { | ||
| $apbct->data['key_is_ok'] = false; | ||
| $apbct->errorAdd( | ||
| 'key_invalid', | ||
| __('Testing is failed. Please check the Access key.', 'cleantalk-spam-protect') | ||
| ); | ||
| } | ||
|
|
||
| $apbct->data['key_changed'] = false; | ||
| $apbct->saveData(); | ||
|
|
||
| apbct_react_sync_json_response($account_is_ok); | ||
| } | ||
|
|
||
| function apbct_react_sfw_update() | ||
| { | ||
| global $apbct; | ||
|
|
||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| if ( (int) $apbct->settings['sfw__enabled'] === 1 ) { | ||
| $result = apbct_sfw_update__init(5); | ||
| if ( ! empty($result['error']) ) { | ||
| $apbct->errorAdd('sfw_update', $result['error']); | ||
| } | ||
|
|
||
| $result = ct_sfw_send_logs($apbct->settings['apikey']); | ||
| if ( ! empty($result['error']) ) { | ||
| $apbct->errorAdd('sfw_send_logs', $result['error']); | ||
| } | ||
| } | ||
|
|
||
| $apbct->saveData(); | ||
|
|
||
| apbct_react_sync_json_response(true); | ||
| } | ||
|
|
||
| function apbct_react_send_feedback() | ||
| { | ||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| ct_send_feedback('0:' . APBCT_AGENT); | ||
|
|
||
| apbct_react_sync_json_response(true); | ||
| } | ||
|
|
||
| function apbct_react_brief_data() | ||
| { | ||
| global $apbct; | ||
|
|
||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| cleantalk_get_brief_data($apbct->settings['apikey']); | ||
|
|
||
| apbct_react_sync_json_response(true); | ||
| } | ||
|
|
||
| function apbct_react_run_adjusting_env() | ||
| { | ||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| $adjust = new AdjustToEnvironmentHandler(); | ||
| $adjust->handle(); | ||
|
|
||
| apbct_react_sync_json_response(true); | ||
| } | ||
|
|
||
| function apbct_react_sync_end() | ||
| { | ||
| global $apbct; | ||
|
|
||
| AJAXService::checkAdminNonce(); | ||
|
|
||
| if ( ! current_user_can('activate_plugins') ) { | ||
| apbct_react_sync_json_response(false); | ||
| } | ||
|
|
||
| $apbct->saveData(); | ||
|
|
||
| apbct_react_sync_json_response(true); | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.