Plugin Directory

Changeset 201255


Ignore:
Timestamp:
02/03/2010 02:47:10 AM (16 years ago)
Author:
zeeg
Message:

Lifestream now injects, or uses an existing page for its home template.

Location:
lifestream/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lifestream/trunk/inc/core.php

    r199288 r201255  
    528528        'links_new_windows' => '0',
    529529        'truncate_interval' => '0',
     530        'page_id'           => '',
    530531    );
    531532   
     
    685686    function is_lifestream_home()
    686687    {
    687         global $wp_query;
    688 
    689         return (@$_GET['cp'] == 'lifestream');
     688        global $wp_query, $post;
     689       
     690        return (is_page() && $post->ID == $this->get_option('page_id'));
    690691    }
    691692
     
    16691670    function install($allow_database_install=true)
    16701671    {
     1672        global $wpdb, $userdata;
     1673
    16711674        $version = (string)$this->get_option('_version', 0);
    16721675
     
    17021705        $this->add_option('theme_dir', WP_CONTENT_DIR.'/wp-lifestream/themes/');
    17031706        $this->add_option('icon_dir', WP_CONTENT_DIR.'/wp-lifestream/icons/');
     1707       
     1708        if (!$this->get_option('page_id'))
     1709        {
     1710            get_currentuserinfo();
     1711           
     1712            // First let's see if they have a legacy page:
     1713           
     1714            $results = $wpdb->get_results($wpdb->prepare("SELECT `ID` FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'page' AND `post_content` LIKE '%%[lifestream]%%' AND `post_author` = %d AND `post_status` != 'trash' LIMIT 2", $userdata->ID));
     1715            if (count($results) == 2)
     1716            {
     1717                // Now we're in trouble
     1718            }
     1719            elseif (count($results) == 1)
     1720            {
     1721                $this->update_option('page_id', $results[0]->ID);
     1722            }
     1723            else
     1724            {
     1725
     1726                $post = array(
     1727                    'post_title' => 'Lifestream',
     1728                    'post_content' => 'This is just a placeholder for your Lifestream. You may modify the title, categories, and anything else, but the page\'s content has no effect on your Lifestream.',
     1729                    'post_status' => 'publish',
     1730                    'post_author' => $userdata->ID,
     1731                    'post_type' => 'page',
     1732                    // should we insert the feed types into the tags?
     1733                    // 'tags_input' => ''
     1734                );
     1735                $post_id = wp_insert_post($post);
     1736                $this->update_option('page_id', $post_id);
     1737            }
     1738        }
    17041739       
    17051740        if (version_compare($version, LIFESTREAM_VERSION, '=')) return;
  • lifestream/trunk/templates/home.php

    r200909 r201255  
    55
    66    <h2><?php $lifestream->_e('Lifestream'); ?></h2>
    7 
     7    <?php
     8    /* TODO this should be the page text
     9    <div class="entry">
     10        <p>This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.</p>
     11    </div>
     12    */
     13    ?>
     14   
     15   
    816    <div class="navigation">
    917        <div class="alignleft"><?php ls_prev_page('&laquo; %link') ?></div>
Note: See TracChangeset for help on using the changeset viewer.