- Implement Groq_AI_Compatibility_Service to manage WooCommerce dependency and admin notices. - Create Groq_AI_Log_Scheduler for scheduled log cleanup based on settings. - Develop Groq_AI_Model_Service for model selection and caching. - Add language translations in POT file for Dutch. - Set up PHPUnit configuration and bootstrap for testing. - Implement unit tests for model exclusions, provider request building, settings management, and term saving functionality.
59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
class Groq_AI_Compatibility_Service {
|
|
/** @var bool */
|
|
private $missing_wc_notice = false;
|
|
|
|
public function maybe_deactivate_if_woocommerce_missing() {
|
|
if ( $this->is_woocommerce_active() ) {
|
|
return;
|
|
}
|
|
|
|
if ( ! function_exists( 'deactivate_plugins' ) ) {
|
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
}
|
|
|
|
deactivate_plugins( plugin_basename( GROQ_AI_PRODUCT_TEXT_FILE ) );
|
|
$this->missing_wc_notice = true;
|
|
|
|
add_action( 'admin_notices', [ $this, 'render_missing_wc_notice' ] );
|
|
}
|
|
|
|
public function render_missing_wc_notice() {
|
|
if ( ! $this->missing_wc_notice ) {
|
|
return;
|
|
}
|
|
?>
|
|
<div class="notice notice-error">
|
|
<p>
|
|
<?php esc_html_e( 'SitiAI Product Teksten vereist WooCommerce en is gedeactiveerd omdat WooCommerce niet actief is.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
|
</p>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
public function is_rankmath_active() {
|
|
if ( class_exists( 'RankMath' ) ) {
|
|
return true;
|
|
}
|
|
|
|
if ( ! function_exists( 'is_plugin_active' ) ) {
|
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
}
|
|
|
|
return function_exists( 'is_plugin_active' ) && is_plugin_active( 'seo-by-rank-math/rank-math.php' );
|
|
}
|
|
|
|
public function is_woocommerce_active() {
|
|
if ( class_exists( 'WooCommerce' ) ) {
|
|
return true;
|
|
}
|
|
|
|
if ( ! function_exists( 'is_plugin_active' ) ) {
|
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
}
|
|
|
|
return function_exists( 'is_plugin_active' ) && is_plugin_active( 'woocommerce/woocommerce.php' );
|
|
}
|
|
}
|