• Hola buenas comunidad les tengo una consulta hay alguna forma de como habilitar por defecto el abrir un link en una nueva pestaña los links creados desde block editor.

    He intentado habilitar el linkcontrol openInNewTab = true a traves de un archivo js

    wp.domReady(() => { const { addFilter } = wp.hooks; const { createHigherOrderComponent } = wp.compose; const withDefaultSettings = createHigherOrderComponent((LinkControl) => { return (props) => { if (props.value && typeof props.value.opensInNewTab === ‘undefined’) { props.value.opensInNewTab = true; // Activar abrir en nueva pestaña por defecto } return wp.element.createElement(LinkControl, props); }; }, ‘withDefaultSettings’); addFilter( ‘editor.LinkControl’, ‘custom/default-link-settings’, withDefaultSettings ); });

    No he tenido exito.

    Les agradeceria mucho su ayuda

Viendo 1 respuesta (de un total de 1)
  • Hola.

    Prueba con esta función:

    function jrb_enlaces_externos_new_tab() { ?>

        <script>

            jQuery(".entry-content a[href^=http]").each(function(){

            if(this.href.indexOf(location.hostname) == -1) {

            jQuery(this).attr({

            target: "_blank",

            rel: "noreferrer noopener",

            });

            }

            });

        </script>

        <?php }

        add_action('wp_footer', 'jrb_enlaces_externos_new_tab', 100);

    Saludos.

Viendo 1 respuesta (de un total de 1)
  • Debes estar registrado para responder a este debate.