-
-
Save tommcfarlin/567aabec289c7e6bdbcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php $comments = $this->load_post_comments(); ?> | |
| <?php foreach ( $comments as $comment ) { ?> | |
| <label for="acme-comment-status-<?php echo $comment->comment_ID ?>"> | |
| <input type="checkbox" name="acme-comment-status[<?php echo $comment->comment_ID ?>]" id="acme-comment-status-<?php echo $comment->comment_ID ?>" /> | |
| This comment has received a reply. | |
| </label> | |
| <p> | |
| <em><?php echo $comment->comment_author; ?></em>: | |
| <?php echo $comment->comment_content; ?> | |
| </p> | |
| <?php } ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'save_post', 'acme_comment_status_save_post' ); | |
| /** | |
| * @param int $post_id The ID of the post that's currently being edited. | |
| */ | |
| function acme_comment_status_save_post( $post_id ) { | |
| /* Code to verify that the user has permission to save the post has been removed | |
| * for brevity. | |
| */ | |
| // If there are any values saved in the 'Published' input, save them | |
| if ( ! empty( $_POST['acme-comment-status'] ) ) { | |
| /* Additional sanitization should occur here before actually saving the array. */ | |
| update_post_meta( $post_id, 'acme-comment-status', $_POST['acme-comment-status'] ); | |
| } | |
| /* Code for deleting the post value has been removed for brevity. */ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php $comments = $this->load_post_comments(); ?> | |
| <?php foreach ( $comments as $comment ) { ?> | |
| <?php | |
| // Retrieve the comments and determine if the ID of the current comment exists in the array | |
| $comments = get_post_meta( get_the_ID(), 'authors-commentary-comments', true ); | |
| $is_checked = array_key_exists( $comment->comment_ID, $comments ) ? 'checked="checked"' : ''; | |
| ?> | |
| <label for="acme-comment-status-<?php echo $comment->comment_ID ?>"> | |
| <input type="checkbox" name="acme-comment-status[<?php echo $comment->comment_ID ?>]" id="acme-comment-status-<?php echo $comment->comment_ID ?>" <?php echo $is_checked; ?> /> | |
| This comment has received a reply. | |
| </label> | |
| <p> | |
| <em><?php echo $comment->comment_author; ?></em>: | |
| <?php echo $comment->comment_content; ?> | |
| </p> | |
| <?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment