Hi
i need a little function.
In the link manager, it's not possible to add a link if the field URL is empty.
I need to save links without target, so i need to save link with the field URL empty.
mdepresb answers:
Hi Sebastien,
Link Manager, in the Widgets?
Marcos
Sébastien | French WordpressDesigner comments:
no.
THE link manager : /wp-admin/link-manager.php
Abdelhadi Touil answers:
Hi.
If I understand what you want, then I think you can simply add # symbole as link.
Good luck.
Sébastien | French WordpressDesigner comments:
yes...
but i need to have the field EMPTY
Abdelhadi Touil comments:
You mean by link manager when we add a link in the post editor? or when adding links in the sidebar for example?
Sébastien | French WordpressDesigner comments:
THE link manager : /wp-admin/link-manager.php
Dbranes answers:
if you are using
wp_list_bookmarks()
to display the links from the link-manager you could try something like
function my_custom_urls($s){
return str_replace("http://empty","",$s);
}
add_filter('wp_list_bookmarks', 'my_custom_urls');
where you have write
empty
in the url field.
Hope this helps.
Dbranes comments:
ps: you can also use something like:
add_filter('wp_list_bookmarks', 'my_custom_urls');
function my_custom_urls($s){
$from = "/href=\"#\"/i";
$to = 'href=""';
return preg_replace($from, $to, $s);
}
if you want to write # in the link field, to indicate empty href.
Have tested this on wp_list_bookmarks(), and the filter seems to work.
Sébastien | French WordpressDesigner comments:
i don't need this function.
I need the possibility to have the field "url" empty in the link manager.
is it clear ?
Dbranes comments:
ok i see ;-)
well one quick&dirty way around this is commenting out one line in the core file: "/wp-admin/includes/bookmark.php"
i.e. line 154 change
if ( trim( $link_url ) == '' )
return 0;
to
if ( trim( $link_url ) == '' )
//return 0;
Hope this helps
Dbranes comments:
ps: I think the link-manager is going to phase out from the core in future versions of Wordpress, so you might need to consider that in the long run
See fx. discussions here:
http://core.trac.wordpress.org/ticket/21307
Gabriel Reguly answers:
Hi,
Basically you can't save a link with an empty URL, because of this
if ( trim( $link_url ) == '' )
return 0;
From <em>function wp_insert_link( $linkdata, $wp_error = false ) </em>, file is wp-admin/includes/bookmark.php
Of course you could create your own plugin to do it, based on the above code and this plugin http://wordpress.org/extend/plugins/custom-list-table-example/
Regards,
Gabriel