categories - Unset plugins on front-end belonging to specific category

admin2025-06-02  3

I have a function which unset plugins on the front-end.
The only extra criteria, in_category ( 'my-cat-name' ), I am not able to achieve.

Where and how to add the category so the plugins are only unset on post types which belong to this category?

I tried if( !is_admin() && is_category('my-cat-name') ) but that seems not correct.

Below the code I have add, in a separate file, in the mu-plugins folder.
As it is now, the plugins are removed from all post and that is not what I want to achieve.

if( !is_admin() ) {
    add_filter( 'option_active_plugins', 'de_active_plugins' );    
}
function de_active_plugins( $plugins ) 
{
    $skip   = array();   
    $skip[] = 'plugin01_foldername/plugin01_name.php';   
    $skip[] = 'plugin02_foldername/plugin02_name.php';   

    foreach ( $skip as $plugin ) {
        $collected = array_search( $plugin, $plugins );
        if( false !== $collected ) {
            unset( $plugins[$collected] );
        }
    }
    return $plugins; 
}

I appreciate all help.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748867691a314384.html

最新回复(0)