wp-codebox, wp-openid 버그 패치

wp-codebox의 경우 jquery 를 사용하는 다른 플러그인과 함께 사용할 경우 jquery를 두 번 호출하게 되어 자바스크립트 에러를 발생시킵니다.

script를 wp_enqueue_script를 사용해서 삽입하지 않고, 직접 삽입을 하기 때문에 발생하는 문제인데, 아래 패치를 적용하면 문제를 일으키지 않습니다.

diff -urN wp-codebox_org/main.php wp-codebox/main.php
--- wp-codebox_org/main.php	2008-12-27 08:52:10.000000000 +0900
+++ wp-codebox/main.php	2009-01-29 22:47:24.525402649 +0900
@@ -1,15 +1,22 @@
 <?php 
 
 // function for head output sytles
+function codebox_init() {
+	global $cb_path;
+	
+	//URL to the plugin directory
+	$cb_path = WP_PLUGIN_URL."/wp-codebox";	
+	
+	wp_enqueue_script( 'jquery' );
+	wp_enqueue_script( 'wp-codebox', $cb_path."/js/codebox.js", FALSE, 1.3 );
+}
 function codebox_header() {
 	global $cb_path;
-	$cb_path = get_bloginfo('wpurl')."/wp-content/plugins/wp-codebox";	//URL to the plugin directory
-	$hHead = "\n"."<!-- Start Of Script Generated By CodeBox -->"."\n";
-	$hHead .= "	<link rel=\"stylesheet\" href=\"{$cb_path}/css/codebox.css\" type=\"text/css\" media=\"screen\" />\n";
-	$hHead .= "	<script language=\"javascript\" type=\"text/javascript\" src=\"".get_bloginfo('wpurl')."/wp-includes/js/jquery/jquery.js\"></script>\n";
-	$hHead .= "	<script language=\"javascript\" type=\"text/javascript\" src=\"{$cb_path}/js/codebox.js\" ></script>\n";
-	$hHead .= "<!-- End Of Script Generated By CodeBox -->"."\n";
-	print($hHead);
+
+	echo '
+	<link rel="stylesheet" type="text/css" href="'.$cb_path.'/css/codebox.css" media="screen" />
+	';
+	
 }
 
 // function for admin head output only
@@ -170,4 +177,4 @@
   $agent = $_SERVER['HTTP_USER_AGENT'];
   return eregi("win", $agent) && eregi("msie",$agent) && !eregi("opera",$agent);
 }
-?>
\ No newline at end of file
+?>
diff -urN wp-codebox_org/wp-codebox.php wp-codebox/wp-codebox.php
--- wp-codebox_org/wp-codebox.php	2008-12-27 08:52:10.000000000 +0900
+++ wp-codebox/wp-codebox.php	2009-01-29 22:40:01.649298169 +0900
@@ -64,6 +64,7 @@
 }
 
 // output to the <head> section of the page
+add_action('init', 'codebox_init');
 add_action('wp_head', 'codebox_header');
 
 /**

그리고 wp-openid의 경우 page와 함께 사용하는 것을 고려하지 않고 있기 때문에 page에 코멘트를 남길 수 있도록 해놓은 경우에 자바스크립트 에러를 발생시킵니다.

이 부분은 common.php의 991번째 줄 정도를 다음과 같이 수정하면 해결할 수 있습니다.

function openid_js_setup() {
    // if (is_single() || is_comments_popup() || is_admin()) {
    if (is_single() || is_comments_popup() || is_admin() || is_page()) {

원 저작자들에게 메일을 보내놓기는 했는데, 적용이 언제쯤 될지는 잘 모르겠네요. :)

Related Posts

This entry was posted by 정태영 on Thursday, January 29th, 2009 at 5:45 PM and is taged under , , , , , , , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “wp-codebox, wp-openid 버그 패치”

  1. kukie says:

    내 덕분에 고친거지? 응?응?!

Leave a Reply

믹시