• Please add these functions. $ post_content. = "\ n \ n <a target = \" _ blank \ "rel = \" nofollow \ "href = '". esc_url ($ bookmark ['uri']). "'>". $ post_title. '</a>'; A PHP redirect function would of course also be good.

    PS, I’m currently trying to expand the plugin with automatic screenshots and an extended description.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter christophknickmeier

    (@christophknickmeier)

    Automatic sreenshot $post_content .= "<img src='http://s.wordpress.com/mshots/v1/" . esc_url( $bookmark['uri'] ) . "' />"; cheers

    Thread Starter christophknickmeier

    (@christophknickmeier)

    Description works fine

    // Get meta description
    function getDescription($url) {
    $tags = get_meta_tags($url);
    return @($tags['description'] ? $tags['description'] : "NULL");
    }
    // Post meta description.
    $post_content .= 'Meta Description: ' . getDescription( $bookmark['uri'] );

    Next I will look at the source code of the Firefox addon Free Export Bookmarks

    Plugin Author Jan Boddez

    (@janboddez)

    Not sure if you’re directly editing the plugin’s files (you probably shouldn’t), but you should be able to edit post_content using the available filters.

    Example:

    
    add_filter( 'import_bookmarks_post_content', function( $post_content, $bookmark ) {
      $post_content .= "<img src='http://s.wordpress.com/mshots/v1/" . esc_url( $bookmark['uri'] ) . "'>";
    
      return $post_content;
    }, 10, 2 );
    

    Some more inspiration can be found at https://jan.boddez.net/wordpress/import-bookmarks.

    Plugin Author Jan Boddez

    (@janboddez)

    For redirects (definitely out of scope for the plugin itself), if you mean rather than show the generated post you would want to immediately redirect visitors to the bookmarked URL, you’re going to want to hook into a much earlier WP hook, one that runs before any headers are outputted.

    Note that you could always fetch the stored URL like so (at least if your chosen Post Type supports custom meta fields): get_post_meta( $post_id, 'import_bookmarks_uri', true ); and (probably) grab $post_id from a query var or the post global.

    But, like I said, that would be an add-on plugin on its own.

    • This reply was modified 3 years, 9 months ago by Jan Boddez.
    • This reply was modified 3 years, 9 months ago by Jan Boddez.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Simple but nice plugin’ is closed to new replies.