2016-05-08 12 views
1

アスタリスク(*)のみをウェブサイトのフィールドから削除して、WordPressウェブサイトのコメントフォームに不要にします。アスタリスクを他のフィールドに置いても問題ありません。ここでcomments.phpからのコードは次のとおりです。コメントフォームに必要なアスタリスクをウェブサイトから削除する

<?php 
 
\t // Do not delete these lines 
 
\t if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) 
 
\t \t die ('Please do not load this page directly. Thanks!'); 
 
\t 
 
\t $comments_by_type = separate_comments($comments); 
 
?> 
 

 
<div id="comments" class="comments-wrap"> 
 
    
 
\t <?php if (post_password_required()): ?> 
 
\t \t <p class="nopassword"><?php _e('This post is password protected. Enter the password to view any comments.', 'gummfw'); ?></p> 
 
\t \t </div><!-- #comments --> 
 

 
\t <?php 
 
\t \t return; 
 
\t \t endif; 
 
\t ?> 
 
\t 
 
\t <?php if (have_comments() && comments_open()): ?> 
 
     <div class="bluebox-heading-wrap"> 
 
      <h3 class="bluebox-heading"><?php comments_number(__('No Comments', 'gummfw'), __('One Comment', 'gummfw'), __('% Comments', 'gummfw'));?></h3> 
 
     </div> 
 
     
 
     <ol class="comment-list"> 
 
      <?php 
 
      wp_list_comments(array(
 
       'callback' => array(
 
        GummRegistry::get('Controller', 'Comments'), 
 
        'view' 
 
       ), 
 
      )); 
 
      ?> 
 
     </ol> 
 

 
\t \t <?php if (get_comment_pages_count() > 1 && get_option('page_comments')): // Are there comments to navigate through? ?> 
 
\t \t \t <div class="navigation"> 
 
\t \t \t \t <div class="nav-previous"> 
 
\t \t \t \t \t <?php previous_comments_link(__('<span class="meta-nav">&larr;</span> Older Comments', 'gummfw')); ?> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div class="nav-next"> 
 
\t \t \t \t \t <?php next_comments_link(__('Newer Comments <span class="meta-nav">&rarr;</span>', 'gummfw')); ?> 
 
\t \t \t \t </div> 
 
\t \t \t </div> <!-- .navigation --> 
 
\t \t <?php endif; // check for comment navigation ?> 
 

 

 
\t <?php elseif (!comments_open()): // this is displayed if comments are closed ?> 
 
\t \t \t 
 
\t <?php else: ?> 
 

 
\t <?php endif; ?> 
 
\t 
 
</div> 
 

 
<?php if (comments_open()) : ?> 
 
    <?php 
 
    add_filter('comment_form_default_fields', 'gummFilterFormDefaultFields'); 
 
    
 
    echo '<div class="bluebox-heading-wrap"><h3 class="bluebox-heading">' . __('Leave a reply', 'gummfw') . '</h3></div>'; 
 
    echo '<div class="bluebox-contact type-one">'; 
 

 
    comment_form(array(
 
     'title_reply' => '', 
 
     'id_submit' => 'button-submit', 
 
     'comment_notes_after' => '', 
 
     'comment_field' => '<textarea id="comment" name="comment" placeholder="' . __('Comment', 'gummfw') . '*" cols="45" rows="8" aria-required="true"></textarea>' 
 
    )); 
 
    echo '</div>'; 
 
    ?> 
 
<?php endif; // if you delete this the sky will fall on your head ?> 
 

 
<?php 
 
function gummFilterFormDefaultFields($fields) { 
 
    global $gummHtmlHelper; 
 
    
 
    $commenter = wp_get_current_commenter(); 
 
    $req = get_option('require_name_email'); 
 
    $aria_req = ($req ? " aria-required='true'" : ''); 
 
    
 
    $inputAtts = array(
 
     'author' => array(
 
      'id' => 'author', 
 
      'name' => 'author', 
 
      'type' => 'text', 
 
      'placeholder' => __('Name', 'gummfw'), 
 
      'value' => esc_attr($commenter['comment_author']), 
 
     ), 
 
     'email' => array(
 
      'id' => __('Email', 'gummfw'), 
 
      'name' => 'email', 
 
      'type' => 'text', 
 
      'placeholder' => __('Email', 'gummfw'), 
 
      'value' => esc_attr( $commenter['comment_author_email']), 
 
     ), 
 
     'url' => array(
 
      'id' => 'url', 
 
      'name' => 'url', 
 
      'type' => 'text', 
 
      'placeholder' => __('Website', 'gummfw'), 
 
      'value' => esc_attr($commenter['comment_author_url']), 
 
     ), 
 
    ); 
 
    
 
    foreach ($inputAtts as $type => &$atts) { 
 
     if ($req) { 
 
      $atts['placeholder'] .= '*'; 
 
      $atts['aria-required'] = 'true'; 
 
     } 
 
    } 
 
    
 
    $fields['author'] = '<input' . $gummHtmlHelper->_constructTagAttributes($inputAtts['author']) .' />'; 
 
    $fields['email'] = '<input' . $gummHtmlHelper->_constructTagAttributes($inputAtts['email']) .' />'; 
 
    $fields['url'] = '<input' . $gummHtmlHelper->_constructTagAttributes($inputAtts['url']) .' />'; 
 

 
    return $fields; 
 
} 
 
?>

答えて

0

あなたは一人でウェブサイトのフィールドにstr_replaceかにpreg_replaceを使用して試してみたいことがあります。

<?php 
 
\t // Do not delete these lines 
 
\t if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) 
 
\t \t die ('Please do not load this page directly. Thanks!'); 
 
\t 
 
\t $comments_by_type = separate_comments($comments); 
 
?> 
 

 
<div id="comments" class="comments-wrap"> 
 
    
 
\t <?php if (post_password_required()): ?> 
 
\t \t <p class="nopassword"><?php _e('This post is password protected. Enter the password to view any comments.', 'gummfw'); ?></p> 
 
\t \t </div><!-- #comments --> 
 

 
\t <?php 
 
\t \t return; 
 
\t \t endif; 
 
\t ?> 
 
\t 
 
\t <?php if (have_comments() && comments_open()): ?> 
 
     <div class="bluebox-heading-wrap"> 
 
      <h3 class="bluebox-heading"><?php comments_number(__('No Comments', 'gummfw'), __('One Comment', 'gummfw'), __('% Comments', 'gummfw'));?></h3> 
 
     </div> 
 
     
 
     <ol class="comment-list"> 
 
      <?php 
 
      wp_list_comments(array(
 
       'callback' => array(
 
        GummRegistry::get('Controller', 'Comments'), 
 
        'view' 
 
       ), 
 
      )); 
 
      ?> 
 
     </ol> 
 

 
\t \t <?php if (get_comment_pages_count() > 1 && get_option('page_comments')): // Are there comments to navigate through? ?> 
 
\t \t \t <div class="navigation"> 
 
\t \t \t \t <div class="nav-previous"> 
 
\t \t \t \t \t <?php previous_comments_link(__('<span class="meta-nav">&larr;</span> Older Comments', 'gummfw')); ?> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div class="nav-next"> 
 
\t \t \t \t \t <?php next_comments_link(__('Newer Comments <span class="meta-nav">&rarr;</span>', 'gummfw')); ?> 
 
\t \t \t \t </div> 
 
\t \t \t </div> <!-- .navigation --> 
 
\t \t <?php endif; // check for comment navigation ?> 
 

 

 
\t <?php elseif (!comments_open()): // this is displayed if comments are closed ?> 
 
\t \t \t 
 
\t <?php else: ?> 
 

 
\t <?php endif; ?> 
 
\t 
 
</div> 
 

 
<?php if (comments_open()) : ?> 
 
    <?php 
 
    add_filter('comment_form_default_fields', 'gummFilterFormDefaultFields'); 
 
    
 
    echo '<div class="bluebox-heading-wrap"><h3 class="bluebox-heading">' . __('Leave a reply', 'gummfw') . '</h3></div>'; 
 
    echo '<div class="bluebox-contact type-one">'; 
 

 
    comment_form(array(
 
     'title_reply' => '', 
 
     'id_submit' => 'button-submit', 
 
     'comment_notes_after' => '', 
 
     'comment_field' => '<textarea id="comment" name="comment" placeholder="' . __('Comment', 'gummfw') . '*" cols="45" rows="8" aria-required="true"></textarea>' 
 
    )); 
 
    echo '</div>'; 
 
    ?> 
 
<?php endif; // if you delete this the sky will fall on your head ?> 
 

 
<?php 
 
function gummFilterFormDefaultFields($fields) { 
 
    global $gummHtmlHelper; 
 
    
 
    $commenter = wp_get_current_commenter(); 
 
    $req = get_option('require_name_email'); 
 
    $aria_req = ($req ? " aria-required='true'" : ''); 
 
    
 
    $inputAtts = array(
 
     'author' => array(
 
      'id' => 'author', 
 
      'name' => 'author', 
 
      'type' => 'text', 
 
      'placeholder' => __('Name', 'gummfw'), 
 
      'value' => esc_attr($commenter['comment_author']), 
 
     ), 
 
     'email' => array(
 
      'id' => __('Email', 'gummfw'), 
 
      'name' => 'email', 
 
      'type' => 'text', 
 
      'placeholder' => __('Email', 'gummfw'), 
 
      'value' => esc_attr( $commenter['comment_author_email']), 
 
     ), 
 
     'url' => array(
 
      'id' => 'url', 
 
      'name' => 'url', 
 
      'type' => 'text', 
 
      'placeholder' => __('Website', 'gummfw'), 
 
      'value' => esc_attr($commenter['comment_author_url']), 
 
     ), 
 
    ); 
 
    
 
    foreach ($inputAtts as $type => &$atts) { 
 
     if ($req) { 
 
      $atts['placeholder'] .= '*'; 
 
      $atts['aria-required'] = 'true'; 
 
     } 
 
    } 
 
    
 
    $fields['author'] = '<input' . $gummHtmlHelper->_constructTagAttributes($inputAtts['author']) .' />'; 
 
    $fields['email'] = '<input' . $gummHtmlHelper->_constructTagAttributes($inputAtts['email']) .' />'; 
 
    
 
    // HERE YOU MAY WANT TO DO EITHER STRING REPLACEMENT OR USE REGEX: 
 
    $fields['url'] = '<input' . str_replace("*", "", $gummHtmlHelper->_constructTagAttributes($inputAtts['url'])) .' />'; 
 

 
    return $fields; 
 
} 
 
?>

関連する問題