'Fluent Forms', 'wpforms/wpforms.php' => 'WPForms', 'wpforms-lite/wpforms.php' => 'WPForms Lite', 'gravityforms/gravityforms.php' => 'Gravity Forms', 'formidable/formidable.php' => 'Formidable Forms', 'ninja-forms/ninja-forms.php' => 'Ninja Forms', 'contact-form-7/wp-contact-form-7.php' => 'Contact Form 7', ]; const DISMISS_META_KEY = 'chargeforms_dismissed_competing_notice'; public function __construct() { add_action( 'admin_notices', [ $this, 'render' ] ); add_action( 'admin_post_chargeforms_dismiss_competing_notice', [ $this, 'handle_dismiss' ] ); } public function render() { if ( ! current_user_can( 'chargeforms_manage_forms' ) || ! $this->on_chargeforms_screen() ) { return; } if ( 'yes' === get_user_meta( get_current_user_id(), self::DISMISS_META_KEY, true ) ) { return; } $active_names = $this->active_competing_plugin_names(); if ( empty( $active_names ) ) { return; } $dismiss_url = wp_nonce_url( admin_url( 'admin-post.php?action=chargeforms_dismiss_competing_notice' ), 'chargeforms_dismiss_competing_notice' ); ?>
$label ) { if ( is_plugin_active( $plugin_file ) ) { $names[] = $label; } } return $names; } public function handle_dismiss() { check_admin_referer( 'chargeforms_dismiss_competing_notice' ); if ( ! current_user_can( 'chargeforms_manage_forms' ) ) { wp_die( esc_html__( 'You do not have permission to do this.', 'chargeforms' ), 403 ); } update_user_meta( get_current_user_id(), self::DISMISS_META_KEY, 'yes' ); wp_safe_redirect( wp_get_referer() ?: admin_url( 'admin.php?page=chargeforms' ) ); exit; } /** Same scoping rule as Delivery_Health_Notice — ChargeForms' own screens only, never a site-wide nag. */ private function on_chargeforms_screen() { $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended return 0 === strpos( $page, 'chargeforms' ); } }