'amount', 'givewp/payment-gateways' => 'gateways', 'givewp/donation-summary' => 'summary', ]; /** * @since 4.17.0 * * @param array $data The array GetFormSkeletonData returns. * * @return string Empty for a design the skeleton cannot sketch. */ public function __invoke(array $data): string { $design = (string)($data['design'] ?? ''); if (!in_array($design, self::KNOWN_DESIGNS, true)) { return ''; } $sections = array_map(static function ($blocks): array { return array_map('strval', is_array($blocks) ? $blocks : []); }, array_values(is_array($data['sections'] ?? null) ? $data['sections'] : [])); return trim(View::load('DonationForms.form-skeleton', [ 'design' => $design, 'header' => !empty($data['header']), 'goal' => !empty($data['goal']), 'image' => !empty($data['image']), 'sections' => $sections, 'gateways' => (int)($data['gateways'] ?? 0), 'variants' => self::BLOCK_VARIANTS, ])); } /** * The skeleton's stylesheet, raw, for the caller to inline however its page allows. It has to * travel with the markup because the markup must paint before any enqueued stylesheet arrives: * the block prints a style element next to it in the content, since anything it enqueued would * print in the footer, and the form view adds it to its head through wp_add_inline_style(). * * @since 4.17.0 */ public function css(): string { static $css = null; if ($css === null) { $file = GIVE_PLUGIN_DIR . 'build/donationFormSkeletonCss.css'; $css = is_readable($file) ? (string)file_get_contents($file) : ''; } return $css; } }