Support

Account

Home Forums Bug Reports Name Field is lots of data Reply To: Name Field is lots of data

  • I switched the theme to test out the plugin. Default theme worked, so that told me something in my theme was altering the code. Through a process of elimination in my functions.php file, I found that this function was causing it to alter the name field:

    add_filter('get_the_excerpt', 'end_with_sentence');
    
    function end_with_sentence($excerpt) {
      $allowed_end = array('.', '!', '?', '...');
      $exc = explode( ' ', $excerpt );
      $found = false;
      $last = '';
      while ( ! $found && ! empty($exc) ) { 
        $last = array_pop($exc);
        $end = strrev( $last );
        $found = in_array( $end{0}, $allowed_end );
      }
      return (! empty($exc)) ? $excerpt.'</p><a class="cta-link" href="'. get_permalink($post->ID) . '" title="'. __( 'Read', 'wpBASEtheme' ) . get_the_title($post->ID).'">'. __( 'View Full Post <span>e</span>', 'wpBASEtheme' ) .'</a>' : rtrim(implode(' ', $exc) . ' ' .$last);
    }
    
    add_filter('wp_insert_post_data', 'end_with_sentence_on_save', 20, 2);
    
    function end_with_sentence_on_save($data, $postarr) {
      if ( ! empty( $data['post_content'] ) && $data['post_status'] != 'inherit' && $data['post_status'] != 'trash' ) {
        $text = strip_shortcodes( $data['post_content'] );
        $text = apply_filters('the_content', $text );
        $text = str_replace(']]>', ']]>', $text );
        $excerpt_length = apply_filters('excerpt_length', 55);
        $data['post_excerpt'] = wp_trim_words($text, $excerpt_length, '');
      } else {
        return $data;
      }
      $allowed_end = array('.', '!', '?', '...');
      $exc = explode(' ', $data['post_excerpt']);
      $found = false;
      $last = '';
      while ( ! $found && ! empty($exc) ) { 
        $last = array_pop($exc);
        $end = strrev( $last );
        $found = in_array( $end{0}, $allowed_end );
      }
      if (! empty($exc)) $data['post_excerpt'] = rtrim(implode(' ', $exc) . ' ' .$last);
      return $data; 
    }

    So there’s no need to worry about this issue any longer.