-
-
Save maddisondesigns/276af3c3781cde053c4855cd1da37cac to your computer and use it in GitHub Desktop.
| /** | |
| * Redirect the new AI Settings > Connectors screen back to the Dashboard so it can't be accessed | |
| */ | |
| function mytheme_admin_redirects() { | |
| global $pagenow; | |
| /* Redirect Connectors screen back to main Dashboard page */ | |
| if( $pagenow == 'options-connectors.php' ) { | |
| wp_redirect( admin_url( '/' ), 301 ); | |
| exit; | |
| } | |
| } | |
| add_action( 'admin_init', 'mytheme_admin_redirects' ); | |
| /** | |
| * Remove the new AI Settings > Connectors page from the WP Dashboard menu | |
| */ | |
| function mytheme_remove_connectors_screen() { | |
| remove_submenu_page( 'options-general.php', 'options-connectors.php' ); | |
| } | |
| add_action( 'admin_init', 'mytheme_remove_connectors_screen' ); |
| // Disable AI Support | |
| define( 'WP_AI_SUPPORT', false ); |
Thanks for this. It is annoying how hard they are pushing AI trash.
No worries π
And agreed! Last thing I want in my site is AI!
Thanks for this.
Thanks for this.
π Glad you find it useful :-)
In case anyone finds it useful, I've refactored @maddisondesigns code to utilise the WP_AI_SUPPORT constant - unless this constant is both defined and set to true, the AI settings screen will be removed from the WP 7+ dashboard:
/**
* Removes AI support from WordPress 7+:
* @link https://gist.github.com/maddisondesigns/276af3c3781cde053c4855cd1da37cac
*
* @return void
*/
add_action('admin_init', function() {
if (defined('WP_AI_SUPPORT') && constant('WP_AI_SUPPORT')) {
return;
}
global $pagenow;
/**
* Removes the new Settings > Connectors AI screen from the WP
* Dashboard menu:
*/
remove_submenu_page('options-general.php', 'options-connectors.php');
/**
* Redirects the new Settings > Connectors AI screen back to the main
* Dashboard so the URL can't be accessed directly:
*/
if ('options-connectors.php' === $pagenow) {
wp_redirect(admin_url('/'), 301);
exit;
}
});
You can also use the filters - (Apparently Jetpack if installed can override the WP baseline setting):
add_filter( 'wp_supports_ai', '__return_false' );
add_filter( 'jetpack_ai_enabled', '__return_false' );
Setting via constant will override both.
while not directly related to AI, Akismet also uses the connector interface and it can be overridden with:
/**
* Disable Akismet Connector Usage
*/
add_action(
'wp_connectors_init',
function ( $registry ) {
if ( method_exists( $registry, 'is_registered' ) && $registry->is_registered( 'akismet' ) ) {
$registry->unregister( 'akismet' );
}
},
20
); // after Akismet_Connector::register_connector (default priority 10).
Thanks for this. It is annoying how hard they are pushing AI trash.