Forum Replies Created

Viewing 15 replies - 16 through 30 (of 374 total)
  • It occurred to me that it might not be the best idea to use files that are not from WP. I just deactivated and deleted the plugin, then re-uploaded it from the WP site. On activation, I’m relieved to report that everything is now in the zip file, and the plugin works correctly once again.

    (Please note that this is not to be construed as a slight against brogr.)

    re:

    Unfortunately, no one making the decisions will see your post here.

    Considering that this forum is called “Requests and Feedback”, it seems odd that people making decisions won’t see posts here. This is quite disheartening news. Perhaps it would be advisable to direct the decision makers toward this forum, or at least to make sure they are aware of its existence. Otherwise, change the name to “Requests and Feedback to be Filed Under G”.

    I am with ecollart here. Fewer updates unless they are for security reasons, please.

    Thank you, brogr!

    After being unable to access the WP Media section and seeing the message “There has been a critical error on your website” in my admin area. To assess what was causing the critical error, I had to disable all plugins and then enable them one by one, to learn that it was “Upgrade for Unattach and Re-attach Media Attachments” causing the nightmare.

    As a result, it was with great regret that this previously great plugin has now been disabled until the error is fixed.

    Thread Starter ejm

    (@llizard)

    Thank you both for pointing to the core.trac.wordpress area.

    Please note that this phrase appears in several of the WordPress themes (I confess that I didn’t check them all….) and keeps appearing with its incorrect punctuation over and over. ie: as far as I understand, these are not non-bundled themes. They are the themes that are automatically loaded with WP.

    In twenty twelve theme, the coding for it is NOT in a core file. It is in the functions file.

    Thread Starter ejm

    (@llizard)

    Thank you, Jarret.

    Like sanderrrrr, I have also noticed a marked increase in the number of spam comments that are getting through. I am using V2 for comments and have “Show login Captcha after how many failed attempts” set to 0 = show always.

    (I don’t know what “create a review with verifying captcha” means in the question to the original poster.)

    • This reply was modified 5 years, 1 month ago by ejm.
    • This reply was modified 5 years, 1 month ago by ejm.
    Thread Starter ejm

    (@llizard)

    Yes, I did mean a bicycle ride.

    The bike ride was good, but I still don’t understand why   is still giving me grief either. I’ll keep picking away at it. I bet it’s something as simple as a misplaced semi-colon! (I know what you mean about how easy it is to miss those. I’ve learned from experience to check for their absence whenever I see an error message saying something like unexpected }….)

    Thread Starter ejm

    (@llizard)

    Thank you again for your reply.

    Getting mixed up with this stuff is par for the course when starting out. When you keep at it it starts to make sense eventually.

    I thought it was making sense, and it’s true that I’m getting glimmerings. But I will have to stare and re-stare at this. I have still failed to be able remove existing  ‘s except by going into phpMyAdmin.

    But I did manage to get this code to be accepted by noticing that $webname = '' was missing its ending semicolon: $webname = '';

    if ( isset( $_POST['webname'])) {
       $webname = trim( html_entity_decode( wp_filter_nohtml_kses( $_POST[webname])), " \t\n\r\0\x0B\xC2\xA0");
    } else {
       $webname = '';
    }
    add_comment_meta( $comment_id, 'webname', $webname ); 

    So many things to go wrong…. I think I’ll go on a bike ride and maybe, just maybe, it will clear what’s left of my mind, and I’ll suddenly get a breakthrough. ??

    • This reply was modified 5 years, 5 months ago by ejm.
    Thread Starter ejm

    (@llizard)

    re:

    Heh, I was trying to get you to work out the final solution to the parentheses quandary by dropping a bunch of hints. One usually learns more that way…

    If it’s any consolation, I did see that the hints were being dropped but I had managed to get myself so mixed up that I failed to get beyond knowing there were arrows pointing to the flashing words “this is a hint”. (I still think I’m getting an inkling about this though…)

    Remarkably, I’m not at all uncomfortable with phpMyAdmin and have managed to remove the extraneous   values for $webname. Thank you for spelling out for me which table to save first (I’m a big fan of “save early, save often”) and then remove the offending values.

    I had started to grow attached to the tilde but still decided to returne to the parentheses to go around $webname. When I did that in the functions file, I also removed the extraneous part at the end that was simply a repeat of the add_comment_meta_values($comment_id) function….

    /*.......
     from wpengineer.com/2214/adding-input-fields-to-the-comment-form/
    ....*/ 
    function save_comment_meta_data( $comment_id ) {
        add_comment_meta( $comment_id, 'webname', $_POST[ 'webname' ] );
    }
    add_action( 'comment_post', 'save_comment_meta_data' );

    To test that everything was working, I added a webname value to a comment that didn’t have one. Now I cannot seem to remove it – except via phpMyAdmin. It insists on holding onto the space. (Oh oh….)

    What this means, I’m assuming, is that I have not managed to get the $webname to unset. Am I right that here is my clue for fixing this?

    When we use isset() like this:
    if ( isset( $webname ) && '' != $webname ) {
    it serves to prevent unassigned variable warnings when we do ” != $webname should $webname not be set for any reason.

    Here is the coding I tried, but it does not make it so that the parentheses disappear, nor does it follow the instruction to remove the   (because, I guess, the empty value is in the DB???).

    
    function add_comment_meta_values($comment_id) {
       if ( ( isset( $_POST['webname'] ) ) && ( $_POST['webname'] != '') ) {
    	$webname = wp_filter_nohtml_kses($_POST['webname']);
            add_comment_meta($comment_id, 'webname', $webname);
        } 
       if (($_POST[ 'webname' ] = ' ') || ($_POST[ 'webname' ] = ' ')) {
    	$webname = '';	
       } 
    }
    add_action ('comment_post', 'add_comment_meta_values', 1);

    I was going to try using your array somehow but, well, you know… I’m barely able to tread water to keep breathing as it is.

    • This reply was modified 5 years, 5 months ago by ejm.
    • This reply was modified 5 years, 5 months ago by ejm.
    Thread Starter ejm

    (@llizard)

    re:

    Remember that comment author link output occurs during a GET request, so there will be nothing in the global $_POST.

    I’m guessing that this explains (sort of) why a webname value that is removed in WP_admin, after being entered from outset, remains as ' ', rather than disappearing.

    Because I have been unable to figure out how to remove the parentheses from those newly empty value fields, I’ve compromised by changing the parentheses to a single tilde: $author .= esc_html(" ~ $webname");. This way, it doesn’t look ridiculous to see “Commenter’sName ~” instead of “Commenter’sName ()”

    I’m completely unclear where to put

    if ($webname = '') || ($webname = ' ') {
      !isset( $webname ) 
    }

    (I don’t even know if !isset is an actual thing….)

    OR

    if ($webname = ' ') {
      $_POST['webname'] = ''; 
    }

    Also, if $webname = '', is it not possible to display the emptiness with emptiness, rather than a tilde (or as before, inside parentheses)?

    I realize that you may well have answered this already; please excuse my obtuseness.
    Babysteps! Babysteps! Thank you again for all your help.

    • This reply was modified 5 years, 5 months ago by ejm.
    Thread Starter ejm

    (@llizard)

    Sigh… I spoke to soon. Back to the drawing board….

    The parentheses are still appearing.

    Thread Starter ejm

    (@llizard)

    Please excuse me for replying to myself….

    It’s a miracle! I think I got it… in the function, attach_websitename_to_author( $author ), I have to use if( isset( $_POST['webname'] ) ) instead of if ( $webname ). This is so exciting!

    Thank you once again for all your help. It is most appreciated.

    function comment_edit_function( $comment_id )
    {
        if( isset( $_POST['webname'] ) )
          update_comment_meta( $comment_id, 'webname', esc_attr( $_POST['webname'] ) );
    	else 
    	$_POST['webname'] = ' ';
    }
    
    add_filter( 'get_comment_author_link', 'attach_websitename_to_author' );
    
    function attach_websitename_to_author( $author ) {
        $webname = get_comment_meta( get_comment_ID(), 'webname', true );
    	if( isset( $_POST['webname'] ) )
    //    if ( $webname )
            $author .= " ($webname)";
    	elseif ($_POST['webname'] = ' ')
    		$author .= " $webname";
    //		$author .= " ";
    		return $author;
     }
    Thread Starter ejm

    (@llizard)

    Take your time, better to fully grasp what’s going on than to knock something out.

    Once again, you are wise.

    Now that I’ve got it working but am pretty certain the first set of coding falls under the category of not quite fully grasping what is going on, I’ve revised it in my WP test site:

    As you suspected would happen somewhere higher in the thread, now the website variable is showing the parentheses, even when the variable is not filled in.

    I’ve tried various riffs on the following, all producing the parentheses. What am I missing? Because there must be a way to instruct the page to show the parentheses only if that variable is filled in. Shouldn’t there?

    
    // try to show parentheses around webname ONLY if it is filled in
     
    function comment_edit_function( $comment_id )
    {
        if( isset( $_POST['webname'] ) )
          update_comment_meta( $comment_id, 'webname', esc_attr( $_POST['webname'] ) );
        else
        $_POST['webname'] = ' ';
    }
    add_filter( 'get_comment_author_link', 'attach_websitename_to_author' );
     
    function attach_websitename_to_author( $author ) {
        $webname = get_comment_meta( get_comment_ID(), 'webname', true );
        if ( $webname )
            $author .= " ($webname)";
        elseif ($_POST['webname'] = ' ')
            $author .= " $webname";
       return $author;
     }

    Here is the full coding:
    pastebin [dot] com/QHNXTwKX

    Thread Starter ejm

    (@llizard)

    That took a lot less time than expected! Good idea to add define( 'WP_DEBUG', true ); in my test WP’s config file. That was most helpful. The first thing that came up was a very easy fix on another part of the comment customizaton, once I realized the variable had to be defined inside the curly bracket of the function…

    Notice: Undefined variable: commenter in ../wp-content/themes/my-child-theme/functions.php on line 140

    function modify_comment_form_fields($fields){
    	$commenter = 0;
        $fields['url'] = '<p class="comment-form-url"><label for="url">' . __( 'Path on Web', 'domainreference' ) . '</label>' .
        '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .

    I was also missing opening curly bracket after if ( isset ( $_POST[‘webname’] )

    /*..........
    Update comment meta data from comment editing screen 
     ....*/ 
    function webname_comment_edit_meta_fields( $comment_id ) {
        if ( isset( $_POST['webname'] ) && '' != $_POST['webname']) {
            update_comment_meta( $comment_id, 'webname', esc_attr( $_POST['webname'] ) );
        }
    
    }

    But the main problem and the reason for the inability to edit was because I had the add-action placed erroneously inside final curly bracket of the webname_comment_edit_meta_fields( $comment_id ) function!

    add_action( 'edit_comment', 'webname_comment_edit_meta_fields' );

    Once again, many many thanks for your patient and very helpful answers, bcworkz. It’s thrilling to be able to mark this as resolved.

    Here is the full coding I ended up with (that probably still needs cleaning up, but at least it’s working!):

    /*...............
    add a field to the comment form
    ...............*/
    function add_comment_fields($newfield) {
        $newfield['webname'] = '<p class="comment-form-author" title="this field is optional"><label for="webname">' . __( 'Your Site\'s Name' ) . '</label>' .
            '<input id="webname" name="webname" type="text" size="30" /></p>';
        return $newfield;
    }
    add_filter('comment_form_default_fields','add_comment_fields');
    
    function add_comment_meta_values($comment_id) {
       if ( ( isset( $_POST['webname'] ) ) && ( $_POST['webname'] != '') ) {
    	$webname = wp_filter_nohtml_kses($_POST['webname']);
            add_comment_meta($comment_id, 'webname', $webname);
        } 
    	else    
    		$webname = '&nbsp;';
    }
    add_action ('comment_post', 'add_comment_meta_values', 1);
    
    function comment_edit_function( $comment_id )
    {
        if( isset( $_POST['webname'] ) )
          update_comment_meta( $comment_id, 'webname', esc_attr( $_POST['webname'] ) );
        else 
    		$_POST['webname'] = '&nbsp;';
    }
    
    add_filter( 'get_comment_author_link', 'attach_websitename_to_author' );
    
    function attach_websitename_to_author( $author ) {
        $webname = get_comment_meta( get_comment_ID(), 'webname', true );
        if ( $webname )
            $author .= " ($webname)";
    	elseif ($webname = '')
    		$author .= " $webname";
       return $author;
     }
    
    // Register meta box on comment edit screen
    function webname_comment_edit_add_meta_box() {
        add_meta_box( 'title', __( 'website name', 'text-domain' ), 'webname_comment_meta_box', 'comment', 'normal', 'high' );
    }
    add_action( 'add_meta_boxes_comment', 'webname_comment_edit_add_meta_box' );
    
    // Callback function for displaying the comment meta box.
    function webname_comment_meta_box( $comment ) {
        $webname = get_comment_meta( $comment->comment_ID, 'webname', true );
        wp_nonce_field( 'webname_comment_fields_update', 'webname_comment_fields_update', false );
        ?>
        <p>
            <label for="webname"><?php _e( 'Commenter\'s Site Name', 'text-domain' ); ?></label>
            <input type="text" name="webname" value="<?php echo esc_attr( $webname ); ?>" class="widefat" />
        </p><?php
    }
    
    /*..........
    Update comment meta data from comment editing screen 
     ....*/ 
    function webname_comment_edit_meta_fields( $comment_id ) {
        if ( isset( $_POST['webname'] ) && '' != $_POST['webname']) {
            update_comment_meta( $comment_id, 'webname', esc_attr( $_POST['webname'] ) );
        }
    
    }
    add_action( 'edit_comment', 'webname_comment_edit_meta_fields' );
    
    /*.......
     from wpengineer.com/2214/adding-input-fields-to-the-comment-form/
     ....*/ 
    function save_comment_meta_data( $comment_id ) {
        add_comment_meta( $comment_id, 'webname', $_POST[ 'webname' ] );
    }
    add_action( 'comment_post', 'save_comment_meta_data' );
    
    // many thanks to bcworkz for help in fixing adding custom field to comments www.ads-software.com/support/topic/adding-and-editing-non-required-field-in-comments/
Viewing 15 replies - 16 through 30 (of 374 total)