Miniblog-COMPAT - Designed specificaly for Wordpress 2.1 only. Please do not try to enable this version if you have Wordpress 2.0.7 or below. Allows miniature blogs, links, notes, asides, or whatever to be created. The menu, functionality, and documentation can be found in the Write : Miniblog menu once the plugin is activated. Previous developer Thomas Cort.
Version: 0.16-COMPAT
Author: Joe
Author URI: http://blog.fileville.net/
*/
/* Copyright 2006 Joe (ttech5593@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Edit Only If Needed */
define("DREAMHOST", "FALSE");
/* Please do not edit below this point... */
/* We always want to load these */
if(!function_exists('miniblog_return_entries')) {
function miniblog_return_entries($limit = 5, $offset = 0, $identifier = '', $sortby = '_date', $filter = TRUE, $full = 1, $limitperblog= 0) {
global $wpdb;
if(!is_numeric($offset)) {
$offset = 0;
}
if(!is_numeric($limit) || $limit < 2) {
$limit = 4;
}
if($identifier == 'all') {
$identifier = '';
}
if(!is_numeric($limitperblog)) {
$limitperblog = 0;
}
$limit_q = $offset . ',' . $limit;
$identifier_q = '';
if($identifier) {
if(stristr($identifier, '%') !== FALSE) {
$identifier_q = 'WHERE blog LIKE \'' . $identifier . '\'';
} else {
$identifier_q = 'WHERE blog="' . $identifier . '"';
}
}
/* Sort ordering */
$sort_o = '` ASC';
if (substr($sortby, 0, 1) == '_') {
$sort_o = '` DESC';
$sortby = substr($sortby, 1);
}
$sortby_q = 'ORDER BY `' . $sortby;
$sortby_q .= $sort_o;
/* We can either show the most recent in each blog
or show everything. Group By is just that way.
The subquery table pre-sorts the data so that
the Group By can pick up rows in the desired order. */
if(!empty($identifier) AND $limitperblog == 0) {
// If $identifier is not empty and $limitperblog is 0
$query = 'SELECT * FROM ' . $wpdb->prefix .
'miniblog ' . $identifier_q . ' ' . $sortby_q .
' LIMIT ' . $limit_q;
//$query = 'SELECT * FROM `' . $wpdb->prefix . 'miniblog` '.$identifier_q.' LIMIT '.$limit_q.'';
} else {
// If $identifier is empty and $limitperblog is 0 or a number
$query = 'SELECT * FROM '.$wpdb->prefix.'miniblog '
. ( $limitperblog ? ' GROUP BY `blog`' : '' )
. ' ' . $sortby_q . ' LIMIT ' . $limit_q;
}
$results = $wpdb->get_results($query);
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 (preg_match('/\[readon\]/',$results[$i]->text) && $full == 0) {
$parts = preg_split('/\[readon\]/',$results[$i]->text);
$results[$i]->text = $parts[0] . '... read on.';
} else if ($full == 1) {
$results[$i]->text = preg_replace('/\[readon\]/','',$results[$i]->text);
}
if ($filter == 'ON') {
$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 = '
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 `' . $wpdb->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`)) ENGINE=MYISAM');
/* If the user requested to uninstall */
if($_POST['delstring'] == 'Remove Thyself') {
$wpdb->query('DROP TABLE `' . $wpdb->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_footer();
}
}
}
/* Add the menu item */
if(!function_exists('miniblog_menu')) {
function miniblog_menu () {
add_submenu_page('post.php', 'Miniblog', 'Miniblog', 9, basename(__FILE__), 'miniblog');
}
}
/* Add what we need to the Wordpress admin area header */
if(!function_exists('miniblog_header')) {
function miniblog_header($switch=0) {
if(stristr($_SERVER['REQUEST_URI'], "miniblog")) {
if(user_can_richedit()) {
$site_url = get_settings('siteurl');
/* If your having problem just comment the line below out */
$site_url = $site_url;
$opt = ($switch == 1) ? "?ver=20061113" : "";
echo "\n";
}
echo "\n";
}
}
}
if(function_exists('add_action')) {
add_action('admin_menu', 'miniblog_menu');
add_action('admin_head', 'miniblog_header');
}
?>