process_bulk_action(); $table->prepare_items(); ?>

display(); ?>

'array', 'sanitize_callback' => array( $this, 'sanitize_settings' ), 'default' => array(), ) ); } public function sanitize_settings( array $settings ): array { return array_map( 'sanitize_text_field', $settings ); } /** * Parse post data and extract and save form settings. * * @param [int] $post_id * @param [mixed] $post * @return void */ public function save_form( $post_id, $post ) { if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) { return; } if ( ! in_array( $post->post_type, array( 'page', 'post' ), true ) ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } $content = $post->post_content; $blocks = parse_blocks( $content ); $forms = $this->get_nnforms_block_attributes( $blocks ); foreach ( $forms as $form_id => $form_data ) { $form_data['post_id'] = $post_id; update_option( 'nnforms_form_' . $form_id, $form_data ); } } /** * Extract form and field attributes recursively. * * @param array $blocks * @param array $results * @param [int] $form_id * @return array */ private function get_nnforms_block_attributes( $blocks, &$results = array(), $form_id = null ) { foreach ( $blocks as $block ) { if ( str_starts_with( $block['blockName'] ?? '', 'nnforms/' ) ) { $block_id = $block['attrs']['id'] ?? null; if ( 'nnforms/form' === $block['blockName'] ) { $form_id = $block_id; $results[ $form_id ] = array_intersect_key( $block, array_flip( array( 'blockName', 'attrs' ) ) ); $results[ $form_id ]['fields'] = array(); } elseif ( $form_id ) { $results[ $form_id ]['fields'][ $block_id ] = array_intersect_key( $block, array_flip( array( 'blockName', 'attrs' ) ) ); } } if ( ! empty( $block['innerBlocks'] ) ) { $this->get_nnforms_block_attributes( $block['innerBlocks'], $results, $form_id ); } } return $results; } public function enqueue_scripts() { wp_enqueue_script( 'nnforms_admin', NNFORMS_BUILD_URL . 'admin/admin.js', array(), NNFORMS_VERSION, array( 'in_footer' => true, ) ); wp_enqueue_style( 'nnforms_admin', NNFORMS_BUILD_URL . 'admin/admin.css', array(), NNFORMS_VERSION, ); } }