Skip to content
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

Update quickbooks.php #1360

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions public_html/wp-content/mu-plugins/quickbooks/quickbooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@
require_once PLUGIN_DIR . '/includes/admin.php';

add_filter( 'wordcamp_qbo_client_config', __NAMESPACE__ . '\set_client_config' );
add_action( 'init', __NAMESPACE__ . '\check_qbo_connection_cron' );
add_action( 'check_qbo_connection_action', __NAMESPACE__ . '\check_qbo_connection' );

/**
* Setup hourly qbo connection task.
*/
function check_qbo_connection_cron() {
if ( ! wp_next_scheduled( 'check_qbo_connection_action' ) ) {
wp_schedule_event( time(), 'hourly', 'check_qbo_connection_action' );
}
}

/**
* Monitors the Quickbooks connection, and sends message to Slack if not connected.
*/
function check_qbo_connection() {
$client = get_client();

if ( ! $client->has_valid_token() && function_exists( 'slack_dm' ) ) {
slack_dm( 'QBO token invalid. Visit <https://wordcamp.org/wp-admin/network/settings.php> to check connection.', 'dotorg' );
}
}

/**
* Filter: Add client configuration details depending on the environment.
Expand Down
Loading