Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
add_action( 'widgets_init', 'ic_remove_simple_social_css', 999 );
function ic_remove_simple_social_css() {
global $wp_registered_widgets;
$widgetNames = array_keys( $wp_registered_widgets );
$ssWidgets = [];
foreach ( $widgetNames as $name ) {
if ( false !== strpos( $name, 'simple-social-icons' ) ) {
$ssWidgets[] = $name;
}
}
foreach ( $ssWidgets as $widget ) {
$widgetObject = $wp_registered_widgets[ $widget ]['callback'][0];
remove_action( 'wp_head', [ $widgetObject, 'css' ] );
}
}
Owner

iCaspar commented May 8, 2017

Removing the CSS from the simple social icons widget requires finding the widget object. This sorts through all the widgets that are registered in the WP global $wp_registered_widgets to see if the widget has been registered, and if it has, grabs the object from the registered widgets array and unregisters the action. Your mileage may vary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment