Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixes notices thrown by unset tooltip settings.
add_action( 'elementor/widget/before_render_content', function( $widget ) {
$settings = $widget->get_settings();
if ( isset( $settings['ep_tooltip'] ) && 'on' === $settings['ep_tooltip'] ) {
if ( 'heading' === $widget->get_name() ) {
$widget->add_render_attribute( 'title', 'data-tooltip', $settings['ep_tooltip_text'] );
$widget->add_render_attribute( 'title', 'class', 'ep-tooltip' );
$widget->add_render_attribute( 'title', 'class', $settings['ep_tooltip_position'] );
} elseif ( 'icon' === $widget->get_name() ) {
$widget->add_render_attribute( $widget->get_name() . '-wrapper', 'data-tooltip', $settings['ep_tooltip_text'] );
$widget->add_render_attribute( $widget->get_name() . '-wrapper', 'class', 'ep-tooltip' );
$widget->add_render_attribute( $widget->get_name() . '-wrapper', 'class', $settings['ep_tooltip_position'] );
} elseif ( 'icon-box' === $widget->get_name() ) {
$widget->add_render_attribute( 'icon', 'data-tooltip', $settings['ep_tooltip_text'] );
$widget->add_render_attribute( 'icon', 'class', 'ep-tooltip' );
$widget->add_render_attribute( 'icon', 'class', $settings['ep_tooltip_position'] );
} elseif ( 'button' === $widget->get_name() ) {
$widget->add_render_attribute( $widget->get_name(), 'data-tooltip', $settings['ep_tooltip_text'] );
$widget->add_render_attribute( $widget->get_name(), 'class', 'ep-tooltip' );
$widget->add_render_attribute( $widget->get_name(), 'class', $settings['ep_tooltip_position'] );
}
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment