zhuangb_comments`(`commentid` INT( 20 ) NOT NULL ,`postid` INT( 20 ) NOT NULL ,`zhuangbid` INT( 5 ) NOT NULL ,PRIMARY KEY ( `commentid` ))", $wpdb->dbh) or die(mysql_error() . ' on line: ' . __LINE__);
if (!$result) {
return false;
}
return true;
}
}
/*
creat table zhuangb_comments.
*/
function zhuangb_init() {
global $wpdb, $wpzhuangb;
$wpdb->zhuangb_comments = $wpdb->prefix . 'zhuangb_comments';
$wpzhuangb = new wp_zhuangb;
$result = mysql_list_tables(DB_NAME);
$tables = array ();
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
if (!in_array($wpdb->zhuangb_comments, $tables)) {
$wpzhuangb->install();
}
}
/*
add js&&css
*/
add_action('wp_head', 'zhuangb_css_js');
function zhuangb_css_js() {
echo "\n" . '' . "\n";
if (@ file_exists(TEMPLATEPATH . '/jquery-1.2.6.pack.js')) {
echo '' . "\n";
wp_print_scripts('jquery');
echo '' . "\n";
echo '' . "\n";
} else {
echo '' . "\n";
wp_print_scripts('jquery');
echo '' . "\n";
echo '' . "\n";
}
echo '' . "\n";
}
/*
add post
*/
add_filter('the_content', 'zhuangb_post_add', 0);
//add_filter('the_excerpt', 'wp_syntax_before_filter', 0);
function zhuangb_post_add($content) {
global $zhuangb_post_out;
preg_match_all("/\[zhuangb(.+)\]/siU", $content, $results, PREG_SET_ORDER);
if ($results) {
foreach ($results as $item) {
$zhuangbtag = $item[0];
//echo $item[0];
preg_match_all("/\[zhuangb\s*event=\"(.*)\"\s*id=\"(.*)\"\s*title=\"(.*)\"\s*\]/siU", $zhuangbtag, $resultstags, PREG_SET_ORDER);
if ($resultstags) {
foreach ($resultstags as $itemtags) {
$zhuangbevent = $itemtags[1];
$zhuangbid = $itemtags[2];
$zhuangbtitle = $itemtags[3];
$out = "
" . $zhuangbtitle . "[!!]";
$out .= "