File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -947,9 +947,20 @@ class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
947947 // @codingStandardsIgnoreStart
948948 echo $ content ;
949949 // @codingStandardsIgnoreEnd
950- ?>
951- <input type="hidden" name="referrer" value="<?php the_permalink (); ?> ">
952- <input type="hidden" name="_referrer_id" value="<?php echo esc_attr ( get_the_id () ); ?> ">
950+
951+ if ( is_archive () ) :
952+ global $ wp ;
953+ $ current_url = home_url ( $ wp ->request );
954+ if ( empty ( get_option ( 'permalink_structure ' ) ) ) {
955+ $ current_url = add_query_arg ( $ wp ->query_string , '' , home_url ( $ wp ->request ) );
956+ } ?>
957+ <input type="hidden" name="referrer" value="<?php echo esc_attr ( $ current_url ); ?> ">
958+ <input type="hidden" name="_referrer_id" value="archive">
959+ <input type="hidden" name="_referrer_archive_title" value="<?php echo esc_attr ( get_the_archive_title () ); ?> ">
960+ <?php else : ?>
961+ <input type="hidden" name="referrer" value="<?php the_permalink (); ?> ">
962+ <input type="hidden" name="_referrer_id" value="<?php echo esc_attr ( get_the_id () ); ?> ">
963+ <?php endif ; ?>
953964 <input type="hidden" name="_form_id" value="<?php echo esc_attr ( $ id ); ?> ">
954965</form>
955966<?php
Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ function wplf_validate_additional_fields( $return ) {
114114 }
115115 $ additional_fields = array_filter ( $ additional_fields ); // get rid of the empty keys
116116
117+ // support archive referrer, do not keep field _referrer_archive_title as a additional field
118+ if ( 'archive ' === $ all_fields ['_referrer_id ' ] && array_key_exists ( '_refererr_archive_title ' , $ additional_fields ) ) {
119+ unset( $ additional_fields ['_referrer_archive_title ' ] );
120+ }
121+
117122 if ( ! empty ( $ additional_fields ) ) {
118123 $ return ->ok = 0 ;
119124 $ return ->error = __ ( 'Additional fields are present. ' , 'wp-libre-form ' );
You can’t perform that action at this time.
0 commit comments