| @@ -4,10 +4,8 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -use Automattic\Jetpack\Connection\Client; | |
| 9 | -use Automattic\Jetpack\Connection\Manager as Connection_Manager; | |
| 10 | 8 | use Automattic\Jetpack\Current_Plan as Jetpack_Plan; |
| 11 | 9 | use Automattic\Jetpack\Plugins_Installer; |
| 12 | 10 | use Automattic\Jetpack\Status; |
| 13 | 11 | use Automattic\Jetpack\Status\Host; |
| @@ -68,55 +66,15 @@ | ||
| 68 | 66 | * Returns a boolean indicating if the Jetpack Banner is enabled. |
| 69 | 67 | * |
| 70 | 68 | * @since 9.3.0 |
| 71 | 69 | * |
| 70 | + * @deprecated 13.2 | |
| 71 | + * | |
| 72 | 72 | * @return bool |
| 73 | 73 | */ |
| 74 | 74 | public static function is_banner_enabled() { |
| 75 | - // Shortcircuit early if the recommendations are not enabled at all. | |
| 76 | - if ( ! self::is_enabled() ) { | |
| 77 | - return false; | |
| 78 | - } | |
| 79 | - | |
| 80 | - $recommendations_banner_enabled = Jetpack_Options::get_option( 'recommendations_banner_enabled', null ); | |
| 81 | - | |
| 82 | - // If the option is already set, just return the cached value. | |
| 83 | - // Otherwise calculate it and store it before returning it. | |
| 84 | - if ( null !== $recommendations_banner_enabled ) { | |
| 85 | - return $recommendations_banner_enabled; | |
| 86 | - } | |
| 87 | - | |
| 88 | - if ( ! Jetpack::connection()->is_connected() ) { | |
| 89 | - return new WP_Error( 'site_not_connected', esc_html__( 'Site not connected.', 'jetpack' ) ); | |
| 90 | - } | |
| 91 | - | |
| 92 | - $blog_id = Jetpack_Options::get_option( 'id' ); | |
| 93 | - | |
| 94 | - $request_path = sprintf( '/sites/%s/jetpack-recommendations/site-registered-date', $blog_id ); | |
| 95 | - $result = Client::wpcom_json_api_request_as_blog( | |
| 96 | - $request_path, | |
| 97 | - 2, | |
| 98 | - array( | |
| 99 | - 'headers' => array( 'content-type' => 'application/json' ), | |
| 100 | - ), | |
| 101 | - null, | |
| 102 | - 'wpcom' | |
| 103 | - ); | |
| 104 | - | |
| 105 | - $body = json_decode( wp_remote_retrieve_body( $result ) ); | |
| 106 | - if ( 200 === wp_remote_retrieve_response_code( $result ) ) { | |
| 107 | - $site_registered_date = $body->site_registered_date; | |
| 108 | - } else { | |
| 109 | - $connection = new Connection_Manager( 'jetpack' ); | |
| 110 | - $site_registered_date = $connection->get_assumed_site_creation_date(); | |
| 111 | - } | |
| 112 | - | |
| 113 | - $recommendations_start_date = gmdate( 'Y-m-d H:i:s', strtotime( '2020-12-01 00:00:00' ) ); | |
| 114 | - $recommendations_banner_enabled = $site_registered_date > $recommendations_start_date; | |
| 115 | - | |
| 116 | - Jetpack_Options::update_option( 'recommendations_banner_enabled', $recommendations_banner_enabled ); | |
| 117 | - | |
| 118 | - return $recommendations_banner_enabled; | |
| 75 | + _deprecated_function( __METHOD__, 'jetpack-13.2' ); | |
| 76 | + return false; | |
| 119 | 77 | } |
| 120 | 78 | |
| 121 | 79 | /** |
| 122 | 80 | * Set up actions to monitor for things that trigger a recommendation. |
| @@ -212,9 +170,9 @@ | ||
| 212 | 170 | 'woocommerce.php', |
| 213 | 171 | ); |
| 214 | 172 | |
| 215 | 173 | $path_parts = explode( '/', $plugin ); |
| 216 | - $plugin_file = $path_parts ? array_pop( $path_parts ) : $plugin; | |
| 174 | + $plugin_file = array_pop( $path_parts ); | |
| 217 | 175 | |
| 218 | 176 | if ( ! in_array( $plugin_file, $plugin_whitelist, true ) ) { |
| 219 | 177 | $products = array_column( Jetpack_Plan::get_products(), 'product_slug' ); |
| 220 | 178 | |
| @@ -280,9 +238,9 @@ | ||
| 280 | 238 | // The site has anti-spam features already. |
| 281 | 239 | $site_products = array_column( Jetpack_Plan::get_products(), 'product_slug' ); |
| 282 | 240 | $has_anti_spam_product = count( array_intersect( array( 'jetpack_anti_spam', 'jetpack_anti_spam_monthly' ), $site_products ) ) > 0; |
| 283 | 241 | |
| 284 | - if ( Jetpack_Plan::supports( 'antispam' ) || $has_anti_spam_product ) { | |
| 242 | + if ( Jetpack_Plan::supports( 'akismet' ) || Jetpack_Plan::supports( 'antispam' ) || $has_anti_spam_product ) { | |
| 285 | 243 | return; |
| 286 | 244 | } |
| 287 | 245 | |
| 288 | 246 | if ( isset( $commentdata['comment_post_ID'] ) ) { |
| @@ -423,9 +381,9 @@ | ||
| 423 | 381 | */ |
| 424 | 382 | public static function get_new_conditional_recommendations() { |
| 425 | 383 | $conditional_recommendations = self::get_conditional_recommendations(); |
| 426 | 384 | $recommendations_data = Jetpack_Options::get_option( 'recommendations_data', array() ); |
| 427 | - $viewed_recommendations = isset( $recommendations_data['viewedRecommendations'] ) ? $recommendations_data['viewedRecommendations'] : array(); | |
| 385 | + $viewed_recommendations = $recommendations_data['viewedRecommendations'] ?? array(); | |
| 428 | 386 | |
| 429 | 387 | // array_diff returns a keyed array - reduce to unique values. |
| 430 | 388 | return array_unique( array_values( array_diff( $conditional_recommendations, $viewed_recommendations ) ) ); |
| 431 | 389 | } |
| @@ -439,9 +397,8 @@ | ||
| 439 | 397 | } |
| 440 | 398 | |
| 441 | 399 | $setup_wizard_status = Jetpack_Options::get_option( 'setup_wizard_status' ); |
| 442 | 400 | if ( 'completed' === $setup_wizard_status ) { |
| 443 | - Jetpack_Options::update_option( 'recommendations_banner_enabled', false ); | |
| 444 | 401 | Jetpack_Options::update_option( 'recommendations_step', 'setup-wizard-completed' ); |
| 445 | 402 | } |
| 446 | 403 | } |
| 447 | 404 | |