license = $license; } public function init() { // License_Manager::heartbeat() stores the signed entitlement snapshot // returned by the same authenticated request. } public function get_snapshot() { $license = $this->license->get_license(); if ( ! $this->license->is_activated() ) { return $this->local_snapshot(); } $snapshot = isset( $license['entitlements'] ) && is_array( $license['entitlements'] ) ? $license['entitlements'] : array(); if ( ! $this->license->verify_entitlements( $snapshot, (string) ( $license['site_token'] ?? '' ) ) || ! $this->license->is_online_grace_valid() ) { return $this->local_snapshot(); } $snapshot['features'] = array_merge( $this->local_features(), (array) ( $snapshot['features'] ?? array() ) ); $snapshot['limits'] = array(); return $snapshot; } public function allows( $feature ) { $feature = sanitize_key( $feature ); if ( in_array( $feature, $this->local_features(), true ) ) { return true; } $snapshot = $this->get_snapshot(); return ! empty( $snapshot['features'][ $feature ] ); } public function content_allowed( $post_type, $current_count ) { return true; } public function content_category( $post_type ) { $post_type = sanitize_key( $post_type ); if ( 'page' === $post_type ) { return 'pages'; } if ( 'post' === $post_type ) { return 'posts'; } if ( 'product' === $post_type ) { return 'products'; } if ( in_array( $post_type, array( 'html_block', 'wp_block' ), true ) ) { return 'html_blocks'; } return preg_match( '/(slider|carousel|slide)/i', $post_type ) ? 'sliders' : 'html_blocks'; } public function language_allowed( $current_count ) { return true; } public function free_snapshot() { return $this->local_snapshot(); } private function local_snapshot() { return array( 'plan_code' => 'free', 'plan_name' => 'Free', 'limits' => array(), 'features' => array_fill_keys( $this->local_features(), true ), 'allowed_ai_models' => array(), ); } private function local_features() { return array( 'manual_translation', 'elementor_translation', 'menu_translation', 'review_translation', 'merchant_feed', 'internal_backlinks', 'language_switcher', 'xliff' ); } }