Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Force WPML to use Dash Icons instead of the default outdated png icons
<?php
/*
The filter that is in WPML core to allow for the modification of the admin icons occurs in wpml-post-status-display.class
in get_status_html. Howevr this filter (wpml_icon_to_translation) only provides the actual icon file, not the full path,
making it's replacement with icons stored elsewhere impossible.
So for this code to work, you have to mod render_status_icon() as follows:
private function render_status_icon( $link, $text, $img ) {
$path = ICL_PLUGIN_URL . '/res/img/';
$w = '16';
$h = '16';
$icon_html = '<img style="padding:1px;margin:2px;" border="0" src="'
. $path
. $img . '" alt="'
. $text . '" width="' . $w . '" height="' . $h . '"/>';
$icon_html = apply_filters( 'wpml_icon_to_translation_html', $icon_html, $path, $img, $text, $w, $h );
$icon_html = '<a href="' . $link . '" title="' . $text . '">'
. $icon_html
. '</a>';
return $icon_html;
Once this is done, the code below will work.
*/
add_filter('wpml_icon_to_translation_html', 'cnmd_modernize_wpml_icons', 10, 6);
function cnmd_modernize_wpml_icons($icon_html, $path, $img, $text, $w, $h) {
$class = "wpml_icon_" . basename( $img, '.png');
$i = "<div class='$class'><div class='wpml_icon_hidden'>$icon_html</div></div>";
return $i;
}
add_action('admin_head', 'cnmd_cpt_set_wpml_icons',1);
function cnmd_cpt_set_wpml_icons( ) {
?>
<style type="text/css">
.wpml_icon_edit_translation:before {
content: '\f119';
margin-left: -1px;
font-family: dashicons;
font-size: 3em;
}
.wpml_icon_hidden {
display: none;
}
.wpml_icon_needs-update:before {
content: '\f531';
margin-left: -1px;
font-family: dashicons;
font-size: 3em;
}
.wpml_icon_add_translation:before {
content: '\f132';
margin-left: -1px;
font-family: dashicons;
font-size: 3em;
}
</style>
<?php
}
@theMikeD

This comment has been minimized.

Copy link
Owner Author

theMikeD commented Aug 2, 2017

And yes, before you say anything, I know this is hacky, but this took me about 15 minutes of effort to prove a point that making these changes is not difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.