integration = $integration; } /** * Register field rendering and the provider's native post save hook. * * @since 1.8.0 */ public function hooks(): void { add_filter( 'cubewp/admin/text/customfield', [ $this, 'render_protection_field' ], 20, 2 ); add_action( 'save_post_cwp_forms', [ $this, 'save_protection' ] ); } /** * Append the checkbox after the form ID setting, which is always rendered. * * @since 1.8.0 * * @param string $output Existing CubeWP field HTML. * @param array $args Native field configuration. * * @return string Existing field and optional ActiveLayer setting. */ public function render_protection_field( string $output, array $args ): string { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only editor context; CubeWP verifies its edit nonce. $page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; if ( $page !== 'cubewp-form-fields' || ( $args['name'] ?? '' ) !== 'cwp[form][settings][form_id]' ) { return $output; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only form settings lookup. $form_id = isset( $_GET['groupid'] ) && is_scalar( $_GET['groupid'] ) ? absint( $_GET['groupid'] ) : 0; $enabled = $this->integration->get_admin_settings()->get_form_settings( $form_id )['enabled']; $output .= '