Created
April 13, 2023 05:36
-
-
Save dominicvogl/61ab18d5dc73b220b0a6ddad1e2a2a64 to your computer and use it in GitHub Desktop.
Show me a Table view of all registered and active styles and scripts of a Wordpress Installation
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
| function list_registered_scripts_and_styles() { | |
| global $wp_scripts, $wp_styles; | |
| // Tabellarische Ausgabe für registrierte Skripte | |
| echo "<h2>Registrierte Skripte:</h2>"; | |
| echo "<table><thead><tr><th>Name</th><th>URL</th><th>Version</th><th>Abhängigkeiten</th></tr></thead><tbody>"; | |
| foreach( $wp_scripts->registered as $script ) { | |
| echo "<tr><td>{$script->handle}</td>"; | |
| echo "<td>{$script->src}</td>"; | |
| echo "<td>{$script->ver}</td>"; | |
| echo "<td>" . implode( ", ", $script->deps ) . "</td></tr>"; | |
| } | |
| echo "</tbody></table>"; | |
| // Tabellarische Ausgabe für registrierte Styles | |
| echo "<h2>Registrierte Styles:</h2>"; | |
| echo "<table><thead><tr><th>Name</th><th>URL</th><th>Version</th><th>Abhängigkeiten</th></tr></thead><tbody>"; | |
| foreach( $wp_styles->registered as $style ) { | |
| echo "<tr><td>{$style->handle}</td>"; | |
| echo "<td>{$style->src}</td>"; | |
| echo "<td>{$style->ver}</td>"; | |
| echo "<td>" . implode( ", ", $style->deps ) . "</td></tr>"; | |
| } | |
| echo "</tbody></table>"; | |
| } | |
| // Die Funktion kann zum Beispiel in functions.php des aktiven Themes aufgerufen werden | |
| list_registered_scripts_and_styles(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment