false, 'state' => $state->get(), 'error' => 'Invalid data', ); } $provider_key = sanitize_key( $data['key'] ); $css = $this->unmask_content( $data['css'] ); $storage = new Critical_CSS_Storage(); $storage->store_css( $provider_key, $css ); $state->set_provider_success( $provider_key ); $state->save(); return array( 'success' => true, 'state' => $state->get(), ); } /** * Unmasks the content. * * @param string $content The content to unmask. * @return string The unmasked content. */ private function unmask_content( $content ) { return str_replace( '__JB_XMLNS__', 'xmlns', $content ); } }