Created
November 27, 2020 21:55
-
-
Save georgestephanis/e4d2b1f72e919b7560eb1ad6c242ad54 to your computer and use it in GitHub Desktop.
This will build a github markdown table of all the plugins on a site.
This file contains hidden or 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
| <?php | |
| include( 'the/path/to/wp-load.php' ); | |
| if ( ! function_exists( 'is_plugin_active_for_network' ) ) { | |
| require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | |
| } | |
| $updates = get_site_transient( 'update_plugins' ); | |
| if ( ! $updates ) { | |
| wp_update_plugins(); | |
| $updates = get_site_transient( 'update_plugins' ); | |
| } | |
| $headers = array( | |
| 'Slug', | |
| 'Active', | |
| 'Version', | |
| 'Repo Version', | |
| 'Repo Or Custom URL', | |
| ); | |
| echo '| ' . implode( ' | ', $headers ) . " |\r\n"; | |
| echo '| ' . trim( str_repeat( '--- | ', count( $headers ) ) ) . "\r\n"; | |
| $plugins = get_plugins(); | |
| foreach ( $plugins as $file => $data ) { | |
| echo '| '; | |
| foreach ( $headers as $header ) { | |
| switch ( $header ) { | |
| case 'Slug': | |
| echo strpos( $file, '/' ) ? dirname( $file ) : $file; | |
| break; | |
| case 'Active': | |
| echo is_plugin_active( $file ) ? 'Yes' : ( is_plugin_active_for_network( $file ) ? 'Network' : 'No' ); | |
| break; | |
| case 'Repo Version': | |
| if ( isset( $updates->response[ $file ] ) ) { | |
| echo $updates->response[ $file ]->new_version; | |
| } elseif ( isset( $updates->no_update[ $file ] ) ) { | |
| echo 'Current'; | |
| } else { | |
| echo 'Not In Repository'; | |
| } | |
| break; | |
| case 'Repo Or Custom URL': | |
| if ( isset( $updates->response[ $file ] ) ) { | |
| echo $updates->response[ $file ]->url; | |
| } elseif ( isset( $updates->no_update[ $file ] ) ) { | |
| echo $updates->no_update[ $file ]->url; | |
| } else { | |
| echo $data['Plugin URI']; | |
| } | |
| break; | |
| default: | |
| echo $data[ $header ]; | |
| break; | |
| } | |
| echo ' | '; | |
| } | |
| echo "\r\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment