Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Last active October 5, 2017 23:31
Show Gist options
  • Save rafaehlers/61782e471aa70ed86467b0660cc30423 to your computer and use it in GitHub Desktop.
Save rafaehlers/61782e471aa70ed86467b0660cc30423 to your computer and use it in GitHub Desktop.
Filter to modify the review form
<?php
/** The defaults below are just for reference to use with the filter:
$defaults = array(
'fields' => $fields,
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Review', 'noun', 'gravityview-ratings-reviews' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
// This filter is documented in wp-includes/link-template.php
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'gravityview-ratings-reviews' ), wp_login_url( $permalink ) ) . '</p>',
// This filter is documented in wp-includes/link-template.php
'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'gravityview-ratings-reviews' ), get_edit_user_link(), $user_identity, wp_logout_url( $permalink ) ) . '</p>',
'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.', 'gravityview-ratings-reviews' ) . ( $req ? $required_text : '' ) . '</p>',
'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'gravityview-ratings-reviews' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
'id_form' => 'commentform',
'id_submit' => 'submit',
'name_submit' => 'submit',
'title_reply' => __( 'Review this entry', 'gravityview-ratings-reviews' ),
'title_reply_to' => __( 'Reply to %s', 'gravityview-ratings-reviews' ),
'cancel_reply_link' => __( 'Cancel reply', 'gravityview-ratings-reviews' ),
'label_submit' => __( 'Post Review', 'gravityview-ratings-reviews' ),
'format' => 'xhtml',
// The message shown to users who try to add two reviews to the same entry.
'limited_to_one_review' => '<p class="limited-to-one-review">' . sprintf( __( 'You have already reviewed this entry.', 'gravityview-ratings-reviews' ) ) . '</p>',
);
*/
add_filter( 'gv_ratings_reviews_review_form_settings', 'gv_modify_review_form_labels',10,1);
function gv_modify_review_form_labels($defaults){
$new_defaults = array(
'title_reply' => 'You are about to review this entry',
'label_submit' => 'Submit your review',
);
$defaults = array_replace($defaults, $new_defaults);
return $defaults;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment