dcramer / wp-lifestream

Lifestreaming plugin for Wordpress
http://forums.lifestrm.com/index.php
122 stars 31 forks source link

Custom Post_Type support ? #96

Open anthonymasure opened 12 years ago

anthonymasure commented 12 years ago

Hi,

Thank you for your awesome Lifestream Plugin ! Did you plan to upgrade the plugin in the WordPress repository, or do I have to download the latest version here ? Is http://wordpress.org/extend/plugins/lifestream-update/ the new and good link ?

//

I've seen that the plugin create a custom post_type 'lsevent' for each event imported.

The code who register the post_type is located in inc/core.php line 648 :

register_post_type('lsevent', array(
            'label' => $this->__('Lifestream Events'),
            'singular_label' => $this->__('Lifestream Event'),
            'show_ui' => false,
            'public' => true,
            'exclude_from_search' => true,
            'hierarchical' => false,
            'capability_type' => 'post',
            'rewrite' => array('slug', 'lifestream'),
            'query_var' => false,
            'can_export' => false,
            'show_in_nav_menus' => false,
            'supports' => array('title', 'comments')
        ));

Then, the function who create a post_type for each event is located line 1977 :

function create_post_for_event($event)
    {
        global $wpdb;

        // TODO: find a better title
        $post = array(
            'post_title' => 'Lifestream Event',
            'post_content' => '',
            'post_status' => 'publish',
            'post_author' => $event->owner_id,
            'post_type' => 'lsevent',
            // should we insert the feed types into the tags?
            // 'tags_input' => ''
            'post_date' => date('Y-m-d H:i:s', $event->timestamp),
        );
        $post_id = wp_insert_post($post);
        $event->post_id = $post_id;
        $event_list = array();
        if ($event->is_grouped)
        {
            $wpdb->query($wpdb->prepare("UPDATE <code>&quot;.$wpdb->prefix.&quot;lifestream_event_group</code> set <code>post_id</code> = %d WHERE <code>id</code> = %d", $event->post_id, $event->id));
            foreach ($event->data as $event)
            {
                // TODO: append to $event_list
            }
        }
        else
        {
            $event_list[] = $event;
        }
        // TODO: process event list and update post ids
    }

So, my goal is to extend the possibilities of the plugin by using custom post_types capabilities : post edit, tags, categories, thumbnails...

I'm able to show 'lsevent' post_types in WP Admin with this code (replacing yours) :

register_post_type('lsevent', array(
'label' => 'Lifestream',
'singular_label' => 'Event',
'show_ui' => true,
'public' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'capability_type' => 'post',
'rewrite' => true,
'query_var' => true,
'can_export' => false,
'show_in_nav_menus' => false,
'menu_position' => 4,
'supports' => array('editor', 'title','excerpt', 'custom-fields', 'thumbnail'),
'taxonomies' => array('category', 'post_tag'), // this is IMPORTANT
'_builtin' => false, // It's a custom post type, not built in!
));

But, the problem is that all 'lsevent' post_types are empty (they don't have content), so for the moment it's useless to query them.

So, my question is : How can I do do allow the plugin to import the events contents in the post_types ? The content can be included in the content box and in the title...

With this way of thinking, we will be able to categorize events, for exemple query all events (google reader, tweets...) relative to "WordPress" subject (by tagging evnts with the "WordPress" tag. Usefull !

Thanks a lot for your advices. Anthony (from Paris)