. '_wordpress_field', $label . $this->getCheckbox( true ), $submit_field ); return implode( '', [ $field, $submit_field ] ); } /** * @param false $checked * * @return string */ public function getCheckbox( bool $checked = false ): string { $required = Template::get( 'Front/Elements/required', [ 'message' => $this->getRequiredText() ] ); return Template::get( 'Front/Comment/checkbox', [ 'name' => $this->getFieldTag(), 'label' => implode( ' ', [ $this->getCheckboxText(), $required ] ), 'checked' => $checked, 'class' => 'comment-form-' . Plugin::PREFIX, ] ); } public function checkPost() { if ( isset( $_POST[ $this->getFieldTag() ] ) ) { return; } $message = Template::get( 'Front/Elements/error', [ 'message' => $this->getErrorText() ] ); wp_die( wp_kses( $message, \WPGDPRC\Utils\AdminHelper::getAllowedHTMLTags() ), esc_html( __( 'Comment Submission Failure', 'wp-gdpr-compliance' ) ), [ 'back_link' => true ] ); } /** * @param int $comment_id */ public function addAcceptedDateToMeta( int $comment_id = 0 ) { if ( empty( $_POST[ $this->getFieldTag() ] ) ) { return; } if ( empty( $comment_id ) ) { return; } add_comment_meta( $comment_id, '_' . $this->getFieldTag(), time() ); } /** * @param array $columns * * @return array */ public function acceptedDateColumnInCommentOverview( array $columns = [] ): array { $columns[ $this->getFieldTag() . '-date' ] = esc_html( apply_filters( Plugin::PREFIX . '_accepted_date_column_in_comment_overview', _x( 'GDPR accepted on', 'admin', 'wp-gdpr-compliance' ) ) ); return $columns; } /** * @param string $column * @param int $comment_id * * @return string */ public function acceptedDateInCommentOverview( string $column = '', int $comment_id = 0 ): string { if ( $column !== $this->getFieldTag() . '-date' ) { return $column; } $date = get_comment_meta( $comment_id, '_' . $this->getFieldTag(), true ); $value = $this->getAcceptedDate( $date ); echo esc_html( apply_filters( Plugin::PREFIX . '_accepted_date_in_comment_overview', $value, $comment_id ) ); return $column; } }