Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Created June 7, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/3a75b98797f0442215d1cd95f01764ec to your computer and use it in GitHub Desktop.
Save wpmudev-sls/3a75b98797f0442215d1cd95f01764ec to your computer and use it in GitHub Desktop.
[New Blog Templates] - Pro Sites - Premium Plugins. Excludes Template plugins that are not included in Premium Plugins
<?php
/**
* Plugin Name: [New Blog Templates] - Pro Sites - Premium Plugins
* Plugin URI: https://premium.wpmudev.org/
* Description: Excludes Template plugins that are not included in Premium Plugins
* Author: Panos Lyrakis @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
add_filter( 'blog_templates-copy-options_row', function( $row ){
if ( 'active_plugins' != $row->option_name || ! isset( $_REQUEST['level'] ) ) {
return $row;
}
global $psts;
$active_plugins = maybe_unserialize( $row->option_value );
$level = intval( $_REQUEST['level'] );
$pro_level_plugins = $psts->get_setting( 'psts_ppm_' . $level, array() );
foreach ( $active_plugins as $key => $plugin ) {
if ( ! in_array( $plugin, $pro_level_plugins ) ) {
unset( $active_plugins[ $key ] );
}
}
$row->option_value = maybe_serialize( $active_plugins );
return $row;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment