I've written a plugin that creates a feed reader like google reader in wordpress. An old screenshot of Orbital Feed Reader

Currently I let folks reblog feed items by using the built in WP PressThis plugin url. I pass in parameters and WP formats a post for my users.

I'd like to get more granular control - let my users specify a post format etc. I want to control the title, the body, and maybe even things like tags or format, but I want my users to have a chance to edit it all right before they hit publish to add in their wise thoughts.

What's the WP way to do this in my plugin?


I've installed your plugin and it doesn't work.

Feeds counter are updated correctly, but no feed are shown (and so no 'Press this' buttons).

After that when I install it I see several notices: are you testing your plugin with wp debugging active?

The best way, for me, is redirect users to the standard wordpress post creation page. But how pre populated it?

After a quick look on your code, I'll give you the bones of a solution that should be improved and tailored to your plugin.

Sure there are more elegant way, but first coming into my mind is:

  1. create and save a post with selected feed content, and set status as auto-draft.
  2. redirect users to edit page for the just created posts

Something like:

Javascript: in the file 'js/myblogthis.js'

jQuery().ready(function($) {
  $('.entry-tools a').click(function(e) {
  var $entry = $(this).closest('.entry');
  var $titleObj = $entry.find('.entry-title');
  var _title = $titleObj.text();
  var _url = $titleObj.parent().attr('href');
  var _by = $entry.find('.author').text();
  var _date = $entry.find('.date').text();
  var _content= $entry.find('.entry-content').html();
      url: ajaxurl, type: 'POST', dataType: 'json',
      data: {
        title: _title, url: _url, by: _by, date: _date, content: _content,
        action: 'blog_this', nonce: myblogthisData.nonce
      function( data ) {
        if ( data && data.url ) { window.location.href = data.url
        } else { alert( "Error!" ); }


add_action('admin_enqueue_scripts', 'enqueue_blog_this_js');

add_action('wp_ajax_blog_this', 'my_blog_this');   

function enqueue_blog_this_js($page) {
  if ( $page != 'toplevel_page_orbital' ) return;
  wp_enqueue_script('myblogthis', plugins_url('js/myblogthis.js', __FILE__), array(), null );
  $data = array( 'nonce' => wp_create_nonce('myblogthis') );
  wp_localize_script('myblogthis', 'myblogthisData', $data);

function my_blog_this() {
  if ( ! isset($_POST['nonce']) || ! wp_verify_nonce($_POST['nonce'], 'myblogthis') )
    wp_send_json( array('error' => 'Security Fail') );
  $title = isset($_POST['title']) ? $_POST['title'] : '';
  $url = isset($_POST['url']) ? $_POST['url'] : '';
  $by = isset($_POST['by']) ? $_POST['by'] : '';
  $date = isset($_POST['date']) ? $_POST['date'] : '';
  $content = isset($_POST['content']) ? $_POST['content'] : '';
  if ( $title && $url && $by && $date) {
    $content .= sprintf(
      '<p>Originally posted by: %s on %s (see: <a href="%s">%s</a>)</p>',
      esc_html($by), esc_html($date), esc_url($url), esc_html($title)
  $args = array(
    'post_status' => 'auto-draft',
    'post_title' => '',
    'post_author' => wp_get_current_user()->ID,
    'post_content' => $content
  $id = wp_insert_post($args);
  if ( $id ) {
    $url = add_query_arg( array('action'=> 'edit', 'post'=> $id), admin_url('post.php') );
    wp_send_json( array('url'=> $url ) );
  wp_send_json( array('error' => 'Saving Post Error') );

As you can see, I tried to create js according to the html outputted by 'mainwindow.php'.

The main between the method you are using and the mine is that you let users select a text to re-blog, while I use the entire content. But with some js improvements maybe you can modify this behaviour.

| improve this answer | |
  • Hi G.M, thanks for the answer - can you help me out with more info on how the plugin didn't work for you? I've had a few testers so far and no one reported not seeing anything from the sample feeds. Also, any text of the notices you got or errors would be much appreciated. If you want to take it off of StackExchange, I'd love to work on any issues you file on the github issues page: github.com/mattkatz/Orbital-Feed-Reader/issues – MattK Sep 3 '13 at 10:43
  • Sounds like there is no way to just import the wordpress editor etc from the WP core code. – MattK Sep 3 '13 at 10:49
  • @MattK I've removed your plugin now.. I'll will test again as soon as possible and give you feedback. The wordpress editor can be printed with a simple wp_editor() call. If you want it in modal window I think can be easy embedding in a ajax loaded page by thickbox. But If I understand, your problem is that you need to edit not only content, but title, taxonomies, post formats.. so you need the full post creation page. So why don't use it? – gmazzap Sep 3 '13 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.