isset( $results['plan'] ) ) { return false; } $current_plan = get_option( self::PLAN_OPTION, array() ); if ( ! empty( $current_plan ) && $current_plan === $results['plan'] ) { // Bail if the plans array hasn't changed. return false; } // Store the new plan in an option and return true if updated. $result = self::store_data_in_option( self::PLAN_OPTION, $results['plan'] ); if ( $result ) { // Reset the cache since we've just updated the plan. self::$active_plan_cache = null; } return $result; } /** * Store data in an option. * * @param string $option The name of the option that will store the data. * @param array $data Data to be store in an option. * @return bool Were the subscriptions successfully updated? */ private static function store_data_in_option( $option, $data ) { $result = update_option( $option, $data, true ); // If something goes wrong with the update, so delete the current option and then update it. if ( ! $result ) { delete_option( $option ); $result = update_option( $option, $data, true ); } return $result; } /** * Make an API call to WordPress.com for plan status * * @uses Jetpack_Options::get_option() * @uses Client::wpcom_json_api_request_as_blog() * @uses update_option() * * @access public * @static * * @return bool True if plan is updated, false if no update */ public static function refresh_from_wpcom() { $site_id = Manager::get_site_id(); if ( is_wp_error( $site_id ) ) { return false; } // Make the API request. $response = Client::wpcom_json_api_request_as_blog( sprintf( '/sites/%d?force=wpcom', $site_id ), '1.1' ); return self::update_from_sites_response( $response ); } /** * Get the plan that this Jetpack site is currently using. * * @uses get_option() * * @access public * @static * * @return array Active Jetpack plan details */ public static function get() { // this can be expensive to compute so we cache for the duration of a request. if ( is_array( self::$active_plan_cache ) && ! empty( self::$active_plan_cache ) ) { return self::$active_plan_cache; } $plan = get_option( self::PLAN_OPTION, array() ); // Set the default options. $plan = wp_parse_args( $plan, array( 'product_slug' => 'jetpack_free', 'class' => 'free', 'features' => array( 'active' => array(), ), ) ); list( $plan['class'], $supports ) = self::get_class_and_features( $plan['product_slug'] ); $modules = new Modules(); foreach ( $modules->get_available() as $module_slug ) { $module = $modules->get( $module_slug ); if ( ! isset( $module ) || ! is_array( $module ) ) { continue; } if ( in_array( 'free', $module['plan_classes'], true ) || in_array( $plan['class'], $module['plan_classes'], true ) ) { $supports[] = $module_slug; } } $plan['supports'] = $supports; self::$active_plan_cache = $plan; return $plan; } /** * Get the site's products. * * @uses get_option() * * @access public * @static * * @return array Active Jetpack products */ public static function get_products() { return get_option( self::SITE_PRODUCTS_OPTION, array() ); } /** * Get the class of plan and a list of features it supports * * @param string $plan_slug The plan that we're interested in. * @return array Two item array, the plan class and the an array of features. */ private static function get_class_and_features( $plan_slug ) { $features = array(); foreach ( self::PLAN_DATA as $class => $details ) { $features = array_merge( $features, $details['supports'] ); if ( in_array( $plan_slug, $details['plans'], true ) ) { return array( $class, $features ); } } return array( 'free', self::PLAN_DATA['free']['supports'] ); } /** * Gets the minimum plan slug that supports the given feature * * @param string $feature The name of the feature. * @return string|bool The slug for the minimum plan that supports. * the feature or false if not found */ public static function get_minimum_plan_for_feature( $feature ) { foreach ( self::PLAN_DATA as $details ) { if ( in_array( $feature, $details['supports'], true ) ) { return $details['plans'][0]; } } return false; } /** * Determine whether the active plan supports a particular feature * * @uses self::get() * * @access public * @static * * @param string $feature The module or feature to check. * @param bool $refresh_from_wpcom Refresh the local plan cache from wpcom. * * @return bool True if plan supports feature, false if not */ public static function supports( $feature, $refresh_from_wpcom = false ) { if ( $refresh_from_wpcom ) { self::refresh_from_wpcom(); } // Hijack the feature eligibility check on WordPress.com sites since they are gated differently. $should_wpcom_gate_feature = ( function_exists( 'wpcom_site_has_feature' ) && function_exists( 'wpcom_feature_exists' ) && wpcom_feature_exists( $feature ) ); if ( $should_wpcom_gate_feature ) { return wpcom_site_has_feature( $feature ); } // Search product bypasses plan feature check. if ( 'search' === $feature && (bool) get_option( 'has_jetpack_search_product' ) ) { return true; } // As of Q3 2021 - a videopress free tier is available to all plans. if ( 'videopress' === $feature ) { return true; } // As of 05 2023 - all plans support Earn features (minus 'simple-payments') if ( in_array( $feature, array( 'donations', 'recurring-payments', 'premium-content/container' ), true ) ) { return true; } $plan = self::get(); if ( in_array( $feature, $plan['supports'], true ) || in_array( $feature, $plan['features']['active'], true ) ) { return true; } return false; } }
Fatal error: Uncaught Error: Class "Automattic\Jetpack\Current_Plan" not found in /htdocs/wp-content/plugins/jetpack/extensions/blocks/wordads/wordads.php:51 Stack trace: #0 /htdocs/wp-content/plugins/jetpack/extensions/blocks/wordads/wordads.php(58): Automattic\Jetpack\Extensions\WordAds::is_available() #1 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Extensions\WordAds::register('') #2 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /htdocs/wp-settings.php(727): do_action('init') #5 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #6 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #7 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #8 /htdocs/index.php(17): require('/htdocs/wp-blog...') #9 {main} thrown in /htdocs/wp-content/plugins/jetpack/extensions/blocks/wordads/wordads.php on line 51