Created
November 3, 2024 15:42
-
-
Save mateitudor/6f507e661aa5219435a136e5b66a549d to your computer and use it in GitHub Desktop.
Remove Elementor AI including the silly per user checkboxes like "Enable Elementor AI functionality"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function disable_elementor_ai_module() { | |
| if ( class_exists( 'Elementor\Plugin' ) && isset( \Elementor\Plugin::$instance->modules_manager ) ) { | |
| $modules_manager = \Elementor\Plugin::$instance->modules_manager; | |
| // Disable AI module entirely by removing its registration | |
| remove_all_actions( 'personal_options' ); | |
| remove_all_actions( 'personal_options_update' ); | |
| remove_all_actions( 'edit_user_profile_update' ); | |
| // Disable AI option across all users | |
| add_filter( 'pre_update_user_option_elementor_enable_ai', '__return_false' ); | |
| add_filter( 'default_option_elementor_enable_ai', '__return_false' ); | |
| // Remove any instance of the AI module within Elementor | |
| if ( isset( $modules_manager->modules['ai'] ) ) { | |
| unset( $modules_manager->modules['ai'] ); | |
| } | |
| } | |
| } | |
| add_action( 'elementor/init', 'disable_elementor_ai_module', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment