verify_license_key($key, 'slm_activate');
if (!empty($key_response) && $key_response->result == 'success') {
update_option('berqwp_license_key', $key);
if (is_admin()) {
?>
result == 'error') {
$error = $key_response->message;
if (is_admin()) {
?>
activate_license_from_multi_site();
}
if (is_admin()) {
$this->berq_post_types();
}
if (get_option('berqwp_disable_emojis') == 1) {
$this->disable_emoji();
}
if (is_admin() && !empty(get_option('berqwp_license_key'))) {
$license_key = get_option('berqwp_license_key');
$key_response = $this->verify_license_key($license_key);
if (!empty($key_response) && $key_response->result == 'success' && $key_response->status == 'active') {
$this->is_key_verified = true;
$this->key_response = $key_response;
} else {
$this->is_key_verified = false;
}
}
// redirect to berqwp admin page
if (get_transient('berqwp_redirect')) {
delete_transient('berqwp_redirect');
// Set the URL to redirect to after activation
$redirect_url = admin_url('admin.php?page=berqwp');
// Redirect after activation
wp_redirect($redirect_url);
// Make sure to exit after the redirect
exit;
}
// Deactivate conflicting plugins
if (is_admin() && isset($_POST['berqwp_plugins_deactivate']) && wp_verify_nonce($_POST['berqwp_plugins_deactivate'], 'berqwp_plugins_deactivate')) {
foreach ($this->conflicting_plugins as $plugin) {
// Deactivate each conflicting plugin
if (is_plugin_active($plugin)) {
deactivate_plugins($plugin);
}
}
header('location: ' . esc_url(get_site_url() . add_query_arg($_GET)));
exit;
}
}
function save_settings()
{
require_once optifer_PATH . '/admin/save-settings.php';
}
function berqwp_cleanup_completed_and_failed_tasks()
{
if (!get_transient('berqwp_action_cleanup')) {
set_transient('berqwp_action_cleanup', true, 60 * 60 * 10);
global $berq_log;
$berq_log->info("* * * * * * * * *");
$berq_log->info("* Task Cleanup");
$berq_log->info("* * * * * * * * *");
global $wpdb;
// Define the hook name
$hook_name = 'warmup_cache_by_slug';
// Count the number of completed and failed actions for the given hook
$count = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = %s AND (status = 'complete' OR status = 'failed')",
$hook_name
)
);
$berq_log->info("Completed + failed task count: $count");
// Check if the count exceeds 50
if ($count > 50) {
$delete_count = $count - 50; // Calculate how many rows to delete
$berq_log->info("Deleting last $delete_count");
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = %s AND (status = 'complete' OR status = 'failed') ORDER BY scheduled_date_gmt ASC LIMIT %d",
$hook_name,
$delete_count
)
);
}
// clear logs, keep the last 1000
if ( class_exists( 'ActionScheduler_QueueRunner' ) ) {
global $wpdb;
$table_name = $wpdb->prefix . 'actionscheduler_logs';
// Count the total number of logs
$total_logs = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
// Set the limit to keep the latest 1000 logs
$limit = max( 0, $total_logs - 1000 );
// Delete logs beyond the limit
$wpdb->query( "DELETE FROM $table_name WHERE log_date_gmt < (SELECT log_date_gmt FROM $table_name ORDER BY log_date_gmt DESC LIMIT 1 OFFSET $limit)" );
}
$berq_log->info("* * * * * * * * * *");
$berq_log->info("* Task Cleanup End");
$berq_log->info("* * * * * * * * * *");
}
}
function notices()
{
if (isset($_GET['dismiss_feedback'])) {
set_transient( 'bqwp_hide_feedback_notice', true, DAY_IN_SECONDS * 2 );
}
// Check rest api
$check_rest = bwp_check_rest_api();
if ( $check_rest['status'] == 'error' ) {
?>
Error: The WordPress REST API is disabled. BerqWP plugin will not function correctly without the
REST API. Please enable the REST API for full functionality.
is_key_verified) {
$notice = '
';
$notice .= '
';
$notice .= __('🎉 Loving BerqWP\'s performance? 🚀 Show some love and help us grow 👉 - Rate BerqWP Plugin. Your insights shape our journey.', 'searchpro');
$notice .= 'Dismiss';
$notice .= '
';
$notice .= '
';
echo wp_kses_post($notice);
}
if (berq_is_localhost()) {
?>
Localhost Detected: BerqWP doesn't operate in a localhost environment.", 'searchpro'));
?>
conflicting_plugins as $plugin) {
if (is_plugin_active($plugin)) {
$plugins_to_deactivate .= '
' . basename(dirname($plugin)) . '
';
}
}
if (!empty($plugins_to_deactivate)) {
echo "";
echo '
';
echo wp_kses_post(__('
BerqWP Plugin Conflict: The following plugins have a same nature as BerqWP plugin. Having multiple plugins of the same type can cause unexpected results.