Last active
June 5, 2021 19:36
-
-
Save phillip-boombox/5a65a5bdf972c937b7fe0bd702bc544d to your computer and use it in GitHub Desktop.
WordPress: Required plugins from the plugins repository
This file contains 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
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