get_results('SELECT * FROM ' . $table_prefix . 'miniblog ' . $identifier_q . ' ' . $sortby_q . ' LIMIT ' . $limit_q); if($results) { $cnt = count($results); for($i = 0; $i < $cnt; $i++) { $results[$i]->blog = stripslashes($results[$i]->blog); $results[$i]->title = apply_filters('the_title', stripslashes($results[$i]->title)); $results[$i]->url = stripslashes($results[$i]->url); if($results[$i]->text) { if ($filter) $results[$i]->text = apply_filters('the_content', stripslashes($results[$i]->text)); else $results[$i]->text = stripslashes($results[$i]->text); } } } else { $results = array(); } return $results; } } /* Simple, beginner-friendly (not to mention smart) version of the above function */ if(!function_exists('miniblog_list_entries')) { function miniblog_list_entries($before = '
  • ', $between = '
    ', $after = '
  • ', $identifier = '', $limit = 5, $offset = 0, $sortby = '_date', $filter = TRUE) { $entries = array(); $entry = ''; $entries = miniblog_return_entries($limit, $offset, $identifier, $sortby, $filter); foreach($entries as $entry) { $date = date("F j, Y", strtotime($entry->date)); echo $before; if ($entry->title && $entry->url) { echo '' . $entry->title . ''; } elseif ($entry->title) { echo $entry->title; } elseif ($entry->url) { echo '' . $date . ''; } else { echo $date; } if(trim($entry->text)) { echo $between; echo str_replace("\n" , '', $entry->text); } echo $after . "\n"; } } } /* Creates the RSS feed URL to use in the href="" tag */ if(!function_exists('miniblog_create_rss_url')) { function miniblog_create_rss_url($limit = 5, $offset = 0, $identifier = '', $sortby = '_date', $title = '%site_name%', $description = '%site_description%') { /* Get the blog URL */ ob_start(); bloginfo('url'); $url = ob_get_clean(); /* Build new URL */ $url = $url . '/wp-content/plugins/' . basename(__FILE__); $url = $url . '?action=rss&n=' . $limit . '&o=' . $offset; $url = $url . '&q=' . htmlentities(urlencode($identifier)) . '&s=' . htmlentities(urlencode($sortby)); $url = $url . '&t=' . htmlentities(urlencode($title)) . '&d=' . htmlentities(urlencode($description)); return $url; } } /* Cooperation with other popular plugins */ if(!function_exists('miniblog_cooperate')) { function miniblog_cooperate() { /* Staticize Reloaded */ if(function_exists('StaticizeClean')) { StaticizeClean(); } } } /* My general purpose variable sanitizer */ if(!function_exists('miniblog_clean_var')) { function miniblog_clean_var(&$var) { return trim(strip_tags(stripslashes($var))); } } /* This code is called when the plugin is viewed from the admin panel */ if(strpos($_SERVER['PHP_SELF'], 'wp-admin') !== FALSE) { if($_GET['page'] == basename(__FILE__)) { /* This function echos the plugin page contents */ if (!function_exists('miniblog_render_plugin_page')) { function miniblog_render_plugin_page($post_date='',$post_blog='',$post_title='',$post_url='',$post_text='', $post_id='') { global $wpdb, $table_prefix; if(!$post_id) $post_id = '-'; if(!$post_blog) $post_blog = 'default'; /* Number of posts to list per page (editing pagination) */ $per_page = 50; ?>
    Write new post | Edit posts | Documentation and Help | Check for Updates | Uninstall

    100)) { $rows = 10; } ?>

    type="button" value="Check Spelling" onClick="openSpellChecker();" />

    1) { $page = $_GET['p']; $page_url = '&p=' . $page; $page_first_num = ($page-1)*$per_page; if(!$page_first_num) $page_first_num = '0'; $page_query = $page_first_num . ',' . ($page+$per_page); } else { $page = 1; $page_url = '&p=' . $page; $page_query = '0,' . ($page+$per_page); } $posts = $wpdb->get_results('SELECT id,blog,title,url FROM ' . $table_prefix . 'miniblog ORDER BY `date` DESC LIMIT ' . $page_query); if($posts) { $_alt = ' class="alternate"'; foreach($posts as $post) { ?> > 1) { $prev_page = $page - 1; $prev_page_url = '&p=' . $prev_page; $next_page = $page + 1; $next_page_num = (($next_page-1)*$per_page); if(!$next_page_num) $next_page_num = '0'; $next_page_query = $next_page_num . ',' . ($next_page+$per_page); } else { $next_page = 2; $next_page_query = $per_page . ',' . ($next_page+$per_page); } /* Find out if there are more entries on the next page */ $are_more = $wpdb->get_results('SELECT id FROM ' . $table_prefix . 'miniblog LIMIT ' . $next_page_query); if(count($are_more)) { if(is_numeric($are_more[0]->id)) $next_page_url = '&p=' . $next_page; } ?>

    « Previous Next »

    id); ?> blog)); ?> title)); ?> url)); ?>

    Welcome to Miniblog! Make sure you have the latest version, or it may not work with your version of WordPress.

    Miniblog is a plugin for Wordpress 1.5+ (and maybe lower). It is:

    Help on adding items to, editing, or deleting items from the database.

    The Title is simply the title of the item you wish to post.

    This field is designated as a URL for link blogging, but it can be used for any purpose, as it is not required to input a hyperlink.

    This field may not seem self explanatory at first, but it's really just a way to organize one's postings. The default entry is "default," so if one never changed the field, all posts would fall under this one category.

    An example use of this is to separate your link blog from your asides. For every link blog entry made, one would change this field to "link." For every aside entry made, one would change this field to "aside." This is done so that they can later be called separately in templates.

    This field doesn't appear the first time you publish an entry. To get it, you must save the entry and edit it via the list. All it does is allow you to change the date or time of the post. The format is Year-Month-Day Hour:Minute:Second (military time).

    This field is the content of the entry. It is passed through the_content's filters.

    This section demonstrates how one can use the entries saved in their templates.

    This function is a beginner friendly version of miniblog_return_entries(). It has default formatting that is changeable and tries to keep in cahoots with other WordPress list functions.

    The function is designed to be smart. If you have no title or url, it displays the date. If you have a title and no URL, it displays the title with no link. If you have a URL and no title, it uses the date as the href title. If you have no entry text, it skips the between parameter and displays nothing as a description.

    Parameters:

    1. Before: text to display before every entry's title link. Default is '<li>'.
    2. Between: text to display between every entry's title link and text. Default is '<br />'.
    3. After: text to display after every entry's text. Default is '</li>'.
    4. Blog Identifier: this determines which entries to call specificied by an entry's "Blog Identifier" field. This can be any text string. To retrieve all field, leave blank (''). Default is blank ('').
    5. Limit: the number of entries to return. Default is 10.
    6. Offset: the number of entries to skip before returning. For instance, a limit of 5 with an offset of 5 will return entries 6 through 10. Default is 0.
    7. Sort Field: this is the field that determines the order in which entries are returned. Prepending an underscore (_) to the parameter sorts the entries descending (latest first) as opposed to ascending (earliest first).

      Options:

      • ID - an entry's ID (unique).
      • Date - the date the entry was posted.
      • Blog - the entry's blog identifier field.
      • Title - the entry's title.
      • URL - the entry's URL.
      • Text - the entry's text.
      Default is '_date.'

    8. Filter Text: this boolean option determines rather or not to filter the entry's text through the_content's filters. This is useful to set to false if you want to use ad plugins that apply a filter to the_content to show relevant ads. Default is FALSE.

    Examples:

    <h2>Asides</h2>
    <ul>
        <?php miniblog_list_entries(); ?>
    </ul>

    This will output the latest 5 entries in a simple list that makes up of only the title and the text separated with a line break.

    <h2>Asides</h2>
    <
    ul>
        
    miniblog_list_entries('<li><strong>', '</strong><blockquote>', '</blockquote></li>', 'aside', 10);
    </
    ul>

    This will output the latest 10 entries with the blog identifier of 'aside' and display them in a list that will resemble this:

    This function returns a set of entries into an array of arrays containing entry data.

    Parameters:

    1. Limit: the number of entries to return. Default is 10.
    2. Offset: the number of entries to skip before returning. For instance, a limit of 5 with an offset of 5 will return entries 6 through 10. Default is 0.
    3. Blog Identifier: this determines which entries to call specificied by an entry's "Blog Identifier" field. This can be any text string. To retrieve all field, leave blank (''). Default is blank ('').
    4. Sort Field: this is the field that determines the order in which entries are returned. Prepending an underscore (_) to the parameter sorts the entries descending (latest first) as opposed to ascending (earliest first).

      Options:

      • ID - an entry's ID (unique).
      • Date - the date the entry was posted.
      • Blog - the entry's blog identifier field.
      • Title - the entry's title.
      • URL - the entry's URL.
      • Text - the entry's text.
      Default is '_date.'

    5. Filter Text: this boolean option determines rather or not to filter the entry's text through the_content's filters. This is useful to set to false if you want to use ad plugins that apply a filter to the_content to show relevant ads. Default is FALSE.

    The array for each entry contains an object that can be accessed by calling the following methods.

    Examples:

    <?php
        $asides
    = miniblog_return_entries(5, 0, '', 'Title');
        foreach(
    $asides as $aside) { ?>
            <li><?php _e($aside->title); ?><br /><?php _e($aside->text); ?></li>
    <?php } ?>

    This will output the latest 5 entries in a simple list that makes up of only the title and the text separated with a line break.

    <?php
        $news_array
    = miniblog_return_entries(15, 0, 'news', '_date');
        if(
    $news_array) {
            foreach(
    $news_array as $news) { ?>
                <div class="post">
                    <h2>
                        <a href="<?php _e($news->url); ?>">
                         <?php _e($news->title); ?>
                        </a>
                    </h2>
                    <div class="meta">
                        Posted on <?php _e(date("F j, Y, g:i a", strtotime($news->date))); ?>
                    </div>
                    <div class="content">
                        <?php _e($news->text); ?>
                    </div>
                </div>
            <? }
        }
    ?>

    This will output the latest 15 entries with the string 'news' in their blog identifier field and outputs them in a format much like Wordpress's default output style.

    This function returns a URL to an RSS feed specified by the parameters entered. The parameters are exactly the same as the parameters of miniblog_return_entries() with two note-worthy exceptions:

    1. Limit...
    2. Offset: ...
    3. Blog Identifier: ...
    4. Sort Field: ...
    5. RSS Feed Title: this field determines the title of the RSS feed. Default is %site_name%
    6. RSS Feed Description: this field determines the description of the RSS feed. Default is %site_description%.

    The two new fields can have the following template tags within them:

    Examples:

    <a href="<?php _e(miniblog_create_rss_url()); ?>">Miniblog RSS</a>

    This example will simply display the latest 5 miniblog entries that you've posted with your site's title and description as the feed's description.

    <h2>Asides</h2>
    <ul>
        <?php
        $asides
    = miniblog_return_entries(5, 0, 'aside', '_Date');
        foreach(
    $asides as $aside) { ?>
            <li>
                <span><a href="<?php _e($aside->url); ?>"><?php _e($aside->title); ?></a></span>
                <?php _e($aside->text); ?>
            </li>
        <?php } ?>
    </ul>
    <?php $feed_url = miniblog_create_rss_url(5, 0, 'aside', '_Date'); ?>
    <p id="asidefeed">
        <a href="<?php _e($feed_url); ?>">rss</a>
    </p>

    This example is what I use on my index page to show asides. Notice at the bottom how I use the miniblog_create_rss_url().

    <a href="<?php _e(miniblog_create_rss_url(5, 0, 'aside', '_date', "%site_name%'s Asides", "%site_name% (%site_description%) has asides. These are them.")); ?>">Miniblog RSS</a>

    This example will output an RSS feed link with the title of "nmyworld's asides" and a description of "nmyworld (Just another WordPress blog) has asides. These are them." Your blog will show different results (because your blog has different settings).

    To remove the table from the database, do it manually or enter the string "Remove Thyself" (case sensitive) in the box below and press submit.

    query('CREATE TABLE IF NOT EXISTS `' . $table_prefix . 'miniblog` ( `id` bigint(20) unsigned NOT NULL auto_increment, `date` datetime NOT NULL default \'0000-00-00 00:00:00\', `blog` text NOT NULL, `title` text NOT NULL, `url` text NOT NULL, `text` text NOT NULL, FULLTEXT (`blog`), PRIMARY KEY (`id`))'); /* If the user requested to uninstall */ if($_POST['delstring'] == 'Remove Thyself') { $wpdb->query('DROP TABLE `' . $table_prefix . 'miniblog`'); ?>

    The Miniblog table has been deleted from the MySQL database. To finish uninstalling the plugin, deactivate it from the "Plugins" menu and delete the file from the plugins directory.

    get_results('SELECT * FROM ' . $table_prefix . 'miniblog WHERE id=' . $id . ' LIMIT 1'); if ($entry) { $entry = $entry[0]; if($entry->date) $post_date = stripslashes($entry->date); if($entry->blog) $post_blog = stripslashes($entry->blog); if($entry->title) $post_title = stripslashes($entry->title); if($entry->url) $post_url = stripslashes($entry->url); if($entry->text) $post_text = stripslashes($entry->text); if($entry->id) $post_id = stripslashes($entry->id); miniblog_render_plugin_page($post_date,$post_blog,$post_title,$post_url,$post_text,$post_id); } else { ?>

    Post not found.

    query('UPDATE ' . $table_prefix . 'miniblog SET date="' . mysql_escape_string($_POST['date']) .'", blog="' . mysql_escape_string($_POST['blog']) .'", title="' . mysql_escape_string($_POST['title']) .'", url="' . mysql_escape_string($_POST['url']) .'", text="' . mysql_escape_string($_POST['content']) . '" WHERE id=' . $_POST['id'])) { ?>

    Unable to update entry.

    Entry successfully updated

    query('INSERT INTO ' . $table_prefix . 'miniblog SET date=NOW(), blog="' . mysql_escape_string($_POST['blog']) .'", title="' . mysql_escape_string($_POST['title']) .'", url="' . mysql_escape_string($_POST['url']) .'", text="' . mysql_escape_string($_POST['content']) . '"')) { ?>

    Unable to add entry.

    Entry successfully added.

    query('DELETE FROM ' . $table_prefix . 'miniblog WHERE id=' . $_GET['id'])) { ?>

    Unable to delete entry.

    Entry successfully deleted.

    $v) $_GET[$k] = stripslashes($v); foreach($_POST as $k => $v) $_POST[$k] = stripslashes($v); } /* Call up the WordPress configuration stuff */ $wordpress_dir = dirname(dirname(dirname(__FILE__))); if (!file_exists($wordpress_dir . '/wp-config.php')) { die('Can\'t load wp-config.php (located in "' . $wordpress_dir . '"). You must put this plugin in your plugins directory ("/wordpress/wp-content/plugins/").'); } require_once($wordpress_dir . '/wp-config.php'); /* RSS display */ if($_GET['action'] == 'rss') { /* Get the blog name and description (stupid stupid WordPress making me do this) */ ob_start(); bloginfo('name'); $blog_name = ob_get_clean(); ob_start(); bloginfo('description'); $blog_description = ob_get_clean(); /* Return to sanity */ $number = $_GET['n']; $offset = $_GET['o']; $blog_term = htmlspecialchars(urldecode($_GET['q'])); $sort_by = htmlspecialchars(urldecode($_GET['s'])); $title = htmlspecialchars(urldecode($_GET['t'])); $description = htmlspecialchars(urldecode($_GET['d'])); /* Parse custom tags */ $title = str_replace('%site_name%', $blog_name, $title); $description = str_replace('%site_name%', $blog_name, $description); $title = str_replace('%site_description%', $blog_description, $title); $description = str_replace('%site_description%', $blog_description, $description); /* Clean the variables */ $varstoclean = array(&$number, &$offset, &$blog_term, &$sort_by, &$title, &$description); foreach($varstoclean as $varname) { $varname = miniblog_clean_var($varname); } /* Render the RSS */ header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true); echo "\n"; echo "\n"; echo "\t\n"; echo "\t\t" . miniblog_clean_var($title) . "\n"; echo "\t\t"; bloginfo('url'); echo "\n"; echo "\t\t" . miniblog_clean_var($descriptions) . "\n"; echo "\t\thttp://backend.userland.com/rss092\n"; $entries = miniblog_return_entries($number, $offset, $blog_term, $sort_by, FALSE); foreach($entries as $entry) { echo "\t\t\n"; echo "\t\t\t" . miniblog_clean_var($entry->title) . "\n"; echo "\t\t\t" . miniblog_clean_var($entry->text) . "\n"; echo "\t\t\t" . miniblog_clean_var($entry->url) . "\n"; echo "\t\t\n"; } echo "\t\n"; echo ""; } } } /* Add the menu item */ if(!function_exists('miniblog_menu')) { function miniblog_menu () { add_submenu_page('post.php', 'Miniblog', 'Miniblog', 9, basename(__FILE__), 'miniblog'); } } if(function_exists('add_action')) add_action('admin_menu', 'miniblog_menu'); ?>