array( Renderer::class, 'render' ), ) ); wp_set_script_translations( 'alpeg-forms-form-editor-script', 'alpeg-forms' ); } /** * Server values the editor needs. */ public function editor_config() { $config = array( 'maxUploadMb' => max( 1, (int) floor( wp_max_upload_size() / MB_IN_BYTES ) ), 'maxFiles' => Files::MAX_FILES, 'presets' => Files::presets(), ); wp_add_inline_script( 'alpeg-forms-form-editor-script', 'window.alpegFormsEditor = ' . wp_json_encode( $config ) . ';', 'before' ); } /** * Load the front-end CSS in already when the current page contains * the form (avoids a flash of unstyled fields). Nothing is loaded anywhere else. */ public function maybe_enqueue_early() { if ( is_singular() && has_block( 'alpeg-forms/form', get_queried_object() ) ) { wp_enqueue_style( 'alpeg-forms-frontend' ); } } }