10, 'httpversion' => '1.0', 'sslverify' => true, ); $response = wp_remote_get( $fetch_plugins_url, $args ); if ( ! is_wp_error( $response && is_array( $response ) ) ) { $body = wp_remote_retrieve_body( $response ); $body = json_decode( $body ); if ( ! empty( $body ) && $body->success ) { $get_plugins = $body->data; } else { error_log( print_r( $body, true ) ); } } else { $errorMessage = '(' . wp_remote_retrieve_response_code( $response ) . ') ' . wp_remote_retrieve_response_message( $response ); error_log( 'Error in forms protection notice -->' . print_r( $errorMessage, true ) ); } if ( is_array( $get_plugins ) && ! empty( $get_plugins ) ) { set_site_transient( 'onecom_fetched_plugins', $get_plugins, 10 * HOUR_IN_SECONDS ); return $get_plugins; } } } if ( ! function_exists( 'onecom_spam_protection_notice' ) ) { function onecom_spam_protection_notice() { $screen = get_current_screen(); $screens = array( 'themes', 'plugins', 'options-general', 'users', 'edit-comments', ); // return if screen not allowed or user has not the capability if ( ! in_array( $screen->base, $screens ) || ! current_user_can( 'deactivate_plugin' ) ) { return false; } $features = oc_set_premi_flag(); // if spam protection plugin is active and the user is having mWP package then return if ( isset( $features['data'] ) && ! empty( $features['data'] ) && is_plugin_active( SP_PLUGIN_SLUG ) && in_array( 'MWP_ADDON', $features['data'] ) ) { return false; } // get active plugins $act_plugins = get_site_option( 'active_plugins' ); $display_notice = true; $activated_plugins_slug = array(); foreach ( $act_plugins as $plg ) { $activated_plugins_slug[] = explode( '/', $plg )[0]; } $get_plugins = get_site_transient( 'onecom_fetched_plugins' ); if ( ! $get_plugins ) { $get_plugins = (array) onecom_fetch_antispam_plugins(); } $active_spam_plugin = array_intersect( $get_plugins, $activated_plugins_slug ); if ( get_site_option( 'dismiss-oc-spam-notice' ) && ( get_site_option( 'dismiss-oc-spam-notice' ) > strtotime( '-60 days' ) ) ) { $display_notice = false; } if ( $active_spam_plugin || ! $display_notice ) { return false; } else { // Display Spam protection warning $link = admin_url( 'plugin-install.php?s=anti-spam&tab=search&type=term' ); if ( ! ismWP() ) { $text = __( 'Your website forms are not protected against spam and abuse. We recommend installing a captcha or spam protection plugin. View recommended plugins ', 'onecom-wp' ); } elseif ( ismWP() && ! file_exists( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . SP_PLUGIN_SLUG ) ) { $text = __( 'Your website forms are not protected against spam and abuse. We recommend installing spam protection plugin.', 'onecom-wp' ) . '
'; } else { $text = __( 'Your website forms are not protected against spam and abuse. We recommend installing spam protection plugin.', 'onecom-wp' ) . ''; } echo "{$text}