Skip to content

Instantly share code, notes, and snippets.

@phillip-boombox
Last active June 5, 2021 19:36
Show Gist options
  • Save phillip-boombox/5a65a5bdf972c937b7fe0bd702bc544d to your computer and use it in GitHub Desktop.
Save phillip-boombox/5a65a5bdf972c937b7fe0bd702bc544d to your computer and use it in GitHub Desktop.
WordPress: Required plugins from the plugins repository
add_filter( 'install_plugins_tabs', 'cmfy_required_plugins_tab' );
function cmfy_required_plugins_tab( $tabs ) {
$tabs['cmfy'] = _x( 'Required', 'Plugin Installer', 'cmfy' );
return $tabs;
}
add_action( 'install_plugins_cmfy', 'cmfy_required_plugins_page' );
function cmfy_required_plugins_page() {
$required_plugin_slugs = array(
'cmb2',
'gravity-forms-google-analytics-event-tracking',
'syntaxhighlighter',
'wordpress-seo',
);
echo '<p>' . __( 'These plugins are required for this installation.', 'cmfy' ) . '</p>';
echo '<div id="the-list">';
$table = new WP_Plugin_Install_List_Table();
$table->items = array();
foreach ( $required_plugin_slugs as $slug ) {
$args = array(
'fields' => array(
'last_updated' => true,
'icons' => true,
'active_installs' => true
),
'locale' => get_user_locale(),
'slug' => $slug,
);
$table->items[] = plugins_api( 'plugin_information', $args );
}
$table->display_rows();
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment