Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#936 - comment confirmation message #1020

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static function init() {
}
}

// Register the field to capture the "subject to moderation." message for amp comments.
add_action( 'admin_init', array( __CLASS__, 'register_discussion_setting' ) );

add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );

/*
Expand Down Expand Up @@ -520,7 +523,7 @@ public static function add_amp_comment_form_templates() {
?>
<div submit-success>
<template type="amp-mustache">
<?php esc_html_e( 'Your comment has been posted, but may be subject to moderation.', 'amp' ); ?>
<?php echo esc_html( self::get_comment_moderation_notice() ); ?>
</template>
</div>
<div submit-error>
Expand All @@ -531,6 +534,48 @@ public static function add_amp_comment_form_templates() {
<?php
}

/**
* Register the setting to capture the "subject to moderation." message for amp comments.
*
* @since 0.7
*/
public static function register_discussion_setting() {
register_setting( 'discussion', 'amp_comment_notice', 'sanitize_text_field' );
add_settings_field( 'amp_comment_notice', 'Comment Notice', array( __CLASS__, 'comment_moderation_field' ), 'discussion' );
}

/**
* Get the moderation notice for AMP comment submission.
*
* @since 0.7
*/
public static function get_comment_moderation_notice() {
$default = __( 'Your comment has been posted and will show shortly.', 'amp' );
$message = trim( get_option( 'amp_comment_notice' ) );
if ( empty( $message ) ) {
$message = $default;
}
return $message;
}

/**
* Output the field to capture the comment moderation message for amp comments.
*
* @since 0.7
*/
public static function comment_moderation_field() {
?>
<p>
<label for="amp_comment_notice">
<?php echo esc_html__( 'This message is to indicate to a user that the comment was posted, but there will be a delay in displaying it.', 'amp' ); ?>
</label>
</p>
<p>
<textarea name="amp_comment_notice" id="amp_comment_notice" rows="3" cols="50" class="large-text code"><?php echo esc_html( self::get_comment_moderation_notice() ); ?></textarea>
</p>
<?php
}

/**
* Prepends template hierarchy with template_dir for AMP paired mode templates.
*
Expand Down