老项无情卸磨杀驴 小紫姑娘冤魂不散
2008-11-28 13:48:09 pdx, wordpress, 万蝶
找来找去,也找不到改的东西都在哪了.
这两个,是关于评论回复的修改.
原理是:
访客评论直接做一般显示,用一个<textarea>写回复,提交后,直接把回复内容用<blockquote>容器包裹附在原评论后面存入数据库。
再次修改回复时,要以<blockquote>为分隔分离原评论和回复.
这个分离折磨了我好几天,搞的点点都不理我了,恰好被我翻到WP-T-WAP的作者Neot大侠的老巢,请教一番,终于开窍,找到问题所在.
特地声明:
这个主意不是剽窃万蝶的,是当初老项想要评论回复,又不想改变数据库结构,找我想的办法.
我也不想改变数据库结构,所以把这个方法又拿回来.
~~~~~~~~~~~~~~
老项无情卸磨杀驴 小紫姑娘冤魂不散
老项对不起本少爷!
所以本少爷要反攻!
老项总说,本少爷总是居功自傲.那好吧,我要你感谢了吗?我是不是说过,不要没事就发个公告感谢我?
不说这些,就算我没帮过你任何忙.
可是你对我公平吗?
就是因为熟,本少爷成了可以随便牺牲的弃子.
小紫姑娘爱老项,本少爷也不过分,就是恶心老项一下子了.
准备拿回密码以后,把我的PDX首页改成这个样子.
http://thirteen.com.cn/tools/bt.html
图在这里看不到,老项总算把防盗链弄明白了.
结构大概是这样,照片以下的几个模块,横向位置随机滑动,当然我还没弄明白.
照片是Keylo处理的,我最喜欢的两张照片合成,飞翔的鸟人和烂仔造型.我要加上恶魔的漆黑翅膀和角,够老项恶心的了.
NND,这两张照片里穿的还是本少爷亲自设计,制作,销售的万蝶文化衫呢,小紫姑娘真够爱老项的了.
另外,现在的背景图.也是Keylo处理出来的.
~~~~~~~~~~~~~~
Worepress 的WAP插件 WP-T-WAP
本来这个想单独写一篇介绍的,但词穷,又不想很少字就发.
下载介绍都在这里:
http://www.tanggaowei.com/2008/01/04/7.html
如果想和WWW样式统一,自己动手改个样式什么的,很容易.
本少爷BT,想要多个样式,所以自己弄双栖自适应.
但改的过程中,WAP基本就是参照WP-T-WAP来的.
本少爷的背景图是专用的,所以大不可能把模板贡献出来.
那么,WP-T-WAP绝对是最好的选择.
另外也有别的WAP插件,那个2个文件的,忘了叫什么了,太简单,而且是WAP1.1.
还有个,是双栖自适应的,但WAP上,有折行问题,而且忽而WWW忽而WAP,适应的显示不佳.
嗯,万蝶的WAP2.0模板折行问题也是我解决的.
~~~~~~~~~~~~~~
我的双栖自适应模板
正式介绍一下.
本以为是很难的东西,结果单只是前台的显示,只用了不到12小时就改好了.
电脑,智能手机默认进WWW版,其它默认进WAP版.
每一页都可以随意切换WWW/WAP.
智能手机那里可能有遗漏,因为我没有那么多智能手机来看UA,反正我的熟人也就那么几个,都在symbian/wm了.
由此知道了,PHP很强大,而且没想像的难.
所以,仿照plurk的插件,写了自己的.
暂时放这,我要拿回万蝶用的.
~~~~~~~~~~~~~~
wp-includesgeneal-template.php(929):
$rows = get_option($apos;default_post_edit_rows$apos;);
if (($rows < 3) || ($rows > 100))
$rows = 12;
	$rows = $quot;rows=$apos;$rows$apos;$quot;;	?>
	<div id=$quot;editor-toolbar$quot;>
	<?php if ( user_can_richedit() ) {
		$wp_default_editor = wp_default_editor(); ?>
		<div class=$quot;zerosize$quot;><input accesskey=$quot;e$quot; type=$quot;button$quot; onclick=$quot;switchEditors.go($apos;<?php echo $id; ?>$apos;)$quot; /></div>
		<?php if ( $apos;tinymce$apos; == $wp_default_editor ) {
			add_filter($apos;the_editor_content$apos;, $apos;wp_richedit_pre$apos;); ?>
			<a id=$quot;edButtonHTML$quot; onclick=$quot;switchEditors.go($apos;<?php echo $id; ?>$apos;);$quot;><?php _e($apos;HTML$apos;); ?></a>
			<a id=$quot;edButtonPreview$quot; class=$quot;active$quot;><?php _e($apos;Visual$apos;); ?></a>
		<?php } elseif ( $apos;html$apos; == $wp_default_editor ) {
			add_filter($apos;the_editor_content$apos;, $apos;wp_htmledit_pre$apos;); ?>
			<a id=$quot;edButtonHTML$quot; class=$quot;active$quot;><?php _e($apos;HTML$apos;); ?></a>
			<a id=$quot;edButtonPreview$quot; onclick=$quot;switchEditors.go($apos;<?php echo $id; ?>$apos;);$quot;><?php _e($apos;Visual$apos;); ?></a>
		<?php }
	}
	if ( $media_buttons ) { ?>
		<div id=$quot;media-buttons$quot; class=$quot;hide-if-no-js$quot;>
		<?php do_action( $apos;media_buttons$apos; ); ?>
		</div>
	<?php } ?>
	</div>
<?php if ( strstr($_SERVER[$apos;PHP_SELF$apos;], $apos;comment.php$apos;) ) {
	$content_old = $apos;$apos;;
	if ( strstr($content, $apos;blockquote$apos;) ) {
		$content_old = preg_replace($quot;$apos;<blockquote.*$apos;si$quot;, $quot;$quot;, $content);
		$content_reply = preg_replace($quot;$apos;.*Reply :<br />$apos;is$quot;, $quot;$quot;, $content);
		$content_reply = str_replace($quot;</blockquote>$quot;, $quot;$quot;, $content_reply);
		}
		else {
		$content_old = $content;
		$content_reply = $quot;$quot;;
		}
?><div><blockquote>
<?php echo $content_old; ?>
</blockquote><textarea class=$apos;$apos;style=$quot;display:none$quot; name=$apos;content_old$apos;><?php echo $content_old; ?></textarea></div>
<?php } else {
	$content_old = $quot;$quot;;
	$content_reply = $content;
}?>
	<div id=$quot;quicktags$quot;>
	<?php wp_print_scripts( $apos;quicktags$apos; ); ?>
	<script type=$quot;text/javascript$quot;>edToolbar()</script>
	</div>
    <?php if ( $apos;html$apos; != $wp_default_editor ) : ?>
    <script type=$quot;text/javascript$quot;>
    // <![CDATA[
        if ( typeof tinyMCE != $quot;undefined$quot; )
            document.getElementById($quot;quicktags$quot;).style.display=$quot;none$quot;;
    // ]]>
    </script>
    <?php endif; // $apos;html$apos; != $wp_default_editor
	$the_editor = apply_filters($apos;the_editor$apos;, $quot;<div id=$apos;editorcontainer$apos;><textarea class=$apos;$apos; $rows cols=$apos;40$apos; name=$apos;$id$apos; tabindex=$apos;$tab_index$apos; id=$apos;$id$apos;>%s</textarea></div>
$quot;);
	$the_editor_content = apply_filters($apos;the_editor_content$apos;, $content_reply);
printf($the_editor, $the_editor_content);
	?>
    <script type=$quot;text/javascript$quot;>
    // <![CDATA[
    edCanvas = document.getElementById($apos;<?php echo $id; ?>$apos;);
    <?php if ( $prev_id && user_can_richedit() ) : ?>
    // If tinyMCE is defined.
    if ( typeof tinyMCE != $apos;undefined$apos; ) {
    // This code is meant to allow tabbing from Title to Post (TinyMCE).
        document.getElementById($apos;<?php echo $prev_id; ?>$apos;).onkeydown = function (e) {
            e = e || window.event;
            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
                if ( tinyMCE.activeEditor ) {
                    if ( (jQuery($quot;#post_ID$quot;).val() < 1) && (jQuery($quot;#title$quot;).val().length > 0) ) { autosave(); }
                    e = null;
                    if ( tinyMCE.activeEditor.isHidden() ) return true;
                    tinyMCE.activeEditor.focus();
                    return false;
                }
                return true;
            }
        }
    }
    <?php endif; ?>
    // ]]>
    </script>
    <?php
}
wp-adminincludescomment.php(10)
global $wpdb, $user_login, $post;
$comment_post_ID = (int) $_POST['comment_post_ID'];
	if (!current_user_can( 'edit_post', $comment_post_ID ))
		wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
	$_POST['comment_author'] = $_POST['newcomment_author'];
	$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
	$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
	$_POST['comment_approved'] = $_POST['comment_status'];
	$_POST['comment_content'] = $_POST['content_old'] . '<blockquote>' . $user_login .' Reply :<br />' . $_POST['content'] . '</blockquote>';
	$_POST['comment_ID'] = (int) $_POST['comment_ID'];
	foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
		if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
			$_POST['edit_date'] = '1';
			break;
		}
	}
	if (!empty ( $_POST['edit_date'] ) ) {
		$aa = $_POST['aa'];
		$mm = $_POST['mm'];
		$jj = $_POST['jj'];
		$hh = $_POST['hh'];
		$mn = $_POST['mn'];
		$ss = $_POST['ss'];
		$jj = ($jj > 31 ) ? 31 : $jj;
		$hh = ($hh > 23 ) ? $hh -24 : $hh;
		$mn = ($mn > 59 ) ? $mn -60 : $mn;
		$ss = ($ss > 59 ) ? $ss -60 : $ss;
		$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
	}
$posts = get_post($comment_post_ID);
$mail_subject = '来自 ' . get_option('blogname') . ' 的对话' ;
$mail_message = '您在“' . $posts->post_title . '’的评论有了回复: ';
$mail_message .= "
您的评论:
" . $_POST['content_old'] . "
新的回复:
" . $_POST['content'] . "
现在就查看:
";
$mail_message .= get_option('siteurl') . '/archives/' . $comment_post_ID . '.html#comment-' . $_POST['comment_ID'];
@wp_mail($_POST['comment_author_email'], $mail_subject, $mail_message, '');
	wp_update_comment( $_POST);
}
回复邮件的那里用了中文,所以整个PHP文件,要转成utf-8编码.
我试了用&#****;的格式写中文,但邮件里仍显示&#****;
WordPresswp-adminpage-new.php(6): wp_enqueue_script('autosave');
Wordpresswp-adminpage.php(95):    wp_enqueue_script('autosave');
Wordpresswp-adminpost-new.php(6): wp_enqueue_script('autosave');
Wordpresswp-adminpost.php(102):    wp_enqueue_script('autosave');
Wordpresswp-adminadmin-header.php(123): <title><?php echo wp_specialchars( strip_tags( $title ) ); ?> › <?php bloginfo('name') ?> — WordPress</title>
2008-11-28 13:48 By : thirteen (plurk,相册)
Permalink : http://13jl.com/1038611.html
1 Comment so far
你写的文章我都看不懂。呵呵。