Code change to allow target _blank or _self
-
Hello, I have made a change in the code to include compatibility with links in external window or in the same window. They are only two lines of code but I provide them for a future version
public static function before_section_render(Element_Base $element) { $link_settings = $element->get_settings_for_display('ra_element_link'); if ($link_settings && !empty($link_settings['url'])) { $target = $link_settings['is_external'] != '' ? '_blank' : '_self'; $element->add_render_attribute( '_wrapper', [ 'data-ra-element-link' => json_encode($link_settings), 'style' => 'cursor: pointer', 'target' => $target, 'onClick' => 'window.open(\'' . $link_settings['url'] . '\', \'' . $target . '\')', ] ); } }
I hope it can helps!
- The topic ‘Code change to allow target _blank or _self’ is closed to new replies.