$option_value ) { if ( ! in_array( $option_name, $allowed_options, true ) ) { unset( $options[ $option_name ] ); } } $options['blog_id'] = Jetpack_Options::get_option( 'id' ); $options['version'] = Main::STATS_VERSION; $success = update_option( self::OPTION_NAME, $options ); if ( true === $success ) { self::$options = $options; } return $success; } /** * Stats Upgrade Options. * * Ideally this should be a protected method but keeping it public * to maintain backwards compatibility with stats_upgrade_options. * * @access public * @param array $options The stats options. * @return array|bool */ public static function upgrade_options( $options ) { if ( isset( $options['reg_users'] ) ) { if ( ! function_exists( 'get_editable_roles' ) ) { require_once ABSPATH . 'wp-admin/includes/user.php'; } if ( $options['reg_users'] ) { $options['count_roles'] = array_keys( get_editable_roles() ); } unset( $options['reg_users'] ); } if ( false === self::set_options( $options ) ) { return false; } return self::$options; } /** * Default Stats related options. * * Exposed so consumers (e.g. the Abilities API surface) can introspect * each option's default value and infer its type without redeclaring * a parallel allow-list of bool/array fields. * * @return array */ public static function get_defaults() { return array( 'admin_bar' => true, 'roles' => array( 'administrator' ), 'count_roles' => array(), 'do_not_track' => true, // @todo 'blog_id' => Jetpack_Options::get_option( 'id' ), 'version' => Main::STATS_VERSION, 'collapse_nudges' => false, 'enable_odyssey_stats' => true, 'odyssey_stats_changed_at' => 0, 'notices' => array(), 'views' => 0, 'honor_cookie_consent' => false, ); } }