| Server IP : 8.134.250.228 / Your IP : 216.73.217.39 Web Server : Apache System : Linux iZ7xv33p9e9ivk7yhmj7ibZ 5.10.134-18.al8.x86_64 #1 SMP Fri Dec 13 16:56:53 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.gobluemade.com/wp-content/plugins/wpforms-lite/src/Integrations/AI/ |
Upload File : |
<?php
namespace WPForms\Integrations\AI;
/**
* AI features related helper methods.
*
* @since 1.9.1
*/
class Helpers {
/**
* Key for a state whether integration is disabled on the Settings > Misc admin page.
*
* @since 1.9.1
*/
public const DISABLE_KEY = 'ai-feature-disabled';
/**
* Key for a state whether integration is used (or has been used).
* There is no UI/UX for it, and it's used for internal purposes.
*
* @since 1.9.1
*/
private const USE_KEY = 'ai-feature-used';
/**
* Determine whether integration is disabled.
*
* @since 1.9.1
*
* @return bool
*/
public static function is_disabled(): bool {
return self::is_disabled_by_rule() || wpforms_setting( self::DISABLE_KEY );
}
/**
* Determine whether integration is used.
*
* @since 1.9.1
*
* @return bool
*/
public static function is_used(): bool {
return (bool) wpforms_setting( self::USE_KEY );
}
/**
* Mark integration as used.
*
* @since 1.9.1
*/
public static function set_ai_used() {
if ( self::is_used() ) {
return;
}
$settings = (array) get_option( 'wpforms_settings', [] );
$settings[ self::USE_KEY ] = true;
update_option( 'wpforms_settings', $settings );
}
/**
* Determine whether integration is disabled through constant or filter.
*
* @since 1.9.1
*
* @return bool
* @noinspection PhpUndefinedConstantInspection
*/
public static function is_disabled_by_rule(): bool {
$is_disabled = defined( 'WPFORMS_DISABLE_AI_FEATURES' ) && WPFORMS_DISABLE_AI_FEATURES;
/**
* Allow modifying whether AI integration is disabled in WPForms.
*
* @since 1.9.1
*
* @param bool $is_disabled True if AI integration is disabled. Default is false.
*/
return (bool) apply_filters( 'wpforms_disable_ai_features', $is_disabled ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
}
/**
* Log an error record.
*
* @since 1.9.1
*
* @param string $message Error message.
* @param string $endpoint Endpoint.
* @param array $args Arguments.
*/
public static function log_error( string $message, string $endpoint, array $args ) {
wpforms_log(
'AI Integration Error',
[
'error' => $message,
'endpoint' => $endpoint,
'args' => $args,
],
[
'type' => [ 'ai', 'error' ],
]
);
}
/**
* Get the license type.
*
* @since 1.9.4
*
* @return string
*/
public static function get_license_type(): string {
$license = (array) get_option( 'wpforms_license', [] );
return $license['type'] ?? '';
}
/**
* Determine whether a license key is active.
*
* @since 1.9.4
*
* @return bool
*/
public static function is_license_active(): bool {
$license = (array) get_option( 'wpforms_license', [] );
return ! empty( wpforms_get_license_key() ) &&
empty( $license['is_expired'] ) &&
empty( $license['is_disabled'] ) &&
empty( $license['is_invalid'] );
}
}